Skip to content

Commit

Permalink
fix: terminal case winner detection
Browse files Browse the repository at this point in the history
  • Loading branch information
beheh committed Aug 23, 2023
1 parent 5353e8f commit 01d13bc
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions Hearthstone Deck Tracker/BobsBuddy/BobsBuddyInvoker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ internal class BobsBuddyInvoker
private Input? _input;
private int _turn;
static int LogLinesKept = Remote.Config.Data?.BobsBuddy?.LogLinesKept ?? 100;
public string OpponentCardId = "";
public string PlayerCardId = "";
private Entity? _attackingHero;
private Entity? _defendingHero;
public Entity? LastAttackingHero = null;
Expand Down Expand Up @@ -353,10 +351,6 @@ private void SnapshotBoardState(int turn)
DebugLog("Hero(es) could not be found. Exiting.");
return;
}

//We set OpponentCardId and PlayerCardId here so that later we can do lookups for these entites without using _game.Opponent/Player, which might be innacurate or null depending on when they're accessed.
OpponentCardId = opponentHero.CardId ?? "";
PlayerCardId = playerHero.CardId ?? "";

input.SetHealths(playerHero.Health + playerHero.GetTag(GameTag.ARMOR), opponentHero.Health + opponentHero.GetTag(GameTag.ARMOR));

Expand Down Expand Up @@ -699,16 +693,10 @@ private CombatResult GetLastCombatResult()
{
if(LastAttackingHero == null)
return CombatResult.Tie;
var playerHero = _game.Entities.Values.FirstOrDefault(x => x.CardId == PlayerCardId);
var opponentHero = _game.Entities.Values.FirstOrDefault(x => x.CardId == OpponentCardId);
if(playerHero != null && opponentHero != null)
{
if(LastAttackingHero.CardId == playerHero.CardId)
return CombatResult.Win;
if(LastAttackingHero.CardId == opponentHero.CardId)
return CombatResult.Loss;
}
return CombatResult.Invalid;
if(LastAttackingHero.IsControlledBy(_game.Player.Id))
return CombatResult.Win;
else
return CombatResult.Loss;
}

private LethalResult GetLastLethalResult()
Expand Down

0 comments on commit 01d13bc

Please sign in to comment.