-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #608 from caioavidal/spells
Add BloodRange spell and fix some combat stuff
- Loading branch information
Showing
15 changed files
with
196 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using NeoServer.Game.Combat.Spells; | ||
using NeoServer.Game.Common; | ||
using NeoServer.Game.Common.Contracts.Creatures; | ||
using NeoServer.Game.Common.Creatures; | ||
|
||
namespace NeoServer.Extensions.Spells.Support.Knight; | ||
|
||
public class BloodRage : Spell<Food> | ||
{ | ||
public override uint Duration => 10_000; | ||
public override ConditionType ConditionType => ConditionType.Strengthened; | ||
public override EffectT Effect => EffectT.GlitterBlue; | ||
|
||
public override bool OnCast(ICombatActor actor, string words, out InvalidOperation error) | ||
{ | ||
error = InvalidOperation.None; | ||
|
||
if (actor is not IPlayer player) return false; | ||
|
||
player.AddSkillBonus(SkillType.Axe, (sbyte)Math.Abs(player.Skills[SkillType.Axe].Level * 0.35)); | ||
player.AddSkillBonus(SkillType.Sword, (sbyte)Math.Abs(player.Skills[SkillType.Axe].Level * 0.35)); | ||
player.AddSkillBonus(SkillType.Club, (sbyte)Math.Abs(player.Skills[SkillType.Axe].Level * 0.35)); | ||
player.AddSkillBonus(SkillType.Fist, (sbyte)Math.Abs(player.Skills[SkillType.Axe].Level * 0.35)); | ||
|
||
actor.DisableShieldDefense(); | ||
actor.IncreaseDamageReceived(15); | ||
return true; | ||
} | ||
|
||
public override void OnEnd(ICombatActor actor) | ||
{ | ||
if (actor is not IPlayer player) return; | ||
|
||
player.RemoveSkillBonus(SkillType.Axe, (sbyte)Math.Abs(player.Skills[SkillType.Axe].Level * 0.35)); | ||
player.RemoveSkillBonus(SkillType.Sword, (sbyte)Math.Abs(player.Skills[SkillType.Axe].Level * 0.35)); | ||
player.RemoveSkillBonus(SkillType.Club, (sbyte)Math.Abs(player.Skills[SkillType.Axe].Level * 0.35)); | ||
player.RemoveSkillBonus(SkillType.Fist, (sbyte)Math.Abs(player.Skills[SkillType.Axe].Level * 0.35)); | ||
|
||
actor.EnableShieldDefense(); | ||
actor.DecreaseDamageReceived(15); | ||
|
||
base.OnEnd(actor); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,5 +24,6 @@ public enum CooldownType | |
Awaken, | ||
Advertise, | ||
WalkAround, | ||
UseItem | ||
UseItem, | ||
SupportSpell, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
tests/NeoServer.Game.Creatures.Tests/Combat/CombatTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using FluentAssertions; | ||
using NeoServer.Game.Common.Combat.Structs; | ||
using NeoServer.Game.Common.Creatures.Players; | ||
using NeoServer.Game.Common.Item; | ||
using NeoServer.Game.Creatures.Player.Inventory; | ||
using NeoServer.Game.Tests.Helpers; | ||
using NeoServer.Game.Tests.Helpers.Player; | ||
using Xunit; | ||
|
||
namespace NeoServer.Game.Creatures.Tests.Combat; | ||
|
||
public class CombatTests | ||
{ | ||
[Fact] | ||
public void Player_Gets_More_Damage_When_Has_Damage_Percentage_Increased() | ||
{ | ||
//arrange | ||
var victim = PlayerTestDataBuilder.Build(hp: 1000); | ||
var attacker = PlayerTestDataBuilder.Build(); | ||
|
||
//act | ||
victim.ReceiveAttack(attacker, new CombatDamage(100, DamageType.Physical)); | ||
|
||
//assert | ||
victim.HealthPoints.Should().Be(900); | ||
|
||
//act | ||
victim.IncreaseDamageReceived(100); | ||
victim.ReceiveAttack(attacker, new CombatDamage(100, DamageType.Physical)); | ||
|
||
//assert | ||
victim.HealthPoints.Should().Be(700); | ||
|
||
//act | ||
victim.DecreaseDamageReceived(100); | ||
victim.ReceiveAttack(attacker, new CombatDamage(100, DamageType.Physical)); | ||
|
||
//assert | ||
victim.HealthPoints.Should().Be(600); | ||
} | ||
|
||
[Fact] | ||
public void Player_Does_Not_Block_Attack_When_Shield_Defense_Is_Disabled() | ||
{ | ||
//arrange | ||
var inventory = InventoryTestDataBuilder.Build(); | ||
var shield = ItemTestData.CreateBodyEquipmentItem(7, "", "shield"); | ||
shield.Metadata.Attributes.SetAttribute(ItemAttribute.Defense, byte.MaxValue); | ||
|
||
inventory.AddItem(shield, Slot.Right); | ||
|
||
var victim = PlayerTestDataBuilder.Build(hp: 1000, capacity: uint.MaxValue ); | ||
victim.AddInventory(inventory); | ||
|
||
var attacker = PlayerTestDataBuilder.Build(); | ||
|
||
//act | ||
victim.ReceiveAttack(attacker, new CombatDamage(1, DamageType.Melee)); | ||
|
||
//assert | ||
victim.HealthPoints.Should().Be(1000); | ||
|
||
//act | ||
victim.DisableShieldDefense(); | ||
victim.ReceiveAttack(attacker, new CombatDamage(1, DamageType.Melee)); | ||
|
||
//assert | ||
victim.HealthPoints.Should().Be(999); | ||
|
||
//act | ||
victim.EnableShieldDefense(); | ||
victim.ReceiveAttack(attacker, new CombatDamage(1, DamageType.Melee)); | ||
|
||
//assert | ||
victim.HealthPoints.Should().Be(999); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters