Skip to content

Commit

Permalink
stats: track coin based on FIRST_PLAYER tag (HearthSim#2193)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Zeier committed Mar 9, 2016
1 parent 143f609 commit 9a57d10
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions Hearthstone Deck Tracker/GameEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -592,10 +592,13 @@ public async void HandleGameEnd()
_assignedDeck = null;
return;
}
var player = _game.Entities.FirstOrDefault(e => e.Value.IsPlayer);
var player = _game.Entities.FirstOrDefault(e => e.Value.IsPlayer).Value;
var opponent = _game.Entities.FirstOrDefault(e => e.Value.HasTag(PLAYER_ID) && !e.Value.IsPlayer);
if(player.Value != null)
_game.CurrentGameStats.PlayerName = player.Value.Name;
if(player != null)
{
_game.CurrentGameStats.PlayerName = player.Name;
_game.CurrentGameStats.Coin = !player.HasTag(FIRST_PLAYER);
}
if(opponent.Value != null && CardIds.HeroIdDict.ContainsValue(_game.CurrentGameStats.OpponentHero))
_game.CurrentGameStats.OpponentName = opponent.Value.Name;
else
Expand Down Expand Up @@ -898,11 +901,6 @@ public void HandlePlayerGet(Entity entity, string cardId, int turn)
if(string.IsNullOrEmpty(cardId))
return;
_game.Player.CreateInHand(entity, turn);
if(cardId == "GAME_005" && _game.CurrentGameStats != null)
{
_game.CurrentGameStats.Coin = true;
Log.Info("Got coin");
}
Helper.UpdatePlayerCards();
_game.AddPlayToCurrentGame(PlayType.PlayerGet, turn, cardId);
GameEvents.OnPlayerGet.Execute(Database.GetCardFromId(cardId));
Expand Down

0 comments on commit 9a57d10

Please sign in to comment.