@firestone-hs/simulate-bgs-battle 1.1.659 → 1.1.662

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 (76) hide show
  1. package/dist/cards/cards-data.d.ts +3 -1
  2. package/dist/cards/cards-data.js +3 -2
  3. package/dist/cards/cards-data.js.map +1 -1
  4. package/dist/cards/impl/_card-mappings.js +4 -0
  5. package/dist/cards/impl/_card-mappings.js.map +1 -1
  6. package/dist/cards/impl/minion/apexis-guardian.js +15 -11
  7. package/dist/cards/impl/minion/apexis-guardian.js.map +1 -1
  8. package/dist/cards/impl/minion/bassgill.js +1 -1
  9. package/dist/cards/impl/minion/bassgill.js.map +1 -1
  10. package/dist/cards/impl/minion/blue-volumizer.d.ts +2 -2
  11. package/dist/cards/impl/minion/blue-volumizer.js +1 -1
  12. package/dist/cards/impl/minion/blue-volumizer.js.map +1 -1
  13. package/dist/cards/impl/minion/bluesy-siren.js +1 -1
  14. package/dist/cards/impl/minion/bluesy-siren.js.map +1 -1
  15. package/dist/cards/impl/minion/clunker-junker.js +1 -1
  16. package/dist/cards/impl/minion/clunker-junker.js.map +1 -1
  17. package/dist/cards/impl/minion/dramaloc.js +7 -6
  18. package/dist/cards/impl/minion/dramaloc.js.map +1 -1
  19. package/dist/cards/impl/minion/impulsive-trickster.js +13 -5
  20. package/dist/cards/impl/minion/impulsive-trickster.js.map +1 -1
  21. package/dist/cards/impl/minion/pashmar-the-vengeful.js +2 -1
  22. package/dist/cards/impl/minion/pashmar-the-vengeful.js.map +1 -1
  23. package/dist/cards/impl/minion/profound-thinker.d.ts +2 -2
  24. package/dist/cards/impl/minion/profound-thinker.js +11 -8
  25. package/dist/cards/impl/minion/profound-thinker.js.map +1 -1
  26. package/dist/cards/impl/minion/red-volumizer.d.ts +2 -2
  27. package/dist/cards/impl/minion/red-volumizer.js +1 -1
  28. package/dist/cards/impl/minion/red-volumizer.js.map +1 -1
  29. package/dist/cards/impl/minion/rickety-repairbot.js +1 -1
  30. package/dist/cards/impl/minion/rickety-repairbot.js.map +1 -1
  31. package/dist/cards/impl/minion/roaring-rallier.d.ts +2 -2
  32. package/dist/cards/impl/minion/roaring-rallier.js +1 -1
  33. package/dist/cards/impl/minion/roaring-rallier.js.map +1 -1
  34. package/dist/cards/impl/minion/silent-enforcer.js +1 -1
  35. package/dist/cards/impl/minion/silent-enforcer.js.map +1 -1
  36. package/dist/cards/impl/minion/soulsplitter.js +6 -11
  37. package/dist/cards/impl/minion/soulsplitter.js.map +1 -1
  38. package/dist/cards/impl/minion/the-glad-iator.d.ts +2 -0
  39. package/dist/cards/impl/minion/the-glad-iator.js +12 -0
  40. package/dist/cards/impl/minion/the-glad-iator.js.map +1 -0
  41. package/dist/cards/impl/minion/timewarped-electron.js +1 -1
  42. package/dist/cards/impl/minion/timewarped-electron.js.map +1 -1
  43. package/dist/cards/impl/minion/timewarped-immortal.js +2 -2
  44. package/dist/cards/impl/minion/timewarped-immortal.js.map +1 -1
  45. package/dist/cards/impl/minion/timewarped-interpreter.js +2 -1
  46. package/dist/cards/impl/minion/timewarped-interpreter.js.map +1 -1
  47. package/dist/cards/impl/minion/timewarped-murcules.js +3 -0
  48. package/dist/cards/impl/minion/timewarped-murcules.js.map +1 -1
  49. package/dist/cards/impl/minion/timewarped-pashmar.js +2 -1
  50. package/dist/cards/impl/minion/timewarped-pashmar.js.map +1 -1
  51. package/dist/cards/impl/minion/timewarped-trickster.js +5 -8
  52. package/dist/cards/impl/minion/timewarped-trickster.js.map +1 -1
  53. package/dist/cards/impl/minion/timewarped-warghoul.js +9 -1
  54. package/dist/cards/impl/minion/timewarped-warghoul.js.map +1 -1
  55. package/dist/cards/impl/minion/whelp-watcher.js +4 -1
  56. package/dist/cards/impl/minion/whelp-watcher.js.map +1 -1
  57. package/dist/cards/impl/spellcraft/crab-mount.d.ts +2 -0
  58. package/dist/cards/impl/spellcraft/crab-mount.js +23 -0
  59. package/dist/cards/impl/spellcraft/crab-mount.js.map +1 -0
  60. package/dist/cards/impl/spellcraft/deep-blues.js +2 -1
  61. package/dist/cards/impl/spellcraft/deep-blues.js.map +1 -1
  62. package/dist/cards/impl/trinket/sepulchral-sergent.js +4 -2
  63. package/dist/cards/impl/trinket/sepulchral-sergent.js.map +1 -1
  64. package/dist/simulation/damage-effects.js +1 -1
  65. package/dist/simulation/damage-effects.js.map +1 -1
  66. package/dist/simulation/deathrattle-effects.js +10 -2
  67. package/dist/simulation/deathrattle-effects.js.map +1 -1
  68. package/dist/simulation/deathrattle-spawns.js +14 -14
  69. package/dist/simulation/deathrattle-spawns.js.map +1 -1
  70. package/dist/simulation/magnetize.d.ts +1 -1
  71. package/dist/simulation/magnetize.js +74 -64
  72. package/dist/simulation/magnetize.js.map +1 -1
  73. package/dist/utils.d.ts +3 -1
  74. package/dist/utils.js +13 -8
  75. package/dist/utils.js.map +1 -1
  76. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"deathrattle-effects.js","sourceRoot":"","sources":["../../src/simulation/deathrattle-effects.ts"],"names":[],"mappings":";;;AACA,iEAA8E;AAI9E,6EAAkG;AAClG,6DAA+D;AAC/D,6CAAgD;AAEhD,6CAAgE;AAChE,gEAAuE;AACvE,oCAOkB;AAClB,qCAA8C;AAC9C,mDAAiD;AACjD,6DAAqD;AAErD,qEAAwE;AAExE,mCAAsC;AAEtC,MAAM,2BAA2B,GAAG,0BAAwE,CAAC;AAC7G,MAAM,2BAA2B,GAAG;;;;CAInC,CAAC;AACF,MAAM,2BAA2B,GAAG,kCAA+E,CAAC;AAE7G,MAAM,4BAA4B,GAAG,CAC3C,KAAoB,EACpB,SAA0B,EAC1B,UAAuB,EACvB,WAAwB,EACf,EAAE;;IACX,MAAM,OAAO,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,MAAA,MAAA,SAAS,CAAC,OAAO,0CAAE,GAAG,CA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AC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,WAAC,OAAA,MAAA,CAAC,CAAC,MAAM,0CAAE,UAAU,YAA8B,CAAA,EAAA,CAAC,EAAE;YAKpF,MAAM,uBAAuB,GAAG,IAAA,qDAA4B,EAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;YAC1F,IAAI,CAAC,sBAAsB,GAAG;gBAC7B,GAAG,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,WAAC,OAAA,CAAC,CAAA,MAAA,CAAC,CAAC,MAAM,0CAAE,UAAU,YAA8B,CAAA,CAAA,EAAA,CAAC;gBACjG,GAAG,uBAAuB;aAC1B,CAAC;SACF;KACD;AAYF,CAAC,CAAC;AAnFW,QAAA,oBAAoB,wBAmF/B;AAEF,MAAM,sBAAsB,GAAG,CAC9B,mBAAkC,EAClC,IAAqB,EACrB,SAAwB,EACvB,EAAE;AAWJ,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, GameTag, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardsData } from '../cards/cards-data';\r\nimport { eternalKnightAttack, eternalKnightHealth } from '../cards/impl/trinket/eternal-portrait';\r\nimport { updateDivineShield } from '../keywords/divine-shield';\r\nimport { updateTaunt } from '../keywords/taunt';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { pickMultipleRandomDifferent } from '../services/utils';\r\nimport { isValidDeathrattleEnchantment } from '../simulate-bgs-battle';\r\nimport {\r\n\tgetRandomMinionWithHighestHealth,\r\n\tgrantRandomStats,\r\n\thasCorrectTribe,\r\n\tisDead,\r\n\tisFish,\r\n\tisGolden,\r\n} from '../utils';\r\nimport { dealDamageToMinion } from './attack';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { groupLeapfroggerDeathrattles } from './remembered-deathrattle';\r\nimport { SharedState } from './shared-state';\r\nimport { modifyStats } from './stats';\r\n\r\nconst DEATHRATTLES_REQUIRE_MEMORY = [CardIds.StitchedSalvager_BG31_999, CardIds.StitchedSalvager_BG31_999_G];\r\nconst DOUBLE_DEATHRATTLE_CARD_IDS = [\r\n\tCardIds.MoiraBronzebeard_BG27_518,\r\n\tCardIds.TitusTribute_BG28_843,\r\n\tCardIds.TimewarpedDeios_BG34_Giant_376,\r\n];\r\nconst TRIPLE_DEATHRATTLE_CARD_IDS = [CardIds.MoiraBronzebeard_BG27_518_G, CardIds.TimewarpedDeios_BG34_Giant_376_G];\r\n\r\nexport const computeDeathrattleMultiplier = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tsharedState: SharedState,\r\n): number => {\r\n\tconst cardIds = [...board.map((e) => e.cardId), ...(boardHero.secrets?.map((e) => e.cardId) ?? [])];\r\n\tconst triggerMult = cardIds.some((cardId) => TRIPLE_DEATHRATTLE_CARD_IDS.includes(cardId as CardIds))\r\n\t\t? 3\r\n\t\t: cardIds.some((cardId) => DOUBLE_DEATHRATTLE_CARD_IDS.includes(cardId as CardIds))\r\n\t\t? 2\r\n\t\t: 1;\r\n\r\n\tconst titus = board.filter((entity) => entity.cardId === CardIds.TitusRivendare_BG25_354).length;\r\n\tconst goldenTitus = board.filter((entity) => entity.cardId === CardIds.TitusRivendare_BG25_354_G).length;\r\n\tconst deathlyPhylacteries = boardHero.trinkets.filter(\r\n\t\t(t) => t.cardId === CardIds.DeathlyPhylactery_BG30_MagicItem_700 && t.scriptDataNum1 > 0,\r\n\t).length;\r\n\tconst tombs =\r\n\t\tboardHero.questRewardEntities?.filter((entity) => entity.cardId === CardIds.TurbulentTombs)?.length ?? 0;\r\n\tconst echoesOfArgus = sharedState.anomalies.includes(CardIds.EchoesOfArgus_BG27_Anomaly_802) ? 1 : 0;\r\n\tconst scourgeMultiplier = deadEntity.additionalCards?.includes(CardIds.ScourgeTroll) ? 2 : 1;\r\n\r\n\tconst multiplier =\r\n\t\tscourgeMultiplier * (triggerMult + deathlyPhylacteries + titus + 2 * goldenTitus + tombs + echoesOfArgus);\r\n\treturn multiplier;\r\n};\r\n\r\nexport const applyLightningInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity | BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// Because the golden version doubles all the remembered effects\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tconst previousVenomous = (deadEntity as BoardEntity).venomous;\r\n\t(deadEntity as BoardEntity).venomous = false;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst targets = pickMultipleRandomDifferent(otherBoard, 5);\r\n\t\tfor (const target of targets) {\r\n\t\t\tdealDamageToMinion(\r\n\t\t\t\ttarget,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tdeadEntity,\r\n\t\t\t\t1,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\t(deadEntity as BoardEntity).venomous = previousVenomous;\r\n};\r\n\r\nexport const applyWaterInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity, // Can be null when trinket is used\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst validBoard = boardWithDeadEntity.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\t\tconst target: BoardEntity = validBoard[validBoard.length - 1];\r\n\t\tif (!!target) {\r\n\t\t\tupdateTaunt(target, true, boardWithDeadEntity, boardWithDeadEntityHero, otherHero, gameState);\r\n\t\t\tupdateDivineShield(target, boardWithDeadEntity, boardWithDeadEntityHero, otherHero, true, gameState);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyFireInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst target: BoardEntity = boardWithDeadEntity.filter((e) => e.health > 0 && !e.definitelyDead)[0];\r\n\t\tif (!!target) {\r\n\t\t\tmodifyStats(\r\n\t\t\t\ttarget,\r\n\t\t\t\tsourceEntity,\r\n\t\t\t\ttarget.attack,\r\n\t\t\t\t0,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyEarthInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst minionsGrantedDeathrattle: BoardEntity[] = pickMultipleRandomDifferent(boardWithDeadEntity, 4);\r\n\t\tminionsGrantedDeathrattle.forEach((minion) => {\r\n\t\t\tminion.enchantments.push({\r\n\t\t\t\tcardId: CardIds.EarthInvocation_ElementEarthEnchantment,\r\n\t\t\t\toriginEntityId: deadEntity?.entityId,\r\n\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t});\r\n\t\t\tgameState.spectator.registerPowerTarget(sourceEntity, minion, boardWithDeadEntity, null, null);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const applyLeapFroggerEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tgameState: FullGameState,\r\n\tmultiplier: number,\r\n): void => {\r\n\tmultiplier = multiplier ?? deadEntity.deathrattleRepeats ?? 1;\r\n\t// console.debug('applying leapfrogger effect', deadEntity.entityId, multiplier);\r\n\tconst buffed = grantRandomStats(\r\n\t\tdeadEntity,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tmultiplier * (isPremium ? 2 : 1),\r\n\t\tmultiplier * (isPremium ? 2 : 1),\r\n\t\tRace.BEAST,\r\n\t\tfalse,\r\n\t\tgameState,\r\n\t);\r\n\tif (buffed) {\r\n\t\tbuffed.enchantments.push({\r\n\t\t\tcardId: isPremium\r\n\t\t\t\t? CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge\r\n\t\t\t\t: CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e,\r\n\t\t\toriginEntityId: deadEntity.entityId,\r\n\t\t\trepeats: multiplier > 1 ? multiplier : 1,\r\n\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const applyRecurringNightmareDeathrattleEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tgameState: FullGameState,\r\n\tmultiplier = 1,\r\n): void => {\r\n\t// multiplier = multiplier || 1;\r\n\t// const target = pickRandom(\r\n\t// \tboardWithDeadEntity\r\n\t// \t\t.filter((e) =>\r\n\t// \t\t\thasCorrectTribe(e, boardWithDeadEntityHero, Race.UNDEAD, gameState.anomalies, gameState.allCards),\r\n\t// \t\t)\r\n\t// \t\t.filter(\r\n\t// \t\t\t(e) =>\r\n\t// \t\t\t\te.cardId !== CardIds.RecurringNightmare_BG26_055 &&\r\n\t// \t\t\t\te.cardId !== CardIds.RecurringNightmare_BG26_055_G,\r\n\t// \t\t),\r\n\t// );\r\n\t// if (target) {\r\n\t// \ttarget.enchantments = target.enchantments ?? [];\r\n\t// \ttarget.enchantments.push({\r\n\t// \t\tcardId: isPremium\r\n\t// \t\t\t? CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055_Ge\r\n\t// \t\t\t: CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055e,\r\n\t// \t\toriginEntityId: deadEntity.entityId,\r\n\t// \t\trepeats: multiplier > 1 ? multiplier : 1,\r\n\t// \t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t// \t});\r\n\t// \tgameState.spectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity, null, null);\r\n\t// }\r\n};\r\n\r\n// Some minions like Icesnarl can revive themselves when killing a minion, so it needs to be handled before\r\n// we actually make the minion die\r\nexport const handleWheneverMinionsKillEffect = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\thandleWheneverMinionsKillEffectForBoard(board, hero, otherBoard, otherHero, gameState);\r\n\t// It's called once for each board already, so don't duplicate it here\r\n\t// handleWheneverMinionsKillEffectForBoard(otherBoard, otherHero, board, hero, gameState);\r\n};\r\n\r\nconst handleWheneverMinionsKillEffectForBoard = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].health <= 0 || board[i].definitelyDead) {\r\n\t\t\tconst futureDeadEntity = board[i];\r\n\t\t\tconst killer = futureDeadEntity.lastAffectedByEntity;\r\n\t\t\tif (!killer) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Killed an enemy minion\r\n\t\t\tif (killer.friendly !== futureDeadEntity.friendly) {\r\n\t\t\t\tfor (const heroPower of otherHero.heroPowers) {\r\n\t\t\t\t\t// Can't be used to resurrect a dead minion\r\n\t\t\t\t\t// https://replays.firestoneapp.com/?reviewId=d1fffee8-0bc3-40f5-9a59-85eef8367095&turn=11&action=4\r\n\t\t\t\t\tif (heroPower.cardId === CardIds.Rokara_GloryOfCombat && !isDead(killer)) {\r\n\t\t\t\t\t\tmodifyStats(killer, otherHero, 1, 0, otherBoard, otherHero, gameState);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Icesnarl the Mighty\r\n\t\t\t\totherBoard\r\n\t\t\t\t\t.filter(\r\n\t\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\t\te.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy ||\r\n\t\t\t\t\t\t\te.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy_G,\r\n\t\t\t\t\t)\r\n\t\t\t\t\t// Can't be revived\r\n\t\t\t\t\t// 33.6 https://replays.firestoneapp.com/?reviewId=608ddffb-6c04-4def-a8de-fd39228f4de4&turn=11&action=4\r\n\t\t\t\t\t// Maybe should move to an \"after kill\" phase, where dead minions are already dead?\r\n\t\t\t\t\t.filter((e) => e.health > 0 && !e.definitelyDead)\r\n\t\t\t\t\t.forEach((icesnarl) => {\r\n\t\t\t\t\t\tconst mult = icesnarl.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy_G ? 2 : 1;\r\n\t\t\t\t\t\tmodifyStats(icesnarl, icesnarl, 0, 3 * mult, board, hero, gameState);\r\n\t\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const handleAfterMinionKillsEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// Moved to \"whenever kills\", as these can revive the minion that kills\r\n\t// const killer = deadEntity.lastAffectedByEntity;\r\n\t// if (!killer) {\r\n\t// \treturn;\r\n\t// }\r\n\t// // Killed an enemy minion\r\n\t// if (killer.friendly !== deadEntity.friendly) {\r\n\t// }\r\n};\r\n\r\nexport const applyAfterMinionDiesEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.DEMON, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplySoulJugglerEffect(boardWithDeadEntity, boardWithDeadEntityHero, otherBoard, otherBoardHero, gameState);\r\n\t}\r\n};\r\n\r\nexport const applyWheneverMinionDiesEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// console.log('applying minion death effect', stringifySimpleCard(deadEntity, allCards));\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.BEAST, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplyScavengingHyenaEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.MECH, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplyJunkbotEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.MURLOC, gameState.anomalies, gameState.allCards)) {\r\n\t\tremoveOldMurkEyeAttack(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\tremoveOldMurkEyeAttack(otherBoard, otherBoardHero, gameState);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.ELEMENTAL, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplyMossOfTheSchlossEffect(deadEntity, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\r\n\tif (deadEntity.taunt) {\r\n\t\tapplyBristlemaneScrapsmithEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\tapplyQirajiHarbringerEffect(boardWithDeadEntity, boardWithDeadEntityHero, deadEntityIndexFromRight, gameState);\r\n\t}\r\n\r\n\tif (\r\n\t\tdeadEntity.cardId === CardIds.EternalKnight_BG25_008 ||\r\n\t\tdeadEntity.cardId === CardIds.EternalKnight_BG25_008_G\r\n\t) {\r\n\t\tapplyEternalKnightEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\r\n\t// Putricide-only\r\n\tboardWithDeadEntity\r\n\t\t.filter((e) => e.additionalCards?.includes(CardIds.FlesheatingGhoulLegacy_BG26_tt_004))\r\n\t\t.forEach((e) => {\r\n\t\t\tmodifyStats(e, null, 1, 0, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t});\r\n\r\n\tapplyRotHideGnollEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\r\n\t// Overkill\r\n\tif (\r\n\t\tdeadEntity.health < 0 &&\r\n\t\tgameState.sharedState.currentAttackerEntityId != null &&\r\n\t\tgameState.sharedState.currentAttackerEntityId === deadEntity.lastAffectedByEntity?.entityId\r\n\t) {\r\n\t\t// if (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlame_BGS_032) {\r\n\t\t// \tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t// \tif (targets.length > 0) {\r\n\t\t// \t\tconst target = targets[0];\r\n\t\t// \t\tdealDamageToMinion(\r\n\t\t// \t\t\ttarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\t3,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tgameState,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlame_TB_BaconUps_103) {\r\n\t\t// \tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t// \tif (targets.length > 0) {\r\n\t\t// \t\tconst target = targets[0];\r\n\t\t// \t\tdealDamageToMinion(\r\n\t\t// \t\t\ttarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\t6,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tgameState,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// }\r\n\t\t// else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental && deadEntity.lastAffectedByEntity.attacking) {\r\n\t\t// \t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental) {\r\n\t\t// \t// console.log('applying WildfireElemental effect', stringifySimple(boardWithDeadEntity, allCards));\r\n\t\t// \tconst excessDamage = -deadEntity.health;\r\n\t\t// \t// Prevent propagation of the effect\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking = false;\r\n\t\t// \tconst neighbours = getNeighbours(boardWithDeadEntity, null, boardWithDeadEntity.length - deadEntityIndexFromRight);\r\n\t\t// \t// console.log('neighbours', stringifySimple(neighbours, allCards));\r\n\t\t// \tif (neighbours.length > 0) {\r\n\t\t// \t\tconst randomTarget = neighbours[Math.floor(Math.random() * neighbours.length)];\r\n\t\t// \t\tdealDamageToEnemy(\r\n\t\t// \t\t\trandomTarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\texcessDamage,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tallCards,\r\n\t\t// \t\t\tcardsData,\r\n\t\t// \t\t\tsharedState,\r\n\t\t// \t\t\tspectator,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// } else if (\r\n\t\t// \tdeadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElementalBattlegrounds &&\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking\r\n\t\t// ) {\r\n\t\t// \tconst excessDamage = -deadEntity.health;\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking = false;\r\n\t\t// \tconst neighbours = getNeighbours(boardWithDeadEntity, null, boardWithDeadEntity.length - deadEntityIndexFromRight);\r\n\t\t// \tneighbours.forEach((neighbour) =>\r\n\t\t// \t\tdealDamageToEnemy(\r\n\t\t// \t\t\tneighbour,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\texcessDamage,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tallCards,\r\n\t\t// \t\t\tcardsData,\r\n\t\t// \t\t\tsharedState,\r\n\t\t// \t\t\tspectator,\r\n\t\t// \t\t),\r\n\t\t// \t);\r\n\t\t// }\r\n\t\tif (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn_TRL_232) {\r\n\t\t\tconst newEntities = spawnEntities(\r\n\t\t\t\tCardIds.IronhideDirehorn_IronhideRuntToken_TRL_232t,\r\n\t\t\t\t1,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\t!deadEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t\totherBoard.splice(otherBoard.length - deadEntityIndexFromRight, 0, ...newEntities);\r\n\t\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn_TB_BaconUps_051) {\r\n\t\t\t// \tconst newEntities = spawnEntities(\r\n\t\t\t// \t\tCardIds.IronhideDirehorn_IronhideRuntToken_TB_BaconUps_051t,\r\n\t\t\t// \t\t1,\r\n\t\t\t// \t\totherBoard,\r\n\t\t\t// \t\totherBoardHero,\r\n\t\t\t// \t\tboardWithDeadEntity,\r\n\t\t\t// \t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\tgameState,\r\n\t\t\t// \t\t!deadEntity.friendly,\r\n\t\t\t// \t\tfalse,\r\n\t\t\t// \t);\r\n\t\t\t// \totherBoard.splice(otherBoard.length - deadEntityIndexFromRight, 0, ...newEntities);\r\n\t\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath_BGS_080) {\r\n\t\t\t// \tconst otherPirates = otherBoard\r\n\t\t\t// \t\t.filter((entity) =>\r\n\t\t\t// \t\t\thasCorrectTribe(\r\n\t\t\t// \t\t\t\tentity,\r\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\t\tRace.PIRATE,\r\n\t\t\t// \t\t\t\tgameState.anomalies,\r\n\t\t\t// \t\t\t\tgameState.allCards,\r\n\t\t\t// \t\t\t),\r\n\t\t\t// \t\t)\r\n\t\t\t// \t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\t// \totherPirates.forEach((pirate) => {\r\n\t\t\t// \t\tmodifyStats(\r\n\t\t\t// \t\t\tpirate,\r\n\t\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t// \t\t\t2,\r\n\t\t\t// \t\t\t2,\r\n\t\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t\t// \t\t\tboardWithDeadEntityHero,\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// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath_TB_BaconUps_142) {\r\n\t\t\t// \tconst otherPirates = otherBoard\r\n\t\t\t// \t\t.filter((entity) =>\r\n\t\t\t// \t\t\thasCorrectTribe(\r\n\t\t\t// \t\t\t\tentity,\r\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\t\tRace.PIRATE,\r\n\t\t\t// \t\t\t\tgameState.anomalies,\r\n\t\t\t// \t\t\t\tgameState.allCards,\r\n\t\t\t// \t\t\t),\r\n\t\t\t// \t\t)\r\n\t\t\t// \t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\t// \totherPirates.forEach((pirate) => {\r\n\t\t\t// \t\tmodifyStats(\r\n\t\t\t// \t\t\tpirate,\r\n\t\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t// \t\t\t4,\r\n\t\t\t// \t\t\t4,\r\n\t\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t\t// \t\t\tboardWithDeadEntityHero,\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}\r\n\t}\r\n};\r\n\r\n/** @deprecated */\r\nexport const dealDamageToAllMinions = (\r\n\tboard1: BoardEntity[],\r\n\tboard1Hero: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tboard2Hero: BgsPlayerEntity,\r\n\tdamageSource: BoardEntity,\r\n\tdamageDealt: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (board1.length === 0 && board2.length === 0) {\r\n\t\treturn;\r\n\t}\r\n\tfor (let i = 0; i < board1.length; i++) {\r\n\t\tdealDamageToMinion(board1[i], board1, board1Hero, damageSource, damageDealt, board2, board2Hero, gameState);\r\n\t}\r\n\tfor (let i = 0; i < board2.length; i++) {\r\n\t\tdealDamageToMinion(board2[i], board2, board2Hero, damageSource, damageDealt, board1, board1Hero, gameState);\r\n\t}\r\n};\r\n\r\nexport const applySoulJugglerEffect = (\r\n\tboardWithJugglers: BoardEntity[],\r\n\tboardWithJugglersHero: BgsPlayerEntity,\r\n\tboardToAttack: BoardEntity[],\r\n\tboardToAttackHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (boardWithJugglers.length === 0 && boardToAttack.length === 0) {\r\n\t\treturn;\r\n\t\t// return [boardWithJugglers, boardToAttack];\r\n\t}\r\n\tconst jugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler_BGS_002);\r\n\tfor (const juggler of jugglers) {\r\n\t\tconst target = getRandomMinionWithHighestHealth(boardToAttack);\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tjuggler,\r\n\t\t\ttarget,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tboardToAttackHero,\r\n\t\t);\r\n\t\tdealDamageToMinion(\r\n\t\t\ttarget,\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t4,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\tconst goldenJugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler_TB_BaconUps_075);\r\n\tfor (const juggler of goldenJugglers) {\r\n\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\tconst target = getRandomMinionWithHighestHealth(boardToAttack);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tjuggler,\r\n\t\t\t\ttarget,\r\n\t\t\t\tboardWithJugglers,\r\n\t\t\t\tboardWithJugglersHero,\r\n\t\t\t\tboardToAttackHero,\r\n\t\t\t);\r\n\t\t\tdealDamageToMinion(\r\n\t\t\t\ttarget,\r\n\t\t\t\tboardToAttack,\r\n\t\t\t\tboardToAttackHero,\r\n\t\t\t\tjuggler,\r\n\t\t\t\t4,\r\n\t\t\t\tboardWithJugglers,\r\n\t\t\t\tboardWithJugglersHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\t// processMinionDeath(\r\n\t// \tboardWithJugglers,\r\n\t// \tboardWithJugglersHero,\r\n\t// \tboardToAttack,\r\n\t// \tboardToAttackHero,\r\n\t// \tallCards,\r\n\t// \tcardsData,\r\n\t// \tsharedState,\r\n\t// \tspectator,\r\n\t// );\r\n};\r\n\r\nconst applyScavengingHyenaEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// const copy = [...board];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.ScavengingHyenaLegacy_BG_EX1_531) {\r\n\t\t\tmodifyStats(board[i], null, 2, 1, board, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t} else if (board[i].cardId === CardIds.ScavengingHyenaLegacy_TB_BaconUps_043) {\r\n\t\t\tmodifyStats(board[i], null, 4, 2, board, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyEternalKnightEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (\r\n\t\t\tboard[i].cardId === CardIds.EternalKnight_BG25_008 ||\r\n\t\t\tboard[i].cardId === CardIds.EternalKnight_BG25_008_G\r\n\t\t) {\r\n\t\t\tconst multiplier = board[i].cardId === CardIds.EternalKnight_BG25_008_G ? 2 : 1;\r\n\t\t\tmodifyStats(\r\n\t\t\t\tboard[i],\r\n\t\t\t\tnull,\r\n\t\t\t\tmultiplier * eternalKnightAttack,\r\n\t\t\t\tmultiplier * eternalKnightHealth,\r\n\t\t\t\tboard,\r\n\t\t\t\thero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyRotHideGnollEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.RotHideGnoll_BG25_013 || board[i].cardId === CardIds.RotHideGnoll_BG25_013_G) {\r\n\t\t\tconst multiplier = board[i].cardId === CardIds.RotHideGnoll_BG25_013_G ? 2 : 1;\r\n\t\t\tmodifyStats(board[i], null, multiplier * 1, 0, board, hero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyBristlemaneScrapsmithEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardPlayerEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (\r\n\t\t\tboard[i].cardId === CardIds.BristlemaneScrapsmith_BG24_707 ||\r\n\t\t\tboard[i].cardId === CardIds.BristlemaneScrapsmith_BG24_707_G\r\n\t\t) {\r\n\t\t\tconst cardsToAdd = Array(CardIds.BristlemaneScrapsmith_BG24_707_G ? 2 : 1).fill(CardIds.BloodGem);\r\n\t\t\taddCardsInHand(boardPlayerEntity, board, cardsToAdd, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, boardPlayerEntity, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyMossOfTheSchlossEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tboard\r\n\t\t.filter(\r\n\t\t\t(e) => e.cardId === CardIds.MossOfTheSchloss_BG30_111 || e.cardId === CardIds.MossOfTheSchloss_BG30_111_G,\r\n\t\t)\r\n\t\t.filter((e) => e.abiityChargesLeft > 0)\r\n\t\t.forEach((entity) => {\r\n\t\t\tmodifyStats(entity, null, deadEntity.maxAttack, deadEntity.maxHealth, board, hero, gameState);\r\n\t\t\tentity.abiityChargesLeft--;\r\n\t\t\tgameState.spectator.registerPowerTarget(entity, entity, board, null, null);\r\n\t\t});\r\n};\r\n\r\nconst applyJunkbotEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.Junkbot_GVG_106) {\r\n\t\t\tmodifyStats(board[i], board[i], 2, 2, board, hero, gameState);\r\n\t\t\t// } else if (board[i].cardId === CardIds.Junkbot_TB_BaconUps_046) {\r\n\t\t\t// \tmodifyStats(board[i], board[i], 4, 4, board, hero, gameState);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyQirajiHarbringerEffect = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// const qiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger_BGS_112);\r\n\t// const goldenQiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger_TB_BaconUps_303);\r\n\t// // TODO: if reactivated, properly apply buffs one by one, instead of all together\r\n\t// if (qiraji.length + goldenQiraji.length > 0) {\r\n\t// \tconst neighbours = getNeighbours(board, null, deadEntityIndexFromRight);\r\n\t// \tconst buff = 2 * qiraji.length + 4 * goldenQiraji.length;\r\n\t// \tneighbours.forEach((entity) => {\r\n\t// \t\tmodifyStats(entity, null, buff, buff, board, hero, gameState);\r\n\t// \t});\r\n\t// }\r\n};\r\n\r\nexport const rememberDeathrattles = (\r\n\tfish: BoardEntity,\r\n\tinputDeadEntities: readonly BoardEntity[],\r\n\tcardsData: CardsData,\r\n\tallCards: AllCardsService,\r\n\tsharedState: SharedState,\r\n): void => {\r\n\tconst deadEntities = inputDeadEntities.filter((e) => !isFish(e));\r\n\tif (!deadEntities?.length) {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// Some infinite loops going on?\r\n\tif (fish.rememberedDeathrattles?.length > 100) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst debug = deadEntities.some((e) => e.cardId === CardIds.CorruptedBristler_BG32_431);\r\n\r\n\tconst validDeathrattles = deadEntities\r\n\t\t.filter((entity) => allCards.getCard(entity.cardId).mechanics?.includes(GameTag[GameTag.DEATHRATTLE]))\r\n\t\t.filter((e) => !DEATHRATTLES_REQUIRE_MEMORY.includes(e.cardId as CardIds) || e.memory)\r\n\t\t.map((entity) => ({\r\n\t\t\tcardId: entity.cardId,\r\n\t\t\trepeats: 1,\r\n\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t\tmemory: entity.memory,\r\n\t\t\tscriptDataNum1: entity.scriptDataNum1,\r\n\t\t\tscriptDataNum2: entity.scriptDataNum2,\r\n\t\t}));\r\n\tconst validEnchantments = deadEntities\r\n\t\t.map((entity) => entity.enchantments)\r\n\t\t.reduce((a, b) => a.concat(b), [])\r\n\t\t.flatMap((enchantment) => ({\r\n\t\t\tcardId: enchantment.cardId,\r\n\t\t\trepeats: enchantment.repeats ?? 1,\r\n\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t}))\r\n\t\t.filter((enchantment) => isValidDeathrattleEnchantment(enchantment.cardId));\r\n\t// Multiple fish\r\n\tconst deadEntityRememberedDeathrattles =\r\n\t\tdeadEntities\r\n\t\t\t.filter((e) => !!e.rememberedDeathrattles?.length)\r\n\t\t\t// If the fish has reborn, it will inherit its own Deathrattles, and we don't want that\r\n\t\t\t.filter((e) => e.entityId !== fish.rebornFromEntityId)\r\n\t\t\t.filter((e) => !DEATHRATTLES_REQUIRE_MEMORY.includes(e.cardId as CardIds) || e.memory)\r\n\t\t\t.flatMap((e) => e.rememberedDeathrattles) ?? [];\r\n\tconst newDeathrattles = [...validDeathrattles, ...validEnchantments, ...deadEntityRememberedDeathrattles];\r\n\r\n\tif (newDeathrattles.length > 0) {\r\n\t\t// Order is important - the DR are triggered in the order d the minions have died\r\n\t\t// The \"golden\" part is handled at the card level for the other non-fish cards, like Piloted Whirl-o-Tron\r\n\t\tif (isFish(fish) && isGolden(fish.cardId, allCards)) {\r\n\t\t\t// https://stackoverflow.com/questions/33305152/how-to-duplicate-elements-in-a-js-array\r\n\t\t\tconst doubleDr = newDeathrattles.reduce((res, current) => res.concat([current, current]), []);\r\n\t\t\tfish.rememberedDeathrattles = [...(fish.rememberedDeathrattles || []), ...doubleDr];\r\n\t\t} else {\r\n\t\t\tfish.rememberedDeathrattles = [...(fish.rememberedDeathrattles || []), ...newDeathrattles];\r\n\t\t}\r\n\r\n\t\tif (newDeathrattles.some((d) => d.cardId?.startsWith(CardIds.Leapfrogger_BG21_000))) {\r\n\t\t\t// Not sure exactly why, but if a leapfrogger dies first, then a manasaber,\r\n\t\t\t// when the fish dies, the manasaber's effect (spawning tokens) is triggered first\r\n\t\t\t// https://replays.firestoneapp.com/?reviewId=521733fb-8ba1-4663-9a87-3da58e8a09c8&turn=21&action=3\r\n\t\t\t// HACK: So I will hardcode a rule for now to put leapfrogger effects last\r\n\t\t\tconst leapfroggerDeathrattles = groupLeapfroggerDeathrattles(fish.rememberedDeathrattles);\r\n\t\t\tfish.rememberedDeathrattles = [\r\n\t\t\t\t...fish.rememberedDeathrattles.filter((d) => !d.cardId?.startsWith(CardIds.Leapfrogger_BG21_000)),\r\n\t\t\t\t...leapfroggerDeathrattles,\r\n\t\t\t];\r\n\t\t}\r\n\t}\r\n\t// console.debug(\r\n\t// \t'remembered',\r\n\t// \tfish.cardId,\r\n\t// \tfish.entityId,\r\n\t// \tfish.rememberedDeathrattles.map((d) => ({\r\n\t// \t\tcardId: d.cardId,\r\n\t// \t\tname: allCards.getCard(d.cardId)?.name,\r\n\t// \t\t// repeats: d.repeats,\r\n\t// \t\t// timing: d.timing,\r\n\t// \t})),\r\n\t// );\r\n};\r\n\r\nconst removeOldMurkEyeAttack = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\t// const murkeyes = boardWithDeadEntity.filter(\r\n\t// \t(entity) => entity.cardId === CardIds.OldMurkEyeLegacy || entity.cardId === CardIds.OldMurkEyeVanilla,\r\n\t// );\r\n\t// const goldenMurkeyes = boardWithDeadEntity.filter((entity) => entity.cardId === CardIds.OldMurkEye);\r\n\t// murkeyes.forEach((entity) => {\r\n\t// \tmodifyStats(entity, null, -1, 0, boardWithDeadEntity, hero, gameState);\r\n\t// });\r\n\t// goldenMurkeyes.forEach((entity) => {\r\n\t// \tmodifyStats(entity, null, -2, 0, boardWithDeadEntity, hero, gameState);\r\n\t// });\r\n};\r\n"]}
