Skip to content

Commit

Permalink
fix(BobsBuddy): Teron Gorefiend's hero power not working
Browse files Browse the repository at this point in the history
This reverts commit 1ba6f92.
  • Loading branch information
beheh committed May 8, 2024
1 parent adac345 commit b4cb1b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
15 changes: 9 additions & 6 deletions Hearthstone Deck Tracker/BobsBuddy/BobsBuddyInvoker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,13 @@ private void SnapshotBoardState(int turn)
var pHpData2 = playerHeroPower?.GetTag(GameTag.TAG_SCRIPT_DATA_NUM_2) ?? 0;
if(playerHeroPower?.CardId == NonCollectible.Neutral.TeronGorefiend_RapidReanimation)
{
var ench = _game.Player.PlayerEntities.FirstOrDefault(x => x.CardId == NonCollectible.Neutral.TeronGorefiend_ImpendingDeath && (x.IsInPlay || x.IsInSetAside))
?? _game.Player.Graveyard.LastOrDefault(x => x.CardId == NonCollectible.Neutral.TeronGorefiend_ImpendingDeath);
var target = ench?.GetTag(GameTag.ATTACHED) ?? 0;
if(target > 0)
pHpData = target;
var minionsInPlay = _game.Player.Board.Where(e => e.IsMinion && e.IsControlledBy(_game.Player.Id)).Select(x => x.Id);
var attachedToEntityId = _game.Player.PlayerEntities
.Where(x => x.CardId == NonCollectible.Neutral.TeronGorefiend_ImpendingDeath && x.IsInPlay)
.Select(x => x.GetTag(GameTag.ATTACHED))
.FirstOrDefault(x => minionsInPlay.Any(y => y == x));
if(attachedToEntityId > 0)
pHpData = attachedToEntityId;
}
input.SetPlayerHeroPower(playerHeroPower?.CardId ?? "", WasHeroPowerActivated(playerHeroPower), pHpData, pHpData2);

Expand All @@ -391,7 +393,8 @@ private void SnapshotBoardState(int turn)
if(opponentHeroPower?.CardId == NonCollectible.Neutral.TeronGorefiend_RapidReanimation)
{
// It appear this enchantment may be in the graveyard now in the opponents case
var ench = _game.Opponent.PlayerEntities.FirstOrDefault(x => x.CardId == NonCollectible.Neutral.TeronGorefiend_ImpendingDeath && (x.IsInPlay || x.IsInSetAside))
var ench = _game.Opponent.PlayerEntities.FirstOrDefault(x => x.CardId == NonCollectible.Neutral.TeronGorefiend_ImpendingDeath && x.IsInPlay)
?? _game.Opponent.PlayerEntities.LastOrDefault(x => x.CardId == NonCollectible.Neutral.TeronGorefiend_ImpendingDeath && x.IsInSetAside)
?? _game.Opponent.Graveyard.LastOrDefault(x => x.CardId == NonCollectible.Neutral.TeronGorefiend_ImpendingDeath);
var target = ench?.GetTag(GameTag.ATTACHED) ?? 0;
if(target > 0)
Expand Down
5 changes: 1 addition & 4 deletions Hearthstone Deck Tracker/BobsBuddy/BobsBuddyUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,7 @@ internal static Minion GetMinionFromEntity(MinionFactory minionFactory, bool pla
}
}

// As of 198037 the shop identity of the card is more important, because e.g. Teron Gorefiends hero power
// encodes the id from the shop. Luckily we have COPIED_FROM_ENTITY_ID for that.
var copiedFromId = entity.GetTag(GameTag.COPIED_FROM_ENTITY_ID);
minion.game_id = copiedFromId > 0 ? copiedFromId : entity.Id;
minion.game_id = entity.Id;

return minion;
}
Expand Down

0 comments on commit b4cb1b0

Please sign in to comment.