Skip to content

Commit

Permalink
fix(BoardCard): Mega Mountain not having Wind-Fury
Browse files Browse the repository at this point in the history
  • Loading branch information
beheh committed Dec 10, 2023
1 parent 7be978b commit ad813f3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
11 changes: 7 additions & 4 deletions HDTTests/BoardDamage/BoardCardTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,20 @@ public void Attack_WeaponWithWindfuryOneHitLeft()
Assert.AreEqual(5, card.Attack);
}

[TestMethod]
public void Attack_MegaWindfury_V07TR0N()
[DataTestMethod]
[DataRow(CardIds.NonCollectible.Neutral.MimironsHead_V07Tr0NToken, DisplayName = "V-07-TR-0N")]
[DataRow(CardIds.Collectible.Shaman.WalkingMountain, DisplayName = "Walking Mountain")]
public void Attack_MegaWindfury(string cardId)
{
var eb = new EntityBuilder("GVG_111t", 4, 8).Windfury().Charge().InPlay();
var eb = new EntityBuilder(cardId, 4, 8).Windfury().Charge().InPlay();

Assert.AreEqual(16, eb.ToBoardCard().Attack);
Assert.AreEqual(16, eb.Exhausted().ToBoardCard(false).Attack);
Assert.AreEqual(16, eb.AttacksThisTurn(4).ToBoardCard(false).Attack);
Assert.AreEqual(12, eb.AttacksThisTurn(1).ToBoardCard().Attack);
Assert.AreEqual(8, eb.AttacksThisTurn(2).ToBoardCard().Attack);
Assert.AreEqual(4, eb.AttacksThisTurn(3).ToBoardCard().Attack);
Assert.AreEqual(4, eb.AttacksThisTurn(4).ToBoardCard().Attack);
Assert.AreEqual(0, eb.AttacksThisTurn(4).ToBoardCard().Attack);
}

[TestMethod]
Expand Down
32 changes: 20 additions & 12 deletions Hearthstone Deck Tracker/Utility/BoardDamage/BoardCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public BoardCard(Entity e, bool active = true)
_frozen = e.GetTag(FROZEN) == 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);
AttacksThisTurn = e.GetTag(NUM_ATTACKS_THIS_TURN);
_dormant = e.GetTag(DORMANT) == 1;
_isTitan = e.GetTag(TITAN) == 1;
Expand All @@ -64,6 +65,7 @@ public BoardCard(Entity e, bool active = true)
public bool Taunt { get; private set; }
public bool Charge { get; }
public bool Windfury { get; }
public bool MegaWindfury { get; }
public string CardType { get; private set; }

public string Name { get; }
Expand All @@ -72,6 +74,18 @@ public BoardCard(Entity e, bool active = true)
public bool Include { get; }

public int AttacksThisTurn { get; }
public int AttacksPerTurn
{
get
{
if(MegaWindfury)
return 4;
if(Windfury)
return 2;
return 1;
}
}

public bool Exhausted { get; }

public string Zone { get; }
Expand All @@ -86,19 +100,13 @@ public BoardCard(Entity e, bool active = true)

private int CalculateAttack(bool active, bool isWeapon)
{
// V-07-TR-0N is a special case Mega-Windfury
if(!string.IsNullOrEmpty(CardId) && CardId == "GVG_111t")
return V07TRONAttack(active);
// for weapons check for windfury and number of hits left
var remainingAttacks = Math.Max(AttacksPerTurn - (active ? AttacksThisTurn : 0), 0);

if(isWeapon)
{
if(Windfury && Health >= 2 && AttacksThisTurn == 0)
return _stdAttack * 2;
}
// for minions with windfury that haven't already attacked, double attack
else if(Windfury && (!active || AttacksThisTurn == 0))
return _stdAttack * 2;
return _stdAttack;
// for weapons, clamp remaining attacks to health
remainingAttacks = Math.Min(remainingAttacks, Health);

return remainingAttacks * _stdAttack;
}

private bool IsAbleToAttack(bool active, bool isWeapon)
Expand Down

0 comments on commit ad813f3

Please sign in to comment.