Skip to content

Commit

Permalink
Merge pull request HearthSim#1677 from andburn/misc_fixes
Browse files Browse the repository at this point in the history
Quick fixes
  • Loading branch information
Epix committed Oct 30, 2015
2 parents df051d3 + 4b35870 commit 2f1369c
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 12 deletions.
28 changes: 28 additions & 0 deletions HDTTests/BoardDamage/BoardCardTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,34 @@ public void DontInclude_IfExhausted()
Assert.IsFalse(card.Include);
}

[TestMethod]
public void DontInclude_IfInDeckZoneAndAttacked()
{
var card = _minion.Deck().AttacksThisTurn(1).ToBoardCard();
Assert.IsFalse(card.Include);
}

[TestMethod]
public void DontInclude_IfInHandZoneAndWindfuryAttackedTwice()
{
var card = _minion.Hand().Windfury().AttacksThisTurn(2).ToBoardCard();
Assert.IsFalse(card.Include);
}

[TestMethod]
public void Include_IfInDeckHandAndNotAttacked()
{
var card = _minion.Hand().AttacksThisTurn(0).ToBoardCard();
Assert.IsTrue(card.Include);
}

[TestMethod]
public void Include_IfInDeckZoneAndWindfuryAttackedOnce()
{
var card = _minion.Deck().Windfury().AttacksThisTurn(1).ToBoardCard();
Assert.IsTrue(card.Include);
}

[TestMethod]
public void Include_IfExhaustedAndCharged()
{
Expand Down
13 changes: 4 additions & 9 deletions HDTTests/BoardDamage/PlayerBoardTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ public void Setup()
_cards.Add(new EntityBuilder("", 3, 1).InPlay().Charge().ToCardEntity());
_cards.Add(new EntityBuilder("", 3, 1).InPlay().Windfury().ToCardEntity());
_cards.Add(new EntityBuilder("", 2, 2).InPlay().Exhausted().ToCardEntity());

_exceptions = new List<CardEntity>();
var icehowl = new EntityBuilder("AT_125", 10, 10).InPlay().ToCardEntity();
_exceptions.Add(icehowl);
}

[TestMethod]
Expand All @@ -54,12 +50,11 @@ public void IgnoreSetaside()
}

[TestMethod]
// TODO: ignore Icehowl for now, if taunts were to be included
// could add back in with special attrib
public void IgnoreSpecialCases()
public void IgnoreGraveyard()
{
var board = new PlayerBoard(_exceptions, true);
Assert.AreEqual(0, board.Cards.Count);
_cards.Add(new EntityBuilder("", 3, 3).Graveyard().ToCardEntity());
var board = new PlayerBoard(_cards, true);
Assert.AreEqual(6, board.Cards.Count);
}

[TestMethod]
Expand Down
18 changes: 18 additions & 0 deletions HDTTests/BoardDamage/TestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,24 @@ public EntityBuilder Setaside()
return this;
}

public EntityBuilder Graveyard()
{
_instance.SetTag(GAME_TAG.ZONE, (int)TAG_ZONE.GRAVEYARD);
return this;
}

public EntityBuilder Deck()
{
_instance.SetTag(GAME_TAG.ZONE, (int)TAG_ZONE.DECK);
return this;
}

public EntityBuilder Hand()
{
_instance.SetTag(GAME_TAG.ZONE, (int)TAG_ZONE.HAND);
return this;
}

public EntityBuilder Invalid()
{
_instance.SetTag(GAME_TAG.ZONE, (int)TAG_ZONE.INVALID);
Expand Down
17 changes: 17 additions & 0 deletions Hearthstone Deck Tracker/Utility/BoardDamage/BoardCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,23 @@ private bool IsAbleToAttack(bool active, bool isWeapon)
return false;
}
}
// sometimes cards seem to be in wrong zone while in play,
// these cards don't become exhausted, so check attacks.
else if (Zone.ToLower() == "deck" || Zone.ToLower() == "hand")
{
if(_windfury && _attacksThisTurn >= 2)
{
return false;
}
else if(!_windfury && _attacksThisTurn >= 1)
{
return false;
}
else
{
return true;
}
}
else
{
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private List<CardEntity> Filter(List<CardEntity> cards)
&& x.Entity.GetTag(GAME_TAG.CARDTYPE) != (int)TAG_CARDTYPE.ENCHANTMENT
&& x.Entity.GetTag(GAME_TAG.CARDTYPE) != (int)TAG_CARDTYPE.HERO_POWER
&& x.Entity.GetTag(GAME_TAG.ZONE) != (int)TAG_ZONE.SETASIDE
&& x.CardId != "AT_125" // Icehowl
&& x.Entity.GetTag(GAME_TAG.ZONE) != (int)TAG_ZONE.GRAVEYARD
).ToList<CardEntity>();
}
}
Expand Down
5 changes: 3 additions & 2 deletions Hearthstone Deck Tracker/Windows/OverlayWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ private void SetOpponentCardCount(int cardCount, int cardsLeftInDeck)

var holdingNextTurn2 = Math.Round(100.0f * Helper.DrawProbability(2, (cardsLeftInDeck + handWithoutCoin), handWithoutCoin + 1), 1);
var drawNextTurn2 = Math.Round(200.0f / cardsLeftInDeck, 1);
LblOpponentDrawChance2.Text = drawNextTurn2 + "%";
LblOpponentDrawChance2.Text = (cardsLeftInDeck == 1 ? 100 : drawNextTurn2) + "%";
LblOpponentHandChance2.Text = holdingNextTurn2 + "%";

var holdingNextTurn = Math.Round(100.0f * Helper.DrawProbability(1, (cardsLeftInDeck + handWithoutCoin), handWithoutCoin + 1), 1);
Expand All @@ -495,7 +495,8 @@ private void SetCardCount(int cardCount, int cardsLeftInDeck)
}
LblPlayerFatigue.Text = "";

LblDrawChance2.Text = Math.Round(200.0f / cardsLeftInDeck, 1) + "%";
var drawNextTurn2 = Math.Round(200.0f / cardsLeftInDeck, 1);
LblDrawChance2.Text = (cardsLeftInDeck == 1 ? 100 : drawNextTurn2) + "%";
LblDrawChance1.Text = Math.Round(100.0f / cardsLeftInDeck, 1) + "%";
}

Expand Down

0 comments on commit 2f1369c

Please sign in to comment.