@firestone-hs/simulate-bgs-battle 1.1.639 → 1.1.641

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 (61) hide show
  1. package/dist/board-entity.d.ts +1 -0
  2. package/dist/board-entity.js.map +1 -1
  3. package/dist/cards/impl/_card-mappings.js +2 -0
  4. package/dist/cards/impl/_card-mappings.js.map +1 -1
  5. package/dist/cards/impl/hero-power/fragrant-phylactery-enchantment.js +2 -2
  6. package/dist/cards/impl/hero-power/fragrant-phylactery-enchantment.js.map +1 -1
  7. package/dist/cards/impl/hero-power/fragrant-phylactery.js +1 -1
  8. package/dist/cards/impl/hero-power/fragrant-phylactery.js.map +1 -1
  9. package/dist/cards/impl/hero-power/tentacular.js +1 -1
  10. package/dist/cards/impl/hero-power/tentacular.js.map +1 -1
  11. package/dist/cards/impl/minion/baby-yshaarj.d.ts +2 -0
  12. package/dist/cards/impl/minion/baby-yshaarj.js +17 -0
  13. package/dist/cards/impl/minion/baby-yshaarj.js.map +1 -0
  14. package/dist/cards/impl/minion/bile-spitter.js +1 -0
  15. package/dist/cards/impl/minion/bile-spitter.js.map +1 -1
  16. package/dist/cards/impl/minion/friendly-bouncer.js +11 -9
  17. package/dist/cards/impl/minion/friendly-bouncer.js.map +1 -1
  18. package/dist/cards/impl/minion/goldrinn-the-great-wolf.js +1 -1
  19. package/dist/cards/impl/minion/goldrinn-the-great-wolf.js.map +1 -1
  20. package/dist/cards/impl/minion/kalecgos-arcane-aspect.js +1 -1
  21. package/dist/cards/impl/minion/kalecgos-arcane-aspect.js.map +1 -1
  22. package/dist/cards/impl/minion/oranomonos-the-wilted.js +3 -2
  23. package/dist/cards/impl/minion/oranomonos-the-wilted.js.map +1 -1
  24. package/dist/cards/impl/minion/pilot-the-shredder.js +2 -0
  25. package/dist/cards/impl/minion/pilot-the-shredder.js.map +1 -1
  26. package/dist/cards/impl/minion/primeval-monstrosity.js +1 -1
  27. package/dist/cards/impl/minion/primeval-monstrosity.js.map +1 -1
  28. package/dist/cards/impl/minion/stoneshell-guardian.js +9 -15
  29. package/dist/cards/impl/minion/stoneshell-guardian.js.map +1 -1
  30. package/dist/cards/impl/minion/transmuted-bramblewitch.js.map +1 -1
  31. package/dist/cards/impl/minion/wrathscale-rogue.js +1 -1
  32. package/dist/cards/impl/minion/wrathscale-rogue.js.map +1 -1
  33. package/dist/simulation/death-effects.js +3 -1
  34. package/dist/simulation/death-effects.js.map +1 -1
  35. package/dist/simulation/deathrattle-effects.js +5 -1
  36. package/dist/simulation/deathrattle-effects.js.map +1 -1
  37. package/dist/simulation/deathrattle-orchestration.js +1 -0
  38. package/dist/simulation/deathrattle-orchestration.js.map +1 -1
  39. package/dist/simulation/on-attack.js +1 -0
  40. package/dist/simulation/on-attack.js.map +1 -1
  41. package/dist/simulation/on-being-attacked.js +2 -2
  42. package/dist/simulation/on-being-attacked.js.map +1 -1
  43. package/dist/simulation/start-of-combat/soc-anomalies.js +9 -1
  44. package/dist/simulation/start-of-combat/soc-anomalies.js.map +1 -1
  45. package/dist/simulation/start-of-combat/soc-illidan-hero-power.js +9 -1
  46. package/dist/simulation/start-of-combat/soc-illidan-hero-power.js.map +1 -1
  47. package/dist/simulation/start-of-combat/soc-minion.js +9 -1
  48. package/dist/simulation/start-of-combat/soc-minion.js.map +1 -1
  49. package/dist/simulation/start-of-combat/soc-quest-reward.js +9 -1
  50. package/dist/simulation/start-of-combat/soc-quest-reward.js.map +1 -1
  51. package/dist/simulation/start-of-combat/soc-secret.js +9 -1
  52. package/dist/simulation/start-of-combat/soc-secret.js.map +1 -1
  53. package/dist/simulation/start-of-combat/soc-trinket.js +9 -1
  54. package/dist/simulation/start-of-combat/soc-trinket.js.map +1 -1
  55. package/dist/simulation/stats.js +3 -1
  56. package/dist/simulation/stats.js.map +1 -1
  57. package/dist/simulation/summon-when-space.js +2 -0
  58. package/dist/simulation/summon-when-space.js.map +1 -1
  59. package/dist/utils.js +9 -3
  60. package/dist/utils.js.map +1 -1
  61. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"deathrattle-orchestration.js","sourceRoot":"","sources":["../../src/simulation/deathrattle-orchestration.ts"],"names":[],"mappings":";;;AAAA,iEAAoD;AAGpD,oCAA2C;AAC3C,qCAA8C;AAC9C,mDAAyD;AACzD,+DAI+B;AAC/B,6DAAkH;AAElH,qCAAiD;AACjD,qCAA+C;AAWxC,MAAM,6BAA6B,GAAG,CAC5C,gBAAkC,EAClC,aAAa,GAAG,IAAI,EACpB,aAAa,GAAG,IAAI,EACnB,EAAE;IAEH,6BAA6B,CAAC,gBAAgB,CAAC,CAAC;IAGhD,+BAA+B,CAAC,gBAAgB,CAAC,CAAC;IAElD,MAAM,iBAAiB,GAAG,CAAC,GAAG,gBAAgB,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACjF,MAAM,mBAAmB,GAAG,CAAC,GAAG,gBAAgB,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAErF,MAAM,wBAAwB,GAAG,mBAAmB,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;IAItF,4BAA4B,CAAC,gBAAgB,CAAC,CAAC;IAM/C,MAAM,gBAAgB,GAAG,CAAC,GAAG,gBAAgB,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChF,MAAM,kBAAkB,GAAG,CAAC,GAAG,gBAAgB,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpF,MAAM,8BAA8B,GAAG,kBAAkB;SACvD,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;SACzD,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,kBAAkB,CAAC,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,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;AACF,CAAC,CAAC","sourcesContent":["import { Race } from '@firestone-hs/reference-data';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { hasCorrectTribe } from '../utils';\r\nimport { applyAvengeEffects } from './avenge';\r\nimport { applyAfterDeathEffects } from './death-effects';\r\nimport {\r\n\tapplyAfterMinionDiesEffect,\r\n\tapplyWheneverMinionDiesEffect,\r\n\thandleAfterMinionKillsEffect,\r\n} from './deathrattle-effects';\r\nimport { spawnEntities, spawnEntitiesFromDeathrattle, spawnEntitiesFromEnchantments } from './deathrattle-spawns';\r\nimport { FullGameState, PlayerState } from './internal-game-state';\r\nimport { handleRebornForEntity } from './reborn';\r\nimport { performEntitySpawns } from './spawns';\r\n\r\n// FIXME:\r\n// From Mitchell on Discord:\r\n// - Minions die left to right\r\n// - When a minion dies, it procs natural deathrattle, added deathrattles, and then all avenges progress\r\n// by 1 (and trigger as necessary)\r\n// - Then next minion\r\n// - After ALL deathrattles and avenges are done, Reborn triggers\r\n// - (Ideally after all of that I would want Feathermane to trigger, but that is not what it does right now.\r\n// Right now it triggers at deathrattle speed rather than after Reborn speed)\r\nexport const orchestrateMinionDeathEffects = (\r\n\tdeathrattleInput: DeathrattleInput,\r\n\tprocessAvenge = true,\r\n\tprocessReborn = true,\r\n) => {\r\n\t// Icesnarl / Rokara here?\r\n\thandleAfterMinionsKillEffects(deathrattleInput);\r\n\r\n\t// Not sure about this\r\n\thandleWheneverMinionsDieEffects(deathrattleInput);\r\n\r\n\tconst playerBoardBefore = [...deathrattleInput.gameState.gameState.player.board];\r\n\tconst opponentBoardBefore = [...deathrattleInput.gameState.gameState.opponent.board];\r\n\r\n\tconst entitiesFromDeathrattles = processDeathrattles(deathrattleInput, processAvenge);\r\n\r\n\t// When a Silent Enforcer dies, it deals damage to other minions, then Soul Juggler damages the minions\r\n\t// **before** they completely die and spawn their own deathrattles\r\n\thandleAfterMinionsDieEffects(deathrattleInput);\r\n\r\n\t// Hack to try and fix how reborn indices are handled when there are spawns during the deathrattle phase\r\n\t// Ideally, this should probably be rewritten completely to keep the dead entities in the board itself\r\n\t// so we can use that as a source for the spawn index. However this is a big rewrite with lots of\r\n\t// potential side-effects\r\n\tconst playerBoardAfter = [...deathrattleInput.gameState.gameState.player.board];\r\n\tconst opponentBoardAfter = [...deathrattleInput.gameState.gameState.opponent.board];\r\n\tconst opponentIndexOfSpawnedEntities = opponentBoardAfter\r\n\t\t.filter((entity) => !opponentBoardBefore.includes(entity))\r\n\t\t.map((entity) => opponentBoardAfter.length - opponentBoardAfter.indexOf(entity) - 1);\r\n\tconst playerIndexOfSpawnedEntities = playerBoardAfter\r\n\t\t.filter((entity) => !playerBoardBefore.includes(entity))\r\n\t\t.map((entity) => playerBoardAfter.length - playerBoardAfter.indexOf(entity) - 1);\r\n\tdeathrattleInput.opponentDeadEntityIndexesFromRight = deathrattleInput.opponentDeadEntityIndexesFromRight.map(\r\n\t\t(previousIndex) => {\r\n\t\t\topponentIndexOfSpawnedEntities.forEach((index) => {\r\n\t\t\t\tif (index < previousIndex) {\r\n\t\t\t\t\tpreviousIndex++;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\treturn previousIndex;\r\n\t\t},\r\n\t);\r\n\tdeathrattleInput.playerDeadEntityIndexesFromRight = deathrattleInput.playerDeadEntityIndexesFromRight.map(\r\n\t\t(previousIndex) => {\r\n\t\t\tplayerIndexOfSpawnedEntities.forEach((index) => {\r\n\t\t\t\tif (index < previousIndex) {\r\n\t\t\t\t\tpreviousIndex++;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\treturn previousIndex;\r\n\t\t},\r\n\t);\r\n\r\n\tif (processReborn) {\r\n\t\tprocessReborns(deathrattleInput);\r\n\t}\r\n\r\n\tconst entitiesFromFeathermanes = processFeathermaneEffects(deathrattleInput);\r\n\thandlePostDeathrattleEffects(deathrattleInput, [...entitiesFromDeathrattles, ...entitiesFromFeathermanes]);\r\n};\r\n\r\nconst handleAfterMinionsKillEffects = (deathrattleInput: DeathrattleInput) => {\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\thandleAfterMinionKillsEffect(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tplayerDeadEntityIndexesFromRight[i][j],\r\n\t\t\t\t\tplayerStates[i].board,\r\n\t\t\t\t\tplayerStates[i].player,\r\n\t\t\t\t\tplayerStates[1 - i].board,\r\n\t\t\t\t\tplayerStates[1 - i].player,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleWheneverMinionsDieEffects = (deathrattleInput: DeathrattleInput) => {\r\n\t// Wildfire Element is applied first, before the DR spawns\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\tapplyWheneverMinionDiesEffect(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tplayerDeadEntityIndexesFromRight[i][j],\r\n\t\t\t\t\tplayerStates[i].board,\r\n\t\t\t\t\tplayerStates[i].player,\r\n\t\t\t\t\tplayerStates[1 - i].board,\r\n\t\t\t\t\tplayerStates[1 - i].player,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleAfterMinionsDieEffects = (deathrattleInput: DeathrattleInput) => {\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\tapplyAfterMinionDiesEffect(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tplayerDeadEntityIndexesFromRight[i][j],\r\n\t\t\t\t\tplayerStates[i].board,\r\n\t\t\t\t\tplayerStates[i].player,\r\n\t\t\t\t\tplayerStates[1 - i].board,\r\n\t\t\t\t\tplayerStates[1 - i].player,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst processDeathrattles = (deathrattleInput: DeathrattleInput, processAvenge = true): BoardEntity[] => {\r\n\tconst entitiesFromDeathrattles: BoardEntity[] = [];\r\n\t// Deathrattles are handled left to right\r\n\t// Then for each minion, natural deathrattles are processed first, then enchantments\r\n\t// http://replays.firestoneapp.com/?reviewId=ec5428bf-a599-4f4c-bea9-8acad5075cb8&turn=11&action=1\r\n\t// http://replays.firestoneapp.com/?reviewId=f32e734a-d5a2-4fa4-ad10-94019969cdd7&turn=6&action=22\r\n\t// http://replays.firestoneapp.com/?reviewId=ea9503c9-2795-49f0-866b-9ea856cec7df&turn=11&action=3\r\n\t// http://replays.firestoneapp.com/?reviewId=1ff37e17-704c-4a73-8c78-377c52b6cb42&turn=13&action=1 is a trap: the enchantment is on the first\r\n\t// minion, but the DR is on the second one.\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\t// Process one player first, then the other\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\t// Issue: we should process all deathrattles first, then all avenge. If multiple minions die at the same time,\r\n\t\t// the current implementation processes the first minion completely (DR + avenge), then the second one\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\t// Entities are processed left to right\r\n\t\t\t// TODO: in fact, the processing order is summoning order, so maybe we can just use the entityId\r\n\t\t\t// to determine the order? https://x.com/LoewenMitchell/status/1750792974383173676?s=20\r\n\t\t\t// \"It should be summoned order (which is most cases would be left to right but mid-combat that could change).\"\r\n\t\t\t// This doesn't actually work: http://replays.firestoneapp.com/?reviewId=ec5428bf-a599-4f4c-bea9-8acad5075cb8&turn=11&action=6\r\n\t\t\t// deadEntities.sort((a, b) => a.entityId - b.entityId);\r\n\t\t\t// So we would need to find another proxy for the order\r\n\t\t\tconst spawns = processDeathrattleForMinions(\r\n\t\t\t\tdeadEntities,\r\n\t\t\t\tplayerDeadEntityIndexesFromRight[i],\r\n\t\t\t\tplayerStates[i],\r\n\t\t\t\tplayerStates[1 - i],\r\n\t\t\t\tdeathrattleInput,\r\n\t\t\t\tprocessAvenge,\r\n\t\t\t);\r\n\t\t\tentitiesFromDeathrattles.push(...spawns);\r\n\t\t\t// for (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\t// \tconst deadEntity = deadEntities[j];\r\n\t\t\t// \tconst indexFromRight = playerDeadEntityIndexesFromRight[i][j];\r\n\t\t\t// \tconst deadEntityPlayerState = playerStates[i];\r\n\t\t\t// \tconst otherPlayerState = playerStates[1 - i];\r\n\t\t\t// \tconst spawns = processDeathrattleForMinion(\r\n\t\t\t// \t\tdeadEntity,\r\n\t\t\t// \t\tindexFromRight,\r\n\t\t\t// \t\tdeadEntities,\r\n\t\t\t// \t\tdeadEntityPlayerState,\r\n\t\t\t// \t\totherPlayerState,\r\n\t\t\t// \t\tdeathrattleInput.gameState,\r\n\t\t\t// \t\tprocessAvenge,\r\n\t\t\t// \t);\r\n\t\t\t// \tentitiesFromDeathrattles.push(...spawns);\r\n\t\t\t// }\r\n\t\t}\r\n\t}\r\n\treturn entitiesFromDeathrattles;\r\n};\r\n\r\nconst processFeathermaneEffects = (deathrattleInput: DeathrattleInput, processAvenge = true): BoardEntity[] => {\r\n\tconst entitiesFromDeathrattles: BoardEntity[] = [];\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\t// Process one player first, then the other\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\t// Entities are processed left to right\r\n\t\t\t// TODO: in fact, the processing order is summoning order, so maybe we can just use the entityId\r\n\t\t\t// to determine the order? https://x.com/LoewenMitchell/status/1750792974383173676?s=20\r\n\t\t\t// \"It should be summoned order (which is most cases would be left to right but mid-combat that could change).\"\r\n\t\t\t// This doesn't actually work: http://replays.firestoneapp.com/?reviewId=ec5428bf-a599-4f4c-bea9-8acad5075cb8&turn=11&action=6\r\n\t\t\t// deadEntities.sort((a, b) => a.entityId - b.entityId);\r\n\t\t\t// So we would need to find another proxy for the order\r\n\t\t\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\tconst indexFromRight = playerDeadEntityIndexesFromRight[i][j];\r\n\t\t\t\tconst modifiedIndexFromRight = Math.min(playerStates[i].board.length, indexFromRight);\r\n\t\t\t\tconst deadEntityPlayerState = playerStates[i];\r\n\t\t\t\tconst otherPlayerState = playerStates[1 - i];\r\n\t\t\t\tconst spawns = processFeathermaneForMinion(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\tdeadEntities,\r\n\t\t\t\t\tdeadEntityPlayerState,\r\n\t\t\t\t\totherPlayerState,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t\tprocessAvenge,\r\n\t\t\t\t);\r\n\t\t\t\tentitiesFromDeathrattles.push(...spawns);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn entitiesFromDeathrattles;\r\n};\r\n\r\nconst processFeathermaneForMinion = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tdeadEntities: BoardEntity[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tgameState: FullGameState,\r\n\tprocessAvenge = true,\r\n) => {\r\n\tconst maxSpawns = 7 - deadEntityPlayerState.board.length;\r\n\tconst allSpawns = [];\r\n\r\n\t// Feathermane\r\n\tif (\r\n\t\thasCorrectTribe(deadEntity, deadEntityPlayerState.player, Race.BEAST, gameState.anomalies, gameState.allCards)\r\n\t) {\r\n\t\tconst feathermanes =\r\n\t\t\tdeadEntityPlayerState.player.hand\r\n\t\t\t\t?.filter((e) => !e.locked)\r\n\t\t\t\t.filter(\r\n\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\te.cardId === CardIds.FreeFlyingFeathermane_BG27_014 ||\r\n\t\t\t\t\t\te.cardId === CardIds.FreeFlyingFeathermane_BG27_014_G,\r\n\t\t\t\t) ?? [];\r\n\t\tfor (const feathermaneSpawn of feathermanes) {\r\n\t\t\tif (allSpawns.length >= maxSpawns) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tfeathermaneSpawn.locked = true;\r\n\t\t\tconst spawns = spawnEntities(\r\n\t\t\t\tfeathermaneSpawn.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tdeadEntityPlayerState.board,\r\n\t\t\t\tdeadEntityPlayerState.player,\r\n\t\t\t\totherPlayerState.board,\r\n\t\t\t\totherPlayerState.player,\r\n\t\t\t\tgameState,\r\n\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\ttrue,\r\n\t\t\t\t{ ...feathermaneSpawn } as BoardEntity,\r\n\t\t\t);\r\n\r\n\t\t\t// So that it can be flagged as \"unspawned\" if it is not spawned in the end\r\n\t\t\tfor (const spawn of spawns) {\r\n\t\t\t\tspawn.onCanceledSummon = () => (feathermaneSpawn.locked = false);\r\n\t\t\t\t// spawn.backRef = feathermaneSpawn;\r\n\t\t\t}\r\n\t\t\tallSpawns.push(...spawns);\r\n\t\t}\r\n\t}\r\n\r\n\tperformEntitySpawns(\r\n\t\tallSpawns,\r\n\t\tdeadEntityPlayerState.board,\r\n\t\tdeadEntityPlayerState.player,\r\n\t\tdeadEntity,\r\n\t\tindexFromRight,\r\n\t\totherPlayerState.board,\r\n\t\totherPlayerState.player,\r\n\t\tgameState,\r\n\t);\r\n\treturn allSpawns;\r\n};\r\n\r\nconst processDeathrattleForMinions = (\r\n\tdeadEntities: BoardEntity[],\r\n\tplayerDeadEntityIndexesFromRight: number[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tinput: DeathrattleInput,\r\n\tprocessAvenge = true,\r\n) => {\r\n\tconst entitiesFromDeathrattles: BoardEntity[] = [];\r\n\r\n\t// Natural deathrattles & enchantments\r\n\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\tconst deadEntity = deadEntities[j];\r\n\t\tconst indexFromRight = playerDeadEntityIndexesFromRight[j];\r\n\t\tconst drEntities = handleNaturalDeathrattle(\r\n\t\t\tdeadEntity,\r\n\t\t\tindexFromRight,\r\n\t\t\tdeadEntities,\r\n\t\t\tdeadEntityPlayerState,\r\n\t\t\totherPlayerState,\r\n\t\t\tinput.gameState,\r\n\t\t);\r\n\t\tconst enchEntities = handleEnchantmentsDeathrattle(\r\n\t\t\tdeadEntity,\r\n\t\t\tindexFromRight,\r\n\t\t\tdeadEntities,\r\n\t\t\tdeadEntityPlayerState,\r\n\t\t\totherPlayerState,\r\n\t\t\tinput.gameState,\r\n\t\t);\r\n\r\n\t\tentitiesFromDeathrattles.push(...drEntities, ...enchEntities);\r\n\t}\r\n\r\n\t// Avenge\r\n\tlet avengeEntities = [];\r\n\tif (processAvenge) {\r\n\t\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\tconst indexFromRight = playerDeadEntityIndexesFromRight[j];\r\n\t\t\tavengeEntities = applyAvengeEffects(\r\n\t\t\t\tdeadEntity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\tdeadEntityPlayerState.board,\r\n\t\t\t\tdeadEntityPlayerState.player,\r\n\t\t\t\totherPlayerState.board,\r\n\t\t\t\totherPlayerState.player,\r\n\t\t\t\tinput.gameState,\r\n\t\t\t\tentitiesFromDeathrattles,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\tconst allAfterDeathEntities = [];\r\n\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\tconst deadEntity = deadEntities[j];\r\n\t\tconst indexFromRight = playerDeadEntityIndexesFromRight[j];\r\n\t\tconst afterDeathEntities = applyAfterDeathEffects(\r\n\t\t\tdeadEntity,\r\n\t\t\tindexFromRight,\r\n\t\t\tdeadEntityPlayerState.board,\r\n\t\t\tdeadEntityPlayerState.player,\r\n\t\t\totherPlayerState.board,\r\n\t\t\totherPlayerState.player,\r\n\t\t\tinput.gameState,\r\n\t\t);\r\n\t\tallAfterDeathEntities.push(...afterDeathEntities);\r\n\t}\r\n\r\n\treturn [...entitiesFromDeathrattles, ...avengeEntities, ...allAfterDeathEntities];\r\n};\r\n\r\nexport const processDeathrattleForMinion = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tdeadEntities: BoardEntity[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tgameState: FullGameState,\r\n\tprocessAvenge = true,\r\n) => {\r\n\tconst drEntities = handleNaturalDeathrattle(\r\n\t\tdeadEntity,\r\n\t\tindexFromRight,\r\n\t\tdeadEntities,\r\n\t\tdeadEntityPlayerState,\r\n\t\totherPlayerState,\r\n\t\tgameState,\r\n\t);\r\n\tconst enchEntities = handleEnchantmentsDeathrattle(\r\n\t\tdeadEntity,\r\n\t\tindexFromRight,\r\n\t\tdeadEntities,\r\n\t\tdeadEntityPlayerState,\r\n\t\totherPlayerState,\r\n\t\tgameState,\r\n\t);\r\n\t// Avenge trigger before reborn\r\n\t// http://replays.firestoneapp.com/?reviewId=5bb20eb8-e0ca-47ab-adc7-13134716d568&turn=7&action=6\r\n\tlet avengeEntities = [];\r\n\tlet afterDeathEntities = [];\r\n\tif (processAvenge) {\r\n\t\tavengeEntities = applyAvengeEffects(\r\n\t\t\tdeadEntity,\r\n\t\t\tindexFromRight,\r\n\t\t\tdeadEntityPlayerState.board,\r\n\t\t\tdeadEntityPlayerState.player,\r\n\t\t\totherPlayerState.board,\r\n\t\t\totherPlayerState.player,\r\n\t\t\tgameState,\r\n\t\t\t[...drEntities, ...enchEntities],\r\n\t\t);\r\n\r\n\t\t// TODO: Feathermane should be applied after the Reborn effects have all been processed\r\n\t\t// Secrets should be processed here (\"at Avenge speed\")\r\n\t\tafterDeathEntities = applyAfterDeathEffects(\r\n\t\t\tdeadEntity,\r\n\t\t\tindexFromRight,\r\n\t\t\tdeadEntityPlayerState.board,\r\n\t\t\tdeadEntityPlayerState.player,\r\n\t\t\totherPlayerState.board,\r\n\t\t\totherPlayerState.player,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\treturn [...drEntities, ...enchEntities, ...avengeEntities, ...afterDeathEntities];\r\n};\r\n\r\nconst handleNaturalDeathrattle = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tdeadEntities: BoardEntity[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tgameState: FullGameState,\r\n): readonly BoardEntity[] => {\r\n\tconst modifiedIndexFromRight = Math.min(deadEntityPlayerState.board.length, indexFromRight);\r\n\t// const allSpawns = [];\r\n\t// const spawnsToSpawn = [];\r\n\tfor (const dr of deadEntity.rememberedDeathrattles ?? []) {\r\n\t\tconst entityToProcess: BoardEntity = {\r\n\t\t\t...deadEntity,\r\n\t\t\trememberedDeathrattles: undefined,\r\n\t\t\tdeathrattleRepeats: dr.repeats ?? 1,\r\n\t\t\tscriptDataNum1: dr.scriptDataNum1,\r\n\t\t\tscriptDataNum2: dr.scriptDataNum2,\r\n\t\t\tcardId: dr.cardId,\r\n\t\t\tpendingAttackBuffs: [],\r\n\t\t\t// For Corrupted Bristler\r\n\t\t\tenchantments: deadEntity.enchantments.filter((e) => e.cardId?.startsWith(CardIds.BloodGem)),\r\n\t\t\tmemory:\r\n\t\t\t\tdr.memory == null\r\n\t\t\t\t\t? null\r\n\t\t\t\t\t: Array.isArray(dr.memory)\r\n\t\t\t\t\t? dr.memory.map((mem) => ({ ...mem }))\r\n\t\t\t\t\t: { ...dr.memory },\r\n\t\t};\r\n\t\tconst spawns = handleNaturalDeathrattle(\r\n\t\t\tentityToProcess,\r\n\t\t\tindexFromRight,\r\n\t\t\tdeadEntities,\r\n\t\t\tdeadEntityPlayerState,\r\n\t\t\totherPlayerState,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\t// The spawns have already been processed in the \"handleNaturalDeathrattle\" method\r\n\t\t// spawnsToSpawn.push(...spawns);\r\n\t\t// allSpawns.push(...spawns);\r\n\t}\r\n\r\n\tconst entitiesFromNativeDeathrattle: readonly BoardEntity[] = spawnEntitiesFromDeathrattle(\r\n\t\tdeadEntity,\r\n\t\tmodifiedIndexFromRight,\r\n\t\tdeadEntityPlayerState.board,\r\n\t\tdeadEntityPlayerState.player,\r\n\t\totherPlayerState.board,\r\n\t\totherPlayerState.player,\r\n\t\tdeadEntities,\r\n\t\tgameState,\r\n\t);\r\n\t// allSpawns.push(...entitiesFromNativeDeathrattle);\r\n\t// spawnsToSpawn.push(...entitiesFromNativeDeathrattle);\r\n\t// Some candidate entities are not spawned, and so are ignored in further processing\r\n\t// const actualSpawns = performEntitySpawns(\r\n\t// \tspawnsToSpawn,\r\n\t// \tdeadEntityPlayerState.board,\r\n\t// \tdeadEntityPlayerState.player,\r\n\t// \tdeadEntity,\r\n\t// \tmodifiedIndexFromRight,\r\n\t// \totherPlayerState.board,\r\n\t// \totherPlayerState.player,\r\n\t// \tgameState,\r\n\t// );\r\n\t// In case of leapfrogger, we want to first spawn the minions, then apply the frog effect\r\n\t// TODO: revisit this once Leapfroggers are in the game again\r\n\t// handleDeathrattleEffects(\r\n\t// \tdeadEntityPlayerState.board,\r\n\t// \tdeadEntityPlayerState.player,\r\n\t// \tdeadEntity,\r\n\t// \tmodifiedIndexFromRight,\r\n\t// \totherPlayerState.board,\r\n\t// \totherPlayerState.player,\r\n\t// \tgameState,\r\n\t// );\r\n\r\n\treturn entitiesFromNativeDeathrattle;\r\n};\r\n\r\nconst handleEnchantmentsDeathrattle = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tdeadEntities: BoardEntity[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tgameState: FullGameState,\r\n\tskipSpawns = false,\r\n) => {\r\n\tconst modifiedIndexFromRight = Math.min(deadEntityPlayerState.board.length, indexFromRight);\r\n\tconst result = [];\r\n\tfor (const dr of deadEntity.rememberedDeathrattles ?? []) {\r\n\t\tconst entityToProcess: BoardEntity = {\r\n\t\t\t...deadEntity,\r\n\t\t\trememberedDeathrattles: undefined,\r\n\t\t\tcardId: dr.cardId,\r\n\t\t\t// So that cards that rely on the tavern tier use the base entity, and not the enchantment / remembered card\r\n\t\t\ttavernTier: gameState.cardsData.getTavernLevel(deadEntity.cardId),\r\n\t\t\tenchantments: [\r\n\t\t\t\t{\r\n\t\t\t\t\tcardId: dr.cardId,\r\n\t\t\t\t\toriginEntityId: deadEntity.entityId,\r\n\t\t\t\t\trepeats: dr.repeats ?? 1,\r\n\t\t\t\t\ttiming: dr.timing,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t\tpendingAttackBuffs: [],\r\n\t\t};\r\n\t\tconst spawns = handleEnchantmentsDeathrattle(\r\n\t\t\tentityToProcess,\r\n\t\t\tindexFromRight,\r\n\t\t\tdeadEntities,\r\n\t\t\tdeadEntityPlayerState,\r\n\t\t\totherPlayerState,\r\n\t\t\tgameState,\r\n\t\t\t// We skip spawns, otherwise it will be added twice\r\n\t\t\ttrue,\r\n\t\t);\r\n\t\tresult.push(...spawns);\r\n\t}\r\n\tconst entitiesFromEnchantments: readonly BoardEntity[] = spawnEntitiesFromEnchantments(\r\n\t\tdeadEntity,\r\n\t\tdeadEntityPlayerState.board,\r\n\t\tdeadEntityPlayerState.player,\r\n\t\totherPlayerState.board,\r\n\t\totherPlayerState.player,\r\n\t\tgameState,\r\n\t);\r\n\tresult.push(...entitiesFromEnchantments);\r\n\tif (!skipSpawns) {\r\n\t\tperformEntitySpawns(\r\n\t\t\tresult,\r\n\t\t\tdeadEntityPlayerState.board,\r\n\t\t\tdeadEntityPlayerState.player,\r\n\t\t\tdeadEntity,\r\n\t\t\tmodifiedIndexFromRight,\r\n\t\t\totherPlayerState.board,\r\n\t\t\totherPlayerState.player,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\treturn result;\r\n};\r\n\r\nconst processReborns = (deathrattleInput: DeathrattleInput) => {\r\n\t// const entitiesFromReborn: BoardEntity[] = [];\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\t// Process one player first, then the other\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\tconst indexFromRight = playerDeadEntityIndexesFromRight[i][j];\r\n\t\t\t\tconst modifiedIndexFromRight = Math.min(playerStates[i].board.length, indexFromRight);\r\n\t\t\t\tconst deadEntityPlayerState = playerStates[i];\r\n\t\t\t\tconst otherPlayerState = playerStates[1 - i];\r\n\t\t\t\thandleRebornForEntity(\r\n\t\t\t\t\tdeadEntityPlayerState.board,\r\n\t\t\t\t\tdeadEntityPlayerState.player,\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\totherPlayerState.board,\r\n\t\t\t\t\totherPlayerState.player,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handlePostDeathrattleEffects = (deathrattleInput: DeathrattleInput, entitiesFromDeathrattles: BoardEntity[]) => {\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\t// Process one player first, then the other\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tconst deadEntityPlayerState = playerStates[i];\r\n\t\tconst otherPlayerState = playerStates[1 - i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\t// Process from right to left, so that we can set the hasAttacked attribute properly\r\n\t\t\t// If two minions die at the same time, both of which having attacked, but the third in line having not,\r\n\t\t\t// processing them from left to right means the first (leftmost) one will check its right neighbor, which\r\n\t\t\t// is the minion that hasn't attacked\r\n\t\t\tfor (let j = deadEntities.length - 1; j >= 0; j--) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\tconst indexFromRight = playerDeadEntityIndexesFromRight[i][j];\r\n\t\t\t\tconst modifiedIndexFromRight = Math.min(playerStates[i].board.length, indexFromRight);\r\n\t\t\t\thandlePostDeathrattleEffect(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\tdeadEntities,\r\n\t\t\t\t\tdeadEntityPlayerState,\r\n\t\t\t\t\totherPlayerState,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t\tentitiesFromDeathrattles,\r\n\t\t\t\t\tdeadEntityPlayerState.player.friendly,\r\n\t\t\t\t\tdeathrattleInput,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const handleDeathrattles = (deathrattleInput: DeathrattleInput) => {\r\n\torchestrateMinionDeathEffects(deathrattleInput, false, false);\r\n};\r\n\r\nconst handlePostDeathrattleEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tdeadEntities: BoardEntity[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tgameState: FullGameState,\r\n\tspawnedEntities: BoardEntity[],\r\n\tisPlayer: boolean,\r\n\tdeathrattleInput: DeathrattleInput,\r\n) => {\r\n\t// This doesn't work if the entity that was to the right died.\r\n\tconst entityRightToSpawns =\r\n\t\tindexFromRight === 0 ? null : deadEntityPlayerState.board[deadEntityPlayerState.board.length - indexFromRight];\r\n\t// To handle minions attack tokens\r\n\t// See http://replays.firestoneapp.com/?reviewId=0583d6a4-6ed0-4b20-894e-4ceb560894fe&turn=6&action=11\r\n\t// When a minion dies, the spawn are either elligible to attack next turn or not\r\n\t// If the minion right to the spawned minion has already attacked, then the spawned\r\n\t// minion cannot attack\r\n\tspawnedEntities.forEach((entity) => {\r\n\t\tentity.hasAttacked = deadEntity.hasAttacked > 1 ? 1 : entityRightToSpawns?.hasAttacked ?? 0;\r\n\t});\r\n\r\n\tif (deadEntityPlayerState.player.questRewards?.includes(CardIds.RitualDagger_BG24_Reward_113)) {\r\n\t\tconst ogDeadEntity = gameState.sharedState.deaths.find((entity) => entity.entityId === deadEntity.entityId);\r\n\t\tif (ogDeadEntity) {\r\n\t\t\togDeadEntity.attack += 4;\r\n\t\t\togDeadEntity.health += 4;\r\n\t\t}\r\n\t}\r\n\r\n\t// ISSUE: when we do this, we change the minion's stats before processing deathrattle effects, which can mess\r\n\t// up the simulation in some cases (like Nightbane, Ignited)\r\n\t// FIX: we do it in postDeathrattleEfects, not when removing minions from the board\r\n\tif (deadEntityPlayerState.player.globalInfo.HauntedCarapaceAttackBonus > 0) {\r\n\t\tdeadEntity.attack = Math.max(\r\n\t\t\t0,\r\n\t\t\tdeadEntity.attack - deadEntityPlayerState.player.globalInfo.HauntedCarapaceAttackBonus,\r\n\t\t);\r\n\t}\r\n\tif (deadEntityPlayerState.player.globalInfo.HauntedCarapaceHealthBonus > 0) {\r\n\t\tdeadEntity.health = Math.max(\r\n\t\t\t1,\r\n\t\t\tdeadEntity.health - deadEntityPlayerState.player.globalInfo.HauntedCarapaceHealthBonus,\r\n\t\t);\r\n\t}\r\n\tif (\r\n\t\thasCorrectTribe(deadEntity, deadEntityPlayerState.player, Race.UNDEAD, gameState.anomalies, gameState.allCards)\r\n\t) {\r\n\t\tif (deadEntityPlayerState.player.globalInfo.UndeadAttackBonus > 0) {\r\n\t\t\tdeadEntity.attack = Math.max(\r\n\t\t\t\t0,\r\n\t\t\t\tdeadEntity.attack - deadEntityPlayerState.player.globalInfo.UndeadAttackBonus,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\tif (\r\n\t\thasCorrectTribe(deadEntity, deadEntityPlayerState.player, Race.BEAST, gameState.anomalies, gameState.allCards)\r\n\t) {\r\n\t\tif (deadEntityPlayerState.player.globalInfo.GoldrinnBuffAtk > 0) {\r\n\t\t\tdeadEntity.attack = Math.max(\r\n\t\t\t\t0,\r\n\t\t\t\tdeadEntity.attack - deadEntityPlayerState.player.globalInfo.GoldrinnBuffAtk,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n};\r\n\r\ninterface DeathrattleInput {\r\n\tgameState: FullGameState;\r\n\tplayerDeadEntities: BoardEntity[];\r\n\tplayerDeadEntityIndexesFromRight: number[];\r\n\topponentDeadEntities: BoardEntity[];\r\n\topponentDeadEntityIndexesFromRight: number[];\r\n}\r\n"]}
