@firestone-hs/simulate-bgs-battle 1.1.472 → 1.1.474
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.
- package/README.md +5 -6
- package/dist/bgs-player-entity.d.ts +1 -1
- package/dist/bgs-player-entity.js.map +1 -1
- package/dist/input-sanitation.js +12 -6
- package/dist/input-sanitation.js.map +1 -1
- package/dist/simulation/attack.js +1 -1
- package/dist/simulation/attack.js.map +1 -1
- package/dist/simulation/on-being-attacked.js +1 -1
- package/dist/simulation/on-being-attacked.js.map +1 -1
- package/dist/simulation/spectator/game-action.js +27 -13
- package/dist/simulation/spectator/game-action.js.map +1 -1
- package/dist/simulation/start-of-combat.js +5 -5
- package/dist/simulation/start-of-combat.js.map +1 -1
- package/dist/simulation/stats.js +5 -5
- package/dist/simulation/stats.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-of-combat.js","sourceRoot":"","sources":["../../src/simulation/start-of-combat.ts"],"names":[],"mappings":";;;AACA,iEAAsG;AAGtG,oDAA0F;AAC1F,6CAAqF;AACrF,oCAUkB;AAClB,+DAA4D;AAC5D,qCAQkB;AAClB,mDAAiD;AACjD,+DAM+B;AAC/B,2EAAiE;AACjE,6DAAqD;AAErD,qCAA+C;AAE/C,mCAA6E;AAC7E,2DAA6D;AAC7D,2CAAkD;AAS3C,MAAM,mBAAmB,GAAG,CAClC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IACX,IAAA,0CAAsB,EAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;IAC5F,MAAM,8BAA8B,GAAG,IAAI,CAAC;IAC5C,IAAI,8BAA8B,EAAE;QACnC,eAAe;YACd,WAAW,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM;gBACxC,CAAC,CAAC,CAAC;g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AU,CAAC;IACtC,SAAS,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAClE,CAAC,CAAC;AAEF,MAAM,4BAA4B,GAAG,CAAC,MAAmB,EAA6C,EAAE;IACvG,MAAM,aAAa,GAAkD,CAAC,OAAO,CAAC,CAAC;IAC/E,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;QACnB,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KAC7B;IACD,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;QACrB,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;KAC/B;IACD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;QAClB,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KAC5B;IACD,OAAO,IAAA,kBAAU,EAAC,aAAa,CAAC,CAAC;AAClC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { ALL_BG_RACES, AllCardsService, CardIds, CardType, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { grantDivineShieldToLeftmostMinions, updateDivineShield } from '../divine-shield';\r\nimport { pickRandom, pickRandomLowestHealth, shuffleArray } from '../services/utils';\r\nimport {\r\n\taddImpliedMechanics,\r\n\taddStatsToBoard,\r\n\tcopyEntity,\r\n\tgetEffectiveTribesForEntity,\r\n\tgetMinionsOfDifferentTypes,\r\n\tgetRandomMinionWithHighestHealth,\r\n\tgetTeammateInitialState,\r\n\thasCorrectTribe,\r\n\tisGolden,\r\n} from '../utils';\r\nimport { removeAurasFromSelf } from './add-minion-to-board';\r\nimport {\r\n\tdealDamageToMinion,\r\n\tdealDamageToRandomEnemy,\r\n\tdoFullAttack,\r\n\tfindNearestEnemies,\r\n\tgetNeighbours,\r\n\tprocessMinionDeath,\r\n\tsimulateAttack,\r\n} from './attack';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport {\r\n\tapplyEarthInvocationEnchantment,\r\n\tapplyFireInvocationEnchantment,\r\n\tapplyLightningInvocationEnchantment,\r\n\tapplyWaterInvocationEnchantment,\r\n\trememberDeathrattles,\r\n} from './deathrattle-effects';\r\nimport { handleDeathrattles } from './deathrattle-orchestration';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { performEntitySpawns } from './spawns';\r\nimport { Spectator } from './spectator/spectator';\r\nimport { applyAfterStatsUpdate, modifyStats, setEntityStats } from './stats';\r\nimport { handleSummonsWhenSpace } from './summon-when-space';\r\nimport { makeMinionGolden } from './utils/golden';\r\n\r\n// TODO 20/04/2024: I'm not too sure about some ordering. The way I understand it, the Start of Combat has\r\n// multiple phases, and in each phase the player order is random\r\n// However, looking at http://replays.firestoneapp.com/?reviewId=a577602e-06f3-4c4b-928d-36ea98c2e6d5&turn=5&action=0,\r\n// it feels that a \"start of combat\" minion effect could trigger before an opponent's hero power effect\r\n// Or is that limited to Bru'kan?\r\n// I feel that I've asked a lot of questions recently, so I don't want to add that one to the list, as the interaction\r\n// is for now pretty marginal\r\nexport const handleStartOfCombat = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\tconst shouldRecomputeCurrentAttacker = true;\r\n\tif (shouldRecomputeCurrentAttacker) {\r\n\t\tcurrentAttacker =\r\n\t\t\tplayerBoard.length > opponentBoard.length\r\n\t\t\t\t? 0\r\n\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t? 1\r\n\t\t\t\t: Math.round(Math.random());\r\n\t}\r\n\r\n\t// https://twitter.com/DCalkosz/status/1564705111850434561\r\n\tcurrentAttacker = handleStartOfCombatQuestRewards(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t);\r\n\tcurrentAttacker = handleStartOfCombatAnomalies(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t);\r\n\t// https://twitter.com/DCalkosz/status/1488361384320528388?s=20&t=1ECxRZFdjqwEa2fRsXk32Q\r\n\t// There’s a certain order for Start of Combat hero powers, rather than “coin flips” where\r\n\t// an unlucky trigger order could mess up some positioning you had planned for your own hero\r\n\t// power. “Precombat” (Al’Akir, Y’Shaarj), then Illidan, then others.\r\n\t// Update: this seems to have changed: https://x.com/LoewenMitchell/status/1737588920139825335?s=20\r\n\t// now you have all hero powers trigger in a first phase, then you have Illidan, and once everything has triggered, you have Tavish\r\n\tcurrentAttacker = handlePreCombatHeroPowers(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t);\r\n\t// Because start of combat powers like Red Whelp's use the board composition before Illidan's strike to know the amount of damage\r\n\tconst playerBoardBefore = playerBoard.map((e) => ({ ...e }));\r\n\tconst opponentBoardBefore = opponentBoard.map((e) => ({ ...e }));\r\n\tcurrentAttacker = handleIllidanHeroPowers(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t);\r\n\tcurrentAttacker = handleStartOfCombatHeroPowers(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t);\r\n\t// Timing confirmed by Mitchell on Discord on 2024-02-21\r\n\tcurrentAttacker = handleStartOfCombatSpells(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t);\r\n\t// Not sure if this can change who the first player will be\r\n\t// I don't have any official source on it at the moment, but there are some simulation\r\n\thandleStartOfCombatMinions(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tplayerBoardBefore,\r\n\t\topponentBoardBefore,\r\n\t\tgameState,\r\n\t);\r\n\tplayerEntity.startOfCombatDone = true;\r\n\topponentEntity.startOfCombatDone = true;\r\n\tapplyAfterStatsUpdate(gameState);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePreCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t} else {\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePreCombatHeroPowersForPlayer = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tif (playerEntity.startOfCombatDone || playerEntity.hpLeft <= 0) {\r\n\t\treturn currentAttacker;\r\n\t}\r\n\r\n\tlet shouldRecomputeCurrentAttacker = false;\r\n\t// Some are part of the incoming board: Y'Shaarj, Lich King, Ozumat\r\n\t// Since the order is not important here, we just always do the player first\r\n\tconst playerHeroPowerId = playerEntity.heroPowerId || getHeroPowerForHero(playerEntity.cardId);\r\n\tif (playerHeroPowerId === CardIds.SwattingInsects && playerBoard.length > 0) {\r\n\t\t// Should be sent by the app, but it is an idempotent operation, so we can just reapply it here\r\n\t\thandleAlakirForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.EarthInvocationToken) {\r\n\t\tapplyEarthInvocationEnchantment(playerBoard, null, playerEntity, gameState);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.WaterInvocationToken) {\r\n\t\tapplyWaterInvocationEnchantment(playerBoard, playerEntity, null, playerEntity, gameState);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.FireInvocationToken) {\r\n\t\tapplyFireInvocationEnchantment(playerBoard, playerEntity, null, playerEntity, gameState);\r\n\t} else if (playerHeroPowerId === CardIds.AllWillBurn) {\r\n\t\tapplyAllWillBurn(playerBoard, playerEntity, opponentBoard, opponentEntity, playerEntity, gameState);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.TamsinRoame_FragrantPhylactery) {\r\n\t\thandleTamsinForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t// Tamsin's hero power somehow happens before the current attacker is chosen.\r\n\t\t// See http://replays.firestoneapp.com/?reviewId=bce94e6b-c807-48e4-9c72-2c5c04421213&turn=6&action=9\r\n\t\t// Even worse: if a scallywag token pops, it attacks before the first attacker is recomputed\r\n\t\tshouldRecomputeCurrentAttacker = true;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.EmbraceYourRage) {\r\n\t\thandleEmbraceYourRageForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\tshouldRecomputeCurrentAttacker = true;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.RebornRites) {\r\n\t\thandleRebornRitesForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.TeronGorefiend_RapidReanimation) {\r\n\t\tshouldRecomputeCurrentAttacker = handleTeronForPlayer(\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\t// Same as Tamsin? No, because the new minion should repop automatically\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.WaxWarband) {\r\n\t\thandleWaxWarbandForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.LightningInvocationToken) {\r\n\t\tapplyLightningInvocationEnchantment(playerBoard, playerEntity, null, opponentBoard, opponentEntity, gameState);\r\n\t} else if (\r\n\t\tplayerEntity.heroPowerUsed &&\r\n\t\tplayerHeroPowerId === CardIds.FlobbidinousFloop_GloriousGloop_BGDUO_HERO_101p\r\n\t) {\r\n\t\tapplyGloriousGloop(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t}\r\n\r\n\tprocessMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\tif (shouldRecomputeCurrentAttacker) {\r\n\t\tcurrentAttacker =\r\n\t\t\tplayerBoard.length > opponentBoard.length\r\n\t\t\t\t? friendly\r\n\t\t\t\t\t? 0\r\n\t\t\t\t\t: 1\r\n\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t? friendly\r\n\t\t\t\t\t? 1\r\n\t\t\t\t\t: 0\r\n\t\t\t\t: Math.round(Math.random());\r\n\t}\r\n\r\n\treturn currentAttacker;\r\n};\r\n\r\nexport const handleIllidanHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\t// console.log('current attacker before', currentAttacker);\r\n\t// Apparently it's a toin coss about whether to handle Illidan first or Al'Akir first\r\n\t// Auras are only relevant for Illidan, and already applied there\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t} else {\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\tprocessMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatMinions = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tplayerBoardBefore: BoardEntity[],\r\n\topponentBoardBefore: BoardEntity[],\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tlet attackerForStart = Math.random() < 0.5 ? 0 : 1;\r\n\tconst playerAttackers = [...playerBoard];\r\n\tconst opponentAttackers = [...opponentBoard];\r\n\r\n\twhile (playerAttackers.length > 0 || opponentAttackers.length > 0) {\r\n\t\tlet shouldUpdateNextPlayer = false;\r\n\t\tif (attackerForStart === 0 && playerAttackers.length > 0) {\r\n\t\t\tconst attacker = playerAttackers.splice(0, 1)[0];\r\n\t\t\tif (attacker.health <= 0 || attacker.definitelyDead) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tshouldUpdateNextPlayer = performStartOfCombatMinionsForPlayer(\r\n\t\t\t\tattacker,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tplayerBoardBefore,\r\n\t\t\t\topponentBoardBefore,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t} else if (attackerForStart === 0 && playerAttackers.length === 0) {\r\n\t\t\tshouldUpdateNextPlayer = true;\r\n\t\t} else if (attackerForStart === 1 && opponentAttackers.length > 0) {\r\n\t\t\tconst attacker = opponentAttackers.splice(0, 1)[0];\r\n\t\t\tif (attacker.health <= 0 || attacker.definitelyDead) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tshouldUpdateNextPlayer = performStartOfCombatMinionsForPlayer(\r\n\t\t\t\tattacker,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoardBefore,\r\n\t\t\t\tplayerBoardBefore,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t} else if (attackerForStart === 1 && opponentAttackers.length === 0) {\r\n\t\t\tshouldUpdateNextPlayer = true;\r\n\t\t}\r\n\r\n\t\tif (shouldUpdateNextPlayer) {\r\n\t\t\tattackerForStart = (attackerForStart + 1) % 2;\r\n\t\t}\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatQuestRewards = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handleStartOfCombatQuestRewardsForPlayer(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t\tcurrentAttacker = handleStartOfCombatQuestRewardsForPlayer(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t\tfalse,\r\n\t\t);\r\n\t} else {\r\n\t\tcurrentAttacker = handleStartOfCombatQuestRewardsForPlayer(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t\tfalse,\r\n\t\t);\r\n\t\tcurrentAttacker = handleStartOfCombatQuestRewardsForPlayer(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t}\r\n\r\n\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatSpells = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handleStartOfCombatSpellsForPlayer(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tcurrentAttacker = handleStartOfCombatSpellsForPlayer(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t} else {\r\n\t\tcurrentAttacker = handleStartOfCombatSpellsForPlayer(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tcurrentAttacker = handleStartOfCombatSpellsForPlayer(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatAnomalies = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tcurrentAttacker = handleStartOfCombatAnomaliesForPlayer(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t);\r\n\tcurrentAttacker = handleStartOfCombatAnomaliesForPlayer(\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t);\r\n\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatQuestRewardsForPlayer = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n\tplayerIsFriendly: boolean,\r\n): number => {\r\n\tif (playerEntity.startOfCombatDone) {\r\n\t\treturn currentAttacker;\r\n\t}\r\n\r\n\tfor (const trinket of playerEntity.trinkets) {\r\n\t\tswitch (trinket.cardId) {\r\n\t\t\tcase CardIds.HolyMallet_BG30_MagicItem_902:\r\n\t\t\t\tif (playerBoard.length > 0) {\r\n\t\t\t\t\tupdateDivineShield(playerBoard[0], playerBoard, playerEntity, opponentEntity, true, gameState);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(playerEntity, playerBoard[0], playerBoard, null, null);\r\n\t\t\t\t\tif (playerBoard.length > 1) {\r\n\t\t\t\t\t\tupdateDivineShield(playerBoard[1], playerBoard, playerEntity, opponentEntity, true, gameState);\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(playerEntity, playerBoard[1], playerBoard, null, null);\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.TrainingCertificate_BG30_MagicItem_962:\r\n\t\t\t\tif (playerBoard.length > 0) {\r\n\t\t\t\t\tconst minionsByAttack = [...playerBoard].sort((a, b) => a.attack - b.attack);\r\n\t\t\t\t\tconst firstTarget = minionsByAttack[0];\r\n\t\t\t\t\tsetEntityStats(\r\n\t\t\t\t\t\tfirstTarget,\r\n\t\t\t\t\t\t2 * firstTarget.maxAttack,\r\n\t\t\t\t\t\t2 * firstTarget.maxHealth,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (playerBoard.length > 1) {\r\n\t\t\t\t\t\tconst secondTarget = minionsByAttack[1];\r\n\t\t\t\t\t\tsetEntityStats(\r\n\t\t\t\t\t\t\tsecondTarget,\r\n\t\t\t\t\t\t\t2 * secondTarget.maxAttack,\r\n\t\t\t\t\t\t\t2 * secondTarget.maxHealth,\r\n\t\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\t\tplayerEntity,\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}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ValorousMedallion_BG30_MagicItem_970:\r\n\t\t\tcase CardIds.ValorousMedallion_ValorousMedallionToken_BG30_MagicItem_970t:\r\n\t\t\t\tconst medallionBuff = trinket.cardId === CardIds.ValorousMedallion_BG30_MagicItem_970 ? 2 : 5;\r\n\t\t\t\taddStatsToBoard(trinket, playerBoard, playerEntity, medallionBuff, medallionBuff, gameState);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.EmeraldDreamcatcher_BG30_MagicItem_542:\r\n\t\t\t\tconst highestAttack = Math.max(...playerBoard.map((entity) => entity.attack));\r\n\t\t\t\tplayerBoard\r\n\t\t\t\t\t.filter((e) => hasCorrectTribe(e, playerEntity, Race.DRAGON, gameState.allCards))\r\n\t\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\t\tsetEntityStats(e, highestAttack, null, playerBoard, playerEntity, gameState);\r\n\t\t\t\t\t});\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.JarredFrostling_BG30_MagicItem_952:\r\n\t\t\t\tconst elementals = shuffleArray(\r\n\t\t\t\t\tplayerBoard.filter((e) => hasCorrectTribe(e, playerEntity, Race.ELEMENTAL, gameState.allCards)),\r\n\t\t\t\t);\r\n\t\t\t\tconst targets = elementals.slice(0, 2);\r\n\t\t\t\ttargets.forEach((e) => {\r\n\t\t\t\t\te.enchantments = e.enchantments ?? [];\r\n\t\t\t\t\te.enchantments.push({\r\n\t\t\t\t\t\tcardId: CardIds.JarredFrostling_FrostyGlobeEnchantment_BG30_MagicItem_952e,\r\n\t\t\t\t\t\toriginEntityId: trinket.entityId,\r\n\t\t\t\t\t\trepeats: 1,\r\n\t\t\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t\t\t});\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(playerEntity, e, playerBoard, null, null);\r\n\t\t\t\t});\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.RustyTrident_BG30_MagicItem_917:\r\n\t\t\t\tplayerBoard\r\n\t\t\t\t\t.filter((e) => hasCorrectTribe(e, playerEntity, Race.NAGA, gameState.allCards))\r\n\t\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\t\te.enchantments = e.enchantments ?? [];\r\n\t\t\t\t\t\te.enchantments.push({\r\n\t\t\t\t\t\t\tcardId: CardIds.RustyTrident_TridentsTreasureEnchantment_BG30_MagicItem_917e,\r\n\t\t\t\t\t\t\toriginEntityId: trinket.entityId,\r\n\t\t\t\t\t\t\trepeats: 1,\r\n\t\t\t\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t});\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.HoggyBank_BG30_MagicItem_411:\r\n\t\t\t\tplayerBoard\r\n\t\t\t\t\t.filter((e) => hasCorrectTribe(e, playerEntity, Race.QUILBOAR, gameState.allCards))\r\n\t\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\t\te.enchantments = e.enchantments ?? [];\r\n\t\t\t\t\t\te.enchantments.push({\r\n\t\t\t\t\t\t\tcardId: CardIds.HoggyBank_GemInTheBankEnchantment_BG30_MagicItem_411e,\r\n\t\t\t\t\t\t\toriginEntityId: trinket.entityId,\r\n\t\t\t\t\t\t\trepeats: 1,\r\n\t\t\t\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t});\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.AutomatonPortrait_BG30_MagicItem_303:\r\n\t\t\t\tif (playerBoard.length < 7) {\r\n\t\t\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\t\t\tCardIds.AstralAutomaton_BG_TTN_401,\r\n\t\t\t\t\t\t1,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tperformEntitySpawns(\r\n\t\t\t\t\t\tnewMinions,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\t0,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState,\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.ShipInABottle_BG30_MagicItem_407:\r\n\t\t\t\tif (playerBoard.length < 7) {\r\n\t\t\t\t\tconst target = pickRandom(gameState.cardsData.pirateSpawns);\r\n\t\t\t\t\taddCardsInHand(playerEntity, playerBoard, [target], gameState);\r\n\t\t\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t1,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tconst spawns = performEntitySpawns(\r\n\t\t\t\t\t\tnewMinions,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\t0,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tspawns.forEach((spawn) => (spawn.attackImmediately = true));\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.EternalPortrait_BG30_MagicItem_301:\r\n\t\t\t\tplayerBoard\r\n\t\t\t\t\t.filter(\r\n\t\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\t\te.cardId === CardIds.EternalKnight_BG25_008 ||\r\n\t\t\t\t\t\t\te.cardId === CardIds.EternalKnight_BG25_008_G,\r\n\t\t\t\t\t)\r\n\t\t\t\t\t.forEach((knight) => {\r\n\t\t\t\t\t\tknight.taunt = true;\r\n\t\t\t\t\t\tknight.reborn = true;\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(playerEntity, knight, playerBoard, null, null);\r\n\t\t\t\t\t});\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.TwinSkyLanterns_BG30_MagicItem_822:\r\n\t\t\tcase CardIds.TwinSkyLanterns_TwinSkyLanternsToken_BG30_MagicItem_822t2:\r\n\t\t\t\ttrinket.rememberedMinion = null;\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ArtisanalUrn_BG30_MagicItem_989:\r\n\t\t\tcase CardIds.ArtisanalUrn_ArtisanalUrnToken_BG30_MagicItem_989t:\r\n\t\t\t\tconst artisanalUrnBuff = trinket.cardId === CardIds.ArtisanalUrn_BG30_MagicItem_989 ? 3 : 7;\r\n\t\t\t\tplayerEntity.globalInfo.UndeadAttackBonus =\r\n\t\t\t\t\t(playerEntity.globalInfo.UndeadAttackBonus ?? 0) + artisanalUrnBuff;\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.RivendarePortrait_BG30_MagicItem_310:\r\n\t\t\t\tplayerBoard\r\n\t\t\t\t\t.filter(\r\n\t\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\t\te.cardId === CardIds.TitusRivendare_BG25_354 ||\r\n\t\t\t\t\t\t\te.cardId === CardIds.TitusRivendare_BG25_354_G,\r\n\t\t\t\t\t)\r\n\t\t\t\t\t.forEach((e) => (e.stealth = true));\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.TinyfinOnesie_BG30_MagicItem_441:\r\n\t\t\t\tconst highestHealthMinionInHand = playerEntity.hand?.sort((a, b) => b.health - a.health)[0];\r\n\t\t\t\tif (highestHealthMinionInHand && playerBoard.length > 0) {\r\n\t\t\t\t\tmodifyStats(\r\n\t\t\t\t\t\tplayerBoard[0],\r\n\t\t\t\t\t\thighestHealthMinionInHand.attack,\r\n\t\t\t\t\t\thighestHealthMinionInHand.health,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\tgameState,\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.BronzeTimepiece_BG30_MagicItem_995:\r\n\t\t\t\tif (playerBoard.length > 0) {\r\n\t\t\t\t\tplayerBoard.forEach((entity) => {\r\n\t\t\t\t\t\tconst highest = Math.max(entity.attack, entity.health);\r\n\t\t\t\t\t\tsetEntityStats(entity, highest, highest, playerBoard, playerEntity, gameState);\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(trinket, entity, playerBoard, null, null);\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.IronforgeAnvil_BG30_MagicItem_403:\r\n\t\t\t\tif (playerBoard.length > 0) {\r\n\t\t\t\t\tplayerBoard\r\n\t\t\t\t\t\t.filter((e) => getEffectiveTribesForEntity(e, playerEntity, gameState.allCards).length === 0)\r\n\t\t\t\t\t\t.forEach((entity) => {\r\n\t\t\t\t\t\t\tsetEntityStats(\r\n\t\t\t\t\t\t\t\tentity,\r\n\t\t\t\t\t\t\t\t3 * entity.attack,\r\n\t\t\t\t\t\t\t\t3 * entity.health,\r\n\t\t\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\t\t\tplayerEntity,\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(trinket, entity, playerBoard, null, null);\r\n\t\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.KarazhanChessSet_BG30_MagicItem_972:\r\n\t\t\t\tif (playerBoard.length > 0) {\r\n\t\t\t\t\tfor (let i = 0; i < Math.min(playerBoard.length, 7); i++) {\r\n\t\t\t\t\t\tconst entityToCoy = playerBoard[i];\r\n\t\t\t\t\t\tconst copy: BoardEntity = copyEntity(entityToCoy);\r\n\t\t\t\t\t\tremoveAurasFromSelf(copy, playerBoard, playerEntity, gameState);\r\n\t\t\t\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\t\t\t\tcopy.cardId,\r\n\t\t\t\t\t\t\t1,\r\n\t\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\t\tcopy,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tconst spawns = performEntitySpawns(\r\n\t\t\t\t\t\t\tnewMinions,\r\n\t\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\t\tplayerBoard.length - i - 1,\r\n\t\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\t\topponentEntity,\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// TODO: according to http://replays.firestoneapp.com/?reviewId=576aa3bb-caa1-4e46-9d16-08a001fdd941&turn=23&action=3\r\n\t\t\t\t\t\t// it looks like the stats are simply copied from the original entity to the copy, instead\r\n\t\t\t\t\t\t// of summoning a copy and applying all the auras stuff\r\n\t\t\t\t\t\t// I've asked on Discord (2024-08-21) for clarification\r\n\t\t\t\t\t\ti += spawns.length;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tcurrentAttacker =\r\n\t\t\t\t\tplayerBoard.length > opponentBoard.length\r\n\t\t\t\t\t\t? playerIsFriendly\r\n\t\t\t\t\t\t\t? 0\r\n\t\t\t\t\t\t\t: 1\r\n\t\t\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t\t\t? playerIsFriendly\r\n\t\t\t\t\t\t\t? 1\r\n\t\t\t\t\t\t\t: 0\r\n\t\t\t\t\t\t: Math.round(Math.random());\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.FishySticker_BG30_MagicItem_821:\r\n\t\t\tcase CardIds.FishySticker_FishyStickerToken_BG30_MagicItem_821t2:\r\n\t\t\t\tif (playerBoard.length < 7) {\r\n\t\t\t\t\tconst spawnId =\r\n\t\t\t\t\t\ttrinket.cardId === CardIds.FishySticker_BG30_MagicItem_821\r\n\t\t\t\t\t\t\t? CardIds.AvatarOfNzoth_FishOfNzothToken\r\n\t\t\t\t\t\t\t: CardIds.FishOfNzoth;\r\n\t\t\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\t\t\tspawnId,\r\n\t\t\t\t\t\t1,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tconst spawns = performEntitySpawns(\r\n\t\t\t\t\t\tnewMinions,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\t0,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tcurrentAttacker =\r\n\t\t\t\t\t\tplayerBoard.length > opponentBoard.length\r\n\t\t\t\t\t\t\t? playerIsFriendly\r\n\t\t\t\t\t\t\t\t? 0\r\n\t\t\t\t\t\t\t\t: 1\r\n\t\t\t\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t\t\t\t? playerIsFriendly\r\n\t\t\t\t\t\t\t\t? 1\r\n\t\t\t\t\t\t\t\t: 0\r\n\t\t\t\t\t\t\t: Math.round(Math.random());\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const reward of playerEntity.questRewards) {\r\n\t\tswitch (reward) {\r\n\t\t\tcase CardIds.EvilTwin:\r\n\t\t\t\tif (!!playerBoard.length && playerBoard.length < 7) {\r\n\t\t\t\t\tconst highestHealthMinion = [...playerBoard].sort((a, b) => b.health - a.health)[0];\r\n\t\t\t\t\tconst copy: BoardEntity = {\r\n\t\t\t\t\t\t...highestHealthMinion,\r\n\t\t\t\t\t\tlastAffectedByEntity: null,\r\n\t\t\t\t\t};\r\n\t\t\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\t\t\tcopy.cardId,\r\n\t\t\t\t\t\t1,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\t\thighestHealthMinion.friendly,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\tcopy,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tconst indexFromRight = playerBoard.length - (playerBoard.indexOf(highestHealthMinion) + 1);\r\n\t\t\t\t\tperformEntitySpawns(\r\n\t\t\t\t\t\tnewMinions,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\thighestHealthMinion,\r\n\t\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(playerEntity, copy, playerBoard, null, null);\r\n\t\t\t\t\t// Recompute first attacker\r\n\t\t\t\t\t// See https://replays.firestoneapp.com/?reviewId=93229c4a-d864-4196-83dd-2fea2a5bf70a&turn=29&action=0\r\n\t\t\t\t\tcurrentAttacker =\r\n\t\t\t\t\t\tplayerBoard.length > opponentBoard.length\r\n\t\t\t\t\t\t\t? playerIsFriendly\r\n\t\t\t\t\t\t\t\t? 0\r\n\t\t\t\t\t\t\t\t: 1\r\n\t\t\t\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t\t\t\t? playerIsFriendly\r\n\t\t\t\t\t\t\t\t? 1\r\n\t\t\t\t\t\t\t\t: 0\r\n\t\t\t\t\t\t\t: Math.round(Math.random());\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.StaffOfOrigination_BG24_Reward_312:\r\n\t\t\t\tplayerBoard.forEach((entity) => {\r\n\t\t\t\t\tmodifyStats(entity, 15, 15, playerBoard, playerEntity, gameState);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(playerEntity, entity, playerBoard, null, null);\r\n\t\t\t\t});\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.StolenGold:\r\n\t\t\t\tif (playerBoard.length > 0) {\r\n\t\t\t\t\tmakeMinionGolden(\r\n\t\t\t\t\t\tplayerBoard[0],\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tif (playerBoard.length > 1) {\r\n\t\t\t\t\tmakeMinionGolden(\r\n\t\t\t\t\t\tplayerBoard[playerBoard.length - 1],\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatSpellsForPlayer = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tif (playerEntity.startOfCombatDone) {\r\n\t\treturn currentAttacker;\r\n\t}\r\n\tif (!playerEntity.secrets?.length) {\r\n\t\treturn currentAttacker;\r\n\t}\r\n\tfor (const secret of playerEntity.secrets) {\r\n\t\tswitch (secret.cardId) {\r\n\t\t\tcase CardIds.UpperHand_BG28_573:\r\n\t\t\t\tif (!!opponentBoard.length) {\r\n\t\t\t\t\tconst target = pickRandom(opponentBoard);\r\n\t\t\t\t\ttarget.health = 1;\r\n\t\t\t\t\ttarget.maxHealth = 1;\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(playerEntity, target, opponentBoard, null, null);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.BoonOfBeetles_BG28_603:\r\n\t\t\t\tsecret.scriptDataNum1 = secret.scriptDataNum1 ?? 1;\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.FleetingVigor_BG28_519:\r\n\t\t\t\taddStatsToBoard(secret, playerBoard, playerEntity, 2, 1, gameState);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ToxicTumbleweed_BG28_641:\r\n\t\t\t\tif (playerBoard.length < 7) {\r\n\t\t\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\t\t\tCardIds.ToxicTumbleweed_TumblingAssassinToken_BG28_641t,\r\n\t\t\t\t\t\t1,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tnewMinions[0].attackImmediately = true;\r\n\t\t\t\t\tperformEntitySpawns(\r\n\t\t\t\t\t\tnewMinions,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\t0,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatAnomaliesForPlayer = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tif (!gameState.anomalies?.length || playerEntity.startOfCombatDone) {\r\n\t\treturn currentAttacker;\r\n\t}\r\n\tfor (const anomaly of gameState.anomalies) {\r\n\t\tswitch (anomaly) {\r\n\t\t\tcase CardIds.BlessedOrBlighted_BG27_Anomaly_726:\r\n\t\t\t\tif (playerBoard.length > 0) {\r\n\t\t\t\t\tconst dsTarget = playerBoard[0];\r\n\t\t\t\t\tupdateDivineShield(dsTarget, playerBoard, playerEntity, opponentEntity, true, gameState);\r\n\t\t\t\t\tconst rebornTarget = playerBoard[playerBoard.length - 1];\r\n\t\t\t\t\trebornTarget.reborn = true;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.AnomalousTwin_BG27_Anomaly_560:\r\n\t\t\t\tif (!!playerBoard.length && playerBoard.length < 7) {\r\n\t\t\t\t\tconst highestHealthMinion = [...playerBoard].sort((a, b) => b.health - a.health)[0];\r\n\t\t\t\t\tconst copy: BoardEntity = {\r\n\t\t\t\t\t\t...highestHealthMinion,\r\n\t\t\t\t\t\tlastAffectedByEntity: null,\r\n\t\t\t\t\t};\r\n\t\t\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\t\t\tcopy.cardId,\r\n\t\t\t\t\t\t1,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\t\thighestHealthMinion.friendly,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\tcopy,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tconst indexFromRight = playerBoard.length - (playerBoard.indexOf(highestHealthMinion) + 1);\r\n\t\t\t\t\tperformEntitySpawns(\r\n\t\t\t\t\t\tnewMinions,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\thighestHealthMinion,\r\n\t\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(playerEntity, copy, playerBoard, null, null);\r\n\t\t\t\t}\r\n\t\t\t\t// Recompute first attacker\r\n\t\t\t\t// See https://replays.firestoneapp.com/?reviewId=93229c4a-d864-4196-83dd-2fea2a5bf70a&turn=29&action=0\r\n\t\t\t\treturn playerBoard.length > opponentBoard.length\r\n\t\t\t\t\t? 0\r\n\t\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t\t? 1\r\n\t\t\t\t\t: Math.round(Math.random());\r\n\t\t}\r\n\t}\r\n\r\n\treturn currentAttacker;\r\n};\r\n\r\nexport const handleStartOfCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\t// Apparently it's a toin coss about whether to handle Illidan first or Al'Akir first\r\n\t// Auras are only relevant for Illidan, and already applied there\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t} else {\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePlayerIllidanHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tif (playerEntity.hpLeft <= 0) {\r\n\t\treturn currentAttacker;\r\n\t}\r\n\tconst playerHeroPowerId = playerEntity.heroPowerId || getHeroPowerForHero(playerEntity.cardId);\r\n\tif (playerHeroPowerId === CardIds.Wingmen && playerBoard.length > 0) {\r\n\t\t// After Illidan triggers, it's always the other opponent's turn\r\n\t\t// https://x.com/LoewenMitchell/status/1752714583360639131?s=20\r\n\t\thandleIllidanForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState, currentAttacker);\r\n\t\tcurrentAttacker = friendly ? 1 : 0;\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\n// TODO: not exactly correct, because of \"attack immediately\", but it's close enough\r\nconst handleIllidanForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tcurrentAttacker: number,\r\n): void => {\r\n\tif (playerEntity.startOfCombatDone) {\r\n\t\treturn;\r\n\t}\r\n\t// Otherwise, if the first minion dies on the attack, and the board has only 2 minions, we\r\n\t// miss the second one\r\n\tconst minionsAtStart = playerBoard.length;\r\n\tconst firstAttacker = playerBoard[0];\r\n\tconst secondAttacker = minionsAtStart > 1 ? playerBoard[playerBoard.length - 1] : null;\r\n\r\n\t// Stats updates\r\n\tmodifyStats(firstAttacker, 2, 1, playerBoard, playerEntity, gameState);\r\n\tgameState.spectator.registerPowerTarget(firstAttacker, firstAttacker, playerBoard, playerEntity, opponentEntity);\r\n\tif (!!secondAttacker && !secondAttacker.definitelyDead && secondAttacker.health > 0) {\r\n\t\tmodifyStats(secondAttacker, 2, 1, playerBoard, playerEntity, gameState);\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tsecondAttacker,\r\n\t\t\tsecondAttacker,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentEntity,\r\n\t\t);\r\n\t}\r\n\r\n\t// Attacks\r\n\tfirstAttacker.attackImmediately = true;\r\n\tsimulateAttack(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t// See http://replays.firestoneapp.com/?reviewId=f16b7a49-c2a2-4ac5-a9eb-a75f83246f70&turn=6&action=8\r\n\tfirstAttacker.hasAttacked = 0;\r\n\tif (!!secondAttacker && !secondAttacker.definitelyDead && secondAttacker.health > 0) {\r\n\t\tsecondAttacker.attackImmediately = true;\r\n\t\tsimulateAttack(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\tsecondAttacker.hasAttacked = 0;\r\n\t}\r\n\r\n\t// // See http://replays.firestoneapp.com/?reviewId=7e9ec42c-a8f6-43d2-9f39-cc486dfa2395&turn=6&action=5\r\n\t// if (firstAttacker.definitelyDead || firstAttacker.health <= 0) {\r\n\t// \tcurrentAttacker = (currentAttacker + 1) % 2;\r\n\t// }\r\n\t// return currentAttacker;\r\n};\r\n\r\nconst handleAlakirForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst firstEntity = playerBoard[0];\r\n\tfirstEntity.windfury = true;\r\n\tif (!firstEntity.divineShield) {\r\n\t\tupdateDivineShield(firstEntity, playerBoard, playerEntity, opponentEntity, true, gameState);\r\n\t}\r\n\tfirstEntity.taunt = true;\r\n\tgameState.spectator.registerPowerTarget(firstEntity, firstEntity, playerBoard, playerEntity, opponentEntity);\r\n};\r\n\r\nconst handleTamsinForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst chosenEntity = pickRandomLowestHealth(playerBoard);\r\n\tif (!chosenEntity) {\r\n\t\tconsole.warn('could not pick any entity for tamsin');\r\n\t\treturn;\r\n\t}\r\n\tgameState.spectator.registerPowerTarget(playerEntity, chosenEntity, playerBoard, null, null);\r\n\tconst newBoard = playerBoard.filter((e) => e.entityId !== chosenEntity.entityId);\r\n\t// How to mark the minion as dead\r\n\tchosenEntity.definitelyDead = true;\r\n\tnewBoard.forEach((e) => {\r\n\t\tmodifyStats(e, chosenEntity.attack, chosenEntity.health, newBoard, playerEntity, gameState);\r\n\t\tgameState.spectator.registerPowerTarget(chosenEntity, e, newBoard, playerEntity, opponentEntity);\r\n\t});\r\n};\r\n\r\nconst applyGloriousGloop = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (!playerBoard?.length) {\r\n\t\treturn;\r\n\t}\r\n\tconst target = playerBoard.find((m) =>\r\n\t\tm.enchantments?.some((e) => e.cardId === CardIds.GloriousGloop_InTheGloopEnchantment_BGDUO_HERO_101pe2),\r\n\t);\r\n\tif (!target) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst teammateState = getTeammateInitialState(gameState.gameState, playerEntity);\r\n\tif (!teammateState?.board?.length) {\r\n\t\treturn;\r\n\t}\r\n\tconst highestTier = Math.max(\r\n\t\t...teammateState.board.map((entity) => gameState.allCards.getCard(entity.cardId).techLevel),\r\n\t);\r\n\tconst candidates = teammateState.board.filter(\r\n\t\t(entity) => gameState.allCards.getCard(entity.cardId).techLevel === highestTier,\r\n\t);\r\n\tif (!candidates.length) {\r\n\t\treturn;\r\n\t}\r\n\tconst highestTierMinion = pickRandom(candidates);\r\n\tconst clone: BoardEntity = addImpliedMechanics(\r\n\t\t{\r\n\t\t\t...highestTierMinion,\r\n\t\t\tlastAffectedByEntity: null,\r\n\t\t\tdefinitelyDead: false,\r\n\t\t\tattackImmediately: false,\r\n\t\t},\r\n\t\tgameState.cardsData,\r\n\t);\r\n\tgameState.spectator.registerPowerTarget(playerEntity, target, playerBoard, playerEntity, opponentEntity);\r\n\t// Replace the \"target\" minion with the \"clone\"\r\n\tconst index = playerBoard.indexOf(target);\r\n\tplayerBoard.splice(index, 1, clone);\r\n};\r\n\r\nconst handleEmbraceYourRageForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst createdCardId = playerEntity.heroPowerInfo as string;\r\n\tif (!createdCardId?.length) {\r\n\t\t// console.warn('no card id for embrace your rage');\r\n\t\treturn;\r\n\t}\r\n\tconst spawns = spawnEntities(\r\n\t\tcreatedCardId,\r\n\t\t1,\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tgameState.allCards,\r\n\t\tgameState.cardsData,\r\n\t\tgameState.sharedState,\r\n\t\tgameState.spectator,\r\n\t\tplayerEntity.friendly,\r\n\t\ttrue,\r\n\t\tfalse,\r\n\t\tfalse,\r\n\t);\r\n\tconst indexFromRight = 0;\r\n\tperformEntitySpawns(\r\n\t\tspawns,\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\tplayerEntity,\r\n\t\tindexFromRight,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tgameState,\r\n\t);\r\n\tgameState.spectator.registerPowerTarget(playerEntity, spawns[0], playerBoard, playerEntity, opponentEntity);\r\n\taddCardsInHand(playerEntity, playerBoard, spawns, gameState);\r\n\tgameState.spectator.registerPowerTarget(playerEntity, spawns[0], playerBoard, playerEntity, opponentEntity);\r\n};\r\n\r\nconst handleRebornRitesForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst targetEntityId = playerEntity.heroPowerInfo as number;\r\n\tconst target = playerBoard.find((entity) => entity.entityId === targetEntityId);\r\n\tif (!target) {\r\n\t\treturn;\r\n\t}\r\n\r\n\ttarget.reborn = true;\r\n\tgameState.spectator.registerPowerTarget(playerEntity, target, playerBoard, playerEntity, opponentEntity);\r\n};\r\n\r\nconst handleTeronForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): boolean => {\r\n\t// Getting the right enchantment can be tricky. The RapidReanimation enchantment can sometimes be\r\n\t// in the Graveyard zone, so we can't filter them out. In that case, we can have multiple\r\n\t// enchantments\r\n\t// However, because of how things are handled in the logs, we should be able to always take the one *\r\n\t// with the biggest entityId\r\n\tconst minionThatWillDie = playerBoard\r\n\t\t.filter((m) => m.enchantments.some((e) => e.cardId === CardIds.RapidReanimation_ImpendingDeathEnchantment))\r\n\t\t.sort(\r\n\t\t\t(a, b) =>\r\n\t\t\t\tb.enchantments.find((e) => e.cardId === CardIds.RapidReanimation_ImpendingDeathEnchantment)\r\n\t\t\t\t\t.originEntityId -\r\n\t\t\t\t\ta.enchantments.find((e) => e.cardId === CardIds.RapidReanimation_ImpendingDeathEnchantment)\r\n\t\t\t\t\t\t.originEntityId || b.entityId - a.entityId,\r\n\t\t)[0];\r\n\tif (minionThatWillDie) {\r\n\t\t// So this is a bit tricky (as all the stuff with indices...). Because in practice it's more likely that players use Rapid Reanimation\r\n\t\t// on minions that they want to die quickly, most of the time they will be placed\r\n\t\t// to the left of the board\r\n\t\t// So using a left-based index (usually 0) is more likely to be correct after minions spawn on the board\r\n\t\t// Update: this looks like it's not the case, and looking at\r\n\t\t// http://replays.firestoneapp.com/?reviewId=2e6b389f-d904-43a2-a7cd-928a60d973ce&turn=11&action=1\r\n\t\t// the index seems to be right-based at least in some cases\r\n\t\t// Looks like even this is wrong:\r\n\t\t// http://replays.firestoneapp.com/?reviewId=9a46ab39-ccf0-478c-a010-68f2abb06c6f&turn=9&action=0\r\n\t\tconst rapidReanimationIndexFromLeft = playerBoard.indexOf(minionThatWillDie);\r\n\t\tplayerEntity.rapidReanimationIndexFromRight = playerBoard.length - 1 - rapidReanimationIndexFromLeft;\r\n\t\tconst minionToCopy = {\r\n\t\t\t...minionThatWillDie,\r\n\t\t\tenchantments: minionThatWillDie.enchantments.map((e) => ({ ...e })) ?? [],\r\n\t\t\tpendingAttackBuffs: [],\r\n\t\t} as BoardEntity;\r\n\t\tremoveAurasFromSelf(minionToCopy, playerBoard, playerEntity, gameState);\r\n\t\tplayerEntity.rapidReanimationMinion = minionToCopy;\r\n\t\tminionThatWillDie.definitelyDead = true;\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tplayerEntity,\r\n\t\t\tminionThatWillDie,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentEntity,\r\n\t\t);\r\n\t\treturn true;\r\n\t}\r\n\treturn false;\r\n};\r\n\r\nconst handleWaxWarbandForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (playerBoard.length > 0) {\r\n\t\tconst boardWithTribes = playerBoard.filter(\r\n\t\t\t(e) => !!getEffectiveTribesForEntity(e, playerEntity, gameState.allCards).length,\r\n\t\t);\r\n\t\tconst boardWithoutAll = boardWithTribes.filter(\r\n\t\t\t(e) => !gameState.allCards.getCard(e.cardId).races?.includes(Race[Race.ALL]),\r\n\t\t);\r\n\t\tconst selectedMinions = selectMinions(boardWithoutAll, ALL_BG_RACES, gameState.allCards);\r\n\t\tconst allMinions = [\r\n\t\t\t...selectedMinions,\r\n\t\t\t...boardWithTribes.filter((e) => gameState.allCards.getCard(e.cardId).races?.includes(Race[Race.ALL])),\r\n\t\t];\r\n\t\tallMinions.forEach((e) => {\r\n\t\t\tmodifyStats(\r\n\t\t\t\te,\r\n\t\t\t\tgameState.cardsData.getTavernLevel(e.cardId),\r\n\t\t\t\tgameState.cardsData.getTavernLevel(e.cardId),\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(playerEntity, e, playerBoard, playerEntity, opponentEntity);\r\n\t\t});\r\n\t}\r\n};\r\n\r\n// Not perfect, as I don't think this solves the issue where some cards are mutually exclusive\r\nconst selectMinions = (minions: BoardEntity[], tribes: Race[], allCards: AllCardsService): BoardEntity[] => {\r\n\t// Step 1\r\n\tconst minionsByTribe: { [tribe: string]: BoardEntity[] } = {};\r\n\tfor (const minion of minions) {\r\n\t\tfor (const tribe of allCards.getCard(minion.cardId).races ?? []) {\r\n\t\t\tif (!minionsByTribe[tribe]) {\r\n\t\t\t\tminionsByTribe[tribe] = [];\r\n\t\t\t}\r\n\t\t\tminionsByTribe[tribe].push(minion);\r\n\t\t}\r\n\t}\r\n\tfor (const tribe of ALL_BG_RACES) {\r\n\t\tminionsByTribe[tribe] = shuffleArray(minionsByTribe[Race[tribe]] ?? []);\r\n\t}\r\n\r\n\tconst selectedMinions: BoardEntity[] = [];\r\n\r\n\t// Step 3\r\n\tfor (const tribe of tribes) {\r\n\t\tif (minionsByTribe[tribe]) {\r\n\t\t\tminionsByTribe[tribe].sort(\r\n\t\t\t\t(a, b) => allCards.getCard(a.cardId).races.length - allCards.getCard(b.cardId).races.length,\r\n\t\t\t);\r\n\t\t\tfor (const minion of minionsByTribe[tribe]) {\r\n\t\t\t\tif (!selectedMinions.includes(minion)) {\r\n\t\t\t\t\tselectedMinions.push(minion);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Step 4\r\n\treturn selectedMinions;\r\n};\r\n\r\nconst handlePlayerStartOfCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tif (playerEntity.startOfCombatDone || playerEntity.hpLeft <= 0) {\r\n\t\treturn currentAttacker;\r\n\t}\r\n\t// eslint-disable-next-line prefer-const\r\n\tlet shouldRecomputeCurrentAttacker = false;\r\n\tconst playerHeroPowerId = playerEntity.heroPowerId || getHeroPowerForHero(playerEntity.cardId);\r\n\t// TODO: should this recompute the first attack order?\r\n\tif (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimLeftToken) {\r\n\t\tconst target = opponentBoard[0];\r\n\t\tconst damageDone = dealDamageToMinion(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo2 ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimRightToken) {\r\n\t\tconst target = opponentBoard[opponentBoard.length - 1];\r\n\t\tconst damageDone = dealDamageToMinion(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo2 ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimLowToken) {\r\n\t\tconst smallestHealthMinion = [...opponentBoard].sort((a, b) => a.health - b.health)[0];\r\n\t\tconst target = pickRandom(opponentBoard.filter((e) => e.health === smallestHealthMinion.health));\r\n\t\tconst damageDone = dealDamageToMinion(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo2 ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimHighToken) {\r\n\t\tconst highestHealthMinion = [...opponentBoard].sort((a, b) => b.health - a.health)[0];\r\n\t\tconst target = pickRandom(opponentBoard.filter((e) => e.health === highestHealthMinion.health));\r\n\t\tconst damageDone = dealDamageToMinion(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo2 ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t}\r\n\tprocessMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\tif (shouldRecomputeCurrentAttacker) {\r\n\t\tconst previousCurrentAttacker = currentAttacker;\r\n\t\tcurrentAttacker =\r\n\t\t\tplayerBoard.length > opponentBoard.length\r\n\t\t\t\t? friendly\r\n\t\t\t\t\t? 0\r\n\t\t\t\t\t: 1\r\n\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t? friendly\r\n\t\t\t\t\t? 1\r\n\t\t\t\t\t: 0\r\n\t\t\t\t: currentAttacker;\r\n\t\t// console.debug(\r\n\t\t// \t'recompting current attacker',\r\n\t\t// \tcurrentAttacker,\r\n\t\t// \tplayerBoard.length,\r\n\t\t// \topponentBoard.length,\r\n\t\t// \tpreviousCurrentAttacker,\r\n\t\t// \tstringifySimple(playerBoard, allCards),\r\n\t\t// \tstringifySimple(opponentBoard, allCards),\r\n\t\t// );\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\nexport const getHeroPowerForHero = (heroCardId: string): string => {\r\n\tswitch (heroCardId) {\r\n\t\tcase CardIds.IllidanStormrage_TB_BaconShop_HERO_08:\r\n\t\t\treturn CardIds.Wingmen;\r\n\t\tcase CardIds.TheLichKing_TB_BaconShop_HERO_22:\r\n\t\t\treturn CardIds.RebornRites;\r\n\t\tcase CardIds.ProfessorPutricide_BG25_HERO_100:\r\n\t\t\treturn CardIds.RagePotion;\r\n\t\tcase CardIds.Deathwing_TB_BaconShop_HERO_52:\r\n\t\t\treturn CardIds.AllWillBurn;\r\n\t\tcase CardIds.TeronGorefiend_BG25_HERO_103:\r\n\t\t\treturn CardIds.TeronGorefiend_RapidReanimation;\r\n\t}\r\n\treturn null;\r\n};\r\n\r\nexport const performStartOfCombatMinionsForPlayer = (\r\n\tattacker: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\t// Apparently, the board composition used for start of combat minion effects (like Red Whelp, and I assume it works the\r\n\t// same way for others like Prized Promo Drake or Mantid Queen) is the one that is used before Illidan's effect is handled.\r\n\t// Since this also runs before HP start of combat, we probably also use the state as it was before HP were triggered, like\r\n\t// Tamsin's Phylactery.\r\n\tattackingBoardBefore: BoardEntity[],\r\n\tdefendingBoardBefore: BoardEntity[],\r\n\tgameState: FullGameState,\r\n): boolean => {\r\n\tif (attackingBoardHero.startOfCombatDone) {\r\n\t\treturn false;\r\n\t}\r\n\tlet hasProcessed = true;\r\n\tif (attacker.cardId === CardIds.RedWhelp_BGS_019) {\r\n\t\tconst damage = attackingBoardBefore.filter((entity) =>\r\n\t\t\thasCorrectTribe(entity, attackingBoardHero, Race.DRAGON, gameState.allCards),\r\n\t\t).length;\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tattacker,\r\n\t\t\tdamage,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t} else if (attacker.cardId === CardIds.RedWhelp_TB_BaconUps_102) {\r\n\t\tconst damage = attackingBoardBefore.filter((entity) =>\r\n\t\t\thasCorrectTribe(entity, attackingBoardHero, Race.DRAGON, gameState.allCards),\r\n\t\t).length;\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tattacker,\r\n\t\t\tdamage,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tattacker,\r\n\t\t\tdamage,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.PrizedPromoDrake_BG21_014 ||\r\n\t\tattacker.cardId === CardIds.PrizedPromoDrake_BG21_014_G\r\n\t) {\r\n\t\tconst stats = attacker.cardId === CardIds.PrizedPromoDrake_BG21_014_G ? 6 : 3;\r\n\t\tconst targets = attackingBoard\r\n\t\t\t.filter((e) => e.entityId !== attacker.entityId)\r\n\t\t\t.filter((e) => hasCorrectTribe(e, attackingBoardHero, Race.DRAGON, gameState.allCards));\r\n\t\tfor (const entity of targets) {\r\n\t\t\tmodifyStats(entity, stats, stats, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tattacker,\r\n\t\t\t\tentity,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t);\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.ChoralMrrrglr_BG26_354 ||\r\n\t\tattacker.cardId === CardIds.ChoralMrrrglr_BG26_354_G\r\n\t) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.ChoralMrrrglr_BG26_354_G ? 2 : 1;\r\n\t\tmodifyStats(\r\n\t\t\tattacker,\r\n\t\t\tmultiplier * attackingBoardHero.globalInfo?.ChoralAttackBuff,\r\n\t\t\tmultiplier * attackingBoardHero.globalInfo?.ChoralHealthBuff,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tattacker,\r\n\t\t\tattacker,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoardHero,\r\n\t\t);\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.AmberGuardian_BG24_500 ||\r\n\t\tattacker.cardId === CardIds.AmberGuardian_BG24_500_G\r\n\t) {\r\n\t\t// First try to get a target without divine shield, and if none is available, pick one with divine shield\r\n\t\tconst otherDragons = attackingBoard\r\n\t\t\t.filter((e) => hasCorrectTribe(e, attackingBoardHero, Race.DRAGON, gameState.allCards))\r\n\t\t\t.filter((e) => e.entityId !== attacker.entityId);\r\n\t\tconst loops = attacker.cardId === CardIds.AmberGuardian_BG24_500_G ? 2 : 1;\r\n\t\tconst dragonsToConsider = otherDragons;\r\n\t\tfor (let i = 0; i < loops; i++) {\r\n\t\t\tconst otherDragon =\r\n\t\t\t\tpickRandom(dragonsToConsider.filter((e) => !e.divineShield)) ?? pickRandom(dragonsToConsider);\r\n\t\t\tif (otherDragon) {\r\n\t\t\t\tif (!otherDragon.divineShield) {\r\n\t\t\t\t\tupdateDivineShield(\r\n\t\t\t\t\t\totherDragon,\r\n\t\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\t\tdefendingBoardHero,\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}\r\n\t\t\t\tmodifyStats(otherDragon, 7, 7, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\totherDragon,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t);\r\n\t\t\t\tdragonsToConsider.splice(dragonsToConsider.indexOf(otherDragon), 1);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.SanctumRester_BG26_356 ||\r\n\t\tattacker.cardId === CardIds.SanctumRester_BG26_356_G\r\n\t) {\r\n\t\tconst buff = attacker.cardId === CardIds.SanctumRester_BG26_356_G ? 16 : 8;\r\n\t\t// First try to get a target without divine shield, and if none is available, pick one with divine shield\r\n\t\tconst otherDragons = attackingBoard\r\n\t\t\t.filter((e) => hasCorrectTribe(e, attackingBoardHero, Race.DRAGON, gameState.allCards))\r\n\t\t\t.filter((e) => e.entityId !== attacker.entityId);\r\n\t\totherDragons.forEach((otherDragon) => {\r\n\t\t\tmodifyStats(otherDragon, 0, buff, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tattacker,\r\n\t\t\t\totherDragon,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t);\r\n\t\t});\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.Soulsplitter_BG25_023 ||\r\n\t\tattacker.cardId === CardIds.Soulsplitter_BG25_023_G\r\n\t) {\r\n\t\tconst numberOfTargets = attacker.cardId === CardIds.Soulsplitter_BG25_023_G ? 2 : 1;\r\n\t\tfor (let i = 0; i < numberOfTargets; i++) {\r\n\t\t\tconst undeadsWithoutReborn = attackingBoard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, attackingBoardHero, Race.UNDEAD, gameState.allCards))\r\n\t\t\t\t.filter((e) => !e.reborn);\r\n\t\t\tconst chosenUndead = pickRandom(undeadsWithoutReborn);\r\n\t\t\tif (chosenUndead) {\r\n\t\t\t\tchosenUndead.reborn = true;\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tchosenUndead,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.Crabby_BG22_HERO_000_Buddy ||\r\n\t\tattacker.cardId === CardIds.Crabby_BG22_HERO_000_Buddy_G\r\n\t) {\r\n\t\tconst neighbours = getNeighbours(attackingBoard, attacker);\r\n\t\tconst multiplier = attacker.cardId === CardIds.Crabby_BG22_HERO_000_Buddy_G ? 2 : 1;\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyStats(\r\n\t\t\t\tentity,\r\n\t\t\t\tmultiplier * (attackingBoardHero.deadEyeDamageDone ?? 0),\r\n\t\t\t\tmultiplier * (attackingBoardHero.deadEyeDamageDone ?? 0),\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tattacker,\r\n\t\t\t\tentity,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t);\r\n\t\t});\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.CorruptedMyrmidon_BG23_012 ||\r\n\t\tattacker.cardId === CardIds.CorruptedMyrmidon_BG23_012_G\r\n\t) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.CorruptedMyrmidon_BG23_012_G ? 2 : 1;\r\n\t\tmodifyStats(\r\n\t\t\tattacker,\r\n\t\t\tmultiplier * attacker.attack,\r\n\t\t\tmultiplier * attacker.health,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tattacker,\r\n\t\t\tattacker,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoardHero,\r\n\t\t);\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.InterrogatorWhitemane_BG24_704 ||\r\n\t\tattacker.cardId === CardIds.InterrogatorWhitemane_BG24_704_G\r\n\t) {\r\n\t\tif (defendingBoard.length > 0) {\r\n\t\t\tconst validTargets = defendingBoard.filter((e) => gameState.cardsData.getTavernLevel(e.cardId) >= 5);\r\n\t\t\tconst numberOfPicks = attacker.cardId === CardIds.InterrogatorWhitemane_BG24_704_G ? 2 : 1;\r\n\t\t\tfor (let i = 0; i < numberOfPicks; i++) {\r\n\t\t\t\tconst target = pickRandom(validTargets);\r\n\t\t\t\tif (!!target) {\r\n\t\t\t\t\tcastImpure(attacker, target, attackingBoard, gameState.spectator);\r\n\t\t\t\t\tconst targetIndex = validTargets.findIndex((e) => e.entityId === target.entityId);\r\n\t\t\t\t\tvalidTargets.splice(targetIndex, 1);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (attacker.cardId === CardIds.MantidQueen_BG22_402 || attacker.cardId === CardIds.MantidQueen_BG22_402_G) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.MantidQueen_BG22_402_G ? 2 : 1;\r\n\t\tconst allRaces = attackingBoardBefore\r\n\t\t\t.map((entity) => entity.cardId)\r\n\t\t\t.flatMap((cardId) => gameState.allCards.getCard(cardId).races)\r\n\t\t\t.filter((race) => !!race && race !== Race[Race.BLANK]);\r\n\t\tconst totalRaces =\r\n\t\t\t[...new Set(allRaces.filter((race) => race !== Race[Race.ALL]))].length +\r\n\t\t\tallRaces.filter((race) => race === Race[Race.ALL]).length;\r\n\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\tfor (let j = 0; j < totalRaces; j++) {\r\n\t\t\t\tconst buffType = getRandomMantidQueenBuffType(attacker);\r\n\t\t\t\tswitch (buffType) {\r\n\t\t\t\t\tcase 'stats':\r\n\t\t\t\t\t\tmodifyStats(attacker, 5, 5, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'reborn':\r\n\t\t\t\t\t\tattacker.reborn = true;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'taunt':\r\n\t\t\t\t\t\tattacker.taunt = true;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'windfury':\r\n\t\t\t\t\t\tattacker.windfury = true;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.CarbonicCopy_BG27_503 ||\r\n\t\tattacker.cardId === CardIds.CarbonicCopy_BG27_503_G\r\n\t) {\r\n\t\tconst numberOfCopies = attacker.cardId === CardIds.CarbonicCopy_BG27_503_G ? 2 : 1;\r\n\t\tfor (let i = 0; i < numberOfCopies; i++) {\r\n\t\t\tif (!!attackingBoard.length && attackingBoard.length < 7) {\r\n\t\t\t\tconst copy: BoardEntity = {\r\n\t\t\t\t\t...attacker,\r\n\t\t\t\t\tlastAffectedByEntity: null,\r\n\t\t\t\t};\r\n\t\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\t\tcopy.cardId,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\tattacker.friendly,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tcopy,\r\n\t\t\t\t);\r\n\t\t\t\tconst indexFromRight = attackingBoard.length - (attackingBoard.indexOf(attacker) + 1);\r\n\t\t\t\tperformEntitySpawns(\r\n\t\t\t\t\tnewMinions,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tcopy,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.DiremuckForager_BG27_556 ||\r\n\t\tattacker.cardId === CardIds.DiremuckForager_BG27_556_G\r\n\t) {\r\n\t\tconst potentialTargets = attackingBoardHero.hand\r\n\t\t\t.filter((e) => !!e.cardId)\r\n\t\t\t.filter((e) => gameState.allCards.getCard(e.cardId).type?.toUpperCase() === CardType[CardType.MINION])\r\n\t\t\t.filter((e) => !e.locked);\r\n\t\tif (potentialTargets.length > 0) {\r\n\t\t\tconst target = pickRandom(potentialTargets);\r\n\t\t\t// When it's the opponent, the game state already contains all the buffs\r\n\t\t\t// It can happen that, for the opponent, a card is first added to their hand (eg with Embrace Your Rage)\r\n\t\t\t// and then summoned by Diremuck. In that case, the stats need to be buffed\r\n\t\t\t// Update 29.2 18/04/2024: this is no longer the case, and the minions passed in the initial state should\r\n\t\t\t// reflect the values they have in hand\r\n\t\t\t// if (target?.friendly || !target?.inInitialState) {\r\n\t\t\tconst diremuckBuff = attacker.cardId === CardIds.DiremuckForager_BG27_556_G ? 4 : 2;\r\n\t\t\tmodifyStats(target, diremuckBuff, diremuckBuff, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tattacker,\r\n\t\t\t\ttarget,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t);\r\n\t\t\t// }\r\n\t\t\tif (attackingBoard.length < 7) {\r\n\t\t\t\ttarget.locked = true;\r\n\t\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\t\ttarget.cardId,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\tattacker.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t\t{ ...target } as BoardEntity,\r\n\t\t\t\t);\r\n\t\t\t\tfor (const s of newMinions) {\r\n\t\t\t\t\ts.onCanceledSummon = () => (target.locked = false);\r\n\t\t\t\t}\r\n\t\t\t\tperformEntitySpawns(\r\n\t\t\t\t\tnewMinions,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tattackingBoard.length - (attackingBoard.indexOf(attacker) + 1),\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\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} else if (\r\n\t\tattacker.cardId === CardIds.HawkstriderHerald_BG27_079 ||\r\n\t\tattacker.cardId === CardIds.HawkstriderHerald_BG27_079_G\r\n\t) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.HawkstriderHerald_BG27_079_G ? 2 : 1;\r\n\t\tfor (const entity of attackingBoard) {\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t);\r\n\t\t\t\thandleDeathrattles({\r\n\t\t\t\t\tgameState: gameState,\r\n\t\t\t\t\tplayerDeadEntities: attackingBoardHero.friendly ? [entity] : [],\r\n\t\t\t\t\tplayerDeadEntityIndexesFromRight: attackingBoardHero.friendly\r\n\t\t\t\t\t\t? [attackingBoard.length - 1 - attackingBoard.indexOf(entity)]\r\n\t\t\t\t\t\t: [],\r\n\t\t\t\t\topponentDeadEntities: attackingBoardHero.friendly ? [] : [entity],\r\n\t\t\t\t\topponentDeadEntityIndexesFromRight: attackingBoardHero.friendly\r\n\t\t\t\t\t\t? []\r\n\t\t\t\t\t\t: [attackingBoard.length - 1 - attackingBoard.indexOf(entity)],\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t\t// console.debug('done triggering hawkstrider\\n\\n\\n');\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.AudaciousAnchor_BG28_904 ||\r\n\t\tattacker.cardId === CardIds.AudaciousAnchor_BG28_904_G\r\n\t) {\r\n\t\tconst iterations = attacker.cardId === CardIds.AudaciousAnchor_BG28_904_G ? 2 : 1;\r\n\t\tfor (let i = 0; i < iterations; i++) {\r\n\t\t\tconst targets = findNearestEnemies(\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattacker,\r\n\t\t\t\tattackingBoard.length - 1 - attackingBoard.indexOf(attacker),\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\t1,\r\n\t\t\t\tgameState.allCards,\r\n\t\t\t);\r\n\t\t\tif (!targets.length) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tif (targets.length > 2) {\r\n\t\t\t\tconsole.error('Invalid number of targets', targets.length);\r\n\t\t\t}\r\n\r\n\t\t\tconst target = pickRandom(targets);\r\n\t\t\twhile (attacker.health > 0 && target.health > 0 && !attacker.definitelyDead && !target.definitelyDead) {\r\n\t\t\t\t// Attackers don't alternate\r\n\t\t\t\t// See http://replays.firestoneapp.com/?reviewId=f9f6bf62-db73-49ad-8187-d2f8848b7f36&turn=17&action=0\r\n\t\t\t\tdoFullAttack(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\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} else if (\r\n\t\tattacker.cardId === CardIds.PilotedWhirlOTron_BG21_HERO_030_Buddy ||\r\n\t\tattacker.cardId === CardIds.PilotedWhirlOTron_BG21_HERO_030_Buddy_G\r\n\t) {\r\n\t\t// const iterations = attacker.cardId === CardIds.PilotedWhirlOTron_BG21_HERO_030_Buddy_G ? 2 : 1;\r\n\t\trememberDeathrattles(\r\n\t\t\tattacker,\r\n\t\t\tattackingBoard.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId !== CardIds.PilotedWhirlOTron_BG21_HERO_030_Buddy &&\r\n\t\t\t\t\te.cardId !== CardIds.PilotedWhirlOTron_BG21_HERO_030_Buddy_G,\r\n\t\t\t),\r\n\t\t\tgameState.cardsData,\r\n\t\t\tgameState.allCards,\r\n\t\t\tgameState.sharedState,\r\n\t\t);\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tattacker,\r\n\t\t\tattacker,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoardHero,\r\n\t\t);\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.IrateRooster_BG29_990 ||\r\n\t\tattacker.cardId === CardIds.IrateRooster_BG29_990_G\r\n\t) {\r\n\t\tconst loops = attacker.cardId === CardIds.IrateRooster_BG29_990_G ? 2 : 1;\r\n\t\tfor (let i = 0; i < loops; i++) {\r\n\t\t\tconst neighbours = getNeighbours(attackingBoard, attacker);\r\n\t\t\tfor (const neighbour of neighbours) {\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tneighbour,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t);\r\n\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\tneighbour,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t\tmodifyStats(neighbour, 4, 0, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.MisfitDragonling_BG29_814 ||\r\n\t\tattacker.cardId === CardIds.MisfitDragonling_BG29_814_G\r\n\t) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.MisfitDragonling_BG29_814_G ? 2 : 1;\r\n\t\tconst tier = attackingBoardHero.tavernTier;\r\n\t\tconst stats = multiplier * tier;\r\n\t\tmodifyStats(attacker, stats, stats, attackingBoard, attackingBoardHero, gameState);\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tattacker,\r\n\t\t\tattacker,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoardHero,\r\n\t\t);\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.ThousandthPaperDrake_BG29_810 ||\r\n\t\tattacker.cardId === CardIds.ThousandthPaperDrake_BG29_810_G\r\n\t) {\r\n\t\tconst loops = attacker.cardId === CardIds.ThousandthPaperDrake_BG29_810_G ? 2 : 1;\r\n\t\tconst pickedTargets = [];\r\n\t\tconst dragons = attackingBoard.filter((e) =>\r\n\t\t\thasCorrectTribe(e, attackingBoardHero, Race.DRAGON, gameState.allCards),\r\n\t\t);\r\n\t\tfor (let i = 0; i < loops; i++) {\r\n\t\t\tconst target = dragons.filter((e) => !pickedTargets.includes(e))[0];\r\n\t\t\tif (!!target) {\r\n\t\t\t\tmodifyStats(target, 1, 2, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\t\ttarget.windfury = true;\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t);\r\n\t\t\t\tpickedTargets.push(target);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.YulonFortuneGranter_BG29_811 ||\r\n\t\tattacker.cardId === CardIds.YulonFortuneGranter_BG29_811_G\r\n\t) {\r\n\t\tconst loops = attacker.cardId === CardIds.YulonFortuneGranter_BG29_811_G ? 2 : 1;\r\n\t\tfor (let i = 0; i < loops; i++) {\r\n\t\t\tconst candidateBoard = attackingBoard\r\n\t\t\t\t.filter((e) => !isGolden(e.cardId, gameState.allCards))\r\n\t\t\t\t.filter(\r\n\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\te.cardId !== CardIds.YulonFortuneGranter_BG29_811 &&\r\n\t\t\t\t\t\te.cardId !== CardIds.YulonFortuneGranter_BG29_811_G,\r\n\t\t\t\t);\r\n\t\t\t// Because we pick one at random from all the ones that have the lowest tier\r\n\t\t\tconst randomBoard = shuffleArray(candidateBoard);\r\n\t\t\tconst candidates = randomBoard.sort(\r\n\t\t\t\t(a, b) => gameState.cardsData.getTavernLevel(a.cardId) - gameState.cardsData.getTavernLevel(b.cardId),\r\n\t\t\t);\r\n\t\t\tconst target = candidates[0];\r\n\t\t\tif (!!target) {\r\n\t\t\t\tmakeMinionGolden(target, attacker, attackingBoard, attackingBoardHero, defendingBoardHero, gameState);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.HoardingHatespawn_BG29_872 ||\r\n\t\tattacker.cardId === CardIds.HoardingHatespawn_BG29_872_G\r\n\t) {\r\n\t\tconst stats = attacker.cardId === CardIds.HoardingHatespawn_BG29_872_G ? 20 : 10;\r\n\t\tconst target = getRandomMinionWithHighestHealth(defendingBoard);\r\n\t\tif (!!target) {\r\n\t\t\tconst previousAttack = target.attack;\r\n\t\t\tconst previousHealth = target.health;\r\n\t\t\ttarget.attack = Math.max(0, target.attack - stats);\r\n\t\t\ttarget.health = Math.max(0, target.health - stats);\r\n\t\t\ttarget.maxHealth = Math.max(0, target.maxHealth - stats);\r\n\t\t\tmodifyStats(\r\n\t\t\t\tattacker,\r\n\t\t\t\tpreviousAttack - target.attack,\r\n\t\t\t\tpreviousHealth - target.health,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tattacker,\r\n\t\t\t\ttarget,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t);\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.TheUninvitedGuest_BG29_875 ||\r\n\t\tattacker.cardId === CardIds.TheUninvitedGuest_BG29_875_G\r\n\t) {\r\n\t\tconst targetEnchantment =\r\n\t\t\tattacker.cardId === CardIds.TheUninvitedGuest_BG29_875_G\r\n\t\t\t\t? CardIds.TheUninvitedGuest_UninvitedEnchantment_BG29_875_Ge\r\n\t\t\t\t: CardIds.TheUninvitedGuest_UninvitedEnchantment_BG29_875e;\r\n\t\tattackingBoard\r\n\t\t\t.filter((e) => e.entityId != attacker.entityId)\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\te.enchantments = e.enchantments || [];\r\n\t\t\t\tif (!e.enchantments.some((e) => e.cardId === targetEnchantment)) {\r\n\t\t\t\t\te.enchantments.push({\r\n\t\t\t\t\t\tcardId: targetEnchantment,\r\n\t\t\t\t\t\toriginEntityId: attacker.entityId,\r\n\t\t\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t} else if (attacker.cardId === CardIds.Sandy_BGDUO_125 || attacker.cardId === CardIds.Sandy_BGDUO_125_G) {\r\n\t\tconst teammateState = getTeammateInitialState(gameState.gameState, attackingBoardHero);\r\n\t\tif (teammateState?.board?.length) {\r\n\t\t\tconst isGolden = attacker.cardId === CardIds.Sandy_BGDUO_125_G;\r\n\t\t\tconst minionToCopy = getRandomMinionWithHighestHealth(teammateState.board);\r\n\t\t\tconst copy: BoardEntity = { ...minionToCopy, enchantments: [...minionToCopy.enchantments] };\r\n\t\t\tconst attackerIndex = attackingBoard.indexOf(attacker);\r\n\t\t\t// Insert the copy in its place\r\n\t\t\tattackingBoard.splice(attackerIndex, 0, copy);\r\n\t\t\tif (isGolden) {\r\n\t\t\t\tmakeMinionGolden(copy, copy, attackingBoard, attackingBoardHero, defendingBoardHero, gameState);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.Vaelastrasz_TB_BaconShop_HERO_56_Buddy ||\r\n\t\tattacker.cardId === CardIds.Vaelastrasz_TB_BaconShop_HERO_56_Buddy_G\r\n\t) {\r\n\t\tconst vaelastraszBonus = attacker.cardId === CardIds.Vaelastrasz_TB_BaconShop_HERO_56_Buddy_G ? 6 : 3;\r\n\t\tattackingBoard\r\n\t\t\t.filter((e) => e.entityId !== attacker.entityId)\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\tmodifyStats(e, vaelastraszBonus, vaelastraszBonus, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\te,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.ElderTaggawag_TB_BaconShop_HERO_14_Buddy ||\r\n\t\tattacker.cardId === CardIds.ElderTaggawag_TB_BaconShop_HERO_14_Buddy_G\r\n\t) {\r\n\t\tconst minionsOfDifferentTypes = getMinionsOfDifferentTypes(attackingBoard, attackingBoardHero, gameState);\r\n\t\tif (minionsOfDifferentTypes.length >= 4) {\r\n\t\t\tconst highestAttackOnBoard = Math.max(...attackingBoard.map((entity) => entity.attack));\r\n\t\t\tconst highestHealthOnBoard = Math.max(...attackingBoard.map((entity) => entity.health));\r\n\t\t\tconst multiplier = attacker.cardId === CardIds.ElderTaggawag_TB_BaconShop_HERO_14_Buddy_G ? 2 : 1;\r\n\t\t\tmodifyStats(\r\n\t\t\t\tattacker,\r\n\t\t\t\thighestAttackOnBoard * multiplier,\r\n\t\t\t\thighestHealthOnBoard * multiplier,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tattacker,\r\n\t\t\t\tattacker,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t);\r\n\t\t}\r\n\t} else if (attacker.cardId === CardIds.SunScreener_BG30_101 || attacker.cardId === CardIds.SunScreener_BG30_101_G) {\r\n\t\tif (attackingBoard.length > 0 || defendingBoard.length > 0) {\r\n\t\t\tconst quantity = attacker.cardId === CardIds.SunScreener_BG30_101 ? 3 : 6;\r\n\t\t\tgrantDivineShieldToLeftmostMinions(\r\n\t\t\t\tattacker,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tquantity,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.SkyPirateFlagbearer_BG30_119 ||\r\n\t\tattacker.cardId === CardIds.SkyPirateFlagbearer_BG30_119_G\r\n\t) {\r\n\t\tattackingBoard\r\n\t\t\t.filter((e) => e.entityId !== attacker.entityId)\r\n\t\t\t.filter((e) => hasCorrectTribe(e, attackingBoardHero, Race.PIRATE, gameState.allCards))\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\te.enchantments = e.enchantments || [];\r\n\t\t\t\te.enchantments.push({\r\n\t\t\t\t\tcardId:\r\n\t\t\t\t\t\tattacker.cardId === CardIds.SkyPirateFlagbearer_BG30_119_G\r\n\t\t\t\t\t\t\t? CardIds.SkyPirateFlagbearer_FlagbearingEnchantment_BG30_119_Ge\r\n\t\t\t\t\t\t\t: CardIds.SkyPirateFlagbearer_FlagbearingEnchantment_BG30_119e,\r\n\t\t\t\t\toriginEntityId: attacker.entityId,\r\n\t\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t} else {\r\n\t\thasProcessed = false;\r\n\t}\r\n\tprocessMinionDeath(attackingBoard, attackingBoardHero, defendingBoard, defendingBoardHero, gameState);\r\n\treturn hasProcessed;\r\n};\r\n\r\nconst applyAllWillBurn = (\r\n\tboard1: BoardEntity[],\r\n\tboard1Hero: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tboard2Hero: BgsPlayerEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tfor (const entity of board1) {\r\n\t\tmodifyStats(entity, 2, 0, board1, board1Hero, gameState);\r\n\t\tgameState.spectator.registerPowerTarget(sourceEntity, entity, board1, null, null);\r\n\t}\r\n\tfor (const entity of board2) {\r\n\t\tmodifyStats(entity, 2, 0, board2, board1Hero, gameState);\r\n\t\tgameState.spectator.registerPowerTarget(sourceEntity, entity, board2, null, null);\r\n\t}\r\n};\r\n\r\nconst castImpure = (entity: BoardEntity, source: BoardEntity, board: BoardEntity[], spectator: Spectator) => {\r\n\tif (!entity) {\r\n\t\treturn;\r\n\t}\r\n\tconst multiplier = source.cardId === CardIds.InterrogatorWhitemane_BG24_704_G ? 3 : 2;\r\n\tentity.taunt = true;\r\n\tentity.damageMultiplier = entity.damageMultiplier ?? 1;\r\n\tentity.damageMultiplier *= multiplier;\r\n\tspectator.registerPowerTarget(source, entity, board, null, null);\r\n};\r\n\r\nconst getRandomMantidQueenBuffType = (entity: BoardEntity): 'stats' | 'reborn' | 'windfury' | 'taunt' => {\r\n\tconst possibilities: ('stats' | 'reborn' | 'windfury' | 'taunt')[] = ['stats'];\r\n\tif (!entity.reborn) {\r\n\t\tpossibilities.push('reborn');\r\n\t}\r\n\tif (!entity.windfury) {\r\n\t\tpossibilities.push('windfury');\r\n\t}\r\n\tif (!entity.taunt) {\r\n\t\tpossibilities.push('taunt');\r\n\t}\r\n\treturn pickRandom(possibilities);\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"start-of-combat.js","sourceRoot":"","sources":["../../src/simulation/start-of-combat.ts"],"names":[],"mappings":";;;AACA,iEAAsG;AAGtG,oDAA0F;AAC1F,6CAAqF;AACrF,oCAUkB;AAClB,+DAA4D;AAC5D,qCAQkB;AAClB,mDAAiD;AACjD,+DAM+B;AAC/B,2EAAiE;AACjE,6DAAqD;AAErD,qCAA+C;AAE/C,mCAA6E;AAC7E,2DAA6D;AAC7D,2CAAkD;AAS3C,MAAM,mBAAmB,GAAG,CAClC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IACX,MAAM,8BAA8B,GAAG,IAAI,CAAC;IAC5C,IAAI,8BAA8B,EAAE;QACnC,eAAe;YACd,WAAW,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM;gBACxC,CAAC,CAAC,CAAC;gBACH,CAAC,CAAC,aAAa,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM;oBAC3C,CAAC,CAAC,CAAC;oBACH,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;KAC9B;IAGD,eAAe,GAAG,+BAA+B,CAChD,YAAY,EACZ,WAAW,EACX,cAAc,EACd,aAAa,EACb,eAAe,EACf,SAAS,CACT,CAAC;IACF,eAAe,GAAG,4BAA4B,CAC7C,YAAY,EACZ,WAAW,EACX,cAAc,EACd,aAAa,EACb,eAAe,EACf,SAAS,CACT,CAAC;IAOF,eAAe,GAAG,yBAAyB,CAC1C,YAAY,EACZ,WAAW,EACX,cAAc,EACd,aAAa,EACb,eAAe,EACf,SAAS,CACT,CAAC;IAEF,MAAM,iBAAiB,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAA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AAO,CAAC,CAAC;KAC5B;IACD,OAAO,IAAA,kBAAU,EAAC,aAAa,CAAC,CAAC;AAClC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { ALL_BG_RACES, AllCardsService, CardIds, CardType, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { grantDivineShieldToLeftmostMinions, updateDivineShield } from '../divine-shield';\r\nimport { pickRandom, pickRandomLowestHealth, shuffleArray } from '../services/utils';\r\nimport {\r\n\taddImpliedMechanics,\r\n\taddStatsToBoard,\r\n\tcopyEntity,\r\n\tgetEffectiveTribesForEntity,\r\n\tgetMinionsOfDifferentTypes,\r\n\tgetRandomMinionWithHighestHealth,\r\n\tgetTeammateInitialState,\r\n\thasCorrectTribe,\r\n\tisGolden,\r\n} from '../utils';\r\nimport { removeAurasFromSelf } from './add-minion-to-board';\r\nimport {\r\n\tdealDamageToMinion,\r\n\tdealDamageToRandomEnemy,\r\n\tdoFullAttack,\r\n\tfindNearestEnemies,\r\n\tgetNeighbours,\r\n\tprocessMinionDeath,\r\n\tsimulateAttack,\r\n} from './attack';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport {\r\n\tapplyEarthInvocationEnchantment,\r\n\tapplyFireInvocationEnchantment,\r\n\tapplyLightningInvocationEnchantment,\r\n\tapplyWaterInvocationEnchantment,\r\n\trememberDeathrattles,\r\n} from './deathrattle-effects';\r\nimport { handleDeathrattles } from './deathrattle-orchestration';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { performEntitySpawns } from './spawns';\r\nimport { Spectator } from './spectator/spectator';\r\nimport { applyAfterStatsUpdate, modifyStats, setEntityStats } from './stats';\r\nimport { handleSummonsWhenSpace } from './summon-when-space';\r\nimport { makeMinionGolden } from './utils/golden';\r\n\r\n// TODO 20/04/2024: I'm not too sure about some ordering. The way I understand it, the Start of Combat has\r\n// multiple phases, and in each phase the player order is random\r\n// However, looking at http://replays.firestoneapp.com/?reviewId=a577602e-06f3-4c4b-928d-36ea98c2e6d5&turn=5&action=0,\r\n// it feels that a \"start of combat\" minion effect could trigger before an opponent's hero power effect\r\n// Or is that limited to Bru'kan?\r\n// I feel that I've asked a lot of questions recently, so I don't want to add that one to the list, as the interaction\r\n// is for now pretty marginal\r\nexport const handleStartOfCombat = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tconst shouldRecomputeCurrentAttacker = true;\r\n\tif (shouldRecomputeCurrentAttacker) {\r\n\t\tcurrentAttacker =\r\n\t\t\tplayerBoard.length > opponentBoard.length\r\n\t\t\t\t? 0\r\n\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t? 1\r\n\t\t\t\t: Math.round(Math.random());\r\n\t}\r\n\r\n\t// https://twitter.com/DCalkosz/status/1564705111850434561\r\n\tcurrentAttacker = handleStartOfCombatQuestRewards(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t);\r\n\tcurrentAttacker = handleStartOfCombatAnomalies(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t);\r\n\t// https://twitter.com/DCalkosz/status/1488361384320528388?s=20&t=1ECxRZFdjqwEa2fRsXk32Q\r\n\t// There’s a certain order for Start of Combat hero powers, rather than “coin flips” where\r\n\t// an unlucky trigger order could mess up some positioning you had planned for your own hero\r\n\t// power. “Precombat” (Al’Akir, Y’Shaarj), then Illidan, then others.\r\n\t// Update: this seems to have changed: https://x.com/LoewenMitchell/status/1737588920139825335?s=20\r\n\t// now you have all hero powers trigger in a first phase, then you have Illidan, and once everything has triggered, you have Tavish\r\n\tcurrentAttacker = handlePreCombatHeroPowers(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t);\r\n\t// Because start of combat powers like Red Whelp's use the board composition before Illidan's strike to know the amount of damage\r\n\tconst playerBoardBefore = playerBoard.map((e) => ({ ...e }));\r\n\tconst opponentBoardBefore = opponentBoard.map((e) => ({ ...e }));\r\n\tcurrentAttacker = handleIllidanHeroPowers(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t);\r\n\tcurrentAttacker = handleStartOfCombatHeroPowers(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t);\r\n\t// Timing confirmed by Mitchell on Discord on 2024-02-21\r\n\tcurrentAttacker = handleStartOfCombatSpells(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t);\r\n\t// Not sure if this can change who the first player will be\r\n\t// I don't have any official source on it at the moment, but there are some simulation\r\n\thandleStartOfCombatMinions(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tplayerBoardBefore,\r\n\t\topponentBoardBefore,\r\n\t\tgameState,\r\n\t);\r\n\tplayerEntity.startOfCombatDone = true;\r\n\topponentEntity.startOfCombatDone = true;\r\n\tapplyAfterStatsUpdate(gameState);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePreCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t} else {\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePreCombatHeroPowersForPlayer = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tif (playerEntity.startOfCombatDone || playerEntity.hpLeft <= 0) {\r\n\t\treturn currentAttacker;\r\n\t}\r\n\r\n\tlet shouldRecomputeCurrentAttacker = false;\r\n\t// Some are part of the incoming board: Y'Shaarj, Lich King, Ozumat\r\n\t// Since the order is not important here, we just always do the player first\r\n\tconst playerHeroPowerId = playerEntity.heroPowerId || getHeroPowerForHero(playerEntity.cardId);\r\n\tif (playerHeroPowerId === CardIds.SwattingInsects && playerBoard.length > 0) {\r\n\t\t// Should be sent by the app, but it is an idempotent operation, so we can just reapply it here\r\n\t\thandleAlakirForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.EarthInvocationToken) {\r\n\t\tapplyEarthInvocationEnchantment(playerBoard, null, playerEntity, gameState);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.WaterInvocationToken) {\r\n\t\tapplyWaterInvocationEnchantment(playerBoard, playerEntity, null, playerEntity, gameState);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.FireInvocationToken) {\r\n\t\tapplyFireInvocationEnchantment(playerBoard, playerEntity, null, playerEntity, gameState);\r\n\t} else if (playerHeroPowerId === CardIds.AllWillBurn) {\r\n\t\tapplyAllWillBurn(playerBoard, playerEntity, opponentBoard, opponentEntity, playerEntity, gameState);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.TamsinRoame_FragrantPhylactery) {\r\n\t\thandleTamsinForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t// Tamsin's hero power somehow happens before the current attacker is chosen.\r\n\t\t// See http://replays.firestoneapp.com/?reviewId=bce94e6b-c807-48e4-9c72-2c5c04421213&turn=6&action=9\r\n\t\t// Even worse: if a scallywag token pops, it attacks before the first attacker is recomputed\r\n\t\tshouldRecomputeCurrentAttacker = true;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.EmbraceYourRage) {\r\n\t\thandleEmbraceYourRageForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\tshouldRecomputeCurrentAttacker = true;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.RebornRites) {\r\n\t\thandleRebornRitesForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.TeronGorefiend_RapidReanimation) {\r\n\t\tshouldRecomputeCurrentAttacker = handleTeronForPlayer(\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\t// Same as Tamsin? No, because the new minion should repop automatically\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.WaxWarband) {\r\n\t\thandleWaxWarbandForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.LightningInvocationToken) {\r\n\t\tapplyLightningInvocationEnchantment(playerBoard, playerEntity, null, opponentBoard, opponentEntity, gameState);\r\n\t} else if (\r\n\t\tplayerEntity.heroPowerUsed &&\r\n\t\tplayerHeroPowerId === CardIds.FlobbidinousFloop_GloriousGloop_BGDUO_HERO_101p\r\n\t) {\r\n\t\tapplyGloriousGloop(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t}\r\n\r\n\tprocessMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\tif (shouldRecomputeCurrentAttacker) {\r\n\t\tcurrentAttacker =\r\n\t\t\tplayerBoard.length > opponentBoard.length\r\n\t\t\t\t? friendly\r\n\t\t\t\t\t? 0\r\n\t\t\t\t\t: 1\r\n\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t? friendly\r\n\t\t\t\t\t? 1\r\n\t\t\t\t\t: 0\r\n\t\t\t\t: Math.round(Math.random());\r\n\t}\r\n\r\n\treturn currentAttacker;\r\n};\r\n\r\nexport const handleIllidanHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\t// console.log('current attacker before', currentAttacker);\r\n\t// Apparently it's a toin coss about whether to handle Illidan first or Al'Akir first\r\n\t// Auras are only relevant for Illidan, and already applied there\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t} else {\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\tprocessMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatMinions = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tplayerBoardBefore: BoardEntity[],\r\n\topponentBoardBefore: BoardEntity[],\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tlet attackerForStart = Math.random() < 0.5 ? 0 : 1;\r\n\tconst playerAttackers = [...playerBoard];\r\n\tconst opponentAttackers = [...opponentBoard];\r\n\r\n\twhile (playerAttackers.length > 0 || opponentAttackers.length > 0) {\r\n\t\tlet shouldUpdateNextPlayer = false;\r\n\t\tif (attackerForStart === 0 && playerAttackers.length > 0) {\r\n\t\t\tconst attacker = playerAttackers.splice(0, 1)[0];\r\n\t\t\tif (attacker.health <= 0 || attacker.definitelyDead) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tshouldUpdateNextPlayer = performStartOfCombatMinionsForPlayer(\r\n\t\t\t\tattacker,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tplayerBoardBefore,\r\n\t\t\t\topponentBoardBefore,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t} else if (attackerForStart === 0 && playerAttackers.length === 0) {\r\n\t\t\tshouldUpdateNextPlayer = true;\r\n\t\t} else if (attackerForStart === 1 && opponentAttackers.length > 0) {\r\n\t\t\tconst attacker = opponentAttackers.splice(0, 1)[0];\r\n\t\t\tif (attacker.health <= 0 || attacker.definitelyDead) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tshouldUpdateNextPlayer = performStartOfCombatMinionsForPlayer(\r\n\t\t\t\tattacker,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoardBefore,\r\n\t\t\t\tplayerBoardBefore,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t} else if (attackerForStart === 1 && opponentAttackers.length === 0) {\r\n\t\t\tshouldUpdateNextPlayer = true;\r\n\t\t}\r\n\r\n\t\tif (shouldUpdateNextPlayer) {\r\n\t\t\tattackerForStart = (attackerForStart + 1) % 2;\r\n\t\t}\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatQuestRewards = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handleStartOfCombatQuestRewardsForPlayer(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t\tcurrentAttacker = handleStartOfCombatQuestRewardsForPlayer(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t\tfalse,\r\n\t\t);\r\n\t} else {\r\n\t\tcurrentAttacker = handleStartOfCombatQuestRewardsForPlayer(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t\tfalse,\r\n\t\t);\r\n\t\tcurrentAttacker = handleStartOfCombatQuestRewardsForPlayer(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t}\r\n\r\n\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatSpells = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handleStartOfCombatSpellsForPlayer(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tcurrentAttacker = handleStartOfCombatSpellsForPlayer(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t} else {\r\n\t\tcurrentAttacker = handleStartOfCombatSpellsForPlayer(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tcurrentAttacker = handleStartOfCombatSpellsForPlayer(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatAnomalies = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tcurrentAttacker = handleStartOfCombatAnomaliesForPlayer(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t);\r\n\tcurrentAttacker = handleStartOfCombatAnomaliesForPlayer(\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t);\r\n\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatQuestRewardsForPlayer = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n\tplayerIsFriendly: boolean,\r\n): number => {\r\n\tif (playerEntity.startOfCombatDone) {\r\n\t\treturn currentAttacker;\r\n\t}\r\n\r\n\tfor (const trinket of playerEntity.trinkets) {\r\n\t\tswitch (trinket.cardId) {\r\n\t\t\tcase CardIds.HolyMallet_BG30_MagicItem_902:\r\n\t\t\t\tif (playerBoard.length > 0) {\r\n\t\t\t\t\tupdateDivineShield(playerBoard[0], playerBoard, playerEntity, opponentEntity, true, gameState);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(playerEntity, playerBoard[0], playerBoard, null, null);\r\n\t\t\t\t\tif (playerBoard.length > 1) {\r\n\t\t\t\t\t\tupdateDivineShield(\r\n\t\t\t\t\t\t\tplayerBoard[playerBoard.length - 1],\r\n\t\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\t\tplayerBoard[playerBoard.length - 1],\r\n\t\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\t\tnull,\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.TrainingCertificate_BG30_MagicItem_962:\r\n\t\t\t\tif (playerBoard.length > 0) {\r\n\t\t\t\t\tconst minionsByAttack = [...playerBoard].sort((a, b) => a.attack - b.attack);\r\n\t\t\t\t\tconst firstTarget = minionsByAttack[0];\r\n\t\t\t\t\tsetEntityStats(\r\n\t\t\t\t\t\tfirstTarget,\r\n\t\t\t\t\t\t2 * firstTarget.maxAttack,\r\n\t\t\t\t\t\t2 * firstTarget.maxHealth,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (playerBoard.length > 1) {\r\n\t\t\t\t\t\tconst secondTarget = minionsByAttack[1];\r\n\t\t\t\t\t\tsetEntityStats(\r\n\t\t\t\t\t\t\tsecondTarget,\r\n\t\t\t\t\t\t\t2 * secondTarget.maxAttack,\r\n\t\t\t\t\t\t\t2 * secondTarget.maxHealth,\r\n\t\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\t\tplayerEntity,\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}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ValorousMedallion_BG30_MagicItem_970:\r\n\t\t\tcase CardIds.ValorousMedallion_ValorousMedallionToken_BG30_MagicItem_970t:\r\n\t\t\t\tconst medallionBuff = trinket.cardId === CardIds.ValorousMedallion_BG30_MagicItem_970 ? 2 : 5;\r\n\t\t\t\taddStatsToBoard(trinket, playerBoard, playerEntity, medallionBuff, medallionBuff, gameState);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.EmeraldDreamcatcher_BG30_MagicItem_542:\r\n\t\t\t\tconst highestAttack = Math.max(...playerBoard.map((entity) => entity.attack));\r\n\t\t\t\tplayerBoard\r\n\t\t\t\t\t.filter((e) => hasCorrectTribe(e, playerEntity, Race.DRAGON, gameState.allCards))\r\n\t\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\t\tsetEntityStats(e, highestAttack, null, playerBoard, playerEntity, gameState);\r\n\t\t\t\t\t});\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.JarredFrostling_BG30_MagicItem_952:\r\n\t\t\t\tconst elementals = shuffleArray(\r\n\t\t\t\t\tplayerBoard.filter((e) => hasCorrectTribe(e, playerEntity, Race.ELEMENTAL, gameState.allCards)),\r\n\t\t\t\t);\r\n\t\t\t\tconst targets = elementals.slice(0, 2);\r\n\t\t\t\ttargets.forEach((e) => {\r\n\t\t\t\t\te.enchantments = e.enchantments ?? [];\r\n\t\t\t\t\te.enchantments.push({\r\n\t\t\t\t\t\tcardId: CardIds.JarredFrostling_FrostyGlobeEnchantment_BG30_MagicItem_952e,\r\n\t\t\t\t\t\toriginEntityId: trinket.entityId,\r\n\t\t\t\t\t\trepeats: 1,\r\n\t\t\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t\t\t});\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(playerEntity, e, playerBoard, null, null);\r\n\t\t\t\t});\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.RustyTrident_BG30_MagicItem_917:\r\n\t\t\t\tplayerBoard\r\n\t\t\t\t\t.filter((e) => hasCorrectTribe(e, playerEntity, Race.NAGA, gameState.allCards))\r\n\t\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\t\te.enchantments = e.enchantments ?? [];\r\n\t\t\t\t\t\te.enchantments.push({\r\n\t\t\t\t\t\t\tcardId: CardIds.RustyTrident_TridentsTreasureEnchantment_BG30_MagicItem_917e,\r\n\t\t\t\t\t\t\toriginEntityId: trinket.entityId,\r\n\t\t\t\t\t\t\trepeats: 1,\r\n\t\t\t\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t});\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.HoggyBank_BG30_MagicItem_411:\r\n\t\t\t\tplayerBoard\r\n\t\t\t\t\t.filter((e) => hasCorrectTribe(e, playerEntity, Race.QUILBOAR, gameState.allCards))\r\n\t\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\t\te.enchantments = e.enchantments ?? [];\r\n\t\t\t\t\t\te.enchantments.push({\r\n\t\t\t\t\t\t\tcardId: CardIds.HoggyBank_GemInTheBankEnchantment_BG30_MagicItem_411e,\r\n\t\t\t\t\t\t\toriginEntityId: trinket.entityId,\r\n\t\t\t\t\t\t\trepeats: 1,\r\n\t\t\t\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t});\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.AutomatonPortrait_BG30_MagicItem_303:\r\n\t\t\t\tif (playerBoard.length < 7) {\r\n\t\t\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\t\t\tCardIds.AstralAutomaton_BG_TTN_401,\r\n\t\t\t\t\t\t1,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tperformEntitySpawns(\r\n\t\t\t\t\t\tnewMinions,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\t0,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState,\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.ShipInABottle_BG30_MagicItem_407:\r\n\t\t\t\tif (playerBoard.length < 7) {\r\n\t\t\t\t\tconst target = pickRandom(gameState.cardsData.pirateSpawns);\r\n\t\t\t\t\taddCardsInHand(playerEntity, playerBoard, [target], gameState);\r\n\t\t\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t1,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tconst spawns = performEntitySpawns(\r\n\t\t\t\t\t\tnewMinions,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\t0,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tspawns.forEach((spawn) => (spawn.attackImmediately = true));\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.EternalPortrait_BG30_MagicItem_301:\r\n\t\t\t\tplayerBoard\r\n\t\t\t\t\t.filter(\r\n\t\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\t\te.cardId === CardIds.EternalKnight_BG25_008 ||\r\n\t\t\t\t\t\t\te.cardId === CardIds.EternalKnight_BG25_008_G,\r\n\t\t\t\t\t)\r\n\t\t\t\t\t.forEach((knight) => {\r\n\t\t\t\t\t\tknight.taunt = true;\r\n\t\t\t\t\t\tknight.reborn = true;\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(playerEntity, knight, playerBoard, null, null);\r\n\t\t\t\t\t});\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.TwinSkyLanterns_BG30_MagicItem_822:\r\n\t\t\tcase CardIds.TwinSkyLanterns_TwinSkyLanternsToken_BG30_MagicItem_822t2:\r\n\t\t\t\ttrinket.rememberedMinion = null;\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ArtisanalUrn_BG30_MagicItem_989:\r\n\t\t\tcase CardIds.ArtisanalUrn_ArtisanalUrnToken_BG30_MagicItem_989t:\r\n\t\t\t\tconst artisanalUrnBuff = trinket.cardId === CardIds.ArtisanalUrn_BG30_MagicItem_989 ? 3 : 7;\r\n\t\t\t\tplayerEntity.globalInfo.UndeadAttackBonus =\r\n\t\t\t\t\t(playerEntity.globalInfo.UndeadAttackBonus ?? 0) + artisanalUrnBuff;\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.RivendarePortrait_BG30_MagicItem_310:\r\n\t\t\t\tplayerBoard\r\n\t\t\t\t\t.filter(\r\n\t\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\t\te.cardId === CardIds.TitusRivendare_BG25_354 ||\r\n\t\t\t\t\t\t\te.cardId === CardIds.TitusRivendare_BG25_354_G,\r\n\t\t\t\t\t)\r\n\t\t\t\t\t.forEach((e) => (e.stealth = true));\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.TinyfinOnesie_BG30_MagicItem_441:\r\n\t\t\t\tconst highestHealthMinionInHand = playerEntity.hand?.sort((a, b) => b.health - a.health)[0];\r\n\t\t\t\tif (highestHealthMinionInHand && playerBoard.length > 0) {\r\n\t\t\t\t\tmodifyStats(\r\n\t\t\t\t\t\tplayerBoard[0],\r\n\t\t\t\t\t\thighestHealthMinionInHand.attack,\r\n\t\t\t\t\t\thighestHealthMinionInHand.health,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\tgameState,\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.BronzeTimepiece_BG30_MagicItem_995:\r\n\t\t\t\tif (playerBoard.length > 0) {\r\n\t\t\t\t\tplayerBoard.forEach((entity) => {\r\n\t\t\t\t\t\tconst highest = Math.max(entity.attack, entity.health);\r\n\t\t\t\t\t\tsetEntityStats(entity, highest, highest, playerBoard, playerEntity, gameState);\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(trinket, entity, playerBoard, null, null);\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.IronforgeAnvil_BG30_MagicItem_403:\r\n\t\t\t\tif (playerBoard.length > 0) {\r\n\t\t\t\t\tplayerBoard\r\n\t\t\t\t\t\t.filter((e) => getEffectiveTribesForEntity(e, playerEntity, gameState.allCards).length === 0)\r\n\t\t\t\t\t\t.forEach((entity) => {\r\n\t\t\t\t\t\t\tsetEntityStats(\r\n\t\t\t\t\t\t\t\tentity,\r\n\t\t\t\t\t\t\t\t3 * entity.attack,\r\n\t\t\t\t\t\t\t\t3 * entity.health,\r\n\t\t\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\t\t\tplayerEntity,\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(trinket, entity, playerBoard, null, null);\r\n\t\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.KarazhanChessSet_BG30_MagicItem_972:\r\n\t\t\t\tif (playerBoard.length > 0) {\r\n\t\t\t\t\tfor (let i = 0; i < Math.min(playerBoard.length, 7); i++) {\r\n\t\t\t\t\t\tconst entityToCoy = playerBoard[i];\r\n\t\t\t\t\t\tconst copy: BoardEntity = copyEntity(entityToCoy);\r\n\t\t\t\t\t\tremoveAurasFromSelf(copy, playerBoard, playerEntity, gameState);\r\n\t\t\t\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\t\t\t\tcopy.cardId,\r\n\t\t\t\t\t\t\t1,\r\n\t\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\t\tcopy,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tconst spawns = performEntitySpawns(\r\n\t\t\t\t\t\t\tnewMinions,\r\n\t\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\t\tplayerBoard.length - i - 1,\r\n\t\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\t\topponentEntity,\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// TODO: according to http://replays.firestoneapp.com/?reviewId=576aa3bb-caa1-4e46-9d16-08a001fdd941&turn=23&action=3\r\n\t\t\t\t\t\t// it looks like the stats are simply copied from the original entity to the copy, instead\r\n\t\t\t\t\t\t// of summoning a copy and applying all the auras stuff\r\n\t\t\t\t\t\t// I've asked on Discord (2024-08-21) for clarification\r\n\t\t\t\t\t\ti += spawns.length;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tcurrentAttacker =\r\n\t\t\t\t\tplayerBoard.length > opponentBoard.length\r\n\t\t\t\t\t\t? playerIsFriendly\r\n\t\t\t\t\t\t\t? 0\r\n\t\t\t\t\t\t\t: 1\r\n\t\t\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t\t\t? playerIsFriendly\r\n\t\t\t\t\t\t\t? 1\r\n\t\t\t\t\t\t\t: 0\r\n\t\t\t\t\t\t: Math.round(Math.random());\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.FishySticker_BG30_MagicItem_821:\r\n\t\t\tcase CardIds.FishySticker_FishyStickerToken_BG30_MagicItem_821t2:\r\n\t\t\t\tif (playerBoard.length < 7) {\r\n\t\t\t\t\tconst spawnId =\r\n\t\t\t\t\t\ttrinket.cardId === CardIds.FishySticker_BG30_MagicItem_821\r\n\t\t\t\t\t\t\t? CardIds.AvatarOfNzoth_FishOfNzothToken\r\n\t\t\t\t\t\t\t: CardIds.FishOfNzoth;\r\n\t\t\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\t\t\tspawnId,\r\n\t\t\t\t\t\t1,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tconst spawns = performEntitySpawns(\r\n\t\t\t\t\t\tnewMinions,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\t0,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tcurrentAttacker =\r\n\t\t\t\t\t\tplayerBoard.length > opponentBoard.length\r\n\t\t\t\t\t\t\t? playerIsFriendly\r\n\t\t\t\t\t\t\t\t? 0\r\n\t\t\t\t\t\t\t\t: 1\r\n\t\t\t\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t\t\t\t? playerIsFriendly\r\n\t\t\t\t\t\t\t\t? 1\r\n\t\t\t\t\t\t\t\t: 0\r\n\t\t\t\t\t\t\t: Math.round(Math.random());\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const reward of playerEntity.questRewards) {\r\n\t\tswitch (reward) {\r\n\t\t\tcase CardIds.EvilTwin:\r\n\t\t\t\tif (!!playerBoard.length && playerBoard.length < 7) {\r\n\t\t\t\t\tconst highestHealthMinion = [...playerBoard].sort((a, b) => b.health - a.health)[0];\r\n\t\t\t\t\tconst copy: BoardEntity = {\r\n\t\t\t\t\t\t...highestHealthMinion,\r\n\t\t\t\t\t\tlastAffectedByEntity: null,\r\n\t\t\t\t\t};\r\n\t\t\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\t\t\tcopy.cardId,\r\n\t\t\t\t\t\t1,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\t\thighestHealthMinion.friendly,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\tcopy,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tconst indexFromRight = playerBoard.length - (playerBoard.indexOf(highestHealthMinion) + 1);\r\n\t\t\t\t\tperformEntitySpawns(\r\n\t\t\t\t\t\tnewMinions,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\thighestHealthMinion,\r\n\t\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(playerEntity, copy, playerBoard, null, null);\r\n\t\t\t\t\t// Recompute first attacker\r\n\t\t\t\t\t// See https://replays.firestoneapp.com/?reviewId=93229c4a-d864-4196-83dd-2fea2a5bf70a&turn=29&action=0\r\n\t\t\t\t\tcurrentAttacker =\r\n\t\t\t\t\t\tplayerBoard.length > opponentBoard.length\r\n\t\t\t\t\t\t\t? playerIsFriendly\r\n\t\t\t\t\t\t\t\t? 0\r\n\t\t\t\t\t\t\t\t: 1\r\n\t\t\t\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t\t\t\t? playerIsFriendly\r\n\t\t\t\t\t\t\t\t? 1\r\n\t\t\t\t\t\t\t\t: 0\r\n\t\t\t\t\t\t\t: Math.round(Math.random());\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.StaffOfOrigination_BG24_Reward_312:\r\n\t\t\t\tplayerBoard.forEach((entity) => {\r\n\t\t\t\t\tmodifyStats(entity, 15, 15, playerBoard, playerEntity, gameState);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(playerEntity, entity, playerBoard, null, null);\r\n\t\t\t\t});\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.StolenGold:\r\n\t\t\t\tif (playerBoard.length > 0) {\r\n\t\t\t\t\tmakeMinionGolden(\r\n\t\t\t\t\t\tplayerBoard[0],\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tif (playerBoard.length > 1) {\r\n\t\t\t\t\tmakeMinionGolden(\r\n\t\t\t\t\t\tplayerBoard[playerBoard.length - 1],\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatSpellsForPlayer = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tif (playerEntity.startOfCombatDone) {\r\n\t\treturn currentAttacker;\r\n\t}\r\n\tif (!playerEntity.secrets?.length) {\r\n\t\treturn currentAttacker;\r\n\t}\r\n\tfor (const secret of playerEntity.secrets) {\r\n\t\tswitch (secret.cardId) {\r\n\t\t\tcase CardIds.UpperHand_BG28_573:\r\n\t\t\t\tif (!!opponentBoard.length) {\r\n\t\t\t\t\tconst target = pickRandom(opponentBoard);\r\n\t\t\t\t\ttarget.health = 1;\r\n\t\t\t\t\ttarget.maxHealth = 1;\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(playerEntity, target, opponentBoard, null, null);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.BoonOfBeetles_BG28_603:\r\n\t\t\t\tsecret.scriptDataNum1 = 1;\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.FleetingVigor_BG28_519:\r\n\t\t\t\taddStatsToBoard(secret, playerBoard, playerEntity, 2, 1, gameState);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ToxicTumbleweed_BG28_641:\r\n\t\t\t\tif (playerBoard.length < 7) {\r\n\t\t\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\t\t\tCardIds.ToxicTumbleweed_TumblingAssassinToken_BG28_641t,\r\n\t\t\t\t\t\t1,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tnewMinions[0].attackImmediately = true;\r\n\t\t\t\t\tperformEntitySpawns(\r\n\t\t\t\t\t\tnewMinions,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\t0,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatAnomaliesForPlayer = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tif (!gameState.anomalies?.length || playerEntity.startOfCombatDone) {\r\n\t\treturn currentAttacker;\r\n\t}\r\n\tfor (const anomaly of gameState.anomalies) {\r\n\t\tswitch (anomaly) {\r\n\t\t\tcase CardIds.BlessedOrBlighted_BG27_Anomaly_726:\r\n\t\t\t\tif (playerBoard.length > 0) {\r\n\t\t\t\t\tconst dsTarget = playerBoard[0];\r\n\t\t\t\t\tupdateDivineShield(dsTarget, playerBoard, playerEntity, opponentEntity, true, gameState);\r\n\t\t\t\t\tconst rebornTarget = playerBoard[playerBoard.length - 1];\r\n\t\t\t\t\trebornTarget.reborn = true;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.AnomalousTwin_BG27_Anomaly_560:\r\n\t\t\t\tif (!!playerBoard.length && playerBoard.length < 7) {\r\n\t\t\t\t\tconst highestHealthMinion = [...playerBoard].sort((a, b) => b.health - a.health)[0];\r\n\t\t\t\t\tconst copy: BoardEntity = {\r\n\t\t\t\t\t\t...highestHealthMinion,\r\n\t\t\t\t\t\tlastAffectedByEntity: null,\r\n\t\t\t\t\t};\r\n\t\t\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\t\t\tcopy.cardId,\r\n\t\t\t\t\t\t1,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\t\thighestHealthMinion.friendly,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\tcopy,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tconst indexFromRight = playerBoard.length - (playerBoard.indexOf(highestHealthMinion) + 1);\r\n\t\t\t\t\tperformEntitySpawns(\r\n\t\t\t\t\t\tnewMinions,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\thighestHealthMinion,\r\n\t\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(playerEntity, copy, playerBoard, null, null);\r\n\t\t\t\t}\r\n\t\t\t\t// Recompute first attacker\r\n\t\t\t\t// See https://replays.firestoneapp.com/?reviewId=93229c4a-d864-4196-83dd-2fea2a5bf70a&turn=29&action=0\r\n\t\t\t\treturn playerBoard.length > opponentBoard.length\r\n\t\t\t\t\t? 0\r\n\t\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t\t? 1\r\n\t\t\t\t\t: Math.round(Math.random());\r\n\t\t}\r\n\t}\r\n\r\n\treturn currentAttacker;\r\n};\r\n\r\nexport const handleStartOfCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\t// Apparently it's a toin coss about whether to handle Illidan first or Al'Akir first\r\n\t// Auras are only relevant for Illidan, and already applied there\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t} else {\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePlayerIllidanHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tif (playerEntity.hpLeft <= 0) {\r\n\t\treturn currentAttacker;\r\n\t}\r\n\tconst playerHeroPowerId = playerEntity.heroPowerId || getHeroPowerForHero(playerEntity.cardId);\r\n\tif (playerHeroPowerId === CardIds.Wingmen && playerBoard.length > 0) {\r\n\t\t// After Illidan triggers, it's always the other opponent's turn\r\n\t\t// https://x.com/LoewenMitchell/status/1752714583360639131?s=20\r\n\t\thandleIllidanForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState, currentAttacker);\r\n\t\tcurrentAttacker = friendly ? 1 : 0;\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\n// TODO: not exactly correct, because of \"attack immediately\", but it's close enough\r\nconst handleIllidanForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tcurrentAttacker: number,\r\n): void => {\r\n\tif (playerEntity.startOfCombatDone) {\r\n\t\treturn;\r\n\t}\r\n\t// Otherwise, if the first minion dies on the attack, and the board has only 2 minions, we\r\n\t// miss the second one\r\n\tconst minionsAtStart = playerBoard.length;\r\n\tconst firstAttacker = playerBoard[0];\r\n\tconst secondAttacker = minionsAtStart > 1 ? playerBoard[playerBoard.length - 1] : null;\r\n\r\n\t// Stats updates\r\n\tmodifyStats(firstAttacker, 2, 1, playerBoard, playerEntity, gameState);\r\n\tgameState.spectator.registerPowerTarget(firstAttacker, firstAttacker, playerBoard, playerEntity, opponentEntity);\r\n\tif (!!secondAttacker && !secondAttacker.definitelyDead && secondAttacker.health > 0) {\r\n\t\tmodifyStats(secondAttacker, 2, 1, playerBoard, playerEntity, gameState);\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tsecondAttacker,\r\n\t\t\tsecondAttacker,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentEntity,\r\n\t\t);\r\n\t}\r\n\r\n\t// Attacks\r\n\tfirstAttacker.attackImmediately = true;\r\n\tsimulateAttack(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t// See http://replays.firestoneapp.com/?reviewId=f16b7a49-c2a2-4ac5-a9eb-a75f83246f70&turn=6&action=8\r\n\tfirstAttacker.hasAttacked = 0;\r\n\tif (!!secondAttacker && !secondAttacker.definitelyDead && secondAttacker.health > 0) {\r\n\t\tsecondAttacker.attackImmediately = true;\r\n\t\tsimulateAttack(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\tsecondAttacker.hasAttacked = 0;\r\n\t}\r\n\r\n\t// // See http://replays.firestoneapp.com/?reviewId=7e9ec42c-a8f6-43d2-9f39-cc486dfa2395&turn=6&action=5\r\n\t// if (firstAttacker.definitelyDead || firstAttacker.health <= 0) {\r\n\t// \tcurrentAttacker = (currentAttacker + 1) % 2;\r\n\t// }\r\n\t// return currentAttacker;\r\n};\r\n\r\nconst handleAlakirForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst firstEntity = playerBoard[0];\r\n\tfirstEntity.windfury = true;\r\n\tif (!firstEntity.divineShield) {\r\n\t\tupdateDivineShield(firstEntity, playerBoard, playerEntity, opponentEntity, true, gameState);\r\n\t}\r\n\tfirstEntity.taunt = true;\r\n\tgameState.spectator.registerPowerTarget(firstEntity, firstEntity, playerBoard, playerEntity, opponentEntity);\r\n};\r\n\r\nconst handleTamsinForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst chosenEntity = pickRandomLowestHealth(playerBoard);\r\n\tif (!chosenEntity) {\r\n\t\tconsole.warn('could not pick any entity for tamsin');\r\n\t\treturn;\r\n\t}\r\n\tgameState.spectator.registerPowerTarget(playerEntity, chosenEntity, playerBoard, null, null);\r\n\tconst newBoard = playerBoard.filter((e) => e.entityId !== chosenEntity.entityId);\r\n\t// How to mark the minion as dead\r\n\tchosenEntity.definitelyDead = true;\r\n\tnewBoard.forEach((e) => {\r\n\t\tmodifyStats(e, chosenEntity.attack, chosenEntity.health, newBoard, playerEntity, gameState);\r\n\t\tgameState.spectator.registerPowerTarget(chosenEntity, e, newBoard, playerEntity, opponentEntity);\r\n\t});\r\n};\r\n\r\nconst applyGloriousGloop = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (!playerBoard?.length) {\r\n\t\treturn;\r\n\t}\r\n\tconst target = playerBoard.find((m) =>\r\n\t\tm.enchantments?.some((e) => e.cardId === CardIds.GloriousGloop_InTheGloopEnchantment_BGDUO_HERO_101pe2),\r\n\t);\r\n\tif (!target) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst teammateState = getTeammateInitialState(gameState.gameState, playerEntity);\r\n\tif (!teammateState?.board?.length) {\r\n\t\treturn;\r\n\t}\r\n\tconst highestTier = Math.max(\r\n\t\t...teammateState.board.map((entity) => gameState.allCards.getCard(entity.cardId).techLevel),\r\n\t);\r\n\tconst candidates = teammateState.board.filter(\r\n\t\t(entity) => gameState.allCards.getCard(entity.cardId).techLevel === highestTier,\r\n\t);\r\n\tif (!candidates.length) {\r\n\t\treturn;\r\n\t}\r\n\tconst highestTierMinion = pickRandom(candidates);\r\n\tconst clone: BoardEntity = addImpliedMechanics(\r\n\t\t{\r\n\t\t\t...highestTierMinion,\r\n\t\t\tlastAffectedByEntity: null,\r\n\t\t\tdefinitelyDead: false,\r\n\t\t\tattackImmediately: false,\r\n\t\t},\r\n\t\tgameState.cardsData,\r\n\t);\r\n\tgameState.spectator.registerPowerTarget(playerEntity, target, playerBoard, playerEntity, opponentEntity);\r\n\t// Replace the \"target\" minion with the \"clone\"\r\n\tconst index = playerBoard.indexOf(target);\r\n\tplayerBoard.splice(index, 1, clone);\r\n};\r\n\r\nconst handleEmbraceYourRageForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst createdCardId = playerEntity.heroPowerInfo as string;\r\n\tif (!createdCardId?.length) {\r\n\t\t// console.warn('no card id for embrace your rage');\r\n\t\treturn;\r\n\t}\r\n\tconst spawns = spawnEntities(\r\n\t\tcreatedCardId,\r\n\t\t1,\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tgameState.allCards,\r\n\t\tgameState.cardsData,\r\n\t\tgameState.sharedState,\r\n\t\tgameState.spectator,\r\n\t\tplayerEntity.friendly,\r\n\t\ttrue,\r\n\t\tfalse,\r\n\t\tfalse,\r\n\t);\r\n\tconst indexFromRight = 0;\r\n\tperformEntitySpawns(\r\n\t\tspawns,\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\tplayerEntity,\r\n\t\tindexFromRight,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tgameState,\r\n\t);\r\n\tgameState.spectator.registerPowerTarget(playerEntity, spawns[0], playerBoard, playerEntity, opponentEntity);\r\n\taddCardsInHand(playerEntity, playerBoard, spawns, gameState);\r\n\tgameState.spectator.registerPowerTarget(playerEntity, spawns[0], playerBoard, playerEntity, opponentEntity);\r\n};\r\n\r\nconst handleRebornRitesForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst targetEntityId = playerEntity.heroPowerInfo as number;\r\n\tconst target = playerBoard.find((entity) => entity.entityId === targetEntityId);\r\n\tif (!target) {\r\n\t\treturn;\r\n\t}\r\n\r\n\ttarget.reborn = true;\r\n\tgameState.spectator.registerPowerTarget(playerEntity, target, playerBoard, playerEntity, opponentEntity);\r\n};\r\n\r\nconst handleTeronForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): boolean => {\r\n\t// Getting the right enchantment can be tricky. The RapidReanimation enchantment can sometimes be\r\n\t// in the Graveyard zone, so we can't filter them out. In that case, we can have multiple\r\n\t// enchantments\r\n\t// However, because of how things are handled in the logs, we should be able to always take the one *\r\n\t// with the biggest entityId\r\n\tconst minionThatWillDie = playerBoard\r\n\t\t.filter((m) => m.enchantments.some((e) => e.cardId === CardIds.RapidReanimation_ImpendingDeathEnchantment))\r\n\t\t.sort(\r\n\t\t\t(a, b) =>\r\n\t\t\t\tb.enchantments.find((e) => e.cardId === CardIds.RapidReanimation_ImpendingDeathEnchantment)\r\n\t\t\t\t\t.originEntityId -\r\n\t\t\t\t\ta.enchantments.find((e) => e.cardId === CardIds.RapidReanimation_ImpendingDeathEnchantment)\r\n\t\t\t\t\t\t.originEntityId || b.entityId - a.entityId,\r\n\t\t)[0];\r\n\tif (minionThatWillDie) {\r\n\t\t// So this is a bit tricky (as all the stuff with indices...). Because in practice it's more likely that players use Rapid Reanimation\r\n\t\t// on minions that they want to die quickly, most of the time they will be placed\r\n\t\t// to the left of the board\r\n\t\t// So using a left-based index (usually 0) is more likely to be correct after minions spawn on the board\r\n\t\t// Update: this looks like it's not the case, and looking at\r\n\t\t// http://replays.firestoneapp.com/?reviewId=2e6b389f-d904-43a2-a7cd-928a60d973ce&turn=11&action=1\r\n\t\t// the index seems to be right-based at least in some cases\r\n\t\t// Looks like even this is wrong:\r\n\t\t// http://replays.firestoneapp.com/?reviewId=9a46ab39-ccf0-478c-a010-68f2abb06c6f&turn=9&action=0\r\n\t\tconst rapidReanimationIndexFromLeft = playerBoard.indexOf(minionThatWillDie);\r\n\t\tplayerEntity.rapidReanimationIndexFromRight = playerBoard.length - 1 - rapidReanimationIndexFromLeft;\r\n\t\tconst minionToCopy = {\r\n\t\t\t...minionThatWillDie,\r\n\t\t\tenchantments: minionThatWillDie.enchantments.map((e) => ({ ...e })) ?? [],\r\n\t\t\tpendingAttackBuffs: [],\r\n\t\t} as BoardEntity;\r\n\t\tremoveAurasFromSelf(minionToCopy, playerBoard, playerEntity, gameState);\r\n\t\tplayerEntity.rapidReanimationMinion = minionToCopy;\r\n\t\tminionThatWillDie.definitelyDead = true;\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tplayerEntity,\r\n\t\t\tminionThatWillDie,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentEntity,\r\n\t\t);\r\n\t\treturn true;\r\n\t}\r\n\treturn false;\r\n};\r\n\r\nconst handleWaxWarbandForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (playerBoard.length > 0) {\r\n\t\tconst boardWithTribes = playerBoard.filter(\r\n\t\t\t(e) => !!getEffectiveTribesForEntity(e, playerEntity, gameState.allCards).length,\r\n\t\t);\r\n\t\tconst boardWithoutAll = boardWithTribes.filter(\r\n\t\t\t(e) => !gameState.allCards.getCard(e.cardId).races?.includes(Race[Race.ALL]),\r\n\t\t);\r\n\t\tconst selectedMinions = selectMinions(boardWithoutAll, ALL_BG_RACES, gameState.allCards);\r\n\t\tconst allMinions = [\r\n\t\t\t...selectedMinions,\r\n\t\t\t...boardWithTribes.filter((e) => gameState.allCards.getCard(e.cardId).races?.includes(Race[Race.ALL])),\r\n\t\t];\r\n\t\tallMinions.forEach((e) => {\r\n\t\t\tmodifyStats(\r\n\t\t\t\te,\r\n\t\t\t\tgameState.cardsData.getTavernLevel(e.cardId),\r\n\t\t\t\tgameState.cardsData.getTavernLevel(e.cardId),\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(playerEntity, e, playerBoard, playerEntity, opponentEntity);\r\n\t\t});\r\n\t}\r\n};\r\n\r\n// Not perfect, as I don't think this solves the issue where some cards are mutually exclusive\r\nconst selectMinions = (minions: BoardEntity[], tribes: Race[], allCards: AllCardsService): BoardEntity[] => {\r\n\t// Step 1\r\n\tconst minionsByTribe: { [tribe: string]: BoardEntity[] } = {};\r\n\tfor (const minion of minions) {\r\n\t\tfor (const tribe of allCards.getCard(minion.cardId).races ?? []) {\r\n\t\t\tif (!minionsByTribe[tribe]) {\r\n\t\t\t\tminionsByTribe[tribe] = [];\r\n\t\t\t}\r\n\t\t\tminionsByTribe[tribe].push(minion);\r\n\t\t}\r\n\t}\r\n\tfor (const tribe of ALL_BG_RACES) {\r\n\t\tminionsByTribe[tribe] = shuffleArray(minionsByTribe[Race[tribe]] ?? []);\r\n\t}\r\n\r\n\tconst selectedMinions: BoardEntity[] = [];\r\n\r\n\t// Step 3\r\n\tfor (const tribe of tribes) {\r\n\t\tif (minionsByTribe[tribe]) {\r\n\t\t\tminionsByTribe[tribe].sort(\r\n\t\t\t\t(a, b) => allCards.getCard(a.cardId).races.length - allCards.getCard(b.cardId).races.length,\r\n\t\t\t);\r\n\t\t\tfor (const minion of minionsByTribe[tribe]) {\r\n\t\t\t\tif (!selectedMinions.includes(minion)) {\r\n\t\t\t\t\tselectedMinions.push(minion);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Step 4\r\n\treturn selectedMinions;\r\n};\r\n\r\nconst handlePlayerStartOfCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tif (playerEntity.startOfCombatDone || playerEntity.hpLeft <= 0) {\r\n\t\treturn currentAttacker;\r\n\t}\r\n\t// eslint-disable-next-line prefer-const\r\n\tlet shouldRecomputeCurrentAttacker = false;\r\n\tconst playerHeroPowerId = playerEntity.heroPowerId || getHeroPowerForHero(playerEntity.cardId);\r\n\t// TODO: should this recompute the first attack order?\r\n\tif (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimLeftToken) {\r\n\t\tconst target = opponentBoard[0];\r\n\t\tconst damageDone = dealDamageToMinion(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo2 ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimRightToken) {\r\n\t\tconst target = opponentBoard[opponentBoard.length - 1];\r\n\t\tconst damageDone = dealDamageToMinion(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo2 ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimLowToken) {\r\n\t\tconst smallestHealthMinion = [...opponentBoard].sort((a, b) => a.health - b.health)[0];\r\n\t\tconst target = pickRandom(opponentBoard.filter((e) => e.health === smallestHealthMinion.health));\r\n\t\tconst damageDone = dealDamageToMinion(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo2 ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimHighToken) {\r\n\t\tconst highestHealthMinion = [...opponentBoard].sort((a, b) => b.health - a.health)[0];\r\n\t\tconst target = pickRandom(opponentBoard.filter((e) => e.health === highestHealthMinion.health));\r\n\t\tconst damageDone = dealDamageToMinion(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo2 ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t}\r\n\tprocessMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\tif (shouldRecomputeCurrentAttacker) {\r\n\t\tconst previousCurrentAttacker = currentAttacker;\r\n\t\tcurrentAttacker =\r\n\t\t\tplayerBoard.length > opponentBoard.length\r\n\t\t\t\t? friendly\r\n\t\t\t\t\t? 0\r\n\t\t\t\t\t: 1\r\n\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t? friendly\r\n\t\t\t\t\t? 1\r\n\t\t\t\t\t: 0\r\n\t\t\t\t: currentAttacker;\r\n\t\t// console.debug(\r\n\t\t// \t'recompting current attacker',\r\n\t\t// \tcurrentAttacker,\r\n\t\t// \tplayerBoard.length,\r\n\t\t// \topponentBoard.length,\r\n\t\t// \tpreviousCurrentAttacker,\r\n\t\t// \tstringifySimple(playerBoard, allCards),\r\n\t\t// \tstringifySimple(opponentBoard, allCards),\r\n\t\t// );\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\nexport const getHeroPowerForHero = (heroCardId: string): string => {\r\n\tswitch (heroCardId) {\r\n\t\tcase CardIds.IllidanStormrage_TB_BaconShop_HERO_08:\r\n\t\t\treturn CardIds.Wingmen;\r\n\t\tcase CardIds.TheLichKing_TB_BaconShop_HERO_22:\r\n\t\t\treturn CardIds.RebornRites;\r\n\t\tcase CardIds.ProfessorPutricide_BG25_HERO_100:\r\n\t\t\treturn CardIds.RagePotion;\r\n\t\tcase CardIds.Deathwing_TB_BaconShop_HERO_52:\r\n\t\t\treturn CardIds.AllWillBurn;\r\n\t\tcase CardIds.TeronGorefiend_BG25_HERO_103:\r\n\t\t\treturn CardIds.TeronGorefiend_RapidReanimation;\r\n\t}\r\n\treturn null;\r\n};\r\n\r\nexport const performStartOfCombatMinionsForPlayer = (\r\n\tattacker: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\t// Apparently, the board composition used for start of combat minion effects (like Red Whelp, and I assume it works the\r\n\t// same way for others like Prized Promo Drake or Mantid Queen) is the one that is used before Illidan's effect is handled.\r\n\t// Since this also runs before HP start of combat, we probably also use the state as it was before HP were triggered, like\r\n\t// Tamsin's Phylactery.\r\n\tattackingBoardBefore: BoardEntity[],\r\n\tdefendingBoardBefore: BoardEntity[],\r\n\tgameState: FullGameState,\r\n): boolean => {\r\n\tif (attackingBoardHero.startOfCombatDone) {\r\n\t\treturn false;\r\n\t}\r\n\tlet hasProcessed = true;\r\n\tif (attacker.cardId === CardIds.RedWhelp_BGS_019) {\r\n\t\tconst damage = attackingBoardBefore.filter((entity) =>\r\n\t\t\thasCorrectTribe(entity, attackingBoardHero, Race.DRAGON, gameState.allCards),\r\n\t\t).length;\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tattacker,\r\n\t\t\tdamage,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t} else if (attacker.cardId === CardIds.RedWhelp_TB_BaconUps_102) {\r\n\t\tconst damage = attackingBoardBefore.filter((entity) =>\r\n\t\t\thasCorrectTribe(entity, attackingBoardHero, Race.DRAGON, gameState.allCards),\r\n\t\t).length;\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tattacker,\r\n\t\t\tdamage,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tattacker,\r\n\t\t\tdamage,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.PrizedPromoDrake_BG21_014 ||\r\n\t\tattacker.cardId === CardIds.PrizedPromoDrake_BG21_014_G\r\n\t) {\r\n\t\tconst stats = attacker.cardId === CardIds.PrizedPromoDrake_BG21_014_G ? 6 : 3;\r\n\t\tconst targets = attackingBoard\r\n\t\t\t.filter((e) => e.entityId !== attacker.entityId)\r\n\t\t\t.filter((e) => hasCorrectTribe(e, attackingBoardHero, Race.DRAGON, gameState.allCards));\r\n\t\tfor (const entity of targets) {\r\n\t\t\tmodifyStats(entity, stats, stats, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tattacker,\r\n\t\t\t\tentity,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t);\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.ChoralMrrrglr_BG26_354 ||\r\n\t\tattacker.cardId === CardIds.ChoralMrrrglr_BG26_354_G\r\n\t) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.ChoralMrrrglr_BG26_354_G ? 2 : 1;\r\n\t\tmodifyStats(\r\n\t\t\tattacker,\r\n\t\t\tmultiplier * attackingBoardHero.globalInfo?.ChoralAttackBuff,\r\n\t\t\tmultiplier * attackingBoardHero.globalInfo?.ChoralHealthBuff,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tattacker,\r\n\t\t\tattacker,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoardHero,\r\n\t\t);\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.AmberGuardian_BG24_500 ||\r\n\t\tattacker.cardId === CardIds.AmberGuardian_BG24_500_G\r\n\t) {\r\n\t\t// First try to get a target without divine shield, and if none is available, pick one with divine shield\r\n\t\tconst otherDragons = attackingBoard\r\n\t\t\t.filter((e) => hasCorrectTribe(e, attackingBoardHero, Race.DRAGON, gameState.allCards))\r\n\t\t\t.filter((e) => e.entityId !== attacker.entityId);\r\n\t\tconst loops = attacker.cardId === CardIds.AmberGuardian_BG24_500_G ? 2 : 1;\r\n\t\tconst dragonsToConsider = otherDragons;\r\n\t\tfor (let i = 0; i < loops; i++) {\r\n\t\t\tconst otherDragon =\r\n\t\t\t\tpickRandom(dragonsToConsider.filter((e) => !e.divineShield)) ?? pickRandom(dragonsToConsider);\r\n\t\t\tif (otherDragon) {\r\n\t\t\t\tif (!otherDragon.divineShield) {\r\n\t\t\t\t\tupdateDivineShield(\r\n\t\t\t\t\t\totherDragon,\r\n\t\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\t\tdefendingBoardHero,\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}\r\n\t\t\t\tmodifyStats(otherDragon, 7, 7, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\totherDragon,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t);\r\n\t\t\t\tdragonsToConsider.splice(dragonsToConsider.indexOf(otherDragon), 1);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.SanctumRester_BG26_356 ||\r\n\t\tattacker.cardId === CardIds.SanctumRester_BG26_356_G\r\n\t) {\r\n\t\tconst buff = attacker.cardId === CardIds.SanctumRester_BG26_356_G ? 16 : 8;\r\n\t\t// First try to get a target without divine shield, and if none is available, pick one with divine shield\r\n\t\tconst otherDragons = attackingBoard\r\n\t\t\t.filter((e) => hasCorrectTribe(e, attackingBoardHero, Race.DRAGON, gameState.allCards))\r\n\t\t\t.filter((e) => e.entityId !== attacker.entityId);\r\n\t\totherDragons.forEach((otherDragon) => {\r\n\t\t\tmodifyStats(otherDragon, 0, buff, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tattacker,\r\n\t\t\t\totherDragon,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t);\r\n\t\t});\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.Soulsplitter_BG25_023 ||\r\n\t\tattacker.cardId === CardIds.Soulsplitter_BG25_023_G\r\n\t) {\r\n\t\tconst numberOfTargets = attacker.cardId === CardIds.Soulsplitter_BG25_023_G ? 2 : 1;\r\n\t\tfor (let i = 0; i < numberOfTargets; i++) {\r\n\t\t\tconst undeadsWithoutReborn = attackingBoard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, attackingBoardHero, Race.UNDEAD, gameState.allCards))\r\n\t\t\t\t.filter((e) => !e.reborn);\r\n\t\t\tconst chosenUndead = pickRandom(undeadsWithoutReborn);\r\n\t\t\tif (chosenUndead) {\r\n\t\t\t\tchosenUndead.reborn = true;\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tchosenUndead,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.Crabby_BG22_HERO_000_Buddy ||\r\n\t\tattacker.cardId === CardIds.Crabby_BG22_HERO_000_Buddy_G\r\n\t) {\r\n\t\tconst neighbours = getNeighbours(attackingBoard, attacker);\r\n\t\tconst multiplier = attacker.cardId === CardIds.Crabby_BG22_HERO_000_Buddy_G ? 2 : 1;\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyStats(\r\n\t\t\t\tentity,\r\n\t\t\t\tmultiplier * (attackingBoardHero.deadEyeDamageDone ?? 0),\r\n\t\t\t\tmultiplier * (attackingBoardHero.deadEyeDamageDone ?? 0),\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tattacker,\r\n\t\t\t\tentity,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t);\r\n\t\t});\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.CorruptedMyrmidon_BG23_012 ||\r\n\t\tattacker.cardId === CardIds.CorruptedMyrmidon_BG23_012_G\r\n\t) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.CorruptedMyrmidon_BG23_012_G ? 2 : 1;\r\n\t\tmodifyStats(\r\n\t\t\tattacker,\r\n\t\t\tmultiplier * attacker.attack,\r\n\t\t\tmultiplier * attacker.health,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tattacker,\r\n\t\t\tattacker,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoardHero,\r\n\t\t);\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.InterrogatorWhitemane_BG24_704 ||\r\n\t\tattacker.cardId === CardIds.InterrogatorWhitemane_BG24_704_G\r\n\t) {\r\n\t\tif (defendingBoard.length > 0) {\r\n\t\t\tconst validTargets = defendingBoard.filter((e) => gameState.cardsData.getTavernLevel(e.cardId) >= 5);\r\n\t\t\tconst numberOfPicks = attacker.cardId === CardIds.InterrogatorWhitemane_BG24_704_G ? 2 : 1;\r\n\t\t\tfor (let i = 0; i < numberOfPicks; i++) {\r\n\t\t\t\tconst target = pickRandom(validTargets);\r\n\t\t\t\tif (!!target) {\r\n\t\t\t\t\tcastImpure(attacker, target, attackingBoard, gameState.spectator);\r\n\t\t\t\t\tconst targetIndex = validTargets.findIndex((e) => e.entityId === target.entityId);\r\n\t\t\t\t\tvalidTargets.splice(targetIndex, 1);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (attacker.cardId === CardIds.MantidQueen_BG22_402 || attacker.cardId === CardIds.MantidQueen_BG22_402_G) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.MantidQueen_BG22_402_G ? 2 : 1;\r\n\t\tconst allRaces = attackingBoardBefore\r\n\t\t\t.map((entity) => entity.cardId)\r\n\t\t\t.flatMap((cardId) => gameState.allCards.getCard(cardId).races)\r\n\t\t\t.filter((race) => !!race && race !== Race[Race.BLANK]);\r\n\t\tconst totalRaces =\r\n\t\t\t[...new Set(allRaces.filter((race) => race !== Race[Race.ALL]))].length +\r\n\t\t\tallRaces.filter((race) => race === Race[Race.ALL]).length;\r\n\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\tfor (let j = 0; j < totalRaces; j++) {\r\n\t\t\t\tconst buffType = getRandomMantidQueenBuffType(attacker);\r\n\t\t\t\tswitch (buffType) {\r\n\t\t\t\t\tcase 'stats':\r\n\t\t\t\t\t\tmodifyStats(attacker, 5, 5, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'reborn':\r\n\t\t\t\t\t\tattacker.reborn = true;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'taunt':\r\n\t\t\t\t\t\tattacker.taunt = true;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'windfury':\r\n\t\t\t\t\t\tattacker.windfury = true;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.CarbonicCopy_BG27_503 ||\r\n\t\tattacker.cardId === CardIds.CarbonicCopy_BG27_503_G\r\n\t) {\r\n\t\tconst numberOfCopies = attacker.cardId === CardIds.CarbonicCopy_BG27_503_G ? 2 : 1;\r\n\t\tfor (let i = 0; i < numberOfCopies; i++) {\r\n\t\t\tif (!!attackingBoard.length && attackingBoard.length < 7) {\r\n\t\t\t\tconst copy: BoardEntity = {\r\n\t\t\t\t\t...attacker,\r\n\t\t\t\t\tlastAffectedByEntity: null,\r\n\t\t\t\t};\r\n\t\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\t\tcopy.cardId,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\tattacker.friendly,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tcopy,\r\n\t\t\t\t);\r\n\t\t\t\tconst indexFromRight = attackingBoard.length - (attackingBoard.indexOf(attacker) + 1);\r\n\t\t\t\tperformEntitySpawns(\r\n\t\t\t\t\tnewMinions,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tcopy,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.DiremuckForager_BG27_556 ||\r\n\t\tattacker.cardId === CardIds.DiremuckForager_BG27_556_G\r\n\t) {\r\n\t\tconst potentialTargets = attackingBoardHero.hand\r\n\t\t\t.filter((e) => !!e.cardId)\r\n\t\t\t.filter((e) => gameState.allCards.getCard(e.cardId).type?.toUpperCase() === CardType[CardType.MINION])\r\n\t\t\t.filter((e) => !e.locked);\r\n\t\tif (potentialTargets.length > 0) {\r\n\t\t\tconst target = pickRandom(potentialTargets);\r\n\t\t\t// When it's the opponent, the game state already contains all the buffs\r\n\t\t\t// It can happen that, for the opponent, a card is first added to their hand (eg with Embrace Your Rage)\r\n\t\t\t// and then summoned by Diremuck. In that case, the stats need to be buffed\r\n\t\t\t// Update 29.2 18/04/2024: this is no longer the case, and the minions passed in the initial state should\r\n\t\t\t// reflect the values they have in hand\r\n\t\t\t// if (target?.friendly || !target?.inInitialState) {\r\n\t\t\tconst diremuckBuff = attacker.cardId === CardIds.DiremuckForager_BG27_556_G ? 4 : 2;\r\n\t\t\tmodifyStats(target, diremuckBuff, diremuckBuff, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tattacker,\r\n\t\t\t\ttarget,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t);\r\n\t\t\t// }\r\n\t\t\tif (attackingBoard.length < 7) {\r\n\t\t\t\ttarget.locked = true;\r\n\t\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\t\ttarget.cardId,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\tattacker.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t\t{ ...target } as BoardEntity,\r\n\t\t\t\t);\r\n\t\t\t\tfor (const s of newMinions) {\r\n\t\t\t\t\ts.onCanceledSummon = () => (target.locked = false);\r\n\t\t\t\t}\r\n\t\t\t\tperformEntitySpawns(\r\n\t\t\t\t\tnewMinions,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tattackingBoard.length - (attackingBoard.indexOf(attacker) + 1),\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\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} else if (\r\n\t\tattacker.cardId === CardIds.HawkstriderHerald_BG27_079 ||\r\n\t\tattacker.cardId === CardIds.HawkstriderHerald_BG27_079_G\r\n\t) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.HawkstriderHerald_BG27_079_G ? 2 : 1;\r\n\t\tfor (const entity of attackingBoard) {\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t);\r\n\t\t\t\thandleDeathrattles({\r\n\t\t\t\t\tgameState: gameState,\r\n\t\t\t\t\tplayerDeadEntities: attackingBoardHero.friendly ? [entity] : [],\r\n\t\t\t\t\tplayerDeadEntityIndexesFromRight: attackingBoardHero.friendly\r\n\t\t\t\t\t\t? [attackingBoard.length - 1 - attackingBoard.indexOf(entity)]\r\n\t\t\t\t\t\t: [],\r\n\t\t\t\t\topponentDeadEntities: attackingBoardHero.friendly ? [] : [entity],\r\n\t\t\t\t\topponentDeadEntityIndexesFromRight: attackingBoardHero.friendly\r\n\t\t\t\t\t\t? []\r\n\t\t\t\t\t\t: [attackingBoard.length - 1 - attackingBoard.indexOf(entity)],\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t\t// console.debug('done triggering hawkstrider\\n\\n\\n');\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.AudaciousAnchor_BG28_904 ||\r\n\t\tattacker.cardId === CardIds.AudaciousAnchor_BG28_904_G\r\n\t) {\r\n\t\tconst iterations = attacker.cardId === CardIds.AudaciousAnchor_BG28_904_G ? 2 : 1;\r\n\t\tfor (let i = 0; i < iterations; i++) {\r\n\t\t\tconst targets = findNearestEnemies(\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattacker,\r\n\t\t\t\tattackingBoard.length - 1 - attackingBoard.indexOf(attacker),\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\t1,\r\n\t\t\t\tgameState.allCards,\r\n\t\t\t);\r\n\t\t\tif (!targets.length) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tif (targets.length > 2) {\r\n\t\t\t\tconsole.error('Invalid number of targets', targets.length);\r\n\t\t\t}\r\n\r\n\t\t\tconst target = pickRandom(targets);\r\n\t\t\twhile (attacker.health > 0 && target.health > 0 && !attacker.definitelyDead && !target.definitelyDead) {\r\n\t\t\t\t// Attackers don't alternate\r\n\t\t\t\t// See http://replays.firestoneapp.com/?reviewId=f9f6bf62-db73-49ad-8187-d2f8848b7f36&turn=17&action=0\r\n\t\t\t\tdoFullAttack(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\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} else if (\r\n\t\tattacker.cardId === CardIds.PilotedWhirlOTron_BG21_HERO_030_Buddy ||\r\n\t\tattacker.cardId === CardIds.PilotedWhirlOTron_BG21_HERO_030_Buddy_G\r\n\t) {\r\n\t\t// const iterations = attacker.cardId === CardIds.PilotedWhirlOTron_BG21_HERO_030_Buddy_G ? 2 : 1;\r\n\t\trememberDeathrattles(\r\n\t\t\tattacker,\r\n\t\t\tattackingBoard.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId !== CardIds.PilotedWhirlOTron_BG21_HERO_030_Buddy &&\r\n\t\t\t\t\te.cardId !== CardIds.PilotedWhirlOTron_BG21_HERO_030_Buddy_G,\r\n\t\t\t),\r\n\t\t\tgameState.cardsData,\r\n\t\t\tgameState.allCards,\r\n\t\t\tgameState.sharedState,\r\n\t\t);\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tattacker,\r\n\t\t\tattacker,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoardHero,\r\n\t\t);\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.IrateRooster_BG29_990 ||\r\n\t\tattacker.cardId === CardIds.IrateRooster_BG29_990_G\r\n\t) {\r\n\t\tconst loops = attacker.cardId === CardIds.IrateRooster_BG29_990_G ? 2 : 1;\r\n\t\tfor (let i = 0; i < loops; i++) {\r\n\t\t\tconst neighbours = getNeighbours(attackingBoard, attacker);\r\n\t\t\tfor (const neighbour of neighbours) {\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tneighbour,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t);\r\n\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\tneighbour,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t\tmodifyStats(neighbour, 4, 0, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.MisfitDragonling_BG29_814 ||\r\n\t\tattacker.cardId === CardIds.MisfitDragonling_BG29_814_G\r\n\t) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.MisfitDragonling_BG29_814_G ? 2 : 1;\r\n\t\tconst tier = attackingBoardHero.tavernTier;\r\n\t\tconst stats = multiplier * tier;\r\n\t\tmodifyStats(attacker, stats, stats, attackingBoard, attackingBoardHero, gameState);\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tattacker,\r\n\t\t\tattacker,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoardHero,\r\n\t\t);\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.ThousandthPaperDrake_BG29_810 ||\r\n\t\tattacker.cardId === CardIds.ThousandthPaperDrake_BG29_810_G\r\n\t) {\r\n\t\tconst loops = attacker.cardId === CardIds.ThousandthPaperDrake_BG29_810_G ? 2 : 1;\r\n\t\tconst pickedTargets = [];\r\n\t\tconst dragons = attackingBoard.filter((e) =>\r\n\t\t\thasCorrectTribe(e, attackingBoardHero, Race.DRAGON, gameState.allCards),\r\n\t\t);\r\n\t\tfor (let i = 0; i < loops; i++) {\r\n\t\t\tconst target = dragons.filter((e) => !pickedTargets.includes(e))[0];\r\n\t\t\tif (!!target) {\r\n\t\t\t\tmodifyStats(target, 1, 2, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\t\ttarget.windfury = true;\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t);\r\n\t\t\t\tpickedTargets.push(target);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.YulonFortuneGranter_BG29_811 ||\r\n\t\tattacker.cardId === CardIds.YulonFortuneGranter_BG29_811_G\r\n\t) {\r\n\t\tconst loops = attacker.cardId === CardIds.YulonFortuneGranter_BG29_811_G ? 2 : 1;\r\n\t\tfor (let i = 0; i < loops; i++) {\r\n\t\t\tconst candidateBoard = attackingBoard\r\n\t\t\t\t.filter((e) => !isGolden(e.cardId, gameState.allCards))\r\n\t\t\t\t.filter(\r\n\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\te.cardId !== CardIds.YulonFortuneGranter_BG29_811 &&\r\n\t\t\t\t\t\te.cardId !== CardIds.YulonFortuneGranter_BG29_811_G,\r\n\t\t\t\t);\r\n\t\t\t// Because we pick one at random from all the ones that have the lowest tier\r\n\t\t\tconst randomBoard = shuffleArray(candidateBoard);\r\n\t\t\tconst candidates = randomBoard.sort(\r\n\t\t\t\t(a, b) => gameState.cardsData.getTavernLevel(a.cardId) - gameState.cardsData.getTavernLevel(b.cardId),\r\n\t\t\t);\r\n\t\t\tconst target = candidates[0];\r\n\t\t\tif (!!target) {\r\n\t\t\t\tmakeMinionGolden(target, attacker, attackingBoard, attackingBoardHero, defendingBoardHero, gameState);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.HoardingHatespawn_BG29_872 ||\r\n\t\tattacker.cardId === CardIds.HoardingHatespawn_BG29_872_G\r\n\t) {\r\n\t\tconst stats = attacker.cardId === CardIds.HoardingHatespawn_BG29_872_G ? 20 : 10;\r\n\t\tconst target = getRandomMinionWithHighestHealth(defendingBoard);\r\n\t\tif (!!target) {\r\n\t\t\tconst previousAttack = target.attack;\r\n\t\t\tconst previousHealth = target.health;\r\n\t\t\ttarget.attack = Math.max(0, target.attack - stats);\r\n\t\t\ttarget.health = Math.max(0, target.health - stats);\r\n\t\t\ttarget.maxHealth = Math.max(0, target.maxHealth - stats);\r\n\t\t\tmodifyStats(\r\n\t\t\t\tattacker,\r\n\t\t\t\tpreviousAttack - target.attack,\r\n\t\t\t\tpreviousHealth - target.health,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tattacker,\r\n\t\t\t\ttarget,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t);\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.TheUninvitedGuest_BG29_875 ||\r\n\t\tattacker.cardId === CardIds.TheUninvitedGuest_BG29_875_G\r\n\t) {\r\n\t\tconst targetEnchantment =\r\n\t\t\tattacker.cardId === CardIds.TheUninvitedGuest_BG29_875_G\r\n\t\t\t\t? CardIds.TheUninvitedGuest_UninvitedEnchantment_BG29_875_Ge\r\n\t\t\t\t: CardIds.TheUninvitedGuest_UninvitedEnchantment_BG29_875e;\r\n\t\tattackingBoard\r\n\t\t\t.filter((e) => e.entityId != attacker.entityId)\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\te.enchantments = e.enchantments || [];\r\n\t\t\t\tif (!e.enchantments.some((e) => e.cardId === targetEnchantment)) {\r\n\t\t\t\t\te.enchantments.push({\r\n\t\t\t\t\t\tcardId: targetEnchantment,\r\n\t\t\t\t\t\toriginEntityId: attacker.entityId,\r\n\t\t\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t} else if (attacker.cardId === CardIds.Sandy_BGDUO_125 || attacker.cardId === CardIds.Sandy_BGDUO_125_G) {\r\n\t\tconst teammateState = getTeammateInitialState(gameState.gameState, attackingBoardHero);\r\n\t\tif (teammateState?.board?.length) {\r\n\t\t\tconst isGolden = attacker.cardId === CardIds.Sandy_BGDUO_125_G;\r\n\t\t\tconst minionToCopy = getRandomMinionWithHighestHealth(teammateState.board);\r\n\t\t\tconst copy: BoardEntity = { ...minionToCopy, enchantments: [...minionToCopy.enchantments] };\r\n\t\t\tconst attackerIndex = attackingBoard.indexOf(attacker);\r\n\t\t\t// Insert the copy in its place\r\n\t\t\tattackingBoard.splice(attackerIndex, 0, copy);\r\n\t\t\tif (isGolden) {\r\n\t\t\t\tmakeMinionGolden(copy, copy, attackingBoard, attackingBoardHero, defendingBoardHero, gameState);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.Vaelastrasz_TB_BaconShop_HERO_56_Buddy ||\r\n\t\tattacker.cardId === CardIds.Vaelastrasz_TB_BaconShop_HERO_56_Buddy_G\r\n\t) {\r\n\t\tconst vaelastraszBonus = attacker.cardId === CardIds.Vaelastrasz_TB_BaconShop_HERO_56_Buddy_G ? 6 : 3;\r\n\t\tattackingBoard\r\n\t\t\t.filter((e) => e.entityId !== attacker.entityId)\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\tmodifyStats(e, vaelastraszBonus, vaelastraszBonus, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\te,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.ElderTaggawag_TB_BaconShop_HERO_14_Buddy ||\r\n\t\tattacker.cardId === CardIds.ElderTaggawag_TB_BaconShop_HERO_14_Buddy_G\r\n\t) {\r\n\t\tconst minionsOfDifferentTypes = getMinionsOfDifferentTypes(attackingBoard, attackingBoardHero, gameState);\r\n\t\tif (minionsOfDifferentTypes.length >= 4) {\r\n\t\t\tconst highestAttackOnBoard = Math.max(...attackingBoard.map((entity) => entity.attack));\r\n\t\t\tconst highestHealthOnBoard = Math.max(...attackingBoard.map((entity) => entity.health));\r\n\t\t\tconst multiplier = attacker.cardId === CardIds.ElderTaggawag_TB_BaconShop_HERO_14_Buddy_G ? 2 : 1;\r\n\t\t\tmodifyStats(\r\n\t\t\t\tattacker,\r\n\t\t\t\thighestAttackOnBoard * multiplier,\r\n\t\t\t\thighestHealthOnBoard * multiplier,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tattacker,\r\n\t\t\t\tattacker,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t);\r\n\t\t}\r\n\t} else if (attacker.cardId === CardIds.SunScreener_BG30_101 || attacker.cardId === CardIds.SunScreener_BG30_101_G) {\r\n\t\tif (attackingBoard.length > 0 || defendingBoard.length > 0) {\r\n\t\t\tconst quantity = attacker.cardId === CardIds.SunScreener_BG30_101 ? 3 : 6;\r\n\t\t\tgrantDivineShieldToLeftmostMinions(\r\n\t\t\t\tattacker,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tquantity,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgrantDivineShieldToLeftmostMinions(\r\n\t\t\t\tattacker,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tquantity,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.SkyPirateFlagbearer_BG30_119 ||\r\n\t\tattacker.cardId === CardIds.SkyPirateFlagbearer_BG30_119_G\r\n\t) {\r\n\t\tattackingBoard\r\n\t\t\t.filter((e) => e.entityId !== attacker.entityId)\r\n\t\t\t.filter((e) => hasCorrectTribe(e, attackingBoardHero, Race.PIRATE, gameState.allCards))\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\te.enchantments = e.enchantments || [];\r\n\t\t\t\te.enchantments.push({\r\n\t\t\t\t\tcardId:\r\n\t\t\t\t\t\tattacker.cardId === CardIds.SkyPirateFlagbearer_BG30_119_G\r\n\t\t\t\t\t\t\t? CardIds.SkyPirateFlagbearer_FlagbearingEnchantment_BG30_119_Ge\r\n\t\t\t\t\t\t\t: CardIds.SkyPirateFlagbearer_FlagbearingEnchantment_BG30_119e,\r\n\t\t\t\t\toriginEntityId: attacker.entityId,\r\n\t\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t} else {\r\n\t\thasProcessed = false;\r\n\t}\r\n\tprocessMinionDeath(attackingBoard, attackingBoardHero, defendingBoard, defendingBoardHero, gameState);\r\n\treturn hasProcessed;\r\n};\r\n\r\nconst applyAllWillBurn = (\r\n\tboard1: BoardEntity[],\r\n\tboard1Hero: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tboard2Hero: BgsPlayerEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tfor (const entity of board1) {\r\n\t\tmodifyStats(entity, 2, 0, board1, board1Hero, gameState);\r\n\t\tgameState.spectator.registerPowerTarget(sourceEntity, entity, board1, null, null);\r\n\t}\r\n\tfor (const entity of board2) {\r\n\t\tmodifyStats(entity, 2, 0, board2, board1Hero, gameState);\r\n\t\tgameState.spectator.registerPowerTarget(sourceEntity, entity, board2, null, null);\r\n\t}\r\n};\r\n\r\nconst castImpure = (entity: BoardEntity, source: BoardEntity, board: BoardEntity[], spectator: Spectator) => {\r\n\tif (!entity) {\r\n\t\treturn;\r\n\t}\r\n\tconst multiplier = source.cardId === CardIds.InterrogatorWhitemane_BG24_704_G ? 3 : 2;\r\n\tentity.taunt = true;\r\n\tentity.damageMultiplier = entity.damageMultiplier ?? 1;\r\n\tentity.damageMultiplier *= multiplier;\r\n\tspectator.registerPowerTarget(source, entity, board, null, null);\r\n};\r\n\r\nconst getRandomMantidQueenBuffType = (entity: BoardEntity): 'stats' | 'reborn' | 'windfury' | 'taunt' => {\r\n\tconst possibilities: ('stats' | 'reborn' | 'windfury' | 'taunt')[] = ['stats'];\r\n\tif (!entity.reborn) {\r\n\t\tpossibilities.push('reborn');\r\n\t}\r\n\tif (!entity.windfury) {\r\n\t\tpossibilities.push('windfury');\r\n\t}\r\n\tif (!entity.taunt) {\r\n\t\tpossibilities.push('taunt');\r\n\t}\r\n\treturn pickRandom(possibilities);\r\n};\r\n"]}
|