@firestone-hs/simulate-bgs-battle 1.1.535 → 1.1.538

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.
Files changed (29) hide show
  1. package/dist/bgs-player-entity.d.ts +12 -2
  2. package/dist/bgs-player-entity.js.map +1 -1
  3. package/dist/input-sanitation.js +21 -5
  4. package/dist/input-sanitation.js.map +1 -1
  5. package/dist/simulation/add-minion-to-board.js +15 -13
  6. package/dist/simulation/add-minion-to-board.js.map +1 -1
  7. package/dist/simulation/auras.js +49 -45
  8. package/dist/simulation/auras.js.map +1 -1
  9. package/dist/simulation/avenge.js +12 -8
  10. package/dist/simulation/avenge.js.map +1 -1
  11. package/dist/simulation/deathrattle-effects.js +4 -2
  12. package/dist/simulation/deathrattle-effects.js.map +1 -1
  13. package/dist/simulation/minion-death.js +8 -6
  14. package/dist/simulation/minion-death.js.map +1 -1
  15. package/dist/simulation/spectator/game-action.d.ts +3 -1
  16. package/dist/simulation/spectator/game-action.js +19 -17
  17. package/dist/simulation/spectator/game-action.js.map +1 -1
  18. package/dist/simulation/spectator/spectator.js +0 -2
  19. package/dist/simulation/spectator/spectator.js.map +1 -1
  20. package/dist/simulation/start-of-combat/soc-hero-power.d.ts +0 -1
  21. package/dist/simulation/start-of-combat/soc-hero-power.js +4 -19
  22. package/dist/simulation/start-of-combat/soc-hero-power.js.map +1 -1
  23. package/dist/simulation/start-of-combat/soc-illidan-hero-power.js +5 -5
  24. package/dist/simulation/start-of-combat/soc-illidan-hero-power.js.map +1 -1
  25. package/dist/simulation/start-of-combat/soc-pre-combat-hero-power.js +3 -3
  26. package/dist/simulation/start-of-combat/soc-pre-combat-hero-power.js.map +1 -1
  27. package/dist/simulation/summon-when-space.js +4 -2
  28. package/dist/simulation/summon-when-space.js.map +1 -1
  29. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"minion-death.js","sourceRoot":"","sources":["../../src/simulation/minion-death.ts"],"names":[],"mappings":";;;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AxGW,QAAA,iBAAiB,qBAwG5B","sourcesContent":["import { CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { pickMultipleRandomAlive } from '../services/utils';\r\nimport { getEffectiveTribesForEntity, hasCorrectTribe } from '../utils';\r\nimport { updateAvengeCounters } from './avenge';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { onQuestProgressUpdated } from './quest';\r\nimport { removeMinionFromBoard } from './remove-minion-from-board';\r\nimport { performEntitySpawns } from './spawns';\r\nimport { modifyStats } from './stats';\r\n\r\nexport const makeMinionsDie = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): [number[], number[], BoardEntity[]] => {\r\n\t// Because entities spawn to the left, so the right index is unchanged\r\n\tconst deadMinionIndexesFromLeft: number[] = [];\r\n\tconst deadMinionIndexesFromRight: number[] = [];\r\n\tconst deadEntities: BoardEntity[] = [];\r\n\tconst initialBoardLength = board.length;\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].health <= 0 || board[i].definitelyDead) {\r\n\t\t\tdeadMinionIndexesFromLeft.push(i);\r\n\t\t\tdeadMinionIndexesFromRight.push(initialBoardLength - (i + 1));\r\n\t\t\tdeadEntities.push(board[i]);\r\n\t\t\t// console.log(\r\n\t\t\t// \t'\\tflagging dead minion 0',\r\n\t\t\t// \tstringifySimpleCard(board[i], allCards),\r\n\t\t\t// \tstringifySimple(board, allCards),\r\n\t\t\t// \tinitialBoardLength,\r\n\t\t\t// \ti,\r\n\t\t\t// \tdeadMinionIndexesFromRight,\r\n\t\t\t// );\r\n\t\t}\r\n\t}\r\n\r\n\t// These will always be processed from left to right afterwards\r\n\t// We compute the indexes as they will be once the new board is effective. For a\r\n\t// board of length N, having an indexFromRight at N means it will spawn at the very left\r\n\t// of the board (first minion)\r\n\tlet indexesFromRightAfterDeath = [];\r\n\tfor (let i = deadMinionIndexesFromRight.length - 1; i >= 0; i--) {\r\n\t\tconst newIndex = deadMinionIndexesFromRight[i] - indexesFromRightAfterDeath.length;\r\n\t\tindexesFromRightAfterDeath.push(newIndex);\r\n\t}\r\n\tindexesFromRightAfterDeath = indexesFromRightAfterDeath.reverse();\r\n\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].health <= 0 || board[i].definitelyDead) {\r\n\t\t\t// console.log('\\tflagging dead minion', stringifySimpleCard(board[i], allCards), deadMinionIndexesFromRight);\r\n\t\t\tremoveMinionFromBoard(board, boardHero, i, gameState);\r\n\t\t\t// We modify the original array, so we need to update teh current index accordingly\r\n\t\t\ti--;\r\n\t\t}\r\n\t}\r\n\r\n\t// console.debug('dead entities', stringifySimple(deadEntities, allCards));\r\n\t// Update the avenge counters as soon as minions die. If we wait until the \"avenge\" phase, we might\r\n\t// update the counters for entities that have been spawned after the death of the original entity\r\n\t// ISSUE: deaths are actually processed one by one. Once a minion dies, its DR triggers, then the next, etc.\r\n\t// This means that if you have a minion that summons another one, it can progress and complete and quest\r\n\t// and the next minion dying could count towards that quest progress\r\n\t// See http://replays.firestoneapp.com/?reviewId=0ce4db9c-3269-4704-b662-8a8c31f5afe1&turn=16&action=27\r\n\tfor (const deadEntity of deadEntities) {\r\n\t\tconst indexFromRight = indexesFromRightAfterDeath[deadEntities.indexOf(deadEntity)];\r\n\t\tupdateAvengeCounters(board, boardHero);\r\n\t\tonMinionDeadHeroPower(board, boardHero, deadEntity, gameState);\r\n\t\tonMinionDeadHeroPower(otherBoard, otherBoardHero, deadEntity, gameState);\r\n\t\tonMinionDeadQuest(deadEntity, indexFromRight, board, boardHero, otherBoard, otherBoardHero, gameState);\r\n\t\tonMinionDeadQuest(deadEntity, indexFromRight, otherBoard, otherBoardHero, board, boardHero, gameState);\r\n\t}\r\n\r\n\treturn [deadMinionIndexesFromLeft, indexesFromRightAfterDeath, deadEntities];\r\n};\r\n\r\nexport const onMinionDeadHeroPower = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tif (\r\n\t\tboardHero.heroPowerId === CardIds.IllTakeThat &&\r\n\t\tboardHero.heroPowerUsed &&\r\n\t\tboardHero.heroPowerInfo2 <= 0 &&\r\n\t\tdeadEntity.friendly !== boardHero.friendly\r\n\t) {\r\n\t\taddCardsInHand(boardHero, board, [deadEntity.cardId], gameState);\r\n\t\tboardHero.heroPowerInfo2 = 1;\r\n\t}\r\n};\r\n\r\nexport const onMinionDeadQuest = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst quests = boardHero.questEntities ?? [];\r\n\tfor (const quest of quests) {\r\n\t\tswitch (quest.CardId) {\r\n\t\t\tcase CardIds.ReenactTheMurder:\r\n\t\t\t\tif (deadEntity.friendly === boardHero.friendly) {\r\n\t\t\t\t\tonQuestProgressUpdated(boardHero, quest, board, gameState);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.RoundUpTheSuspects:\r\n\t\t\t\tif (deadEntity.friendly !== boardHero.friendly) {\r\n\t\t\t\t\tonQuestProgressUpdated(boardHero, quest, board, gameState);\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 trinket of boardHero.trinkets) {\r\n\t\tswitch (trinket.cardId) {\r\n\t\t\tcase CardIds.AllianceKeychain_BG30_MagicItem_433:\r\n\t\t\tcase CardIds.AllianceKeychain_AllianceKeychainToken_BG30_MagicItem_433t:\r\n\t\t\t\tif (trinket.scriptDataNum1 > 0 && deadEntity.friendly === boardHero.friendly) {\r\n\t\t\t\t\tconst quantity = trinket.cardId === CardIds.AllianceKeychain_BG30_MagicItem_433 ? 1 : 2;\r\n\t\t\t\t\tconst targets = pickMultipleRandomAlive(board, quantity);\r\n\t\t\t\t\tfor (const target of targets) {\r\n\t\t\t\t\t\tmodifyStats(target, deadEntity.maxAttack, deadEntity.maxHealth, board, boardHero, gameState);\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(boardHero, target, board, boardHero, otherBoardHero);\r\n\t\t\t\t\t}\r\n\t\t\t\t\ttrinket.scriptDataNum1--;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.TheEyeOfDalaran_BG30_MagicItem_981:\r\n\t\t\t\tif (\r\n\t\t\t\t\tdeadEntity.friendly === boardHero.friendly &&\r\n\t\t\t\t\tgetEffectiveTribesForEntity(deadEntity, boardHero, gameState.allCards).length === 0\r\n\t\t\t\t) {\r\n\t\t\t\t\taddCardsInHand(boardHero, board, [null], gameState);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.BloodGolemSticker_BG30_MagicItem_442:\r\n\t\t\t\tif (\r\n\t\t\t\t\tdeadEntity.friendly === boardHero.friendly &&\r\n\t\t\t\t\ttrinket.scriptDataNum1 > 0 &&\r\n\t\t\t\t\thasCorrectTribe(deadEntity, boardHero, Race.QUILBOAR, gameState.allCards)\r\n\t\t\t\t) {\r\n\t\t\t\t\tlet bloodGemEnchantments = deadEntity.enchantments?.filter(\r\n\t\t\t\t\t\t(e) => e.cardId === CardIds.BloodGem_BloodGemsEnchantment,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (bloodGemEnchantments?.length === 0) {\r\n\t\t\t\t\t\tbloodGemEnchantments = deadEntity.enchantments?.filter(\r\n\t\t\t\t\t\t\t(e) => e.cardId === CardIds.BloodGem_BloodGemEnchantment,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (bloodGemEnchantments?.length > 0) {\r\n\t\t\t\t\t\tconst bloodGemAttack = bloodGemEnchantments\r\n\t\t\t\t\t\t\t.map((e) => e.tagScriptDataNum1 ?? 0)\r\n\t\t\t\t\t\t\t.reduce((a, b) => a + b, 0);\r\n\t\t\t\t\t\tconst bloodGemHealth = bloodGemEnchantments\r\n\t\t\t\t\t\t\t.map((e) => e.tagScriptDataNum2 ?? 0)\r\n\t\t\t\t\t\t\t.reduce((a, b) => a + b, 0);\r\n\t\t\t\t\t\tif (bloodGemAttack > 0 || bloodGemHealth > 0) {\r\n\t\t\t\t\t\t\tconst spawns = spawnEntities(\r\n\t\t\t\t\t\t\t\tCardIds.BloodGolemSticker_BloodGolemToken_BG30_MagicItem_442t,\r\n\t\t\t\t\t\t\t\t1,\r\n\t\t\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\t\t\tboardHero,\r\n\t\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\tspawns.forEach((b) => {\r\n\t\t\t\t\t\t\t\tb.attack = bloodGemAttack;\r\n\t\t\t\t\t\t\t\tb.health = bloodGemHealth;\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\tperformEntitySpawns(\r\n\t\t\t\t\t\t\t\tspawns,\r\n\t\t\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\t\t\tboardHero,\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\ttrinket.scriptDataNum1--;\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}\r\n\t}\r\n};\r\n"]}