1
+ {"version":3,"file":"deathrattle-orchestration.js","sourceRoot":"","sources":["../../src/simulation/deathrattle-orchestration.ts"],"names":[],"mappings":";;;AAAA,iEAAoD;AAGpD,oCAA2C;AAC3C,qCAA8C;AAC9C,mDAAyD;AACzD,+DAI+B;AAC/B,6DAAkH;AAElH,qCAAiD;AACjD,qCAA+C;AAWxC,MAAM,6BAA6B,GAAG,CAC5C,gBAAkC,EAClC,aAAa,GAAG,IAAI,EACpB,aAAa,GAAG,IAAI,EACnB,EAAE;IAEH,6BAA6B,CAAC,gBAAgB,CAAC,CAAC;IAGhD,+BAA+B,CAAC,gBAAgB,CAAC,CAAC;IAElD,MAAM,iBAAiB,GAAG,CAAC,GAAG,gBAAgB,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACjF,MAAM,mBAAmB,GAAG,CAAC,GAAG,gBAAgB,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAErF,MAAM,wBAAwB,GAAG,mBAAmB,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;IAItF,4BAA4B,CAAC,gBAAgB,CAAC,CAAC;IAM/C,MAAM,gBAAgB,GAAG,CAAC,GAAG,gBAAgB,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChF,MAAM,kBAAkB,GAAG,CAAC,GAAG,gBAAgB,CAAC,SAAS,CAAC,SAA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MAAM,EAAE,qBAAI,CAAC,KAAK,EAAE,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,QAAQ,CAAC,EAC7G;QACD,IAAI,qBAAqB,CAAC,MAAM,CAAC,UAAU,CAAC,eAAe,GAAG,CAAC,EAAE;YAChE,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAC3B,CAAC,EACD,UAAU,CAAC,MAAM,GAAG,qBAAqB,CAAC,MAAM,CAAC,UAAU,CAAC,eAAe,CAC3E,CAAC;SACF;KACD;AACF,CAAC,CAAC","sourcesContent":["import { Race } from '@firestone-hs/reference-data';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { hasCorrectTribe } from '../utils';\r\nimport { applyAvengeEffects } from './avenge';\r\nimport { applyAfterDeathEffects } from './death-effects';\r\nimport {\r\n\tapplyAfterMinionDiesEffect,\r\n\tapplyWheneverMinionDiesEffect,\r\n\thandleAfterMinionKillsEffect,\r\n} from './deathrattle-effects';\r\nimport { spawnEntities, spawnEntitiesFromDeathrattle, spawnEntitiesFromEnchantments } from './deathrattle-spawns';\r\nimport { FullGameState, PlayerState } from './internal-game-state';\r\nimport { handleRebornForEntity } from './reborn';\r\nimport { performEntitySpawns } from './spawns';\r\n\r\n// FIXME:\r\n// From Mitchell on Discord:\r\n// - Minions die left to right\r\n// - When a minion dies, it procs natural deathrattle, added deathrattles, and then all avenges progress\r\n// by 1 (and trigger as necessary)\r\n// - Then next minion\r\n// - After ALL deathrattles and avenges are done, Reborn triggers\r\n// - (Ideally after all of that I would want Feathermane to trigger, but that is not what it does right now.\r\n// Right now it triggers at deathrattle speed rather than after Reborn speed)\r\nexport const orchestrateMinionDeathEffects = (\r\n\tdeathrattleInput: DeathrattleInput,\r\n\tprocessAvenge = true,\r\n\tprocessReborn = true,\r\n) => {\r\n\t// Icesnarl / Rokara here?\r\n\thandleAfterMinionsKillEffects(deathrattleInput);\r\n\r\n\t// Not sure about this\r\n\thandleWheneverMinionsDieEffects(deathrattleInput);\r\n\r\n\tconst playerBoardBefore = [...deathrattleInput.gameState.gameState.player.board];\r\n\tconst opponentBoardBefore = [...deathrattleInput.gameState.gameState.opponent.board];\r\n\r\n\tconst entitiesFromDeathrattles = processDeathrattles(deathrattleInput, processAvenge);\r\n\r\n\t// When a Silent Enforcer dies, it deals damage to other minions, then Soul Juggler damages the minions\r\n\t// **before** they completely die and spawn their own deathrattles\r\n\thandleAfterMinionsDieEffects(deathrattleInput);\r\n\r\n\t// Hack to try and fix how reborn indices are handled when there are spawns during the deathrattle phase\r\n\t// Ideally, this should probably be rewritten completely to keep the dead entities in the board itself\r\n\t// so we can use that as a source for the spawn index. However this is a big rewrite with lots of\r\n\t// potential side-effects\r\n\tconst playerBoardAfter = [...deathrattleInput.gameState.gameState.player.board];\r\n\tconst opponentBoardAfter = [...deathrattleInput.gameState.gameState.opponent.board];\r\n\tconst opponentIndexOfSpawnedEntities = opponentBoardAfter\r\n\t\t.filter((entity) => !opponentBoardBefore.includes(entity))\r\n\t\t.map((entity) => opponentBoardAfter.length - opponentBoardAfter.indexOf(entity) - 1);\r\n\tconst playerIndexOfSpawnedEntities = playerBoardAfter\r\n\t\t.filter((entity) => !playerBoardBefore.includes(entity))\r\n\t\t.map((entity) => playerBoardAfter.length - playerBoardAfter.indexOf(entity) - 1);\r\n\tdeathrattleInput.opponentDeadEntityIndexesFromRight = deathrattleInput.opponentDeadEntityIndexesFromRight.map(\r\n\t\t(previousIndex) => {\r\n\t\t\topponentIndexOfSpawnedEntities.forEach((index) => {\r\n\t\t\t\tif (index < previousIndex) {\r\n\t\t\t\t\tpreviousIndex++;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\treturn previousIndex;\r\n\t\t},\r\n\t);\r\n\tdeathrattleInput.playerDeadEntityIndexesFromRight = deathrattleInput.playerDeadEntityIndexesFromRight.map(\r\n\t\t(previousIndex) => {\r\n\t\t\tplayerIndexOfSpawnedEntities.forEach((index) => {\r\n\t\t\t\tif (index < previousIndex) {\r\n\t\t\t\t\tpreviousIndex++;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\treturn previousIndex;\r\n\t\t},\r\n\t);\r\n\r\n\tif (processReborn) {\r\n\t\tprocessReborns(deathrattleInput);\r\n\t}\r\n\r\n\tconst entitiesFromFeathermanes = processFeathermaneEffects(deathrattleInput);\r\n\thandlePostDeathrattleEffects(deathrattleInput, [...entitiesFromDeathrattles, ...entitiesFromFeathermanes]);\r\n};\r\n\r\nconst handleAfterMinionsKillEffects = (deathrattleInput: DeathrattleInput) => {\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\thandleAfterMinionKillsEffect(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tplayerDeadEntityIndexesFromRight[i][j],\r\n\t\t\t\t\tplayerStates[i].board,\r\n\t\t\t\t\tplayerStates[i].player,\r\n\t\t\t\t\tplayerStates[1 - i].board,\r\n\t\t\t\t\tplayerStates[1 - i].player,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleWheneverMinionsDieEffects = (deathrattleInput: DeathrattleInput) => {\r\n\t// Wildfire Element is applied first, before the DR spawns\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\tapplyWheneverMinionDiesEffect(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tplayerDeadEntityIndexesFromRight[i][j],\r\n\t\t\t\t\tplayerStates[i].board,\r\n\t\t\t\t\tplayerStates[i].player,\r\n\t\t\t\t\tplayerStates[1 - i].board,\r\n\t\t\t\t\tplayerStates[1 - i].player,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleAfterMinionsDieEffects = (deathrattleInput: DeathrattleInput) => {\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\tapplyAfterMinionDiesEffect(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tplayerDeadEntityIndexesFromRight[i][j],\r\n\t\t\t\t\tplayerStates[i].board,\r\n\t\t\t\t\tplayerStates[i].player,\r\n\t\t\t\t\tplayerStates[1 - i].board,\r\n\t\t\t\t\tplayerStates[1 - i].player,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst processDeathrattles = (deathrattleInput: DeathrattleInput, processAvenge = true): BoardEntity[] => {\r\n\tconst entitiesFromDeathrattles: BoardEntity[] = [];\r\n\t// Deathrattles are handled left to right\r\n\t// Then for each minion, natural deathrattles are processed first, then enchantments\r\n\t// http://replays.firestoneapp.com/?reviewId=ec5428bf-a599-4f4c-bea9-8acad5075cb8&turn=11&action=1\r\n\t// http://replays.firestoneapp.com/?reviewId=f32e734a-d5a2-4fa4-ad10-94019969cdd7&turn=6&action=22\r\n\t// http://replays.firestoneapp.com/?reviewId=ea9503c9-2795-49f0-866b-9ea856cec7df&turn=11&action=3\r\n\t// http://replays.firestoneapp.com/?reviewId=1ff37e17-704c-4a73-8c78-377c52b6cb42&turn=13&action=1 is a trap: the enchantment is on the first\r\n\t// minion, but the DR is on the second one.\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\t// Process one player first, then the other\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\t// Issue: we should process all deathrattles first, then all avenge. If multiple minions die at the same time,\r\n\t\t// the current implementation processes the first minion completely (DR + avenge), then the second one\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\t// Entities are processed left to right\r\n\t\t\t// TODO: in fact, the processing order is summoning order, so maybe we can just use the entityId\r\n\t\t\t// to determine the order? https://x.com/LoewenMitchell/status/1750792974383173676?s=20\r\n\t\t\t// \"It should be summoned order (which is most cases would be left to right but mid-combat that could change).\"\r\n\t\t\t// This doesn't actually work: http://replays.firestoneapp.com/?reviewId=ec5428bf-a599-4f4c-bea9-8acad5075cb8&turn=11&action=6\r\n\t\t\t// deadEntities.sort((a, b) => a.entityId - b.entityId);\r\n\t\t\t// So we would need to find another proxy for the order\r\n\t\t\tconst spawns = processDeathrattleForMinions(\r\n\t\t\t\tdeadEntities,\r\n\t\t\t\tplayerDeadEntityIndexesFromRight[i],\r\n\t\t\t\tplayerStates[i],\r\n\t\t\t\tplayerStates[1 - i],\r\n\t\t\t\tdeathrattleInput,\r\n\t\t\t\tprocessAvenge,\r\n\t\t\t);\r\n\t\t\tentitiesFromDeathrattles.push(...spawns);\r\n\t\t\t// for (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\t// \tconst deadEntity = deadEntities[j];\r\n\t\t\t// \tconst indexFromRight = playerDeadEntityIndexesFromRight[i][j];\r\n\t\t\t// \tconst deadEntityPlayerState = playerStates[i];\r\n\t\t\t// \tconst otherPlayerState = playerStates[1 - i];\r\n\t\t\t// \tconst spawns = processDeathrattleForMinion(\r\n\t\t\t// \t\tdeadEntity,\r\n\t\t\t// \t\tindexFromRight,\r\n\t\t\t// \t\tdeadEntities,\r\n\t\t\t// \t\tdeadEntityPlayerState,\r\n\t\t\t// \t\totherPlayerState,\r\n\t\t\t// \t\tdeathrattleInput.gameState,\r\n\t\t\t// \t\tprocessAvenge,\r\n\t\t\t// \t);\r\n\t\t\t// \tentitiesFromDeathrattles.push(...spawns);\r\n\t\t\t// }\r\n\t\t}\r\n\t}\r\n\treturn entitiesFromDeathrattles;\r\n};\r\n\r\nconst processFeathermaneEffects = (deathrattleInput: DeathrattleInput, processAvenge = true): BoardEntity[] => {\r\n\tconst entitiesFromDeathrattles: BoardEntity[] = [];\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\t// Process one player first, then the other\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\t// Entities are processed left to right\r\n\t\t\t// TODO: in fact, the processing order is summoning order, so maybe we can just use the entityId\r\n\t\t\t// to determine the order? https://x.com/LoewenMitchell/status/1750792974383173676?s=20\r\n\t\t\t// \"It should be summoned order (which is most cases would be left to right but mid-combat that could change).\"\r\n\t\t\t// This doesn't actually work: http://replays.firestoneapp.com/?reviewId=ec5428bf-a599-4f4c-bea9-8acad5075cb8&turn=11&action=6\r\n\t\t\t// deadEntities.sort((a, b) => a.entityId - b.entityId);\r\n\t\t\t// So we would need to find another proxy for the order\r\n\t\t\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\tconst indexFromRight = playerDeadEntityIndexesFromRight[i][j];\r\n\t\t\t\tconst modifiedIndexFromRight = Math.min(playerStates[i].board.length, indexFromRight);\r\n\t\t\t\tconst deadEntityPlayerState = playerStates[i];\r\n\t\t\t\tconst otherPlayerState = playerStates[1 - i];\r\n\t\t\t\tconst spawns = processFeathermaneForMinion(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\tdeadEntities,\r\n\t\t\t\t\tdeadEntityPlayerState,\r\n\t\t\t\t\totherPlayerState,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t\tprocessAvenge,\r\n\t\t\t\t);\r\n\t\t\t\tentitiesFromDeathrattles.push(...spawns);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn entitiesFromDeathrattles;\r\n};\r\n\r\nconst processFeathermaneForMinion = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tdeadEntities: BoardEntity[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tgameState: FullGameState,\r\n\tprocessAvenge = true,\r\n) => {\r\n\tconst maxSpawns = 7 - deadEntityPlayerState.board.length;\r\n\tconst allSpawns = [];\r\n\r\n\t// Feathermane\r\n\tif (\r\n\t\thasCorrectTribe(deadEntity, deadEntityPlayerState.player, Race.BEAST, gameState.anomalies, gameState.allCards)\r\n\t) {\r\n\t\tconst feathermanes =\r\n\t\t\tdeadEntityPlayerState.player.hand\r\n\t\t\t\t?.filter((e) => !e.locked)\r\n\t\t\t\t.filter(\r\n\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\te.cardId === CardIds.FreeFlyingFeathermane_BG27_014 ||\r\n\t\t\t\t\t\te.cardId === CardIds.FreeFlyingFeathermane_BG27_014_G,\r\n\t\t\t\t) ?? [];\r\n\t\tfor (const feathermaneSpawn of feathermanes) {\r\n\t\t\tif (allSpawns.length >= maxSpawns) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tfeathermaneSpawn.locked = true;\r\n\t\t\tconst spawns = spawnEntities(\r\n\t\t\t\tfeathermaneSpawn.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tdeadEntityPlayerState.board,\r\n\t\t\t\tdeadEntityPlayerState.player,\r\n\t\t\t\totherPlayerState.board,\r\n\t\t\t\totherPlayerState.player,\r\n\t\t\t\tgameState,\r\n\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\ttrue,\r\n\t\t\t\t{ ...feathermaneSpawn } as BoardEntity,\r\n\t\t\t);\r\n\r\n\t\t\t// So that it can be flagged as \"unspawned\" if it is not spawned in the end\r\n\t\t\tfor (const spawn of spawns) {\r\n\t\t\t\tspawn.onCanceledSummon = () => (feathermaneSpawn.locked = false);\r\n\t\t\t\t// spawn.backRef = feathermaneSpawn;\r\n\t\t\t}\r\n\t\t\tallSpawns.push(...spawns);\r\n\t\t}\r\n\t}\r\n\r\n\tperformEntitySpawns(\r\n\t\tallSpawns,\r\n\t\tdeadEntityPlayerState.board,\r\n\t\tdeadEntityPlayerState.player,\r\n\t\tdeadEntity,\r\n\t\tindexFromRight,\r\n\t\totherPlayerState.board,\r\n\t\totherPlayerState.player,\r\n\t\tgameState,\r\n\t);\r\n\treturn allSpawns;\r\n};\r\n\r\nconst processDeathrattleForMinions = (\r\n\tdeadEntities: BoardEntity[],\r\n\tplayerDeadEntityIndexesFromRight: number[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tinput: DeathrattleInput,\r\n\tprocessAvenge = true,\r\n) => {\r\n\tconst entitiesFromDeathrattles: BoardEntity[] = [];\r\n\r\n\t// Natural deathrattles & enchantments\r\n\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\tconst deadEntity = deadEntities[j];\r\n\t\tconst indexFromRight = playerDeadEntityIndexesFromRight[j];\r\n\t\tconst drEntities = handleNaturalDeathrattle(\r\n\t\t\tdeadEntity,\r\n\t\t\tindexFromRight,\r\n\t\t\tdeadEntities,\r\n\t\t\tdeadEntityPlayerState,\r\n\t\t\totherPlayerState,\r\n\t\t\tinput.gameState,\r\n\t\t);\r\n\t\tconst enchEntities = handleEnchantmentsDeathrattle(\r\n\t\t\tdeadEntity,\r\n\t\t\tindexFromRight,\r\n\t\t\tdeadEntities,\r\n\t\t\tdeadEntityPlayerState,\r\n\t\t\totherPlayerState,\r\n\t\t\tinput.gameState,\r\n\t\t);\r\n\r\n\t\tentitiesFromDeathrattles.push(...drEntities, ...enchEntities);\r\n\t}\r\n\r\n\t// Avenge\r\n\tlet avengeEntities = [];\r\n\tif (processAvenge) {\r\n\t\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\tconst indexFromRight = playerDeadEntityIndexesFromRight[j];\r\n\t\t\tavengeEntities = applyAvengeEffects(\r\n\t\t\t\tdeadEntity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\tdeadEntityPlayerState.board,\r\n\t\t\t\tdeadEntityPlayerState.player,\r\n\t\t\t\totherPlayerState.board,\r\n\t\t\t\totherPlayerState.player,\r\n\t\t\t\tinput.gameState,\r\n\t\t\t\tentitiesFromDeathrattles,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\tconst allAfterDeathEntities = [];\r\n\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\tconst deadEntity = deadEntities[j];\r\n\t\tconst indexFromRight = playerDeadEntityIndexesFromRight[j];\r\n\t\tconst afterDeathEntities = applyAfterDeathEffects(\r\n\t\t\tdeadEntity,\r\n\t\t\tindexFromRight,\r\n\t\t\tdeadEntityPlayerState.board,\r\n\t\t\tdeadEntityPlayerState.player,\r\n\t\t\totherPlayerState.board,\r\n\t\t\totherPlayerState.player,\r\n\t\t\tinput.gameState,\r\n\t\t);\r\n\t\tallAfterDeathEntities.push(...afterDeathEntities);\r\n\t}\r\n\r\n\treturn [...entitiesFromDeathrattles, ...avengeEntities, ...allAfterDeathEntities];\r\n};\r\n\r\nexport const processDeathrattleForMinion = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tdeadEntities: BoardEntity[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tgameState: FullGameState,\r\n\tprocessAvenge = true,\r\n) => {\r\n\tconst drEntities = handleNaturalDeathrattle(\r\n\t\tdeadEntity,\r\n\t\tindexFromRight,\r\n\t\tdeadEntities,\r\n\t\tdeadEntityPlayerState,\r\n\t\totherPlayerState,\r\n\t\tgameState,\r\n\t);\r\n\tconst enchEntities = handleEnchantmentsDeathrattle(\r\n\t\tdeadEntity,\r\n\t\tindexFromRight,\r\n\t\tdeadEntities,\r\n\t\tdeadEntityPlayerState,\r\n\t\totherPlayerState,\r\n\t\tgameState,\r\n\t);\r\n\t// Avenge trigger before reborn\r\n\t// http://replays.firestoneapp.com/?reviewId=5bb20eb8-e0ca-47ab-adc7-13134716d568&turn=7&action=6\r\n\tlet avengeEntities = [];\r\n\tlet afterDeathEntities = [];\r\n\tif (processAvenge) {\r\n\t\tavengeEntities = applyAvengeEffects(\r\n\t\t\tdeadEntity,\r\n\t\t\tindexFromRight,\r\n\t\t\tdeadEntityPlayerState.board,\r\n\t\t\tdeadEntityPlayerState.player,\r\n\t\t\totherPlayerState.board,\r\n\t\t\totherPlayerState.player,\r\n\t\t\tgameState,\r\n\t\t\t[...drEntities, ...enchEntities],\r\n\t\t);\r\n\r\n\t\t// TODO: Feathermane should be applied after the Reborn effects have all been processed\r\n\t\t// Secrets should be processed here (\"at Avenge speed\")\r\n\t\tafterDeathEntities = applyAfterDeathEffects(\r\n\t\t\tdeadEntity,\r\n\t\t\tindexFromRight,\r\n\t\t\tdeadEntityPlayerState.board,\r\n\t\t\tdeadEntityPlayerState.player,\r\n\t\t\totherPlayerState.board,\r\n\t\t\totherPlayerState.player,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\treturn [...drEntities, ...enchEntities, ...avengeEntities, ...afterDeathEntities];\r\n};\r\n\r\nconst handleNaturalDeathrattle = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tdeadEntities: BoardEntity[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tgameState: FullGameState,\r\n): readonly BoardEntity[] => {\r\n\tconst modifiedIndexFromRight = Math.min(deadEntityPlayerState.board.length, indexFromRight);\r\n\t// const allSpawns = [];\r\n\t// const spawnsToSpawn = [];\r\n\tfor (const dr of deadEntity.rememberedDeathrattles ?? []) {\r\n\t\tconst entityToProcess: BoardEntity = {\r\n\t\t\t...deadEntity,\r\n\t\t\toriginalCardId: deadEntity.cardId,\r\n\t\t\trememberedDeathrattles: undefined,\r\n\t\t\tdeathrattleRepeats: dr.repeats ?? 1,\r\n\t\t\tscriptDataNum1: dr.scriptDataNum1,\r\n\t\t\tscriptDataNum2: dr.scriptDataNum2,\r\n\t\t\tcardId: dr.cardId,\r\n\t\t\tpendingAttackBuffs: [],\r\n\t\t\t// For Corrupted Bristler\r\n\t\t\tenchantments: deadEntity.enchantments.filter((e) => e.cardId?.startsWith(CardIds.BloodGem)),\r\n\t\t\tmemory:\r\n\t\t\t\tdr.memory == null\r\n\t\t\t\t\t? null\r\n\t\t\t\t\t: Array.isArray(dr.memory)\r\n\t\t\t\t\t? dr.memory.map((mem) => ({ ...mem }))\r\n\t\t\t\t\t: { ...dr.memory },\r\n\t\t};\r\n\t\tconst spawns = handleNaturalDeathrattle(\r\n\t\t\tentityToProcess,\r\n\t\t\tindexFromRight,\r\n\t\t\tdeadEntities,\r\n\t\t\tdeadEntityPlayerState,\r\n\t\t\totherPlayerState,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\t// The spawns have already been processed in the \"handleNaturalDeathrattle\" method\r\n\t\t// spawnsToSpawn.push(...spawns);\r\n\t\t// allSpawns.push(...spawns);\r\n\t}\r\n\r\n\tconst entitiesFromNativeDeathrattle: readonly BoardEntity[] = spawnEntitiesFromDeathrattle(\r\n\t\tdeadEntity,\r\n\t\tmodifiedIndexFromRight,\r\n\t\tdeadEntityPlayerState.board,\r\n\t\tdeadEntityPlayerState.player,\r\n\t\totherPlayerState.board,\r\n\t\totherPlayerState.player,\r\n\t\tdeadEntities,\r\n\t\tgameState,\r\n\t);\r\n\t// allSpawns.push(...entitiesFromNativeDeathrattle);\r\n\t// spawnsToSpawn.push(...entitiesFromNativeDeathrattle);\r\n\t// Some candidate entities are not spawned, and so are ignored in further processing\r\n\t// const actualSpawns = performEntitySpawns(\r\n\t// \tspawnsToSpawn,\r\n\t// \tdeadEntityPlayerState.board,\r\n\t// \tdeadEntityPlayerState.player,\r\n\t// \tdeadEntity,\r\n\t// \tmodifiedIndexFromRight,\r\n\t// \totherPlayerState.board,\r\n\t// \totherPlayerState.player,\r\n\t// \tgameState,\r\n\t// );\r\n\t// In case of leapfrogger, we want to first spawn the minions, then apply the frog effect\r\n\t// TODO: revisit this once Leapfroggers are in the game again\r\n\t// handleDeathrattleEffects(\r\n\t// \tdeadEntityPlayerState.board,\r\n\t// \tdeadEntityPlayerState.player,\r\n\t// \tdeadEntity,\r\n\t// \tmodifiedIndexFromRight,\r\n\t// \totherPlayerState.board,\r\n\t// \totherPlayerState.player,\r\n\t// \tgameState,\r\n\t// );\r\n\r\n\treturn entitiesFromNativeDeathrattle;\r\n};\r\n\r\nconst handleEnchantmentsDeathrattle = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tdeadEntities: BoardEntity[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tgameState: FullGameState,\r\n\tskipSpawns = false,\r\n) => {\r\n\tconst modifiedIndexFromRight = Math.min(deadEntityPlayerState.board.length, indexFromRight);\r\n\tconst result = [];\r\n\tfor (const dr of deadEntity.rememberedDeathrattles ?? []) {\r\n\t\tconst entityToProcess: BoardEntity = {\r\n\t\t\t...deadEntity,\r\n\t\t\trememberedDeathrattles: undefined,\r\n\t\t\tcardId: dr.cardId,\r\n\t\t\t// So that cards that rely on the tavern tier use the base entity, and not the enchantment / remembered card\r\n\t\t\ttavernTier: gameState.cardsData.getTavernLevel(deadEntity.cardId),\r\n\t\t\tenchantments: [\r\n\t\t\t\t{\r\n\t\t\t\t\tcardId: dr.cardId,\r\n\t\t\t\t\toriginEntityId: deadEntity.entityId,\r\n\t\t\t\t\trepeats: dr.repeats ?? 1,\r\n\t\t\t\t\ttiming: dr.timing,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t\tpendingAttackBuffs: [],\r\n\t\t};\r\n\t\tconst spawns = handleEnchantmentsDeathrattle(\r\n\t\t\tentityToProcess,\r\n\t\t\tindexFromRight,\r\n\t\t\tdeadEntities,\r\n\t\t\tdeadEntityPlayerState,\r\n\t\t\totherPlayerState,\r\n\t\t\tgameState,\r\n\t\t\t// We skip spawns, otherwise it will be added twice\r\n\t\t\ttrue,\r\n\t\t);\r\n\t\tresult.push(...spawns);\r\n\t}\r\n\tconst entitiesFromEnchantments: readonly BoardEntity[] = spawnEntitiesFromEnchantments(\r\n\t\tdeadEntity,\r\n\t\tdeadEntityPlayerState.board,\r\n\t\tdeadEntityPlayerState.player,\r\n\t\totherPlayerState.board,\r\n\t\totherPlayerState.player,\r\n\t\tgameState,\r\n\t);\r\n\tresult.push(...entitiesFromEnchantments);\r\n\tif (!skipSpawns) {\r\n\t\tperformEntitySpawns(\r\n\t\t\tresult,\r\n\t\t\tdeadEntityPlayerState.board,\r\n\t\t\tdeadEntityPlayerState.player,\r\n\t\t\tdeadEntity,\r\n\t\t\tmodifiedIndexFromRight,\r\n\t\t\totherPlayerState.board,\r\n\t\t\totherPlayerState.player,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\treturn result;\r\n};\r\n\r\nconst processReborns = (deathrattleInput: DeathrattleInput) => {\r\n\t// const entitiesFromReborn: BoardEntity[] = [];\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\t// Process one player first, then the other\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\tconst indexFromRight = playerDeadEntityIndexesFromRight[i][j];\r\n\t\t\t\tconst modifiedIndexFromRight = Math.min(playerStates[i].board.length, indexFromRight);\r\n\t\t\t\tconst deadEntityPlayerState = playerStates[i];\r\n\t\t\t\tconst otherPlayerState = playerStates[1 - i];\r\n\t\t\t\thandleRebornForEntity(\r\n\t\t\t\t\tdeadEntityPlayerState.board,\r\n\t\t\t\t\tdeadEntityPlayerState.player,\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\totherPlayerState.board,\r\n\t\t\t\t\totherPlayerState.player,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handlePostDeathrattleEffects = (deathrattleInput: DeathrattleInput, entitiesFromDeathrattles: BoardEntity[]) => {\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\t// Process one player first, then the other\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tconst deadEntityPlayerState = playerStates[i];\r\n\t\tconst otherPlayerState = playerStates[1 - i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\t// Process from right to left, so that we can set the hasAttacked attribute properly\r\n\t\t\t// If two minions die at the same time, both of which having attacked, but the third in line having not,\r\n\t\t\t// processing them from left to right means the first (leftmost) one will check its right neighbor, which\r\n\t\t\t// is the minion that hasn't attacked\r\n\t\t\tfor (let j = deadEntities.length - 1; j >= 0; j--) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\tconst indexFromRight = playerDeadEntityIndexesFromRight[i][j];\r\n\t\t\t\tconst modifiedIndexFromRight = Math.min(playerStates[i].board.length, indexFromRight);\r\n\t\t\t\thandlePostDeathrattleEffect(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\tdeadEntities,\r\n\t\t\t\t\tdeadEntityPlayerState,\r\n\t\t\t\t\totherPlayerState,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t\tentitiesFromDeathrattles,\r\n\t\t\t\t\tdeadEntityPlayerState.player.friendly,\r\n\t\t\t\t\tdeathrattleInput,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const handleDeathrattles = (deathrattleInput: DeathrattleInput) => {\r\n\torchestrateMinionDeathEffects(deathrattleInput, false, false);\r\n};\r\n\r\nconst handlePostDeathrattleEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tdeadEntities: BoardEntity[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tgameState: FullGameState,\r\n\tspawnedEntities: BoardEntity[],\r\n\tisPlayer: boolean,\r\n\tdeathrattleInput: DeathrattleInput,\r\n) => {\r\n\t// This doesn't work if the entity that was to the right died.\r\n\tconst entityRightToSpawns =\r\n\t\tindexFromRight === 0 ? null : deadEntityPlayerState.board[deadEntityPlayerState.board.length - indexFromRight];\r\n\t// To handle minions attack tokens\r\n\t// See http://replays.firestoneapp.com/?reviewId=0583d6a4-6ed0-4b20-894e-4ceb560894fe&turn=6&action=11\r\n\t// When a minion dies, the spawn are either elligible to attack next turn or not\r\n\t// If the minion right to the spawned minion has already attacked, then the spawned\r\n\t// minion cannot attack\r\n\tspawnedEntities.forEach((entity) => {\r\n\t\tentity.hasAttacked = deadEntity.hasAttacked > 1 ? 1 : entityRightToSpawns?.hasAttacked ?? 0;\r\n\t});\r\n\r\n\tif (deadEntityPlayerState.player.questRewards?.includes(CardIds.RitualDagger_BG24_Reward_113)) {\r\n\t\tconst ogDeadEntity = gameState.sharedState.deaths.find((entity) => entity.entityId === deadEntity.entityId);\r\n\t\tif (ogDeadEntity) {\r\n\t\t\togDeadEntity.attack += 4;\r\n\t\t\togDeadEntity.health += 4;\r\n\t\t}\r\n\t}\r\n\r\n\t// ISSUE: when we do this, we change the minion's stats before processing deathrattle effects, which can mess\r\n\t// up the simulation in some cases (like Nightbane, Ignited)\r\n\t// FIX: we do it in postDeathrattleEfects, not when removing minions from the board\r\n\tif (deadEntityPlayerState.player.globalInfo.HauntedCarapaceAttackBonus > 0) {\r\n\t\tdeadEntity.attack = Math.max(\r\n\t\t\t0,\r\n\t\t\tdeadEntity.attack - deadEntityPlayerState.player.globalInfo.HauntedCarapaceAttackBonus,\r\n\t\t);\r\n\t}\r\n\tif (deadEntityPlayerState.player.globalInfo.HauntedCarapaceHealthBonus > 0) {\r\n\t\tdeadEntity.health = Math.max(\r\n\t\t\t1,\r\n\t\t\tdeadEntity.health - deadEntityPlayerState.player.globalInfo.HauntedCarapaceHealthBonus,\r\n\t\t);\r\n\t}\r\n\tif (\r\n\t\thasCorrectTribe(deadEntity, deadEntityPlayerState.player, Race.UNDEAD, gameState.anomalies, gameState.allCards)\r\n\t) {\r\n\t\tif (deadEntityPlayerState.player.globalInfo.UndeadAttackBonus > 0) {\r\n\t\t\tdeadEntity.attack = Math.max(\r\n\t\t\t\t0,\r\n\t\t\t\tdeadEntity.attack - deadEntityPlayerState.player.globalInfo.UndeadAttackBonus,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\tif (\r\n\t\thasCorrectTribe(deadEntity, deadEntityPlayerState.player, Race.BEAST, gameState.anomalies, gameState.allCards)\r\n\t) {\r\n\t\tif (deadEntityPlayerState.player.globalInfo.GoldrinnBuffAtk > 0) {\r\n\t\t\tdeadEntity.attack = Math.max(\r\n\t\t\t\t0,\r\n\t\t\t\tdeadEntity.attack - deadEntityPlayerState.player.globalInfo.GoldrinnBuffAtk,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n};\r\n\r\ninterface DeathrattleInput {\r\n\tgameState: FullGameState;\r\n\tplayerDeadEntities: BoardEntity[];\r\n\tplayerDeadEntityIndexesFromRight: number[];\r\n\topponentDeadEntities: BoardEntity[];\r\n\topponentDeadEntityIndexesFromRight: number[];\r\n}\r\n"]}
@@ -98,6 +98,7 @@ const applyOnAttackEffects = (attacker, attackingBoard, attackingBoardHero, defe
98
98
  health: attacker.health,
99
99
  maxHealth: attacker.maxHealth,
100
100
  maxAttack: attacker.maxAttack,
101
+ abiityChargesLeft: attacker.abiityChargesLeft,
101
102
  };
