diff --git a/HDTTests/BoardDamage/BoardCardTest.cs b/HDTTests/BoardDamage/BoardCardTest.cs index 522024d07..987d11a45 100644 --- a/HDTTests/BoardDamage/BoardCardTest.cs +++ b/HDTTests/BoardDamage/BoardCardTest.cs @@ -181,7 +181,7 @@ public void Attack_WeaponWithWindfuryOneHitLeft() [DataRow(CardIds.Collectible.Shaman.WalkingMountain, DisplayName = "Walking Mountain")] public void Attack_MegaWindfury(string cardId) { - var eb = new EntityBuilder(cardId, 4, 8).Windfury().Charge().InPlay(); + var eb = new EntityBuilder(cardId, 4, 8).MegaWindfury().Charge().InPlay(); Assert.AreEqual(16, eb.ToBoardCard().Attack); Assert.AreEqual(16, eb.Exhausted().ToBoardCard(false).Attack); diff --git a/HDTTests/BoardDamage/BoardHeroTest.cs b/HDTTests/BoardDamage/BoardHeroTest.cs index c6a402c26..a2e56126c 100644 --- a/HDTTests/BoardDamage/BoardHeroTest.cs +++ b/HDTTests/BoardDamage/BoardHeroTest.cs @@ -112,5 +112,37 @@ public void HeroHasWindfuryWithWeapon() true); Assert.AreEqual(4, hero.Attack); } + + [TestMethod] + public void HeroGotWindfuryFromMinion() + { + var hero = new BoardHero( + _hero.Attack(1).Windfury().ToEntity(), + null, + true + ); + Assert.AreEqual(hero.Attack, 2); + } + + [TestMethod] + public void WindfuryHeroAttackedOnce() + { + var hero = new BoardHero( + _hero.Attack(1).Windfury().AttacksThisTurn(1).ToEntity(), + null, + true); + Assert.AreEqual(1, hero.Attack); + } + + [TestMethod] + public void HeroGotWindfuryFromMinionAndHasSingleChargeWeapon() + { + var hero = new BoardHero( + _hero.Attack(7).Windfury().ToEntity(), + _weapon.Attack(6).Damage(1).ToEntity(), + true + ); + Assert.AreEqual(8, hero.Attack); + } } } diff --git a/HDTTests/BoardDamage/TestHelper.cs b/HDTTests/BoardDamage/TestHelper.cs index dc6d6c0d5..137a4fbfb 100644 --- a/HDTTests/BoardDamage/TestHelper.cs +++ b/HDTTests/BoardDamage/TestHelper.cs @@ -102,6 +102,12 @@ public EntityBuilder Windfury() return this; } + public EntityBuilder MegaWindfury() + { + _instance.SetTag(GameTag.WINDFURY, 3); + return this; + } + public EntityBuilder InPlay() { _instance.SetTag(GameTag.ZONE, (int)Zone.PLAY); diff --git a/Hearthstone Deck Tracker/Utility/BoardDamage/BoardCard.cs b/Hearthstone Deck Tracker/Utility/BoardDamage/BoardCard.cs index 56dd36e81..cbd27946e 100644 --- a/Hearthstone Deck Tracker/Utility/BoardDamage/BoardCard.cs +++ b/Hearthstone Deck Tracker/Utility/BoardDamage/BoardCard.cs @@ -40,7 +40,7 @@ public BoardCard(Entity e, bool active = true) Silenced = e.GetTag(SILENCED) == 1; Charge = e.GetTag(CHARGE) == 1; Windfury = e.GetTag(WINDFURY) == 1; - MegaWindfury = (e.CardId == HearthDb.CardIds.NonCollectible.Neutral.MimironsHead_V07Tr0NToken || e.CardId == HearthDb.CardIds.Collectible.Shaman.WalkingMountain); + MegaWindfury = e.GetTag(MEGA_WINDFURY) == 1 || e.GetTag(WINDFURY) == 3; AttacksThisTurn = e.GetTag(NUM_ATTACKS_THIS_TURN); _dormant = e.GetTag(DORMANT) == 1; _isTitan = e.GetTag(TITAN) == 1; @@ -127,6 +127,10 @@ private bool IsAbleToAttack(bool active, bool isWeapon) // newly played card could be given charge return Charge && AttacksThisTurn == 0; } + if(AttacksThisTurn == AttacksPerTurn) + { + return false; + } // sometimes cards seem to be in wrong zone while in play, // these cards don't become exhausted, so check attacks. if(Zone.ToLower() == "deck" || Zone.ToLower() == "hand") diff --git a/Hearthstone Deck Tracker/Utility/BoardDamage/BoardHero.cs b/Hearthstone Deck Tracker/Utility/BoardDamage/BoardHero.cs index 25bfbce43..5d029284c 100644 --- a/Hearthstone Deck Tracker/Utility/BoardDamage/BoardHero.cs +++ b/Hearthstone Deck Tracker/Utility/BoardDamage/BoardHero.cs @@ -13,7 +13,7 @@ public class BoardHero : IBoardEntity private readonly BoardCard _hero; private readonly BoardCard? _weapon; - public BoardHero(Entity hero, Entity weapon, bool activeTurn) + public BoardHero(Entity hero, Entity? weapon, bool activeTurn) { _hero = new BoardCard(hero, activeTurn); // hero gains windfury with weapon, doubling attack get base attack @@ -46,16 +46,23 @@ private int AttackWithWeapon() { if(Include) { - // weapon is equipped if(_weapon != null) { - // windfury weapon, with 2 or more charges, - // and hero hasn't attacked yet this turn. - if(_weapon.Windfury && _weapon.Health >= 2 && _hero.AttacksThisTurn == 0) + if((_hero.Windfury || _weapon.Windfury) && _weapon.Health >= 2 && _hero.AttacksThisTurn == 0) { - // double the hero attack value return _baseAttack * 2; } + + if(_hero.Windfury && !_weapon.Windfury && _weapon.Health == 1) + { + return _baseAttack * 2 - _weapon.Attack; + } + + } + // Hero got windfury from other means (Inara, Sand Art Elemental) + else if(_hero.Windfury && _hero.AttacksThisTurn == 0) + { + return _baseAttack * 2; } } // otherwise normal hero attack is correct diff --git a/Hearthstone Deck Tracker/Utility/BoardDamage/PlayerBoard.cs b/Hearthstone Deck Tracker/Utility/BoardDamage/PlayerBoard.cs index a87f3ea90..1cddd6f1a 100644 --- a/Hearthstone Deck Tracker/Utility/BoardDamage/PlayerBoard.cs +++ b/Hearthstone Deck Tracker/Utility/BoardDamage/PlayerBoard.cs @@ -4,6 +4,7 @@ using System.Linq; using HearthDb.Enums; using Hearthstone_Deck_Tracker.Hearthstone.Entities; +using NuGet; using static HearthDb.Enums.GameTag; #endregion @@ -36,10 +37,20 @@ public PlayerBoard(List list, bool activeTurn) public int Damage => Cards.Where(x => x.Include).Sum(x => x.Attack); - public Entity GetWeapon(List list) + public Entity? GetWeapon(List list) { var weapons = list.Where(x => x.IsWeapon).ToList(); - return weapons.Count == 1 ? weapons[0] : list.FirstOrDefault(x => x.HasTag(JUST_PLAYED) && x.GetTag(JUST_PLAYED) == 1); + if (weapons.IsEmpty()) + { + return null; + } + + if(weapons.Count == 1) + { + return weapons[0]; + } + + return list.FirstOrDefault(x => x.HasTag(JUST_PLAYED) && x.GetTag(JUST_PLAYED) == 1); } public override string ToString() => $"(H:{Hero?.Health ?? 0} A:{Damage})";