Skip to content

Commit

Permalink
Still handle secret played even without block cardid (HearthSim#4313)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonysegal authored Jun 28, 2021
1 parent 5093543 commit ab5188c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Hearthstone Deck Tracker/LogReader/Handlers/TagChangeActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ private void ZoneChangeFromOther(IHsGameState gameState, int id, IGame game, int
{
if(!game.Entities.TryGetValue(id, out var entity))
return;
var currentBlockCardId = gameState.CurrentBlock?.CardId ?? "";
if(entity.Info.OriginalZone == DECK && value != (int)DECK)
{
//This entity was moved from DECK to SETASIDE to HAND, e.g. by Tracking
Expand Down Expand Up @@ -510,8 +511,8 @@ private void ZoneChangeFromOther(IHsGameState gameState, int id, IGame game, int
gameState.GameHandler.HandleOpponentGet(entity, gameState.GetTurnNumber(), id);
break;
case Zone.SECRET:
if(controller == game.Player.Id && gameState.CurrentBlock?.Parent != null)
gameState.GameHandler.HandlePlayerSecretPlayed(entity, cardId, gameState.GetTurnNumber(), (Zone)prevValue, gameState.CurrentBlock.Parent.CardId);
if(controller == game.Player.Id)
gameState.GameHandler.HandlePlayerSecretPlayed(entity, cardId, gameState.GetTurnNumber(), (Zone)prevValue, currentBlockCardId);
else if(controller == game.Opponent.Id)
gameState.GameHandler.HandleOpponentSecretPlayed(entity, cardId, -1, gameState.GetTurnNumber(), (Zone)prevValue, id);
break;
Expand Down Expand Up @@ -594,11 +595,12 @@ private void ZoneChangeFromHand(IHsGameState gameState, int id, IGame game, int
{
if(!game.Entities.TryGetValue(id, out var entity))
return;
var currentBlockCardId = gameState.CurrentBlock?.CardId ?? "";
switch((Zone)value)
{
case PLAY:
if(controller == game.Player.Id && gameState.CurrentBlock?.Parent != null)
gameState.GameHandler.HandlePlayerPlay(entity, cardId, gameState.GetTurnNumber(), gameState.CurrentBlock.Parent.CardId);
if(controller == game.Player.Id)
gameState.GameHandler.HandlePlayerPlay(entity, cardId, gameState.GetTurnNumber(), currentBlockCardId);
else if(controller == game.Opponent.Id)
{
gameState.GameHandler.HandleOpponentPlay(entity, cardId, entity.GetTag(ZONE_POSITION),
Expand All @@ -618,7 +620,7 @@ private void ZoneChangeFromHand(IHsGameState gameState, int id, IGame game, int
break;
case Zone.SECRET:
if(controller == game.Player.Id && gameState.CurrentBlock?.Parent != null)
gameState.GameHandler.HandlePlayerSecretPlayed(entity, cardId, gameState.GetTurnNumber(), (Zone)prevValue, gameState.CurrentBlock.Parent.CardId);
gameState.GameHandler.HandlePlayerSecretPlayed(entity, cardId, gameState.GetTurnNumber(), (Zone)prevValue, currentBlockCardId);
else if(controller == game.Opponent.Id)
{
gameState.GameHandler.HandleOpponentSecretPlayed(entity, cardId, entity.GetTag(ZONE_POSITION),
Expand All @@ -641,6 +643,7 @@ private void ZoneChangeFromDeck(IHsGameState gameState, int id, IGame game, int
{
if(!game.Entities.TryGetValue(id, out var entity))
return;
var currentBlockCardId = gameState.CurrentBlock?.CardId ?? "";
switch((Zone)value)
{
case HAND:
Expand Down Expand Up @@ -711,8 +714,8 @@ private void ZoneChangeFromDeck(IHsGameState gameState, int id, IGame game, int
gameState.GameHandler.HandleOpponentDeckToPlay(entity, cardId, gameState.GetTurnNumber());
break;
case Zone.SECRET:
if(controller == game.Player.Id && gameState.CurrentBlock?.Parent != null)
gameState.GameHandler.HandlePlayerSecretPlayed(entity, cardId, gameState.GetTurnNumber(), (Zone)prevValue, gameState.CurrentBlock.Parent.CardId);
if(controller == game.Player.Id)
gameState.GameHandler.HandlePlayerSecretPlayed(entity, cardId, gameState.GetTurnNumber(), (Zone)prevValue, currentBlockCardId);
else if(controller == game.Opponent.Id)
gameState.GameHandler.HandleOpponentSecretPlayed(entity, cardId, -1, gameState.GetTurnNumber(), (Zone)prevValue, id);
break;
Expand Down

0 comments on commit ab5188c

Please sign in to comment.