102
103
  enchantmentToMinion = (0, enchantments_1.fixEnchantments)(enchantmentToMinion, gameState.allCards);
103
104
  const { dmgDoneByAttacker, dmgDoneByDefender } = onAttackImpl.rally(enchantmentToMinion, {
@@ -1 +1 @@
1
- {"version":3,"file":"on-attack.js","sourceRoot":"","sources":["../../src/simulation/on-attack.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAG7D,4DAAsF;AACtF,iEAA4D;AAC5D,+CAAkD;AAElD,6CAA+C;AAC/C,oCAA8D;AAC9D,qCAA6D;AAC7D,mDAAiD;AACjD,iDAAiD;AAEjD,mCAAsC;AA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Z,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CACb;;;SAGC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAiB,CAAC,CAC/B;aACA,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACd,CAAC,CAAC,iBAAiB,EAAE,CAAC;QACvB,CAAC,CAAC,CAAC;KACJ;IAED,KAAK,MAAM,OAAO,IAAI,kBAAkB,CAAC,QAAQ,EAAE;QAClD,QAAQ,OAAO,CAAC,MAAM,EAAE;YACvB;gBACC,IAAA,mBAAW,EAAC,QAAQ,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,cAAc,EAAE,kBAAkB,EAAE,SAAS,CAAC,CAAC;gBACpF,MAAM;SACP;KACD;IAED,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,CAAC;AACvD,CAAC,CAAC;AAjSW,QAAA,oBAAoB,wBAiS/B","sourcesContent":["import { GameTag, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { hasOnWheneverAnotherMinionAttacks, hasRally } from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { updateReborn } from '../keywords/reborn';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { pickRandom } from '../services/utils';\r\nimport { hasCorrectTribe, hasEntityMechanic } from '../utils';\r\nimport { dealDamageToMinion, getNeighbours } from './attack';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport { fixEnchantments } from './enchantments';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { modifyStats } from './stats';\r\n\r\n// Whenever it attacks\r\nexport const applyOnAttackEffects = (\r\n\tattacker: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingEntity: BoardEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): { damageDoneByAttacker: number; damageDoneByDefender: number } => {\r\n\tlet damageDoneByAttacker = 0;\r\n\tlet damageDoneByDefender = 0;\r\n\r\n\tfor (const trinket of attackingBoardHero.trinkets ?? []) {\r\n\t\tconst onAttackImpl = cardMappings[trinket.cardId];\r\n\t\tif (hasOnWheneverAnotherMinionAttacks(onAttackImpl)) {\r\n\t\t\tconst { dmgDoneByAttacker, dmgDoneByDefender } = onAttackImpl.onWheneverAnotherMinionAttacks(trinket, {\r\n\t\t\t\tattacker: attacker,\r\n\t\t\t\tattackingHero: attackingBoardHero,\r\n\t\t\t\tattackingBoard: attackingBoard,\r\n\t\t\t\tdefendingEntity: defendingEntity,\r\n\t\t\t\tdefendingHero: defendingBoardHero,\r\n\t\t\t\tdefendingBoard: defendingBoard,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerIsFriendly: attackingBoardHero.friendly,\r\n\t\t\t});\r\n\t\t\tdamageDoneByAttacker += dmgDoneByAttacker;\r\n\t\t\tdamageDoneByDefender += dmgDoneByDefender;\r\n\t\t}\r\n\t}\r\n\r\n\t// \"Whenever friendly minion attacks\" triggers before the rally itself?\r\n\t// https://replays.firestoneapp.com/?reviewId=04e6a624-ccd5-4068-9420-884843f3685f&turn=25&action=1\r\n\tconst attackingBoardOtherEntities = attackingBoard.filter((e) => e !== attacker);\r\n\tfor (const boardEntity of attackingBoardOtherEntities) {\r\n\t\tconst onAttackImpl = cardMappings[boardEntity.cardId];\r\n\t\tif (hasOnWheneverAnotherMinionAttacks(onAttackImpl)) {\r\n\t\t\tconst { dmgDoneByAttacker, dmgDoneByDefender } = onAttackImpl.onWheneverAnotherMinionAttacks(boardEntity, {\r\n\t\t\t\tattacker: attacker,\r\n\t\t\t\tattackingHero: attackingBoardHero,\r\n\t\t\t\tattackingBoard: attackingBoard,\r\n\t\t\t\tdefendingEntity: defendingEntity,\r\n\t\t\t\tdefendingHero: defendingBoardHero,\r\n\t\t\t\tdefendingBoard: defendingBoard,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerIsFriendly: attackingBoardHero.friendly,\r\n\t\t\t});\r\n\t\t\tdamageDoneByAttacker += dmgDoneByAttacker;\r\n\t\t\tdamageDoneByDefender += dmgDoneByDefender;\r\n\t\t}\r\n\t\tconst enchantments = boardEntity.enchantments;\r\n\t\tfor (const enchantment of enchantments) {\r\n\t\t\tconst onAttackImpl = cardMappings[enchantment.cardId];\r\n\t\t\tif (hasOnWheneverAnotherMinionAttacks(onAttackImpl)) {\r\n\t\t\t\tconst { dmgDoneByAttacker, dmgDoneByDefender } = onAttackImpl.onWheneverAnotherMinionAttacks(\r\n\t\t\t\t\tenchantment,\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tattacker: attacker,\r\n\t\t\t\t\t\tattackingHero: attackingBoardHero,\r\n\t\t\t\t\t\tattackingBoard: attackingBoard,\r\n\t\t\t\t\t\tdefendingEntity: defendingEntity,\r\n\t\t\t\t\t\tdefendingHero: defendingBoardHero,\r\n\t\t\t\t\t\tdefendingBoard: defendingBoard,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\tplayerIsFriendly: attackingBoardHero.friendly,\r\n\t\t\t\t\t},\r\n\t\t\t\t);\r\n\t\t\t\tdamageDoneByAttacker += dmgDoneByAttacker;\r\n\t\t\t\tdamageDoneByDefender += dmgDoneByDefender;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// This assumes that only \"Rally\" effects trigger on attack\r\n\t// 2025-08-20: this is false. \"Whenever a friendly minion attacks\" is not a rally effect\r\n\tconst isAttackerRallying = hasEntityMechanic(attacker, GameTag.BACON_RALLY, gameState.allCards);\r\n\tconst numberOfRallyingCries =\r\n\t\tattackingBoardHero.questRewardEntities?.filter((r) => r.cardId === CardIds.RallyingCry_BG33_Reward_021)\r\n\t\t\t.length ?? 0;\r\n\tconst rallyLoops = 1 + (isAttackerRallying ? numberOfRallyingCries : 0);\r\n\tfor (let i = 0; i < rallyLoops; i++) {\r\n\t\tconst onAttackImpl = cardMappings[attacker.cardId];\r\n\t\tif (hasRally(onAttackImpl)) {\r\n\t\t\tconst { dmgDoneByAttacker, dmgDoneByDefender } = onAttackImpl.rally(attacker, {\r\n\t\t\t\tattacker: attacker,\r\n\t\t\t\tattackingHero: attackingBoardHero,\r\n\t\t\t\tattackingBoard: attackingBoard,\r\n\t\t\t\tdefendingEntity: defendingEntity,\r\n\t\t\t\tdefendingHero: defendingBoardHero,\r\n\t\t\t\tdefendingBoard: defendingBoard,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerIsFriendly: attackingBoardHero.friendly,\r\n\t\t\t});\r\n\t\t\tdamageDoneByAttacker += dmgDoneByAttacker;\r\n\t\t\tdamageDoneByDefender += dmgDoneByDefender;\r\n\t\t}\r\n\t\tconst enchantments = attacker.enchantments;\r\n\t\tfor (const enchantment of enchantments) {\r\n\t\t\tconst onAttackImpl = cardMappings[enchantment.cardId];\r\n\t\t\tif (hasRally(onAttackImpl)) {\r\n\t\t\t\tlet enchantmentToMinion: BoardEntity = {\r\n\t\t\t\t\t...enchantment,\r\n\t\t\t\t\tentityId: attacker.entityId,\r\n\t\t\t\t\tattack: attacker.attack,\r\n\t\t\t\t\thealth: attacker.health,\r\n\t\t\t\t\tmaxHealth: attacker.maxHealth,\r\n\t\t\t\t\tmaxAttack: attacker.maxAttack,\r\n\t\t\t\t};\r\n\t\t\t\tenchantmentToMinion = fixEnchantments(enchantmentToMinion, gameState.allCards);\r\n\t\t\t\tconst { dmgDoneByAttacker, dmgDoneByDefender } = onAttackImpl.rally(enchantmentToMinion, {\r\n\t\t\t\t\tattacker: attacker,\r\n\t\t\t\t\tattackingHero: attackingBoardHero,\r\n\t\t\t\t\tattackingBoard: attackingBoard,\r\n\t\t\t\t\tdefendingEntity: defendingEntity,\r\n\t\t\t\t\tdefendingHero: defendingBoardHero,\r\n\t\t\t\t\tdefendingBoard: defendingBoard,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tplayerIsFriendly: attackingBoardHero.friendly,\r\n\t\t\t\t});\r\n\t\t\t\tdamageDoneByAttacker += dmgDoneByAttacker;\r\n\t\t\t\tdamageDoneByDefender += dmgDoneByDefender;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Damage happens before the entity is buffed, e.g. before an attack buff from Roaring Rallier\r\n\tif (\r\n\t\tattacker.cardId === CardIds.ObsidianRavager_BG27_017 ||\r\n\t\tattacker.cardId === CardIds.ObsidianRavager_BG27_017_G\r\n\t) {\r\n\t\tconst neighbours = getNeighbours(defendingBoard, defendingEntity);\r\n\t\tconst targets = attacker.cardId === CardIds.ObsidianRavager_BG27_017_G ? neighbours : [pickRandom(neighbours)];\r\n\t\t[defendingEntity, ...targets].forEach((target) => {\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tattacker,\r\n\t\t\t\ttarget,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t);\r\n\t\t\t// damageDoneByAttacker +=\r\n\t\t\tdealDamageToMinion(\r\n\t\t\t\ttarget,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tattacker,\r\n\t\t\t\tattacker.attack,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\r\n\t// Roaring Rallier\r\n\tif (hasCorrectTribe(attacker, attackingBoardHero, Race.DRAGON, gameState.anomalies, gameState.allCards)) {\r\n\t\tattackingBoard\r\n\t\t\t.filter(\r\n\t\t\t\t(e) => e.cardId === CardIds.RoaringRallier_BG29_816 || e.cardId === CardIds.RoaringRallier_BG29_816_G,\r\n\t\t\t)\r\n\t\t\t.forEach((rallier) => {\r\n\t\t\t\tif (rallier !== attacker) {\r\n\t\t\t\t\tconst stats = rallier.cardId === CardIds.RoaringRallier_BG29_816_G ? 2 : 1;\r\n\t\t\t\t\tmodifyStats(attacker, rallier, 3 * stats, 1 * stats, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t}\r\n\r\n\t// if (attacker.cardId === CardIds.GlyphGuardian_BGS_045) {\r\n\t// \t// For now the utility method only works additively, so we hack around it\r\n\t// \tmodifyStats(\r\n\t// \t\tattacker,\r\n\t// \t\tnull,\r\n\t// \t\t2 * attacker.attack - attacker.attack,\r\n\t// \t\t0,\r\n\t// \t\tattackingBoard,\r\n\t// \t\tattackingBoardHero,\r\n\t// \t\tgameState,\r\n\t// \t);\r\n\t// } else if (attacker.cardId === CardIds.GlyphGuardian_TB_BaconUps_115) {\r\n\t// \tmodifyStats(\r\n\t// \t\tattacker,\r\n\t// \t\tnull,\r\n\t// \t\t3 * attacker.attack - attacker.attack,\r\n\t// \t\t0,\r\n\t// \t\tattackingBoard,\r\n\t// \t\tattackingBoardHero,\r\n\t// \t\tgameState,\r\n\t// \t);\r\n\t// } else\r\n\tif (attacker.cardId === CardIds.GlimGuardian_BG29_888 || attacker.cardId === CardIds.GlimGuardian_BG29_888_G) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.GlimGuardian_BG29_888_G ? 2 : 1;\r\n\t\tmodifyStats(attacker, attacker, 2 * multiplier, 0, attackingBoard, attackingBoardHero, gameState);\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708 ||\r\n\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708_G\r\n\t) {\r\n\t\tattackingBoard\r\n\t\t\t.filter((e) => hasCorrectTribe(e, attackingBoardHero, Race.PIRATE, gameState.anomalies, gameState.allCards))\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\tmodifyStats(\r\n\t\t\t\t\te,\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708_G ? 4 : 2,\r\n\t\t\t\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708_G ? 4 : 2,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.WhirlingLassOMatic_BG28_635 ||\r\n\t\tattacker.cardId === CardIds.WhirlingLassOMatic_BG28_635_G\r\n\t) {\r\n\t\tconst numberOfCardsToAdd = attacker.cardId === CardIds.WhirlingLassOMatic_BG28_635_G ? 2 : 1;\r\n\t\tconst cardsToAdd = Array.from({ length: numberOfCardsToAdd }).map(() => null);\r\n\t\taddCardsInHand(attackingBoardHero, attackingBoard, cardsToAdd, gameState);\r\n\t} else if (attacker.cardId === CardIds.Rampager_BG29_809 || attacker.cardId === CardIds.Rampager_BG29_809_G) {\r\n\t\tconst loops = attacker.cardId === CardIds.Rampager_BG29_809_G ? 2 : 1;\r\n\t\tfor (let i = 0; i < loops; i++) {\r\n\t\t\t// Don't include new spawns\r\n\t\t\tfor (const entity of [...attackingBoard]) {\r\n\t\t\t\tif (entity.entityId === attacker.entityId) {\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\t\t\t\tconst isSameSide = entity.friendly === attacker.friendly;\r\n\t\t\t\tconst board = isSameSide ? attackingBoard : defendingBoard;\r\n\t\t\t\tconst hero = isSameSide ? attackingBoardHero : defendingBoardHero;\r\n\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tboard,\r\n\t\t\t\t\thero,\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tisSameSide ? defendingBoard : attackingBoard,\r\n\t\t\t\t\tisSameSide ? defendingBoardHero : attackingBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (attacker.cardId === CardIds.HatefulHag_BG29_120 || attacker.cardId === CardIds.HatefulHag_BG29_120_G) {\r\n\t\tconst loops = attacker.cardId === CardIds.HatefulHag_BG29_120_G ? 2 : 1;\r\n\t\tconst attackerIndex = attackingBoard.indexOf(attacker);\r\n\t\tfor (let i = 1; i <= loops; i++) {\r\n\t\t\tconst target = attackingBoard[attackerIndex + i];\r\n\t\t\tif (!!target) {\r\n\t\t\t\tupdateReborn(target, true, attackingBoard, attackingBoardHero, defendingBoardHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tconst eclipsion = attackingBoard.find(\r\n\t\t(e) =>\r\n\t\t\t[\r\n\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy,\r\n\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy_G,\r\n\t\t\t].includes(e.cardId as CardIds) && e.abiityChargesLeft > 0,\r\n\t);\r\n\t// Only once per minion\r\n\tif (!!eclipsion && attacker.immuneWhenAttackCharges == null) {\r\n\t\tattacker.immuneWhenAttackCharges = 1;\r\n\t\t// If we have 2 eclipsions, the first minion that attacks eats both charges\r\n\t\tattackingBoard\r\n\t\t\t.filter((e) =>\r\n\t\t\t\t[\r\n\t\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy,\r\n\t\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy_G,\r\n\t\t\t\t].includes(e.cardId as CardIds),\r\n\t\t\t)\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\te.abiityChargesLeft--;\r\n\t\t\t});\r\n\t}\r\n\r\n\tfor (const trinket of attackingBoardHero.trinkets) {\r\n\t\tswitch (trinket.cardId) {\r\n\t\t\tcase CardIds.CeremonialSword_BG30_MagicItem_925:\r\n\t\t\t\tmodifyStats(attacker, trinket, 4, 0, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\treturn { damageDoneByAttacker, damageDoneByDefender };\r\n};\r\n\r\nexport interface OnAttackInput {\r\n\tattacker: BoardEntity;\r\n\tattackingHero: BgsPlayerEntity;\r\n\tattackingBoard: BoardEntity[];\r\n\tdefendingEntity: BoardEntity;\r\n\tdefendingHero: BgsPlayerEntity;\r\n\tdefendingBoard: BoardEntity[];\r\n\tgameState: FullGameState;\r\n\tplayerIsFriendly: boolean;\r\n}\r\n"]}
1
+ {"version":3,"file":"on-attack.js","sourceRoot":"","sources":["../../src/simulation/on-attack.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAG7D,4DAAsF;AACtF,iEAA4D;AAC5D,+CAAkD;AAElD,6CAA+C;AAC/C,oCAA8D;AAC9D,qCAA6D;AAC7D,mDAAiD;AACjD,iDAAiD;AAEjD,mCAAsC;AAG/B,MAAM,oBAAoB,GAAG,CACnC,QAAqB,EACrB,cAA6B,EAC7B,kBAAmC,EACnC,eAA4B,EAC5B,cAA6B,EAC7B,kBAAmC,EACnC,SAAwB,EACyC,EAAE;;IACnE,IAAI,oBAAoB,GAAG,CAAC,CAAC;IAC7B,IAAI,oBAAoB,GAAG,CAAC,CAAC;IAE7B,KAAK,MAAM,OAAO,IAAI,MAAA,kBAAkB,CAAC,QAAQ,mCAAI,EAAE,EAAE;QACxD,MAAM,YAAY,GAAG,6BAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAClD,IAAI,IAAA,kDAAiC,EAAC,YAAY,CAAC,EAAE;YACpD,MAAM,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,GAAG,YAAY,CAAC,8BAA8B,CAAC,OAAO,EAAE;gBACrG,QAAQ,EAAE,QAAQ;gBAClB,aAAa,EAAE,kBAAkB;gBACjC,cAAc,EAAE,cAAc;gBAC9B,eAAe,EAAE,eAAe;gBAChC,aAAa,EAAE,kBAAkB;gBACjC,cAAc,EAA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ayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { hasOnWheneverAnotherMinionAttacks, hasRally } from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { updateReborn } from '../keywords/reborn';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { pickRandom } from '../services/utils';\r\nimport { hasCorrectTribe, hasEntityMechanic } from '../utils';\r\nimport { dealDamageToMinion, getNeighbours } from './attack';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport { fixEnchantments } from './enchantments';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { modifyStats } from './stats';\r\n\r\n// Whenever it attacks\r\nexport const applyOnAttackEffects = (\r\n\tattacker: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingEntity: BoardEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): { damageDoneByAttacker: number; damageDoneByDefender: number } => {\r\n\tlet damageDoneByAttacker = 0;\r\n\tlet damageDoneByDefender = 0;\r\n\r\n\tfor (const trinket of attackingBoardHero.trinkets ?? []) {\r\n\t\tconst onAttackImpl = cardMappings[trinket.cardId];\r\n\t\tif (hasOnWheneverAnotherMinionAttacks(onAttackImpl)) {\r\n\t\t\tconst { dmgDoneByAttacker, dmgDoneByDefender } = onAttackImpl.onWheneverAnotherMinionAttacks(trinket, {\r\n\t\t\t\tattacker: attacker,\r\n\t\t\t\tattackingHero: attackingBoardHero,\r\n\t\t\t\tattackingBoard: attackingBoard,\r\n\t\t\t\tdefendingEntity: defendingEntity,\r\n\t\t\t\tdefendingHero: defendingBoardHero,\r\n\t\t\t\tdefendingBoard: defendingBoard,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerIsFriendly: attackingBoardHero.friendly,\r\n\t\t\t});\r\n\t\t\tdamageDoneByAttacker += dmgDoneByAttacker;\r\n\t\t\tdamageDoneByDefender += dmgDoneByDefender;\r\n\t\t}\r\n\t}\r\n\r\n\t// \"Whenever friendly minion attacks\" triggers before the rally itself?\r\n\t// https://replays.firestoneapp.com/?reviewId=04e6a624-ccd5-4068-9420-884843f3685f&turn=25&action=1\r\n\tconst attackingBoardOtherEntities = attackingBoard.filter((e) => e !== attacker);\r\n\tfor (const boardEntity of attackingBoardOtherEntities) {\r\n\t\tconst onAttackImpl = cardMappings[boardEntity.cardId];\r\n\t\tif (hasOnWheneverAnotherMinionAttacks(onAttackImpl)) {\r\n\t\t\tconst { dmgDoneByAttacker, dmgDoneByDefender } = onAttackImpl.onWheneverAnotherMinionAttacks(boardEntity, {\r\n\t\t\t\tattacker: attacker,\r\n\t\t\t\tattackingHero: attackingBoardHero,\r\n\t\t\t\tattackingBoard: attackingBoard,\r\n\t\t\t\tdefendingEntity: defendingEntity,\r\n\t\t\t\tdefendingHero: defendingBoardHero,\r\n\t\t\t\tdefendingBoard: defendingBoard,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerIsFriendly: attackingBoardHero.friendly,\r\n\t\t\t});\r\n\t\t\tdamageDoneByAttacker += dmgDoneByAttacker;\r\n\t\t\tdamageDoneByDefender += dmgDoneByDefender;\r\n\t\t}\r\n\t\tconst enchantments = boardEntity.enchantments;\r\n\t\tfor (const enchantment of enchantments) {\r\n\t\t\tconst onAttackImpl = cardMappings[enchantment.cardId];\r\n\t\t\tif (hasOnWheneverAnotherMinionAttacks(onAttackImpl)) {\r\n\t\t\t\tconst { dmgDoneByAttacker, dmgDoneByDefender } = onAttackImpl.onWheneverAnotherMinionAttacks(\r\n\t\t\t\t\tenchantment,\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tattacker: attacker,\r\n\t\t\t\t\t\tattackingHero: attackingBoardHero,\r\n\t\t\t\t\t\tattackingBoard: attackingBoard,\r\n\t\t\t\t\t\tdefendingEntity: defendingEntity,\r\n\t\t\t\t\t\tdefendingHero: defendingBoardHero,\r\n\t\t\t\t\t\tdefendingBoard: defendingBoard,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\tplayerIsFriendly: attackingBoardHero.friendly,\r\n\t\t\t\t\t},\r\n\t\t\t\t);\r\n\t\t\t\tdamageDoneByAttacker += dmgDoneByAttacker;\r\n\t\t\t\tdamageDoneByDefender += dmgDoneByDefender;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// This assumes that only \"Rally\" effects trigger on attack\r\n\t// 2025-08-20: this is false. \"Whenever a friendly minion attacks\" is not a rally effect\r\n\tconst isAttackerRallying = hasEntityMechanic(attacker, GameTag.BACON_RALLY, gameState.allCards);\r\n\tconst numberOfRallyingCries =\r\n\t\tattackingBoardHero.questRewardEntities?.filter((r) => r.cardId === CardIds.RallyingCry_BG33_Reward_021)\r\n\t\t\t.length ?? 0;\r\n\tconst rallyLoops = 1 + (isAttackerRallying ? numberOfRallyingCries : 0);\r\n\tfor (let i = 0; i < rallyLoops; i++) {\r\n\t\tconst onAttackImpl = cardMappings[attacker.cardId];\r\n\t\tif (hasRally(onAttackImpl)) {\r\n\t\t\tconst { dmgDoneByAttacker, dmgDoneByDefender } = onAttackImpl.rally(attacker, {\r\n\t\t\t\tattacker: attacker,\r\n\t\t\t\tattackingHero: attackingBoardHero,\r\n\t\t\t\tattackingBoard: attackingBoard,\r\n\t\t\t\tdefendingEntity: defendingEntity,\r\n\t\t\t\tdefendingHero: defendingBoardHero,\r\n\t\t\t\tdefendingBoard: defendingBoard,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerIsFriendly: attackingBoardHero.friendly,\r\n\t\t\t});\r\n\t\t\tdamageDoneByAttacker += dmgDoneByAttacker;\r\n\t\t\tdamageDoneByDefender += dmgDoneByDefender;\r\n\t\t}\r\n\t\tconst enchantments = attacker.enchantments;\r\n\t\tfor (const enchantment of enchantments) {\r\n\t\t\tconst onAttackImpl = cardMappings[enchantment.cardId];\r\n\t\t\tif (hasRally(onAttackImpl)) {\r\n\t\t\t\tlet enchantmentToMinion: BoardEntity = {\r\n\t\t\t\t\t...enchantment,\r\n\t\t\t\t\tentityId: attacker.entityId,\r\n\t\t\t\t\tattack: attacker.attack,\r\n\t\t\t\t\thealth: attacker.health,\r\n\t\t\t\t\tmaxHealth: attacker.maxHealth,\r\n\t\t\t\t\tmaxAttack: attacker.maxAttack,\r\n\t\t\t\t\tabiityChargesLeft: attacker.abiityChargesLeft,\r\n\t\t\t\t};\r\n\t\t\t\tenchantmentToMinion = fixEnchantments(enchantmentToMinion, gameState.allCards);\r\n\t\t\t\tconst { dmgDoneByAttacker, dmgDoneByDefender } = onAttackImpl.rally(enchantmentToMinion, {\r\n\t\t\t\t\tattacker: attacker,\r\n\t\t\t\t\tattackingHero: attackingBoardHero,\r\n\t\t\t\t\tattackingBoard: attackingBoard,\r\n\t\t\t\t\tdefendingEntity: defendingEntity,\r\n\t\t\t\t\tdefendingHero: defendingBoardHero,\r\n\t\t\t\t\tdefendingBoard: defendingBoard,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tplayerIsFriendly: attackingBoardHero.friendly,\r\n\t\t\t\t});\r\n\t\t\t\tdamageDoneByAttacker += dmgDoneByAttacker;\r\n\t\t\t\tdamageDoneByDefender += dmgDoneByDefender;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Damage happens before the entity is buffed, e.g. before an attack buff from Roaring Rallier\r\n\tif (\r\n\t\tattacker.cardId === CardIds.ObsidianRavager_BG27_017 ||\r\n\t\tattacker.cardId === CardIds.ObsidianRavager_BG27_017_G\r\n\t) {\r\n\t\tconst neighbours = getNeighbours(defendingBoard, defendingEntity);\r\n\t\tconst targets = attacker.cardId === CardIds.ObsidianRavager_BG27_017_G ? neighbours : [pickRandom(neighbours)];\r\n\t\t[defendingEntity, ...targets].forEach((target) => {\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tattacker,\r\n\t\t\t\ttarget,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t);\r\n\t\t\t// damageDoneByAttacker +=\r\n\t\t\tdealDamageToMinion(\r\n\t\t\t\ttarget,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tattacker,\r\n\t\t\t\tattacker.attack,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\r\n\t// Roaring Rallier\r\n\tif (hasCorrectTribe(attacker, attackingBoardHero, Race.DRAGON, gameState.anomalies, gameState.allCards)) {\r\n\t\tattackingBoard\r\n\t\t\t.filter(\r\n\t\t\t\t(e) => e.cardId === CardIds.RoaringRallier_BG29_816 || e.cardId === CardIds.RoaringRallier_BG29_816_G,\r\n\t\t\t)\r\n\t\t\t.forEach((rallier) => {\r\n\t\t\t\tif (rallier !== attacker) {\r\n\t\t\t\t\tconst stats = rallier.cardId === CardIds.RoaringRallier_BG29_816_G ? 2 : 1;\r\n\t\t\t\t\tmodifyStats(attacker, rallier, 3 * stats, 1 * stats, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t}\r\n\r\n\t// if (attacker.cardId === CardIds.GlyphGuardian_BGS_045) {\r\n\t// \t// For now the utility method only works additively, so we hack around it\r\n\t// \tmodifyStats(\r\n\t// \t\tattacker,\r\n\t// \t\tnull,\r\n\t// \t\t2 * attacker.attack - attacker.attack,\r\n\t// \t\t0,\r\n\t// \t\tattackingBoard,\r\n\t// \t\tattackingBoardHero,\r\n\t// \t\tgameState,\r\n\t// \t);\r\n\t// } else if (attacker.cardId === CardIds.GlyphGuardian_TB_BaconUps_115) {\r\n\t// \tmodifyStats(\r\n\t// \t\tattacker,\r\n\t// \t\tnull,\r\n\t// \t\t3 * attacker.attack - attacker.attack,\r\n\t// \t\t0,\r\n\t// \t\tattackingBoard,\r\n\t// \t\tattackingBoardHero,\r\n\t// \t\tgameState,\r\n\t// \t);\r\n\t// } else\r\n\tif (attacker.cardId === CardIds.GlimGuardian_BG29_888 || attacker.cardId === CardIds.GlimGuardian_BG29_888_G) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.GlimGuardian_BG29_888_G ? 2 : 1;\r\n\t\tmodifyStats(attacker, attacker, 2 * multiplier, 0, attackingBoard, attackingBoardHero, gameState);\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708 ||\r\n\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708_G\r\n\t) {\r\n\t\tattackingBoard\r\n\t\t\t.filter((e) => hasCorrectTribe(e, attackingBoardHero, Race.PIRATE, gameState.anomalies, gameState.allCards))\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\tmodifyStats(\r\n\t\t\t\t\te,\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708_G ? 4 : 2,\r\n\t\t\t\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708_G ? 4 : 2,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.WhirlingLassOMatic_BG28_635 ||\r\n\t\tattacker.cardId === CardIds.WhirlingLassOMatic_BG28_635_G\r\n\t) {\r\n\t\tconst numberOfCardsToAdd = attacker.cardId === CardIds.WhirlingLassOMatic_BG28_635_G ? 2 : 1;\r\n\t\tconst cardsToAdd = Array.from({ length: numberOfCardsToAdd }).map(() => null);\r\n\t\taddCardsInHand(attackingBoardHero, attackingBoard, cardsToAdd, gameState);\r\n\t} else if (attacker.cardId === CardIds.Rampager_BG29_809 || attacker.cardId === CardIds.Rampager_BG29_809_G) {\r\n\t\tconst loops = attacker.cardId === CardIds.Rampager_BG29_809_G ? 2 : 1;\r\n\t\tfor (let i = 0; i < loops; i++) {\r\n\t\t\t// Don't include new spawns\r\n\t\t\tfor (const entity of [...attackingBoard]) {\r\n\t\t\t\tif (entity.entityId === attacker.entityId) {\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\t\t\t\tconst isSameSide = entity.friendly === attacker.friendly;\r\n\t\t\t\tconst board = isSameSide ? attackingBoard : defendingBoard;\r\n\t\t\t\tconst hero = isSameSide ? attackingBoardHero : defendingBoardHero;\r\n\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tboard,\r\n\t\t\t\t\thero,\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tisSameSide ? defendingBoard : attackingBoard,\r\n\t\t\t\t\tisSameSide ? defendingBoardHero : attackingBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (attacker.cardId === CardIds.HatefulHag_BG29_120 || attacker.cardId === CardIds.HatefulHag_BG29_120_G) {\r\n\t\tconst loops = attacker.cardId === CardIds.HatefulHag_BG29_120_G ? 2 : 1;\r\n\t\tconst attackerIndex = attackingBoard.indexOf(attacker);\r\n\t\tfor (let i = 1; i <= loops; i++) {\r\n\t\t\tconst target = attackingBoard[attackerIndex + i];\r\n\t\t\tif (!!target) {\r\n\t\t\t\tupdateReborn(target, true, attackingBoard, attackingBoardHero, defendingBoardHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tconst eclipsion = attackingBoard.find(\r\n\t\t(e) =>\r\n\t\t\t[\r\n\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy,\r\n\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy_G,\r\n\t\t\t].includes(e.cardId as CardIds) && e.abiityChargesLeft > 0,\r\n\t);\r\n\t// Only once per minion\r\n\tif (!!eclipsion && attacker.immuneWhenAttackCharges == null) {\r\n\t\tattacker.immuneWhenAttackCharges = 1;\r\n\t\t// If we have 2 eclipsions, the first minion that attacks eats both charges\r\n\t\tattackingBoard\r\n\t\t\t.filter((e) =>\r\n\t\t\t\t[\r\n\t\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy,\r\n\t\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy_G,\r\n\t\t\t\t].includes(e.cardId as CardIds),\r\n\t\t\t)\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\te.abiityChargesLeft--;\r\n\t\t\t});\r\n\t}\r\n\r\n\tfor (const trinket of attackingBoardHero.trinkets) {\r\n\t\tswitch (trinket.cardId) {\r\n\t\t\tcase CardIds.CeremonialSword_BG30_MagicItem_925:\r\n\t\t\t\tmodifyStats(attacker, trinket, 4, 0, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\treturn { damageDoneByAttacker, damageDoneByDefender };\r\n};\r\n\r\nexport interface OnAttackInput {\r\n\tattacker: BoardEntity;\r\n\tattackingHero: BgsPlayerEntity;\r\n\tattackingBoard: BoardEntity[];\r\n\tdefendingEntity: BoardEntity;\r\n\tdefendingHero: BgsPlayerEntity;\r\n\tdefendingBoard: BoardEntity[];\r\n\tgameState: FullGameState;\r\n\tplayerIsFriendly: boolean;\r\n}\r\n"]}
@@ -75,8 +75,8 @@ const applyOnBeingAttackedBuffs = (attackerEntity, attackerBoard, attackerHero,
75
75
  .filter((e) => e.cardId === "TB_BaconShop_HERO_95_Buddy" ||
76
76
  e.cardId === "TB_BaconShop_HERO_95_Buddy_G")
77
77
  .forEach((entity) => {
78
- const buff = entity.cardId === "TB_BaconShop_HERO_95_Buddy" ? 1 : 2;
79
- (0, utils_1.addStatsToBoard)(entity, defendingBoard, defendingPlayerEntity, buff, 0, gameState);
78
+ const mult = entity.cardId === "TB_BaconShop_HERO_95_Buddy" ? 1 : 2;
79
+ (0, utils_1.addStatsToBoard)(entity, defendingBoard, defendingPlayerEntity, 1 * mult, 1 * mult, gameState);
80
80
  });
81
81
  }
82
82
  if (defendingEntity.cardId === "BG24_300" ||
@@ -1 +1 @@
1
- {"version":3,"file":"on-being-attacked.js","sourceRoot":"","sources":["../../src/simulation/on-being-attacked.ts"],"names":[],"mappings":";;;AAEA,4DAA8D;AAC9D,iEAA4D;AAC5D,6DAA+D;AAC/D,+CAAkD;AAClD,mDAAsD;AAEtD,oCAA2C;AAE3C,uCAA4G;AAC5G,mCAAsC;AAE/B,MAAM,yBAAyB,GAAG,CACxC,cAA2B,EAC3B,aAA4B,EAC5B,YAA6B,EAC7B,eAA4B,EAC5B,cAA6B,EAC7B,qBAAsC,EACtC,SAAwB,EACjB,EAAE;;IAET,KAAK,MAAM,MAAM,IAAI,CAAC,MAAA,qBAAqB,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE;QACvF,QAAQ,MAAM,CAAC,MAAM,EAAE;YACtB,2BAAmD;YACnD;gBACC,IAAI,CAAC,eAAe,CAAC,YAAY,EAAE;oBAClC,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC;oBACxB,IAAA,kCAAkB,EACjB,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,IAAI,EACJ,SAAS,CACT,CAAC;oBACF,IAAI,MAAM,CAAC,MAAM,2BAA2E,EAAE;wBAC7F,eAAe,CAAC,kBAAkB,GAAG,IAAI,CAAC;qBAC1C;iBACD;gBACD,MAAM;YACP;gBACC,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;oBAC9B,MAAM,CAAC,SAAS,GA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B,eAAe,CAAC,MAAM,GAAG,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC;SAC7D;aAAM,IAAI,cAAc,CAAC,QAAQ,IAAI,cAAc,CAAC,SAAS,EAAE;SAE/D;aAAM,IAAI,cAAc,GAAG,UAAU,EAAE;YACvC,eAAe,CAAC,MAAM,GAAG,cAAc,GAAG,CAAC,CAAC;YAC5C,eAAe,CAAC,MAAM,GAAG,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC;SAC7D;KAQD;SAAM,IACN,0BAAwE,CAAC,QAAQ,CAChF,eAAe,CAAC,MAAiB,CACjC,EACA;QACD,IAAA,yBAAc,EAAC,eAAe,EAAE,IAAI,EAAE,cAAc,EAAE,qBAAqB,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;KACtG;AACF,CAAC,CAAC;AA3LW,QAAA,yBAAyB,6BA2LpC","sourcesContent":["import { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { hasOnMinionAttacked } from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { updateDivineShield } from '../keywords/divine-shield';\r\nimport { updateReborn } from '../keywords/reborn';\r\nimport { updateVenomous } from '../keywords/venomous';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { addStatsToBoard } from '../utils';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { handlePackTactics, handleSnakeTrap, handleSplittingImage, handleVenomstrikeTrap } from './secrets';\r\nimport { modifyStats } from './stats';\r\n\r\nexport const applyOnBeingAttackedBuffs = (\r\n\tattackerEntity: BoardEntity,\r\n\tattackerBoard: BoardEntity[],\r\n\tattackerHero: BgsPlayerEntity,\r\n\tdefendingEntity: BoardEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingPlayerEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// We need to respect the order of the secrets\r\n\tfor (const secret of (defendingPlayerEntity.secrets ?? []).filter((s) => !s.triggered)) {\r\n\t\tswitch (secret.cardId) {\r\n\t\t\tcase CardIds.AutodefenseMatrix_TB_Bacon_Secrets_07:\r\n\t\t\tcase CardIds.AutodefenseMatrix_BetterAutodefenseMatrix_TB_Bacon_Secrets_07b:\r\n\t\t\t\tif (!defendingEntity.divineShield) {\r\n\t\t\t\t\tsecret.triggered = true;\r\n\t\t\t\t\tupdateDivineShield(\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t\t\t\tattackerHero,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (secret.cardId === CardIds.AutodefenseMatrix_BetterAutodefenseMatrix_TB_Bacon_Secrets_07b) {\r\n\t\t\t\t\t\tdefendingEntity.strongDivineShield = true;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SplittingImage_TB_Bacon_Secrets_04:\r\n\t\t\t\tif (defendingBoard.length < 7) {\r\n\t\t\t\t\tsecret.triggered = true;\r\n\t\t\t\t\thandleSplittingImage(\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t\t\t\tattackerBoard,\r\n\t\t\t\t\t\tattackerHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.PackTactics_TB_Bacon_Secrets_15:\r\n\t\t\tcase CardIds.PackTactics_BetterPackTactics_TB_Bacon_Secrets_15b:\r\n\t\t\t\tif (defendingBoard.length < 7) {\r\n\t\t\t\t\tsecret.triggered = true;\r\n\t\t\t\t\thandlePackTactics(\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t\t\t\tattackerBoard,\r\n\t\t\t\t\t\tattackerHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\tsecret.cardId,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SnakeTrap_TB_Bacon_Secrets_02:\r\n\t\t\t\tif (defendingBoard.length < 7) {\r\n\t\t\t\t\tsecret.triggered = true;\r\n\t\t\t\t\thandleSnakeTrap(\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t\t\t\tattackerBoard,\r\n\t\t\t\t\t\tattackerHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.VenomstrikeTrap_TB_Bacon_Secrets_01:\r\n\t\t\tcase CardIds.VenomstrikeTrap_BetterVenomstrikeTrap_TB_Bacon_Secrets_01b:\r\n\t\t\t\tif (defendingBoard.length < 7) {\r\n\t\t\t\t\tsecret.triggered = true;\r\n\t\t\t\t\tconst spawns = handleVenomstrikeTrap(\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t\t\t\tattackerBoard,\r\n\t\t\t\t\t\tattackerHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (secret.cardId === CardIds.VenomstrikeTrap_BetterVenomstrikeTrap_TB_Bacon_Secrets_01b) {\r\n\t\t\t\t\t\tfor (const spawn of spawns) {\r\n\t\t\t\t\t\t\tupdateReborn(spawn, true, defendingBoard, defendingPlayerEntity, attackerHero, gameState);\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\tfor (const entity of defendingBoard) {\r\n\t\tconst onBeingAttackedImpl = cardMappings[entity.cardId];\r\n\t\tif (hasOnMinionAttacked(onBeingAttackedImpl)) {\r\n\t\t\tonBeingAttackedImpl.onAttacked(entity, {\r\n\t\t\t\tdefendingEntity: defendingEntity,\r\n\t\t\t\tattacker: attackerEntity,\r\n\t\t\t\tattackingHero: attackerHero,\r\n\t\t\t\tattackingBoard: attackerBoard,\r\n\t\t\t\tdefendingHero: defendingPlayerEntity,\r\n\t\t\t\tdefendingBoard: defendingBoard,\r\n\t\t\t\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tif (defendingEntity.taunt) {\r\n\t\t// const champions = defendingBoard.filter((entity) => entity.cardId === CardIds.ChampionOfYshaarj_BGS_111);\r\n\t\t// const goldenChampions = defendingBoard.filter(\r\n\t\t// \t(entity) => entity.cardId === CardIds.ChampionOfYshaarj_TB_BaconUps_301,\r\n\t\t// );\r\n\t\t// champions.forEach((entity) => {\r\n\t\t// \tmodifyStats(entity, entity, 1, 2, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t// });\r\n\t\t// goldenChampions.forEach((entity) => {\r\n\t\t// \tmodifyStats(entity, entity, 2, 4, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t// });\r\n\r\n\t\tdefendingBoard\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId === CardIds.WanderingTreant_TB_BaconShop_HERO_95_Buddy ||\r\n\t\t\t\t\te.cardId === CardIds.WanderingTreant_TB_BaconShop_HERO_95_Buddy_G,\r\n\t\t\t)\r\n\t\t\t.forEach((entity) => {\r\n\t\t\t\tconst buff = entity.cardId === CardIds.WanderingTreant_TB_BaconShop_HERO_95_Buddy ? 1 : 2;\r\n\t\t\t\taddStatsToBoard(entity, defendingBoard, defendingPlayerEntity, buff, 0, gameState);\r\n\t\t\t});\r\n\t}\r\n\r\n\t// Based on defending entity\r\n\t// if (defendingEntity.cardId === CardIds.TormentedRitualist_BGS_201) {\r\n\t// \tconst neighbours = getNeighbours(defendingBoard, defendingEntity);\r\n\t// \tneighbours.forEach((entity) => {\r\n\t// \t\tmodifyStats(entity, defendingEntity, 1, 1, defendingBoard, defendingPlayerEntity, gameState);\r\n\t// \t});\r\n\t// } else if (defendingEntity.cardId === CardIds.TormentedRitualist_TB_BaconUps_257) {\r\n\t// \tconst neighbours = getNeighbours(defendingBoard, defendingEntity);\r\n\t// \tneighbours.forEach((entity) => {\r\n\t// \t\tmodifyStats(entity, defendingEntity, 2, 2, defendingBoard, defendingPlayerEntity, gameState);\r\n\t// \t});\r\n\t// } else\r\n\tif (\r\n\t\tdefendingEntity.cardId === CardIds.DozyWhelp_BG24_300 ||\r\n\t\tdefendingEntity.cardId === CardIds.DozyWhelp_BG24_300_G\r\n\t) {\r\n\t\tmodifyStats(\r\n\t\t\tdefendingEntity,\r\n\t\t\tdefendingEntity,\r\n\t\t\tdefendingEntity.cardId === CardIds.DozyWhelp_BG24_300_G ? 2 : 1,\r\n\t\t\t0,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingPlayerEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t} else if (\r\n\t\t[CardIds.AdaptableBarricade_BG27_022, CardIds.AdaptableBarricade_BG27_022_G].includes(\r\n\t\t\tdefendingEntity.cardId as CardIds,\r\n\t\t)\r\n\t) {\r\n\t\t// https://twitter.com/LoewenMitchell/status/1692225556559901031?s=20\r\n\t\tconst totalStats = defendingEntity.attack + defendingEntity.health;\r\n\t\tconst attackerAttack = attackerEntity.attack;\r\n\t\tif (defendingEntity.divineShield) {\r\n\t\t\tdefendingEntity.health = 1;\r\n\t\t\tdefendingEntity.attack = totalStats - defendingEntity.health;\r\n\t\t} else if (attackerEntity.venomous || attackerEntity.poisonous) {\r\n\t\t\t// Do nothing\r\n\t\t} else if (attackerAttack < totalStats) {\r\n\t\t\tdefendingEntity.health = attackerAttack + 1;\r\n\t\t\tdefendingEntity.attack = totalStats - defendingEntity.health;\r\n\t\t}\r\n\t\t// } else if (\r\n\t\t// \t[CardIds.GraniteGuardian_BG24_001, CardIds.GraniteGuardian_BG24_001_G].includes(\r\n\t\t// \t\tdefendingEntity.cardId as CardIds,\r\n\t\t// \t)\r\n\t\t// ) {\r\n\t\t// \tsetEntityStats(attackerEntity, attackerEntity.attack, 1, attackerBoard, attackerHero, gameState);\r\n\t\t// \t// attackerEntity.health = 1;\r\n\t} else if (\r\n\t\t[CardIds.WaywardGrimscale_BG28_406, CardIds.WaywardGrimscale_BG28_406_G].includes(\r\n\t\t\tdefendingEntity.cardId as CardIds,\r\n\t\t)\r\n\t) {\r\n\t\tupdateVenomous(defendingEntity, true, defendingBoard, defendingPlayerEntity, attackerHero, gameState);\r\n\t}\r\n};\r\n\r\nexport interface OnMinionAttackedInput {\r\n\tattacker: BoardEntity;\r\n\tattackingHero: BgsPlayerEntity;\r\n\tattackingBoard: BoardEntity[];\r\n\tdefendingEntity: BoardEntity;\r\n\tdefendingHero: BgsPlayerEntity;\r\n\tdefendingBoard: BoardEntity[];\r\n\tgameState: FullGameState;\r\n}\r\n"]}
1
+ {"version":3,"file":"on-being-attacked.js","sourceRoot":"","sources":["../../src/simulation/on-being-attacked.ts"],"names":[],"mappings":";;;AAEA,4DAA8D;AAC9D,iEAA4D;AAC5D,6DAA+D;AAC/D,+CAAkD;AAClD,mDAAsD;AAEtD,oCAA2C;AAE3C,uCAA4G;AAC5G,mCAAsC;AAE/B,MAAM,yBAAyB,GAAG,CACxC,cAA2B,EAC3B,aAA4B,EAC5B,YAA6B,EAC7B,eAA4B,EAC5B,cAA6B,EAC7B,qBAAsC,EACtC,SAAwB,EACjB,EAAE;;IAET,KAAK,MAAM,MAAM,IAAI,CAAC,MAAA,qBAAqB,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE;QACvF,QAAQ,MAAM,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D,IAAA,mBAAW,EACV,eAAe,EACf,eAAe,EACf,eAAe,CAAC,MAAM,iBAAiC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC/D,CAAC,EACD,cAAc,EACd,qBAAqB,EACrB,SAAS,CACT,CAAC;KACF;SAAM,IACN,0BAA4E,CAAC,QAAQ,CACpF,eAAe,CAAC,MAAiB,CACjC,EACA;QAED,MAAM,UAAU,GAAG,eAAe,CAAC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC;QACnE,MAAM,cAAc,GAAG,cAAc,CAAC,MAAM,CAAC;QAC7C,IAAI,eAAe,CAAC,YAAY,EAAE;YACjC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC;YAC3B,eAAe,CAAC,MAAM,GAAG,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC;SAC7D;aAAM,IAAI,cAAc,CAAC,QAAQ,IAAI,cAAc,CAAC,SAAS,EAAE;SAE/D;aAAM,IAAI,cAAc,GAAG,UAAU,EAAE;YACvC,eAAe,CAAC,MAAM,GAAG,cAAc,GAAG,CAAC,CAAC;YAC5C,eAAe,CAAC,MAAM,GAAG,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC;SAC7D;KAQD;SAAM,IACN,0BAAwE,CAAC,QAAQ,CAChF,eAAe,CAAC,MAAiB,CACjC,EACA;QACD,IAAA,yBAAc,EAAC,eAAe,EAAE,IAAI,EAAE,cAAc,EAAE,qBAAqB,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;KACtG;AACF,CAAC,CAAC;AA3LW,QAAA,yBAAyB,6BA2LpC","sourcesContent":["import { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { hasOnMinionAttacked } from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { updateDivineShield } from '../keywords/divine-shield';\r\nimport { updateReborn } from '../keywords/reborn';\r\nimport { updateVenomous } from '../keywords/venomous';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { addStatsToBoard } from '../utils';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { handlePackTactics, handleSnakeTrap, handleSplittingImage, handleVenomstrikeTrap } from './secrets';\r\nimport { modifyStats } from './stats';\r\n\r\nexport const applyOnBeingAttackedBuffs = (\r\n\tattackerEntity: BoardEntity,\r\n\tattackerBoard: BoardEntity[],\r\n\tattackerHero: BgsPlayerEntity,\r\n\tdefendingEntity: BoardEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingPlayerEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// We need to respect the order of the secrets\r\n\tfor (const secret of (defendingPlayerEntity.secrets ?? []).filter((s) => !s.triggered)) {\r\n\t\tswitch (secret.cardId) {\r\n\t\t\tcase CardIds.AutodefenseMatrix_TB_Bacon_Secrets_07:\r\n\t\t\tcase CardIds.AutodefenseMatrix_BetterAutodefenseMatrix_TB_Bacon_Secrets_07b:\r\n\t\t\t\tif (!defendingEntity.divineShield) {\r\n\t\t\t\t\tsecret.triggered = true;\r\n\t\t\t\t\tupdateDivineShield(\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t\t\t\tattackerHero,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (secret.cardId === CardIds.AutodefenseMatrix_BetterAutodefenseMatrix_TB_Bacon_Secrets_07b) {\r\n\t\t\t\t\t\tdefendingEntity.strongDivineShield = true;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SplittingImage_TB_Bacon_Secrets_04:\r\n\t\t\t\tif (defendingBoard.length < 7) {\r\n\t\t\t\t\tsecret.triggered = true;\r\n\t\t\t\t\thandleSplittingImage(\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t\t\t\tattackerBoard,\r\n\t\t\t\t\t\tattackerHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.PackTactics_TB_Bacon_Secrets_15:\r\n\t\t\tcase CardIds.PackTactics_BetterPackTactics_TB_Bacon_Secrets_15b:\r\n\t\t\t\tif (defendingBoard.length < 7) {\r\n\t\t\t\t\tsecret.triggered = true;\r\n\t\t\t\t\thandlePackTactics(\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t\t\t\tattackerBoard,\r\n\t\t\t\t\t\tattackerHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\tsecret.cardId,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SnakeTrap_TB_Bacon_Secrets_02:\r\n\t\t\t\tif (defendingBoard.length < 7) {\r\n\t\t\t\t\tsecret.triggered = true;\r\n\t\t\t\t\thandleSnakeTrap(\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t\t\t\tattackerBoard,\r\n\t\t\t\t\t\tattackerHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.VenomstrikeTrap_TB_Bacon_Secrets_01:\r\n\t\t\tcase CardIds.VenomstrikeTrap_BetterVenomstrikeTrap_TB_Bacon_Secrets_01b:\r\n\t\t\t\tif (defendingBoard.length < 7) {\r\n\t\t\t\t\tsecret.triggered = true;\r\n\t\t\t\t\tconst spawns = handleVenomstrikeTrap(\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t\t\t\tattackerBoard,\r\n\t\t\t\t\t\tattackerHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (secret.cardId === CardIds.VenomstrikeTrap_BetterVenomstrikeTrap_TB_Bacon_Secrets_01b) {\r\n\t\t\t\t\t\tfor (const spawn of spawns) {\r\n\t\t\t\t\t\t\tupdateReborn(spawn, true, defendingBoard, defendingPlayerEntity, attackerHero, gameState);\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\tfor (const entity of defendingBoard) {\r\n\t\tconst onBeingAttackedImpl = cardMappings[entity.cardId];\r\n\t\tif (hasOnMinionAttacked(onBeingAttackedImpl)) {\r\n\t\t\tonBeingAttackedImpl.onAttacked(entity, {\r\n\t\t\t\tdefendingEntity: defendingEntity,\r\n\t\t\t\tattacker: attackerEntity,\r\n\t\t\t\tattackingHero: attackerHero,\r\n\t\t\t\tattackingBoard: attackerBoard,\r\n\t\t\t\tdefendingHero: defendingPlayerEntity,\r\n\t\t\t\tdefendingBoard: defendingBoard,\r\n\t\t\t\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tif (defendingEntity.taunt) {\r\n\t\t// const champions = defendingBoard.filter((entity) => entity.cardId === CardIds.ChampionOfYshaarj_BGS_111);\r\n\t\t// const goldenChampions = defendingBoard.filter(\r\n\t\t// \t(entity) => entity.cardId === CardIds.ChampionOfYshaarj_TB_BaconUps_301,\r\n\t\t// );\r\n\t\t// champions.forEach((entity) => {\r\n\t\t// \tmodifyStats(entity, entity, 1, 2, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t// });\r\n\t\t// goldenChampions.forEach((entity) => {\r\n\t\t// \tmodifyStats(entity, entity, 2, 4, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t// });\r\n\r\n\t\tdefendingBoard\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId === CardIds.WanderingTreant_TB_BaconShop_HERO_95_Buddy ||\r\n\t\t\t\t\te.cardId === CardIds.WanderingTreant_TB_BaconShop_HERO_95_Buddy_G,\r\n\t\t\t)\r\n\t\t\t.forEach((entity) => {\r\n\t\t\t\tconst mult = entity.cardId === CardIds.WanderingTreant_TB_BaconShop_HERO_95_Buddy ? 1 : 2;\r\n\t\t\t\taddStatsToBoard(entity, defendingBoard, defendingPlayerEntity, 1 * mult, 1 * mult, gameState);\r\n\t\t\t});\r\n\t}\r\n\r\n\t// Based on defending entity\r\n\t// if (defendingEntity.cardId === CardIds.TormentedRitualist_BGS_201) {\r\n\t// \tconst neighbours = getNeighbours(defendingBoard, defendingEntity);\r\n\t// \tneighbours.forEach((entity) => {\r\n\t// \t\tmodifyStats(entity, defendingEntity, 1, 1, defendingBoard, defendingPlayerEntity, gameState);\r\n\t// \t});\r\n\t// } else if (defendingEntity.cardId === CardIds.TormentedRitualist_TB_BaconUps_257) {\r\n\t// \tconst neighbours = getNeighbours(defendingBoard, defendingEntity);\r\n\t// \tneighbours.forEach((entity) => {\r\n\t// \t\tmodifyStats(entity, defendingEntity, 2, 2, defendingBoard, defendingPlayerEntity, gameState);\r\n\t// \t});\r\n\t// } else\r\n\tif (\r\n\t\tdefendingEntity.cardId === CardIds.DozyWhelp_BG24_300 ||\r\n\t\tdefendingEntity.cardId === CardIds.DozyWhelp_BG24_300_G\r\n\t) {\r\n\t\tmodifyStats(\r\n\t\t\tdefendingEntity,\r\n\t\t\tdefendingEntity,\r\n\t\t\tdefendingEntity.cardId === CardIds.DozyWhelp_BG24_300_G ? 2 : 1,\r\n\t\t\t0,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingPlayerEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t} else if (\r\n\t\t[CardIds.AdaptableBarricade_BG27_022, CardIds.AdaptableBarricade_BG27_022_G].includes(\r\n\t\t\tdefendingEntity.cardId as CardIds,\r\n\t\t)\r\n\t) {\r\n\t\t// https://twitter.com/LoewenMitchell/status/1692225556559901031?s=20\r\n\t\tconst totalStats = defendingEntity.attack + defendingEntity.health;\r\n\t\tconst attackerAttack = attackerEntity.attack;\r\n\t\tif (defendingEntity.divineShield) {\r\n\t\t\tdefendingEntity.health = 1;\r\n\t\t\tdefendingEntity.attack = totalStats - defendingEntity.health;\r\n\t\t} else if (attackerEntity.venomous || attackerEntity.poisonous) {\r\n\t\t\t// Do nothing\r\n\t\t} else if (attackerAttack < totalStats) {\r\n\t\t\tdefendingEntity.health = attackerAttack + 1;\r\n\t\t\tdefendingEntity.attack = totalStats - defendingEntity.health;\r\n\t\t}\r\n\t\t// } else if (\r\n\t\t// \t[CardIds.GraniteGuardian_BG24_001, CardIds.GraniteGuardian_BG24_001_G].includes(\r\n\t\t// \t\tdefendingEntity.cardId as CardIds,\r\n\t\t// \t)\r\n\t\t// ) {\r\n\t\t// \tsetEntityStats(attackerEntity, attackerEntity.attack, 1, attackerBoard, attackerHero, gameState);\r\n\t\t// \t// attackerEntity.health = 1;\r\n\t} else if (\r\n\t\t[CardIds.WaywardGrimscale_BG28_406, CardIds.WaywardGrimscale_BG28_406_G].includes(\r\n\t\t\tdefendingEntity.cardId as CardIds,\r\n\t\t)\r\n\t) {\r\n\t\tupdateVenomous(defendingEntity, true, defendingBoard, defendingPlayerEntity, attackerHero, gameState);\r\n\t}\r\n};\r\n\r\nexport interface OnMinionAttackedInput {\r\n\tattacker: BoardEntity;\r\n\tattackingHero: BgsPlayerEntity;\r\n\tattackingBoard: BoardEntity[];\r\n\tdefendingEntity: BoardEntity;\r\n\tdefendingHero: BgsPlayerEntity;\r\n\tdefendingBoard: BoardEntity[];\r\n\tgameState: FullGameState;\r\n}\r\n"]}
@@ -22,7 +22,15 @@ const handleStartOfCombatAnomalies = (playerEntity, playerBoard, opponentEntity,
22
22
  gameState,
23
23
  playerIsFriendly: false,
24
24
  });
25
- (0, summon_when_space_1.handleSummonsWhenSpace)(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);
25
+ const shouldRecomputeCurrentAttacker = (0, summon_when_space_1.handleSummonsWhenSpace)(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);
26
+ if (shouldRecomputeCurrentAttacker) {
27
+ currentAttacker =
28
+ playerBoard.length > opponentBoard.length
29
+ ? 0
30
+ : opponentBoard.length > playerBoard.length
31
+ ? 1
32
+ : Math.round(Math.random());
33
+ }
26
34
  return currentAttacker;
27
35
  };
28
36
  exports.handleStartOfCombatAnomalies = handleStartOfCombatAnomalies;
@@ -1 +1 @@
1
- {"version":3,"file":"soc-anomalies.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-anomalies.ts"],"names":[],"mappings":";;;AAIA,4DAA8D;AAC9D,iEAAoE;AAG7D,MAAM,4BAA4B,GAAG,CAC3C,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IACX,eAAe,GAAG,qCAAqC,CAAC;QACvD,YAAY,EAAE,YAAY;QAC1B,WAAW,EAAE,WAAW;QACxB,cAAc,EAAE,cAAc;QAC9B,aAAa,EAAE,aAAa;QAC5B,eAAe;QACf,SAAS;QACT,gBAAgB,EAAE,IAAI;KACtB,CAAC,CAAC;IACH,eAAe,GAAG,qCAAqC,CAAC;QACvD,YAAY,EAAE,cAAc;QAC5B,WAAW,EAAE,aAAa;QAC1B,cAAc,EAAE,YAAY;QAC5B,aAAa,EAAE,WAAW;QAC1B,eAAe;QACf,SAAS;QACT,gBAAgB,EAAE,KAAK;KACvB,CAAC,CAAC;IACH,IAAA,0CAAsB,EAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;IAC5F,OAAO,eAAe,CAAC;AACxB,CAAC,CAAC;AA5BW,QAAA,4BAA4B,gCA4BvC;AAEF,MAAM,qCAAqC,GAAG,CAAC,KAAe,EAAU,EAAE;;IACzE,MAAM,KAAK,GAAG,CAAA,MAAA,KAAK,CAAC,YAAY,CAAC,QAAQ,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,yBAAoD,CAAC;QACnH,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,CAAC,CAAC;IACL,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;QAC/B,IAAI,CAAC,CAAA,MAAA,KAAK,CAAC,SAAS,CAAC,SAAS,0CAAE,MAAM,CAAA,IAAI,KAAK,CAAC,YAAY,CAAC,iBAAiB,EAAE;YAC/E,OAAO,KAAK,CAAC,eAAe,CAAC;SAC7B;QAED,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,SAAS,CAAC,SAAS,EAAE;YAChD,IAAA,iDAA0B,EAAC,OAAO,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;SACtE;KACD;IAED,OAAO,KAAK,CAAC,eAAe,CAAC;AAC9B,CAAC,CAAC","sourcesContent":["import { CardIds } from '../../services/card-ids';\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 handleStartOfCombatAnomalies = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tcurrentAttacker = handleStartOfCombatAnomaliesForPlayer({\r\n\t\tplayerEntity: playerEntity,\r\n\t\tplayerBoard: playerBoard,\r\n\t\topponentEntity: opponentEntity,\r\n\t\topponentBoard: opponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t\tplayerIsFriendly: true,\r\n\t});\r\n\tcurrentAttacker = handleStartOfCombatAnomaliesForPlayer({\r\n\t\tplayerEntity: opponentEntity,\r\n\t\tplayerBoard: opponentBoard,\r\n\t\topponentEntity: playerEntity,\r\n\t\topponentBoard: playerBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t\tplayerIsFriendly: false,\r\n\t});\r\n\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatAnomaliesForPlayer = (input: SoCInput): number => {\r\n\tconst loops = input.playerEntity.trinkets?.some((t) => t.cardId === CardIds.ValdrakkenWindChimes_BG32_MagicItem_365)\r\n\t\t? 2\r\n\t\t: 1;\r\n\tfor (let i = 0; i < loops; i++) {\r\n\t\tif (!input.gameState.anomalies?.length || input.playerEntity.startOfCombatDone) {\r\n\t\t\treturn input.currentAttacker;\r\n\t\t}\r\n\r\n\t\tfor (const anomaly of input.gameState.anomalies) {\r\n\t\t\tperformStartOfCombatAction(anomaly, input.playerEntity, input, false);\r\n\t\t}\r\n\t}\r\n\r\n\treturn input.currentAttacker;\r\n};\r\n"]}
1
+ {"version":3,"file":"soc-anomalies.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-anomalies.ts"],"names":[],"mappings":";;;AAIA,4DAA8D;AAC9D,iEAAoE;AAG7D,MAAM,4BAA4B,GAAG,CAC3C,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IACX,eAAe,GAAG,qCAAqC,CAAC;QACvD,YAAY,EAAE,YAAY;QAC1B,WAAW,EAAE,WAAW;QACxB,cAAc,EAAE,cAAc;QAC9B,aAAa,EAAE,aAAa;QAC5B,eA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AK,MAAM,OAAO,IAAI,KAAK,CAAC,SAAS,CAAC,SAAS,EAAE;YAChD,IAAA,iDAA0B,EAAC,OAAO,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;SACtE;KACD;IAED,OAAO,KAAK,CAAC,eAAe,CAAC;AAC9B,CAAC,CAAC","sourcesContent":["import { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { CardIds } from '../../services/card-ids';\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 handleStartOfCombatAnomalies = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tcurrentAttacker = handleStartOfCombatAnomaliesForPlayer({\r\n\t\tplayerEntity: playerEntity,\r\n\t\tplayerBoard: playerBoard,\r\n\t\topponentEntity: opponentEntity,\r\n\t\topponentBoard: opponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t\tplayerIsFriendly: true,\r\n\t});\r\n\tcurrentAttacker = handleStartOfCombatAnomaliesForPlayer({\r\n\t\tplayerEntity: opponentEntity,\r\n\t\tplayerBoard: opponentBoard,\r\n\t\topponentEntity: playerEntity,\r\n\t\topponentBoard: playerBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t\tplayerIsFriendly: false,\r\n\t});\r\n\tconst shouldRecomputeCurrentAttacker = handleSummonsWhenSpace(\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tgameState,\r\n\t);\r\n\tif (shouldRecomputeCurrentAttacker) {\r\n\t\tcurrentAttacker =\r\n\t\t\tplayerBoard.length > opponentBoard.length\r\n\t\t\t\t? 0\r\n\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t? 1\r\n\t\t\t\t: Math.round(Math.random());\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatAnomaliesForPlayer = (input: SoCInput): number => {\r\n\tconst loops = input.playerEntity.trinkets?.some((t) => t.cardId === CardIds.ValdrakkenWindChimes_BG32_MagicItem_365)\r\n\t\t? 2\r\n\t\t: 1;\r\n\tfor (let i = 0; i < loops; i++) {\r\n\t\tif (!input.gameState.anomalies?.length || input.playerEntity.startOfCombatDone) {\r\n\t\t\treturn input.currentAttacker;\r\n\t\t}\r\n\r\n\t\tfor (const anomaly of input.gameState.anomalies) {\r\n\t\t\tperformStartOfCombatAction(anomaly, input.playerEntity, input, false);\r\n\t\t}\r\n\t}\r\n\r\n\treturn input.currentAttacker;\r\n};\r\n"]}
@@ -14,7 +14,15 @@ const handleIllidanHeroPowers = (playerEntity, playerBoard, opponentEntity, oppo
14
14
  currentAttacker = handlePlayerIllidanHeroPowers(playerEntity, playerBoard, opponentEntity, opponentBoard, currentAttacker, true, gameState);
15
15
  }