1
+ {"version":3,"file":"deathrattle-effects.js","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A7FW,QAAA,oBAAoB,wBA6F/B;AAEF,MAAM,sBAAsB,GAAG,CAC9B,mBAAkC,EAClC,IAAqB,EACrB,SAAwB,EACvB,EAAE;AAWJ,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, GameTag, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardsData } from '../cards/cards-data';\r\nimport { eternalKnightAttack, eternalKnightHealth } from '../cards/impl/trinket/eternal-portrait';\r\nimport { updateDivineShield } from '../keywords/divine-shield';\r\nimport { updateTaunt } from '../keywords/taunt';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { pickMultipleRandomDifferent } from '../services/utils';\r\nimport { isValidDeathrattleEnchantment } from '../simulate-bgs-battle';\r\nimport {\r\n\tgetRandomMinionWithHighestHealth,\r\n\tgrantRandomStats,\r\n\thasCorrectTribe,\r\n\tisDead,\r\n\tisFish,\r\n\tisGolden,\r\n} from '../utils';\r\nimport { dealDamageToMinion } from './attack';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { groupLeapfroggerDeathrattles } from './remembered-deathrattle';\r\nimport { SharedState } from './shared-state';\r\nimport { modifyStats } from './stats';\r\n\r\nconst DEATHRATTLES_REQUIRE_MEMORY = [CardIds.StitchedSalvager_BG31_999, CardIds.StitchedSalvager_BG31_999_G];\r\nconst DOUBLE_DEATHRATTLE_CARD_IDS = [\r\n\tCardIds.MoiraBronzebeard_BG27_518,\r\n\tCardIds.TitusTribute_BG28_843,\r\n\tCardIds.TimewarpedDeios_BG34_Giant_376,\r\n];\r\nconst TRIPLE_DEATHRATTLE_CARD_IDS = [CardIds.MoiraBronzebeard_BG27_518_G, CardIds.TimewarpedDeios_BG34_Giant_376_G];\r\n\r\nexport const computeDeathrattleMultiplier = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tsharedState: SharedState,\r\n): number => {\r\n\tconst cardIds = [...board.map((e) => e.cardId), ...(boardHero.secrets?.map((e) => e.cardId) ?? [])];\r\n\tconst triggerMult = cardIds.some((cardId) => TRIPLE_DEATHRATTLE_CARD_IDS.includes(cardId as CardIds))\r\n\t\t? 3\r\n\t\t: cardIds.some((cardId) => DOUBLE_DEATHRATTLE_CARD_IDS.includes(cardId as CardIds))\r\n\t\t? 2\r\n\t\t: 1;\r\n\r\n\tconst titus = board.filter((entity) => entity.cardId === CardIds.TitusRivendare_BG25_354).length;\r\n\tconst goldenTitus = board.filter((entity) => entity.cardId === CardIds.TitusRivendare_BG25_354_G).length;\r\n\tconst deathlyPhylacteries = boardHero.trinkets.filter(\r\n\t\t(t) => t.cardId === CardIds.DeathlyPhylactery_BG30_MagicItem_700 && t.scriptDataNum1 > 0,\r\n\t).length;\r\n\tconst tombs =\r\n\t\tboardHero.questRewardEntities?.filter((entity) => entity.cardId === CardIds.TurbulentTombs)?.length ?? 0;\r\n\tconst echoesOfArgus = sharedState.anomalies.includes(CardIds.EchoesOfArgus_BG27_Anomaly_802) ? 1 : 0;\r\n\tconst scourgeMultiplier = deadEntity.additionalCards?.includes(CardIds.ScourgeTroll) ? 2 : 1;\r\n\r\n\tconst multiplier =\r\n\t\tscourgeMultiplier * (triggerMult + deathlyPhylacteries + titus + 2 * goldenTitus + tombs + echoesOfArgus);\r\n\treturn multiplier;\r\n};\r\n\r\nexport const applyLightningInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity | BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// Because the golden version doubles all the remembered effects\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tconst previousVenomous = (deadEntity as BoardEntity).venomous;\r\n\t(deadEntity as BoardEntity).venomous = false;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst targets = pickMultipleRandomDifferent(otherBoard, 5);\r\n\t\tfor (const target of targets) {\r\n\t\t\tdealDamageToMinion(\r\n\t\t\t\ttarget,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tdeadEntity,\r\n\t\t\t\t1,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\t(deadEntity as BoardEntity).venomous = previousVenomous;\r\n};\r\n\r\nexport const applyWaterInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity, // Can be null when trinket is used\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst validBoard = boardWithDeadEntity.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\t\tconst target: BoardEntity = validBoard[validBoard.length - 1];\r\n\t\tif (!!target) {\r\n\t\t\tupdateTaunt(target, true, boardWithDeadEntity, boardWithDeadEntityHero, otherHero, gameState);\r\n\t\t\tupdateDivineShield(target, boardWithDeadEntity, boardWithDeadEntityHero, otherHero, true, gameState);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyFireInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst target: BoardEntity = boardWithDeadEntity.filter((e) => e.health > 0 && !e.definitelyDead)[0];\r\n\t\tif (!!target) {\r\n\t\t\tmodifyStats(\r\n\t\t\t\ttarget,\r\n\t\t\t\tsourceEntity,\r\n\t\t\t\ttarget.attack,\r\n\t\t\t\t0,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyEarthInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst minionsGrantedDeathrattle: BoardEntity[] = pickMultipleRandomDifferent(boardWithDeadEntity, 4);\r\n\t\tminionsGrantedDeathrattle.forEach((minion) => {\r\n\t\t\tminion.enchantments.push({\r\n\t\t\t\tcardId: CardIds.EarthInvocation_ElementEarthEnchantment,\r\n\t\t\t\toriginEntityId: deadEntity?.entityId,\r\n\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t});\r\n\t\t\tgameState.spectator.registerPowerTarget(sourceEntity, minion, boardWithDeadEntity, null, null);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const applyLeapFroggerEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tgameState: FullGameState,\r\n\tmultiplier: number,\r\n): void => {\r\n\tmultiplier = multiplier ?? deadEntity.deathrattleRepeats ?? 1;\r\n\t// console.debug('applying leapfrogger effect', deadEntity.entityId, multiplier);\r\n\tconst buffed = grantRandomStats(\r\n\t\tdeadEntity,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tmultiplier * (isPremium ? 2 : 1),\r\n\t\tmultiplier * (isPremium ? 2 : 1),\r\n\t\tRace.BEAST,\r\n\t\tfalse,\r\n\t\tgameState,\r\n\t);\r\n\tif (buffed) {\r\n\t\tbuffed.enchantments.push({\r\n\t\t\tcardId: isPremium\r\n\t\t\t\t? CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge\r\n\t\t\t\t: CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e,\r\n\t\t\toriginEntityId: deadEntity.entityId,\r\n\t\t\trepeats: multiplier > 1 ? multiplier : 1,\r\n\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const applyRecurringNightmareDeathrattleEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tgameState: FullGameState,\r\n\tmultiplier = 1,\r\n): void => {\r\n\t// multiplier = multiplier || 1;\r\n\t// const target = pickRandom(\r\n\t// \tboardWithDeadEntity\r\n\t// \t\t.filter((e) =>\r\n\t// \t\t\thasCorrectTribe(e, boardWithDeadEntityHero, Race.UNDEAD, gameState.anomalies, gameState.allCards),\r\n\t// \t\t)\r\n\t// \t\t.filter(\r\n\t// \t\t\t(e) =>\r\n\t// \t\t\t\te.cardId !== CardIds.RecurringNightmare_BG26_055 &&\r\n\t// \t\t\t\te.cardId !== CardIds.RecurringNightmare_BG26_055_G,\r\n\t// \t\t),\r\n\t// );\r\n\t// if (target) {\r\n\t// \ttarget.enchantments = target.enchantments ?? [];\r\n\t// \ttarget.enchantments.push({\r\n\t// \t\tcardId: isPremium\r\n\t// \t\t\t? CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055_Ge\r\n\t// \t\t\t: CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055e,\r\n\t// \t\toriginEntityId: deadEntity.entityId,\r\n\t// \t\trepeats: multiplier > 1 ? multiplier : 1,\r\n\t// \t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t// \t});\r\n\t// \tgameState.spectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity, null, null);\r\n\t// }\r\n};\r\n\r\n// Some minions like Icesnarl can revive themselves when killing a minion, so it needs to be handled before\r\n// we actually make the minion die\r\nexport const handleWheneverMinionsKillEffect = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\thandleWheneverMinionsKillEffectForBoard(board, hero, otherBoard, otherHero, gameState);\r\n\t// It's called once for each board already, so don't duplicate it here\r\n\t// handleWheneverMinionsKillEffectForBoard(otherBoard, otherHero, board, hero, gameState);\r\n};\r\n\r\nconst handleWheneverMinionsKillEffectForBoard = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].health <= 0 || board[i].definitelyDead) {\r\n\t\t\tconst futureDeadEntity = board[i];\r\n\t\t\tconst killer = futureDeadEntity.lastAffectedByEntity;\r\n\t\t\tif (!killer) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Killed an enemy minion\r\n\t\t\tif (killer.friendly !== futureDeadEntity.friendly) {\r\n\t\t\t\tfor (const heroPower of otherHero.heroPowers) {\r\n\t\t\t\t\t// Can't be used to resurrect a dead minion\r\n\t\t\t\t\t// https://replays.firestoneapp.com/?reviewId=d1fffee8-0bc3-40f5-9a59-85eef8367095&turn=11&action=4\r\n\t\t\t\t\tif (heroPower.cardId === CardIds.Rokara_GloryOfCombat && !isDead(killer)) {\r\n\t\t\t\t\t\tmodifyStats(killer, otherHero, 1, 0, otherBoard, otherHero, gameState);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Icesnarl the Mighty\r\n\t\t\t\totherBoard\r\n\t\t\t\t\t.filter(\r\n\t\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\t\te.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy ||\r\n\t\t\t\t\t\t\te.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy_G,\r\n\t\t\t\t\t)\r\n\t\t\t\t\t// Can't be revived\r\n\t\t\t\t\t// 33.6 https://replays.firestoneapp.com/?reviewId=608ddffb-6c04-4def-a8de-fd39228f4de4&turn=11&action=4\r\n\t\t\t\t\t// Maybe should move to an \"after kill\" phase, where dead minions are already dead?\r\n\t\t\t\t\t.filter((e) => e.health > 0 && !e.definitelyDead)\r\n\t\t\t\t\t.forEach((icesnarl) => {\r\n\t\t\t\t\t\tconst mult = icesnarl.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy_G ? 2 : 1;\r\n\t\t\t\t\t\tmodifyStats(icesnarl, icesnarl, 0, 3 * mult, board, hero, gameState);\r\n\t\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const handleAfterMinionKillsEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// Moved to \"whenever kills\", as these can revive the minion that kills\r\n\t// const killer = deadEntity.lastAffectedByEntity;\r\n\t// if (!killer) {\r\n\t// \treturn;\r\n\t// }\r\n\t// // Killed an enemy minion\r\n\t// if (killer.friendly !== deadEntity.friendly) {\r\n\t// }\r\n};\r\n\r\nexport const applyAfterMinionDiesEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.DEMON, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplySoulJugglerEffect(boardWithDeadEntity, boardWithDeadEntityHero, otherBoard, otherBoardHero, gameState);\r\n\t}\r\n};\r\n\r\nexport const applyWheneverMinionDiesEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// console.log('applying minion death effect', stringifySimpleCard(deadEntity, allCards));\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.BEAST, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplyScavengingHyenaEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.MECH, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplyJunkbotEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.MURLOC, gameState.anomalies, gameState.allCards)) {\r\n\t\tremoveOldMurkEyeAttack(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\tremoveOldMurkEyeAttack(otherBoard, otherBoardHero, gameState);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.ELEMENTAL, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplyMossOfTheSchlossEffect(deadEntity, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\r\n\tif (deadEntity.taunt) {\r\n\t\tapplyBristlemaneScrapsmithEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\tapplyQirajiHarbringerEffect(boardWithDeadEntity, boardWithDeadEntityHero, deadEntityIndexFromRight, gameState);\r\n\t}\r\n\r\n\tif (\r\n\t\tdeadEntity.cardId === CardIds.EternalKnight_BG25_008 ||\r\n\t\tdeadEntity.cardId === CardIds.EternalKnight_BG25_008_G\r\n\t) {\r\n\t\tapplyEternalKnightEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\r\n\t// Putricide-only\r\n\tboardWithDeadEntity\r\n\t\t.filter((e) => e.additionalCards?.includes(CardIds.FlesheatingGhoulLegacy_BG26_tt_004))\r\n\t\t.forEach((e) => {\r\n\t\t\tmodifyStats(e, null, 1, 0, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t});\r\n\r\n\tapplyRotHideGnollEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\r\n\t// Overkill\r\n\tif (\r\n\t\tdeadEntity.health < 0 &&\r\n\t\tgameState.sharedState.currentAttackerEntityId != null &&\r\n\t\tgameState.sharedState.currentAttackerEntityId === deadEntity.lastAffectedByEntity?.entityId\r\n\t) {\r\n\t\t// if (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlame_BGS_032) {\r\n\t\t// \tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t// \tif (targets.length > 0) {\r\n\t\t// \t\tconst target = targets[0];\r\n\t\t// \t\tdealDamageToMinion(\r\n\t\t// \t\t\ttarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\t3,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tgameState,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlame_TB_BaconUps_103) {\r\n\t\t// \tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t// \tif (targets.length > 0) {\r\n\t\t// \t\tconst target = targets[0];\r\n\t\t// \t\tdealDamageToMinion(\r\n\t\t// \t\t\ttarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\t6,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tgameState,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// }\r\n\t\t// else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental && deadEntity.lastAffectedByEntity.attacking) {\r\n\t\t// \t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental) {\r\n\t\t// \t// console.log('applying WildfireElemental effect', stringifySimple(boardWithDeadEntity, allCards));\r\n\t\t// \tconst excessDamage = -deadEntity.health;\r\n\t\t// \t// Prevent propagation of the effect\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking = false;\r\n\t\t// \tconst neighbours = getNeighbours(boardWithDeadEntity, null, boardWithDeadEntity.length - deadEntityIndexFromRight);\r\n\t\t// \t// console.log('neighbours', stringifySimple(neighbours, allCards));\r\n\t\t// \tif (neighbours.length > 0) {\r\n\t\t// \t\tconst randomTarget = neighbours[Math.floor(Math.random() * neighbours.length)];\r\n\t\t// \t\tdealDamageToEnemy(\r\n\t\t// \t\t\trandomTarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\texcessDamage,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tallCards,\r\n\t\t// \t\t\tcardsData,\r\n\t\t// \t\t\tsharedState,\r\n\t\t// \t\t\tspectator,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// } else if (\r\n\t\t// \tdeadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElementalBattlegrounds &&\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking\r\n\t\t// ) {\r\n\t\t// \tconst excessDamage = -deadEntity.health;\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking = false;\r\n\t\t// \tconst neighbours = getNeighbours(boardWithDeadEntity, null, boardWithDeadEntity.length - deadEntityIndexFromRight);\r\n\t\t// \tneighbours.forEach((neighbour) =>\r\n\t\t// \t\tdealDamageToEnemy(\r\n\t\t// \t\t\tneighbour,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\texcessDamage,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tallCards,\r\n\t\t// \t\t\tcardsData,\r\n\t\t// \t\t\tsharedState,\r\n\t\t// \t\t\tspectator,\r\n\t\t// \t\t),\r\n\t\t// \t);\r\n\t\t// }\r\n\t\tif (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn_TRL_232) {\r\n\t\t\tconst newEntities = spawnEntities(\r\n\t\t\t\tCardIds.IronhideDirehorn_IronhideRuntToken_TRL_232t,\r\n\t\t\t\t1,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\t!deadEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t\totherBoard.splice(otherBoard.length - deadEntityIndexFromRight, 0, ...newEntities);\r\n\t\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn_TB_BaconUps_051) {\r\n\t\t\t// \tconst newEntities = spawnEntities(\r\n\t\t\t// \t\tCardIds.IronhideDirehorn_IronhideRuntToken_TB_BaconUps_051t,\r\n\t\t\t// \t\t1,\r\n\t\t\t// \t\totherBoard,\r\n\t\t\t// \t\totherBoardHero,\r\n\t\t\t// \t\tboardWithDeadEntity,\r\n\t\t\t// \t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\tgameState,\r\n\t\t\t// \t\t!deadEntity.friendly,\r\n\t\t\t// \t\tfalse,\r\n\t\t\t// \t);\r\n\t\t\t// \totherBoard.splice(otherBoard.length - deadEntityIndexFromRight, 0, ...newEntities);\r\n\t\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath_BGS_080) {\r\n\t\t\t// \tconst otherPirates = otherBoard\r\n\t\t\t// \t\t.filter((entity) =>\r\n\t\t\t// \t\t\thasCorrectTribe(\r\n\t\t\t// \t\t\t\tentity,\r\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\t\tRace.PIRATE,\r\n\t\t\t// \t\t\t\tgameState.anomalies,\r\n\t\t\t// \t\t\t\tgameState.allCards,\r\n\t\t\t// \t\t\t),\r\n\t\t\t// \t\t)\r\n\t\t\t// \t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\t// \totherPirates.forEach((pirate) => {\r\n\t\t\t// \t\tmodifyStats(\r\n\t\t\t// \t\t\tpirate,\r\n\t\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t// \t\t\t2,\r\n\t\t\t// \t\t\t2,\r\n\t\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t\t// \t\t\tboardWithDeadEntityHero,\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// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath_TB_BaconUps_142) {\r\n\t\t\t// \tconst otherPirates = otherBoard\r\n\t\t\t// \t\t.filter((entity) =>\r\n\t\t\t// \t\t\thasCorrectTribe(\r\n\t\t\t// \t\t\t\tentity,\r\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\t\tRace.PIRATE,\r\n\t\t\t// \t\t\t\tgameState.anomalies,\r\n\t\t\t// \t\t\t\tgameState.allCards,\r\n\t\t\t// \t\t\t),\r\n\t\t\t// \t\t)\r\n\t\t\t// \t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\t// \totherPirates.forEach((pirate) => {\r\n\t\t\t// \t\tmodifyStats(\r\n\t\t\t// \t\t\tpirate,\r\n\t\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t// \t\t\t4,\r\n\t\t\t// \t\t\t4,\r\n\t\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t\t// \t\t\tboardWithDeadEntityHero,\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}\r\n\t}\r\n};\r\n\r\n/** @deprecated */\r\nexport const dealDamageToAllMinions = (\r\n\tboard1: BoardEntity[],\r\n\tboard1Hero: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tboard2Hero: BgsPlayerEntity,\r\n\tdamageSource: BoardEntity,\r\n\tdamageDealt: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (board1.length === 0 && board2.length === 0) {\r\n\t\treturn;\r\n\t}\r\n\tfor (let i = 0; i < board1.length; i++) {\r\n\t\tdealDamageToMinion(board1[i], board1, board1Hero, damageSource, damageDealt, board2, board2Hero, gameState);\r\n\t}\r\n\tfor (let i = 0; i < board2.length; i++) {\r\n\t\tdealDamageToMinion(board2[i], board2, board2Hero, damageSource, damageDealt, board1, board1Hero, gameState);\r\n\t}\r\n};\r\n\r\nexport const applySoulJugglerEffect = (\r\n\tboardWithJugglers: BoardEntity[],\r\n\tboardWithJugglersHero: BgsPlayerEntity,\r\n\tboardToAttack: BoardEntity[],\r\n\tboardToAttackHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (boardWithJugglers.length === 0 && boardToAttack.length === 0) {\r\n\t\treturn;\r\n\t\t// return [boardWithJugglers, boardToAttack];\r\n\t}\r\n\tconst jugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler_BGS_002);\r\n\tfor (const juggler of jugglers) {\r\n\t\tconst target = getRandomMinionWithHighestHealth(boardToAttack);\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tjuggler,\r\n\t\t\ttarget,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tboardToAttackHero,\r\n\t\t);\r\n\t\tdealDamageToMinion(\r\n\t\t\ttarget,\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t4,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\tconst goldenJugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler_TB_BaconUps_075);\r\n\tfor (const juggler of goldenJugglers) {\r\n\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\tconst target = getRandomMinionWithHighestHealth(boardToAttack);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tjuggler,\r\n\t\t\t\ttarget,\r\n\t\t\t\tboardWithJugglers,\r\n\t\t\t\tboardWithJugglersHero,\r\n\t\t\t\tboardToAttackHero,\r\n\t\t\t);\r\n\t\t\tdealDamageToMinion(\r\n\t\t\t\ttarget,\r\n\t\t\t\tboardToAttack,\r\n\t\t\t\tboardToAttackHero,\r\n\t\t\t\tjuggler,\r\n\t\t\t\t4,\r\n\t\t\t\tboardWithJugglers,\r\n\t\t\t\tboardWithJugglersHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\t// processMinionDeath(\r\n\t// \tboardWithJugglers,\r\n\t// \tboardWithJugglersHero,\r\n\t// \tboardToAttack,\r\n\t// \tboardToAttackHero,\r\n\t// \tallCards,\r\n\t// \tcardsData,\r\n\t// \tsharedState,\r\n\t// \tspectator,\r\n\t// );\r\n};\r\n\r\nconst applyScavengingHyenaEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// const copy = [...board];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.ScavengingHyenaLegacy_BG_EX1_531) {\r\n\t\t\tmodifyStats(board[i], null, 2, 1, board, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t} else if (board[i].cardId === CardIds.ScavengingHyenaLegacy_TB_BaconUps_043) {\r\n\t\t\tmodifyStats(board[i], null, 4, 2, board, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyEternalKnightEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (\r\n\t\t\tboard[i].cardId === CardIds.EternalKnight_BG25_008 ||\r\n\t\t\tboard[i].cardId === CardIds.EternalKnight_BG25_008_G\r\n\t\t) {\r\n\t\t\tconst multiplier = board[i].cardId === CardIds.EternalKnight_BG25_008_G ? 2 : 1;\r\n\t\t\tmodifyStats(\r\n\t\t\t\tboard[i],\r\n\t\t\t\tnull,\r\n\t\t\t\tmultiplier * eternalKnightAttack,\r\n\t\t\t\tmultiplier * eternalKnightHealth,\r\n\t\t\t\tboard,\r\n\t\t\t\thero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyRotHideGnollEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.RotHideGnoll_BG25_013 || board[i].cardId === CardIds.RotHideGnoll_BG25_013_G) {\r\n\t\t\tconst multiplier = board[i].cardId === CardIds.RotHideGnoll_BG25_013_G ? 2 : 1;\r\n\t\t\tmodifyStats(board[i], null, multiplier * 1, 0, board, hero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyBristlemaneScrapsmithEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardPlayerEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (\r\n\t\t\tboard[i].cardId === CardIds.BristlemaneScrapsmith_BG24_707 ||\r\n\t\t\tboard[i].cardId === CardIds.BristlemaneScrapsmith_BG24_707_G\r\n\t\t) {\r\n\t\t\tconst cardsToAdd = Array(CardIds.BristlemaneScrapsmith_BG24_707_G ? 2 : 1).fill(CardIds.BloodGem);\r\n\t\t\taddCardsInHand(boardPlayerEntity, board, cardsToAdd, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, boardPlayerEntity, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyMossOfTheSchlossEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tboard\r\n\t\t.filter(\r\n\t\t\t(e) => e.cardId === CardIds.MossOfTheSchloss_BG30_111 || e.cardId === CardIds.MossOfTheSchloss_BG30_111_G,\r\n\t\t)\r\n\t\t.filter((e) => e.abiityChargesLeft > 0)\r\n\t\t.forEach((entity) => {\r\n\t\t\tmodifyStats(entity, null, deadEntity.maxAttack, deadEntity.maxHealth, board, hero, gameState);\r\n\t\t\tentity.abiityChargesLeft--;\r\n\t\t\tgameState.spectator.registerPowerTarget(entity, entity, board, null, null);\r\n\t\t});\r\n};\r\n\r\nconst applyJunkbotEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.Junkbot_GVG_106) {\r\n\t\t\tmodifyStats(board[i], board[i], 2, 2, board, hero, gameState);\r\n\t\t\t// } else if (board[i].cardId === CardIds.Junkbot_TB_BaconUps_046) {\r\n\t\t\t// \tmodifyStats(board[i], board[i], 4, 4, board, hero, gameState);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyQirajiHarbringerEffect = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// const qiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger_BGS_112);\r\n\t// const goldenQiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger_TB_BaconUps_303);\r\n\t// // TODO: if reactivated, properly apply buffs one by one, instead of all together\r\n\t// if (qiraji.length + goldenQiraji.length > 0) {\r\n\t// \tconst neighbours = getNeighbours(board, null, deadEntityIndexFromRight);\r\n\t// \tconst buff = 2 * qiraji.length + 4 * goldenQiraji.length;\r\n\t// \tneighbours.forEach((entity) => {\r\n\t// \t\tmodifyStats(entity, null, buff, buff, board, hero, gameState);\r\n\t// \t});\r\n\t// }\r\n};\r\n\r\nexport const rememberDeathrattles = (\r\n\tfish: BoardEntity,\r\n\tinputDeadEntities: readonly BoardEntity[],\r\n\tcardsData: CardsData,\r\n\tallCards: AllCardsService,\r\n\tsharedState: SharedState,\r\n): void => {\r\n\tconst deadEntities = inputDeadEntities.filter((e) => !isFish(e));\r\n\tif (!deadEntities?.length) {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// Some infinite loops going on?\r\n\tif (fish.rememberedDeathrattles?.length > 100) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst debug = deadEntities.some((e) => e.cardId === CardIds.CorruptedBristler_BG32_431);\r\n\r\n\tconst validDeathrattles = deadEntities\r\n\t\t.filter((entity) => allCards.getCard(entity.cardId).mechanics?.includes(GameTag[GameTag.DEATHRATTLE]))\r\n\t\t.filter((e) => !DEATHRATTLES_REQUIRE_MEMORY.includes(e.cardId as CardIds) || e.memory)\r\n\t\t.map((entity) => ({\r\n\t\t\tcardId: entity.cardId,\r\n\t\t\trepeats: 1,\r\n\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t\tmemory: entity.memory,\r\n\t\t\tscriptDataNum1: entity.scriptDataNum1,\r\n\t\t\tscriptDataNum2: entity.scriptDataNum2,\r\n\t\t}));\r\n\tconst validEnchantments = deadEntities\r\n\t\t.map((entity) => entity.enchantments)\r\n\t\t.reduce((a, b) => a.concat(b), [])\r\n\t\t.flatMap((enchantment) => ({\r\n\t\t\tcardId: enchantment.cardId,\r\n\t\t\trepeats: enchantment.repeats ?? 1,\r\n\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t}))\r\n\t\t.filter((enchantment) => isValidDeathrattleEnchantment(enchantment.cardId));\r\n\t// Multiple fish\r\n\tconst deadEntityRememberedDeathrattles =\r\n\t\tdeadEntities\r\n\t\t\t.filter((e) => !!e.rememberedDeathrattles?.length)\r\n\t\t\t// If the fish has reborn, it will inherit its own Deathrattles, and we don't want that\r\n\t\t\t.filter((e) => e.entityId !== fish.rebornFromEntityId)\r\n\t\t\t.filter((e) => !DEATHRATTLES_REQUIRE_MEMORY.includes(e.cardId as CardIds) || e.memory)\r\n\t\t\t.flatMap((e) => e.rememberedDeathrattles) ?? [];\r\n\tconst newDeathrattles = [...validDeathrattles, ...validEnchantments, ...deadEntityRememberedDeathrattles];\r\n\r\n\tif (newDeathrattles.length > 0) {\r\n\t\t// Order is important - the DR are triggered in the order d the minions have died\r\n\t\t// The \"golden\" part is handled at the card level for the other non-fish cards, like Piloted Whirl-o-Tron\r\n\t\tif (isFish(fish) && isGolden(fish.cardId, allCards)) {\r\n\t\t\t// https://stackoverflow.com/questions/33305152/how-to-duplicate-elements-in-a-js-array\r\n\t\t\tconst doubleDr = newDeathrattles.reduce((res, current) => res.concat([current, current]), []);\r\n\t\t\tfish.rememberedDeathrattles = [...(fish.rememberedDeathrattles || []), ...doubleDr];\r\n\t\t} else {\r\n\t\t\tfish.rememberedDeathrattles = [...(fish.rememberedDeathrattles || []), ...newDeathrattles];\r\n\t\t}\r\n\r\n\t\tif (\r\n\t\t\tnewDeathrattles.some(\r\n\t\t\t\t(d) =>\r\n\t\t\t\t\td.cardId?.startsWith(CardIds.Leapfrogger_BG21_000) ||\r\n\t\t\t\t\td.cardId?.startsWith(CardIds.TimewarpedLeapfrogger_BG34_Giant_031),\r\n\t\t\t)\r\n\t\t) {\r\n\t\t\t// Not sure exactly why, but if a leapfrogger dies first, then a manasaber,\r\n\t\t\t// when the fish dies, the manasaber's effect (spawning tokens) is triggered first\r\n\t\t\t// https://replays.firestoneapp.com/?reviewId=521733fb-8ba1-4663-9a87-3da58e8a09c8&turn=21&action=3\r\n\t\t\t// HACK: So I will hardcode a rule for now to put leapfrogger effects last\r\n\t\t\tconst leapfroggerDeathrattles = groupLeapfroggerDeathrattles(fish.rememberedDeathrattles);\r\n\t\t\tfish.rememberedDeathrattles = [\r\n\t\t\t\t...fish.rememberedDeathrattles.filter(\r\n\t\t\t\t\t(d) =>\r\n\t\t\t\t\t\t!d.cardId?.startsWith(CardIds.Leapfrogger_BG21_000) &&\r\n\t\t\t\t\t\t!d.cardId?.startsWith(CardIds.TimewarpedLeapfrogger_BG34_Giant_031),\r\n\t\t\t\t),\r\n\t\t\t\t...leapfroggerDeathrattles,\r\n\t\t\t];\r\n\t\t}\r\n\t}\r\n\t// console.debug(\r\n\t// \t'remembered',\r\n\t// \tfish.cardId,\r\n\t// \tfish.entityId,\r\n\t// \tfish.rememberedDeathrattles.map((d) => ({\r\n\t// \t\tcardId: d.cardId,\r\n\t// \t\tname: allCards.getCard(d.cardId)?.name,\r\n\t// \t\t// repeats: d.repeats,\r\n\t// \t\t// timing: d.timing,\r\n\t// \t})),\r\n\t// );\r\n};\r\n\r\nconst removeOldMurkEyeAttack = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\t// const murkeyes = boardWithDeadEntity.filter(\r\n\t// \t(entity) => entity.cardId === CardIds.OldMurkEyeLegacy || entity.cardId === CardIds.OldMurkEyeVanilla,\r\n\t// );\r\n\t// const goldenMurkeyes = boardWithDeadEntity.filter((entity) => entity.cardId === CardIds.OldMurkEye);\r\n\t// murkeyes.forEach((entity) => {\r\n\t// \tmodifyStats(entity, null, -1, 0, boardWithDeadEntity, hero, gameState);\r\n\t// });\r\n\t// goldenMurkeyes.forEach((entity) => {\r\n\t// \tmodifyStats(entity, null, -2, 0, boardWithDeadEntity, hero, gameState);\r\n\t// });\r\n};\r\n"]}
@@ -77,8 +77,8 @@ const spawnEntitiesFromDeathrattle = (deadEntity, deadEntityIndexFromRight, boar
77
77
  ((_d = (_c = b.entityId) !== null && _c !== void 0 ? _c : b.timing) !== null && _d !== void 0 ? _d : 0);
78
78
  });
