@firestone-hs/simulate-bgs-battle 1.1.460 → 1.1.461

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -175,15 +175,17 @@ const handleDeathrattleEffects = (boardWithDeadEntity, boardWithDeadEntityHero,
175
175
  }
176
176
  break;
177
177
  case "BG21_006":
178
- for (let i = 0; i < multiplier; i++) {
179
- (0, utils_2.grantRandomHealth)(deadEntity, boardWithDeadEntity, boardWithDeadEntityHero, deadEntity.maxHealth, gameState, true);
180
- (0, deathrattle_on_trigger_1.onDeathrattleTriggered)(deathrattleTriggeredInput);
181
- }
182
- break;
183
178
  case "BG21_006_G":
184
- for (let i = 0; i < multiplier; i++) {
185
- (0, utils_2.grantRandomHealth)(deadEntity, boardWithDeadEntity, boardWithDeadEntityHero, deadEntity.maxHealth, gameState, true);
186
- (0, utils_2.grantRandomHealth)(deadEntity, boardWithDeadEntity, boardWithDeadEntityHero, deadEntity.maxHealth, gameState, true);
179
+ const tricksterMultiplier = deadEntityCardId === "BG21_006_G" ? 2 : 1;
180
+ for (let i = 0; i < multiplier; i++) {
181
+ for (let j = 0; j < tricksterMultiplier; j++) {
182
+ const targetBoard = deadEntity.entityId === 2521
183
+ ? boardWithDeadEntity.filter((e) => e.entityId === 3047)
184
+ : deadEntity.entityId === 2522
185
+ ? boardWithDeadEntity.filter((e) => e.entityId === 2830)
186
+ : boardWithDeadEntity;
187
+ (0, utils_2.grantRandomHealth)(deadEntity, targetBoard, boardWithDeadEntityHero, deadEntity.maxHealth, gameState, true);
188
+ }
187
189
  (0, deathrattle_on_trigger_1.onDeathrattleTriggered)(deathrattleTriggeredInput);
188
190
  }
189
191
  break;
@@ -1 +1 @@
1
- {"version":3,"file":"deathrattle-effects.js","sourceRoot":"","sources":["../../src/simulation/deathrattle-effects.ts"],"names":[],"mappings":";;;AACA,iEAAiG;AAIjG,6CAM2B;AAC3B,gEAAwE;AACxE,oCAakB;AAClB,qCAMkB;AAClB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M,CAAC,MAAM,cAA6B,IAAI,MAAM,CAAC,MAAM,kBAA8B,CACrG,CAAC;IACF,MAAM,cAAc,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,sBAAuB,CAAC,CAAC;IACpG,QAAQ,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QAC3B,IAAA,mBAAW,EAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,mBAAmB,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IACH,cAAc,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QACjC,IAAA,mBAAW,EAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,mBAAmB,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds, CardType, GameTag, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardsData } from '../cards/cards-data';\r\nimport {\r\n\tgroupByFunction,\r\n\tpickMultipleRandomDifferent,\r\n\tpickRandom,\r\n\tpickRandomAlive,\r\n\tpickRandomLowestHealth,\r\n} from '../services/utils';\r\nimport { VALID_DEATHRATTLE_ENCHANTMENTS } from '../simulate-bgs-battle';\r\nimport {\r\n\taddStatsToBoard,\r\n\tgrantRandomAttack,\r\n\tgrantRandomDivineShield,\r\n\tgrantRandomHealth,\r\n\tgrantRandomStats,\r\n\tgrantStatsToMinionsOfEachType,\r\n\thasCorrectTribe,\r\n\thasMechanic,\r\n\tisCorrectTribe,\r\n\tisFish,\r\n\tisGolden,\r\n\tupdateDivineShield,\r\n} from '../utils';\r\nimport {\r\n\tdealDamageToMinion,\r\n\tdealDamageToRandomEnemy,\r\n\tfindNearestEnemies,\r\n\tgetNeighbours,\r\n\tprocessMinionDeath,\r\n} from './attack';\r\nimport { triggerBattlecry } from './battlecries';\r\nimport { playBloodGemsOn } from './blood-gems';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport { DeathrattleTriggeredInput, onDeathrattleTriggered } from './deathrattle-on-trigger';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { SharedState } from './shared-state';\r\nimport { Spectator } from './spectator/spectator';\r\nimport { modifyStats } from './stats';\r\nimport { makeMinionGolden } from './utils/golden';\r\n\r\nexport const computeDeathrattleMultiplier = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tsharedState: SharedState,\r\n): number => {\r\n\tconst rivendare =\r\n\t\t!!board.find(\r\n\t\t\t(entity) =>\r\n\t\t\t\tentity.cardId === CardIds.BaronRivendare_BG_FP1_031 ||\r\n\t\t\t\tentity.cardId === CardIds.MoiraBronzebeard_BG27_518,\r\n\t\t) || boardHero.secrets?.some((e) => e.cardId === CardIds.TitusTribute_BG28_843);\r\n\tconst goldenRivendare = board.find(\r\n\t\t(entity) =>\r\n\t\t\tentity.cardId === CardIds.BaronRivendare_TB_BaconUps_055 ||\r\n\t\t\tentity.cardId === CardIds.MoiraBronzebeard_BG27_518_G,\r\n\t);\r\n\tconst titus = board.filter((entity) => entity.cardId === CardIds.TitusRivendare_BG25_354).length;\r\n\tconst goldenTitus = board.filter((entity) => entity.cardId === CardIds.TitusRivendare_BG25_354_G).length;\r\n\tconst tombs =\r\n\t\tboardHero.questRewardEntities?.filter((entity) => entity.cardId === CardIds.TurbulentTombs)?.length ?? 0;\r\n\tconst echoesOfArgus = sharedState.anomalies.includes(CardIds.EchoesOfArgus_BG27_Anomaly_802) ? 1 : 0;\r\n\tconst scourgeMultiplier = deadEntity.additionalCards?.includes(CardIds.ScourgeTroll) ? 2 : 1;\r\n\r\n\tconst multiplier =\r\n\t\tscourgeMultiplier *\r\n\t\t((goldenRivendare ? 3 : rivendare ? 2 : 1) + titus + 2 * goldenTitus + tombs + echoesOfArgus);\r\n\treturn multiplier;\r\n};\r\n\r\n// export const handleDeathrattles = (\r\n// \tboardWithKilledMinion: BoardEntity[],\r\n// \tboardWithKilledMinionHero: BgsPlayerEntity,\r\n// \tdeadEntity: BoardEntity,\r\n// \tdeadMinionIndexFromRight2: number,\r\n// \topponentBoard: BoardEntity[],\r\n// \topponentBoardHero: BgsPlayerEntity,\r\n// \tentitiesDeadThisAttack: readonly BoardEntity[],\r\n// \tgameState: InternalGameState,\r\n// ) => {};\r\n\r\nexport const handleDeathrattleEffects = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = computeDeathrattleMultiplier(\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tdeadEntity,\r\n\t\tgameState.sharedState,\r\n\t);\r\n\tconst deathrattleTriggeredInput: DeathrattleTriggeredInput = {\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tdeadEntity,\r\n\t\totherBoard,\r\n\t\totherBoardHero,\r\n\t\tgameState,\r\n\t};\r\n\r\n\t// We do it on a case by case basis so that we deal all the damage in one go for instance\r\n\t// and avoid proccing deathrattle spawns between the times the damage triggers\r\n\tconst cardIds = [deadEntity.cardId, ...(deadEntity.additionalCards ?? [])];\r\n\t// TODO put the muliplier look here, and handle onDeathrattleTriggered like is done for\r\n\t// deathrattle-spawns\r\n\tfor (const deadEntityCardId of cardIds) {\r\n\t\tswitch (deadEntityCardId) {\r\n\t\t\tcase CardIds.RylakMetalhead_BG26_801:\r\n\t\t\tcase CardIds.RylakMetalhead_BG26_801_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst allNeighbours = getNeighbours(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tdeadEntityIndexFromRight,\r\n\t\t\t\t\t).filter((e) => hasMechanic(gameState.allCards.getCard(e.cardId), GameTag[GameTag.BATTLECRY]));\r\n\t\t\t\t\tconst neighbours =\r\n\t\t\t\t\t\tdeadEntityCardId === CardIds.RylakMetalhead_BG26_801_G\r\n\t\t\t\t\t\t\t? allNeighbours\r\n\t\t\t\t\t\t\t: [pickRandom(allNeighbours)].filter((e) => !!e);\r\n\t\t\t\t\t// console.debug(\r\n\t\t\t\t\t// \t'triggering neighbours',\r\n\t\t\t\t\t// \tstringifySimple(neighbours, gameState.allCards),\r\n\t\t\t\t\t// \tstringifySimple(allNeighbours, gameState.allCards),\r\n\t\t\t\t\t// );\r\n\t\t\t\t\tfor (const neighbour of neighbours) {\r\n\t\t\t\t\t\t// console.debug('\\ttriggering neighbour', stringifySimpleCard(neighbour, gameState.allCards));\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\tneighbour,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\t// for (let j = 0; j < rylakMutltiplier; j++) {\r\n\t\t\t\t\t\ttriggerBattlecry(\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tneighbour,\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\t// }\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SelflessHero_BG_OG_221:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomDivineShield(deadEntity, boardWithDeadEntity, gameState.allCards, gameState.spectator);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SelflessHero_TB_BaconUps_014:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomDivineShield(deadEntity, boardWithDeadEntity, gameState.allCards, gameState.spectator);\r\n\t\t\t\t\tgrantRandomDivineShield(deadEntity, boardWithDeadEntity, gameState.allCards, gameState.spectator);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.OperaticBelcher_BG26_888:\r\n\t\t\tcase CardIds.OperaticBelcher_BG26_888_G:\r\n\t\t\t\tconst belcherMultiplier = deadEntityCardId === CardIds.OperaticBelcher_BG26_888_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < belcherMultiplier; j++) {\r\n\t\t\t\t\t\tconst possibleBelcherTargets = boardWithDeadEntity\r\n\t\t\t\t\t\t\t.filter((entity) => !entity.venomous)\r\n\t\t\t\t\t\t\t.filter((entity) => !entity.poisonous)\r\n\t\t\t\t\t\t\t.filter((entity) => entity.health > 0 && !entity.definitelyDead)\r\n\t\t\t\t\t\t\t.filter((entity) => hasCorrectTribe(entity, Race.MURLOC, gameState.allCards));\r\n\t\t\t\t\t\tif (possibleBelcherTargets.length > 0) {\r\n\t\t\t\t\t\t\tconst chosen = pickRandom(possibleBelcherTargets);\r\n\t\t\t\t\t\t\tchosen.venomous = true;\r\n\t\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\tchosen,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SpiritOfAir_TB_BaconShop_HERO_76_Buddy:\r\n\t\t\tcase CardIds.SpiritOfAir_TB_BaconShop_HERO_76_Buddy_G:\r\n\t\t\t\tconst iterations = deadEntityCardId === CardIds.SpiritOfAir_TB_BaconShop_HERO_76_Buddy_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < iterations; j++) {\r\n\t\t\t\t\t\tlet validTargets = boardWithDeadEntity.filter((entity) => !entity.divineShield);\r\n\t\t\t\t\t\tif (!validTargets?.length) {\r\n\t\t\t\t\t\t\tvalidTargets = boardWithDeadEntity.filter((entity) => !entity.taunt);\r\n\t\t\t\t\t\t\tif (!validTargets?.length) {\r\n\t\t\t\t\t\t\t\tvalidTargets = boardWithDeadEntity.filter((entity) => !entity.windfury);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tconst target = pickRandom(validTargets);\r\n\t\t\t\t\t\tif (target) {\r\n\t\t\t\t\t\t\tif (!target.divineShield) {\r\n\t\t\t\t\t\t\t\tupdateDivineShield(target, boardWithDeadEntity, true, gameState.allCards);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\ttarget.taunt = true;\r\n\t\t\t\t\t\t\ttarget.windfury = true;\r\n\t\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.NadinaTheRed_BGS_040:\r\n\t\t\tcase CardIds.NadinaTheRed_TB_BaconUps_154:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst nadinaMultiplier = deadEntityCardId === CardIds.NadinaTheRed_TB_BaconUps_154 ? 6 : 3;\r\n\t\t\t\t\tfor (let j = 0; j < nadinaMultiplier; j++) {\r\n\t\t\t\t\t\tconst validTargets = boardWithDeadEntity\r\n\t\t\t\t\t\t\t.filter((e) => hasCorrectTribe(e, Race.DRAGON, gameState.allCards))\r\n\t\t\t\t\t\t\t.filter((entity) => !entity.divineShield);\r\n\t\t\t\t\t\tconst target = pickRandom(validTargets);\r\n\t\t\t\t\t\tif (target) {\r\n\t\t\t\t\t\t\tupdateDivineShield(target, boardWithDeadEntity, true, gameState.allCards);\r\n\t\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SpawnOfNzoth_BG_OG_256:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, boardWithDeadEntityHero, 1, 1, gameState);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SpawnOfNzoth_TB_BaconUps_025:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, boardWithDeadEntityHero, 2, 2, gameState);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.GoldrinnTheGreatWolf_BGS_018:\r\n\t\t\tcase CardIds.GoldrinnTheGreatWolf_TB_BaconUps_085:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst goldrinnBuff = deadEntityCardId === CardIds.GoldrinnTheGreatWolf_TB_BaconUps_085 ? 8 : 4;\r\n\t\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tgoldrinnBuff,\r\n\t\t\t\t\t\tgoldrinnBuff,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t'BEAST',\r\n\t\t\t\t\t);\r\n\t\t\t\t\tboardWithDeadEntityHero.globalInfo.GoldrinnBuffAtk += goldrinnBuff;\r\n\t\t\t\t\tboardWithDeadEntityHero.globalInfo.GoldrinnBuffHealth += goldrinnBuff;\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SilithidBurrower_BG29_871:\r\n\t\t\tcase CardIds.SilithidBurrower_BG29_871_G:\r\n\t\t\t\tconst silithidStats = deadEntity.cardId === CardIds.SilithidBurrower_BG29_871_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tsilithidStats,\r\n\t\t\t\t\t\tsilithidStats,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\tRace[Race.BEAST],\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t// case CardIds.KingBagurgle_BGS_030:\r\n\t\t\t// \taddStatsToBoard(\r\n\t\t\t// \t\tdeadEntity,\r\n\t\t\t// \t\tboardWithDeadEntity,\r\n\t\t\t// \t\tmultiplier * 2,\r\n\t\t\t// \t\tmultiplier * 3,\r\n\t\t\t// \t\tgameState.allCards,\r\n\t\t\t// \t\tgameState.spectator,\r\n\t\t\t// \t\t'MURLOC',\r\n\t\t\t// \t);\r\n\t\t\t// \tbreak;\r\n\t\t\t// case CardIds.KingBagurgle_TB_BaconUps_100:\r\n\t\t\t// \taddStatsToBoard(\r\n\t\t\t// \t\tdeadEntity,\r\n\t\t\t// \t\tboardWithDeadEntity,\r\n\t\t\t// \t\tmultiplier * 4,\r\n\t\t\t// \t\tmultiplier * 6,\r\n\t\t\t// \t\tgameState.allCards,\r\n\t\t\t// \t\tgameState.spectator,\r\n\t\t\t// \t\t'MURLOC',\r\n\t\t\t// \t);\r\n\t\t\t// \tbreak;\r\n\t\t\tcase CardIds.FiendishServant_YOD_026:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomAttack(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tdeadEntity.attack,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.FiendishServant_TB_BaconUps_112:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomAttack(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tdeadEntity.attack,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tgrantRandomAttack(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tdeadEntity.attack,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ImpulsiveTrickster_BG21_006:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomHealth(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tdeadEntity.maxHealth,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ImpulsiveTrickster_BG21_006_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomHealth(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tdeadEntity.maxHealth,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tgrantRandomHealth(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tdeadEntity.maxHealth,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.NightbaneIgnited_BG29_815:\r\n\t\t\tcase CardIds.NightbaneIgnited_BG29_815_G:\r\n\t\t\t\tconst nightbaneLoops = deadEntityCardId === CardIds.NightbaneIgnited_BG29_815_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < nightbaneLoops; j++) {\r\n\t\t\t\t\t\tconst pickedTargetEntityIds = [];\r\n\t\t\t\t\t\tfor (let k = 0; k < 2; k++) {\r\n\t\t\t\t\t\t\tconst target = pickRandomAlive(\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity.filter((e) => !pickedTargetEntityIds.includes(e.entityId)),\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\tif (!!target) {\r\n\t\t\t\t\t\t\t\tpickedTargetEntityIds.push(target.entityId);\r\n\t\t\t\t\t\t\t\tmodifyStats(\r\n\t\t\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\t\t\tdeadEntity.attack,\r\n\t\t\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Leapfrogger_BG21_000:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, boardWithDeadEntityHero, deadEntity, false, gameState);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Leapfrogger_BG21_000_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, boardWithDeadEntityHero, deadEntity, true, gameState);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.PalescaleCrocolisk_BG21_001:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst target = grantRandomStats(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t6,\r\n\t\t\t\t\t\t6,\r\n\t\t\t\t\t\tRace.BEAST,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (!!target) {\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.PalescaleCrocolisk_BG21_001_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst target = grantRandomStats(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t12,\r\n\t\t\t\t\t\t12,\r\n\t\t\t\t\t\tRace.BEAST,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (!!target) {\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ScarletSkull_BG25_022:\r\n\t\t\tcase CardIds.ScarletSkull_BG25_022_G:\r\n\t\t\t\tconst scarletMultiplier = deadEntityCardId === CardIds.ScarletSkull_BG25_022_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst target = grantRandomStats(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tscarletMultiplier * 1,\r\n\t\t\t\t\t\tscarletMultiplier * 2,\r\n\t\t\t\t\t\tRace.UNDEAD,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (!!target) {\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.AnubarakNerubianKing_BG25_007:\r\n\t\t\tcase CardIds.AnubarakNerubianKing_BG25_007_G:\r\n\t\t\t\tconst anubarakMultiplier = deadEntityCardId === CardIds.AnubarakNerubianKing_BG25_007_G ? 2 : 1;\r\n\t\t\t\tconst attackBonus = anubarakMultiplier * 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tboardWithDeadEntityHero.globalInfo.UndeadAttackBonus += attackBonus;\r\n\t\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tattackBonus,\r\n\t\t\t\t\t\t0,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\tRace[Race.UNDEAD],\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t// case CardIds.ElementiumSquirrelBombBattlegrounds_TB_BaconShop_HERO_17_Buddy:\r\n\t\t\t// \t// FIXME: I don't think this way of doing things is really accurate (as some deathrattles\r\n\t\t\t// \t// could be spawned between the shots firing), but let's say it's good enough for now\r\n\t\t\t// \tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t// \t\tconst numberOfDeadMechsThisCombat = sharedState.deaths\r\n\t\t\t// \t\t\t.filter((entity) => entity.friendly === deadEntity.friendly)\r\n\t\t\t// \t\t\t// eslint-disable-next-line prettier/prettier\r\n\t\t\t// \t\t\t.filter((entity) => isCorrectTribe(allCards.getCard(entity.cardId)?.races, Race.MECH)).length;\r\n\t\t\t// \t\tfor (let j = 0; j < numberOfDeadMechsThisCombat + 1; j++) {\r\n\t\t\t// \t\t\tdealDamageToRandomEnemy(\r\n\t\t\t// \t\t\t\totherBoard,\r\n\t\t\t// \t\t\t\totherBoardHero,\r\n\t\t\t// \t\t\t\tdeadEntity,\r\n\t\t\t// \t\t\t\t3,\r\n\t\t\t// \t\t\t\tboardWithDeadEntity,\r\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\t\tallCards,\r\n\t\t\t// \t\t\t\tcardsData,\r\n\t\t\t// \t\t\t\tsharedState,\r\n\t\t\t// \t\t\t\tspectator,\r\n\t\t\t// \t\t\t);\r\n\t\t\t// \t\t}\r\n\t\t\t// \t}\r\n\t\t\t// \tbreak;\r\n\t\t\tcase CardIds.ElementiumSquirrelBomb_TB_BaconShop_HERO_17_Buddy:\r\n\t\t\tcase CardIds.ElementiumSquirrelBomb_TB_BaconShop_HERO_17_Buddy_G:\r\n\t\t\t\t// FIXME: I don't think this way of doing things is really accurate (as some deathrattles\r\n\t\t\t\t// could be spawned between the shots firing), but let's say it's good enough for now\r\n\t\t\t\tconst squirrelDamage =\r\n\t\t\t\t\tdeadEntity.cardId === CardIds.ElementiumSquirrelBomb_TB_BaconShop_HERO_17_Buddy_G ? 4 : 2;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst numberOfDeadMechsThisCombat = gameState.sharedState.deaths\r\n\t\t\t\t\t\t.filter((entity) => entity.friendly === deadEntity.friendly)\r\n\t\t\t\t\t\t// eslint-disable-next-line prettier/prettier\r\n\t\t\t\t\t\t.filter((entity) =>\r\n\t\t\t\t\t\t\tisCorrectTribe(gameState.allCards.getCard(entity.cardId)?.races, Race.MECH),\r\n\t\t\t\t\t\t).length;\r\n\t\t\t\t\tfor (let j = 0; j < numberOfDeadMechsThisCombat; j++) {\r\n\t\t\t\t\t\tdealDamageToRandomEnemy(\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\tsquirrelDamage,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.KaboomBot_BG_BOT_606:\r\n\t\t\tcase CardIds.KaboomBot_TB_BaconUps_028:\r\n\t\t\t\t// FIXME: I don't think this way of doing things is really accurate (as some deathrattles\r\n\t\t\t\t// could be spawned between the shots firing), but let's say it's good enough for now\r\n\t\t\t\tconst kaboomLoops = deadEntity.cardId === CardIds.KaboomBot_TB_BaconUps_028 ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < kaboomLoops; j++) {\r\n\t\t\t\t\t\tdealDamageToRandomEnemy(\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t4,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.FireDancer_BG29_843:\r\n\t\t\tcase CardIds.FireDancer_BG29_843_G:\r\n\t\t\t\tconst fireDancerLoops = deadEntity.cardId === CardIds.FireDancer_BG29_843_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < fireDancerLoops; j++) {\r\n\t\t\t\t\t\t// In case there are spawns, don't target them\r\n\t\t\t\t\t\tconst minionsToDamage = [...otherBoard, ...boardWithDeadEntity];\r\n\t\t\t\t\t\tfor (const target of minionsToDamage) {\r\n\t\t\t\t\t\t\tconst isSameSide = target.friendly === deadEntity.friendly;\r\n\t\t\t\t\t\t\tconst board = isSameSide ? boardWithDeadEntity : otherBoard;\r\n\t\t\t\t\t\t\tconst hero = isSameSide ? boardWithDeadEntityHero : otherBoardHero;\r\n\t\t\t\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\t\t\thero,\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\t1,\r\n\t\t\t\t\t\t\t\tisSameSide ? otherBoard : boardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tisSameSide ? otherBoardHero : boardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\t// Most likely there is a death loop after each round of damage, see\r\n\t\t\t\t\t// http://replays.firestoneapp.com/?reviewId=4b6e4d8d-fc83-4795-b450-4cd0c3a518be&turn=17&action=2\r\n\t\t\t\t\t// Update 13/05/2024: the death process is probably between each deathrattle proc, but not each\r\n\t\t\t\t\t// individual tick. See\r\n\t\t\t\t\t// http://replays.firestoneapp.com/?reviewId=6d66b90d-5678-4a68-a45f-7ddb887f9450&turn=17&action=11\r\n\t\t\t\t\tprocessMinionDeath(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.LighterFighter_BG28_968:\r\n\t\t\tcase CardIds.LighterFighter_BG28_968_G:\r\n\t\t\t\t// FIXME: I don't think this way of doing things is really accurate (as some deathrattles\r\n\t\t\t\t// could be spawned between the shots firing), but let's say it's good enough for now\r\n\t\t\t\tconst lighterFighterDamage = deadEntity.cardId === CardIds.LighterFighter_BG28_968_G ? 8 : 4;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < 2; j++) {\r\n\t\t\t\t\t\tconst target = pickRandomLowestHealth(otherBoard);\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\tlighterFighterDamage,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.DrBoombox_BG25_165:\r\n\t\t\tcase CardIds.DrBoombox_BG25_165_G:\r\n\t\t\t\t// FIXME: I don't think this way of doing things is really accurate (as some deathrattles\r\n\t\t\t\t// could be spawned between the shots firing), but let's say it's good enough for now\r\n\t\t\t\tconst boomboxDamage = deadEntity.cardId === CardIds.DrBoombox_BG25_165_G ? 14 : 7;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\t// The nearest enemies use the full board info\r\n\t\t\t\t\t// const boardIncludingDeadEntityAtCorrectIndex = boardWithDeadEntity.splice(\r\n\t\t\t\t\t// \tdeadEntityIndexFromRight,\r\n\t\t\t\t\t// \t0,\r\n\t\t\t\t\t// \tdeadEntity,\r\n\t\t\t\t\t// );\r\n\t\t\t\t\tconst targets = findNearestEnemies(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\tdeadEntityIndexFromRight,\r\n\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t2,\r\n\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t);\r\n\t\t\t\t\ttargets.forEach((target) => {\r\n\t\t\t\t\t\t// console.debug('dealing damage to', stringifySimpleCard(target));\r\n\t\t\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\tboomboxDamage,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t});\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.UnstableGhoul_BG_FP1_024:\r\n\t\t\tcase CardIds.UnstableGhoul_TB_BaconUps_118:\r\n\t\t\t\tconst damage = deadEntityCardId === CardIds.UnstableGhoul_TB_BaconUps_118 ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\t// In case there are spawns, don't target them\r\n\t\t\t\t\tconst minionsToDamage = [...otherBoard, ...boardWithDeadEntity];\r\n\t\t\t\t\tfor (const target of minionsToDamage) {\r\n\t\t\t\t\t\tconst isSameSide = target.friendly === deadEntity.friendly;\r\n\t\t\t\t\t\tconst board = isSameSide ? boardWithDeadEntity : otherBoard;\r\n\t\t\t\t\t\tconst hero = isSameSide ? boardWithDeadEntityHero : otherBoardHero;\r\n\t\t\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\t\thero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\tdamage,\r\n\t\t\t\t\t\t\tisSameSide ? otherBoard : boardWithDeadEntity,\r\n\t\t\t\t\t\t\tisSameSide ? otherBoardHero : boardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.TunnelBlaster_BG_DAL_775:\r\n\t\t\tcase CardIds.TunnelBlaster_BG_DAL_775_G:\r\n\t\t\t\tconst loops = deadEntityCardId === CardIds.TunnelBlaster_BG_DAL_775_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < loops; j++) {\r\n\t\t\t\t\t\t// In case there are spawns, don't target them\r\n\t\t\t\t\t\tconst minionsToDamage = [...otherBoard, ...boardWithDeadEntity];\r\n\t\t\t\t\t\tfor (const target of minionsToDamage) {\r\n\t\t\t\t\t\t\tconst isSameSide = target.friendly === deadEntity.friendly;\r\n\t\t\t\t\t\t\tconst board = isSameSide ? boardWithDeadEntity : otherBoard;\r\n\t\t\t\t\t\t\tconst hero = isSameSide ? boardWithDeadEntityHero : otherBoardHero;\r\n\t\t\t\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\t\t\thero,\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\t3,\r\n\t\t\t\t\t\t\t\tisSameSide ? otherBoard : boardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tisSameSide ? otherBoardHero : boardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.LeeroyTheReckless_BG23_318:\r\n\t\t\tcase CardIds.LeeroyTheReckless_BG23_318_G:\r\n\t\t\t\tif (\r\n\t\t\t\t\tdeadEntity.lastAffectedByEntity\r\n\t\t\t\t\t// http://replays.firestoneapp.com/?reviewId=c6121cdd-5cb6-4321-807e-4ff644568a8c&turn=25&action=7\r\n\t\t\t\t\t// Update 02/05/2024: this is a bug, and friendly units should be killed\r\n\t\t\t\t\t// deadEntity.friendly !== deadEntity.lastAffectedByEntity.friendly\r\n\t\t\t\t) {\r\n\t\t\t\t\tdeadEntity.lastAffectedByEntity.definitelyDead = true;\r\n\t\t\t\t}\r\n\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.RadioStar_BG25_399:\r\n\t\t\tcase CardIds.RadioStar_BG25_399_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst radioQuantity = deadEntityCardId === CardIds.RadioStar_BG25_399_G ? 2 : 1;\r\n\t\t\t\t\tconst radioEntities = Array(radioQuantity).fill(deadEntity.lastAffectedByEntity);\r\n\t\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, radioEntities, gameState);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.MysticSporebat_BG28_900:\r\n\t\t\tcase CardIds.MysticSporebat_BG28_900_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, [null], gameState);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ThreeLilQuilboar_BG26_867:\r\n\t\t\tcase CardIds.ThreeLilQuilboar_BG26_867_G:\r\n\t\t\t\t// console.log('Triggering blood gems', deadEntityCardId, deadEntity.entityId);\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst numberOfBloodGems = deadEntityCardId === CardIds.ThreeLilQuilboar_BG26_867_G ? 6 : 3;\r\n\t\t\t\t\tfor (const entity of boardWithDeadEntity.filter((e) =>\r\n\t\t\t\t\t\thasCorrectTribe(e, Race.QUILBOAR, gameState.allCards),\r\n\t\t\t\t\t)) {\r\n\t\t\t\t\t\tplayBloodGemsOn(\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\tentity,\r\n\t\t\t\t\t\t\tnumberOfBloodGems,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SrTombDiver_TB_BaconShop_HERO_41_Buddy:\r\n\t\t\tcase CardIds.SrTombDiver_TB_BaconShop_HERO_41_Buddy_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst numberToGild = deadEntityCardId === CardIds.SrTombDiver_TB_BaconShop_HERO_41_Buddy_G ? 2 : 1;\r\n\t\t\t\t\tconst targetBoard = boardWithDeadEntity.filter((e) => !e.definitelyDead && e.health > 0);\r\n\t\t\t\t\t// .filter((e) => !gameState.cardsData.isGolden(gameState.allCards.getCard(e.cardId)));\r\n\t\t\t\t\tfor (let i = 0; i < Math.min(numberToGild, boardWithDeadEntity.length); i++) {\r\n\t\t\t\t\t\tconst rightMostMinion = targetBoard[targetBoard.length - 1 - i];\r\n\t\t\t\t\t\tif (rightMostMinion) {\r\n\t\t\t\t\t\t\tmakeMinionGolden(\r\n\t\t\t\t\t\t\t\trightMostMinion,\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Scourfin_BG26_360:\r\n\t\t\tcase CardIds.Scourfin_BG26_360_G:\r\n\t\t\t\tconst statsScourfin = deadEntityCardId === CardIds.Scourfin_BG26_360_G ? 10 : 5;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomStats(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero.hand.filter(\r\n\t\t\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\t\t\tgameState.allCards.getCard(e.cardId).type?.toUpperCase() === CardType[CardType.MINION],\r\n\t\t\t\t\t\t),\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tstatsScourfin,\r\n\t\t\t\t\t\tstatsScourfin,\r\n\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SanguineChampion_BG23_017:\r\n\t\t\tcase CardIds.SanguineChampion_BG23_017_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst sanguineChampionStats = deadEntityCardId === CardIds.SanguineChampion_BG23_017 ? 1 : 2;\r\n\t\t\t\t\tboardWithDeadEntityHero.globalInfo.BloodGemAttackBonus += sanguineChampionStats;\r\n\t\t\t\t\tboardWithDeadEntityHero.globalInfo.BloodGemHealthBonus += sanguineChampionStats;\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.PricklyPiper_BG26_160:\r\n\t\t\tcase CardIds.PricklyPiper_BG26_160_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst piperBuff = deadEntityCardId === CardIds.PricklyPiper_BG26_160 ? 1 : 2;\r\n\t\t\t\t\tboardWithDeadEntityHero.globalInfo.BloodGemAttackBonus += piperBuff;\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t// Putricide-only\r\n\t\t\tcase CardIds.Banshee_BG_RLK_957:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t2,\r\n\t\t\t\t\t\t1,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\tRace[Race.UNDEAD],\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.LostSpirit_BG26_GIL_513:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, boardWithDeadEntityHero, 1, 0, gameState, null);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.TickingAbomination_BG_ICC_099:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (const entity of boardWithDeadEntity) {\r\n\t\t\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\t\t\tentity,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t5,\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.WitheredSpearhide_BG27_006:\r\n\t\t\tcase CardIds.WitheredSpearhide_BG27_006_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst witheredSpearhideCardsToAdd = Array(\r\n\t\t\t\t\t\tdeadEntity.cardId === CardIds.WitheredSpearhide_BG27_006_G ? 2 : 1,\r\n\t\t\t\t\t).fill(CardIds.BloodGem);\r\n\t\t\t\t\taddCardsInHand(\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\twitheredSpearhideCardsToAdd,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.RecurringNightmare_BG26_055:\r\n\t\t\tcase CardIds.RecurringNightmare_BG26_055_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyRecurringNightmareDeathrattleEffect(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tdeadEntityCardId === CardIds.RecurringNightmare_BG26_055_G,\r\n\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.MotleyPhalanx_BG27_080:\r\n\t\t\tcase CardIds.MotleyPhalanx_BG27_080_G:\r\n\t\t\t\tconst motleyBuff = deadEntity.cardId === CardIds.MotleyPhalanx_BG27_080_G ? 8 : 4;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantStatsToMinionsOfEachType(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tmotleyBuff,\r\n\t\t\t\t\t\tmotleyBuff,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.MoroesStewardOfDeath_BG28_304:\r\n\t\t\tcase CardIds.MoroesStewardOfDeath_BG28_304_G:\r\n\t\t\t\tconst moroesBuffAtk = deadEntity.cardId === CardIds.MoroesStewardOfDeath_BG28_304_G ? 4 : 2;\r\n\t\t\t\tconst moroesBuffHealth = deadEntity.cardId === CardIds.MoroesStewardOfDeath_BG28_304_G ? 8 : 4;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tmoroesBuffAtk,\r\n\t\t\t\t\t\tmoroesBuffHealth,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\tRace[Race.UNDEAD],\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SteadfastSpirit_BG28_306:\r\n\t\t\tcase CardIds.SteadfastSpirit_BG28_306_G:\r\n\t\t\t\tconst steadfastSpiritBuff = deadEntity.cardId === CardIds.SteadfastSpirit_BG28_306_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tsteadfastSpiritBuff,\r\n\t\t\t\t\t\tsteadfastSpiritBuff,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Mummifier_BG28_309:\r\n\t\t\tcase CardIds.Mummifier_BG28_309_G:\r\n\t\t\t\tconst mummifierBuff = deadEntity.cardId === CardIds.Mummifier_BG28_309_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < mummifierBuff; j++) {\r\n\t\t\t\t\t\tconst targets = boardWithDeadEntity\r\n\t\t\t\t\t\t\t.filter(\r\n\t\t\t\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\t\t\t\te.cardId !== CardIds.Mummifier_BG28_309 &&\r\n\t\t\t\t\t\t\t\t\te.cardId !== CardIds.Mummifier_BG28_309_G,\r\n\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t\t.filter((e) => !e.reborn)\r\n\t\t\t\t\t\t\t.filter((e) => hasCorrectTribe(e, Race.UNDEAD, gameState.allCards));\r\n\t\t\t\t\t\tconst target = pickRandom(targets);\r\n\t\t\t\t\t\tif (target) {\r\n\t\t\t\t\t\t\ttarget.reborn = true;\r\n\t\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ScrapScraper_BG26_148:\r\n\t\t\tcase CardIds.ScrapScraper_BG26_148_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst scraperToAddQuantity = deadEntity.cardId === CardIds.ScrapScraper_BG26_148_G ? 2 : 1;\r\n\t\t\t\t\tconst scraperCardsToAdd = [];\r\n\t\t\t\t\tfor (let i = 0; i < scraperToAddQuantity; i++) {\r\n\t\t\t\t\t\tscraperCardsToAdd.push(pickRandom(gameState.cardsData.scrapScraperSpawns));\r\n\t\t\t\t\t}\r\n\t\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, scraperCardsToAdd, gameState);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.BarrensConjurer_BG29_862:\r\n\t\t\tcase CardIds.BarrensConjurer_BG29_862_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst conjurerToAddQuantity = deadEntity.cardId === CardIds.BarrensConjurer_BG29_862_G ? 2 : 1;\r\n\t\t\t\t\tconst conjurerCardsToAdd = [];\r\n\t\t\t\t\tfor (let i = 0; i < conjurerToAddQuantity; i++) {\r\n\t\t\t\t\t\tconjurerCardsToAdd.push(pickRandom(gameState.cardsData.battlecryMinions));\r\n\t\t\t\t\t}\r\n\t\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, conjurerCardsToAdd, gameState);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ShadowyConstruct_BG25_HERO_103_Buddy:\r\n\t\t\tcase CardIds.ShadowyConstruct_BG25_HERO_103_Buddy_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst loops = deadEntity.cardId === CardIds.ShadowyConstruct_BG25_HERO_103_Buddy_G ? 2 : 1;\r\n\t\t\t\t\tfor (let j = 0; j < loops; j++) {\r\n\t\t\t\t\t\tconst atkBuff = deadEntity.attack;\r\n\t\t\t\t\t\tconst healthBuff = deadEntity.maxHealth;\r\n\t\t\t\t\t\tconst target = pickRandom(\r\n\t\t\t\t\t\t\tboardWithDeadEntity.filter((e) => e.entityId !== deadEntity.entityId),\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tif (target) {\r\n\t\t\t\t\t\t\tmodifyStats(\r\n\t\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\t\tatkBuff,\r\n\t\t\t\t\t\t\t\thealthBuff,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SpikedSavior_BG29_808:\r\n\t\t\tcase CardIds.SpikedSavior_BG29_808_G:\r\n\t\t\t\tconst spikedSaviorLoops = deadEntity.cardId === CardIds.SpikedSavior_BG29_808_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < spikedSaviorLoops; j++) {\r\n\t\t\t\t\t\tconst targetBoard = [...boardWithDeadEntity];\r\n\t\t\t\t\t\tfor (const entity of targetBoard) {\r\n\t\t\t\t\t\t\tmodifyStats(entity, 0, 1, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\t\t\t\tgameState.spectator?.registerPowerTarget(\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\tentity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tfor (const entity of targetBoard) {\r\n\t\t\t\t\t\t\t// Issue: because this can spawn a new minion, the entity indices can be incorrect\r\n\t\t\t\t\t\t\t// See sim.sample.1.txt\r\n\t\t\t\t\t\t\t// Ideally, I should probably move the minion spawn index to another paradigm: keep the dead minions\r\n\t\t\t\t\t\t\t// until there are new spawns, and delete them afterwards, so I can easily refer to their index\r\n\t\t\t\t\t\t\t// by just looking them up, and spawning to the right\r\n\t\t\t\t\t\t\t// However, since this doesn't work, maybe I can look for entity indices adjustments needed\r\n\t\t\t\t\t\t\t// by looking up the position changes of other minions?\r\n\t\t\t\t\t\t\t// Not sure how this could work without creating a giant mess, so for now it will probably\r\n\t\t\t\t\t\t\t// stay as a bug\r\n\t\t\t\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\t\t\t\tentity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\t1,\r\n\t\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t// Add all the deathrattles that don't have an effect on combat\r\n\t\t\tcase CardIds.FieryFelblood_BG29_877:\r\n\t\t\tcase CardIds.FieryFelblood_BG29_877_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\t// It's important to first copy the enchantments, otherwise you could end up\r\n\t// in an infinite loop - since new enchants are added after each step\r\n\tlet enchantments: { cardId: string; originEntityId?: number; repeats?: number }[] = [\r\n\t\t...(deadEntity.enchantments ?? []),\r\n\t\t// These seem to be first processed separately\r\n\t\t// ...(deadEntity.rememberedDeathrattles ?? []),\r\n\t].sort((a, b) => a.timing - b.timing);\r\n\t// In some cases it's possible that there are way too many enchantments because of the frog\r\n\t// In that case, we make a trade-off and don't trigger the \"on stats change\" trigger as\r\n\t// often as we should, so that we can have the stats themselves correct\r\n\t// We don't want to lump everything together, as it skews the stats when there are a lot of buffs\r\n\t// Instead, we build groups\r\n\tconst maxNumberOfGroups = 12;\r\n\tconst enchantmentGroups = groupByFunction((enchantment: any) => enchantment.cardId)(enchantments);\r\n\tenchantments = Object.keys(enchantmentGroups).flatMap((cardId) => {\r\n\t\tlet repeatsToApply = enchantmentGroups[cardId].map((e) => e.repeats || 1).reduce((a, b) => a + b, 0);\r\n\r\n\t\t// Frogs include the multiplers here directly\r\n\t\tif (\r\n\t\t\t[\r\n\t\t\t\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e,\r\n\t\t\t\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge,\r\n\t\t\t].includes(cardId as CardIds)\r\n\t\t) {\r\n\t\t\trepeatsToApply = repeatsToApply * multiplier;\r\n\t\t}\r\n\r\n\t\tconst results = [];\r\n\t\tconst repeatsPerBuff = Math.max(1, Math.floor(repeatsToApply / maxNumberOfGroups));\r\n\t\tlet repeatsDone = 0;\r\n\t\twhile (repeatsDone < repeatsToApply) {\r\n\t\t\tconst repeats = Math.min(repeatsPerBuff, repeatsToApply - repeatsDone);\r\n\t\t\tresults.push({\r\n\t\t\t\tcardId: cardId,\r\n\t\t\t\trepeats: repeats,\r\n\t\t\t\ttiming: Math.min(...enchantmentGroups[cardId].map((e) => e.timing)),\r\n\t\t\t});\r\n\t\t\trepeatsDone += repeatsPerBuff;\r\n\t\t}\r\n\t\treturn results;\r\n\t});\r\n\tfor (const enchantment of enchantments) {\r\n\t\tswitch (enchantment.cardId) {\r\n\t\t\tcase CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e:\r\n\t\t\tcase CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge:\r\n\t\t\t\tapplyLeapFroggerEffect(\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tenchantment.cardId === CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tenchantment.repeats || 1,\r\n\t\t\t\t);\r\n\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.EarthRecollectionEnchantment:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyEarthInvocationEnchantment(boardWithDeadEntity, deadEntity, deadEntity, gameState);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.FireRecollectionEnchantment:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyFireInvocationEnchantment(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.WaterRecollectionEnchantment:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyWaterInvocationEnchantment(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.LightningRecollectionEnchantment:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyLightningInvocationEnchantment(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\t// const playerCopy = boardWithDeadEntity.map((e) => ({ ...e, lastAffectedByEntity: null }));\r\n\t// const oppCopy = otherBoard.map((e) => ({ ...e, lastAffectedByEntity: null }));\r\n\t// console.log('player board', boardWithDeadEntity.length, playerCopy.length, playerCopy.map((e) => JSON.stringify(e)).join('\\n'));\r\n\t// console.log('opp board', JSON.stringify(oppCopy));\r\n};\r\n\r\nexport const applyLightningInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// Because the golden version doubles all the remembered effects\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst targets = pickMultipleRandomDifferent(otherBoard, 5);\r\n\t\tfor (const target of targets) {\r\n\t\t\tdealDamageToMinion(\r\n\t\t\t\ttarget,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tdeadEntity,\r\n\t\t\t\t1,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyWaterInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst validBoard = boardWithDeadEntity.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\t\tconst target: BoardEntity = validBoard[validBoard.length - 1];\r\n\t\tif (!!target) {\r\n\t\t\ttarget.taunt = true;\r\n\t\t\tmodifyStats(target, 0, 3, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(sourceEntity, target, boardWithDeadEntity, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyFireInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst target: BoardEntity = boardWithDeadEntity.filter((e) => e.health > 0 && !e.definitelyDead)[0];\r\n\t\tif (!!target) {\r\n\t\t\tmodifyStats(target, target.attack, 0, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(sourceEntity, target, boardWithDeadEntity, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyEarthInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst minionsGrantedDeathrattle: BoardEntity[] = pickMultipleRandomDifferent(boardWithDeadEntity, 4);\r\n\t\tminionsGrantedDeathrattle.forEach((minion) => {\r\n\t\t\tminion.enchantments.push({\r\n\t\t\t\tcardId: CardIds.EarthInvocation_ElementEarthEnchantment,\r\n\t\t\t\toriginEntityId: deadEntity?.entityId,\r\n\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t});\r\n\t\t\tgameState.spectator.registerPowerTarget(sourceEntity, minion, boardWithDeadEntity, null, null);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nconst applyLeapFroggerEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tgameState: FullGameState,\r\n\tmultiplier = 1,\r\n): void => {\r\n\tmultiplier = multiplier || 1;\r\n\tconst buffed = grantRandomStats(\r\n\t\tdeadEntity,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tmultiplier * (isPremium ? 2 : 1),\r\n\t\tmultiplier * (isPremium ? 2 : 1),\r\n\t\tRace.BEAST,\r\n\t\tfalse,\r\n\t\tgameState,\r\n\t);\r\n\tif (buffed) {\r\n\t\tbuffed.enchantments = buffed.enchantments ?? [];\r\n\t\tbuffed.enchantments.push({\r\n\t\t\tcardId: isPremium\r\n\t\t\t\t? CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge\r\n\t\t\t\t: CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e,\r\n\t\t\toriginEntityId: deadEntity.entityId,\r\n\t\t\trepeats: multiplier > 1 ? multiplier : 1,\r\n\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t});\r\n\t\t// Don't register power effect here, since it's already done in the random stats\r\n\t\t// spectator.registerPowerTarget(deadEntity, buffed, boardWithDeadEntity);\r\n\t\t// console.log('applyLeapFroggerEffect', stringifySimpleCard(deadEntity), stringifySimpleCard(buffed));\r\n\t}\r\n};\r\n\r\nconst applyRecurringNightmareDeathrattleEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tsharedState: SharedState,\r\n\tmultiplier = 1,\r\n): void => {\r\n\tmultiplier = multiplier || 1;\r\n\tconst target = pickRandom(\r\n\t\tboardWithDeadEntity\r\n\t\t\t.filter((e) => hasCorrectTribe(e, Race.UNDEAD, allCards))\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId !== CardIds.RecurringNightmare_BG26_055 &&\r\n\t\t\t\t\te.cardId !== CardIds.RecurringNightmare_BG26_055_G,\r\n\t\t\t),\r\n\t);\r\n\tif (target) {\r\n\t\ttarget.enchantments = target.enchantments ?? [];\r\n\t\ttarget.enchantments.push({\r\n\t\t\tcardId: isPremium\r\n\t\t\t\t? CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055_Ge\r\n\t\t\t\t: CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055e,\r\n\t\t\toriginEntityId: deadEntity.entityId,\r\n\t\t\trepeats: multiplier > 1 ? multiplier : 1,\r\n\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t});\r\n\t\tspectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity, null, null);\r\n\t}\r\n};\r\n\r\nexport const handleAfterMinionKillsEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst killer = deadEntity.lastAffectedByEntity;\r\n\tif (!killer) {\r\n\t\treturn;\r\n\t}\r\n\t// Killed an enemy minion\r\n\tif (killer.friendly !== deadEntity.friendly) {\r\n\t\tif (otherBoardHero.heroPowerId === CardIds.Rokara_GloryOfCombat) {\r\n\t\t\tmodifyStats(killer, 1, 0, otherBoard, otherBoardHero, gameState);\r\n\t\t}\r\n\r\n\t\t// Icesnarl the Mighty\r\n\t\t// The timing here might be off, as the following replay suggests that the effect should trigger\r\n\t\t// before Sr. Tomb Diver's deathrattle is applied\r\n\t\t// http://replays.firestoneapp.com/?reviewId=ebb4e2d6-11b4-44f4-a052-3be2c63dd38f&turn=11&action=6\r\n\t\t// Update 2024-30-06: lived tgus ub ab \"after minion kills\" trigger, let's see how that works\r\n\t\totherBoard\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy ||\r\n\t\t\t\t\te.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy_G,\r\n\t\t\t)\r\n\t\t\t.forEach((icesnarl) => {\r\n\t\t\t\tmodifyStats(\r\n\t\t\t\t\ticesnarl,\r\n\t\t\t\t\t0,\r\n\t\t\t\t\ticesnarl.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy_G ? 2 : 1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t}\r\n};\r\n\r\nexport const applyWheneverMinionDiesEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// console.log('applying minion death effect', stringifySimpleCard(deadEntity, allCards));\r\n\tif (isCorrectTribe(gameState.allCards.getCard(deadEntity.cardId).races, Race.BEAST)) {\r\n\t\tapplyScavengingHyenaEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\tif (isCorrectTribe(gameState.allCards.getCard(deadEntity.cardId).races, Race.DEMON)) {\r\n\t\tapplySoulJugglerEffect(boardWithDeadEntity, boardWithDeadEntityHero, otherBoard, otherBoardHero, gameState);\r\n\t}\r\n\tif (isCorrectTribe(gameState.allCards.getCard(deadEntity.cardId).races, Race.MECH)) {\r\n\t\tapplyJunkbotEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, Race.MURLOC, gameState.allCards)) {\r\n\t\tremoveOldMurkEyeAttack(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\tremoveOldMurkEyeAttack(otherBoard, otherBoardHero, gameState);\r\n\t}\r\n\tif (deadEntity.taunt) {\r\n\t\tapplyBristlemaneScrapsmithEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\tapplyQirajiHarbringerEffect(boardWithDeadEntity, boardWithDeadEntityHero, deadEntityIndexFromRight, gameState);\r\n\t}\r\n\r\n\tif (\r\n\t\tdeadEntity.cardId === CardIds.EternalKnight_BG25_008 ||\r\n\t\tdeadEntity.cardId === CardIds.EternalKnight_BG25_008_G\r\n\t) {\r\n\t\tapplyEternalKnightEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\r\n\t// Putricide-only\r\n\tboardWithDeadEntity\r\n\t\t.filter((e) => e.additionalCards?.includes(CardIds.FlesheatingGhoulLegacy_BG26_tt_004))\r\n\t\t.forEach((e) => {\r\n\t\t\tmodifyStats(e, 1, 0, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t});\r\n\r\n\tapplyRotHideGnollEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\r\n\t// Overkill\r\n\tif (deadEntity.health < 0 && deadEntity.lastAffectedByEntity?.attacking) {\r\n\t\tif (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlame_BGS_032) {\r\n\t\t\tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t\tif (targets.length > 0) {\r\n\t\t\t\tconst target = targets[0];\r\n\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t\t\t3,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlame_TB_BaconUps_103) {\r\n\t\t\tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t\tif (targets.length > 0) {\r\n\t\t\t\tconst target = targets[0];\r\n\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t\t\t6,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t\t// else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental && deadEntity.lastAffectedByEntity.attacking) {\r\n\t\t// \t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental) {\r\n\t\t// \t// console.log('applying WildfireElemental effect', stringifySimple(boardWithDeadEntity, allCards));\r\n\t\t// \tconst excessDamage = -deadEntity.health;\r\n\t\t// \t// Prevent propagation of the effect\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking = false;\r\n\t\t// \tconst neighbours = getNeighbours(boardWithDeadEntity, null, boardWithDeadEntity.length - deadEntityIndexFromRight);\r\n\t\t// \t// console.log('neighbours', stringifySimple(neighbours, allCards));\r\n\t\t// \tif (neighbours.length > 0) {\r\n\t\t// \t\tconst randomTarget = neighbours[Math.floor(Math.random() * neighbours.length)];\r\n\t\t// \t\tdealDamageToEnemy(\r\n\t\t// \t\t\trandomTarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\texcessDamage,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tallCards,\r\n\t\t// \t\t\tcardsData,\r\n\t\t// \t\t\tsharedState,\r\n\t\t// \t\t\tspectator,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// } else if (\r\n\t\t// \tdeadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElementalBattlegrounds &&\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking\r\n\t\t// ) {\r\n\t\t// \tconst excessDamage = -deadEntity.health;\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking = false;\r\n\t\t// \tconst neighbours = getNeighbours(boardWithDeadEntity, null, boardWithDeadEntity.length - deadEntityIndexFromRight);\r\n\t\t// \tneighbours.forEach((neighbour) =>\r\n\t\t// \t\tdealDamageToEnemy(\r\n\t\t// \t\t\tneighbour,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\texcessDamage,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tallCards,\r\n\t\t// \t\t\tcardsData,\r\n\t\t// \t\t\tsharedState,\r\n\t\t// \t\t\tspectator,\r\n\t\t// \t\t),\r\n\t\t// \t);\r\n\t\t// }\r\n\t\telse if (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn_TRL_232) {\r\n\t\t\tconst newEntities = spawnEntities(\r\n\t\t\t\tCardIds.IronhideDirehorn_IronhideRuntToken_TRL_232t,\r\n\t\t\t\t1,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState.allCards,\r\n\t\t\t\tgameState.cardsData,\r\n\t\t\t\tgameState.sharedState,\r\n\t\t\t\tgameState.spectator,\r\n\t\t\t\t!deadEntity.friendly,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t\totherBoard.splice(otherBoard.length - deadEntityIndexFromRight, 0, ...newEntities);\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn_TB_BaconUps_051) {\r\n\t\t\tconst newEntities = spawnEntities(\r\n\t\t\t\tCardIds.IronhideDirehorn_IronhideRuntToken_TB_BaconUps_051t,\r\n\t\t\t\t1,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState.allCards,\r\n\t\t\t\tgameState.cardsData,\r\n\t\t\t\tgameState.sharedState,\r\n\t\t\t\tgameState.spectator,\r\n\t\t\t\t!deadEntity.friendly,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t\totherBoard.splice(otherBoard.length - deadEntityIndexFromRight, 0, ...newEntities);\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath_BGS_080) {\r\n\t\t\tconst otherPirates = otherBoard\r\n\t\t\t\t.filter((entity) => isCorrectTribe(gameState.allCards.getCard(entity.cardId).races, Race.PIRATE))\r\n\t\t\t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\totherPirates.forEach((pirate) => {\r\n\t\t\t\tmodifyStats(pirate, 2, 2, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t\t\tpirate,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath_TB_BaconUps_142) {\r\n\t\t\tconst otherPirates = otherBoard\r\n\t\t\t\t.filter((entity) => isCorrectTribe(gameState.allCards.getCard(entity.cardId).races, Race.PIRATE))\r\n\t\t\t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\totherPirates.forEach((pirate) => {\r\n\t\t\t\tmodifyStats(pirate, 4, 4, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t\t\tpirate,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n};\r\n\r\n/** @deprecated */\r\nexport const dealDamageToAllMinions = (\r\n\tboard1: BoardEntity[],\r\n\tboard1Hero: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tboard2Hero: BgsPlayerEntity,\r\n\tdamageSource: BoardEntity,\r\n\tdamageDealt: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (board1.length === 0 && board2.length === 0) {\r\n\t\treturn;\r\n\t}\r\n\tfor (let i = 0; i < board1.length; i++) {\r\n\t\tdealDamageToMinion(board1[i], board1, board1Hero, damageSource, damageDealt, board2, board2Hero, gameState);\r\n\t}\r\n\tfor (let i = 0; i < board2.length; i++) {\r\n\t\tdealDamageToMinion(board2[i], board2, board2Hero, damageSource, damageDealt, board1, board1Hero, gameState);\r\n\t}\r\n};\r\n\r\nconst applySoulJugglerEffect = (\r\n\tboardWithJugglers: BoardEntity[],\r\n\tboardWithJugglersHero: BgsPlayerEntity,\r\n\tboardToAttack: BoardEntity[],\r\n\tboardToAttackHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (boardWithJugglers.length === 0 && boardToAttack.length === 0) {\r\n\t\treturn;\r\n\t\t// return [boardWithJugglers, boardToAttack];\r\n\t}\r\n\tconst jugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler_BGS_002);\r\n\tfor (const juggler of jugglers) {\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t3,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\tconst goldenJugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler_TB_BaconUps_075);\r\n\tfor (const juggler of goldenJugglers) {\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t3,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t3,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\t// processMinionDeath(\r\n\t// \tboardWithJugglers,\r\n\t// \tboardWithJugglersHero,\r\n\t// \tboardToAttack,\r\n\t// \tboardToAttackHero,\r\n\t// \tallCards,\r\n\t// \tcardsData,\r\n\t// \tsharedState,\r\n\t// \tspectator,\r\n\t// );\r\n};\r\n\r\nconst applyScavengingHyenaEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// const copy = [...board];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.ScavengingHyenaLegacy_BG_EX1_531) {\r\n\t\t\tmodifyStats(board[i], 2, 1, board, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t} else if (board[i].cardId === CardIds.ScavengingHyenaLegacy_TB_BaconUps_043) {\r\n\t\t\tmodifyStats(board[i], 4, 2, board, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyEternalKnightEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (\r\n\t\t\tboard[i].cardId === CardIds.EternalKnight_BG25_008 ||\r\n\t\t\tboard[i].cardId === CardIds.EternalKnight_BG25_008_G\r\n\t\t) {\r\n\t\t\tconst multiplier = board[i].cardId === CardIds.EternalKnight_BG25_008_G ? 2 : 1;\r\n\t\t\tmodifyStats(board[i], multiplier * 1, multiplier * 1, board, hero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyRotHideGnollEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.RotHideGnoll_BG25_013 || board[i].cardId === CardIds.RotHideGnoll_BG25_013_G) {\r\n\t\t\tconst multiplier = board[i].cardId === CardIds.RotHideGnoll_BG25_013_G ? 2 : 1;\r\n\t\t\tmodifyStats(board[i], multiplier * 1, 0, board, hero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyBristlemaneScrapsmithEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardPlayerEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (\r\n\t\t\tboard[i].cardId === CardIds.BristlemaneScrapsmith_BG24_707 ||\r\n\t\t\tboard[i].cardId === CardIds.BristlemaneScrapsmith_BG24_707_G\r\n\t\t) {\r\n\t\t\tconst cardsToAdd = Array(CardIds.BristlemaneScrapsmith_BG24_707_G ? 2 : 1).fill(CardIds.BloodGem);\r\n\t\t\taddCardsInHand(boardPlayerEntity, board, cardsToAdd, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, boardPlayerEntity, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyJunkbotEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.Junkbot_GVG_106) {\r\n\t\t\tmodifyStats(board[i], 2, 2, board, hero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t} else if (board[i].cardId === CardIds.Junkbot_TB_BaconUps_046) {\r\n\t\t\tmodifyStats(board[i], 4, 4, board, hero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyQirajiHarbringerEffect = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst qiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger_BGS_112);\r\n\tconst goldenQiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger_TB_BaconUps_303);\r\n\r\n\t// TODO: if reactivated, properly apply buffs one by one, instead of all together\r\n\tif (qiraji.length + goldenQiraji.length > 0) {\r\n\t\tconst neighbours = getNeighbours(board, null, deadEntityIndexFromRight);\r\n\t\tconst buff = 2 * qiraji.length + 4 * goldenQiraji.length;\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyStats(entity, buff, buff, board, hero, gameState);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const applyMonstrosity = (\r\n\tmonstrosity: BoardEntity,\r\n\tdeadEntities: readonly BoardEntity[],\r\n\tboardWithDeadEntities: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tfor (const deadEntity of deadEntities) {\r\n\t\tmodifyStats(monstrosity, deadEntity.attack, 0, boardWithDeadEntities, boardWithDeadEntityHero, gameState);\r\n\t\tif (monstrosity.cardId === CardIds.Monstrosity_BG20_HERO_282_Buddy_G) {\r\n\t\t\tmodifyStats(monstrosity, deadEntity.attack, 0, boardWithDeadEntities, boardWithDeadEntityHero, gameState);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const rememberDeathrattles = (\r\n\tfish: BoardEntity,\r\n\tdeadEntities: readonly BoardEntity[],\r\n\tcardsData: CardsData,\r\n\tallCards: AllCardsService,\r\n\tsharedState: SharedState,\r\n): void => {\r\n\tconst validDeathrattles = deadEntities\r\n\t\t.filter((entity) => cardsData.validDeathrattles.includes(entity.cardId) || isFish(entity))\r\n\t\t.map((entity) => ({ cardId: entity.cardId, repeats: 1, timing: sharedState.currentEntityId++ }));\r\n\tconst validEnchantments = deadEntities\r\n\t\t.filter((entity) => entity.enchantments?.length)\r\n\t\t.map((entity) => entity.enchantments)\r\n\t\t.reduce((a, b) => a.concat(b), [])\r\n\t\t.flatMap((enchantment) => ({\r\n\t\t\tcardId: enchantment.cardId,\r\n\t\t\trepeats: enchantment.repeats ?? 1,\r\n\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t}))\r\n\t\t.filter((enchantment) => VALID_DEATHRATTLE_ENCHANTMENTS.includes(enchantment.cardId as CardIds));\r\n\t// Multiple fish\r\n\tconst deadEntityRememberedDeathrattles =\r\n\t\tdeadEntities\r\n\t\t\t.filter((e) => !!e.rememberedDeathrattles?.length)\r\n\t\t\t// If the fish has reborn, it will inherit its own Deathrattles, and we don't want that\r\n\t\t\t.filter((e) => e.entityId !== fish.rebornFromEntityId)\r\n\t\t\t.flatMap((e) => e.rememberedDeathrattles) ?? [];\r\n\tconst newDeathrattles = [...validDeathrattles, ...validEnchantments, ...deadEntityRememberedDeathrattles];\r\n\t// Order is important - the DR are triggered in the ordered the minions have died\r\n\tif (isGolden(fish.cardId, allCards)) {\r\n\t\t// https://stackoverflow.com/questions/33305152/how-to-duplicate-elements-in-a-js-array\r\n\t\tconst doubleDr = newDeathrattles.reduce((res, current) => res.concat([current, current]), []);\r\n\t\tfish.rememberedDeathrattles = [...(fish.rememberedDeathrattles || []), ...doubleDr];\r\n\t} else {\r\n\t\tfish.rememberedDeathrattles = [...(fish.rememberedDeathrattles || []), ...newDeathrattles];\r\n\t}\r\n\tif (fish.rememberedDeathrattles?.length) {\r\n\t\tfish.rememberedDeathrattles.sort((a, b) => a.timing - b.timing);\r\n\t}\r\n\t// console.debug(\r\n\t// \t'remembered',\r\n\t// \tfish.rememberedDeathrattles.map((d) => ({\r\n\t// \t\tcardId: d.cardId,\r\n\t// \t\tname: allCards.getCard(d.cardId)?.name,\r\n\t// \t\t// repeats: d.repeats,\r\n\t// \t\ttiming: d.timing,\r\n\t// \t})),\r\n\t// );\r\n};\r\n\r\nconst removeOldMurkEyeAttack = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst murkeyes = boardWithDeadEntity.filter(\r\n\t\t(entity) => entity.cardId === CardIds.OldMurkEyeLegacy || entity.cardId === CardIds.OldMurkEyeVanilla,\r\n\t);\r\n\tconst goldenMurkeyes = boardWithDeadEntity.filter((entity) => entity.cardId === CardIds.OldMurkEye);\r\n\tmurkeyes.forEach((entity) => {\r\n\t\tmodifyStats(entity, -1, 0, boardWithDeadEntity, hero, gameState);\r\n\t});\r\n\tgoldenMurkeyes.forEach((entity) => {\r\n\t\tmodifyStats(entity, -2, 0, boardWithDeadEntity, hero, gameState);\r\n\t});\r\n};\r\n"]}
1
+ {"version":3,"file":"deathrattle-effects.js","sourceRoot":"","sources":["../../src/simulation/deathrattle-effects.ts"],"names":[],"mappings":";;;AACA,iEAAiG;AAIjG,6CAM2B;AAC3B,gEAAwE;AACxE,oCAakB;AAClB,qCAMkB;AAClB,+CAAiD;AACjD,6CAA+C;AAC/C,mDAAiD;AACjD,qEAA6F;AAC7F,6DAAqD;AAIrD,mCAAsC;AACtC,2CAAkD;AAE3C,MAAM,4BAA4B,GAAG,CAC3C,KAAoB,EACpB,SAA0B,EAC1B,UAAuB,EACvB,WAAwB,EACf,EAAE;;IACX,MAAM,SAAS,GACd,CAAC,CAAC,KAAK,CAAC,IAAI,CACX,CAAC,MAAM,EAAE,EAAE,CACV,MAAM,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M,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,sBAAuB,CAAC,CAAC;IACpG,QAAQ,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QAC3B,IAAA,mBAAW,EAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,mBAAmB,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IACH,cAAc,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QACjC,IAAA,mBAAW,EAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,mBAAmB,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds, CardType, GameTag, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardsData } from '../cards/cards-data';\r\nimport {\r\n\tgroupByFunction,\r\n\tpickMultipleRandomDifferent,\r\n\tpickRandom,\r\n\tpickRandomAlive,\r\n\tpickRandomLowestHealth,\r\n} from '../services/utils';\r\nimport { VALID_DEATHRATTLE_ENCHANTMENTS } from '../simulate-bgs-battle';\r\nimport {\r\n\taddStatsToBoard,\r\n\tgrantRandomAttack,\r\n\tgrantRandomDivineShield,\r\n\tgrantRandomHealth,\r\n\tgrantRandomStats,\r\n\tgrantStatsToMinionsOfEachType,\r\n\thasCorrectTribe,\r\n\thasMechanic,\r\n\tisCorrectTribe,\r\n\tisFish,\r\n\tisGolden,\r\n\tupdateDivineShield,\r\n} from '../utils';\r\nimport {\r\n\tdealDamageToMinion,\r\n\tdealDamageToRandomEnemy,\r\n\tfindNearestEnemies,\r\n\tgetNeighbours,\r\n\tprocessMinionDeath,\r\n} from './attack';\r\nimport { triggerBattlecry } from './battlecries';\r\nimport { playBloodGemsOn } from './blood-gems';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport { DeathrattleTriggeredInput, onDeathrattleTriggered } from './deathrattle-on-trigger';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { SharedState } from './shared-state';\r\nimport { Spectator } from './spectator/spectator';\r\nimport { modifyStats } from './stats';\r\nimport { makeMinionGolden } from './utils/golden';\r\n\r\nexport const computeDeathrattleMultiplier = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tsharedState: SharedState,\r\n): number => {\r\n\tconst rivendare =\r\n\t\t!!board.find(\r\n\t\t\t(entity) =>\r\n\t\t\t\tentity.cardId === CardIds.BaronRivendare_BG_FP1_031 ||\r\n\t\t\t\tentity.cardId === CardIds.MoiraBronzebeard_BG27_518,\r\n\t\t) || boardHero.secrets?.some((e) => e.cardId === CardIds.TitusTribute_BG28_843);\r\n\tconst goldenRivendare = board.find(\r\n\t\t(entity) =>\r\n\t\t\tentity.cardId === CardIds.BaronRivendare_TB_BaconUps_055 ||\r\n\t\t\tentity.cardId === CardIds.MoiraBronzebeard_BG27_518_G,\r\n\t);\r\n\tconst titus = board.filter((entity) => entity.cardId === CardIds.TitusRivendare_BG25_354).length;\r\n\tconst goldenTitus = board.filter((entity) => entity.cardId === CardIds.TitusRivendare_BG25_354_G).length;\r\n\tconst tombs =\r\n\t\tboardHero.questRewardEntities?.filter((entity) => entity.cardId === CardIds.TurbulentTombs)?.length ?? 0;\r\n\tconst echoesOfArgus = sharedState.anomalies.includes(CardIds.EchoesOfArgus_BG27_Anomaly_802) ? 1 : 0;\r\n\tconst scourgeMultiplier = deadEntity.additionalCards?.includes(CardIds.ScourgeTroll) ? 2 : 1;\r\n\r\n\tconst multiplier =\r\n\t\tscourgeMultiplier *\r\n\t\t((goldenRivendare ? 3 : rivendare ? 2 : 1) + titus + 2 * goldenTitus + tombs + echoesOfArgus);\r\n\treturn multiplier;\r\n};\r\n\r\n// export const handleDeathrattles = (\r\n// \tboardWithKilledMinion: BoardEntity[],\r\n// \tboardWithKilledMinionHero: BgsPlayerEntity,\r\n// \tdeadEntity: BoardEntity,\r\n// \tdeadMinionIndexFromRight2: number,\r\n// \topponentBoard: BoardEntity[],\r\n// \topponentBoardHero: BgsPlayerEntity,\r\n// \tentitiesDeadThisAttack: readonly BoardEntity[],\r\n// \tgameState: InternalGameState,\r\n// ) => {};\r\n\r\nexport const handleDeathrattleEffects = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = computeDeathrattleMultiplier(\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tdeadEntity,\r\n\t\tgameState.sharedState,\r\n\t);\r\n\tconst deathrattleTriggeredInput: DeathrattleTriggeredInput = {\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tdeadEntity,\r\n\t\totherBoard,\r\n\t\totherBoardHero,\r\n\t\tgameState,\r\n\t};\r\n\r\n\t// We do it on a case by case basis so that we deal all the damage in one go for instance\r\n\t// and avoid proccing deathrattle spawns between the times the damage triggers\r\n\tconst cardIds = [deadEntity.cardId, ...(deadEntity.additionalCards ?? [])];\r\n\t// TODO put the muliplier look here, and handle onDeathrattleTriggered like is done for\r\n\t// deathrattle-spawns\r\n\tfor (const deadEntityCardId of cardIds) {\r\n\t\tswitch (deadEntityCardId) {\r\n\t\t\tcase CardIds.RylakMetalhead_BG26_801:\r\n\t\t\tcase CardIds.RylakMetalhead_BG26_801_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst allNeighbours = getNeighbours(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tdeadEntityIndexFromRight,\r\n\t\t\t\t\t).filter((e) => hasMechanic(gameState.allCards.getCard(e.cardId), GameTag[GameTag.BATTLECRY]));\r\n\t\t\t\t\tconst neighbours =\r\n\t\t\t\t\t\tdeadEntityCardId === CardIds.RylakMetalhead_BG26_801_G\r\n\t\t\t\t\t\t\t? allNeighbours\r\n\t\t\t\t\t\t\t: [pickRandom(allNeighbours)].filter((e) => !!e);\r\n\t\t\t\t\t// console.debug(\r\n\t\t\t\t\t// \t'triggering neighbours',\r\n\t\t\t\t\t// \tstringifySimple(neighbours, gameState.allCards),\r\n\t\t\t\t\t// \tstringifySimple(allNeighbours, gameState.allCards),\r\n\t\t\t\t\t// );\r\n\t\t\t\t\tfor (const neighbour of neighbours) {\r\n\t\t\t\t\t\t// console.debug('\\ttriggering neighbour', stringifySimpleCard(neighbour, gameState.allCards));\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\tneighbour,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\t// for (let j = 0; j < rylakMutltiplier; j++) {\r\n\t\t\t\t\t\ttriggerBattlecry(\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tneighbour,\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\t// }\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SelflessHero_BG_OG_221:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomDivineShield(deadEntity, boardWithDeadEntity, gameState.allCards, gameState.spectator);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SelflessHero_TB_BaconUps_014:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomDivineShield(deadEntity, boardWithDeadEntity, gameState.allCards, gameState.spectator);\r\n\t\t\t\t\tgrantRandomDivineShield(deadEntity, boardWithDeadEntity, gameState.allCards, gameState.spectator);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.OperaticBelcher_BG26_888:\r\n\t\t\tcase CardIds.OperaticBelcher_BG26_888_G:\r\n\t\t\t\tconst belcherMultiplier = deadEntityCardId === CardIds.OperaticBelcher_BG26_888_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < belcherMultiplier; j++) {\r\n\t\t\t\t\t\tconst possibleBelcherTargets = boardWithDeadEntity\r\n\t\t\t\t\t\t\t.filter((entity) => !entity.venomous)\r\n\t\t\t\t\t\t\t.filter((entity) => !entity.poisonous)\r\n\t\t\t\t\t\t\t.filter((entity) => entity.health > 0 && !entity.definitelyDead)\r\n\t\t\t\t\t\t\t.filter((entity) => hasCorrectTribe(entity, Race.MURLOC, gameState.allCards));\r\n\t\t\t\t\t\tif (possibleBelcherTargets.length > 0) {\r\n\t\t\t\t\t\t\tconst chosen = pickRandom(possibleBelcherTargets);\r\n\t\t\t\t\t\t\tchosen.venomous = true;\r\n\t\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\tchosen,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SpiritOfAir_TB_BaconShop_HERO_76_Buddy:\r\n\t\t\tcase CardIds.SpiritOfAir_TB_BaconShop_HERO_76_Buddy_G:\r\n\t\t\t\tconst iterations = deadEntityCardId === CardIds.SpiritOfAir_TB_BaconShop_HERO_76_Buddy_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < iterations; j++) {\r\n\t\t\t\t\t\tlet validTargets = boardWithDeadEntity.filter((entity) => !entity.divineShield);\r\n\t\t\t\t\t\tif (!validTargets?.length) {\r\n\t\t\t\t\t\t\tvalidTargets = boardWithDeadEntity.filter((entity) => !entity.taunt);\r\n\t\t\t\t\t\t\tif (!validTargets?.length) {\r\n\t\t\t\t\t\t\t\tvalidTargets = boardWithDeadEntity.filter((entity) => !entity.windfury);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tconst target = pickRandom(validTargets);\r\n\t\t\t\t\t\tif (target) {\r\n\t\t\t\t\t\t\tif (!target.divineShield) {\r\n\t\t\t\t\t\t\t\tupdateDivineShield(target, boardWithDeadEntity, true, gameState.allCards);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\ttarget.taunt = true;\r\n\t\t\t\t\t\t\ttarget.windfury = true;\r\n\t\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.NadinaTheRed_BGS_040:\r\n\t\t\tcase CardIds.NadinaTheRed_TB_BaconUps_154:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst nadinaMultiplier = deadEntityCardId === CardIds.NadinaTheRed_TB_BaconUps_154 ? 6 : 3;\r\n\t\t\t\t\tfor (let j = 0; j < nadinaMultiplier; j++) {\r\n\t\t\t\t\t\tconst validTargets = boardWithDeadEntity\r\n\t\t\t\t\t\t\t.filter((e) => hasCorrectTribe(e, Race.DRAGON, gameState.allCards))\r\n\t\t\t\t\t\t\t.filter((entity) => !entity.divineShield);\r\n\t\t\t\t\t\tconst target = pickRandom(validTargets);\r\n\t\t\t\t\t\tif (target) {\r\n\t\t\t\t\t\t\tupdateDivineShield(target, boardWithDeadEntity, true, gameState.allCards);\r\n\t\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SpawnOfNzoth_BG_OG_256:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, boardWithDeadEntityHero, 1, 1, gameState);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SpawnOfNzoth_TB_BaconUps_025:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, boardWithDeadEntityHero, 2, 2, gameState);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.GoldrinnTheGreatWolf_BGS_018:\r\n\t\t\tcase CardIds.GoldrinnTheGreatWolf_TB_BaconUps_085:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst goldrinnBuff = deadEntityCardId === CardIds.GoldrinnTheGreatWolf_TB_BaconUps_085 ? 8 : 4;\r\n\t\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tgoldrinnBuff,\r\n\t\t\t\t\t\tgoldrinnBuff,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t'BEAST',\r\n\t\t\t\t\t);\r\n\t\t\t\t\tboardWithDeadEntityHero.globalInfo.GoldrinnBuffAtk += goldrinnBuff;\r\n\t\t\t\t\tboardWithDeadEntityHero.globalInfo.GoldrinnBuffHealth += goldrinnBuff;\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SilithidBurrower_BG29_871:\r\n\t\t\tcase CardIds.SilithidBurrower_BG29_871_G:\r\n\t\t\t\tconst silithidStats = deadEntity.cardId === CardIds.SilithidBurrower_BG29_871_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tsilithidStats,\r\n\t\t\t\t\t\tsilithidStats,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\tRace[Race.BEAST],\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t// case CardIds.KingBagurgle_BGS_030:\r\n\t\t\t// \taddStatsToBoard(\r\n\t\t\t// \t\tdeadEntity,\r\n\t\t\t// \t\tboardWithDeadEntity,\r\n\t\t\t// \t\tmultiplier * 2,\r\n\t\t\t// \t\tmultiplier * 3,\r\n\t\t\t// \t\tgameState.allCards,\r\n\t\t\t// \t\tgameState.spectator,\r\n\t\t\t// \t\t'MURLOC',\r\n\t\t\t// \t);\r\n\t\t\t// \tbreak;\r\n\t\t\t// case CardIds.KingBagurgle_TB_BaconUps_100:\r\n\t\t\t// \taddStatsToBoard(\r\n\t\t\t// \t\tdeadEntity,\r\n\t\t\t// \t\tboardWithDeadEntity,\r\n\t\t\t// \t\tmultiplier * 4,\r\n\t\t\t// \t\tmultiplier * 6,\r\n\t\t\t// \t\tgameState.allCards,\r\n\t\t\t// \t\tgameState.spectator,\r\n\t\t\t// \t\t'MURLOC',\r\n\t\t\t// \t);\r\n\t\t\t// \tbreak;\r\n\t\t\tcase CardIds.FiendishServant_YOD_026:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomAttack(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tdeadEntity.attack,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.FiendishServant_TB_BaconUps_112:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomAttack(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tdeadEntity.attack,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tgrantRandomAttack(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tdeadEntity.attack,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ImpulsiveTrickster_BG21_006:\r\n\t\t\tcase CardIds.ImpulsiveTrickster_BG21_006_G:\r\n\t\t\t\tconst tricksterMultiplier = deadEntityCardId === CardIds.ImpulsiveTrickster_BG21_006_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < tricksterMultiplier; j++) {\r\n\t\t\t\t\t\tconst targetBoard =\r\n\t\t\t\t\t\t\tdeadEntity.entityId === 2521\r\n\t\t\t\t\t\t\t\t? boardWithDeadEntity.filter((e) => e.entityId === 3047)\r\n\t\t\t\t\t\t\t\t: deadEntity.entityId === 2522\r\n\t\t\t\t\t\t\t\t? boardWithDeadEntity.filter((e) => e.entityId === 2830)\r\n\t\t\t\t\t\t\t\t: boardWithDeadEntity;\r\n\t\t\t\t\t\tgrantRandomHealth(\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\ttargetBoard,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tdeadEntity.maxHealth,\r\n\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.NightbaneIgnited_BG29_815:\r\n\t\t\tcase CardIds.NightbaneIgnited_BG29_815_G:\r\n\t\t\t\tconst nightbaneLoops = deadEntityCardId === CardIds.NightbaneIgnited_BG29_815_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < nightbaneLoops; j++) {\r\n\t\t\t\t\t\tconst pickedTargetEntityIds = [];\r\n\t\t\t\t\t\tfor (let k = 0; k < 2; k++) {\r\n\t\t\t\t\t\t\tconst target = pickRandomAlive(\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity.filter((e) => !pickedTargetEntityIds.includes(e.entityId)),\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\tif (!!target) {\r\n\t\t\t\t\t\t\t\tpickedTargetEntityIds.push(target.entityId);\r\n\t\t\t\t\t\t\t\tmodifyStats(\r\n\t\t\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\t\t\tdeadEntity.attack,\r\n\t\t\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Leapfrogger_BG21_000:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, boardWithDeadEntityHero, deadEntity, false, gameState);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Leapfrogger_BG21_000_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, boardWithDeadEntityHero, deadEntity, true, gameState);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.PalescaleCrocolisk_BG21_001:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst target = grantRandomStats(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t6,\r\n\t\t\t\t\t\t6,\r\n\t\t\t\t\t\tRace.BEAST,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (!!target) {\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.PalescaleCrocolisk_BG21_001_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst target = grantRandomStats(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t12,\r\n\t\t\t\t\t\t12,\r\n\t\t\t\t\t\tRace.BEAST,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (!!target) {\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ScarletSkull_BG25_022:\r\n\t\t\tcase CardIds.ScarletSkull_BG25_022_G:\r\n\t\t\t\tconst scarletMultiplier = deadEntityCardId === CardIds.ScarletSkull_BG25_022_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst target = grantRandomStats(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tscarletMultiplier * 1,\r\n\t\t\t\t\t\tscarletMultiplier * 2,\r\n\t\t\t\t\t\tRace.UNDEAD,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (!!target) {\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.AnubarakNerubianKing_BG25_007:\r\n\t\t\tcase CardIds.AnubarakNerubianKing_BG25_007_G:\r\n\t\t\t\tconst anubarakMultiplier = deadEntityCardId === CardIds.AnubarakNerubianKing_BG25_007_G ? 2 : 1;\r\n\t\t\t\tconst attackBonus = anubarakMultiplier * 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tboardWithDeadEntityHero.globalInfo.UndeadAttackBonus += attackBonus;\r\n\t\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tattackBonus,\r\n\t\t\t\t\t\t0,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\tRace[Race.UNDEAD],\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t// case CardIds.ElementiumSquirrelBombBattlegrounds_TB_BaconShop_HERO_17_Buddy:\r\n\t\t\t// \t// FIXME: I don't think this way of doing things is really accurate (as some deathrattles\r\n\t\t\t// \t// could be spawned between the shots firing), but let's say it's good enough for now\r\n\t\t\t// \tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t// \t\tconst numberOfDeadMechsThisCombat = sharedState.deaths\r\n\t\t\t// \t\t\t.filter((entity) => entity.friendly === deadEntity.friendly)\r\n\t\t\t// \t\t\t// eslint-disable-next-line prettier/prettier\r\n\t\t\t// \t\t\t.filter((entity) => isCorrectTribe(allCards.getCard(entity.cardId)?.races, Race.MECH)).length;\r\n\t\t\t// \t\tfor (let j = 0; j < numberOfDeadMechsThisCombat + 1; j++) {\r\n\t\t\t// \t\t\tdealDamageToRandomEnemy(\r\n\t\t\t// \t\t\t\totherBoard,\r\n\t\t\t// \t\t\t\totherBoardHero,\r\n\t\t\t// \t\t\t\tdeadEntity,\r\n\t\t\t// \t\t\t\t3,\r\n\t\t\t// \t\t\t\tboardWithDeadEntity,\r\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\t\tallCards,\r\n\t\t\t// \t\t\t\tcardsData,\r\n\t\t\t// \t\t\t\tsharedState,\r\n\t\t\t// \t\t\t\tspectator,\r\n\t\t\t// \t\t\t);\r\n\t\t\t// \t\t}\r\n\t\t\t// \t}\r\n\t\t\t// \tbreak;\r\n\t\t\tcase CardIds.ElementiumSquirrelBomb_TB_BaconShop_HERO_17_Buddy:\r\n\t\t\tcase CardIds.ElementiumSquirrelBomb_TB_BaconShop_HERO_17_Buddy_G:\r\n\t\t\t\t// FIXME: I don't think this way of doing things is really accurate (as some deathrattles\r\n\t\t\t\t// could be spawned between the shots firing), but let's say it's good enough for now\r\n\t\t\t\tconst squirrelDamage =\r\n\t\t\t\t\tdeadEntity.cardId === CardIds.ElementiumSquirrelBomb_TB_BaconShop_HERO_17_Buddy_G ? 4 : 2;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst numberOfDeadMechsThisCombat = gameState.sharedState.deaths\r\n\t\t\t\t\t\t.filter((entity) => entity.friendly === deadEntity.friendly)\r\n\t\t\t\t\t\t// eslint-disable-next-line prettier/prettier\r\n\t\t\t\t\t\t.filter((entity) =>\r\n\t\t\t\t\t\t\tisCorrectTribe(gameState.allCards.getCard(entity.cardId)?.races, Race.MECH),\r\n\t\t\t\t\t\t).length;\r\n\t\t\t\t\tfor (let j = 0; j < numberOfDeadMechsThisCombat; j++) {\r\n\t\t\t\t\t\tdealDamageToRandomEnemy(\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\tsquirrelDamage,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.KaboomBot_BG_BOT_606:\r\n\t\t\tcase CardIds.KaboomBot_TB_BaconUps_028:\r\n\t\t\t\t// FIXME: I don't think this way of doing things is really accurate (as some deathrattles\r\n\t\t\t\t// could be spawned between the shots firing), but let's say it's good enough for now\r\n\t\t\t\tconst kaboomLoops = deadEntity.cardId === CardIds.KaboomBot_TB_BaconUps_028 ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < kaboomLoops; j++) {\r\n\t\t\t\t\t\tdealDamageToRandomEnemy(\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t4,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.FireDancer_BG29_843:\r\n\t\t\tcase CardIds.FireDancer_BG29_843_G:\r\n\t\t\t\tconst fireDancerLoops = deadEntity.cardId === CardIds.FireDancer_BG29_843_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < fireDancerLoops; j++) {\r\n\t\t\t\t\t\t// In case there are spawns, don't target them\r\n\t\t\t\t\t\tconst minionsToDamage = [...otherBoard, ...boardWithDeadEntity];\r\n\t\t\t\t\t\tfor (const target of minionsToDamage) {\r\n\t\t\t\t\t\t\tconst isSameSide = target.friendly === deadEntity.friendly;\r\n\t\t\t\t\t\t\tconst board = isSameSide ? boardWithDeadEntity : otherBoard;\r\n\t\t\t\t\t\t\tconst hero = isSameSide ? boardWithDeadEntityHero : otherBoardHero;\r\n\t\t\t\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\t\t\thero,\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\t1,\r\n\t\t\t\t\t\t\t\tisSameSide ? otherBoard : boardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tisSameSide ? otherBoardHero : boardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\t// Most likely there is a death loop after each round of damage, see\r\n\t\t\t\t\t// http://replays.firestoneapp.com/?reviewId=4b6e4d8d-fc83-4795-b450-4cd0c3a518be&turn=17&action=2\r\n\t\t\t\t\t// Update 13/05/2024: the death process is probably between each deathrattle proc, but not each\r\n\t\t\t\t\t// individual tick. See\r\n\t\t\t\t\t// http://replays.firestoneapp.com/?reviewId=6d66b90d-5678-4a68-a45f-7ddb887f9450&turn=17&action=11\r\n\t\t\t\t\tprocessMinionDeath(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.LighterFighter_BG28_968:\r\n\t\t\tcase CardIds.LighterFighter_BG28_968_G:\r\n\t\t\t\t// FIXME: I don't think this way of doing things is really accurate (as some deathrattles\r\n\t\t\t\t// could be spawned between the shots firing), but let's say it's good enough for now\r\n\t\t\t\tconst lighterFighterDamage = deadEntity.cardId === CardIds.LighterFighter_BG28_968_G ? 8 : 4;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < 2; j++) {\r\n\t\t\t\t\t\tconst target = pickRandomLowestHealth(otherBoard);\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\tlighterFighterDamage,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.DrBoombox_BG25_165:\r\n\t\t\tcase CardIds.DrBoombox_BG25_165_G:\r\n\t\t\t\t// FIXME: I don't think this way of doing things is really accurate (as some deathrattles\r\n\t\t\t\t// could be spawned between the shots firing), but let's say it's good enough for now\r\n\t\t\t\tconst boomboxDamage = deadEntity.cardId === CardIds.DrBoombox_BG25_165_G ? 14 : 7;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\t// The nearest enemies use the full board info\r\n\t\t\t\t\t// const boardIncludingDeadEntityAtCorrectIndex = boardWithDeadEntity.splice(\r\n\t\t\t\t\t// \tdeadEntityIndexFromRight,\r\n\t\t\t\t\t// \t0,\r\n\t\t\t\t\t// \tdeadEntity,\r\n\t\t\t\t\t// );\r\n\t\t\t\t\tconst targets = findNearestEnemies(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\tdeadEntityIndexFromRight,\r\n\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t2,\r\n\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t);\r\n\t\t\t\t\ttargets.forEach((target) => {\r\n\t\t\t\t\t\t// console.debug('dealing damage to', stringifySimpleCard(target));\r\n\t\t\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\tboomboxDamage,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t});\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.UnstableGhoul_BG_FP1_024:\r\n\t\t\tcase CardIds.UnstableGhoul_TB_BaconUps_118:\r\n\t\t\t\tconst damage = deadEntityCardId === CardIds.UnstableGhoul_TB_BaconUps_118 ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\t// In case there are spawns, don't target them\r\n\t\t\t\t\tconst minionsToDamage = [...otherBoard, ...boardWithDeadEntity];\r\n\t\t\t\t\tfor (const target of minionsToDamage) {\r\n\t\t\t\t\t\tconst isSameSide = target.friendly === deadEntity.friendly;\r\n\t\t\t\t\t\tconst board = isSameSide ? boardWithDeadEntity : otherBoard;\r\n\t\t\t\t\t\tconst hero = isSameSide ? boardWithDeadEntityHero : otherBoardHero;\r\n\t\t\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\t\thero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\tdamage,\r\n\t\t\t\t\t\t\tisSameSide ? otherBoard : boardWithDeadEntity,\r\n\t\t\t\t\t\t\tisSameSide ? otherBoardHero : boardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.TunnelBlaster_BG_DAL_775:\r\n\t\t\tcase CardIds.TunnelBlaster_BG_DAL_775_G:\r\n\t\t\t\tconst loops = deadEntityCardId === CardIds.TunnelBlaster_BG_DAL_775_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < loops; j++) {\r\n\t\t\t\t\t\t// In case there are spawns, don't target them\r\n\t\t\t\t\t\tconst minionsToDamage = [...otherBoard, ...boardWithDeadEntity];\r\n\t\t\t\t\t\tfor (const target of minionsToDamage) {\r\n\t\t\t\t\t\t\tconst isSameSide = target.friendly === deadEntity.friendly;\r\n\t\t\t\t\t\t\tconst board = isSameSide ? boardWithDeadEntity : otherBoard;\r\n\t\t\t\t\t\t\tconst hero = isSameSide ? boardWithDeadEntityHero : otherBoardHero;\r\n\t\t\t\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\t\t\thero,\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\t3,\r\n\t\t\t\t\t\t\t\tisSameSide ? otherBoard : boardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tisSameSide ? otherBoardHero : boardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.LeeroyTheReckless_BG23_318:\r\n\t\t\tcase CardIds.LeeroyTheReckless_BG23_318_G:\r\n\t\t\t\tif (\r\n\t\t\t\t\tdeadEntity.lastAffectedByEntity\r\n\t\t\t\t\t// http://replays.firestoneapp.com/?reviewId=c6121cdd-5cb6-4321-807e-4ff644568a8c&turn=25&action=7\r\n\t\t\t\t\t// Update 02/05/2024: this is a bug, and friendly units should be killed\r\n\t\t\t\t\t// deadEntity.friendly !== deadEntity.lastAffectedByEntity.friendly\r\n\t\t\t\t) {\r\n\t\t\t\t\tdeadEntity.lastAffectedByEntity.definitelyDead = true;\r\n\t\t\t\t}\r\n\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.RadioStar_BG25_399:\r\n\t\t\tcase CardIds.RadioStar_BG25_399_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst radioQuantity = deadEntityCardId === CardIds.RadioStar_BG25_399_G ? 2 : 1;\r\n\t\t\t\t\tconst radioEntities = Array(radioQuantity).fill(deadEntity.lastAffectedByEntity);\r\n\t\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, radioEntities, gameState);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.MysticSporebat_BG28_900:\r\n\t\t\tcase CardIds.MysticSporebat_BG28_900_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, [null], gameState);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ThreeLilQuilboar_BG26_867:\r\n\t\t\tcase CardIds.ThreeLilQuilboar_BG26_867_G:\r\n\t\t\t\t// console.log('Triggering blood gems', deadEntityCardId, deadEntity.entityId);\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst numberOfBloodGems = deadEntityCardId === CardIds.ThreeLilQuilboar_BG26_867_G ? 6 : 3;\r\n\t\t\t\t\tfor (const entity of boardWithDeadEntity.filter((e) =>\r\n\t\t\t\t\t\thasCorrectTribe(e, Race.QUILBOAR, gameState.allCards),\r\n\t\t\t\t\t)) {\r\n\t\t\t\t\t\tplayBloodGemsOn(\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\tentity,\r\n\t\t\t\t\t\t\tnumberOfBloodGems,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SrTombDiver_TB_BaconShop_HERO_41_Buddy:\r\n\t\t\tcase CardIds.SrTombDiver_TB_BaconShop_HERO_41_Buddy_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst numberToGild = deadEntityCardId === CardIds.SrTombDiver_TB_BaconShop_HERO_41_Buddy_G ? 2 : 1;\r\n\t\t\t\t\tconst targetBoard = boardWithDeadEntity.filter((e) => !e.definitelyDead && e.health > 0);\r\n\t\t\t\t\t// .filter((e) => !gameState.cardsData.isGolden(gameState.allCards.getCard(e.cardId)));\r\n\t\t\t\t\tfor (let i = 0; i < Math.min(numberToGild, boardWithDeadEntity.length); i++) {\r\n\t\t\t\t\t\tconst rightMostMinion = targetBoard[targetBoard.length - 1 - i];\r\n\t\t\t\t\t\tif (rightMostMinion) {\r\n\t\t\t\t\t\t\tmakeMinionGolden(\r\n\t\t\t\t\t\t\t\trightMostMinion,\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Scourfin_BG26_360:\r\n\t\t\tcase CardIds.Scourfin_BG26_360_G:\r\n\t\t\t\tconst statsScourfin = deadEntityCardId === CardIds.Scourfin_BG26_360_G ? 10 : 5;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomStats(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero.hand.filter(\r\n\t\t\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\t\t\tgameState.allCards.getCard(e.cardId).type?.toUpperCase() === CardType[CardType.MINION],\r\n\t\t\t\t\t\t),\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tstatsScourfin,\r\n\t\t\t\t\t\tstatsScourfin,\r\n\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SanguineChampion_BG23_017:\r\n\t\t\tcase CardIds.SanguineChampion_BG23_017_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst sanguineChampionStats = deadEntityCardId === CardIds.SanguineChampion_BG23_017 ? 1 : 2;\r\n\t\t\t\t\tboardWithDeadEntityHero.globalInfo.BloodGemAttackBonus += sanguineChampionStats;\r\n\t\t\t\t\tboardWithDeadEntityHero.globalInfo.BloodGemHealthBonus += sanguineChampionStats;\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.PricklyPiper_BG26_160:\r\n\t\t\tcase CardIds.PricklyPiper_BG26_160_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst piperBuff = deadEntityCardId === CardIds.PricklyPiper_BG26_160 ? 1 : 2;\r\n\t\t\t\t\tboardWithDeadEntityHero.globalInfo.BloodGemAttackBonus += piperBuff;\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t// Putricide-only\r\n\t\t\tcase CardIds.Banshee_BG_RLK_957:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t2,\r\n\t\t\t\t\t\t1,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\tRace[Race.UNDEAD],\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.LostSpirit_BG26_GIL_513:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, boardWithDeadEntityHero, 1, 0, gameState, null);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.TickingAbomination_BG_ICC_099:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (const entity of boardWithDeadEntity) {\r\n\t\t\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\t\t\tentity,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t5,\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.WitheredSpearhide_BG27_006:\r\n\t\t\tcase CardIds.WitheredSpearhide_BG27_006_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst witheredSpearhideCardsToAdd = Array(\r\n\t\t\t\t\t\tdeadEntity.cardId === CardIds.WitheredSpearhide_BG27_006_G ? 2 : 1,\r\n\t\t\t\t\t).fill(CardIds.BloodGem);\r\n\t\t\t\t\taddCardsInHand(\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\twitheredSpearhideCardsToAdd,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.RecurringNightmare_BG26_055:\r\n\t\t\tcase CardIds.RecurringNightmare_BG26_055_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyRecurringNightmareDeathrattleEffect(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tdeadEntityCardId === CardIds.RecurringNightmare_BG26_055_G,\r\n\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.MotleyPhalanx_BG27_080:\r\n\t\t\tcase CardIds.MotleyPhalanx_BG27_080_G:\r\n\t\t\t\tconst motleyBuff = deadEntity.cardId === CardIds.MotleyPhalanx_BG27_080_G ? 8 : 4;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantStatsToMinionsOfEachType(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tmotleyBuff,\r\n\t\t\t\t\t\tmotleyBuff,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.MoroesStewardOfDeath_BG28_304:\r\n\t\t\tcase CardIds.MoroesStewardOfDeath_BG28_304_G:\r\n\t\t\t\tconst moroesBuffAtk = deadEntity.cardId === CardIds.MoroesStewardOfDeath_BG28_304_G ? 4 : 2;\r\n\t\t\t\tconst moroesBuffHealth = deadEntity.cardId === CardIds.MoroesStewardOfDeath_BG28_304_G ? 8 : 4;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tmoroesBuffAtk,\r\n\t\t\t\t\t\tmoroesBuffHealth,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\tRace[Race.UNDEAD],\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SteadfastSpirit_BG28_306:\r\n\t\t\tcase CardIds.SteadfastSpirit_BG28_306_G:\r\n\t\t\t\tconst steadfastSpiritBuff = deadEntity.cardId === CardIds.SteadfastSpirit_BG28_306_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tsteadfastSpiritBuff,\r\n\t\t\t\t\t\tsteadfastSpiritBuff,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Mummifier_BG28_309:\r\n\t\t\tcase CardIds.Mummifier_BG28_309_G:\r\n\t\t\t\tconst mummifierBuff = deadEntity.cardId === CardIds.Mummifier_BG28_309_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < mummifierBuff; j++) {\r\n\t\t\t\t\t\tconst targets = boardWithDeadEntity\r\n\t\t\t\t\t\t\t.filter(\r\n\t\t\t\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\t\t\t\te.cardId !== CardIds.Mummifier_BG28_309 &&\r\n\t\t\t\t\t\t\t\t\te.cardId !== CardIds.Mummifier_BG28_309_G,\r\n\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t\t.filter((e) => !e.reborn)\r\n\t\t\t\t\t\t\t.filter((e) => hasCorrectTribe(e, Race.UNDEAD, gameState.allCards));\r\n\t\t\t\t\t\tconst target = pickRandom(targets);\r\n\t\t\t\t\t\tif (target) {\r\n\t\t\t\t\t\t\ttarget.reborn = true;\r\n\t\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ScrapScraper_BG26_148:\r\n\t\t\tcase CardIds.ScrapScraper_BG26_148_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst scraperToAddQuantity = deadEntity.cardId === CardIds.ScrapScraper_BG26_148_G ? 2 : 1;\r\n\t\t\t\t\tconst scraperCardsToAdd = [];\r\n\t\t\t\t\tfor (let i = 0; i < scraperToAddQuantity; i++) {\r\n\t\t\t\t\t\tscraperCardsToAdd.push(pickRandom(gameState.cardsData.scrapScraperSpawns));\r\n\t\t\t\t\t}\r\n\t\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, scraperCardsToAdd, gameState);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.BarrensConjurer_BG29_862:\r\n\t\t\tcase CardIds.BarrensConjurer_BG29_862_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst conjurerToAddQuantity = deadEntity.cardId === CardIds.BarrensConjurer_BG29_862_G ? 2 : 1;\r\n\t\t\t\t\tconst conjurerCardsToAdd = [];\r\n\t\t\t\t\tfor (let i = 0; i < conjurerToAddQuantity; i++) {\r\n\t\t\t\t\t\tconjurerCardsToAdd.push(pickRandom(gameState.cardsData.battlecryMinions));\r\n\t\t\t\t\t}\r\n\t\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, conjurerCardsToAdd, gameState);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ShadowyConstruct_BG25_HERO_103_Buddy:\r\n\t\t\tcase CardIds.ShadowyConstruct_BG25_HERO_103_Buddy_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst loops = deadEntity.cardId === CardIds.ShadowyConstruct_BG25_HERO_103_Buddy_G ? 2 : 1;\r\n\t\t\t\t\tfor (let j = 0; j < loops; j++) {\r\n\t\t\t\t\t\tconst atkBuff = deadEntity.attack;\r\n\t\t\t\t\t\tconst healthBuff = deadEntity.maxHealth;\r\n\t\t\t\t\t\tconst target = pickRandom(\r\n\t\t\t\t\t\t\tboardWithDeadEntity.filter((e) => e.entityId !== deadEntity.entityId),\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tif (target) {\r\n\t\t\t\t\t\t\tmodifyStats(\r\n\t\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\t\tatkBuff,\r\n\t\t\t\t\t\t\t\thealthBuff,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SpikedSavior_BG29_808:\r\n\t\t\tcase CardIds.SpikedSavior_BG29_808_G:\r\n\t\t\t\tconst spikedSaviorLoops = deadEntity.cardId === CardIds.SpikedSavior_BG29_808_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < spikedSaviorLoops; j++) {\r\n\t\t\t\t\t\tconst targetBoard = [...boardWithDeadEntity];\r\n\t\t\t\t\t\tfor (const entity of targetBoard) {\r\n\t\t\t\t\t\t\tmodifyStats(entity, 0, 1, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\t\t\t\tgameState.spectator?.registerPowerTarget(\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\tentity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tfor (const entity of targetBoard) {\r\n\t\t\t\t\t\t\t// Issue: because this can spawn a new minion, the entity indices can be incorrect\r\n\t\t\t\t\t\t\t// See sim.sample.1.txt\r\n\t\t\t\t\t\t\t// Ideally, I should probably move the minion spawn index to another paradigm: keep the dead minions\r\n\t\t\t\t\t\t\t// until there are new spawns, and delete them afterwards, so I can easily refer to their index\r\n\t\t\t\t\t\t\t// by just looking them up, and spawning to the right\r\n\t\t\t\t\t\t\t// However, since this doesn't work, maybe I can look for entity indices adjustments needed\r\n\t\t\t\t\t\t\t// by looking up the position changes of other minions?\r\n\t\t\t\t\t\t\t// Not sure how this could work without creating a giant mess, so for now it will probably\r\n\t\t\t\t\t\t\t// stay as a bug\r\n\t\t\t\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\t\t\t\tentity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\t1,\r\n\t\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t// Add all the deathrattles that don't have an effect on combat\r\n\t\t\tcase CardIds.FieryFelblood_BG29_877:\r\n\t\t\tcase CardIds.FieryFelblood_BG29_877_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\t// It's important to first copy the enchantments, otherwise you could end up\r\n\t// in an infinite loop - since new enchants are added after each step\r\n\tlet enchantments: { cardId: string; originEntityId?: number; repeats?: number }[] = [\r\n\t\t...(deadEntity.enchantments ?? []),\r\n\t\t// These seem to be first processed separately\r\n\t\t// ...(deadEntity.rememberedDeathrattles ?? []),\r\n\t].sort((a, b) => a.timing - b.timing);\r\n\t// In some cases it's possible that there are way too many enchantments because of the frog\r\n\t// In that case, we make a trade-off and don't trigger the \"on stats change\" trigger as\r\n\t// often as we should, so that we can have the stats themselves correct\r\n\t// We don't want to lump everything together, as it skews the stats when there are a lot of buffs\r\n\t// Instead, we build groups\r\n\tconst maxNumberOfGroups = 12;\r\n\tconst enchantmentGroups = groupByFunction((enchantment: any) => enchantment.cardId)(enchantments);\r\n\tenchantments = Object.keys(enchantmentGroups).flatMap((cardId) => {\r\n\t\tlet repeatsToApply = enchantmentGroups[cardId].map((e) => e.repeats || 1).reduce((a, b) => a + b, 0);\r\n\r\n\t\t// Frogs include the multiplers here directly\r\n\t\tif (\r\n\t\t\t[\r\n\t\t\t\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e,\r\n\t\t\t\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge,\r\n\t\t\t].includes(cardId as CardIds)\r\n\t\t) {\r\n\t\t\trepeatsToApply = repeatsToApply * multiplier;\r\n\t\t}\r\n\r\n\t\tconst results = [];\r\n\t\tconst repeatsPerBuff = Math.max(1, Math.floor(repeatsToApply / maxNumberOfGroups));\r\n\t\tlet repeatsDone = 0;\r\n\t\twhile (repeatsDone < repeatsToApply) {\r\n\t\t\tconst repeats = Math.min(repeatsPerBuff, repeatsToApply - repeatsDone);\r\n\t\t\tresults.push({\r\n\t\t\t\tcardId: cardId,\r\n\t\t\t\trepeats: repeats,\r\n\t\t\t\ttiming: Math.min(...enchantmentGroups[cardId].map((e) => e.timing)),\r\n\t\t\t});\r\n\t\t\trepeatsDone += repeatsPerBuff;\r\n\t\t}\r\n\t\treturn results;\r\n\t});\r\n\tfor (const enchantment of enchantments) {\r\n\t\tswitch (enchantment.cardId) {\r\n\t\t\tcase CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e:\r\n\t\t\tcase CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge:\r\n\t\t\t\tapplyLeapFroggerEffect(\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tenchantment.cardId === CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tenchantment.repeats || 1,\r\n\t\t\t\t);\r\n\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.EarthRecollectionEnchantment:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyEarthInvocationEnchantment(boardWithDeadEntity, deadEntity, deadEntity, gameState);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.FireRecollectionEnchantment:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyFireInvocationEnchantment(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.WaterRecollectionEnchantment:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyWaterInvocationEnchantment(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.LightningRecollectionEnchantment:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyLightningInvocationEnchantment(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tonDeathrattleTriggered(deathrattleTriggeredInput);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\t// const playerCopy = boardWithDeadEntity.map((e) => ({ ...e, lastAffectedByEntity: null }));\r\n\t// const oppCopy = otherBoard.map((e) => ({ ...e, lastAffectedByEntity: null }));\r\n\t// console.log('player board', boardWithDeadEntity.length, playerCopy.length, playerCopy.map((e) => JSON.stringify(e)).join('\\n'));\r\n\t// console.log('opp board', JSON.stringify(oppCopy));\r\n};\r\n\r\nexport const applyLightningInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// Because the golden version doubles all the remembered effects\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst targets = pickMultipleRandomDifferent(otherBoard, 5);\r\n\t\tfor (const target of targets) {\r\n\t\t\tdealDamageToMinion(\r\n\t\t\t\ttarget,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tdeadEntity,\r\n\t\t\t\t1,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyWaterInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst validBoard = boardWithDeadEntity.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\t\tconst target: BoardEntity = validBoard[validBoard.length - 1];\r\n\t\tif (!!target) {\r\n\t\t\ttarget.taunt = true;\r\n\t\t\tmodifyStats(target, 0, 3, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(sourceEntity, target, boardWithDeadEntity, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyFireInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst target: BoardEntity = boardWithDeadEntity.filter((e) => e.health > 0 && !e.definitelyDead)[0];\r\n\t\tif (!!target) {\r\n\t\t\tmodifyStats(target, target.attack, 0, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(sourceEntity, target, boardWithDeadEntity, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyEarthInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst minionsGrantedDeathrattle: BoardEntity[] = pickMultipleRandomDifferent(boardWithDeadEntity, 4);\r\n\t\tminionsGrantedDeathrattle.forEach((minion) => {\r\n\t\t\tminion.enchantments.push({\r\n\t\t\t\tcardId: CardIds.EarthInvocation_ElementEarthEnchantment,\r\n\t\t\t\toriginEntityId: deadEntity?.entityId,\r\n\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t});\r\n\t\t\tgameState.spectator.registerPowerTarget(sourceEntity, minion, boardWithDeadEntity, null, null);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nconst applyLeapFroggerEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tgameState: FullGameState,\r\n\tmultiplier = 1,\r\n): void => {\r\n\tmultiplier = multiplier || 1;\r\n\tconst buffed = grantRandomStats(\r\n\t\tdeadEntity,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tmultiplier * (isPremium ? 2 : 1),\r\n\t\tmultiplier * (isPremium ? 2 : 1),\r\n\t\tRace.BEAST,\r\n\t\tfalse,\r\n\t\tgameState,\r\n\t);\r\n\tif (buffed) {\r\n\t\tbuffed.enchantments = buffed.enchantments ?? [];\r\n\t\tbuffed.enchantments.push({\r\n\t\t\tcardId: isPremium\r\n\t\t\t\t? CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge\r\n\t\t\t\t: CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e,\r\n\t\t\toriginEntityId: deadEntity.entityId,\r\n\t\t\trepeats: multiplier > 1 ? multiplier : 1,\r\n\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t});\r\n\t\t// Don't register power effect here, since it's already done in the random stats\r\n\t\t// spectator.registerPowerTarget(deadEntity, buffed, boardWithDeadEntity);\r\n\t\t// console.log('applyLeapFroggerEffect', stringifySimpleCard(deadEntity), stringifySimpleCard(buffed));\r\n\t}\r\n};\r\n\r\nconst applyRecurringNightmareDeathrattleEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tsharedState: SharedState,\r\n\tmultiplier = 1,\r\n): void => {\r\n\tmultiplier = multiplier || 1;\r\n\tconst target = pickRandom(\r\n\t\tboardWithDeadEntity\r\n\t\t\t.filter((e) => hasCorrectTribe(e, Race.UNDEAD, allCards))\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId !== CardIds.RecurringNightmare_BG26_055 &&\r\n\t\t\t\t\te.cardId !== CardIds.RecurringNightmare_BG26_055_G,\r\n\t\t\t),\r\n\t);\r\n\tif (target) {\r\n\t\ttarget.enchantments = target.enchantments ?? [];\r\n\t\ttarget.enchantments.push({\r\n\t\t\tcardId: isPremium\r\n\t\t\t\t? CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055_Ge\r\n\t\t\t\t: CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055e,\r\n\t\t\toriginEntityId: deadEntity.entityId,\r\n\t\t\trepeats: multiplier > 1 ? multiplier : 1,\r\n\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t});\r\n\t\tspectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity, null, null);\r\n\t}\r\n};\r\n\r\nexport const handleAfterMinionKillsEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst killer = deadEntity.lastAffectedByEntity;\r\n\tif (!killer) {\r\n\t\treturn;\r\n\t}\r\n\t// Killed an enemy minion\r\n\tif (killer.friendly !== deadEntity.friendly) {\r\n\t\tif (otherBoardHero.heroPowerId === CardIds.Rokara_GloryOfCombat) {\r\n\t\t\tmodifyStats(killer, 1, 0, otherBoard, otherBoardHero, gameState);\r\n\t\t}\r\n\r\n\t\t// Icesnarl the Mighty\r\n\t\t// The timing here might be off, as the following replay suggests that the effect should trigger\r\n\t\t// before Sr. Tomb Diver's deathrattle is applied\r\n\t\t// http://replays.firestoneapp.com/?reviewId=ebb4e2d6-11b4-44f4-a052-3be2c63dd38f&turn=11&action=6\r\n\t\t// Update 2024-30-06: lived tgus ub ab \"after minion kills\" trigger, let's see how that works\r\n\t\totherBoard\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy ||\r\n\t\t\t\t\te.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy_G,\r\n\t\t\t)\r\n\t\t\t.forEach((icesnarl) => {\r\n\t\t\t\tmodifyStats(\r\n\t\t\t\t\ticesnarl,\r\n\t\t\t\t\t0,\r\n\t\t\t\t\ticesnarl.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy_G ? 2 : 1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t}\r\n};\r\n\r\nexport const applyWheneverMinionDiesEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// console.log('applying minion death effect', stringifySimpleCard(deadEntity, allCards));\r\n\tif (isCorrectTribe(gameState.allCards.getCard(deadEntity.cardId).races, Race.BEAST)) {\r\n\t\tapplyScavengingHyenaEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\tif (isCorrectTribe(gameState.allCards.getCard(deadEntity.cardId).races, Race.DEMON)) {\r\n\t\tapplySoulJugglerEffect(boardWithDeadEntity, boardWithDeadEntityHero, otherBoard, otherBoardHero, gameState);\r\n\t}\r\n\tif (isCorrectTribe(gameState.allCards.getCard(deadEntity.cardId).races, Race.MECH)) {\r\n\t\tapplyJunkbotEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, Race.MURLOC, gameState.allCards)) {\r\n\t\tremoveOldMurkEyeAttack(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\tremoveOldMurkEyeAttack(otherBoard, otherBoardHero, gameState);\r\n\t}\r\n\tif (deadEntity.taunt) {\r\n\t\tapplyBristlemaneScrapsmithEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\tapplyQirajiHarbringerEffect(boardWithDeadEntity, boardWithDeadEntityHero, deadEntityIndexFromRight, gameState);\r\n\t}\r\n\r\n\tif (\r\n\t\tdeadEntity.cardId === CardIds.EternalKnight_BG25_008 ||\r\n\t\tdeadEntity.cardId === CardIds.EternalKnight_BG25_008_G\r\n\t) {\r\n\t\tapplyEternalKnightEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\r\n\t// Putricide-only\r\n\tboardWithDeadEntity\r\n\t\t.filter((e) => e.additionalCards?.includes(CardIds.FlesheatingGhoulLegacy_BG26_tt_004))\r\n\t\t.forEach((e) => {\r\n\t\t\tmodifyStats(e, 1, 0, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t});\r\n\r\n\tapplyRotHideGnollEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\r\n\t// Overkill\r\n\tif (deadEntity.health < 0 && deadEntity.lastAffectedByEntity?.attacking) {\r\n\t\tif (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlame_BGS_032) {\r\n\t\t\tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t\tif (targets.length > 0) {\r\n\t\t\t\tconst target = targets[0];\r\n\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t\t\t3,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlame_TB_BaconUps_103) {\r\n\t\t\tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t\tif (targets.length > 0) {\r\n\t\t\t\tconst target = targets[0];\r\n\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t\t\t6,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t\t// else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental && deadEntity.lastAffectedByEntity.attacking) {\r\n\t\t// \t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental) {\r\n\t\t// \t// console.log('applying WildfireElemental effect', stringifySimple(boardWithDeadEntity, allCards));\r\n\t\t// \tconst excessDamage = -deadEntity.health;\r\n\t\t// \t// Prevent propagation of the effect\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking = false;\r\n\t\t// \tconst neighbours = getNeighbours(boardWithDeadEntity, null, boardWithDeadEntity.length - deadEntityIndexFromRight);\r\n\t\t// \t// console.log('neighbours', stringifySimple(neighbours, allCards));\r\n\t\t// \tif (neighbours.length > 0) {\r\n\t\t// \t\tconst randomTarget = neighbours[Math.floor(Math.random() * neighbours.length)];\r\n\t\t// \t\tdealDamageToEnemy(\r\n\t\t// \t\t\trandomTarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\texcessDamage,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tallCards,\r\n\t\t// \t\t\tcardsData,\r\n\t\t// \t\t\tsharedState,\r\n\t\t// \t\t\tspectator,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// } else if (\r\n\t\t// \tdeadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElementalBattlegrounds &&\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking\r\n\t\t// ) {\r\n\t\t// \tconst excessDamage = -deadEntity.health;\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking = false;\r\n\t\t// \tconst neighbours = getNeighbours(boardWithDeadEntity, null, boardWithDeadEntity.length - deadEntityIndexFromRight);\r\n\t\t// \tneighbours.forEach((neighbour) =>\r\n\t\t// \t\tdealDamageToEnemy(\r\n\t\t// \t\t\tneighbour,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\texcessDamage,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tallCards,\r\n\t\t// \t\t\tcardsData,\r\n\t\t// \t\t\tsharedState,\r\n\t\t// \t\t\tspectator,\r\n\t\t// \t\t),\r\n\t\t// \t);\r\n\t\t// }\r\n\t\telse if (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn_TRL_232) {\r\n\t\t\tconst newEntities = spawnEntities(\r\n\t\t\t\tCardIds.IronhideDirehorn_IronhideRuntToken_TRL_232t,\r\n\t\t\t\t1,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState.allCards,\r\n\t\t\t\tgameState.cardsData,\r\n\t\t\t\tgameState.sharedState,\r\n\t\t\t\tgameState.spectator,\r\n\t\t\t\t!deadEntity.friendly,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t\totherBoard.splice(otherBoard.length - deadEntityIndexFromRight, 0, ...newEntities);\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn_TB_BaconUps_051) {\r\n\t\t\tconst newEntities = spawnEntities(\r\n\t\t\t\tCardIds.IronhideDirehorn_IronhideRuntToken_TB_BaconUps_051t,\r\n\t\t\t\t1,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState.allCards,\r\n\t\t\t\tgameState.cardsData,\r\n\t\t\t\tgameState.sharedState,\r\n\t\t\t\tgameState.spectator,\r\n\t\t\t\t!deadEntity.friendly,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t\totherBoard.splice(otherBoard.length - deadEntityIndexFromRight, 0, ...newEntities);\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath_BGS_080) {\r\n\t\t\tconst otherPirates = otherBoard\r\n\t\t\t\t.filter((entity) => isCorrectTribe(gameState.allCards.getCard(entity.cardId).races, Race.PIRATE))\r\n\t\t\t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\totherPirates.forEach((pirate) => {\r\n\t\t\t\tmodifyStats(pirate, 2, 2, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t\t\tpirate,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath_TB_BaconUps_142) {\r\n\t\t\tconst otherPirates = otherBoard\r\n\t\t\t\t.filter((entity) => isCorrectTribe(gameState.allCards.getCard(entity.cardId).races, Race.PIRATE))\r\n\t\t\t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\totherPirates.forEach((pirate) => {\r\n\t\t\t\tmodifyStats(pirate, 4, 4, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t\t\tpirate,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n};\r\n\r\n/** @deprecated */\r\nexport const dealDamageToAllMinions = (\r\n\tboard1: BoardEntity[],\r\n\tboard1Hero: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tboard2Hero: BgsPlayerEntity,\r\n\tdamageSource: BoardEntity,\r\n\tdamageDealt: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (board1.length === 0 && board2.length === 0) {\r\n\t\treturn;\r\n\t}\r\n\tfor (let i = 0; i < board1.length; i++) {\r\n\t\tdealDamageToMinion(board1[i], board1, board1Hero, damageSource, damageDealt, board2, board2Hero, gameState);\r\n\t}\r\n\tfor (let i = 0; i < board2.length; i++) {\r\n\t\tdealDamageToMinion(board2[i], board2, board2Hero, damageSource, damageDealt, board1, board1Hero, gameState);\r\n\t}\r\n};\r\n\r\nconst applySoulJugglerEffect = (\r\n\tboardWithJugglers: BoardEntity[],\r\n\tboardWithJugglersHero: BgsPlayerEntity,\r\n\tboardToAttack: BoardEntity[],\r\n\tboardToAttackHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (boardWithJugglers.length === 0 && boardToAttack.length === 0) {\r\n\t\treturn;\r\n\t\t// return [boardWithJugglers, boardToAttack];\r\n\t}\r\n\tconst jugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler_BGS_002);\r\n\tfor (const juggler of jugglers) {\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t3,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\tconst goldenJugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler_TB_BaconUps_075);\r\n\tfor (const juggler of goldenJugglers) {\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t3,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t3,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\t// processMinionDeath(\r\n\t// \tboardWithJugglers,\r\n\t// \tboardWithJugglersHero,\r\n\t// \tboardToAttack,\r\n\t// \tboardToAttackHero,\r\n\t// \tallCards,\r\n\t// \tcardsData,\r\n\t// \tsharedState,\r\n\t// \tspectator,\r\n\t// );\r\n};\r\n\r\nconst applyScavengingHyenaEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// const copy = [...board];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.ScavengingHyenaLegacy_BG_EX1_531) {\r\n\t\t\tmodifyStats(board[i], 2, 1, board, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t} else if (board[i].cardId === CardIds.ScavengingHyenaLegacy_TB_BaconUps_043) {\r\n\t\t\tmodifyStats(board[i], 4, 2, board, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyEternalKnightEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (\r\n\t\t\tboard[i].cardId === CardIds.EternalKnight_BG25_008 ||\r\n\t\t\tboard[i].cardId === CardIds.EternalKnight_BG25_008_G\r\n\t\t) {\r\n\t\t\tconst multiplier = board[i].cardId === CardIds.EternalKnight_BG25_008_G ? 2 : 1;\r\n\t\t\tmodifyStats(board[i], multiplier * 1, multiplier * 1, board, hero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyRotHideGnollEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.RotHideGnoll_BG25_013 || board[i].cardId === CardIds.RotHideGnoll_BG25_013_G) {\r\n\t\t\tconst multiplier = board[i].cardId === CardIds.RotHideGnoll_BG25_013_G ? 2 : 1;\r\n\t\t\tmodifyStats(board[i], multiplier * 1, 0, board, hero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyBristlemaneScrapsmithEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardPlayerEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (\r\n\t\t\tboard[i].cardId === CardIds.BristlemaneScrapsmith_BG24_707 ||\r\n\t\t\tboard[i].cardId === CardIds.BristlemaneScrapsmith_BG24_707_G\r\n\t\t) {\r\n\t\t\tconst cardsToAdd = Array(CardIds.BristlemaneScrapsmith_BG24_707_G ? 2 : 1).fill(CardIds.BloodGem);\r\n\t\t\taddCardsInHand(boardPlayerEntity, board, cardsToAdd, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, boardPlayerEntity, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyJunkbotEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.Junkbot_GVG_106) {\r\n\t\t\tmodifyStats(board[i], 2, 2, board, hero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t} else if (board[i].cardId === CardIds.Junkbot_TB_BaconUps_046) {\r\n\t\t\tmodifyStats(board[i], 4, 4, board, hero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyQirajiHarbringerEffect = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst qiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger_BGS_112);\r\n\tconst goldenQiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger_TB_BaconUps_303);\r\n\r\n\t// TODO: if reactivated, properly apply buffs one by one, instead of all together\r\n\tif (qiraji.length + goldenQiraji.length > 0) {\r\n\t\tconst neighbours = getNeighbours(board, null, deadEntityIndexFromRight);\r\n\t\tconst buff = 2 * qiraji.length + 4 * goldenQiraji.length;\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyStats(entity, buff, buff, board, hero, gameState);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const applyMonstrosity = (\r\n\tmonstrosity: BoardEntity,\r\n\tdeadEntities: readonly BoardEntity[],\r\n\tboardWithDeadEntities: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tfor (const deadEntity of deadEntities) {\r\n\t\tmodifyStats(monstrosity, deadEntity.attack, 0, boardWithDeadEntities, boardWithDeadEntityHero, gameState);\r\n\t\tif (monstrosity.cardId === CardIds.Monstrosity_BG20_HERO_282_Buddy_G) {\r\n\t\t\tmodifyStats(monstrosity, deadEntity.attack, 0, boardWithDeadEntities, boardWithDeadEntityHero, gameState);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const rememberDeathrattles = (\r\n\tfish: BoardEntity,\r\n\tdeadEntities: readonly BoardEntity[],\r\n\tcardsData: CardsData,\r\n\tallCards: AllCardsService,\r\n\tsharedState: SharedState,\r\n): void => {\r\n\tconst validDeathrattles = deadEntities\r\n\t\t.filter((entity) => cardsData.validDeathrattles.includes(entity.cardId) || isFish(entity))\r\n\t\t.map((entity) => ({ cardId: entity.cardId, repeats: 1, timing: sharedState.currentEntityId++ }));\r\n\tconst validEnchantments = deadEntities\r\n\t\t.filter((entity) => entity.enchantments?.length)\r\n\t\t.map((entity) => entity.enchantments)\r\n\t\t.reduce((a, b) => a.concat(b), [])\r\n\t\t.flatMap((enchantment) => ({\r\n\t\t\tcardId: enchantment.cardId,\r\n\t\t\trepeats: enchantment.repeats ?? 1,\r\n\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t}))\r\n\t\t.filter((enchantment) => VALID_DEATHRATTLE_ENCHANTMENTS.includes(enchantment.cardId as CardIds));\r\n\t// Multiple fish\r\n\tconst deadEntityRememberedDeathrattles =\r\n\t\tdeadEntities\r\n\t\t\t.filter((e) => !!e.rememberedDeathrattles?.length)\r\n\t\t\t// If the fish has reborn, it will inherit its own Deathrattles, and we don't want that\r\n\t\t\t.filter((e) => e.entityId !== fish.rebornFromEntityId)\r\n\t\t\t.flatMap((e) => e.rememberedDeathrattles) ?? [];\r\n\tconst newDeathrattles = [...validDeathrattles, ...validEnchantments, ...deadEntityRememberedDeathrattles];\r\n\t// Order is important - the DR are triggered in the ordered the minions have died\r\n\tif (isGolden(fish.cardId, allCards)) {\r\n\t\t// https://stackoverflow.com/questions/33305152/how-to-duplicate-elements-in-a-js-array\r\n\t\tconst doubleDr = newDeathrattles.reduce((res, current) => res.concat([current, current]), []);\r\n\t\tfish.rememberedDeathrattles = [...(fish.rememberedDeathrattles || []), ...doubleDr];\r\n\t} else {\r\n\t\tfish.rememberedDeathrattles = [...(fish.rememberedDeathrattles || []), ...newDeathrattles];\r\n\t}\r\n\tif (fish.rememberedDeathrattles?.length) {\r\n\t\tfish.rememberedDeathrattles.sort((a, b) => a.timing - b.timing);\r\n\t}\r\n\t// console.debug(\r\n\t// \t'remembered',\r\n\t// \tfish.rememberedDeathrattles.map((d) => ({\r\n\t// \t\tcardId: d.cardId,\r\n\t// \t\tname: allCards.getCard(d.cardId)?.name,\r\n\t// \t\t// repeats: d.repeats,\r\n\t// \t\ttiming: d.timing,\r\n\t// \t})),\r\n\t// );\r\n};\r\n\r\nconst removeOldMurkEyeAttack = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst murkeyes = boardWithDeadEntity.filter(\r\n\t\t(entity) => entity.cardId === CardIds.OldMurkEyeLegacy || entity.cardId === CardIds.OldMurkEyeVanilla,\r\n\t);\r\n\tconst goldenMurkeyes = boardWithDeadEntity.filter((entity) => entity.cardId === CardIds.OldMurkEye);\r\n\tmurkeyes.forEach((entity) => {\r\n\t\tmodifyStats(entity, -1, 0, boardWithDeadEntity, hero, gameState);\r\n\t});\r\n\tgoldenMurkeyes.forEach((entity) => {\r\n\t\tmodifyStats(entity, -2, 0, boardWithDeadEntity, hero, gameState);\r\n\t});\r\n};\r\n"]}
package/dist/utils.js CHANGED
@@ -46,6 +46,7 @@ const buildSingleBoardEntity = (cardId, controllerHero, friendlyBoard, allCards,
46
46
  reborn: (0, exports.hasMechanic)(card, 'REBORN'),
47
47
  poisonous: (0, exports.hasMechanic)(card, reference_data_1.GameTag[reference_data_1.GameTag.POISONOUS]),
48
48
  venomous: (0, exports.hasMechanic)(card, reference_data_1.GameTag[reference_data_1.GameTag.VENOMOUS]),
49
+ stealth: (0, exports.hasMechanic)(card, reference_data_1.GameTag[reference_data_1.GameTag.STEALTH]),
49
50
  windfury: (0, exports.hasMechanic)(card, reference_data_1.GameTag[reference_data_1.GameTag.WINDFURY]) ||
50
51
  ((_a = card.referencedTags) === null || _a === void 0 ? void 0 : _a.includes(reference_data_1.GameTag[reference_data_1.GameTag.WINDFURY])),
51
52
  enchantments: [],
@@ -84,6 +85,7 @@ const buildSingleBoardEntity = (cardId, controllerHero, friendlyBoard, allCards,
84
85
  newEntity.poisonous = newEntity.poisonous || (0, exports.hasMechanic)(moduleCard, reference_data_1.GameTag[reference_data_1.GameTag.POISONOUS]);
85
86
  newEntity.venomous = newEntity.venomous || (0, exports.hasMechanic)(moduleCard, reference_data_1.GameTag[reference_data_1.GameTag.VENOMOUS]);
86
87
  newEntity.windfury = newEntity.windfury || (0, exports.hasMechanic)(moduleCard, reference_data_1.GameTag[reference_data_1.GameTag.WINDFURY]);
88
+ newEntity.stealth = newEntity.stealth || (0, exports.hasMechanic)(moduleCard, reference_data_1.GameTag[reference_data_1.GameTag.STEALTH]);
87
89
  }
88
90
  }