16
16
  (0, attack_1.processMinionDeath)(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);
17
- (0, summon_when_space_1.handleSummonsWhenSpace)(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);
17
+ const shouldRecomputeCurrentAttacker = (0, summon_when_space_1.handleSummonsWhenSpace)(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);
18
+ if (shouldRecomputeCurrentAttacker) {
19
+ currentAttacker =
20
+ playerBoard.length > opponentBoard.length
21
+ ? 0
22
+ : opponentBoard.length > playerBoard.length
23
+ ? 1
24
+ : Math.round(Math.random());
25
+ }
18
26
  return currentAttacker;
19
27
  };
20
28
  exports.handleIllidanHeroPowers = handleIllidanHeroPowers;
@@ -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;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,uBAAuB,2BAqDlC;AAEF,MAAM,6BAA6B,GAAG,CACrC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,QAAiB,EACjB,SAAwB,EACf,EAAE;;IACX,MAAM,KAAK,GAAG,CAAA,MAAA,YAAY,CAAC,QAAQ,0CAA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,IAAI,CAAC,CAAC,cAAc,IAAI,CAAC,cAAc,CAAC,cAAc,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;QACpF,IAAA,mBAAW,EAAC,cAAc,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;KACtF;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 '../../services/card-ids';\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\tconst loops = playerEntity.trinkets?.some((t) => t.cardId === CardIds.ValdrakkenWindChimes_BG32_MagicItem_365)\r\n\t\t? 2\r\n\t\t: 1;\r\n\tfor (let i = 0; i < loops; i++) {\r\n\t\tif (playerEntity.hpLeft <= 0) {\r\n\t\t\treturn currentAttacker;\r\n\t\t}\r\n\t\tfor (const heroPower of playerEntity.heroPowers) {\r\n\t\t\tif (heroPower.cardId === CardIds.Wingmen && playerBoard.length > 0) {\r\n\t\t\t\t// After Illidan triggers, it's always the other opponent's turn\r\n\t\t\t\t// https://x.com/LoewenMitchell/status/1752714583360639131?s=20\r\n\t\t\t\thandleIllidanForPlayer(\r\n\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentEntity,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tcurrentAttacker,\r\n\t\t\t\t);\r\n\t\t\t\t// This is not true anymore: https://replays.firestoneapp.com/?reviewId=7282387d-66cd-458e-8ee1-e04c662e7bad&turn=5&action=1\r\n\t\t\t\t// currentAttacker = friendly ? 1 : 0;\r\n\t\t\t\t// In fact there is some adjustment going on: https://replays.firestoneapp.com/?reviewId=929f676f-47f6-494b-9619-df04174a0150&turn=11&action=0\r\n\t\t\t\t// So trying another logic\r\n\t\t\t\t// currentAttacker = (currentAttacker + 1) % 2;\r\n\t\t\t\t// This isn't correct. The following game is a case of:\r\n\t\t\t\t// The player with the fewer minions is Illidan, so isn't the \"first attacker\"\r\n\t\t\t\t// Wingmen triggers\r\n\t\t\t\t// The non-Illidan side then attacks first\r\n\t\t\t\t// https://replays.firestoneapp.com/?reviewId=45f40e73-4be9-419f-9093-0c2d91a7bac2&turn=5&action=0\r\n\t\t\t\t// So for now, just randomizing the attacker to try and avoid \"impossible\" scenarios as much as possible\r\n\t\t\t\tcurrentAttacker = Math.random() < 0.5 ? 0 : 1;\r\n\t\t\t}\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, playerEntity, 2, 1, playerBoard, playerEntity, gameState);\r\n\tif (!!secondAttacker && !secondAttacker.definitelyDead && secondAttacker.health > 0) {\r\n\t\tmodifyStats(secondAttacker, playerEntity, 2, 1, playerBoard, playerEntity, gameState);\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":[],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AAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAGvF,IAAA,mBAAW,EAAC,aAAa,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;IACrF,IAAI,CAAC,CAAC,cAAc,IAAI,CAAC,cAAc,CAAC,cAAc,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;QACpF,IAAA,mBAAW,EAAC,cAAc,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;KACtF;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 { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { CardIds } from '../../services/card-ids';\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\tconst shouldRecomputeCurrentAttacker = handleSummonsWhenSpace(\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tgameState,\r\n\t);\r\n\tif (shouldRecomputeCurrentAttacker) {\r\n\t\tcurrentAttacker =\r\n\t\t\tplayerBoard.length > opponentBoard.length\r\n\t\t\t\t? 0\r\n\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t? 1\r\n\t\t\t\t: Math.round(Math.random());\r\n\t}\r\n\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\tconst loops = playerEntity.trinkets?.some((t) => t.cardId === CardIds.ValdrakkenWindChimes_BG32_MagicItem_365)\r\n\t\t? 2\r\n\t\t: 1;\r\n\tfor (let i = 0; i < loops; i++) {\r\n\t\tif (playerEntity.hpLeft <= 0) {\r\n\t\t\treturn currentAttacker;\r\n\t\t}\r\n\t\tfor (const heroPower of playerEntity.heroPowers) {\r\n\t\t\tif (heroPower.cardId === CardIds.Wingmen && playerBoard.length > 0) {\r\n\t\t\t\t// After Illidan triggers, it's always the other opponent's turn\r\n\t\t\t\t// https://x.com/LoewenMitchell/status/1752714583360639131?s=20\r\n\t\t\t\thandleIllidanForPlayer(\r\n\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentEntity,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tcurrentAttacker,\r\n\t\t\t\t);\r\n\t\t\t\t// This is not true anymore: https://replays.firestoneapp.com/?reviewId=7282387d-66cd-458e-8ee1-e04c662e7bad&turn=5&action=1\r\n\t\t\t\t// currentAttacker = friendly ? 1 : 0;\r\n\t\t\t\t// In fact there is some adjustment going on: https://replays.firestoneapp.com/?reviewId=929f676f-47f6-494b-9619-df04174a0150&turn=11&action=0\r\n\t\t\t\t// So trying another logic\r\n\t\t\t\t// currentAttacker = (currentAttacker + 1) % 2;\r\n\t\t\t\t// This isn't correct. The following game is a case of:\r\n\t\t\t\t// The player with the fewer minions is Illidan, so isn't the \"first attacker\"\r\n\t\t\t\t// Wingmen triggers\r\n\t\t\t\t// The non-Illidan side then attacks first\r\n\t\t\t\t// https://replays.firestoneapp.com/?reviewId=45f40e73-4be9-419f-9093-0c2d91a7bac2&turn=5&action=0\r\n\t\t\t\t// So for now, just randomizing the attacker to try and avoid \"impossible\" scenarios as much as possible\r\n\t\t\t\tcurrentAttacker = Math.random() < 0.5 ? 0 : 1;\r\n\t\t\t}\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, playerEntity, 2, 1, playerBoard, playerEntity, gameState);\r\n\tif (!!secondAttacker && !secondAttacker.definitelyDead && secondAttacker.health > 0) {\r\n\t\tmodifyStats(secondAttacker, playerEntity, 2, 1, playerBoard, playerEntity, gameState);\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"]}
@@ -65,7 +65,15 @@ const handleStartOfCombatMinions = (playerEntity, playerBoard, opponentEntity, o
65
65
  attackerForStart = (attackerForStart + 1) % 2;
66
66
  }
67
67
  }
68
- (0, summon_when_space_1.handleSummonsWhenSpace)(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);
68
+ const shouldRecomputeCurrentAttacker = (0, summon_when_space_1.handleSummonsWhenSpace)(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);
69
+ if (shouldRecomputeCurrentAttacker) {
70
+ currentAttacker =
71
+ playerBoard.length > opponentBoard.length
72
+ ? 0
73
+ : opponentBoard.length > playerBoard.length
74
+ ? 1
75
+ : Math.round(Math.random());
76
+ }
69
77
  return currentAttacker;
70
78
  };
71
79
  exports.handleStartOfCombatMinions = handleStartOfCombatMinions;