79
79
  for (let i = 0; i < multiplier; i++) {
80
- let hasTriggered = false;
81
80
  for (const card of cards) {
81
+ let hasTriggered = false;
82
82
  const spawnedEntities = [];
83
83
  const refCard = gameState.allCards.getCard(card.cardId);
84
84
  if (((_a = refCard.type) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === reference_data_1.CardType[reference_data_1.CardType.MINION] &&
@@ -520,16 +520,6 @@ const spawnEntitiesFromDeathrattle = (deadEntity, deadEntityIndexFromRight, boar
520
520
  }
521
521
  }
522
522
  break;
523
- case "BG30_MagicItem_917e":
524
- (0, cards_in_hand_1.addCardsInHand)(boardWithDeadEntityHero, boardWithDeadEntity, [null], gameState);
525
- break;
526
- case "BG30_MagicItem_411e":
527
- (0, cards_in_hand_1.addCardsInHand)(boardWithDeadEntityHero, boardWithDeadEntity, ["BG20_GEM"], gameState);
528
- break;
529
- case "BG21_000e":
530
- case "BG21_000_Ge":
531
- (0, deathrattle_effects_1.applyLeapFroggerEffect)(boardWithDeadEntity, boardWithDeadEntityHero, deadEntity, deadEntityCardId === "BG21_000_Ge", gameState, 1);
532
- break;
533
523
  default:
534
524
  if ((_e = deadEntity.additionalCards) === null || _e === void 0 ? void 0 : _e.includes(deadEntityCardId)) {
535
525
  if (!(0, utils_2.hasMechanic)(gameState.allCards.getCard(deadEntityCardId), reference_data_1.GameTag.DEATHRATTLE)) {
@@ -605,6 +595,16 @@ const spawnEntitiesFromDeathrattle = (deadEntity, deadEntityIndexFromRight, boar
605
595
  case "BG30_MagicItem_952e":
606
596
  spawnedEntities.push(...(0, exports.spawnEntities)("BG26_537", 1, boardWithDeadEntity, boardWithDeadEntityHero, otherBoard, otherBoardHero, gameState, deadEntity.friendly, false));
607
597
  break;
598
+ case "BG30_MagicItem_917e":
599
+ (0, cards_in_hand_1.addCardsInHand)(boardWithDeadEntityHero, boardWithDeadEntity, [null], gameState);
600
+ break;
601
+ case "BG30_MagicItem_411e":
602
+ (0, cards_in_hand_1.addCardsInHand)(boardWithDeadEntityHero, boardWithDeadEntity, ["BG20_GEM"], gameState);
603
+ break;
604
+ case "BG21_000e":
605
+ case "BG21_000_Ge":
606
+ (0, deathrattle_effects_1.applyLeapFroggerEffect)(boardWithDeadEntity, boardWithDeadEntityHero, deadEntity, enchantment.cardId === "BG21_000_Ge", gameState, enchantment.repeats || 1);
607
+ break;
608
608
  default:
609
609
  hasTriggeredThisLoop = false;
610
610
  break;
@@ -616,9 +616,9 @@ const spawnEntitiesFromDeathrattle = (deadEntity, deadEntityIndexFromRight, boar
616
616
  finalSpawns.push(...actualSpawns);
617
617
  }
618
618
  }
619
- }
620
- if (hasTriggered) {
621
- (0, deathrattle_on_trigger_1.onDeathrattleTriggered)(deathrattleTriggeredInput);
619
+ if (hasTriggered) {
620
+ (0, deathrattle_on_trigger_1.onDeathrattleTriggered)(deathrattleTriggeredInput);
621
+ }
622
622
  }
623
623
  }
624
624
  return finalSpawns;