89
91
  newEntity.health = 1;
@@ -139,7 +141,7 @@ const grantRandomHealth = (source, board, hero, health, gameState, excludeSource
139
141
  .filter((e) => !excludeSource || e.entityId !== source.entityId)
140
142
  .filter((e) => e.health > 0 && !e.definitelyDead);
141
143
  if (candidateBoard.length > 0) {
142
- const target = candidateBoard[Math.floor(Math.random() * candidateBoard.length)];
144
+ const target = (0, utils_1.pickRandom)(candidateBoard);
143
145
  (0, stats_1.modifyStats)(target, 0, health, board, hero, gameState);
144
146
  gameState.spectator.registerPowerTarget(source, target, board, null, null);
145
147
  }
@@ -338,7 +340,7 @@ const addImpliedMechanics = (entity, cardsData) => {
338
340
  exports.addImpliedMechanics = addImpliedMechanics;
339
341
  const setImplicitDataForEntity = (entity, cardsData) => {
340
342
  entity.cardId = (0, exports.normalizeCardIdForSkin)(entity.cardId);
341
- entity.maxHealth = Math.max(0, entity.health);
343
+ entity.maxHealth = Math.max(0, entity.health, entity.maxHealth);
342
344
  const avengeValue = cardsData.avengeValue(entity.cardId);
343
345
  if (avengeValue > 0) {
344
346
  entity.avengeCurrent = avengeValue;
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AACA,iEAAoH;AAKpH,4CAA4D;AAI5D,8CAAiD;AAEjD,MAAM,UAAU,GAAG;;;;;;;CAOlB,CAAC;AACF,MAAM,sBAAsB,GAAG;;;;CAO9B,CAAC;AACF,MAAM,eAAe,GAAG,8BAAoE,CAAC;AAEtF,MAAM,sBAAsB,GAAG,CACrC,MAAc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A,uBAAuB,2BAUlC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { ALL_BG_RACES, AllCardsService, CardIds, GameTag, Race, ReferenceCard } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from './bgs-player-entity';\r\nimport { BoardEntity } from './board-entity';\r\nimport { BoardSecret } from './board-secret';\r\nimport { CardsData } from './cards/cards-data';\r\nimport { pickRandom, shuffleArray } from './services/utils';\r\nimport { FullGameState, GameState, PlayerState } from './simulation/internal-game-state';\r\nimport { SharedState } from './simulation/shared-state';\r\nimport { Spectator } from './simulation/spectator/spectator';\r\nimport { modifyStats } from './simulation/stats';\r\n\r\nconst CLEAVE_IDS = [\r\n\tCardIds.CaveHydra_BG_LOOT_078,\r\n\tCardIds.CaveHydra_TB_BaconUps_151,\r\n\tCardIds.FoeReaper4000_BG_GVG_113,\r\n\tCardIds.FoeReaper4000_TB_BaconUps_153,\r\n\tCardIds.BladeCollector_BG26_817,\r\n\tCardIds.BladeCollector_BG26_817_G,\r\n];\r\nconst ATTACK_IMMEDIATELY_IDS = [\r\n\tCardIds.Scallywag_SkyPirateToken_BGS_061t,\r\n\tCardIds.Scallywag_SkyPirateToken_TB_BaconUps_141t,\r\n\tCardIds.Onyxia_OnyxianWhelpToken,\r\n\t// The token doesn't attack immediately natively, only when spawned by the spell\r\n\t// See http://replays.firestoneapp.com/?reviewId=8924452a-540a-4324-8306-46900c3f9f35&turn=22&action=38\r\n\t// CardIds.ToxicTumbleweed_TumblingAssassinToken_BG28_641t,\r\n];\r\nconst CANT_ATTACK_IDS = [CardIds.ArcaneCannon_BGS_077, CardIds.ArcaneCannon_TB_BaconUps_128];\r\n\r\nexport const buildSingleBoardEntity = (\r\n\tcardId: string,\r\n\tcontrollerHero: BgsPlayerEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tfriendly: boolean,\r\n\tentityId = 1,\r\n\tspawnReborn = false,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tentityToSpawn: BoardEntity,\r\n\toriginalEntity: BoardEntity = null,\r\n): BoardEntity => {\r\n\tconst card = allCards.getCard(cardId);\r\n\tconst attackImmediately = ATTACK_IMMEDIATELY_IDS.indexOf(cardId as CardIds) !== -1;\r\n\tconst newEntity = !!entityToSpawn\r\n\t\t? ({\r\n\t\t\t\t...entityToSpawn,\r\n\t\t\t\tentityId: sharedState.currentEntityId++,\r\n\t\t\t\tdefinitelyDead: false,\r\n\t\t\t\tavengeCurrent: entityToSpawn.avengeDefault,\r\n\t\t\t\tattacking: false,\r\n\t\t\t\tdamageMultiplier: 1,\r\n\t\t\t\tfrenzyChargesLeft: 1,\r\n\t\t\t\tfriendly: friendly,\r\n\t\t\t\thasAttacked: 0,\r\n\t\t } as BoardEntity)\r\n\t\t: addImpliedMechanics(\r\n\t\t\t\t{\r\n\t\t\t\t\tentityId: entityId,\r\n\t\t\t\t\tattack: card.attack,\r\n\t\t\t\t\thasAttacked: 0,\r\n\t\t\t\t\tcardId: cardId,\r\n\t\t\t\t\tdivineShield: hasMechanic(card, 'DIVINE_SHIELD'),\r\n\t\t\t\t\thealth: card.health,\r\n\t\t\t\t\tmaxHealth: card.health,\r\n\t\t\t\t\ttaunt: hasMechanic(card, GameTag[GameTag.TAUNT]),\r\n\t\t\t\t\treborn: hasMechanic(card, 'REBORN'),\r\n\t\t\t\t\tpoisonous: hasMechanic(card, GameTag[GameTag.POISONOUS]),\r\n\t\t\t\t\tvenomous: hasMechanic(card, GameTag[GameTag.VENOMOUS]),\r\n\t\t\t\t\twindfury:\r\n\t\t\t\t\t\thasMechanic(card, GameTag[GameTag.WINDFURY]) ||\r\n\t\t\t\t\t\tcard.referencedTags?.includes(GameTag[GameTag.WINDFURY]),\r\n\t\t\t\t\tenchantments: [],\r\n\t\t\t\t\tpendingAttackBuffs: [],\r\n\t\t\t\t\tfriendly: friendly,\r\n\t\t\t\t\tattackImmediately: attackImmediately,\r\n\t\t\t\t\tavengeCurrent: cardsData.avengeValue(cardId),\r\n\t\t\t\t\tavengeDefault: cardsData.avengeValue(cardId),\r\n\t\t\t\t} as BoardEntity,\r\n\t\t\t\tcardsData,\r\n\t\t );\r\n\r\n\tif (spawnReborn && !entityToSpawn) {\r\n\t\tif (cardId === CardIds.BuildAnUndead_PutricidesCreationToken) {\r\n\t\t\tconst stitchedCardId = !!originalEntity.additionalCards?.length ? originalEntity.additionalCards[0] : null;\r\n\t\t\tif (stitchedCardId) {\r\n\t\t\t\tconst stitchedCard = allCards.getCard(stitchedCardId);\r\n\t\t\t\tnewEntity.attack = newEntity.attack + stitchedCard.attack;\r\n\t\t\t\tnewEntity.maxHealth = newEntity.maxHealth + stitchedCard.health;\r\n\t\t\t\tnewEntity.taunt = newEntity.taunt || hasMechanic(stitchedCard, GameTag[GameTag.TAUNT]);\r\n\t\t\t\tnewEntity.divineShield =\r\n\t\t\t\t\tnewEntity.divineShield || hasMechanic(stitchedCard, GameTag[GameTag.DIVINE_SHIELD]);\r\n\t\t\t\tnewEntity.hadDivineShield = newEntity.hadDivineShield || newEntity.divineShield;\r\n\t\t\t\tnewEntity.poisonous = newEntity.poisonous || hasMechanic(stitchedCard, GameTag[GameTag.POISONOUS]);\r\n\t\t\t\tnewEntity.venomous = newEntity.venomous || hasMechanic(stitchedCard, GameTag[GameTag.VENOMOUS]);\r\n\t\t\t\tnewEntity.windfury = newEntity.windfury || hasMechanic(stitchedCard, GameTag[GameTag.WINDFURY]);\r\n\t\t\t\tnewEntity.avengeCurrent = newEntity.avengeCurrent || cardsData.avengeValue(stitchedCardId);\r\n\t\t\t\tnewEntity.avengeDefault = newEntity.avengeDefault || cardsData.avengeValue(stitchedCardId);\r\n\t\t\t}\r\n\t\t} else if (\r\n\t\t\tcardId === CardIds.ZilliaxAssembled_BG29_100_G &&\r\n\t\t\t!!originalEntity.additionalCards?.filter((c) => !!c).length\r\n\t\t) {\r\n\t\t\t// In this case, the base stats are still correct (the golden stats of Zilliax), but the keywords\r\n\t\t\t// can change\r\n\t\t\tfor (const moduleCardId of originalEntity.additionalCards) {\r\n\t\t\t\tconst moduleCard = allCards.getCard(moduleCardId);\r\n\t\t\t\tnewEntity.taunt = newEntity.taunt || hasMechanic(moduleCard, GameTag[GameTag.TAUNT]);\r\n\t\t\t\tnewEntity.divineShield =\r\n\t\t\t\t\tnewEntity.divineShield || hasMechanic(moduleCard, GameTag[GameTag.DIVINE_SHIELD]);\r\n\t\t\t\tnewEntity.hadDivineShield = newEntity.hadDivineShield || newEntity.divineShield;\r\n\t\t\t\tnewEntity.poisonous = newEntity.poisonous || hasMechanic(moduleCard, GameTag[GameTag.POISONOUS]);\r\n\t\t\t\tnewEntity.venomous = newEntity.venomous || hasMechanic(moduleCard, GameTag[GameTag.VENOMOUS]);\r\n\t\t\t\tnewEntity.windfury = newEntity.windfury || hasMechanic(moduleCard, GameTag[GameTag.WINDFURY]);\r\n\t\t\t}\r\n\t\t}\r\n\t\tnewEntity.health = 1;\r\n\t\tnewEntity.reborn = false;\r\n\t\tnewEntity.scriptDataNum1 = getScriptDataNum1(cardId, originalEntity);\r\n\r\n\t\t// For ghoul-acabra + reborn\r\n\t\t// newEntity.attack += originalEntity.permanentAttack ?? 0;\r\n\t\t// newEntity.health += originalEntity.permanentHealth ?? 0;\r\n\t}\r\n\r\n\tnewEntity.hadDivineShield = newEntity.divineShield || newEntity.hadDivineShield;\r\n\treturn newEntity;\r\n};\r\n\r\nconst getScriptDataNum1 = (cardId: string, originalEntity: BoardEntity): number => {\r\n\tswitch (cardId) {\r\n\t\tcase CardIds.OctosariWrapGod_BG26_804:\r\n\t\t\treturn 8;\r\n\t\tcase CardIds.OctosariWrapGod_BG26_804_G:\r\n\t\t\treturn 16;\r\n\t\tdefault:\r\n\t\t\treturn 0;\r\n\t}\r\n};\r\n\r\nexport const buildRandomUndeadCreation = (\r\n\tcontrollerHero: BgsPlayerEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tfriendly: boolean,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n): BoardEntity => {\r\n\tconst baseCard = pickRandom(cardsData.putricidePool1);\r\n\tconst stitchedCardId =\r\n\t\tbaseCard === CardIds.EternalSummoner_BG25_009\r\n\t\t\t? pickRandom(cardsData.putridicePool2ForEternalSummoner)\r\n\t\t\t: pickRandom(cardsData.putricidePool2);\r\n\tconst newEntity = buildSingleBoardEntity(\r\n\t\tbaseCard,\r\n\t\tcontrollerHero,\r\n\t\tfriendlyBoard,\r\n\t\tallCards,\r\n\t\tfriendly,\r\n\t\tsharedState.currentEntityId++,\r\n\t\tfalse,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tnull,\r\n\t);\r\n\tconst stitchedCard = allCards.getCard(stitchedCardId);\r\n\tnewEntity.attack += stitchedCard.attack;\r\n\tnewEntity.health += stitchedCard.health;\r\n\tnewEntity.taunt = newEntity.taunt || hasMechanic(stitchedCard, GameTag[GameTag.TAUNT]);\r\n\tnewEntity.divineShield = newEntity.divineShield || hasMechanic(stitchedCard, GameTag[GameTag.DIVINE_SHIELD]);\r\n\tnewEntity.poisonous = newEntity.venomous || hasMechanic(stitchedCard, GameTag[GameTag.POISONOUS]);\r\n\tnewEntity.venomous = newEntity.poisonous || hasMechanic(stitchedCard, GameTag[GameTag.VENOMOUS]);\r\n\tnewEntity.windfury = newEntity.windfury || hasMechanic(stitchedCard, GameTag[GameTag.WINDFURY]);\r\n\tnewEntity.avengeCurrent = newEntity.avengeCurrent || cardsData.avengeValue(stitchedCardId);\r\n\tnewEntity.avengeDefault = newEntity.avengeDefault || cardsData.avengeValue(stitchedCardId);\r\n\treturn newEntity;\r\n};\r\n\r\nexport const grantRandomAttack = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tadditionalAttack: number,\r\n\tgameState: FullGameState,\r\n\texcludeSource = false,\r\n): void => {\r\n\tconst candidateBoard = board\r\n\t\t.filter((e) => !excludeSource || e.entityId !== source.entityId)\r\n\t\t.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tif (candidateBoard.length > 0) {\r\n\t\tconst target = candidateBoard[Math.floor(Math.random() * candidateBoard.length)];\r\n\t\tmodifyStats(target, additionalAttack, 0, candidateBoard, hero, gameState);\r\n\t\tgameState.spectator.registerPowerTarget(source, target, board, null, null);\r\n\t}\r\n};\r\n\r\nexport const grantRandomHealth = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\thealth: number,\r\n\tgameState: FullGameState,\r\n\texcludeSource = false,\r\n): void => {\r\n\tconst candidateBoard = board\r\n\t\t.filter((e) => !excludeSource || e.entityId !== source.entityId)\r\n\t\t.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tif (candidateBoard.length > 0) {\r\n\t\tconst target = candidateBoard[Math.floor(Math.random() * candidateBoard.length)];\r\n\t\tmodifyStats(target, 0, health, board, hero, gameState);\r\n\t\tgameState.spectator.registerPowerTarget(source, target, board, null, null);\r\n\t}\r\n};\r\n\r\nexport const grantRandomStats = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tattack: number,\r\n\thealth: number,\r\n\trace: Race,\r\n\texcludeSource: boolean,\r\n\tgameState: FullGameState,\r\n): BoardEntity => {\r\n\tif (board.length > 0) {\r\n\t\tconst target: BoardEntity = getRandomAliveMinion(\r\n\t\t\tboard.filter((e) => !!e.cardId).filter((e) => (excludeSource ? e.entityId !== source.entityId : true)),\r\n\t\t\trace,\r\n\t\t\tgameState.allCards,\r\n\t\t);\r\n\t\tif (target) {\r\n\t\t\tmodifyStats(target, attack, health, board, hero, gameState);\r\n\t\t\tif (gameState.spectator) {\r\n\t\t\t\tgameState.spectator.registerPowerTarget(source, target, board, null, null);\r\n\t\t\t}\r\n\t\t\treturn target;\r\n\t\t}\r\n\t}\r\n\treturn null;\r\n};\r\n\r\nexport const grantRandomDivineShield = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst elligibleEntities = board\r\n\t\t.filter((entity) => !entity.divineShield)\r\n\t\t.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\tif (elligibleEntities.length > 0) {\r\n\t\tconst chosen = pickRandom(elligibleEntities);\r\n\t\tupdateDivineShield(chosen, board, true, allCards);\r\n\t\tspectator.registerPowerTarget(source, chosen, board, null, null);\r\n\t}\r\n\t// return board;\r\n};\r\n\r\nexport const updateDivineShield = (\r\n\tentity: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tnewValue: boolean,\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\t// if ((entity.divineShield ?? false) === newValue) {\r\n\t// \treturn;\r\n\t// }\r\n\tentity.hadDivineShield = newValue || entity.divineShield || entity.hadDivineShield;\r\n\tentity.divineShield = newValue;\r\n\tif (entity.divineShield) {\r\n\t\tconst boardForDrake = board;\r\n\t\tconst statsBonus =\r\n\t\t\t8 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043).length +\r\n\t\t\t16 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043_G).length;\r\n\t\t// Don't trigger all \"on attack changed\" effects, since it's an aura\r\n\t\tentity.attack += statsBonus;\r\n\t} else {\r\n\t\t// Also consider itself\r\n\t\tconst boardForDrake = board;\r\n\t\tconst statsBonus =\r\n\t\t\t8 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043).length +\r\n\t\t\t16 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043_G).length;\r\n\t\tentity.attack -= statsBonus;\r\n\t}\r\n};\r\n\r\nexport const grantAllDivineShield = (board: BoardEntity[], tribe: string, cards: AllCardsService): void => {\r\n\tconst elligibleEntities = board\r\n\t\t.filter((entity) => !entity.divineShield)\r\n\t\t.filter((entity) => isCorrectTribe(cards.getCard(entity.cardId).races, getRaceEnum(tribe)));\r\n\tfor (const entity of elligibleEntities) {\r\n\t\tupdateDivineShield(entity, board, true, cards);\r\n\t}\r\n};\r\n\r\nexport const getRandomAliveMinion = (board: BoardEntity[], race: Race, allCards: AllCardsService): BoardEntity => {\r\n\tconst validTribes = board\r\n\t\t.filter((e) => !race || isCorrectTribe(allCards.getCard(e?.cardId).races, race))\r\n\t\t.filter((e) => !!e?.health && !e.definitelyDead);\r\n\tif (!validTribes.length) {\r\n\t\treturn null;\r\n\t}\r\n\tconst randomIndex = Math.floor(Math.random() * validTribes.length);\r\n\treturn validTribes[randomIndex];\r\n};\r\n\r\nexport const getRandomRevivableMinion = (board: BoardEntity[], race: Race, allCards: AllCardsService): BoardEntity => {\r\n\tconst validTribes = board\r\n\t\t.filter((e) => !race || isCorrectTribe(allCards.getCard(e?.cardId).races, race))\r\n\t\t.filter((e) => !e.definitelyDead);\r\n\tif (!validTribes.length) {\r\n\t\treturn null;\r\n\t}\r\n\tconst randomIndex = Math.floor(Math.random() * validTribes.length);\r\n\treturn validTribes[randomIndex];\r\n};\r\n\r\nexport const getRandomMinionWithHighestHealth = (board: BoardEntity[]): BoardEntity => {\r\n\tif (!board.length) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tconst highestHealth = Math.max(...board.map((e) => e.health));\r\n\tconst validMinions = board.filter((e) => e.health === highestHealth);\r\n\treturn validMinions[Math.floor(Math.random() * validMinions.length)];\r\n};\r\n\r\nexport const addStatsToBoard = (\r\n\tsourceEntity: BoardEntity | BgsPlayerEntity | BoardSecret,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tattack: number,\r\n\thealth: number,\r\n\tgameState: FullGameState,\r\n\ttribe?: string,\r\n\t// permanentUpgrade = false,\r\n): void => {\r\n\tfor (const entity of board) {\r\n\t\tif (!tribe || hasCorrectTribe(entity, Race[tribe], gameState.allCards)) {\r\n\t\t\tmodifyStats(entity, attack, health, board, hero, gameState);\r\n\t\t\tgameState.spectator?.registerPowerTarget(sourceEntity, entity, board, null, null);\r\n\t\t\t// if (permanentUpgrade) {\r\n\t\t\t// \tentity.permanentAttack = (entity.permanentAttack ?? 0) + attack;\r\n\t\t\t// \tentity.permanentHealth = (entity.permanentHealth ?? 0) + health;\r\n\t\t\t// }\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const grantStatsToMinionsOfEachType = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tattack: number,\r\n\thealth: number,\r\n\tgameState: FullGameState,\r\n\tnumberOfDifferentTypes = 99,\r\n\tcanRevive = true,\r\n): void => {\r\n\tconst minionsToBuff = getMinionsOfDifferentTypes(board, gameState, canRevive, numberOfDifferentTypes);\r\n\tfor (const entity of minionsToBuff) {\r\n\t\tmodifyStats(entity, attack, health, board, hero, gameState);\r\n\t\tgameState.spectator.registerPowerTarget(source, entity, board, null, null);\r\n\t}\r\n};\r\n\r\nexport const getMinionsOfDifferentTypes = (\r\n\tboard: BoardEntity[],\r\n\tgameState: FullGameState,\r\n\tcanRevive = true,\r\n\tnumberOfDifferentTypes = 99,\r\n): BoardEntity[] => {\r\n\tconst result: BoardEntity[] = [];\r\n\tif (board.length > 0) {\r\n\t\tlet boardCopy = board.filter((e) => !gameState.allCards.getCard(e.cardId).races?.includes(Race[Race.ALL]));\r\n\t\tconst allRaces = shuffleArray(ALL_BG_RACES);\r\n\t\tlet typesBuffed = 0;\r\n\t\tconst racesProcessed = [];\r\n\t\tfor (let i = 1; i <= 2; i++) {\r\n\t\t\tfor (const tribe of allRaces) {\r\n\t\t\t\tconst minionsWithRaces = boardCopy\r\n\t\t\t\t\t.filter((e) => gameState.allCards.getCard(e.cardId).races?.length === i)\r\n\t\t\t\t\t.filter((e) =>\r\n\t\t\t\t\t\tgameState.allCards.getCard(e.cardId).races.some((r) => !racesProcessed.includes(Race[r])),\r\n\t\t\t\t\t);\r\n\t\t\t\tif (typesBuffed >= numberOfDifferentTypes) {\r\n\t\t\t\t\treturn result;\r\n\t\t\t\t}\r\n\t\t\t\t// const tribeStr = Race[tribe];\r\n\t\t\t\t// const minionWithRevive = getRandomRevivableMinion(boardCopy, tribe, gameState.allCards);\r\n\t\t\t\t// const boardDebug = minionsWithRaces.map((e) => ({\r\n\t\t\t\t// \tname: gameState.allCards.getCard(e.cardId).name,\r\n\t\t\t\t// \traces: gameState.allCards.getCard(e.cardId).races?.join(','),\r\n\t\t\t\t// }));\r\n\t\t\t\tconst validMinion: BoardEntity = canRevive\r\n\t\t\t\t\t? getRandomRevivableMinion(minionsWithRaces, tribe, gameState.allCards)\r\n\t\t\t\t\t: getRandomAliveMinion(minionsWithRaces, tribe, gameState.allCards);\r\n\t\t\t\tif (validMinion) {\r\n\t\t\t\t\tresult.push(validMinion);\r\n\t\t\t\t\tboardCopy = boardCopy.filter((e) => e !== validMinion);\r\n\t\t\t\t\ttypesBuffed++;\r\n\t\t\t\t\tracesProcessed.push(tribe);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tresult.push(...board.filter((e) => gameState.allCards.getCard(e.cardId).races?.includes(Race[Race.ALL])));\r\n\t}\r\n\treturn result;\r\n};\r\n\r\nexport const hasMechanic = (card: ReferenceCard, mechanic: string): boolean => {\r\n\treturn card.mechanics?.includes(mechanic);\r\n};\r\n\r\nexport const hasCorrectTribe = (entity: BoardEntity, targetTribe: Race, allCards: AllCardsService): boolean => {\r\n\treturn isCorrectTribe(allCards.getCard(entity.cardId).races, targetTribe);\r\n};\r\n\r\nexport const isCorrectTribe = (cardRaces: readonly string[], targetTribe: Race): boolean => {\r\n\tif (!cardRaces?.length) {\r\n\t\treturn false;\r\n\t}\r\n\treturn cardRaces\r\n\t\t.map((cardRace) => getRaceEnum(cardRace))\r\n\t\t.some((raceEnum) => raceEnum === Race.ALL || raceEnum === targetTribe);\r\n};\r\n\r\nexport const getRaceEnum = (race: string): Race => {\r\n\treturn Race[race];\r\n};\r\n\r\nexport const addImpliedMechanics = (entity: BoardEntity, cardsData: CardsData): BoardEntity => {\r\n\tconst cleave = CLEAVE_IDS.indexOf(entity.cardId as CardIds) !== -1;\r\n\tconst cantAttack = CANT_ATTACK_IDS.indexOf(entity.cardId as CardIds) !== -1;\r\n\tentity.cleave = cleave;\r\n\tentity.cantAttack = cantAttack;\r\n\tentity.divineShield = entity.divineShield || entity.hadDivineShield;\r\n\tentity.immuneWhenAttackCharges =\r\n\t\tentity.cardId === CardIds.Warpwing_BG24_004 || entity.cardId === CardIds.Warpwing_BG24_004_G ? 99999 : null;\r\n\tentity.frenzyChargesLeft =\r\n\t\tentity.cardId === CardIds.BristlebackKnight_BG20_204_G\r\n\t\t\t? 2\r\n\t\t\t: entity.cardId === CardIds.BristlebackKnight_BG20_204\r\n\t\t\t? 1\r\n\t\t\t: 0;\r\n\t// It's not an issue adding a charge for entities without a special ability\r\n\tentity.abiityChargesLeft = [\r\n\t\tCardIds.MarineMatriarch_BG29_610,\r\n\t\tCardIds.MarineMatriarch_BG29_610_G,\r\n\t\tCardIds.SoftHeartedSiren_BG26_590,\r\n\t\tCardIds.SoftHeartedSiren_BG26_590_G,\r\n\t\tCardIds.LongJohnCopper_BG29_831,\r\n\t\tCardIds.LongJohnCopper_BG29_831_G,\r\n\t\tCardIds.BristlingBuffoon_BG29_160,\r\n\t\tCardIds.BristlingBuffoon_BG29_160_G,\r\n\t].includes(entity.cardId as CardIds)\r\n\t\t? 3\r\n\t\t: [\r\n\t\t\t\tCardIds.TransmutedBramblewitch_BG27_013_G,\r\n\t\t\t\tCardIds.Mannoroth_BG27_507_G,\r\n\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy_G,\r\n\t\t\t\tCardIds.MadMatador_BG28_404_G,\r\n\t\t\t\tCardIds.WingedChimera_BG29_844,\r\n\t\t\t\tCardIds.WingedChimera_BG29_844_G,\r\n\t\t ].includes(entity.cardId as CardIds)\r\n\t\t? 2\r\n\t\t: 1;\r\n\r\n\treturn setImplicitDataForEntity(entity, cardsData);\r\n};\r\n\r\nconst setImplicitDataForEntity = (entity: BoardEntity, cardsData: CardsData): BoardEntity => {\r\n\tentity.cardId = normalizeCardIdForSkin(entity.cardId);\r\n\tentity.maxHealth = Math.max(0, entity.health);\r\n\tconst avengeValue = cardsData.avengeValue(entity.cardId);\r\n\tif (avengeValue > 0) {\r\n\t\tentity.avengeCurrent = avengeValue;\r\n\t\tentity.avengeDefault = avengeValue;\r\n\t}\r\n\treturn entity;\r\n};\r\n\r\nexport const normalizeCardIdForSkin = (cardId: string): string => {\r\n\tif (!cardId?.length) {\r\n\t\treturn cardId;\r\n\t}\r\n\tconst skinMatch = cardId.match(/(.*)_SKIN_.*/);\r\n\tif (skinMatch) {\r\n\t\treturn skinMatch[1];\r\n\t}\r\n\treturn cardId;\r\n};\r\n\r\nexport const stringifySimple = (board: readonly BoardEntity[], allCards: AllCardsService = null): string => {\r\n\treturn '[' + board.map((entity) => stringifySimpleCard(entity, allCards)).join(', ') + ']';\r\n};\r\n\r\nexport const stringifySimpleCard = (entity: BoardEntity, allCards: AllCardsService = null): string => {\r\n\treturn entity ? `${allCards?.getCard(entity.cardId)?.name ?? entity.cardId}/atk=${entity.attack}` : null;\r\n};\r\n\r\nexport const isFish = (entity: BoardEntity): boolean => {\r\n\treturn (\r\n\t\tentity.cardId.startsWith(CardIds.AvatarOfNzoth_FishOfNzothToken) ||\r\n\t\tentity.cardId.startsWith(CardIds.FishOfNzoth) ||\r\n\t\tentity.additionalCards?.includes(CardIds.DevourerOfSouls_BG_RLK_538)\r\n\t);\r\n};\r\n\r\nexport const isPilotedWhirlOTron = (entity: BoardEntity): boolean => {\r\n\treturn entity.cardId.startsWith(CardIds.PilotedWhirlOTron_BG21_HERO_030_Buddy);\r\n};\r\n\r\nexport const isGolden = (cardId: string, allCards: AllCardsService): boolean => {\r\n\treturn !!allCards.getCard(cardId).battlegroundsNormalDbfId;\r\n};\r\n\r\nexport const getPlayerState = (gameState: GameState, hero: BgsPlayerEntity): PlayerState => {\r\n\treturn gameState.player.player === hero\r\n\t\t? gameState.player\r\n\t\t: gameState.player.teammate?.player === hero\r\n\t\t? gameState.player.teammate\r\n\t\t: gameState.opponent.player === hero\r\n\t\t? gameState.opponent\r\n\t\t: gameState.opponent.teammate?.player === hero\r\n\t\t? gameState.opponent.teammate\r\n\t\t: null;\r\n};\r\n\r\nexport const getTeammateInitialState = (gameState: GameState, hero: BgsPlayerEntity): PlayerState => {\r\n\treturn gameState.playerInitial.player?.entityId === hero?.entityId\r\n\t\t? gameState.playerInitial.teammate\r\n\t\t: gameState.playerInitial.teammate?.player?.entityId === hero?.entityId\r\n\t\t? gameState.playerInitial\r\n\t\t: gameState.opponentInitial.player?.entityId === hero?.entityId\r\n\t\t? gameState.opponentInitial.teammate\r\n\t\t: gameState.opponentInitial.teammate?.player?.entityId === hero?.entityId\r\n\t\t? gameState.opponentInitial\r\n\t\t: null;\r\n};\r\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AACA,iEAAoH;AAKpH,4CAA4D;AAI5D,8CAAiD;AAEjD,MAAM,UAAU,GAAG;;;;;;;CAOlB,CAAC;AACF,MAAM,sBAAsB,GAAG;;;;CAO9B,CAAC;AACF,MAAM,eAAe,GAAG,8BAAoE,CAAC;AAEtF,MAAM,sBAAsB,GAAG,CACrC,MAAc,EACd,cAA+B,EAC/B,aAA4B,EAC5B,QAAyB,EACzB,QAAiB,EACjB,QAAQ,GAAG,CAAC,EACZ,WAAW,GAAG,KAAK,EACnB,SAAoB,EACpB,WAAwB,EACxB,aAA0B,EAC1B,iBAA8B,IAAI,EACpB,EAAE;;IAChB,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,iBAAiB,GAAG,sBAAsB,CAAC,OAAO,CAAC,MAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;IACnF,MAAM,SAAS,GAAG,CAAC,CAAC,aAAa;QAChC,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CAAC,QAAQ,0CAAE,MAAM,MAAK,IAAI;oBAC9C,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ;oBAC7B,CAAC,CAAC,IAAI,CAAC;AACT,CAAC,CAAC;AAVW,QAAA,cAAc,kBAUzB;AAEK,MAAM,uBAAuB,GAAG,CAAC,SAAoB,EAAE,IAAqB,EAAe,EAAE;;IACnG,OAAO,CAAA,MAAA,SAAS,CAAC,aAAa,CAAC,MAAM,0CAAE,QAAQ,OAAK,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,CAAA;QACjE,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,QAAQ;QAClC,CAAC,CAAC,CAAA,MAAA,MAAA,SAAS,CAAC,aAAa,CAAC,QAAQ,0CAAE,MAAM,0CAAE,QAAQ,OAAK,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,CAAA;YACvE,CAAC,CAAC,SAAS,CAAC,aAAa;YACzB,CAAC,CAAC,CAAA,MAAA,SAAS,CAAC,eAAe,CAAC,MAAM,0CAAE,QAAQ,OAAK,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,CAAA;gBAC/D,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,QAAQ;gBACpC,CAAC,CAAC,CAAA,MAAA,MAAA,SAAS,CAAC,eAAe,CAAC,QAAQ,0CAAE,MAAM,0CAAE,QAAQ,OAAK,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,CAAA;oBACzE,CAAC,CAAC,SAAS,CAAC,eAAe;oBAC3B,CAAC,CAAC,IAAI,CAAC;AACT,CAAC,CAAC;AAVW,QAAA,uBAAuB,2BAUlC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { ALL_BG_RACES, AllCardsService, CardIds, GameTag, Race, ReferenceCard } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from './bgs-player-entity';\r\nimport { BoardEntity } from './board-entity';\r\nimport { BoardSecret } from './board-secret';\r\nimport { CardsData } from './cards/cards-data';\r\nimport { pickRandom, shuffleArray } from './services/utils';\r\nimport { FullGameState, GameState, PlayerState } from './simulation/internal-game-state';\r\nimport { SharedState } from './simulation/shared-state';\r\nimport { Spectator } from './simulation/spectator/spectator';\r\nimport { modifyStats } from './simulation/stats';\r\n\r\nconst CLEAVE_IDS = [\r\n\tCardIds.CaveHydra_BG_LOOT_078,\r\n\tCardIds.CaveHydra_TB_BaconUps_151,\r\n\tCardIds.FoeReaper4000_BG_GVG_113,\r\n\tCardIds.FoeReaper4000_TB_BaconUps_153,\r\n\tCardIds.BladeCollector_BG26_817,\r\n\tCardIds.BladeCollector_BG26_817_G,\r\n];\r\nconst ATTACK_IMMEDIATELY_IDS = [\r\n\tCardIds.Scallywag_SkyPirateToken_BGS_061t,\r\n\tCardIds.Scallywag_SkyPirateToken_TB_BaconUps_141t,\r\n\tCardIds.Onyxia_OnyxianWhelpToken,\r\n\t// The token doesn't attack immediately natively, only when spawned by the spell\r\n\t// See http://replays.firestoneapp.com/?reviewId=8924452a-540a-4324-8306-46900c3f9f35&turn=22&action=38\r\n\t// CardIds.ToxicTumbleweed_TumblingAssassinToken_BG28_641t,\r\n];\r\nconst CANT_ATTACK_IDS = [CardIds.ArcaneCannon_BGS_077, CardIds.ArcaneCannon_TB_BaconUps_128];\r\n\r\nexport const buildSingleBoardEntity = (\r\n\tcardId: string,\r\n\tcontrollerHero: BgsPlayerEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tfriendly: boolean,\r\n\tentityId = 1,\r\n\tspawnReborn = false,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tentityToSpawn: BoardEntity,\r\n\toriginalEntity: BoardEntity = null,\r\n): BoardEntity => {\r\n\tconst card = allCards.getCard(cardId);\r\n\tconst attackImmediately = ATTACK_IMMEDIATELY_IDS.indexOf(cardId as CardIds) !== -1;\r\n\tconst newEntity = !!entityToSpawn\r\n\t\t? ({\r\n\t\t\t\t...entityToSpawn,\r\n\t\t\t\tentityId: sharedState.currentEntityId++,\r\n\t\t\t\tdefinitelyDead: false,\r\n\t\t\t\tavengeCurrent: entityToSpawn.avengeDefault,\r\n\t\t\t\tattacking: false,\r\n\t\t\t\tdamageMultiplier: 1,\r\n\t\t\t\tfrenzyChargesLeft: 1,\r\n\t\t\t\tfriendly: friendly,\r\n\t\t\t\thasAttacked: 0,\r\n\t\t } as BoardEntity)\r\n\t\t: addImpliedMechanics(\r\n\t\t\t\t{\r\n\t\t\t\t\tentityId: entityId,\r\n\t\t\t\t\tattack: card.attack,\r\n\t\t\t\t\thasAttacked: 0,\r\n\t\t\t\t\tcardId: cardId,\r\n\t\t\t\t\tdivineShield: hasMechanic(card, 'DIVINE_SHIELD'),\r\n\t\t\t\t\thealth: card.health,\r\n\t\t\t\t\tmaxHealth: card.health,\r\n\t\t\t\t\ttaunt: hasMechanic(card, GameTag[GameTag.TAUNT]),\r\n\t\t\t\t\treborn: hasMechanic(card, 'REBORN'),\r\n\t\t\t\t\tpoisonous: hasMechanic(card, GameTag[GameTag.POISONOUS]),\r\n\t\t\t\t\tvenomous: hasMechanic(card, GameTag[GameTag.VENOMOUS]),\r\n\t\t\t\t\tstealth: hasMechanic(card, GameTag[GameTag.STEALTH]),\r\n\t\t\t\t\twindfury:\r\n\t\t\t\t\t\thasMechanic(card, GameTag[GameTag.WINDFURY]) ||\r\n\t\t\t\t\t\tcard.referencedTags?.includes(GameTag[GameTag.WINDFURY]),\r\n\t\t\t\t\tenchantments: [],\r\n\t\t\t\t\tpendingAttackBuffs: [],\r\n\t\t\t\t\tfriendly: friendly,\r\n\t\t\t\t\tattackImmediately: attackImmediately,\r\n\t\t\t\t\tavengeCurrent: cardsData.avengeValue(cardId),\r\n\t\t\t\t\tavengeDefault: cardsData.avengeValue(cardId),\r\n\t\t\t\t} as BoardEntity,\r\n\t\t\t\tcardsData,\r\n\t\t );\r\n\r\n\tif (spawnReborn && !entityToSpawn) {\r\n\t\tif (cardId === CardIds.BuildAnUndead_PutricidesCreationToken) {\r\n\t\t\tconst stitchedCardId = !!originalEntity.additionalCards?.length ? originalEntity.additionalCards[0] : null;\r\n\t\t\tif (stitchedCardId) {\r\n\t\t\t\tconst stitchedCard = allCards.getCard(stitchedCardId);\r\n\t\t\t\tnewEntity.attack = newEntity.attack + stitchedCard.attack;\r\n\t\t\t\tnewEntity.maxHealth = newEntity.maxHealth + stitchedCard.health;\r\n\t\t\t\tnewEntity.taunt = newEntity.taunt || hasMechanic(stitchedCard, GameTag[GameTag.TAUNT]);\r\n\t\t\t\tnewEntity.divineShield =\r\n\t\t\t\t\tnewEntity.divineShield || hasMechanic(stitchedCard, GameTag[GameTag.DIVINE_SHIELD]);\r\n\t\t\t\tnewEntity.hadDivineShield = newEntity.hadDivineShield || newEntity.divineShield;\r\n\t\t\t\tnewEntity.poisonous = newEntity.poisonous || hasMechanic(stitchedCard, GameTag[GameTag.POISONOUS]);\r\n\t\t\t\tnewEntity.venomous = newEntity.venomous || hasMechanic(stitchedCard, GameTag[GameTag.VENOMOUS]);\r\n\t\t\t\tnewEntity.windfury = newEntity.windfury || hasMechanic(stitchedCard, GameTag[GameTag.WINDFURY]);\r\n\t\t\t\tnewEntity.avengeCurrent = newEntity.avengeCurrent || cardsData.avengeValue(stitchedCardId);\r\n\t\t\t\tnewEntity.avengeDefault = newEntity.avengeDefault || cardsData.avengeValue(stitchedCardId);\r\n\t\t\t}\r\n\t\t} else if (\r\n\t\t\tcardId === CardIds.ZilliaxAssembled_BG29_100_G &&\r\n\t\t\t!!originalEntity.additionalCards?.filter((c) => !!c).length\r\n\t\t) {\r\n\t\t\t// In this case, the base stats are still correct (the golden stats of Zilliax), but the keywords\r\n\t\t\t// can change\r\n\t\t\tfor (const moduleCardId of originalEntity.additionalCards) {\r\n\t\t\t\tconst moduleCard = allCards.getCard(moduleCardId);\r\n\t\t\t\tnewEntity.taunt = newEntity.taunt || hasMechanic(moduleCard, GameTag[GameTag.TAUNT]);\r\n\t\t\t\tnewEntity.divineShield =\r\n\t\t\t\t\tnewEntity.divineShield || hasMechanic(moduleCard, GameTag[GameTag.DIVINE_SHIELD]);\r\n\t\t\t\tnewEntity.hadDivineShield = newEntity.hadDivineShield || newEntity.divineShield;\r\n\t\t\t\tnewEntity.poisonous = newEntity.poisonous || hasMechanic(moduleCard, GameTag[GameTag.POISONOUS]);\r\n\t\t\t\tnewEntity.venomous = newEntity.venomous || hasMechanic(moduleCard, GameTag[GameTag.VENOMOUS]);\r\n\t\t\t\tnewEntity.windfury = newEntity.windfury || hasMechanic(moduleCard, GameTag[GameTag.WINDFURY]);\r\n\t\t\t\tnewEntity.stealth = newEntity.stealth || hasMechanic(moduleCard, GameTag[GameTag.STEALTH]);\r\n\t\t\t}\r\n\t\t}\r\n\t\tnewEntity.health = 1;\r\n\t\tnewEntity.reborn = false;\r\n\t\tnewEntity.scriptDataNum1 = getScriptDataNum1(cardId, originalEntity);\r\n\r\n\t\t// For ghoul-acabra + reborn\r\n\t\t// newEntity.attack += originalEntity.permanentAttack ?? 0;\r\n\t\t// newEntity.health += originalEntity.permanentHealth ?? 0;\r\n\t}\r\n\r\n\tnewEntity.hadDivineShield = newEntity.divineShield || newEntity.hadDivineShield;\r\n\treturn newEntity;\r\n};\r\n\r\nconst getScriptDataNum1 = (cardId: string, originalEntity: BoardEntity): number => {\r\n\tswitch (cardId) {\r\n\t\tcase CardIds.OctosariWrapGod_BG26_804:\r\n\t\t\treturn 8;\r\n\t\tcase CardIds.OctosariWrapGod_BG26_804_G:\r\n\t\t\treturn 16;\r\n\t\tdefault:\r\n\t\t\treturn 0;\r\n\t}\r\n};\r\n\r\nexport const buildRandomUndeadCreation = (\r\n\tcontrollerHero: BgsPlayerEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tfriendly: boolean,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n): BoardEntity => {\r\n\tconst baseCard = pickRandom(cardsData.putricidePool1);\r\n\tconst stitchedCardId =\r\n\t\tbaseCard === CardIds.EternalSummoner_BG25_009\r\n\t\t\t? pickRandom(cardsData.putridicePool2ForEternalSummoner)\r\n\t\t\t: pickRandom(cardsData.putricidePool2);\r\n\tconst newEntity = buildSingleBoardEntity(\r\n\t\tbaseCard,\r\n\t\tcontrollerHero,\r\n\t\tfriendlyBoard,\r\n\t\tallCards,\r\n\t\tfriendly,\r\n\t\tsharedState.currentEntityId++,\r\n\t\tfalse,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tnull,\r\n\t);\r\n\tconst stitchedCard = allCards.getCard(stitchedCardId);\r\n\tnewEntity.attack += stitchedCard.attack;\r\n\tnewEntity.health += stitchedCard.health;\r\n\tnewEntity.taunt = newEntity.taunt || hasMechanic(stitchedCard, GameTag[GameTag.TAUNT]);\r\n\tnewEntity.divineShield = newEntity.divineShield || hasMechanic(stitchedCard, GameTag[GameTag.DIVINE_SHIELD]);\r\n\tnewEntity.poisonous = newEntity.venomous || hasMechanic(stitchedCard, GameTag[GameTag.POISONOUS]);\r\n\tnewEntity.venomous = newEntity.poisonous || hasMechanic(stitchedCard, GameTag[GameTag.VENOMOUS]);\r\n\tnewEntity.windfury = newEntity.windfury || hasMechanic(stitchedCard, GameTag[GameTag.WINDFURY]);\r\n\tnewEntity.avengeCurrent = newEntity.avengeCurrent || cardsData.avengeValue(stitchedCardId);\r\n\tnewEntity.avengeDefault = newEntity.avengeDefault || cardsData.avengeValue(stitchedCardId);\r\n\treturn newEntity;\r\n};\r\n\r\nexport const grantRandomAttack = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tadditionalAttack: number,\r\n\tgameState: FullGameState,\r\n\texcludeSource = false,\r\n): void => {\r\n\tconst candidateBoard = board\r\n\t\t.filter((e) => !excludeSource || e.entityId !== source.entityId)\r\n\t\t.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tif (candidateBoard.length > 0) {\r\n\t\tconst target = candidateBoard[Math.floor(Math.random() * candidateBoard.length)];\r\n\t\tmodifyStats(target, additionalAttack, 0, candidateBoard, hero, gameState);\r\n\t\tgameState.spectator.registerPowerTarget(source, target, board, null, null);\r\n\t}\r\n};\r\n\r\nexport const grantRandomHealth = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\thealth: number,\r\n\tgameState: FullGameState,\r\n\texcludeSource = false,\r\n): void => {\r\n\tconst candidateBoard = board\r\n\t\t.filter((e) => !excludeSource || e.entityId !== source.entityId)\r\n\t\t.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tif (candidateBoard.length > 0) {\r\n\t\tconst target = pickRandom(candidateBoard);\r\n\t\tmodifyStats(target, 0, health, board, hero, gameState);\r\n\t\tgameState.spectator.registerPowerTarget(source, target, board, null, null);\r\n\t}\r\n};\r\n\r\nexport const grantRandomStats = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tattack: number,\r\n\thealth: number,\r\n\trace: Race,\r\n\texcludeSource: boolean,\r\n\tgameState: FullGameState,\r\n): BoardEntity => {\r\n\tif (board.length > 0) {\r\n\t\tconst target: BoardEntity = getRandomAliveMinion(\r\n\t\t\tboard.filter((e) => !!e.cardId).filter((e) => (excludeSource ? e.entityId !== source.entityId : true)),\r\n\t\t\trace,\r\n\t\t\tgameState.allCards,\r\n\t\t);\r\n\t\tif (target) {\r\n\t\t\tmodifyStats(target, attack, health, board, hero, gameState);\r\n\t\t\tif (gameState.spectator) {\r\n\t\t\t\tgameState.spectator.registerPowerTarget(source, target, board, null, null);\r\n\t\t\t}\r\n\t\t\treturn target;\r\n\t\t}\r\n\t}\r\n\treturn null;\r\n};\r\n\r\nexport const grantRandomDivineShield = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst elligibleEntities = board\r\n\t\t.filter((entity) => !entity.divineShield)\r\n\t\t.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\tif (elligibleEntities.length > 0) {\r\n\t\tconst chosen = pickRandom(elligibleEntities);\r\n\t\tupdateDivineShield(chosen, board, true, allCards);\r\n\t\tspectator.registerPowerTarget(source, chosen, board, null, null);\r\n\t}\r\n\t// return board;\r\n};\r\n\r\nexport const updateDivineShield = (\r\n\tentity: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tnewValue: boolean,\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\t// if ((entity.divineShield ?? false) === newValue) {\r\n\t// \treturn;\r\n\t// }\r\n\tentity.hadDivineShield = newValue || entity.divineShield || entity.hadDivineShield;\r\n\tentity.divineShield = newValue;\r\n\tif (entity.divineShield) {\r\n\t\tconst boardForDrake = board;\r\n\t\tconst statsBonus =\r\n\t\t\t8 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043).length +\r\n\t\t\t16 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043_G).length;\r\n\t\t// Don't trigger all \"on attack changed\" effects, since it's an aura\r\n\t\tentity.attack += statsBonus;\r\n\t} else {\r\n\t\t// Also consider itself\r\n\t\tconst boardForDrake = board;\r\n\t\tconst statsBonus =\r\n\t\t\t8 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043).length +\r\n\t\t\t16 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043_G).length;\r\n\t\tentity.attack -= statsBonus;\r\n\t}\r\n};\r\n\r\nexport const grantAllDivineShield = (board: BoardEntity[], tribe: string, cards: AllCardsService): void => {\r\n\tconst elligibleEntities = board\r\n\t\t.filter((entity) => !entity.divineShield)\r\n\t\t.filter((entity) => isCorrectTribe(cards.getCard(entity.cardId).races, getRaceEnum(tribe)));\r\n\tfor (const entity of elligibleEntities) {\r\n\t\tupdateDivineShield(entity, board, true, cards);\r\n\t}\r\n};\r\n\r\nexport const getRandomAliveMinion = (board: BoardEntity[], race: Race, allCards: AllCardsService): BoardEntity => {\r\n\tconst validTribes = board\r\n\t\t.filter((e) => !race || isCorrectTribe(allCards.getCard(e?.cardId).races, race))\r\n\t\t.filter((e) => !!e?.health && !e.definitelyDead);\r\n\tif (!validTribes.length) {\r\n\t\treturn null;\r\n\t}\r\n\tconst randomIndex = Math.floor(Math.random() * validTribes.length);\r\n\treturn validTribes[randomIndex];\r\n};\r\n\r\nexport const getRandomRevivableMinion = (board: BoardEntity[], race: Race, allCards: AllCardsService): BoardEntity => {\r\n\tconst validTribes = board\r\n\t\t.filter((e) => !race || isCorrectTribe(allCards.getCard(e?.cardId).races, race))\r\n\t\t.filter((e) => !e.definitelyDead);\r\n\tif (!validTribes.length) {\r\n\t\treturn null;\r\n\t}\r\n\tconst randomIndex = Math.floor(Math.random() * validTribes.length);\r\n\treturn validTribes[randomIndex];\r\n};\r\n\r\nexport const getRandomMinionWithHighestHealth = (board: BoardEntity[]): BoardEntity => {\r\n\tif (!board.length) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tconst highestHealth = Math.max(...board.map((e) => e.health));\r\n\tconst validMinions = board.filter((e) => e.health === highestHealth);\r\n\treturn validMinions[Math.floor(Math.random() * validMinions.length)];\r\n};\r\n\r\nexport const addStatsToBoard = (\r\n\tsourceEntity: BoardEntity | BgsPlayerEntity | BoardSecret,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tattack: number,\r\n\thealth: number,\r\n\tgameState: FullGameState,\r\n\ttribe?: string,\r\n\t// permanentUpgrade = false,\r\n): void => {\r\n\tfor (const entity of board) {\r\n\t\tif (!tribe || hasCorrectTribe(entity, Race[tribe], gameState.allCards)) {\r\n\t\t\tmodifyStats(entity, attack, health, board, hero, gameState);\r\n\t\t\tgameState.spectator?.registerPowerTarget(sourceEntity, entity, board, null, null);\r\n\t\t\t// if (permanentUpgrade) {\r\n\t\t\t// \tentity.permanentAttack = (entity.permanentAttack ?? 0) + attack;\r\n\t\t\t// \tentity.permanentHealth = (entity.permanentHealth ?? 0) + health;\r\n\t\t\t// }\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const grantStatsToMinionsOfEachType = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tattack: number,\r\n\thealth: number,\r\n\tgameState: FullGameState,\r\n\tnumberOfDifferentTypes = 99,\r\n\tcanRevive = true,\r\n): void => {\r\n\tconst minionsToBuff = getMinionsOfDifferentTypes(board, gameState, canRevive, numberOfDifferentTypes);\r\n\tfor (const entity of minionsToBuff) {\r\n\t\tmodifyStats(entity, attack, health, board, hero, gameState);\r\n\t\tgameState.spectator.registerPowerTarget(source, entity, board, null, null);\r\n\t}\r\n};\r\n\r\nexport const getMinionsOfDifferentTypes = (\r\n\tboard: BoardEntity[],\r\n\tgameState: FullGameState,\r\n\tcanRevive = true,\r\n\tnumberOfDifferentTypes = 99,\r\n): BoardEntity[] => {\r\n\tconst result: BoardEntity[] = [];\r\n\tif (board.length > 0) {\r\n\t\tlet boardCopy = board.filter((e) => !gameState.allCards.getCard(e.cardId).races?.includes(Race[Race.ALL]));\r\n\t\tconst allRaces = shuffleArray(ALL_BG_RACES);\r\n\t\tlet typesBuffed = 0;\r\n\t\tconst racesProcessed = [];\r\n\t\tfor (let i = 1; i <= 2; i++) {\r\n\t\t\tfor (const tribe of allRaces) {\r\n\t\t\t\tconst minionsWithRaces = boardCopy\r\n\t\t\t\t\t.filter((e) => gameState.allCards.getCard(e.cardId).races?.length === i)\r\n\t\t\t\t\t.filter((e) =>\r\n\t\t\t\t\t\tgameState.allCards.getCard(e.cardId).races.some((r) => !racesProcessed.includes(Race[r])),\r\n\t\t\t\t\t);\r\n\t\t\t\tif (typesBuffed >= numberOfDifferentTypes) {\r\n\t\t\t\t\treturn result;\r\n\t\t\t\t}\r\n\t\t\t\t// const tribeStr = Race[tribe];\r\n\t\t\t\t// const minionWithRevive = getRandomRevivableMinion(boardCopy, tribe, gameState.allCards);\r\n\t\t\t\t// const boardDebug = minionsWithRaces.map((e) => ({\r\n\t\t\t\t// \tname: gameState.allCards.getCard(e.cardId).name,\r\n\t\t\t\t// \traces: gameState.allCards.getCard(e.cardId).races?.join(','),\r\n\t\t\t\t// }));\r\n\t\t\t\tconst validMinion: BoardEntity = canRevive\r\n\t\t\t\t\t? getRandomRevivableMinion(minionsWithRaces, tribe, gameState.allCards)\r\n\t\t\t\t\t: getRandomAliveMinion(minionsWithRaces, tribe, gameState.allCards);\r\n\t\t\t\tif (validMinion) {\r\n\t\t\t\t\tresult.push(validMinion);\r\n\t\t\t\t\tboardCopy = boardCopy.filter((e) => e !== validMinion);\r\n\t\t\t\t\ttypesBuffed++;\r\n\t\t\t\t\tracesProcessed.push(tribe);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tresult.push(...board.filter((e) => gameState.allCards.getCard(e.cardId).races?.includes(Race[Race.ALL])));\r\n\t}\r\n\treturn result;\r\n};\r\n\r\nexport const hasMechanic = (card: ReferenceCard, mechanic: string): boolean => {\r\n\treturn card.mechanics?.includes(mechanic);\r\n};\r\n\r\nexport const hasCorrectTribe = (entity: BoardEntity, targetTribe: Race, allCards: AllCardsService): boolean => {\r\n\treturn isCorrectTribe(allCards.getCard(entity.cardId).races, targetTribe);\r\n};\r\n\r\nexport const isCorrectTribe = (cardRaces: readonly string[], targetTribe: Race): boolean => {\r\n\tif (!cardRaces?.length) {\r\n\t\treturn false;\r\n\t}\r\n\treturn cardRaces\r\n\t\t.map((cardRace) => getRaceEnum(cardRace))\r\n\t\t.some((raceEnum) => raceEnum === Race.ALL || raceEnum === targetTribe);\r\n};\r\n\r\nexport const getRaceEnum = (race: string): Race => {\r\n\treturn Race[race];\r\n};\r\n\r\nexport const addImpliedMechanics = (entity: BoardEntity, cardsData: CardsData): BoardEntity => {\r\n\tconst cleave = CLEAVE_IDS.indexOf(entity.cardId as CardIds) !== -1;\r\n\tconst cantAttack = CANT_ATTACK_IDS.indexOf(entity.cardId as CardIds) !== -1;\r\n\tentity.cleave = cleave;\r\n\tentity.cantAttack = cantAttack;\r\n\tentity.divineShield = entity.divineShield || entity.hadDivineShield;\r\n\tentity.immuneWhenAttackCharges =\r\n\t\tentity.cardId === CardIds.Warpwing_BG24_004 || entity.cardId === CardIds.Warpwing_BG24_004_G ? 99999 : null;\r\n\tentity.frenzyChargesLeft =\r\n\t\tentity.cardId === CardIds.BristlebackKnight_BG20_204_G\r\n\t\t\t? 2\r\n\t\t\t: entity.cardId === CardIds.BristlebackKnight_BG20_204\r\n\t\t\t? 1\r\n\t\t\t: 0;\r\n\t// It's not an issue adding a charge for entities without a special ability\r\n\tentity.abiityChargesLeft = [\r\n\t\tCardIds.MarineMatriarch_BG29_610,\r\n\t\tCardIds.MarineMatriarch_BG29_610_G,\r\n\t\tCardIds.SoftHeartedSiren_BG26_590,\r\n\t\tCardIds.SoftHeartedSiren_BG26_590_G,\r\n\t\tCardIds.LongJohnCopper_BG29_831,\r\n\t\tCardIds.LongJohnCopper_BG29_831_G,\r\n\t\tCardIds.BristlingBuffoon_BG29_160,\r\n\t\tCardIds.BristlingBuffoon_BG29_160_G,\r\n\t].includes(entity.cardId as CardIds)\r\n\t\t? 3\r\n\t\t: [\r\n\t\t\t\tCardIds.TransmutedBramblewitch_BG27_013_G,\r\n\t\t\t\tCardIds.Mannoroth_BG27_507_G,\r\n\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy_G,\r\n\t\t\t\tCardIds.MadMatador_BG28_404_G,\r\n\t\t\t\tCardIds.WingedChimera_BG29_844,\r\n\t\t\t\tCardIds.WingedChimera_BG29_844_G,\r\n\t\t ].includes(entity.cardId as CardIds)\r\n\t\t? 2\r\n\t\t: 1;\r\n\r\n\treturn setImplicitDataForEntity(entity, cardsData);\r\n};\r\n\r\nconst setImplicitDataForEntity = (entity: BoardEntity, cardsData: CardsData): BoardEntity => {\r\n\tentity.cardId = normalizeCardIdForSkin(entity.cardId);\r\n\tentity.maxHealth = Math.max(0, entity.health, entity.maxHealth);\r\n\tconst avengeValue = cardsData.avengeValue(entity.cardId);\r\n\tif (avengeValue > 0) {\r\n\t\tentity.avengeCurrent = avengeValue;\r\n\t\tentity.avengeDefault = avengeValue;\r\n\t}\r\n\treturn entity;\r\n};\r\n\r\nexport const normalizeCardIdForSkin = (cardId: string): string => {\r\n\tif (!cardId?.length) {\r\n\t\treturn cardId;\r\n\t}\r\n\tconst skinMatch = cardId.match(/(.*)_SKIN_.*/);\r\n\tif (skinMatch) {\r\n\t\treturn skinMatch[1];\r\n\t}\r\n\treturn cardId;\r\n};\r\n\r\nexport const stringifySimple = (board: readonly BoardEntity[], allCards: AllCardsService = null): string => {\r\n\treturn '[' + board.map((entity) => stringifySimpleCard(entity, allCards)).join(', ') + ']';\r\n};\r\n\r\nexport const stringifySimpleCard = (entity: BoardEntity, allCards: AllCardsService = null): string => {\r\n\treturn entity ? `${allCards?.getCard(entity.cardId)?.name ?? entity.cardId}/atk=${entity.attack}` : null;\r\n};\r\n\r\nexport const isFish = (entity: BoardEntity): boolean => {\r\n\treturn (\r\n\t\tentity.cardId.startsWith(CardIds.AvatarOfNzoth_FishOfNzothToken) ||\r\n\t\tentity.cardId.startsWith(CardIds.FishOfNzoth) ||\r\n\t\tentity.additionalCards?.includes(CardIds.DevourerOfSouls_BG_RLK_538)\r\n\t);\r\n};\r\n\r\nexport const isPilotedWhirlOTron = (entity: BoardEntity): boolean => {\r\n\treturn entity.cardId.startsWith(CardIds.PilotedWhirlOTron_BG21_HERO_030_Buddy);\r\n};\r\n\r\nexport const isGolden = (cardId: string, allCards: AllCardsService): boolean => {\r\n\treturn !!allCards.getCard(cardId).battlegroundsNormalDbfId;\r\n};\r\n\r\nexport const getPlayerState = (gameState: GameState, hero: BgsPlayerEntity): PlayerState => {\r\n\treturn gameState.player.player === hero\r\n\t\t? gameState.player\r\n\t\t: gameState.player.teammate?.player === hero\r\n\t\t? gameState.player.teammate\r\n\t\t: gameState.opponent.player === hero\r\n\t\t? gameState.opponent\r\n\t\t: gameState.opponent.teammate?.player === hero\r\n\t\t? gameState.opponent.teammate\r\n\t\t: null;\r\n};\r\n\r\nexport const getTeammateInitialState = (gameState: GameState, hero: BgsPlayerEntity): PlayerState => {\r\n\treturn gameState.playerInitial.player?.entityId === hero?.entityId\r\n\t\t? gameState.playerInitial.teammate\r\n\t\t: gameState.playerInitial.teammate?.player?.entityId === hero?.entityId\r\n\t\t? gameState.playerInitial\r\n\t\t: gameState.opponentInitial.player?.entityId === hero?.entityId\r\n\t\t? gameState.opponentInitial.teammate\r\n\t\t: gameState.opponentInitial.teammate?.player?.entityId === hero?.entityId\r\n\t\t? gameState.opponentInitial\r\n\t\t: null;\r\n};\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestone-hs/simulate-bgs-battle",
3
- "version": "1.1.460",
3
+ "version": "1.1.461",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "lint": "eslint --color --fix --ext .ts .",