1
+ {"version":3,"file":"minion-death.js","sourceRoot":"","sources":["../../src/simulation/minion-death.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAG7D,6CAA4D;AAC5D,oCAAwE;AACxE,qCAAgD;AAChD,mDAAiD;AACjD,6DAAqD;AAErD,mCAAiD;AACjD,yEAAmE;AACnE,qCAA+C;AAC/C,mCAAsC;AAE/B,MAAM,cAAc,GAAG,CAC7B,KAAoB,EACpB,SAA0B,EAC1B,UAAyB,EACzB,cAA+B,EAC/B,SAAwB,EACc,EAAE;IAExC,MAAM,yBAAyB,GAAa,EAAE,CAAC;IAC/C,MAAM,0BAA0B,GAAa,EAAE,CAAC;IAChD,MAAM,YAAY,GAAkB,EAAE,CAAC;IACvC,MAAM,kBAAkB,GAAG,KAAK,CAAC,MAAM,CAAC;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,cAAc,EAAE;YACpD,yBAAyB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClC,0BAA0B,CAAC,IAAI,CAAC,kBAAkB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAC9D,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SAS5B;KACD;IAMD,IAAI,0BAA0B,GAAG,EAAE,CAAC;IACpC,KAAK,IAAI,CAAC,GAAG,0BAA0B,CAAC,MAAM,GAAG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,CAAC,CAAC,EAAE,EAAE;gCACpB,CAAC,CAAC,MAAM,GAAG,cAAc,CAAC;gCAC1B,CAAC,CAAC,MAAM,GAAG,cAAc,CAAC;4BAC3B,CAAC,CAAC,CAAC;4BACH,IAAA,4BAAmB,EAClB,MAAM,EACN,KAAK,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,UAAU,EACV,cAAc,EACd,SAAS,CACT,CAAC;4BACF,OAAO,CAAC,cAAc,EAAE,CAAC;yBACzB;qBACD;iBACD;gBACD,MAAM;SACP;KACD;AACF,CAAC,CAAC;AAxGW,QAAA,iBAAiB,qBAwG5B","sourcesContent":["import { CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { pickMultipleRandomAlive } from '../services/utils';\r\nimport { getEffectiveTribesForEntity, hasCorrectTribe } from '../utils';\r\nimport { updateAvengeCounters } from './avenge';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { onQuestProgressUpdated } from './quest';\r\nimport { removeMinionFromBoard } from './remove-minion-from-board';\r\nimport { performEntitySpawns } from './spawns';\r\nimport { modifyStats } from './stats';\r\n\r\nexport const makeMinionsDie = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): [number[], number[], BoardEntity[]] => {\r\n\t// Because entities spawn to the left, so the right index is unchanged\r\n\tconst deadMinionIndexesFromLeft: number[] = [];\r\n\tconst deadMinionIndexesFromRight: number[] = [];\r\n\tconst deadEntities: BoardEntity[] = [];\r\n\tconst initialBoardLength = board.length;\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].health <= 0 || board[i].definitelyDead) {\r\n\t\t\tdeadMinionIndexesFromLeft.push(i);\r\n\t\t\tdeadMinionIndexesFromRight.push(initialBoardLength - (i + 1));\r\n\t\t\tdeadEntities.push(board[i]);\r\n\t\t\t// console.log(\r\n\t\t\t// \t'\\tflagging dead minion 0',\r\n\t\t\t// \tstringifySimpleCard(board[i], allCards),\r\n\t\t\t// \tstringifySimple(board, allCards),\r\n\t\t\t// \tinitialBoardLength,\r\n\t\t\t// \ti,\r\n\t\t\t// \tdeadMinionIndexesFromRight,\r\n\t\t\t// );\r\n\t\t}\r\n\t}\r\n\r\n\t// These will always be processed from left to right afterwards\r\n\t// We compute the indexes as they will be once the new board is effective. For a\r\n\t// board of length N, having an indexFromRight at N means it will spawn at the very left\r\n\t// of the board (first minion)\r\n\tlet indexesFromRightAfterDeath = [];\r\n\tfor (let i = deadMinionIndexesFromRight.length - 1; i >= 0; i--) {\r\n\t\tconst newIndex = deadMinionIndexesFromRight[i] - indexesFromRightAfterDeath.length;\r\n\t\tindexesFromRightAfterDeath.push(newIndex);\r\n\t}\r\n\tindexesFromRightAfterDeath = indexesFromRightAfterDeath.reverse();\r\n\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].health <= 0 || board[i].definitelyDead) {\r\n\t\t\t// console.log('\\tflagging dead minion', stringifySimpleCard(board[i], allCards), deadMinionIndexesFromRight);\r\n\t\t\tremoveMinionFromBoard(board, boardHero, i, gameState);\r\n\t\t\t// We modify the original array, so we need to update teh current index accordingly\r\n\t\t\ti--;\r\n\t\t}\r\n\t}\r\n\r\n\t// console.debug('dead entities', stringifySimple(deadEntities, allCards));\r\n\t// Update the avenge counters as soon as minions die. If we wait until the \"avenge\" phase, we might\r\n\t// update the counters for entities that have been spawned after the death of the original entity\r\n\t// ISSUE: deaths are actually processed one by one. Once a minion dies, its DR triggers, then the next, etc.\r\n\t// This means that if you have a minion that summons another one, it can progress and complete and quest\r\n\t// and the next minion dying could count towards that quest progress\r\n\t// See http://replays.firestoneapp.com/?reviewId=0ce4db9c-3269-4704-b662-8a8c31f5afe1&turn=16&action=27\r\n\tfor (const deadEntity of deadEntities) {\r\n\t\tconst indexFromRight = indexesFromRightAfterDeath[deadEntities.indexOf(deadEntity)];\r\n\t\tupdateAvengeCounters(board, boardHero);\r\n\t\tonMinionDeadHeroPower(board, boardHero, deadEntity, gameState);\r\n\t\tonMinionDeadHeroPower(otherBoard, otherBoardHero, deadEntity, gameState);\r\n\t\tonMinionDeadQuest(deadEntity, indexFromRight, board, boardHero, otherBoard, otherBoardHero, gameState);\r\n\t\tonMinionDeadQuest(deadEntity, indexFromRight, otherBoard, otherBoardHero, board, boardHero, gameState);\r\n\t}\r\n\r\n\treturn [deadMinionIndexesFromLeft, indexesFromRightAfterDeath, deadEntities];\r\n};\r\n\r\nexport const onMinionDeadHeroPower = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tfor (const heroPower of boardHero.heroPowers) {\r\n\t\tif (\r\n\t\t\theroPower.cardId === CardIds.IllTakeThat &&\r\n\t\t\theroPower.used &&\r\n\t\t\theroPower.info2 <= 0 &&\r\n\t\t\tdeadEntity.friendly !== boardHero.friendly\r\n\t\t) {\r\n\t\t\taddCardsInHand(boardHero, board, [deadEntity.cardId], gameState);\r\n\t\t\theroPower.info2 = 1;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const onMinionDeadQuest = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst quests = boardHero.questEntities ?? [];\r\n\tfor (const quest of quests) {\r\n\t\tswitch (quest.CardId) {\r\n\t\t\tcase CardIds.ReenactTheMurder:\r\n\t\t\t\tif (deadEntity.friendly === boardHero.friendly) {\r\n\t\t\t\t\tonQuestProgressUpdated(boardHero, quest, board, gameState);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.RoundUpTheSuspects:\r\n\t\t\t\tif (deadEntity.friendly !== boardHero.friendly) {\r\n\t\t\t\t\tonQuestProgressUpdated(boardHero, quest, board, gameState);\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 trinket of boardHero.trinkets) {\r\n\t\tswitch (trinket.cardId) {\r\n\t\t\tcase CardIds.AllianceKeychain_BG30_MagicItem_433:\r\n\t\t\tcase CardIds.AllianceKeychain_AllianceKeychainToken_BG30_MagicItem_433t:\r\n\t\t\t\tif (trinket.scriptDataNum1 > 0 && deadEntity.friendly === boardHero.friendly) {\r\n\t\t\t\t\tconst quantity = trinket.cardId === CardIds.AllianceKeychain_BG30_MagicItem_433 ? 1 : 2;\r\n\t\t\t\t\tconst targets = pickMultipleRandomAlive(board, quantity);\r\n\t\t\t\t\tfor (const target of targets) {\r\n\t\t\t\t\t\tmodifyStats(target, deadEntity.maxAttack, deadEntity.maxHealth, board, boardHero, gameState);\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(boardHero, target, board, boardHero, otherBoardHero);\r\n\t\t\t\t\t}\r\n\t\t\t\t\ttrinket.scriptDataNum1--;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.TheEyeOfDalaran_BG30_MagicItem_981:\r\n\t\t\t\tif (\r\n\t\t\t\t\tdeadEntity.friendly === boardHero.friendly &&\r\n\t\t\t\t\tgetEffectiveTribesForEntity(deadEntity, boardHero, gameState.allCards).length === 0\r\n\t\t\t\t) {\r\n\t\t\t\t\taddCardsInHand(boardHero, board, [null], gameState);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.BloodGolemSticker_BG30_MagicItem_442:\r\n\t\t\t\tif (\r\n\t\t\t\t\tdeadEntity.friendly === boardHero.friendly &&\r\n\t\t\t\t\ttrinket.scriptDataNum1 > 0 &&\r\n\t\t\t\t\thasCorrectTribe(deadEntity, boardHero, Race.QUILBOAR, gameState.allCards)\r\n\t\t\t\t) {\r\n\t\t\t\t\tlet bloodGemEnchantments = deadEntity.enchantments?.filter(\r\n\t\t\t\t\t\t(e) => e.cardId === CardIds.BloodGem_BloodGemsEnchantment,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (bloodGemEnchantments?.length === 0) {\r\n\t\t\t\t\t\tbloodGemEnchantments = deadEntity.enchantments?.filter(\r\n\t\t\t\t\t\t\t(e) => e.cardId === CardIds.BloodGem_BloodGemEnchantment,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (bloodGemEnchantments?.length > 0) {\r\n\t\t\t\t\t\tconst bloodGemAttack = bloodGemEnchantments\r\n\t\t\t\t\t\t\t.map((e) => e.tagScriptDataNum1 ?? 0)\r\n\t\t\t\t\t\t\t.reduce((a, b) => a + b, 0);\r\n\t\t\t\t\t\tconst bloodGemHealth = bloodGemEnchantments\r\n\t\t\t\t\t\t\t.map((e) => e.tagScriptDataNum2 ?? 0)\r\n\t\t\t\t\t\t\t.reduce((a, b) => a + b, 0);\r\n\t\t\t\t\t\tif (bloodGemAttack > 0 || bloodGemHealth > 0) {\r\n\t\t\t\t\t\t\tconst spawns = spawnEntities(\r\n\t\t\t\t\t\t\t\tCardIds.BloodGolemSticker_BloodGolemToken_BG30_MagicItem_442t,\r\n\t\t\t\t\t\t\t\t1,\r\n\t\t\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\t\t\tboardHero,\r\n\t\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\tspawns.forEach((b) => {\r\n\t\t\t\t\t\t\t\tb.attack = bloodGemAttack;\r\n\t\t\t\t\t\t\t\tb.health = bloodGemHealth;\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\tperformEntitySpawns(\r\n\t\t\t\t\t\t\t\tspawns,\r\n\t\t\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\t\t\tboardHero,\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\ttrinket.scriptDataNum1--;\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}\r\n\t}\r\n};\r\n"]}
@@ -1,4 +1,4 @@
1
- import { BgsPlayerEntity, BoardTrinket } from '../../bgs-player-entity';
1
+ import { BgsHeroPower, BgsPlayerEntity, BoardTrinket } from '../../bgs-player-entity';
2
2
  import { BoardEntity } from '../../board-entity';
3
3
  import { BoardSecret } from '../../board-secret';
4
4
  export interface GameAction {
@@ -16,11 +16,13 @@ export interface GameAction {
16
16
  playerHeroPowerCardId: string;
17
17
  playerHeroPowerEntityId: number;
18
18
  playerHeroPowerUsed: boolean;
19
+ playerHeroPowers: readonly BgsHeroPower[];
19
20
  opponentCardId: string;
20
21
  opponentEntityId: number;
21
22
  opponentHeroPowerCardId: string;
22
23
  opponentHeroPowerEntityId: number;
23
24
  opponentHeroPowerUsed: boolean;
25
+ opponentHeroPowers: readonly BgsHeroPower[];
24
26
  playerRewardCardId: string;
25
27
  playerRewardEntityId: number;
26
28
  playerRewardData: number;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildGameAction = void 0;
4
4
  const buildGameAction = (playerHero, opponentHero, action) => {
5
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13;
5
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
6
6
  const isPlayerSireD = (_a = playerHero === null || playerHero === void 0 ? void 0 : playerHero.cardId) === null || _a === void 0 ? void 0 : _a.startsWith("BG24_HERO_100");
7
7
  const isOpponentSireD = (_b = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.cardId) === null || _b === void 0 ? void 0 : _b.startsWith("BG24_HERO_100");
8
8
  const result = {
@@ -10,34 +10,36 @@ const buildGameAction = (playerHero, opponentHero, action) => {
10
10
  playerSecrets: ((_c = playerHero === null || playerHero === void 0 ? void 0 : playerHero.secrets) !== null && _c !== void 0 ? _c : []).filter((s) => !s.triggered),
11
11
  playerCardId: playerHero === null || playerHero === void 0 ? void 0 : playerHero.cardId,
12
12
  playerEntityId: playerHero === null || playerHero === void 0 ? void 0 : playerHero.entityId,
13
- playerHeroPowerCardId: (_h = (_e = (_d = playerHero === null || playerHero === void 0 ? void 0 : playerHero.trinkets.find((t) => t.scriptDataNum6 === 3)) === null || _d === void 0 ? void 0 : _d.cardId) !== null && _e !== void 0 ? _e : (isPlayerSireD ? (_g = (_f = playerHero.questRewardEntities) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.cardId : null)) !== null && _h !== void 0 ? _h : playerHero === null || playerHero === void 0 ? void 0 : playerHero.heroPowerId,
13
+ playerHeroPowerCardId: (_h = (_e = (_d = playerHero === null || playerHero === void 0 ? void 0 : playerHero.trinkets.find((t) => t.scriptDataNum6 === 3)) === null || _d === void 0 ? void 0 : _d.cardId) !== null && _e !== void 0 ? _e : (isPlayerSireD ? (_g = (_f = playerHero.questRewardEntities) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.cardId : null)) !== null && _h !== void 0 ? _h : (_j = playerHero === null || playerHero === void 0 ? void 0 : playerHero.heroPowers[0]) === null || _j === void 0 ? void 0 : _j.cardId,
14
14
  playerHeroPowerEntityId: 100000002,
15
- playerHeroPowerUsed: playerHero === null || playerHero === void 0 ? void 0 : playerHero.heroPowerUsed,
16
- playerRewardCardId: isPlayerSireD && ((_j = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewardEntities) === null || _j === void 0 ? void 0 : _j.length) < 2
15
+ playerHeroPowerUsed: (_k = playerHero === null || playerHero === void 0 ? void 0 : playerHero.heroPowers[0]) === null || _k === void 0 ? void 0 : _k.used,
16
+ playerHeroPowers: playerHero === null || playerHero === void 0 ? void 0 : playerHero.heroPowers,
17
+ playerRewardCardId: isPlayerSireD && ((_l = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewardEntities) === null || _l === void 0 ? void 0 : _l.length) < 2
17
18
  ? null
18
- : (_m = (_l = (_k = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewardEntities) === null || _k === void 0 ? void 0 : _k[1]) === null || _l === void 0 ? void 0 : _l.cardId) !== null && _m !== void 0 ? _m : (_o = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewards) === null || _o === void 0 ? void 0 : _o[0],
19
- playerRewardEntityId: isPlayerSireD && ((_p = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewardEntities) === null || _p === void 0 ? void 0 : _p.length) < 2
19
+ : (_p = (_o = (_m = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewardEntities) === null || _m === void 0 ? void 0 : _m[1]) === null || _o === void 0 ? void 0 : _o.cardId) !== null && _p !== void 0 ? _p : (_q = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewards) === null || _q === void 0 ? void 0 : _q[0],
20
+ playerRewardEntityId: isPlayerSireD && ((_r = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewardEntities) === null || _r === void 0 ? void 0 : _r.length) < 2
20
21
  ? null
21
- : (_r = (_q = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewardEntities) === null || _q === void 0 ? void 0 : _q[1]) === null || _r === void 0 ? void 0 : _r.entityId,
22
- playerRewardData: isPlayerSireD && ((_s = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewardEntities) === null || _s === void 0 ? void 0 : _s.length) < 2
22
+ : (_t = (_s = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewardEntities) === null || _s === void 0 ? void 0 : _s[1]) === null || _t === void 0 ? void 0 : _t.entityId,
23
+ playerRewardData: isPlayerSireD && ((_u = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewardEntities) === null || _u === void 0 ? void 0 : _u.length) < 2
23
24
  ? null
24
- : (_v = (_u = (_t = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewardEntities) === null || _t === void 0 ? void 0 : _t[0]) === null || _u === void 0 ? void 0 : _u.scriptDataNum1) !== null && _v !== void 0 ? _v : 0,
25
+ : (_x = (_w = (_v = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewardEntities) === null || _v === void 0 ? void 0 : _v[0]) === null || _w === void 0 ? void 0 : _w.scriptDataNum1) !== null && _x !== void 0 ? _x : 0,
25
26
  playerTrinkets: playerHero === null || playerHero === void 0 ? void 0 : playerHero.trinkets,
26
- opponentSecrets: ((_w = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.secrets) !== null && _w !== void 0 ? _w : []).filter((s) => !s.triggered),
27
+ opponentSecrets: ((_y = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.secrets) !== null && _y !== void 0 ? _y : []).filter((s) => !s.triggered),
27
28
  opponentCardId: opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.cardId,
28
29
  opponentEntityId: opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.entityId,
29
- opponentHeroPowerCardId: (_1 = (_y = (_x = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.trinkets.find((t) => t.scriptDataNum6 === 3)) === null || _x === void 0 ? void 0 : _x.cardId) !== null && _y !== void 0 ? _y : (isOpponentSireD ? (_0 = (_z = opponentHero.questRewardEntities) === null || _z === void 0 ? void 0 : _z[0]) === null || _0 === void 0 ? void 0 : _0.cardId : null)) !== null && _1 !== void 0 ? _1 : opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.heroPowerId,
30
+ opponentHeroPowerCardId: (_3 = (_0 = (_z = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.trinkets.find((t) => t.scriptDataNum6 === 3)) === null || _z === void 0 ? void 0 : _z.cardId) !== null && _0 !== void 0 ? _0 : (isOpponentSireD ? (_2 = (_1 = opponentHero.questRewardEntities) === null || _1 === void 0 ? void 0 : _1[0]) === null || _2 === void 0 ? void 0 : _2.cardId : null)) !== null && _3 !== void 0 ? _3 : opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.heroPowerId,
30
31
  opponentHeroPowerEntityId: 200000002,
31
32
  opponentHeroPowerUsed: opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.heroPowerUsed,
32
- opponentRewardCardId: isOpponentSireD && ((_2 = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewardEntities) === null || _2 === void 0 ? void 0 : _2.length) < 2
33
+ opponentHeroPowers: opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.heroPowers,
34
+ opponentRewardCardId: isOpponentSireD && ((_4 = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewardEntities) === null || _4 === void 0 ? void 0 : _4.length) < 2
33
35
  ? null
34
- : (_5 = (_4 = (_3 = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewardEntities) === null || _3 === void 0 ? void 0 : _3[1]) === null || _4 === void 0 ? void 0 : _4.cardId) !== null && _5 !== void 0 ? _5 : (_6 = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewards) === null || _6 === void 0 ? void 0 : _6[0],
35
- opponentRewardEntityId: isOpponentSireD && ((_7 = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewardEntities) === null || _7 === void 0 ? void 0 : _7.length) < 2
36
+ : (_7 = (_6 = (_5 = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewardEntities) === null || _5 === void 0 ? void 0 : _5[1]) === null || _6 === void 0 ? void 0 : _6.cardId) !== null && _7 !== void 0 ? _7 : (_8 = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewards) === null || _8 === void 0 ? void 0 : _8[0],
37
+ opponentRewardEntityId: isOpponentSireD && ((_9 = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewardEntities) === null || _9 === void 0 ? void 0 : _9.length) < 2
36
38
  ? null
37
- : (_9 = (_8 = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewardEntities) === null || _8 === void 0 ? void 0 : _8[1]) === null || _9 === void 0 ? void 0 : _9.entityId,
38
- opponentRewardData: isOpponentSireD && ((_10 = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewardEntities) === null || _10 === void 0 ? void 0 : _10.length) < 2
39
+ : (_11 = (_10 = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewardEntities) === null || _10 === void 0 ? void 0 : _10[1]) === null || _11 === void 0 ? void 0 : _11.entityId,
40
+ opponentRewardData: isOpponentSireD && ((_12 = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewardEntities) === null || _12 === void 0 ? void 0 : _12.length) < 2
39
41
  ? null
40
- : (_13 = (_12 = (_11 = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewardEntities) === null || _11 === void 0 ? void 0 : _11[0]) === null || _12 === void 0 ? void 0 : _12.scriptDataNum1) !== null && _13 !== void 0 ? _13 : 0,
42
+ : (_15 = (_14 = (_13 = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewardEntities) === null || _13 === void 0 ? void 0 : _13[0]) === null || _14 === void 0 ? void 0 : _14.scriptDataNum1) !== null && _15 !== void 0 ? _15 : 0,
41
43
  opponentTrinkets: opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.trinkets,
42
44
  };
43
45
  return result;
@@ -1 +1 @@
1
- {"version":3,"file":"game-action.js","sourceRoot":"","sources":["../../../src/simulation/spectator/game-action.ts"],"names":[],"mappings":";;;AAwDO,MAAM,eAAe,GAAG,CAC9B,UAA2B,EAC3B,YAA6B,EAC7B,MAA2B,EACd,EAAE;;IACf,MAAM,aAAa,GAAG,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,0CAAE,UAAU,iBAAsC,CAAC;IAC3F,MAAM,eAAe,GAAG,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,MAAM,0CAAE,UAAU,iBAAsC,CAAC;IAC/F,MAAM,MAAM,GAAe;QAC1B,GAAG,MAAM;QAET,aAAa,EAAE,CAAC,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,OAAO,mCAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACtE,YAAY,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM;QAChC,cAAc,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ;QACpC,qBAAqB,EACpB,MAAA,MAAA,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,KAAK,CAAC,CAAC,0CAAE,MAAM,mCAChE,CAAC,aAAa,CAAC,CAAC,CAAC,MAAA,MAAA,UAAU,CAAC,mBAAmB,0CAAG,CAAC,CAAC,0CAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,mC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,YAAY,uBAAZ,YAAY,CAAE,mBAAmB,4CAAE,MAAM,IAAG,CAAC;YAC/D,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,OAAA,OAAA,OAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,mBAAmB,4CAAG,CAAC,CAAC,4CAAE,cAAc,qCAAI,CAAC;QAC/D,gBAAgB,EAAE,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,QAAQ;KAC1B,CAAC;IAChB,OAAO,MAAM,CAAC;AACf,CAAC,CAAC;AAzDW,QAAA,eAAe,mBAyD1B","sourcesContent":["import { CardIds } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity, BoardTrinket } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { BoardSecret } from '../../board-secret';\r\n\r\nexport interface GameAction {\r\n\ttype:\r\n\t\t| 'damage'\r\n\t\t| 'attack'\r\n\t\t| 'spawn'\r\n\t\t| 'minion-death'\r\n\t\t| 'power-target'\r\n\t\t| 'start-of-combat'\r\n\t\t| 'player-attack'\r\n\t\t| 'opponent-attack';\r\n\tplayerBoard: readonly BoardEntity[];\r\n\tplayerHand: readonly BoardEntity[];\r\n\tplayerSecrets: readonly BoardSecret[];\r\n\tplayerTrinkets: readonly BoardTrinket[];\r\n\topponentBoard: readonly BoardEntity[];\r\n\topponentHand: readonly BoardEntity[];\r\n\topponentSecrets: readonly BoardSecret[];\r\n\topponentTrinkets: readonly BoardTrinket[];\r\n\tplayerCardId: string;\r\n\tplayerEntityId: number;\r\n\tplayerHeroPowerCardId: string;\r\n\tplayerHeroPowerEntityId: number;\r\n\tplayerHeroPowerUsed: boolean;\r\n\topponentCardId: string;\r\n\topponentEntityId: number;\r\n\topponentHeroPowerCardId: string;\r\n\topponentHeroPowerEntityId: number;\r\n\topponentHeroPowerUsed: boolean;\r\n\tplayerRewardCardId: string;\r\n\tplayerRewardEntityId: number;\r\n\tplayerRewardData: number;\r\n\topponentRewardCardId: string;\r\n\topponentRewardEntityId: number;\r\n\topponentRewardData: number;\r\n\tsourceEntityId?: number;\r\n\t/** @deprecated */\r\n\ttargetEntityId?: number;\r\n\ttargetEntityIds?: number[];\r\n\r\n\tdamages?: Damage[];\r\n\tspawns?: readonly BoardEntity[];\r\n\tdeaths?: readonly BoardEntity[];\r\n\tdeadMinionsPositionsOnBoard?: readonly number[];\r\n}\r\n\r\nexport interface Damage {\r\n\treadonly sourceEntityId?: number;\r\n\treadonly targetEntityId?: number;\r\n\treadonly damage?: number;\r\n}\r\n\r\nexport const buildGameAction = (\r\n\tplayerHero: BgsPlayerEntity,\r\n\topponentHero: BgsPlayerEntity,\r\n\taction: Partial<GameAction>,\r\n): GameAction => {\r\n\tconst isPlayerSireD = playerHero?.cardId?.startsWith(CardIds.SireDenathrius_BG24_HERO_100);\r\n\tconst isOpponentSireD = opponentHero?.cardId?.startsWith(CardIds.SireDenathrius_BG24_HERO_100);\r\n\tconst result: GameAction = {\r\n\t\t...action,\r\n\r\n\t\tplayerSecrets: (playerHero?.secrets ?? []).filter((s) => !s.triggered),\r\n\t\tplayerCardId: playerHero?.cardId,\r\n\t\tplayerEntityId: playerHero?.entityId,\r\n\t\tplayerHeroPowerCardId:\r\n\t\t\tplayerHero?.trinkets.find((t) => t.scriptDataNum6 === 3)?.cardId ??\r\n\t\t\t(isPlayerSireD ? playerHero.questRewardEntities?.[0]?.cardId : null) ??\r\n\t\t\tplayerHero?.heroPowerId,\r\n\t\tplayerHeroPowerEntityId: 100000002,\r\n\t\tplayerHeroPowerUsed: playerHero?.heroPowerUsed,\r\n\t\tplayerRewardCardId:\r\n\t\t\tisPlayerSireD && playerHero?.questRewardEntities?.length < 2\r\n\t\t\t\t? null\r\n\t\t\t\t: playerHero?.questRewardEntities?.[1]?.cardId ?? playerHero?.questRewards?.[0],\r\n\t\tplayerRewardEntityId:\r\n\t\t\tisPlayerSireD && playerHero?.questRewardEntities?.length < 2\r\n\t\t\t\t? null\r\n\t\t\t\t: playerHero?.questRewardEntities?.[1]?.entityId,\r\n\t\tplayerRewardData:\r\n\t\t\tisPlayerSireD && playerHero?.questRewardEntities?.length < 2\r\n\t\t\t\t? null\r\n\t\t\t\t: playerHero?.questRewardEntities?.[0]?.scriptDataNum1 ?? 0,\r\n\t\tplayerTrinkets: playerHero?.trinkets,\r\n\r\n\t\topponentSecrets: (opponentHero?.secrets ?? []).filter((s) => !s.triggered),\r\n\t\topponentCardId: opponentHero?.cardId,\r\n\t\topponentEntityId: opponentHero?.entityId,\r\n\t\topponentHeroPowerCardId:\r\n\t\t\topponentHero?.trinkets.find((t) => t.scriptDataNum6 === 3)?.cardId ??\r\n\t\t\t(isOpponentSireD ? opponentHero.questRewardEntities?.[0]?.cardId : null) ??\r\n\t\t\topponentHero?.heroPowerId,\r\n\t\topponentHeroPowerEntityId: 200000002,\r\n\t\topponentHeroPowerUsed: opponentHero?.heroPowerUsed,\r\n\t\topponentRewardCardId:\r\n\t\t\tisOpponentSireD && opponentHero?.questRewardEntities?.length < 2\r\n\t\t\t\t? null\r\n\t\t\t\t: opponentHero?.questRewardEntities?.[1]?.cardId ?? opponentHero?.questRewards?.[0],\r\n\t\topponentRewardEntityId:\r\n\t\t\tisOpponentSireD && opponentHero?.questRewardEntities?.length < 2\r\n\t\t\t\t? null\r\n\t\t\t\t: opponentHero?.questRewardEntities?.[1]?.entityId,\r\n\t\topponentRewardData:\r\n\t\t\tisOpponentSireD && opponentHero?.questRewardEntities?.length < 2\r\n\t\t\t\t? null\r\n\t\t\t\t: opponentHero?.questRewardEntities?.[0]?.scriptDataNum1 ?? 0,\r\n\t\topponentTrinkets: opponentHero?.trinkets,\r\n\t} as GameAction;\r\n\treturn result;\r\n};\r\n"]}
1
+ {"version":3,"file":"game-action.js","sourceRoot":"","sources":["../../../src/simulation/spectator/game-action.ts"],"names":[],"mappings":";;;AA0DO,MAAM,eAAe,GAAG,CAC9B,UAA2B,EAC3B,YAA6B,EAC7B,MAA2B,EACd,EAAE;;IACf,MAAM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AAC,CAAC,4CAAE,cAAc,qCAAI,CAAC;QAC/D,gBAAgB,EAAE,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,QAAQ;KAC1B,CAAC;IAChB,OAAO,MAAM,CAAC;AACf,CAAC,CAAC;AA7DW,QAAA,eAAe,mBA6D1B","sourcesContent":["import { CardIds } from '@firestone-hs/reference-data';\r\nimport { BgsHeroPower, BgsPlayerEntity, BoardTrinket } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { BoardSecret } from '../../board-secret';\r\n\r\nexport interface GameAction {\r\n\ttype:\r\n\t\t| 'damage'\r\n\t\t| 'attack'\r\n\t\t| 'spawn'\r\n\t\t| 'minion-death'\r\n\t\t| 'power-target'\r\n\t\t| 'start-of-combat'\r\n\t\t| 'player-attack'\r\n\t\t| 'opponent-attack';\r\n\tplayerBoard: readonly BoardEntity[];\r\n\tplayerHand: readonly BoardEntity[];\r\n\tplayerSecrets: readonly BoardSecret[];\r\n\tplayerTrinkets: readonly BoardTrinket[];\r\n\topponentBoard: readonly BoardEntity[];\r\n\topponentHand: readonly BoardEntity[];\r\n\topponentSecrets: readonly BoardSecret[];\r\n\topponentTrinkets: readonly BoardTrinket[];\r\n\tplayerCardId: string;\r\n\tplayerEntityId: number;\r\n\tplayerHeroPowerCardId: string;\r\n\tplayerHeroPowerEntityId: number;\r\n\tplayerHeroPowerUsed: boolean;\r\n\tplayerHeroPowers: readonly BgsHeroPower[];\r\n\topponentCardId: string;\r\n\topponentEntityId: number;\r\n\topponentHeroPowerCardId: string;\r\n\topponentHeroPowerEntityId: number;\r\n\topponentHeroPowerUsed: boolean;\r\n\topponentHeroPowers: readonly BgsHeroPower[];\r\n\tplayerRewardCardId: string;\r\n\tplayerRewardEntityId: number;\r\n\tplayerRewardData: number;\r\n\topponentRewardCardId: string;\r\n\topponentRewardEntityId: number;\r\n\topponentRewardData: number;\r\n\tsourceEntityId?: number;\r\n\t/** @deprecated */\r\n\ttargetEntityId?: number;\r\n\ttargetEntityIds?: number[];\r\n\r\n\tdamages?: Damage[];\r\n\tspawns?: readonly BoardEntity[];\r\n\tdeaths?: readonly BoardEntity[];\r\n\tdeadMinionsPositionsOnBoard?: readonly number[];\r\n}\r\n\r\nexport interface Damage {\r\n\treadonly sourceEntityId?: number;\r\n\treadonly targetEntityId?: number;\r\n\treadonly damage?: number;\r\n}\r\n\r\nexport const buildGameAction = (\r\n\tplayerHero: BgsPlayerEntity,\r\n\topponentHero: BgsPlayerEntity,\r\n\taction: Partial<GameAction>,\r\n): GameAction => {\r\n\tconst isPlayerSireD = playerHero?.cardId?.startsWith(CardIds.SireDenathrius_BG24_HERO_100);\r\n\tconst isOpponentSireD = opponentHero?.cardId?.startsWith(CardIds.SireDenathrius_BG24_HERO_100);\r\n\tconst result: GameAction = {\r\n\t\t...action,\r\n\r\n\t\tplayerSecrets: (playerHero?.secrets ?? []).filter((s) => !s.triggered),\r\n\t\tplayerCardId: playerHero?.cardId,\r\n\t\tplayerEntityId: playerHero?.entityId,\r\n\r\n\t\tplayerHeroPowerCardId:\r\n\t\t\tplayerHero?.trinkets.find((t) => t.scriptDataNum6 === 3)?.cardId ??\r\n\t\t\t(isPlayerSireD ? playerHero.questRewardEntities?.[0]?.cardId : null) ??\r\n\t\t\tplayerHero?.heroPowers[0]?.cardId,\r\n\t\tplayerHeroPowerEntityId: 100000002,\r\n\t\tplayerHeroPowerUsed: playerHero?.heroPowers[0]?.used,\r\n\t\tplayerHeroPowers: playerHero?.heroPowers,\r\n\r\n\t\tplayerRewardCardId:\r\n\t\t\tisPlayerSireD && playerHero?.questRewardEntities?.length < 2\r\n\t\t\t\t? null\r\n\t\t\t\t: playerHero?.questRewardEntities?.[1]?.cardId ?? playerHero?.questRewards?.[0],\r\n\t\tplayerRewardEntityId:\r\n\t\t\tisPlayerSireD && playerHero?.questRewardEntities?.length < 2\r\n\t\t\t\t? null\r\n\t\t\t\t: playerHero?.questRewardEntities?.[1]?.entityId,\r\n\t\tplayerRewardData:\r\n\t\t\tisPlayerSireD && playerHero?.questRewardEntities?.length < 2\r\n\t\t\t\t? null\r\n\t\t\t\t: playerHero?.questRewardEntities?.[0]?.scriptDataNum1 ?? 0,\r\n\t\tplayerTrinkets: playerHero?.trinkets,\r\n\r\n\t\topponentSecrets: (opponentHero?.secrets ?? []).filter((s) => !s.triggered),\r\n\t\topponentCardId: opponentHero?.cardId,\r\n\t\topponentEntityId: opponentHero?.entityId,\r\n\t\topponentHeroPowerCardId:\r\n\t\t\topponentHero?.trinkets.find((t) => t.scriptDataNum6 === 3)?.cardId ??\r\n\t\t\t(isOpponentSireD ? opponentHero.questRewardEntities?.[0]?.cardId : null) ??\r\n\t\t\topponentHero?.heroPowerId,\r\n\t\topponentHeroPowerEntityId: 200000002,\r\n\t\topponentHeroPowerUsed: opponentHero?.heroPowerUsed,\r\n\t\topponentHeroPowers: opponentHero?.heroPowers,\r\n\t\topponentRewardCardId:\r\n\t\t\tisOpponentSireD && opponentHero?.questRewardEntities?.length < 2\r\n\t\t\t\t? null\r\n\t\t\t\t: opponentHero?.questRewardEntities?.[1]?.cardId ?? opponentHero?.questRewards?.[0],\r\n\t\topponentRewardEntityId:\r\n\t\t\tisOpponentSireD && opponentHero?.questRewardEntities?.length < 2\r\n\t\t\t\t? null\r\n\t\t\t\t: opponentHero?.questRewardEntities?.[1]?.entityId,\r\n\t\topponentRewardData:\r\n\t\t\tisOpponentSireD && opponentHero?.questRewardEntities?.length < 2\r\n\t\t\t\t? null\r\n\t\t\t\t: opponentHero?.questRewardEntities?.[0]?.scriptDataNum1 ?? 0,\r\n\t\topponentTrinkets: opponentHero?.trinkets,\r\n\t} as GameAction;\r\n\treturn result;\r\n};\r\n"]}
@@ -167,8 +167,6 @@ class Spectator {
167
167
  if (!targetEntity) {
168
168
  return;
169
169
  }
170
- if (!sourceEntity.entityId && !sourceEntity.heroPowerId) {
171
- }
172
170
  const friendlyBoard = (targetBoard === null || targetBoard === void 0 ? void 0 : targetBoard.every((entity) => entity.friendly)) ? targetBoard : null;
173
171
  const opponentBoard = (targetBoard === null || targetBoard === void 0 ? void 0 : targetBoard.every((entity) => !entity.friendly)) ? targetBoard : null;
174
172
  const friendlyHero = (hero1 === null || hero1 === void 0 ? void 0 : hero1.friendly) ? hero1 : (hero2 === null || hero2 === void 0 ? void 0 : hero2.friendly) ? hero2 : null;
@@ -1 +1 @@
1
- {"version":3,"file":"spectator.js","sourceRoot":"","sources":["../../../src/simulation/spectator/spectator.ts"],"names":[],"mappings":";;;AAGA,+CAA4D;AAG5D,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,MAAa,SAAS;IAMrB,YAA6B,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;QAC5C,IAAI,CAAC,uBAAuB,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACvB,CAAC;IAEM,KAAK;QACX,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;QACxD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;QAC1D,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;IAC3D,CAAC;IAEM,mBAAmB;;QAKzB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YAClB,OAAO;gBACN,GAAG,EAAE,EAAE;gBACP,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,EAAE;aACR,CAAC;SACF;QACD,OAAO;YACN,GAAG,EAAE,MAAA,IAAI,CAAC,UAAU,0CAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,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C;QACF,OAAO,MAAM,CAAC;IACf,CAAC;CACD;AA1cD,8BA0cC","sourcesContent":["import { BgsPlayerEntity, BoardTrinket } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { BoardSecret } from '../../board-secret';\r\nimport { GameAction, buildGameAction } from './game-action';\r\nimport { GameSample } from './game-sample';\r\n\r\nconst MAX_SAMPLES = 1;\r\n\r\nexport class Spectator {\r\n\tprivate actionsForCurrentBattle: GameAction[];\r\n\tprivate wonBattles: GameSample[];\r\n\tprivate tiedBattles: GameSample[];\r\n\tprivate lostBattles: GameSample[];\r\n\r\n\tconstructor(private readonly enabled: boolean) {\r\n\t\tthis.actionsForCurrentBattle = [];\r\n\t\tthis.wonBattles = [];\r\n\t\tthis.tiedBattles = [];\r\n\t\tthis.lostBattles = [];\r\n\t}\r\n\r\n\tpublic prune(): void {\r\n\t\tthis.wonBattles = this.wonBattles.slice(0, MAX_SAMPLES);\r\n\t\tthis.lostBattles = this.lostBattles.slice(0, MAX_SAMPLES);\r\n\t\tthis.tiedBattles = this.tiedBattles.slice(0, MAX_SAMPLES);\r\n\t}\r\n\r\n\tpublic buildOutcomeSamples(): {\r\n\t\twon: readonly GameSample[];\r\n\t\tlost: readonly GameSample[];\r\n\t\ttied: readonly GameSample[];\r\n\t} {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn {\r\n\t\t\t\twon: [],\r\n\t\t\t\tlost: [],\r\n\t\t\t\ttied: [],\r\n\t\t\t};\r\n\t\t}\r\n\t\treturn {\r\n\t\t\twon: this.wonBattles?.map((battle) => this.cleanUpActions(battle)),\r\n\t\t\tlost: this.lostBattles?.map((battle) => this.cleanUpActions(battle)),\r\n\t\t\ttied: this.tiedBattles?.map((battle) => this.cleanUpActions(battle)),\r\n\t\t};\r\n\t}\r\n\r\n\tprivate cleanUpActions(battle: GameSample): GameSample {\r\n\t\tconst collapsed = this.collapseActions(battle.actions);\r\n\t\tconst result: GameSample = {\r\n\t\t\t...battle,\r\n\t\t\tactions: collapsed,\r\n\t\t};\r\n\t\treturn result;\r\n\t}\r\n\r\n\tpublic commitBattleResult(result: 'won' | 'lost' | 'tied'): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\tthis.actionsForCurrentBattle = [];\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (\r\n\t\t\tthis.wonBattles.length >= MAX_SAMPLES &&\r\n\t\t\tthis.lostBattles.length >= MAX_SAMPLES &&\r\n\t\t\tthis.tiedBattles.length >= MAX_SAMPLES\r\n\t\t) {\r\n\t\t\tthis.actionsForCurrentBattle = [];\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// const actionsForBattle = this.collapseActions(this.actionsForCurrentBattle);\r\n\t\tconst actionsForBattle = this.actionsForCurrentBattle;\r\n\t\tthis.actionsForCurrentBattle = [];\r\n\r\n\t\tconst battle: GameSample = {\r\n\t\t\tactions: actionsForBattle,\r\n\t\t};\r\n\t\tswitch (result) {\r\n\t\t\tcase 'won':\r\n\t\t\t\tthis.wonBattles.push(battle);\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'lost':\r\n\t\t\t\tthis.lostBattles.push(battle);\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'tied':\r\n\t\t\t\tthis.tiedBattles.push(battle);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic registerAttack(\r\n\t\tattackingEntity: BoardEntity,\r\n\t\tdefendingEntity: BoardEntity,\r\n\t\tattackingBoard: readonly BoardEntity[],\r\n\t\tdefendingBoard: readonly BoardEntity[],\r\n\t\tattackingBoardHero: BgsPlayerEntity,\r\n\t\tdefendingBoardHero: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// console.debug(\r\n\t\t// \t'\\n register attack',\r\n\t\t// \tstringifySimple(attackingBoard),\r\n\t\t// \t'\\n',\r\n\t\t// \tstringifySimple(defendingBoard),\r\n\t\t// \t'\\n',\r\n\t\t// \tattackingBoard.find((e) => e.entityId === 2441),\r\n\t\t// \t'\\n',\r\n\t\t// \tattackingBoard.find((e) => e.entityId === 2442),\r\n\t\t// );\r\n\t\tconst isAttackerFriendly = attackingBoard.every((entity) => entity.friendly);\r\n\t\tconst playerHero = isAttackerFriendly ? attackingBoardHero : defendingBoardHero;\r\n\t\tconst opponentHero = isAttackerFriendly ? defendingBoardHero : attackingBoardHero;\r\n\t\tconst friendlyBoard = isAttackerFriendly ? attackingBoard : defendingBoard;\r\n\t\tconst opponentBoard = isAttackerFriendly ? defendingBoard : attackingBoard;\r\n\t\tconst action: GameAction = buildGameAction(playerHero, opponentHero, {\r\n\t\t\ttype: 'attack',\r\n\t\t\tsourceEntityId: attackingEntity.entityId,\r\n\t\t\ttargetEntityId: defendingEntity.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\tplayerHand: this.sanitize(playerHero.hand),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\topponentHand: this.sanitize(opponentHero.hand),\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerStartOfCombat(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tfriendlyHero: BgsPlayerEntity,\r\n\t\topponentHero: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(friendlyHero, opponentHero, {\r\n\t\t\ttype: 'start-of-combat',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: this.sanitize(friendlyHero.hand),\r\n\t\t\topponentHand: this.sanitize(opponentHero.hand),\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerPlayerAttack(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tdamage: number,\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'player-attack',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tdamage: damage,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerOpponentAttack(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tdamage: number,\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'opponent-attack',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tdamage: damage,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerDamageDealt(\r\n\t\tdamagingEntity: BoardEntity,\r\n\t\tdamagedEntity: BoardEntity,\r\n\t\tdamageTaken: number,\r\n\t\tdamagedEntityBoard: BoardEntity[],\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!damagingEntity.entityId) {\r\n\t\t\t// console.error('missing damaging entity id', damagingEntity.cardId);\r\n\t\t}\r\n\t\tconst friendlyBoard = damagedEntityBoard.every((entity) => entity.friendly) ? damagedEntityBoard : null;\r\n\t\tconst opponentBoard = damagedEntityBoard.every((entity) => !entity.friendly) ? damagedEntityBoard : null;\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'damage',\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tsourceEntityId: damagingEntity.entityId,\r\n\t\t\t\t\ttargetEntityId: damagedEntity.entityId,\r\n\t\t\t\t\tdamage: damageTaken,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerPowerTarget(\r\n\t\tsourceEntity: BoardEntity | BgsPlayerEntity | BoardSecret | BoardTrinket,\r\n\t\ttargetEntity: BoardEntity | BgsPlayerEntity,\r\n\t\ttargetBoard: BoardEntity[],\r\n\t\thero1: BgsPlayerEntity,\r\n\t\thero2: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!targetEntity) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!sourceEntity.entityId && !(sourceEntity as BgsPlayerEntity).heroPowerId) {\r\n\t\t\t// console.error('missing damaging entity id', sourceEntity.cardId);\r\n\t\t}\r\n\t\t// console.log('registerPowerTarget', stringifySimpleCard(sourceEntity), stringifySimpleCard(targetEntity), new Error().stack);\r\n\t\tconst friendlyBoard = targetBoard?.every((entity) => entity.friendly) ? targetBoard : null;\r\n\t\tconst opponentBoard = targetBoard?.every((entity) => !entity.friendly) ? targetBoard : null;\r\n\t\tconst friendlyHero = hero1?.friendly ? hero1 : hero2?.friendly ? hero2 : null;\r\n\t\tconst opponentHero = hero1?.friendly ? hero2 : hero2?.friendly ? hero1 : null;\r\n\t\tconst action: GameAction = buildGameAction(friendlyHero, opponentHero, {\r\n\t\t\ttype: 'power-target',\r\n\t\t\tsourceEntityId: sourceEntity.entityId,\r\n\t\t\ttargetEntityId: targetEntity.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: this.sanitize(friendlyHero?.hand),\r\n\t\t\topponentHand: this.sanitize(opponentHero?.hand),\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerMinionsSpawn(\r\n\t\tsourceEntity: BoardEntity | BgsPlayerEntity,\r\n\t\tboardOnWhichToSpawn: BoardEntity[],\r\n\t\tspawnedEntities: readonly BoardEntity[],\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!spawnedEntities || spawnedEntities.length === 0) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (!sourceEntity?.entityId) {\r\n\t\t\t// console.error('missing spawn source entity id', sourceEntity);\r\n\t\t}\r\n\t\tconst friendlyBoard = boardOnWhichToSpawn.every((entity) => entity.friendly) ? boardOnWhichToSpawn : null;\r\n\t\tconst opponentBoard = boardOnWhichToSpawn.every((entity) => !entity.friendly) ? boardOnWhichToSpawn : null;\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'spawn',\r\n\t\t\tspawns: this.sanitize(spawnedEntities),\r\n\t\t\tsourceEntityId: sourceEntity?.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerDeadEntities(\r\n\t\tdeadMinionIndexes1: number[],\r\n\t\tdeadEntities1: BoardEntity[],\r\n\t\tboard1: BoardEntity[],\r\n\t\tdeadMinionIndexes2: number[],\r\n\t\tdeadEntities2: BoardEntity[],\r\n\t\tboard2: BoardEntity[],\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst deaths = [...(deadEntities1 || []), ...(deadEntities2 || [])];\r\n\t\tif (!deaths || deaths.length === 0) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'minion-death',\r\n\t\t\tdeaths: this.sanitize(deaths),\r\n\t\t\tdeadMinionsPositionsOnBoard: [\r\n\t\t\t\t...(deadMinionIndexes1 || []).map((i) => board1.length - i),\r\n\t\t\t\t...(deadMinionIndexes2 || []).map((i) => board2.length - i),\r\n\t\t\t],\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tprivate addAction(action: GameAction) {\r\n\t\tthis.actionsForCurrentBattle.push(action);\r\n\t}\r\n\r\n\tprivate collapseActions(actions: readonly GameAction[]): readonly GameAction[] {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\t\tif (!actions || actions.length === 0) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\t\tconst result: GameAction[] = [];\r\n\t\tfor (let i = 0; i < actions.length; i++) {\r\n\t\t\tconst action: GameAction = {\r\n\t\t\t\t...actions[i],\r\n\t\t\t\tplayerBoard: this.sanitize(actions[i].playerBoard),\r\n\t\t\t\topponentBoard: this.sanitize(actions[i].opponentBoard),\r\n\t\t\t\tplayerHand: this.sanitize(actions[i].playerHand),\r\n\t\t\t\topponentHand: this.sanitize(actions[i].opponentHand),\r\n\t\t\t\t// spawns: this.sanitize(actions[i].spawns),\r\n\t\t\t\tdeaths: this.sanitize(actions[i].deaths),\r\n\t\t\t\tplayerTrinkets: this.sanitizeTrinkets(actions[i].playerTrinkets),\r\n\t\t\t\topponentTrinkets: this.sanitizeTrinkets(actions[i].opponentTrinkets),\r\n\t\t\t};\r\n\t\t\t// action.playerBoard && console.debug('\\naction playerboard', stringifySimple(action.playerBoard));\r\n\t\t\tconst lastAction = result.length > 0 ? result[result.length - 1] : null;\r\n\r\n\t\t\tif (lastAction) {\r\n\t\t\t\taction.playerBoard = action.playerBoard ?? lastAction.playerBoard;\r\n\t\t\t\taction.opponentBoard = action.opponentBoard ?? lastAction.opponentBoard;\r\n\t\t\t\taction.playerHand = action.playerHand ?? lastAction.playerHand;\r\n\t\t\t\taction.opponentHand = action.opponentHand ?? lastAction.opponentHand;\r\n\t\t\t\taction.playerSecrets = action.playerSecrets ?? lastAction.playerSecrets;\r\n\t\t\t\taction.opponentSecrets = action.opponentSecrets ?? lastAction.opponentSecrets;\r\n\t\t\t\taction.playerRewardCardId = action.playerRewardCardId ?? lastAction.playerRewardCardId;\r\n\t\t\t\taction.playerRewardEntityId = action.playerRewardEntityId ?? lastAction.playerRewardEntityId;\r\n\t\t\t\taction.playerRewardData = action.playerRewardData ?? lastAction.playerRewardData;\r\n\t\t\t\taction.opponentRewardCardId = action.opponentRewardCardId ?? lastAction.opponentRewardCardId;\r\n\t\t\t\taction.opponentRewardEntityId = action.opponentRewardEntityId ?? lastAction.opponentRewardEntityId;\r\n\t\t\t\taction.opponentRewardData = action.opponentRewardData ?? lastAction.opponentRewardData;\r\n\t\t\t\taction.playerCardId = action.playerCardId ?? lastAction.playerCardId;\r\n\t\t\t\taction.playerEntityId = action.playerEntityId ?? lastAction.playerEntityId;\r\n\t\t\t\taction.playerHeroPowerCardId = action.playerHeroPowerCardId ?? lastAction.playerHeroPowerCardId;\r\n\t\t\t\taction.playerHeroPowerEntityId = action.playerHeroPowerEntityId ?? lastAction.playerHeroPowerEntityId;\r\n\t\t\t\taction.playerHeroPowerUsed = action.playerHeroPowerUsed ?? lastAction.playerHeroPowerUsed;\r\n\t\t\t\taction.opponentCardId = action.opponentCardId ?? lastAction.opponentCardId;\r\n\t\t\t\taction.opponentEntityId = action.opponentEntityId ?? lastAction.opponentEntityId;\r\n\t\t\t\taction.opponentHeroPowerCardId = action.opponentHeroPowerCardId ?? lastAction.opponentHeroPowerCardId;\r\n\t\t\t\taction.opponentHeroPowerEntityId =\r\n\t\t\t\t\taction.opponentHeroPowerEntityId ?? lastAction.opponentHeroPowerEntityId;\r\n\t\t\t\taction.opponentHeroPowerUsed = action.opponentHeroPowerUsed ?? lastAction.opponentHeroPowerUsed;\r\n\t\t\t\taction.playerTrinkets = action.playerTrinkets ?? lastAction.playerTrinkets;\r\n\t\t\t\taction.opponentTrinkets = action.opponentTrinkets ?? lastAction.opponentTrinkets;\r\n\t\t\t}\r\n\r\n\t\t\tif (lastAction && action.type === 'damage' && lastAction.type === 'attack') {\r\n\t\t\t\tlastAction.damages = lastAction.damages || [];\r\n\t\t\t\tlastAction.damages.push({\r\n\t\t\t\t\tdamage: action.damages[0].damage,\r\n\t\t\t\t\tsourceEntityId: action.damages[0].sourceEntityId,\r\n\t\t\t\t\ttargetEntityId: action.damages[0].targetEntityId,\r\n\t\t\t\t});\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t\tlastAction.playerTrinkets = action.playerTrinkets;\r\n\t\t\t\tlastAction.opponentTrinkets = action.opponentTrinkets;\r\n\t\t\t} else if (lastAction && action.type === 'damage' && lastAction.type === 'damage') {\r\n\t\t\t\tlastAction.damages = lastAction.damages || [];\r\n\t\t\t\tlastAction.damages.push({\r\n\t\t\t\t\tdamage: action.damages[0].damage,\r\n\t\t\t\t\tsourceEntityId: action.damages[0].sourceEntityId,\r\n\t\t\t\t\ttargetEntityId: action.damages[0].targetEntityId,\r\n\t\t\t\t});\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t\tlastAction.playerTrinkets = action.playerTrinkets;\r\n\t\t\t\tlastAction.opponentTrinkets = action.opponentTrinkets;\r\n\t\t\t} else if (\r\n\t\t\t\tlastAction &&\r\n\t\t\t\taction.type === 'power-target' &&\r\n\t\t\t\tlastAction.type === 'power-target' &&\r\n\t\t\t\taction.sourceEntityId === lastAction.sourceEntityId\r\n\t\t\t) {\r\n\t\t\t\tlastAction.targetEntityIds =\r\n\t\t\t\t\tlastAction.targetEntityIds ?? (lastAction.targetEntityId ? [lastAction.targetEntityId] : []);\r\n\t\t\t\taction.targetEntityIds =\r\n\t\t\t\t\taction.targetEntityIds ?? (action.targetEntityId ? [action.targetEntityId] : []);\r\n\t\t\t\tlastAction.targetEntityIds.push(...action.targetEntityIds);\r\n\t\t\t\t// So that when multiple Leapfroggers enchantments target the same minion,\r\n\t\t\t\t// we can count them in the replay viewer's text\r\n\t\t\t\t// lastAction.targetEntityIds = [...new Set(lastAction.targetEntityIds)];\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t\tlastAction.playerTrinkets = action.playerTrinkets;\r\n\t\t\t\tlastAction.opponentTrinkets = action.opponentTrinkets;\r\n\t\t\t} else {\r\n\t\t\t\tresult.push(action);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\t// Calling sanitize every time before we add an action to the list is mandatory, since\r\n\t// the entities and boards are mutable\r\n\tprivate sanitize(board: readonly BoardEntity[]): readonly BoardEntity[] {\r\n\t\tif (!board) {\r\n\t\t\treturn undefined;\r\n\t\t}\r\n\t\treturn board.map(\r\n\t\t\t(entity) =>\r\n\t\t\t\t({\r\n\t\t\t\t\tentityId: entity.entityId,\r\n\t\t\t\t\tcardId: entity.cardId,\r\n\t\t\t\t\tfriendly: entity.friendly,\r\n\t\t\t\t\tattack: entity.attack,\r\n\t\t\t\t\thealth: entity.health,\r\n\t\t\t\t\tmaxHealth: entity.maxHealth,\r\n\t\t\t\t\ttaunt: entity.taunt,\r\n\t\t\t\t\tdivineShield: entity.divineShield,\r\n\t\t\t\t\tpoisonous: entity.poisonous,\r\n\t\t\t\t\tvenomous: entity.venomous,\r\n\t\t\t\t\treborn: entity.reborn,\r\n\t\t\t\t\twindfury: entity.windfury,\r\n\t\t\t\t\tstealth: entity.stealth,\r\n\t\t\t\t} as BoardEntity),\r\n\t\t);\r\n\t}\r\n\r\n\tprivate sanitizeTrinkets(trinkets: readonly BoardTrinket[]): readonly BoardTrinket[] {\r\n\t\tif (!trinkets?.length) {\r\n\t\t\treturn undefined;\r\n\t\t}\r\n\t\tconst result = trinkets.map(\r\n\t\t\t(t) =>\r\n\t\t\t\t({\r\n\t\t\t\t\tcardId: t.cardId,\r\n\t\t\t\t\tentityId: t.entityId,\r\n\t\t\t\t\tscriptDataNum1: t.scriptDataNum1,\r\n\t\t\t\t\tscriptDataNum6: t.scriptDataNum6,\r\n\t\t\t\t} as BoardTrinket),\r\n\t\t);\r\n\t\treturn result;\r\n\t}\r\n}\r\n"]}
1
+ {"version":3,"file":"spectator.js","sourceRoot":"","sources":["../../../src/simulation/spectator/spectator.ts"],"names":[],"mappings":";;;AAGA,+CAA4D;AAG5D,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,MAAa,SAAS;IAMrB,YAA6B,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;QAC5C,IAAI,CAAC,uBAAuB,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,C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;YACjC,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,OAAO,EAAE,MAAM,CAAC,OAAO;SACP,CAAA,CAClB,CAAC;IACH,CAAC;IAEO,gBAAgB,CAAC,QAAiC;QACzD,IAAI,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,CAAA,EAAE;YACtB,OAAO,SAAS,CAAC;SACjB;QACD,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAC1B,CAAC,CAAC,EAAE,EAAE,CACL,CAAC;YACA,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,cAAc,EAAE,CAAC,CAAC,cAAc;YAChC,cAAc,EAAE,CAAC,CAAC,cAAc;SACf,CAAA,CACnB,CAAC;QACF,OAAO,MAAM,CAAC;IACf,CAAC;CACD;AAvcD,8BAucC","sourcesContent":["import { BgsPlayerEntity, BoardTrinket } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { BoardSecret } from '../../board-secret';\r\nimport { GameAction, buildGameAction } from './game-action';\r\nimport { GameSample } from './game-sample';\r\n\r\nconst MAX_SAMPLES = 1;\r\n\r\nexport class Spectator {\r\n\tprivate actionsForCurrentBattle: GameAction[];\r\n\tprivate wonBattles: GameSample[];\r\n\tprivate tiedBattles: GameSample[];\r\n\tprivate lostBattles: GameSample[];\r\n\r\n\tconstructor(private readonly enabled: boolean) {\r\n\t\tthis.actionsForCurrentBattle = [];\r\n\t\tthis.wonBattles = [];\r\n\t\tthis.tiedBattles = [];\r\n\t\tthis.lostBattles = [];\r\n\t}\r\n\r\n\tpublic prune(): void {\r\n\t\tthis.wonBattles = this.wonBattles.slice(0, MAX_SAMPLES);\r\n\t\tthis.lostBattles = this.lostBattles.slice(0, MAX_SAMPLES);\r\n\t\tthis.tiedBattles = this.tiedBattles.slice(0, MAX_SAMPLES);\r\n\t}\r\n\r\n\tpublic buildOutcomeSamples(): {\r\n\t\twon: readonly GameSample[];\r\n\t\tlost: readonly GameSample[];\r\n\t\ttied: readonly GameSample[];\r\n\t} {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn {\r\n\t\t\t\twon: [],\r\n\t\t\t\tlost: [],\r\n\t\t\t\ttied: [],\r\n\t\t\t};\r\n\t\t}\r\n\t\treturn {\r\n\t\t\twon: this.wonBattles?.map((battle) => this.cleanUpActions(battle)),\r\n\t\t\tlost: this.lostBattles?.map((battle) => this.cleanUpActions(battle)),\r\n\t\t\ttied: this.tiedBattles?.map((battle) => this.cleanUpActions(battle)),\r\n\t\t};\r\n\t}\r\n\r\n\tprivate cleanUpActions(battle: GameSample): GameSample {\r\n\t\tconst collapsed = this.collapseActions(battle.actions);\r\n\t\tconst result: GameSample = {\r\n\t\t\t...battle,\r\n\t\t\tactions: collapsed,\r\n\t\t};\r\n\t\treturn result;\r\n\t}\r\n\r\n\tpublic commitBattleResult(result: 'won' | 'lost' | 'tied'): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\tthis.actionsForCurrentBattle = [];\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (\r\n\t\t\tthis.wonBattles.length >= MAX_SAMPLES &&\r\n\t\t\tthis.lostBattles.length >= MAX_SAMPLES &&\r\n\t\t\tthis.tiedBattles.length >= MAX_SAMPLES\r\n\t\t) {\r\n\t\t\tthis.actionsForCurrentBattle = [];\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// const actionsForBattle = this.collapseActions(this.actionsForCurrentBattle);\r\n\t\tconst actionsForBattle = this.actionsForCurrentBattle;\r\n\t\tthis.actionsForCurrentBattle = [];\r\n\r\n\t\tconst battle: GameSample = {\r\n\t\t\tactions: actionsForBattle,\r\n\t\t};\r\n\t\tswitch (result) {\r\n\t\t\tcase 'won':\r\n\t\t\t\tthis.wonBattles.push(battle);\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'lost':\r\n\t\t\t\tthis.lostBattles.push(battle);\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'tied':\r\n\t\t\t\tthis.tiedBattles.push(battle);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic registerAttack(\r\n\t\tattackingEntity: BoardEntity,\r\n\t\tdefendingEntity: BoardEntity,\r\n\t\tattackingBoard: readonly BoardEntity[],\r\n\t\tdefendingBoard: readonly BoardEntity[],\r\n\t\tattackingBoardHero: BgsPlayerEntity,\r\n\t\tdefendingBoardHero: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// console.debug(\r\n\t\t// \t'\\n register attack',\r\n\t\t// \tstringifySimple(attackingBoard),\r\n\t\t// \t'\\n',\r\n\t\t// \tstringifySimple(defendingBoard),\r\n\t\t// \t'\\n',\r\n\t\t// \tattackingBoard.find((e) => e.entityId === 2441),\r\n\t\t// \t'\\n',\r\n\t\t// \tattackingBoard.find((e) => e.entityId === 2442),\r\n\t\t// );\r\n\t\tconst isAttackerFriendly = attackingBoard.every((entity) => entity.friendly);\r\n\t\tconst playerHero = isAttackerFriendly ? attackingBoardHero : defendingBoardHero;\r\n\t\tconst opponentHero = isAttackerFriendly ? defendingBoardHero : attackingBoardHero;\r\n\t\tconst friendlyBoard = isAttackerFriendly ? attackingBoard : defendingBoard;\r\n\t\tconst opponentBoard = isAttackerFriendly ? defendingBoard : attackingBoard;\r\n\t\tconst action: GameAction = buildGameAction(playerHero, opponentHero, {\r\n\t\t\ttype: 'attack',\r\n\t\t\tsourceEntityId: attackingEntity.entityId,\r\n\t\t\ttargetEntityId: defendingEntity.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\tplayerHand: this.sanitize(playerHero.hand),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\topponentHand: this.sanitize(opponentHero.hand),\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerStartOfCombat(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tfriendlyHero: BgsPlayerEntity,\r\n\t\topponentHero: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(friendlyHero, opponentHero, {\r\n\t\t\ttype: 'start-of-combat',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: this.sanitize(friendlyHero.hand),\r\n\t\t\topponentHand: this.sanitize(opponentHero.hand),\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerPlayerAttack(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tdamage: number,\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'player-attack',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tdamage: damage,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerOpponentAttack(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tdamage: number,\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'opponent-attack',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tdamage: damage,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerDamageDealt(\r\n\t\tdamagingEntity: BoardEntity,\r\n\t\tdamagedEntity: BoardEntity,\r\n\t\tdamageTaken: number,\r\n\t\tdamagedEntityBoard: BoardEntity[],\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!damagingEntity.entityId) {\r\n\t\t\t// console.error('missing damaging entity id', damagingEntity.cardId);\r\n\t\t}\r\n\t\tconst friendlyBoard = damagedEntityBoard.every((entity) => entity.friendly) ? damagedEntityBoard : null;\r\n\t\tconst opponentBoard = damagedEntityBoard.every((entity) => !entity.friendly) ? damagedEntityBoard : null;\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'damage',\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tsourceEntityId: damagingEntity.entityId,\r\n\t\t\t\t\ttargetEntityId: damagedEntity.entityId,\r\n\t\t\t\t\tdamage: damageTaken,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerPowerTarget(\r\n\t\tsourceEntity: BoardEntity | BgsPlayerEntity | BoardSecret | BoardTrinket,\r\n\t\ttargetEntity: BoardEntity | BgsPlayerEntity,\r\n\t\ttargetBoard: BoardEntity[],\r\n\t\thero1: BgsPlayerEntity,\r\n\t\thero2: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!targetEntity) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// console.log('registerPowerTarget', stringifySimpleCard(sourceEntity), stringifySimpleCard(targetEntity), new Error().stack);\r\n\t\tconst friendlyBoard = targetBoard?.every((entity) => entity.friendly) ? targetBoard : null;\r\n\t\tconst opponentBoard = targetBoard?.every((entity) => !entity.friendly) ? targetBoard : null;\r\n\t\tconst friendlyHero = hero1?.friendly ? hero1 : hero2?.friendly ? hero2 : null;\r\n\t\tconst opponentHero = hero1?.friendly ? hero2 : hero2?.friendly ? hero1 : null;\r\n\t\tconst action: GameAction = buildGameAction(friendlyHero, opponentHero, {\r\n\t\t\ttype: 'power-target',\r\n\t\t\tsourceEntityId: sourceEntity.entityId,\r\n\t\t\ttargetEntityId: targetEntity.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: this.sanitize(friendlyHero?.hand),\r\n\t\t\topponentHand: this.sanitize(opponentHero?.hand),\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerMinionsSpawn(\r\n\t\tsourceEntity: BoardEntity | BgsPlayerEntity,\r\n\t\tboardOnWhichToSpawn: BoardEntity[],\r\n\t\tspawnedEntities: readonly BoardEntity[],\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!spawnedEntities || spawnedEntities.length === 0) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (!sourceEntity?.entityId) {\r\n\t\t\t// console.error('missing spawn source entity id', sourceEntity);\r\n\t\t}\r\n\t\tconst friendlyBoard = boardOnWhichToSpawn.every((entity) => entity.friendly) ? boardOnWhichToSpawn : null;\r\n\t\tconst opponentBoard = boardOnWhichToSpawn.every((entity) => !entity.friendly) ? boardOnWhichToSpawn : null;\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'spawn',\r\n\t\t\tspawns: this.sanitize(spawnedEntities),\r\n\t\t\tsourceEntityId: sourceEntity?.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerDeadEntities(\r\n\t\tdeadMinionIndexes1: number[],\r\n\t\tdeadEntities1: BoardEntity[],\r\n\t\tboard1: BoardEntity[],\r\n\t\tdeadMinionIndexes2: number[],\r\n\t\tdeadEntities2: BoardEntity[],\r\n\t\tboard2: BoardEntity[],\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst deaths = [...(deadEntities1 || []), ...(deadEntities2 || [])];\r\n\t\tif (!deaths || deaths.length === 0) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'minion-death',\r\n\t\t\tdeaths: this.sanitize(deaths),\r\n\t\t\tdeadMinionsPositionsOnBoard: [\r\n\t\t\t\t...(deadMinionIndexes1 || []).map((i) => board1.length - i),\r\n\t\t\t\t...(deadMinionIndexes2 || []).map((i) => board2.length - i),\r\n\t\t\t],\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tprivate addAction(action: GameAction) {\r\n\t\tthis.actionsForCurrentBattle.push(action);\r\n\t}\r\n\r\n\tprivate collapseActions(actions: readonly GameAction[]): readonly GameAction[] {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\t\tif (!actions || actions.length === 0) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\t\tconst result: GameAction[] = [];\r\n\t\tfor (let i = 0; i < actions.length; i++) {\r\n\t\t\tconst action: GameAction = {\r\n\t\t\t\t...actions[i],\r\n\t\t\t\tplayerBoard: this.sanitize(actions[i].playerBoard),\r\n\t\t\t\topponentBoard: this.sanitize(actions[i].opponentBoard),\r\n\t\t\t\tplayerHand: this.sanitize(actions[i].playerHand),\r\n\t\t\t\topponentHand: this.sanitize(actions[i].opponentHand),\r\n\t\t\t\t// spawns: this.sanitize(actions[i].spawns),\r\n\t\t\t\tdeaths: this.sanitize(actions[i].deaths),\r\n\t\t\t\tplayerTrinkets: this.sanitizeTrinkets(actions[i].playerTrinkets),\r\n\t\t\t\topponentTrinkets: this.sanitizeTrinkets(actions[i].opponentTrinkets),\r\n\t\t\t};\r\n\t\t\t// action.playerBoard && console.debug('\\naction playerboard', stringifySimple(action.playerBoard));\r\n\t\t\tconst lastAction = result.length > 0 ? result[result.length - 1] : null;\r\n\r\n\t\t\tif (lastAction) {\r\n\t\t\t\taction.playerBoard = action.playerBoard ?? lastAction.playerBoard;\r\n\t\t\t\taction.opponentBoard = action.opponentBoard ?? lastAction.opponentBoard;\r\n\t\t\t\taction.playerHand = action.playerHand ?? lastAction.playerHand;\r\n\t\t\t\taction.opponentHand = action.opponentHand ?? lastAction.opponentHand;\r\n\t\t\t\taction.playerSecrets = action.playerSecrets ?? lastAction.playerSecrets;\r\n\t\t\t\taction.opponentSecrets = action.opponentSecrets ?? lastAction.opponentSecrets;\r\n\t\t\t\taction.playerRewardCardId = action.playerRewardCardId ?? lastAction.playerRewardCardId;\r\n\t\t\t\taction.playerRewardEntityId = action.playerRewardEntityId ?? lastAction.playerRewardEntityId;\r\n\t\t\t\taction.playerRewardData = action.playerRewardData ?? lastAction.playerRewardData;\r\n\t\t\t\taction.opponentRewardCardId = action.opponentRewardCardId ?? lastAction.opponentRewardCardId;\r\n\t\t\t\taction.opponentRewardEntityId = action.opponentRewardEntityId ?? lastAction.opponentRewardEntityId;\r\n\t\t\t\taction.opponentRewardData = action.opponentRewardData ?? lastAction.opponentRewardData;\r\n\t\t\t\taction.playerCardId = action.playerCardId ?? lastAction.playerCardId;\r\n\t\t\t\taction.playerEntityId = action.playerEntityId ?? lastAction.playerEntityId;\r\n\t\t\t\taction.playerHeroPowerCardId = action.playerHeroPowerCardId ?? lastAction.playerHeroPowerCardId;\r\n\t\t\t\taction.playerHeroPowerEntityId = action.playerHeroPowerEntityId ?? lastAction.playerHeroPowerEntityId;\r\n\t\t\t\taction.playerHeroPowerUsed = action.playerHeroPowerUsed ?? lastAction.playerHeroPowerUsed;\r\n\t\t\t\taction.opponentCardId = action.opponentCardId ?? lastAction.opponentCardId;\r\n\t\t\t\taction.opponentEntityId = action.opponentEntityId ?? lastAction.opponentEntityId;\r\n\t\t\t\taction.opponentHeroPowerCardId = action.opponentHeroPowerCardId ?? lastAction.opponentHeroPowerCardId;\r\n\t\t\t\taction.opponentHeroPowerEntityId =\r\n\t\t\t\t\taction.opponentHeroPowerEntityId ?? lastAction.opponentHeroPowerEntityId;\r\n\t\t\t\taction.opponentHeroPowerUsed = action.opponentHeroPowerUsed ?? lastAction.opponentHeroPowerUsed;\r\n\t\t\t\taction.playerTrinkets = action.playerTrinkets ?? lastAction.playerTrinkets;\r\n\t\t\t\taction.opponentTrinkets = action.opponentTrinkets ?? lastAction.opponentTrinkets;\r\n\t\t\t}\r\n\r\n\t\t\tif (lastAction && action.type === 'damage' && lastAction.type === 'attack') {\r\n\t\t\t\tlastAction.damages = lastAction.damages || [];\r\n\t\t\t\tlastAction.damages.push({\r\n\t\t\t\t\tdamage: action.damages[0].damage,\r\n\t\t\t\t\tsourceEntityId: action.damages[0].sourceEntityId,\r\n\t\t\t\t\ttargetEntityId: action.damages[0].targetEntityId,\r\n\t\t\t\t});\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t\tlastAction.playerTrinkets = action.playerTrinkets;\r\n\t\t\t\tlastAction.opponentTrinkets = action.opponentTrinkets;\r\n\t\t\t} else if (lastAction && action.type === 'damage' && lastAction.type === 'damage') {\r\n\t\t\t\tlastAction.damages = lastAction.damages || [];\r\n\t\t\t\tlastAction.damages.push({\r\n\t\t\t\t\tdamage: action.damages[0].damage,\r\n\t\t\t\t\tsourceEntityId: action.damages[0].sourceEntityId,\r\n\t\t\t\t\ttargetEntityId: action.damages[0].targetEntityId,\r\n\t\t\t\t});\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t\tlastAction.playerTrinkets = action.playerTrinkets;\r\n\t\t\t\tlastAction.opponentTrinkets = action.opponentTrinkets;\r\n\t\t\t} else if (\r\n\t\t\t\tlastAction &&\r\n\t\t\t\taction.type === 'power-target' &&\r\n\t\t\t\tlastAction.type === 'power-target' &&\r\n\t\t\t\taction.sourceEntityId === lastAction.sourceEntityId\r\n\t\t\t) {\r\n\t\t\t\tlastAction.targetEntityIds =\r\n\t\t\t\t\tlastAction.targetEntityIds ?? (lastAction.targetEntityId ? [lastAction.targetEntityId] : []);\r\n\t\t\t\taction.targetEntityIds =\r\n\t\t\t\t\taction.targetEntityIds ?? (action.targetEntityId ? [action.targetEntityId] : []);\r\n\t\t\t\tlastAction.targetEntityIds.push(...action.targetEntityIds);\r\n\t\t\t\t// So that when multiple Leapfroggers enchantments target the same minion,\r\n\t\t\t\t// we can count them in the replay viewer's text\r\n\t\t\t\t// lastAction.targetEntityIds = [...new Set(lastAction.targetEntityIds)];\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t\tlastAction.playerTrinkets = action.playerTrinkets;\r\n\t\t\t\tlastAction.opponentTrinkets = action.opponentTrinkets;\r\n\t\t\t} else {\r\n\t\t\t\tresult.push(action);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\t// Calling sanitize every time before we add an action to the list is mandatory, since\r\n\t// the entities and boards are mutable\r\n\tprivate sanitize(board: readonly BoardEntity[]): readonly BoardEntity[] {\r\n\t\tif (!board) {\r\n\t\t\treturn undefined;\r\n\t\t}\r\n\t\treturn board.map(\r\n\t\t\t(entity) =>\r\n\t\t\t\t({\r\n\t\t\t\t\tentityId: entity.entityId,\r\n\t\t\t\t\tcardId: entity.cardId,\r\n\t\t\t\t\tfriendly: entity.friendly,\r\n\t\t\t\t\tattack: entity.attack,\r\n\t\t\t\t\thealth: entity.health,\r\n\t\t\t\t\tmaxHealth: entity.maxHealth,\r\n\t\t\t\t\ttaunt: entity.taunt,\r\n\t\t\t\t\tdivineShield: entity.divineShield,\r\n\t\t\t\t\tpoisonous: entity.poisonous,\r\n\t\t\t\t\tvenomous: entity.venomous,\r\n\t\t\t\t\treborn: entity.reborn,\r\n\t\t\t\t\twindfury: entity.windfury,\r\n\t\t\t\t\tstealth: entity.stealth,\r\n\t\t\t\t} as BoardEntity),\r\n\t\t);\r\n\t}\r\n\r\n\tprivate sanitizeTrinkets(trinkets: readonly BoardTrinket[]): readonly BoardTrinket[] {\r\n\t\tif (!trinkets?.length) {\r\n\t\t\treturn undefined;\r\n\t\t}\r\n\t\tconst result = trinkets.map(\r\n\t\t\t(t) =>\r\n\t\t\t\t({\r\n\t\t\t\t\tcardId: t.cardId,\r\n\t\t\t\t\tentityId: t.entityId,\r\n\t\t\t\t\tscriptDataNum1: t.scriptDataNum1,\r\n\t\t\t\t\tscriptDataNum6: t.scriptDataNum6,\r\n\t\t\t\t} as BoardTrinket),\r\n\t\t);\r\n\t\treturn result;\r\n\t}\r\n}\r\n"]}
@@ -2,4 +2,3 @@ import { BgsPlayerEntity } from '../../bgs-player-entity';
2
2
  import { BoardEntity } from '../../board-entity';
3
3
  import { FullGameState } from '../internal-game-state';
4
4
  export declare const handleStartOfCombatHeroPowers: (playerEntity: BgsPlayerEntity, playerBoard: BoardEntity[], opponentEntity: BgsPlayerEntity, opponentBoard: BoardEntity[], currentAttacker: number, gameState: FullGameState) => number;
5
- export declare const getHeroPowerForHero: (heroCardId: string) => string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getHeroPowerForHero = exports.handleStartOfCombatHeroPowers = void 0;
3
+ exports.handleStartOfCombatHeroPowers = void 0;
4
4
  const summon_when_space_1 = require("../summon-when-space");
5
5
  const soc_action_processor_1 = require("./soc-action-processor");
6
6
  const handleStartOfCombatHeroPowers = (playerEntity, playerBoard, opponentEntity, opponentBoard, currentAttacker, gameState) => {
@@ -52,24 +52,9 @@ const handlePlayerStartOfCombatHeroPowers = (input) => {
52
52
  if (input.playerEntity.startOfCombatDone || input.playerEntity.hpLeft <= 0) {
53
53
  return input.currentAttacker;
54
54
  }
55
- const playerHeroPowerId = input.playerEntity.heroPowerId || (0, exports.getHeroPowerForHero)(input.playerEntity.cardId);
56
- (0, soc_action_processor_1.performStartOfCombatAction)(playerHeroPowerId, input.playerEntity, input, true, 'start-of-combat');
57
- return input.currentAttacker;
58
- };
59
- const getHeroPowerForHero = (heroCardId) => {
60
- switch (heroCardId) {
61
- case "TB_BaconShop_HERO_08":
62
- return "TB_BaconShop_HP_069";
63
- case "TB_BaconShop_HERO_22":
64
- return "TB_BaconShop_HP_024";
65
- case "BG25_HERO_100":
66
- return "TB_BaconShop_HP_018";
67
- case "TB_BaconShop_HERO_52":
68
- return "TB_BaconShop_HP_061";
69
- case "BG25_HERO_103":
70
- return "BG25_HERO_103p";
55
+ for (const heroPower of input.playerEntity.heroPowers) {
56
+ (0, soc_action_processor_1.performStartOfCombatAction)(heroPower.cardId, input.playerEntity, input, true, 'start-of-combat');
71
57
  }
72
- return null;
58
+ return input.currentAttacker;
73
59
  };
74
- exports.getHeroPowerForHero = getHeroPowerForHero;
75
60
  //# sourceMappingURL=soc-hero-power.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"soc-hero-power.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-hero-power.ts"],"names":[],"mappings":";;;AAIA,4DAA8D;AAC9D,iEAAoE;AAG7D,MAAM,6BAA6B,GAAG,CAC5C,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IAGX,IAAI,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,EAAE;QACxB,eAAe,GAAG,mCAAmC,CAAC;YACrD,YAAY,EAAE,YAAY;YAC1B,WAAW,EAAE,WAAW;YACxB,cAAc,EAAE,cAAc;YAC9B,aAAa,EAAE,aAAa;YAC5B,eAAe;YACf,gBAAgB,EAAE,IAAI;YACtB,SAAS;SACT,CAAC,CAAC;QACH,eAAe,GAAG,mCAAmC,CAAC;YACrD,YAAY,EAAE,cAAc;YAC5B,WAAW,EAAE,aAAa;YAC1B,cAAc,EAAE,YAAY;YAC5B,aAAa,EAAE,WAAW;YAC1B,eAAe;YACf,gBAAgB,EAAE,KAAK;YACvB,SAAS;SACT,CAAC,CAAC;KACH;SAAM;QACN,eAAe,GAAG,mCAAmC,CAAC;YACrD,YAAY,EAAE,cAAc;YAC5B,WAAW,EAAE,aAAa;YAC1B,cAAc,EAAE,YAAY;YAC5B,aAAa,EAAE,WAAW;YAC1B,eAAe;YACf,gBAAgB,EAAE,KAAK;YACvB,SAAS;SACT,CAAC,CAAC;QACH,eAAe,GAAG,mCAAmC,CAAC;YACrD,YAAY,EAAE,YAAY;YAC1B,WAAW,EAAE,WAAW;YACxB,cAAc,EAAE,cAAc;YAC9B,aAAa,EAAE,aAAa;YAC5B,eAAe;YACf,gBAAgB,EAAE,IAAI;YACtB,SAAS;SACT,CAAC,CAAC;KACH;IACD,IAAA,0CAAsB,EAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;IAC5F,OAAO,eAAe,CAAC;AACxB,CAAC,CAAC;AAnDW,QAAA,6BAA6B,iCAmDxC;AAEF,MAAM,mCAAmC,GAAG,CAAC,KAAe,EAAU,EAAE;IACvE,IAAI,KAAK,CAAC,YAAY,CAAC,iBAAiB,IAAI,KAAK,CAAC,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE;QAC3E,OAAO,KAAK,CAAC,eAAe,CAAC;KAC7B;IAED,MAAM,iBAAiB,GAAG,KAAK,CAAC,YAAY,CAAC,WAAW,IAAI,IAAA,2BAAmB,EAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC3G,IAAA,iDAA0B,EAAC,iBAAiB,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,iBAAiB,CAAC,CAAC;IAClG,OAAO,KAAK,CAAC,eAAe,CAAC;AAC9B,CAAC,CAAC;AAEK,MAAM,mBAAmB,GAAG,CAAC,UAAkB,EAAU,EAAE;IACjE,QAAQ,UAAU,EAAE;QACnB;YACC,6BAAuB;QACxB;YACC,6BAA2B;QAC5B;YACC,6BAA0B;QAC3B;YACC,6BAA2B;QAC5B;YACC,wBAA+C;KAChD;IACD,OAAO,IAAI,CAAC;AACb,CAAC,CAAC;AAdW,QAAA,mBAAmB,uBAc9B","sourcesContent":["import { CardIds } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { FullGameState } from '../internal-game-state';\r\nimport { handleSummonsWhenSpace } from '../summon-when-space';\r\nimport { performStartOfCombatAction } from './soc-action-processor';\r\nimport { SoCInput } from './start-of-combat-input';\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: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t} else {\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: true,\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 handlePlayerStartOfCombatHeroPowers = (input: SoCInput): number => {\r\n\tif (input.playerEntity.startOfCombatDone || input.playerEntity.hpLeft <= 0) {\r\n\t\treturn input.currentAttacker;\r\n\t}\r\n\r\n\tconst playerHeroPowerId = input.playerEntity.heroPowerId || getHeroPowerForHero(input.playerEntity.cardId);\r\n\tperformStartOfCombatAction(playerHeroPowerId, input.playerEntity, input, true, 'start-of-combat');\r\n\treturn input.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"]}
1
+ {"version":3,"file":"soc-hero-power.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-hero-power.ts"],"names":[],"mappings":";;;AAGA,4DAA8D;AAC9D,iEAAoE;AAG7D,MAAM,6BAA6B,GAAG,CAC5C,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IAGX,IAAI,IA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AAI,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE;QACtD,IAAA,iDAA0B,EAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,iBAAiB,CAAC,CAAC;KACjG;IACD,OAAO,KAAK,CAAC,eAAe,CAAC;AAC9B,CAAC,CAAC","sourcesContent":["import { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { FullGameState } from '../internal-game-state';\r\nimport { handleSummonsWhenSpace } from '../summon-when-space';\r\nimport { performStartOfCombatAction } from './soc-action-processor';\r\nimport { SoCInput } from './start-of-combat-input';\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: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t} else {\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: true,\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 handlePlayerStartOfCombatHeroPowers = (input: SoCInput): number => {\r\n\tif (input.playerEntity.startOfCombatDone || input.playerEntity.hpLeft <= 0) {\r\n\t\treturn input.currentAttacker;\r\n\t}\r\n\r\n\tfor (const heroPower of input.playerEntity.heroPowers) {\r\n\t\tperformStartOfCombatAction(heroPower.cardId, input.playerEntity, input, true, 'start-of-combat');\r\n\t}\r\n\treturn input.currentAttacker;\r\n};\r\n\r\n// export 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"]}
@@ -4,7 +4,6 @@ exports.handleIllidanHeroPowers = void 0;
4
4
  const attack_1 = require("../attack");
5
5
  const stats_1 = require("../stats");
6
6
  const summon_when_space_1 = require("../summon-when-space");
7
- const soc_hero_power_1 = require("./soc-hero-power");
8
7
  const handleIllidanHeroPowers = (playerEntity, playerBoard, opponentEntity, opponentBoard, currentAttacker, gameState) => {
9
8
  if (Math.random() < 0.5) {
10
9
  currentAttacker = handlePlayerIllidanHeroPowers(playerEntity, playerBoard, opponentEntity, opponentBoard, currentAttacker, true, gameState);
@@ -23,10 +22,11 @@ const handlePlayerIllidanHeroPowers = (playerEntity, playerBoard, opponentEntity
23
22
  if (playerEntity.hpLeft <= 0) {
24
23
  return currentAttacker;
25
24
  }
26
- const playerHeroPowerId = playerEntity.heroPowerId || (0, soc_hero_power_1.getHeroPowerForHero)(playerEntity.cardId);
27
- if (playerHeroPowerId === "TB_BaconShop_HP_069" && playerBoard.length > 0) {
28
- handleIllidanForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState, currentAttacker);
29
- currentAttacker = friendly ? 1 : 0;
25
+ for (const heroPower of playerEntity.heroPowers) {
26
+ if (heroPower.cardId === "TB_BaconShop_HP_069" && playerBoard.length > 0) {
27
+ handleIllidanForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState, currentAttacker);
28
+ currentAttacker = friendly ? 1 : 0;
29
+ }
30
30
  }
31
31
  return currentAttacker;
32
32
  };
@@ -1 +1 @@
1
- {"version":3,"file":"soc-illidan-hero-power.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-illidan-hero-power.ts"],"names":[],"mappings":";;;AAGA,sCAA+D;AAE/D,oCAAuC;AACvC,4DAA8D;AAC9D,qDAAuD;AAEhD,MAAM,uBAAuB,GAAG,CACtC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IAIX,IAAI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SAAS,CAAC,CAAC;IAEpF,aAAa,CAAC,WAAW,GAAG,CAAC,CAAC;IAC9B,IAAI,CAAC,CAAC,cAAc,IAAI,CAAC,cAAc,CAAC,cAAc,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;QACpF,cAAc,CAAC,iBAAiB,GAAG,IAAI,CAAC;QACxC,IAAA,uBAAc,EAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;QACpF,cAAc,CAAC,WAAW,GAAG,CAAC,CAAC;KAC/B;AAOF,CAAC,CAAC","sourcesContent":["import { CardIds } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { processMinionDeath, simulateAttack } from '../attack';\r\nimport { FullGameState } from '../internal-game-state';\r\nimport { modifyStats } from '../stats';\r\nimport { handleSummonsWhenSpace } from '../summon-when-space';\r\nimport { getHeroPowerForHero } from './soc-hero-power';\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 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"]}
1
+ {"version":3,"file":"soc-illidan-hero-power.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-illidan-hero-power.ts"],"names":[],"mappings":";;;AAGA,sCAA+D;AAE/D,oCAAuC;AACvC,4DAA8D;AAEvD,MAAM,uBAAuB,GAAG,CACtC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IAIX,IAAI,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,EAAE;QACxB,eAAe,GAAG,6BAA6B,CAC9C,YAAY,EACZ,WAAW,EACX,cAAc,EACd,aAAa,EACb,eAAe,EACf,IAAI,EACJ,SAAS,CACT,CAAC;QACF,eAAe,GAAG,6BAA6B,CAC9C,cAAc,EACd,aAAa,EACb,YAAY,EACZ,WAAW,EACX,eAAe,EACf,KAAK,EACL,SAAS,CACT,CAAC;KACF;SAAM;QACN,eAAe,GAAG,6BAA6B,CAC9C,cAAc,EACd,aAAa,EACb,YAAY,EACZ,WAAW,EACX,eAAe,EACf,KAAK,EACL,SAAS,CACT,CAAC;QACF,eAAe,GAAG,6BAA6B,CAC9C,YAAY,EACZ,WAAW,EACX,cAAc,EACd,aAAa,EACb,eAAe,EACf,IAAI,EACJ,SAAS,CACT,CAAC;KACF;IACD,IAAA,2BAAkB,EAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;IACxF,IAAA,0CAAsB,EAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;IAC5F,OAAO,eAAe,CAAC;AACxB,CAAC,CAAC;AArDW,QAAA,u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I,CAAC,CAAC,cAAc,IAAI,CAAC,cAAc,CAAC,cAAc,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;QACpF,IAAA,mBAAW,EAAC,cAAc,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;QACxE,SAAS,CAAC,SAAS,CAAC,mBAAmB,CACtC,cAAc,EACd,cAAc,EACd,WAAW,EACX,YAAY,EACZ,cAAc,CACd,CAAC;KACF;IAGD,aAAa,CAAC,iBAAiB,GAAG,IAAI,CAAC;IACvC,IAAA,uBAAc,EAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;IAEpF,aAAa,CAAC,WAAW,GAAG,CAAC,CAAC;IAC9B,IAAI,CAAC,CAAC,cAAc,IAAI,CAAC,cAAc,CAAC,cAAc,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;QACpF,cAAc,CAAC,iBAAiB,GAAG,IAAI,CAAC;QACxC,IAAA,uBAAc,EAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;QACpF,cAAc,CAAC,WAAW,GAAG,CAAC,CAAC;KAC/B;AAOF,CAAC,CAAC","sourcesContent":["import { CardIds } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { processMinionDeath, simulateAttack } from '../attack';\r\nimport { FullGameState } from '../internal-game-state';\r\nimport { modifyStats } from '../stats';\r\nimport { handleSummonsWhenSpace } from '../summon-when-space';\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 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\tfor (const heroPower of playerEntity.heroPowers) {\r\n\t\tif (heroPower.cardId === CardIds.Wingmen && playerBoard.length > 0) {\r\n\t\t\t// After Illidan triggers, it's always the other opponent's turn\r\n\t\t\t// https://x.com/LoewenMitchell/status/1752714583360639131?s=20\r\n\t\t\thandleIllidanForPlayer(\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\tgameState,\r\n\t\t\t\tcurrentAttacker,\r\n\t\t\t);\r\n\t\t\tcurrentAttacker = friendly ? 1 : 0;\r\n\t\t}\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"]}
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handlePreCombatHeroPowers = void 0;
4
4
  const summon_when_space_1 = require("../summon-when-space");
5
5
  const soc_action_processor_1 = require("./soc-action-processor");
6
- const soc_hero_power_1 = require("./soc-hero-power");
7
6
  const handlePreCombatHeroPowers = (playerEntity, playerBoard, opponentEntity, opponentBoard, currentAttacker, gameState) => {
8
7
  let initialPlayerBoardSize = playerBoard.length;
9
8
  let initialOpponentBoardSize = opponentBoard.length;
@@ -71,8 +70,9 @@ const handlePreCombatHeroPowersForPlayer = (input) => {
71
70
  if (input.playerEntity.startOfCombatDone || input.playerEntity.hpLeft <= 0) {
72
71
  return input.currentAttacker;
73
72
  }
74
- const playerHeroPowerId = input.playerEntity.heroPowerId || (0, soc_hero_power_1.getHeroPowerForHero)(input.playerEntity.cardId);
75
- (0, soc_action_processor_1.performStartOfCombatAction)(playerHeroPowerId, input.playerEntity, input, true, 'pre-combat');
73
+ for (const heroPower of input.playerEntity.heroPowers) {
74
+ (0, soc_action_processor_1.performStartOfCombatAction)(heroPower.cardId, input.playerEntity, input, true, 'pre-combat');
75
+ }
76
76
  return input.currentAttacker;
77
77
  };
78
78
  //# sourceMappingURL=soc-pre-combat-hero-power.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"soc-pre-combat-hero-power.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-pre-combat-hero-power.ts"],"names":[],"mappings":";;;AAGA,4DAA8D;AAC9D,iEAAoE;AACpE,qDAAuD;AAGhD,MAAM,yBAAyB,GAAG,CACxC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IACX,IAAI,sBAAsB,GAAG,WAAW,CAAC,MAAM,CAAC;IAChD,IAAI,wBAAwB,GAAG,aAAa,CAAC,MAAM,CAAC;IACpD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC7B,IAAI,MAAM,GAAG,GAAG,EAAE;QACjB,eAAe,GAAG,kCAAkC,CAAC;YACpD,YAAY,EAAE,YAAY;YAC1B,WAAW,EAAE,WAAW;YACxB,cAAc,EAAE,cAAc;YAC9B,aAAa,EAAE,aAAa;YAC5B,eAAe;YACf,gBAAgB,EAAE,IAAI;YACtB,SAAS;SACT,CAAC,CAAC;QACH,sBAAsB,GAAG,WAAW,CAAC,MAAM,CAAC;QAC5C,IAAA,0CAAsB,EAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;QAC5F,eAAe,GAAG,kCAAkC,CAAC;YACpD,YAAY,EAAE,cAAc;YAC5B,WAAW,EAAE,aAAa;YAC1B,cAAc,EAAE,YAAY;YAC5B,aAAa,EAAE,WAAW;YAC1B,eAAe;YACf,gBAAgB,EAAE,KAAK;YACvB,SAAS;SACT,CAAC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,yBAAyB,6BAqEpC;AAEF,MAAM,kCAAkC,GAAG,CAAC,KAAe,EAAU,EAAE;IACtE,IAAI,KAAK,CAAC,YAAY,CAAC,iBAAiB,IAAI,KAAK,CAAC,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE;QAC3E,OAAO,KAAK,CAAC,eAAe,CAAC;KAC7B;IAED,MAAM,iBAAiB,GAAG,KAAK,CAAC,YAAY,CAAC,WAAW,IAAI,IAAA,oCAAmB,EAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC3G,IAAA,iDAA0B,EAAC,iBAAiB,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;IAE7F,OAAO,KAAK,CAAC,eAAe,CAAC;AAC9B,CAAC,CAAC","sourcesContent":["import { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { FullGameState } from '../internal-game-state';\r\nimport { handleSummonsWhenSpace } from '../summon-when-space';\r\nimport { performStartOfCombatAction } from './soc-action-processor';\r\nimport { getHeroPowerForHero } from './soc-hero-power';\r\nimport { SoCInput } from './start-of-combat-input';\r\n\r\nexport const 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\tlet initialPlayerBoardSize = playerBoard.length;\r\n\tlet initialOpponentBoardSize = opponentBoard.length;\r\n\tconst random = Math.random();\r\n\tif (random < 0.5) {\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialPlayerBoardSize = playerBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialOpponentBoardSize = opponentBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t} else {\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialOpponentBoardSize = opponentBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialPlayerBoardSize = playerBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t}\r\n\t// Ozumat's Tentaclecan cause the first player to be recomputed\r\n\t// https://replays.firestoneapp.com/?reviewId=f15c90de-8b3c-4017-960d-365fe09eb7ab&turn=5&action=1\r\n\tif (playerBoard.length !== initialPlayerBoardSize || opponentBoard.length !== initialOpponentBoardSize) {\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\treturn currentAttacker;\r\n};\r\n\r\nconst handlePreCombatHeroPowersForPlayer = (input: SoCInput): number => {\r\n\tif (input.playerEntity.startOfCombatDone || input.playerEntity.hpLeft <= 0) {\r\n\t\treturn input.currentAttacker;\r\n\t}\r\n\r\n\tconst playerHeroPowerId = input.playerEntity.heroPowerId || getHeroPowerForHero(input.playerEntity.cardId);\r\n\tperformStartOfCombatAction(playerHeroPowerId, input.playerEntity, input, true, 'pre-combat');\r\n\r\n\treturn input.currentAttacker;\r\n};\r\n"]}
1
+ {"version":3,"file":"soc-pre-combat-hero-power.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-pre-combat-hero-power.ts"],"names":[],"mappings":";;;AAGA,4DAA8D;AAC9D,iEAAoE;AAG7D,MAAM,yBAAyB,GAAG,CACxC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IACX,IAAI,sBAAsB,GAAG,WAAW,CAAC,MAAM,CAAC;IAChD,IAAI,wBAAwB,GAAG,aAAa,CAAC,MAAM,CAAC;IACpD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC7B,IAAI,MAAM,GAAG,GAAG,EAAE;QACjB,eAAe,GAAG,kCAAkC,CAAC;YACpD,YAAY,EAAE,YAAY;YAC1B,WAAW,EAAE,WAAW;YACxB,cAAc,EAAE,cAAc;YAC9B,aAAa,EAAE,aAAa;YAC5B,eAAe;YACf,gBAAgB,EAAE,IAAI;YACtB,SAAS;SACT,CAAC,CAAC;QACH,sBAAsB,GAAG,WAAW,CAA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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;IACD,OAAO,eAAe,CAAC;AACxB,CAAC,CAAC;AArEW,QAAA,yBAAyB,6BAqEpC;AAEF,MAAM,kCAAkC,GAAG,CAAC,KAAe,EAAU,EAAE;IACtE,IAAI,KAAK,CAAC,YAAY,CAAC,iBAAiB,IAAI,KAAK,CAAC,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE;QAC3E,OAAO,KAAK,CAAC,eAAe,CAAC;KAC7B;IAED,KAAK,MAAM,SAAS,IAAI,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE;QACtD,IAAA,iDAA0B,EAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;KAC5F;IAED,OAAO,KAAK,CAAC,eAAe,CAAC;AAC9B,CAAC,CAAC","sourcesContent":["import { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { FullGameState } from '../internal-game-state';\r\nimport { handleSummonsWhenSpace } from '../summon-when-space';\r\nimport { performStartOfCombatAction } from './soc-action-processor';\r\nimport { SoCInput } from './start-of-combat-input';\r\n\r\nexport const 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\tlet initialPlayerBoardSize = playerBoard.length;\r\n\tlet initialOpponentBoardSize = opponentBoard.length;\r\n\tconst random = Math.random();\r\n\tif (random < 0.5) {\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialPlayerBoardSize = playerBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialOpponentBoardSize = opponentBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t} else {\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialOpponentBoardSize = opponentBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialPlayerBoardSize = playerBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t}\r\n\t// Ozumat's Tentaclecan cause the first player to be recomputed\r\n\t// https://replays.firestoneapp.com/?reviewId=f15c90de-8b3c-4017-960d-365fe09eb7ab&turn=5&action=1\r\n\tif (playerBoard.length !== initialPlayerBoardSize || opponentBoard.length !== initialOpponentBoardSize) {\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\treturn currentAttacker;\r\n};\r\n\r\nconst handlePreCombatHeroPowersForPlayer = (input: SoCInput): number => {\r\n\tif (input.playerEntity.startOfCombatDone || input.playerEntity.hpLeft <= 0) {\r\n\t\treturn input.currentAttacker;\r\n\t}\r\n\r\n\tfor (const heroPower of input.playerEntity.heroPowers) {\r\n\t\tperformStartOfCombatAction(heroPower.cardId, input.playerEntity, input, true, 'pre-combat');\r\n\t}\r\n\r\n\treturn input.currentAttacker;\r\n};\r\n"]}
@@ -23,8 +23,10 @@ const handleSummonsWhenSpaceForPlayer = (targetEntity, playerBoard, playerEntity
23
23
  if ((_b = targetEntity.secrets) === null || _b === void 0 ? void 0 : _b.some((s) => s.cardId === "BG28_603")) {
24
24
  handleBoonOfBeetlesForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);
25
25
  }
26
- if (targetEntity.heroPowerId === "BG23_HERO_201p") {
27
- handleOzumatForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, targetEntity.friendly, gameState);
26
+ for (const heroPower of targetEntity.heroPowers) {
27
+ if (heroPower.cardId === "BG23_HERO_201p") {
28
+ handleOzumatForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, targetEntity.friendly, gameState);
29
+ }
28
30
  }
29
31
  targetEntity.trinkets
30
32
  .filter((t) => t.cardId === "BG30_MagicItem_822" ||