@firestone-hs/simulate-bgs-battle 1.1.314 → 1.1.316

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.
@@ -440,7 +440,10 @@ const applyLeapFroggerEffect = (boardWithDeadEntity, deadEntity, isPremium, allC
440
440
  const applyRecurringNightmareDeathrattleEffect = (boardWithDeadEntity, deadEntity, isPremium, allCards, spectator, sharedState, multiplier = 1) => {
441
441
  var _a;
442
442
  multiplier = multiplier || 1;
443
- const target = (0, utils_1.pickRandom)(boardWithDeadEntity.filter((e) => e.cardId !== "BG26_055" && e.cardId !== "BG26_055_G"));
443
+ const target = (0, utils_1.pickRandom)(boardWithDeadEntity
444
+ .filter((e) => (0, utils_2.hasCorrectTribe)(e, reference_data_1.Race.UNDEAD, allCards))
445
+ .filter((e) => e.cardId !== "BG26_055" &&
446
+ e.cardId !== "BG26_055_G"));
444
447
  if (target) {
445
448
  target.enchantments = (_a = target.enchantments) !== null && _a !== void 0 ? _a : [];
446
449
  target.enchantments.push({
@@ -1 +1 @@
1
- {"version":3,"file":"deathrattle-effects.js","sourceRoot":"","sources":["../../src/simulation/deathrattle-effects.ts"],"names":[],"mappings":";;;AACA,iEAA8E;AAI9E,6CAA6F;AAC7F,oCAgBkB;AAClB,qCAAyG;AACzG,+CAAiD;AACjD,6DAAqD;AAI9C,MAAM,4BAA4B,GAAG,CAC3C,KAAoB,EACpB,SAA0B,EAC1B,UAAuB,EACvB,WAAwB,EACf,EAAE;;IACX,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAC7B,CAAC,MAAM,EAAE,EAAE,CACV,MAAM,CAAC,MAAM,iBAAsC,IAAI,MAAM,CAAC,MAAM,eAAsC,CAC3G,CAAC;IACF,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,CACjC,CAAC,MAAM,EAAE,EAAE,CACV,MAAM,CAAC,MAAM,sBAA2C;QACxD,MAAM,CAAC,MAAM,iBAAwC,CACtD,C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,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAC;KACpF;SAAM;QACN,IAAI,CAAC,sBAAsB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,IAAI,EAAE,CAAC,EAAE,GAAG,eAAe,CAAC,CAAC;KAC3F;AAEF,CAAC,CAAC;AAzDW,QAAA,oBAAoB,wBAyD/B;AAEF,MAAM,sBAAsB,GAAG,CAAC,mBAAkC,EAAE,QAAyB,EAAE,EAAE;IAChG,MAAM,QAAQ,GAAG,mBAAmB,CAAC,MAAM,CAC1C,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,cAA6B,IAAI,MAAM,CAAC,MAAM,kBAA8B,CACrG,CAAC;IACF,MAAM,cAAc,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,sBAAuB,CAAC,CAAC;IACpG,QAAQ,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QAC3B,IAAA,oBAAY,EAAC,MAAM,EAAE,CAAC,CAAC,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC;QACxD,IAAA,wBAAgB,EAAC,MAAM,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IACH,cAAc,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QACjC,IAAA,oBAAY,EAAC,MAAM,EAAE,CAAC,CAAC,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC;QACxD,IAAA,wBAAgB,EAAC,MAAM,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds, 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 { groupByFunction, pickMultipleRandomDifferent, pickRandom } from '../services/utils';\r\nimport {\r\n\taddCardsInHand,\r\n\taddStatsToBoard,\r\n\tafterStatsUpdate,\r\n\tgrantRandomAttack,\r\n\tgrantRandomDivineShield,\r\n\tgrantRandomHealth,\r\n\tgrantRandomStats,\r\n\thasCorrectTribe,\r\n\tisCorrectTribe,\r\n\tisFish,\r\n\tisGolden,\r\n\tmakeMinionGolden,\r\n\tmodifyAttack,\r\n\tmodifyHealth,\r\n\tupdateDivineShield,\r\n} from '../utils';\r\nimport { dealDamageToEnemy, dealDamageToRandomEnemy, findNearestEnemies, getNeighbours } from './attack';\r\nimport { triggerBattlecry } from './battlecries';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { SharedState } from './shared-state';\r\nimport { Spectator } from './spectator/spectator';\r\n\r\nexport const computeDeathrattleMultiplier = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tsharedState: SharedState,\r\n): number => {\r\n\tconst rivendare = !!board.find(\r\n\t\t(entity) =>\r\n\t\t\tentity.cardId === CardIds.BaronRivendare_BG_FP1_031 || entity.cardId === CardIds.MoiraBronzebeard_BG27_518,\r\n\t);\r\n\tconst goldenRivendare = board.find(\r\n\t\t(entity) =>\r\n\t\t\tentity.cardId === CardIds.BaronRivendare_TB_BaconUps_055 ||\r\n\t\t\tentity.cardId === CardIds.MoiraBronzebeard_BG27_518_G,\r\n\t);\r\n\tconst titus = board.filter((entity) => entity.cardId === CardIds.TitusRivendare_BG25_354).length;\r\n\tconst goldenTitus = board.filter((entity) => entity.cardId === CardIds.TitusRivendare_BG25_354_G).length;\r\n\tconst tombs =\r\n\t\tboardHero.questRewardEntities?.filter((entity) => entity.cardId === CardIds.TurbulentTombs)?.length ?? 0;\r\n\tconst echoesOfArgus = sharedState.anomalies.includes(CardIds.EchoesOfArgus_BG27_Anomaly_802) ? 1 : 0;\r\n\tconst scourgeMultiplier = deadEntity.additionalCards?.includes(CardIds.ScourgeTroll) ? 2 : 1;\r\n\tconst multiplier =\r\n\t\tscourgeMultiplier *\r\n\t\t((goldenRivendare ? 3 : rivendare ? 2 : 1) + titus + 2 * goldenTitus + tombs + echoesOfArgus);\r\n\treturn multiplier;\r\n};\r\n\r\nexport const handleDeathrattleEffects = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst multiplier = computeDeathrattleMultiplier(\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tdeadEntity,\r\n\t\tsharedState,\r\n\t);\r\n\t// We do it on a case by case basis so that we deal all the damage in one go for instance\r\n\t// and avoid proccing deathrattle spawns between the times the damage triggers\r\n\r\n\tconst cardIds = [deadEntity.cardId, ...(deadEntity.additionalCards ?? [])];\r\n\tfor (const deadEntityCardId of cardIds) {\r\n\t\tswitch (deadEntityCardId) {\r\n\t\t\tcase CardIds.RylakMetalhead_BG26_801:\r\n\t\t\tcase CardIds.RylakMetalhead_BG26_801_G:\r\n\t\t\t\tconst rylakMutltiplier = deadEntityCardId === CardIds.RylakMetalhead_BG26_801_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst neighbours = getNeighbours(boardWithDeadEntity, null, deadEntityIndexFromRight);\r\n\t\t\t\t\tfor (const neighbour of neighbours) {\r\n\t\t\t\t\t\tspectator.registerPowerTarget(deadEntity, neighbour, boardWithDeadEntity);\r\n\t\t\t\t\t\tfor (let j = 0; j < rylakMutltiplier; j++) {\r\n\t\t\t\t\t\t\ttriggerBattlecry(\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\tneighbour,\r\n\t\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SelflessHero_BG_OG_221:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomDivineShield(deadEntity, boardWithDeadEntity, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SelflessHero_TB_BaconUps_014:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomDivineShield(deadEntity, boardWithDeadEntity, allCards, spectator);\r\n\t\t\t\t\tgrantRandomDivineShield(deadEntity, boardWithDeadEntity, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.OperaticBelcher_BG26_888:\r\n\t\t\tcase CardIds.OperaticBelcher_BG26_888_G:\r\n\t\t\t\tconst belcherMultiplier = deadEntityCardId === CardIds.OperaticBelcher_BG26_888_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < belcherMultiplier; j++) {\r\n\t\t\t\t\t\tconst possibleBelcherTargets = boardWithDeadEntity\r\n\t\t\t\t\t\t\t.filter((entity) => !entity.venomous)\r\n\t\t\t\t\t\t\t.filter((entity) => !entity.poisonous)\r\n\t\t\t\t\t\t\t.filter((entity) => entity.health > 0 && !entity.definitelyDead)\r\n\t\t\t\t\t\t\t.filter((entity) => hasCorrectTribe(entity, Race.MURLOC, allCards));\r\n\t\t\t\t\t\tif (possibleBelcherTargets.length > 0) {\r\n\t\t\t\t\t\t\tconst chosen = pickRandom(possibleBelcherTargets);\r\n\t\t\t\t\t\t\tchosen.venomous = true;\r\n\t\t\t\t\t\t\tspectator.registerPowerTarget(deadEntity, chosen, boardWithDeadEntity);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SpiritOfAir_TB_BaconShop_HERO_76_Buddy:\r\n\t\t\tcase CardIds.SpiritOfAir_TB_BaconShop_HERO_76_Buddy_G:\r\n\t\t\t\tconst iterations = deadEntityCardId === CardIds.SpiritOfAir_TB_BaconShop_HERO_76_Buddy_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < iterations; j++) {\r\n\t\t\t\t\t\tlet validTargets = boardWithDeadEntity.filter((entity) => !entity.divineShield);\r\n\t\t\t\t\t\tif (!validTargets?.length) {\r\n\t\t\t\t\t\t\tvalidTargets = boardWithDeadEntity.filter((entity) => !entity.taunt);\r\n\t\t\t\t\t\t\tif (!validTargets?.length) {\r\n\t\t\t\t\t\t\t\tvalidTargets = boardWithDeadEntity.filter((entity) => !entity.windfury);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tconst target = pickRandom(validTargets);\r\n\t\t\t\t\t\tif (target) {\r\n\t\t\t\t\t\t\tif (!target.divineShield) {\r\n\t\t\t\t\t\t\t\tupdateDivineShield(target, boardWithDeadEntity, true, allCards);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\ttarget.taunt = true;\r\n\t\t\t\t\t\t\ttarget.windfury = true;\r\n\t\t\t\t\t\t\tspectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.NadinaTheRed_BGS_040:\r\n\t\t\tcase CardIds.NadinaTheRed_TB_BaconUps_154:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst nadinaMultiplier = deadEntityCardId === CardIds.NadinaTheRed_TB_BaconUps_154 ? 6 : 3;\r\n\t\t\t\t\tfor (let j = 0; j < nadinaMultiplier; j++) {\r\n\t\t\t\t\t\tconst validTargets = boardWithDeadEntity\r\n\t\t\t\t\t\t\t.filter((e) => hasCorrectTribe(e, Race.DRAGON, allCards))\r\n\t\t\t\t\t\t\t.filter((entity) => !entity.divineShield);\r\n\t\t\t\t\t\tconst target = pickRandom(validTargets);\r\n\t\t\t\t\t\tif (target) {\r\n\t\t\t\t\t\t\tupdateDivineShield(target, boardWithDeadEntity, true, allCards);\r\n\t\t\t\t\t\t\tspectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SpawnOfNzoth_BG_OG_256:\r\n\t\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, multiplier * 1, multiplier * 1, allCards, spectator);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SpawnOfNzoth_TB_BaconUps_025:\r\n\t\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, multiplier * 2, multiplier * 2, allCards, spectator);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.GoldrinnTheGreatWolf_BGS_018:\r\n\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tmultiplier * 5,\r\n\t\t\t\t\tmultiplier * 5,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t\t'BEAST',\r\n\t\t\t\t);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.GoldrinnTheGreatWolf_TB_BaconUps_085:\r\n\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tmultiplier * 10,\r\n\t\t\t\t\tmultiplier * 10,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t\t'BEAST',\r\n\t\t\t\t);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.KingBagurgle_BGS_030:\r\n\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tmultiplier * 2,\r\n\t\t\t\t\tmultiplier * 3,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t\t'MURLOC',\r\n\t\t\t\t);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.KingBagurgle_TB_BaconUps_100:\r\n\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tmultiplier * 4,\r\n\t\t\t\t\tmultiplier * 6,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t\t'MURLOC',\r\n\t\t\t\t);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.FiendishServant_YOD_026:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomAttack(deadEntity, boardWithDeadEntity, deadEntity.attack, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.FiendishServant_TB_BaconUps_112:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomAttack(deadEntity, boardWithDeadEntity, deadEntity.attack, allCards, spectator);\r\n\t\t\t\t\tgrantRandomAttack(deadEntity, boardWithDeadEntity, deadEntity.attack, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ImpulsiveTrickster_BG21_006:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomHealth(deadEntity, boardWithDeadEntity, deadEntity.maxHealth, allCards, spectator, true);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ImpulsiveTrickster_BG21_006_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomHealth(deadEntity, boardWithDeadEntity, deadEntity.maxHealth, allCards, spectator, true);\r\n\t\t\t\t\tgrantRandomHealth(deadEntity, boardWithDeadEntity, deadEntity.maxHealth, allCards, spectator, true);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Leapfrogger_BG21_000:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, deadEntity, false, allCards, spectator, sharedState);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Leapfrogger_BG21_000_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, deadEntity, true, allCards, spectator, sharedState);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.PalescaleCrocolisk_BG21_001:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst target = grantRandomStats(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t6,\r\n\t\t\t\t\t\t6,\r\n\t\t\t\t\t\tRace.BEAST,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (!!target) {\r\n\t\t\t\t\t\tspectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity);\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.PalescaleCrocolisk_BG21_001_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst target = grantRandomStats(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t12,\r\n\t\t\t\t\t\t12,\r\n\t\t\t\t\t\tRace.BEAST,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (!!target) {\r\n\t\t\t\t\t\tspectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity);\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.ScarletSkull_BG25_022:\r\n\t\t\tcase CardIds.ScarletSkull_BG25_022_G:\r\n\t\t\t\tconst scarletMultiplier = deadEntityCardId === CardIds.ScarletSkull_BG25_022_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst target = grantRandomStats(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tscarletMultiplier * 1,\r\n\t\t\t\t\t\tscarletMultiplier * 2,\r\n\t\t\t\t\t\tRace.UNDEAD,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (!!target) {\r\n\t\t\t\t\t\tspectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity);\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.AnubarakNerubianKing_BG25_007:\r\n\t\t\tcase CardIds.AnubarakNerubianKing_BG25_007_G:\r\n\t\t\t\tconst anubarakMultiplier = deadEntityCardId === CardIds.AnubarakNerubianKing_BG25_007_G ? 2 : 1;\r\n\t\t\t\tconst attackBonus = anubarakMultiplier * 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tboardWithDeadEntityHero.globalInfo.UndeadAttackBonus += attackBonus;\r\n\t\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tattackBonus,\r\n\t\t\t\t\t\t0,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t\tRace[Race.UNDEAD],\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t// case CardIds.ElementiumSquirrelBombBattlegrounds_TB_BaconShop_HERO_17_Buddy:\r\n\t\t\t// \t// FIXME: I don't think this way of doing things is really accurate (as some deathrattles\r\n\t\t\t// \t// could be spawned between the shots firing), but let's say it's good enough for now\r\n\t\t\t// \tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t// \t\tconst numberOfDeadMechsThisCombat = sharedState.deaths\r\n\t\t\t// \t\t\t.filter((entity) => entity.friendly === deadEntity.friendly)\r\n\t\t\t// \t\t\t// eslint-disable-next-line prettier/prettier\r\n\t\t\t// \t\t\t.filter((entity) => isCorrectTribe(allCards.getCard(entity.cardId)?.races, Race.MECH)).length;\r\n\t\t\t// \t\tfor (let j = 0; j < numberOfDeadMechsThisCombat + 1; j++) {\r\n\t\t\t// \t\t\tdealDamageToRandomEnemy(\r\n\t\t\t// \t\t\t\totherBoard,\r\n\t\t\t// \t\t\t\totherBoardHero,\r\n\t\t\t// \t\t\t\tdeadEntity,\r\n\t\t\t// \t\t\t\t3,\r\n\t\t\t// \t\t\t\tboardWithDeadEntity,\r\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\t\tallCards,\r\n\t\t\t// \t\t\t\tcardsData,\r\n\t\t\t// \t\t\t\tsharedState,\r\n\t\t\t// \t\t\t\tspectator,\r\n\t\t\t// \t\t\t);\r\n\t\t\t// \t\t}\r\n\t\t\t// \t}\r\n\t\t\t// \tbreak;\r\n\t\t\tcase CardIds.ElementiumSquirrelBomb_TB_BaconShop_HERO_17_Buddy:\r\n\t\t\tcase CardIds.ElementiumSquirrelBomb_TB_BaconShop_HERO_17_Buddy_G:\r\n\t\t\t\t// FIXME: I don't think this way of doing things is really accurate (as some deathrattles\r\n\t\t\t\t// could be spawned between the shots firing), but let's say it's good enough for now\r\n\t\t\t\tconst squirrelDamage =\r\n\t\t\t\t\tdeadEntity.cardId === CardIds.ElementiumSquirrelBomb_TB_BaconShop_HERO_17_Buddy_G ? 4 : 2;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst numberOfDeadMechsThisCombat = sharedState.deaths\r\n\t\t\t\t\t\t.filter((entity) => entity.friendly === deadEntity.friendly)\r\n\t\t\t\t\t\t// eslint-disable-next-line prettier/prettier\r\n\t\t\t\t\t\t.filter((entity) => isCorrectTribe(allCards.getCard(entity.cardId)?.races, Race.MECH)).length;\r\n\t\t\t\t\tfor (let j = 0; j < numberOfDeadMechsThisCombat + 1; j++) {\r\n\t\t\t\t\t\tdealDamageToRandomEnemy(\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\tsquirrelDamage,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.KaboomBot_BG_BOT_606:\r\n\t\t\tcase CardIds.KaboomBot_TB_BaconUps_028:\r\n\t\t\t\t// FIXME: I don't think this way of doing things is really accurate (as some deathrattles\r\n\t\t\t\t// could be spawned between the shots firing), but let's say it's good enough for now\r\n\t\t\t\tconst kaboomLoops = deadEntity.cardId === CardIds.KaboomBot_TB_BaconUps_028 ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < kaboomLoops; j++) {\r\n\t\t\t\t\t\tdealDamageToRandomEnemy(\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t4,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.DrBoombox_BG25_165:\r\n\t\t\tcase CardIds.DrBoombox_BG25_165_G:\r\n\t\t\t\t// FIXME: I don't think this way of doing things is really accurate (as some deathrattles\r\n\t\t\t\t// could be spawned between the shots firing), but let's say it's good enough for now\r\n\t\t\t\tconst boomboxDamage = deadEntity.cardId === CardIds.DrBoombox_BG25_165_G ? 14 : 7;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\t// The nearest enemies use the full board info\r\n\t\t\t\t\t// const boardIncludingDeadEntityAtCorrectIndex = boardWithDeadEntity.splice(\r\n\t\t\t\t\t// \tdeadEntityIndexFromRight,\r\n\t\t\t\t\t// \t0,\r\n\t\t\t\t\t// \tdeadEntity,\r\n\t\t\t\t\t// );\r\n\t\t\t\t\tconst targets = findNearestEnemies(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\tdeadEntityIndexFromRight,\r\n\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t2,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t);\r\n\t\t\t\t\ttargets.forEach((target) => {\r\n\t\t\t\t\t\t// console.debug('dealing damage to', stringifySimpleCard(target));\r\n\t\t\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\tboomboxDamage,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.UnstableGhoul_BG_FP1_024:\r\n\t\t\tcase CardIds.UnstableGhoul_TB_BaconUps_118:\r\n\t\t\t\tconst damage = deadEntityCardId === CardIds.UnstableGhoul_TB_BaconUps_118 ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tdealDamageToAllMinions(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tdamage,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\tspectator,\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.TunnelBlaster_BG_DAL_775:\r\n\t\t\tcase CardIds.TunnelBlaster_BG_DAL_775_G:\r\n\t\t\t\tconst loops = deadEntityCardId === CardIds.TunnelBlaster_BG_DAL_775_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < loops; j++) {\r\n\t\t\t\t\t\tdealDamageToAllMinions(\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t3,\r\n\t\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.LeeroyTheReckless_BG23_318:\r\n\t\t\tcase CardIds.LeeroyTheReckless_BG23_318_G:\r\n\t\t\t\tif (deadEntity.lastAffectedByEntity) {\r\n\t\t\t\t\tdeadEntity.lastAffectedByEntity.definitelyDead = true;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.RadioStar_BG25_399:\r\n\t\t\tcase CardIds.RadioStar_BG25_399_G:\r\n\t\t\t\tconst radioQuantity = deadEntityCardId === CardIds.RadioStar_BG25_399_G ? 2 : 1;\r\n\t\t\t\tconst radioEntities = Array(radioQuantity).fill(deadEntity.lastAffectedByEntity);\r\n\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, allCards, spectator, radioEntities);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SrTombDiver_TB_BaconShop_HERO_41_Buddy:\r\n\t\t\t\tfor (let i = 0; i < Math.min(1, boardWithDeadEntity.length); i++) {\r\n\t\t\t\t\tconst rightMostMinion = boardWithDeadEntity[boardWithDeadEntity.length - 1 - i];\r\n\t\t\t\t\tif (rightMostMinion) {\r\n\t\t\t\t\t\tmakeMinionGolden(rightMostMinion, deadEntity, boardWithDeadEntity, allCards, spectator);\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.SrTombDiver_TB_BaconShop_HERO_41_Buddy_G:\r\n\t\t\t\tfor (let i = 0; i < Math.min(2, boardWithDeadEntity.length); i++) {\r\n\t\t\t\t\tconst rightMostMinion = boardWithDeadEntity[boardWithDeadEntity.length - 1 - i];\r\n\t\t\t\t\tif (rightMostMinion) {\r\n\t\t\t\t\t\tmakeMinionGolden(rightMostMinion, deadEntity, boardWithDeadEntity, allCards, spectator);\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.Scourfin_BG26_360:\r\n\t\t\tcase CardIds.Scourfin_BG26_360_G:\r\n\t\t\t\tconst statsScourfin = deadEntityCardId === CardIds.Scourfin_BG26_360_G ? 10 : 5;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomStats(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero.hand,\r\n\t\t\t\t\t\tstatsScourfin,\r\n\t\t\t\t\t\tstatsScourfin,\r\n\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tnull,\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.SanguineChampion_BG23_017:\r\n\t\t\tcase CardIds.SanguineChampion_BG23_017_G:\r\n\t\t\t\tconst sanguineChampionStats = deadEntityCardId === CardIds.SanguineChampion_BG23_017 ? 1 : 2;\r\n\t\t\t\tboardWithDeadEntityHero.globalInfo.BloodGemAttackBonus += sanguineChampionStats;\r\n\t\t\t\tboardWithDeadEntityHero.globalInfo.BloodGemHealthBonus += sanguineChampionStats;\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t// Putricide-only\r\n\t\t\tcase CardIds.Banshee_BG_RLK_957:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, 2, 1, allCards, spectator, Race[Race.UNDEAD]);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.LostSpirit_BG26_GIL_513:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, 1, 0, allCards, spectator, null);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.TickingAbomination_BG_ICC_099:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (const entity of boardWithDeadEntity) {\r\n\t\t\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\t\t\tentity,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t5,\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.WitheredSpearhide_BG27_006:\r\n\t\t\tcase CardIds.WitheredSpearhide_BG27_006_G:\r\n\t\t\t\tconst witheredSpearhideCardsToAdd = Array(CardIds.WitheredSpearhide_BG27_006_G ? 2 : 1).fill(\r\n\t\t\t\t\tCardIds.BloodGem,\r\n\t\t\t\t);\r\n\t\t\t\taddCardsInHand(\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t\twitheredSpearhideCardsToAdd,\r\n\t\t\t\t);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.RecurringNightmare_BG26_055:\r\n\t\t\tcase CardIds.RecurringNightmare_BG26_055_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyRecurringNightmareDeathrattleEffect(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tdeadEntityCardId === CardIds.RecurringNightmare_BG26_055_G,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t\tsharedState,\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\t// It's important to first copy the enchantments, otherwise you could end up\r\n\t// in an infinite loop - since new enchants are added after each step\r\n\r\n\tlet enchantments: { cardId: string; originEntityId?: number; repeats?: number }[] = [\r\n\t\t...(deadEntity.enchantments ?? []),\r\n\t\t...(deadEntity.rememberedDeathrattles ?? []),\r\n\t].sort((a, b) => a.timing - b.timing);\r\n\t// In some cases it's possible that there are way too many enchantments because of the frog\r\n\t// In that case, we make a trade-off and don't trigger the \"on stats change\" trigger as\r\n\t// often as we should, so that we can have the stats themselves correct\r\n\t// We don't want to lump everything together, as it skews the stats when there are a lot of buffs\r\n\t// Instead, we build groups\r\n\tconst maxNumberOfGroups = 12;\r\n\tconst enchantmentGroups = groupByFunction((enchantment: any) => enchantment.cardId)(enchantments);\r\n\tenchantments = Object.keys(enchantmentGroups).flatMap((cardId) => {\r\n\t\tlet repeatsToApply = enchantmentGroups[cardId].map((e) => e.repeats || 1).reduce((a, b) => a + b, 0);\r\n\r\n\t\t// Frogs include the multiplers here directly\r\n\t\tif (\r\n\t\t\t[\r\n\t\t\t\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e,\r\n\t\t\t\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge,\r\n\t\t\t].includes(cardId as CardIds)\r\n\t\t) {\r\n\t\t\trepeatsToApply = repeatsToApply * multiplier;\r\n\t\t}\r\n\r\n\t\tconst results = [];\r\n\t\tconst repeatsPerBuff = Math.max(1, Math.floor(repeatsToApply / maxNumberOfGroups));\r\n\t\tlet repeatsDone = 0;\r\n\t\twhile (repeatsDone < repeatsToApply) {\r\n\t\t\tconst repeats = Math.min(repeatsPerBuff, repeatsToApply - repeatsDone);\r\n\t\t\tresults.push({\r\n\t\t\t\tcardId: cardId,\r\n\t\t\t\trepeats: repeats,\r\n\t\t\t\ttiming: Math.min(...enchantmentGroups[cardId].map((e) => e.timing)),\r\n\t\t\t});\r\n\t\t\trepeatsDone += repeatsPerBuff;\r\n\t\t}\r\n\t\treturn results;\r\n\t});\r\n\tfor (const enchantment of enchantments) {\r\n\t\tswitch (enchantment.cardId) {\r\n\t\t\tcase CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e:\r\n\t\t\tcase CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge:\r\n\t\t\t\tapplyLeapFroggerEffect(\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tenchantment.cardId === CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t\tsharedState,\r\n\t\t\t\t\tenchantment.repeats || 1,\r\n\t\t\t\t);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.EarthRecollectionEnchantment:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyEarthInvocationEnchantment(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\tspectator,\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.FireRecollectionEnchantment:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyFireInvocationEnchantment(boardWithDeadEntity, deadEntity, deadEntity, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.WaterRecollectionEnchantment:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyWaterInvocationEnchantment(boardWithDeadEntity, deadEntity, deadEntity, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.LightningRecollectionEnchantment:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyLightningInvocationEnchantment(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\tspectator,\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\t// const playerCopy = boardWithDeadEntity.map((e) => ({ ...e, lastAffectedByEntity: null }));\r\n\t// const oppCopy = otherBoard.map((e) => ({ ...e, lastAffectedByEntity: null }));\r\n\t// console.log('player board', boardWithDeadEntity.length, playerCopy.length, playerCopy.map((e) => JSON.stringify(e)).join('\\n'));\r\n\t// console.log('opp board', JSON.stringify(oppCopy));\r\n};\r\n\r\nexport const applyLightningInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// Because the golden version doubles all the remembered effects\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst targets = pickMultipleRandomDifferent(otherBoard, 5);\r\n\t\tfor (const target of targets) {\r\n\t\t\tdealDamageToEnemy(\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\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyWaterInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\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[boardWithDeadEntity.length - 1];\r\n\t\tif (!!target) {\r\n\t\t\tmodifyHealth(target, 3, boardWithDeadEntity, allCards);\r\n\t\t\ttarget.taunt = true;\r\n\t\t\tafterStatsUpdate(target, boardWithDeadEntity, allCards);\r\n\t\t\tspectator.registerPowerTarget(sourceEntity, target, boardWithDeadEntity);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyFireInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\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[0];\r\n\t\tif (!!target) {\r\n\t\t\tmodifyAttack(target, target.attack, boardWithDeadEntity, allCards);\r\n\t\t\tafterStatsUpdate(target, boardWithDeadEntity, allCards);\r\n\t\t\tspectator.registerPowerTarget(sourceEntity, target, boardWithDeadEntity);\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\tallCards: AllCardsService,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\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: sharedState.currentEntityId++,\r\n\t\t\t});\r\n\t\t\tspectator.registerPowerTarget(sourceEntity, minion, boardWithDeadEntity);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nconst applyLeapFroggerEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tsharedState: SharedState,\r\n\tmultiplier = 1,\r\n): void => {\r\n\tmultiplier = multiplier || 1;\r\n\tconst buffed = grantRandomStats(\r\n\t\tdeadEntity,\r\n\t\tboardWithDeadEntity,\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\tallCards,\r\n\t\tspectator,\r\n\t);\r\n\tif (buffed) {\r\n\t\tbuffed.enchantments = buffed.enchantments ?? [];\r\n\t\tbuffed.enchantments.push({\r\n\t\t\tcardId: isPremium\r\n\t\t\t\t? CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge\r\n\t\t\t\t: CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e,\r\n\t\t\toriginEntityId: deadEntity.entityId,\r\n\t\t\trepeats: multiplier > 1 ? multiplier : 1,\r\n\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t});\r\n\t\t// Don't register power effect here, since it's already done in the random stats\r\n\t\t// spectator.registerPowerTarget(deadEntity, buffed, boardWithDeadEntity);\r\n\t\t// console.log('applyLeapFroggerEffect', stringifySimpleCard(deadEntity), stringifySimpleCard(buffed));\r\n\t}\r\n};\r\n\r\nconst applyRecurringNightmareDeathrattleEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tsharedState: SharedState,\r\n\tmultiplier = 1,\r\n): void => {\r\n\tmultiplier = multiplier || 1;\r\n\tconst target = pickRandom(\r\n\t\tboardWithDeadEntity.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId !== CardIds.RecurringNightmare_BG26_055 && e.cardId !== CardIds.RecurringNightmare_BG26_055_G,\r\n\t\t),\r\n\t);\r\n\tif (target) {\r\n\t\ttarget.enchantments = target.enchantments ?? [];\r\n\t\ttarget.enchantments.push({\r\n\t\t\tcardId: isPremium\r\n\t\t\t\t? CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055_Ge\r\n\t\t\t\t: CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055e,\r\n\t\t\toriginEntityId: deadEntity.entityId,\r\n\t\t\trepeats: multiplier > 1 ? multiplier : 1,\r\n\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t});\r\n\t\tspectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity);\r\n\t}\r\n};\r\n\r\nexport const applyMinionDeathEffect = (\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\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// console.log('applying minion death effect', stringifySimpleCard(deadEntity, allCards));\r\n\tif (isCorrectTribe(allCards.getCard(deadEntity.cardId).races, Race.BEAST)) {\r\n\t\tapplyScavengingHyenaEffect(boardWithDeadEntity, allCards, spectator);\r\n\t}\r\n\tif (isCorrectTribe(allCards.getCard(deadEntity.cardId).races, Race.DEMON)) {\r\n\t\tapplySoulJugglerEffect(\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\tif (isCorrectTribe(allCards.getCard(deadEntity.cardId).races, Race.MECH)) {\r\n\t\tapplyJunkbotEffect(boardWithDeadEntity, allCards, spectator);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, Race.MURLOC, allCards)) {\r\n\t\tremoveOldMurkEyeAttack(boardWithDeadEntity, allCards);\r\n\t\tremoveOldMurkEyeAttack(otherBoard, allCards);\r\n\t}\r\n\tif (deadEntity.taunt) {\r\n\t\tapplyBristlemaneScrapsmithEffect(boardWithDeadEntity, boardWithDeadEntityHero, allCards, spectator);\r\n\t\tapplyQirajiHarbringerEffect(boardWithDeadEntity, deadEntityIndexFromRight, allCards, spectator);\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, allCards, spectator);\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\tmodifyAttack(e, 1, boardWithDeadEntity, allCards);\r\n\t\t\tafterStatsUpdate(e, boardWithDeadEntity, allCards);\r\n\t\t});\r\n\r\n\tapplyRotHideGnollEffect(boardWithDeadEntity, allCards, spectator);\r\n\r\n\t// Overkill\r\n\tif (deadEntity.health < 0 && deadEntity.lastAffectedByEntity?.attacking) {\r\n\t\tif (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlame_BGS_032) {\r\n\t\t\tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t\tif (targets.length > 0) {\r\n\t\t\t\tconst target = targets[0];\r\n\t\t\t\tdealDamageToEnemy(\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\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 (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\tdealDamageToEnemy(\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\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\t// else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental && deadEntity.lastAffectedByEntity.attacking) {\r\n\t\t// \t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental) {\r\n\t\t// \t// console.log('applying WildfireElemental effect', stringifySimple(boardWithDeadEntity, allCards));\r\n\t\t// \tconst excessDamage = -deadEntity.health;\r\n\t\t// \t// Prevent propagation of the effect\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking = false;\r\n\t\t// \tconst neighbours = getNeighbours(boardWithDeadEntity, null, boardWithDeadEntity.length - deadEntityIndexFromRight);\r\n\t\t// \t// console.log('neighbours', stringifySimple(neighbours, allCards));\r\n\t\t// \tif (neighbours.length > 0) {\r\n\t\t// \t\tconst randomTarget = neighbours[Math.floor(Math.random() * neighbours.length)];\r\n\t\t// \t\tdealDamageToEnemy(\r\n\t\t// \t\t\trandomTarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\texcessDamage,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tallCards,\r\n\t\t// \t\t\tcardsData,\r\n\t\t// \t\t\tsharedState,\r\n\t\t// \t\t\tspectator,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// } else if (\r\n\t\t// \tdeadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElementalBattlegrounds &&\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking\r\n\t\t// ) {\r\n\t\t// \tconst excessDamage = -deadEntity.health;\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking = false;\r\n\t\t// \tconst neighbours = getNeighbours(boardWithDeadEntity, null, boardWithDeadEntity.length - deadEntityIndexFromRight);\r\n\t\t// \tneighbours.forEach((neighbour) =>\r\n\t\t// \t\tdealDamageToEnemy(\r\n\t\t// \t\t\tneighbour,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\texcessDamage,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tallCards,\r\n\t\t// \t\t\tcardsData,\r\n\t\t// \t\t\tsharedState,\r\n\t\t// \t\t\tspectator,\r\n\t\t// \t\t),\r\n\t\t// \t);\r\n\t\t// }\r\n\t\telse if (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn_TRL_232) {\r\n\t\t\tconst newEntities = spawnEntities(\r\n\t\t\t\tCardIds.IronhideDirehorn_IronhideRuntToken_TRL_232t,\r\n\t\t\t\t1,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t\t!deadEntity.friendly,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t\totherBoard.splice(otherBoard.length - deadEntityIndexFromRight, 0, ...newEntities);\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn_TB_BaconUps_051) {\r\n\t\t\tconst newEntities = spawnEntities(\r\n\t\t\t\tCardIds.IronhideDirehorn_IronhideRuntToken_TB_BaconUps_051t,\r\n\t\t\t\t1,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t\t!deadEntity.friendly,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t\totherBoard.splice(otherBoard.length - deadEntityIndexFromRight, 0, ...newEntities);\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath_BGS_080) {\r\n\t\t\tconst otherPirates = otherBoard\r\n\t\t\t\t.filter((entity) => isCorrectTribe(allCards.getCard(entity.cardId).races, Race.PIRATE))\r\n\t\t\t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\totherPirates.forEach((pirate) => {\r\n\t\t\t\tmodifyAttack(pirate, 2, boardWithDeadEntity, allCards);\r\n\t\t\t\tmodifyHealth(pirate, 2, boardWithDeadEntity, allCards);\r\n\t\t\t\tafterStatsUpdate(pirate, boardWithDeadEntity, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(deadEntity.lastAffectedByEntity, pirate, otherBoard);\r\n\t\t\t});\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath_TB_BaconUps_142) {\r\n\t\t\tconst otherPirates = otherBoard\r\n\t\t\t\t.filter((entity) => isCorrectTribe(allCards.getCard(entity.cardId).races, Race.PIRATE))\r\n\t\t\t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\totherPirates.forEach((pirate) => {\r\n\t\t\t\tmodifyAttack(pirate, 4, boardWithDeadEntity, allCards);\r\n\t\t\t\tmodifyHealth(pirate, 4, boardWithDeadEntity, allCards);\r\n\t\t\t\tafterStatsUpdate(pirate, boardWithDeadEntity, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(deadEntity.lastAffectedByEntity, pirate, otherBoard);\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n};\r\n\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\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\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\tdealDamageToEnemy(\r\n\t\t\tboard1[i],\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdamageSource,\r\n\t\t\tdamageDealt,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\tfor (let i = 0; i < board2.length; i++) {\r\n\t\tdealDamageToEnemy(\r\n\t\t\tboard2[i],\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdamageSource,\r\n\t\t\tdamageDealt,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n};\r\n\r\nconst applySoulJugglerEffect = (\r\n\tboardWithJugglers: BoardEntity[],\r\n\tboardWithJugglersHero: BgsPlayerEntity,\r\n\tboardToAttack: BoardEntity[],\r\n\tboardToAttackHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (boardWithJugglers.length === 0 && boardToAttack.length === 0) {\r\n\t\treturn;\r\n\t\t// return [boardWithJugglers, boardToAttack];\r\n\t}\r\n\tconst jugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler_BGS_002);\r\n\tfor (const juggler of jugglers) {\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t3,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\tconst goldenJugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler_TB_BaconUps_075);\r\n\tfor (const juggler of goldenJugglers) {\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t3,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t3,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\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 = (board: BoardEntity[], allCards: AllCardsService, spectator: Spectator): 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\tmodifyAttack(board[i], 2, board, allCards);\r\n\t\t\tmodifyHealth(board[i], 1, board, allCards);\r\n\t\t\tafterStatsUpdate(board[i], board, allCards);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t} else if (board[i].cardId === CardIds.ScavengingHyenaLegacy_TB_BaconUps_043) {\r\n\t\t\tmodifyAttack(board[i], 4, board, allCards);\r\n\t\t\tmodifyHealth(board[i], 2, board, allCards);\r\n\t\t\tafterStatsUpdate(board[i], board, allCards);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyEternalKnightEffect = (board: BoardEntity[], allCards: AllCardsService, spectator: Spectator): 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\tmodifyAttack(board[i], multiplier * 1, board, allCards);\r\n\t\t\tmodifyHealth(board[i], multiplier * 1, board, allCards);\r\n\t\t\tafterStatsUpdate(board[i], board, allCards);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyRotHideGnollEffect = (board: BoardEntity[], allCards: AllCardsService, spectator: Spectator): 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\tmodifyAttack(board[i], multiplier * 1, board, allCards);\r\n\t\t\tafterStatsUpdate(board[i], board, allCards);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyBristlemaneScrapsmithEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardPlayerEntity: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\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, allCards, spectator, cardsToAdd);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyJunkbotEffect = (board: BoardEntity[], allCards: AllCardsService, spectator: Spectator): 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\tmodifyAttack(board[i], 2, board, allCards);\r\n\t\t\tmodifyHealth(board[i], 2, board, allCards);\r\n\t\t\tafterStatsUpdate(board[i], board, allCards);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t} else if (board[i].cardId === CardIds.Junkbot_TB_BaconUps_046) {\r\n\t\t\tmodifyAttack(board[i], 4, board, allCards);\r\n\t\t\tmodifyHealth(board[i], 4, board, allCards);\r\n\t\t\tafterStatsUpdate(board[i], board, allCards);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyQirajiHarbringerEffect = (\r\n\tboard: BoardEntity[],\r\n\tdeadEntityIndexFromRight: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst qiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger_BGS_112);\r\n\tconst goldenQiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger_TB_BaconUps_303);\r\n\tconst neighbours = getNeighbours(board, null, deadEntityIndexFromRight);\r\n\r\n\t// TODO: if reactivated, properly apply buffs one by one, instead of all together\r\n\tneighbours.forEach((entity) => {\r\n\t\tmodifyAttack(entity, 2 * qiraji.length + 4 * goldenQiraji.length, board, allCards);\r\n\t\tmodifyHealth(entity, 2 * qiraji.length + 4 * goldenQiraji.length, board, allCards);\r\n\t\tafterStatsUpdate(entity, board, allCards);\r\n\t});\r\n};\r\n\r\nexport const applyMonstrosity = (\r\n\tmonstrosity: BoardEntity,\r\n\tdeadEntities: readonly BoardEntity[],\r\n\tboardWithDeadEntities: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\tfor (const deadEntity of deadEntities) {\r\n\t\tmodifyAttack(monstrosity, deadEntity.attack, boardWithDeadEntities, allCards);\r\n\t\tif (monstrosity.cardId === CardIds.Monstrosity_BG20_HERO_282_Buddy_G) {\r\n\t\t\tmodifyAttack(monstrosity, deadEntity.attack, boardWithDeadEntities, allCards);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const rememberDeathrattles = (\r\n\tfish: BoardEntity,\r\n\tdeadEntities: readonly BoardEntity[],\r\n\tcardsData: CardsData,\r\n\tallCards: AllCardsService,\r\n\tsharedState: SharedState,\r\n): void => {\r\n\tconst validDeathrattles = deadEntities\r\n\t\t.filter((entity) => cardsData.validDeathrattles.includes(entity.cardId) || isFish(entity))\r\n\t\t.map((entity) => ({ cardId: entity.cardId, repeats: 1, timing: sharedState.currentEntityId++ }));\r\n\tconst validEnchantments = deadEntities\r\n\t\t.filter((entity) => entity.enchantments?.length)\r\n\t\t.map((entity) => entity.enchantments)\r\n\t\t.reduce((a, b) => a.concat(b), [])\r\n\t\t.flatMap((enchantment) => ({\r\n\t\t\tcardId: enchantment.cardId,\r\n\t\t\trepeats: enchantment.repeats ?? 1,\r\n\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t}))\r\n\t\t.filter((enchantment) =>\r\n\t\t\t[\r\n\t\t\t\tCardIds.ReplicatingMenace_ReplicatingMenaceEnchantment_BG_BOT_312e,\r\n\t\t\t\tCardIds.ReplicatingMenace_ReplicatingMenaceEnchantment_TB_BaconUps_032e,\r\n\t\t\t\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e,\r\n\t\t\t\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge,\r\n\t\t\t\tCardIds.LivingSpores_LivingSporesEnchantment,\r\n\t\t\t\tCardIds.SneedsReplicator_ReplicateEnchantment,\r\n\t\t\t\tCardIds.EarthInvocation_ElementEarthEnchantment,\r\n\t\t\t\tCardIds.FireInvocation_ElementFireEnchantment,\r\n\t\t\t\tCardIds.WaterInvocation_ElementWaterEnchantment,\r\n\t\t\t\tCardIds.LightningInvocation,\r\n\t\t\t\tCardIds.SurfNSurf_CrabRidingEnchantment_BG27_004e,\r\n\t\t\t\tCardIds.SurfNSurf_CrabRidingEnchantment_BG27_004_Ge,\r\n\t\t\t].includes(enchantment.cardId as CardIds),\r\n\t\t);\r\n\t// Multiple fish\r\n\tconst deadEntityRememberedDeathrattles =\r\n\t\tdeadEntities.filter((e) => !!e.rememberedDeathrattles?.length).flatMap((e) => e.rememberedDeathrattles) ?? [];\r\n\tconst newDeathrattles = [...validDeathrattles, ...validEnchantments, ...deadEntityRememberedDeathrattles];\r\n\t// Order is important - the DR are triggered in the ordered the minions have died\r\n\t// console.log(\r\n\t// \t'remembering deathrattle',\r\n\t// \t'\\n',\r\n\t// \tstringifySimpleCard(fish, allCards),\r\n\t// \t'\\n',\r\n\t// \tstringifySimple(deadEntities, allCards),\r\n\t// \t'\\n',\r\n\t// \tfish.rememberedDeathrattles,\r\n\t// );\r\n\tif (isGolden(fish.cardId, allCards)) {\r\n\t\t// https://stackoverflow.com/questions/33305152/how-to-duplicate-elements-in-a-js-array\r\n\t\tconst doubleDr = newDeathrattles.reduce((res, current) => res.concat([current, current]), []);\r\n\t\tfish.rememberedDeathrattles = [...(fish.rememberedDeathrattles || []), ...doubleDr];\r\n\t} else {\r\n\t\tfish.rememberedDeathrattles = [...(fish.rememberedDeathrattles || []), ...newDeathrattles];\r\n\t}\r\n\t// console.log('remembering deathrattle after', '\\n', fish.rememberedDeathrattles);\r\n};\r\n\r\nconst removeOldMurkEyeAttack = (boardWithDeadEntity: BoardEntity[], allCards: AllCardsService) => {\r\n\tconst murkeyes = boardWithDeadEntity.filter(\r\n\t\t(entity) => entity.cardId === CardIds.OldMurkEyeLegacy || entity.cardId === CardIds.OldMurkEyeVanilla,\r\n\t);\r\n\tconst goldenMurkeyes = boardWithDeadEntity.filter((entity) => entity.cardId === CardIds.OldMurkEye);\r\n\tmurkeyes.forEach((entity) => {\r\n\t\tmodifyAttack(entity, -1, boardWithDeadEntity, allCards);\r\n\t\tafterStatsUpdate(entity, boardWithDeadEntity, allCards);\r\n\t});\r\n\tgoldenMurkeyes.forEach((entity) => {\r\n\t\tmodifyAttack(entity, -2, boardWithDeadEntity, allCards);\r\n\t\tafterStatsUpdate(entity, boardWithDeadEntity, allCards);\r\n\t});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E,CAAC,MAAM,CAAC,MAAM,sBAAuB,CAAC,CAAC;IACpG,QAAQ,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QAC3B,IAAA,oBAAY,EAAC,MAAM,EAAE,CAAC,CAAC,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC;QACxD,IAAA,wBAAgB,EAAC,MAAM,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IACH,cAAc,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QACjC,IAAA,oBAAY,EAAC,MAAM,EAAE,CAAC,CAAC,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC;QACxD,IAAA,wBAAgB,EAAC,MAAM,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds, 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 { groupByFunction, pickMultipleRandomDifferent, pickRandom } from '../services/utils';\r\nimport {\r\n\taddCardsInHand,\r\n\taddStatsToBoard,\r\n\tafterStatsUpdate,\r\n\tgrantRandomAttack,\r\n\tgrantRandomDivineShield,\r\n\tgrantRandomHealth,\r\n\tgrantRandomStats,\r\n\thasCorrectTribe,\r\n\tisCorrectTribe,\r\n\tisFish,\r\n\tisGolden,\r\n\tmakeMinionGolden,\r\n\tmodifyAttack,\r\n\tmodifyHealth,\r\n\tupdateDivineShield,\r\n} from '../utils';\r\nimport { dealDamageToEnemy, dealDamageToRandomEnemy, findNearestEnemies, getNeighbours } from './attack';\r\nimport { triggerBattlecry } from './battlecries';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { SharedState } from './shared-state';\r\nimport { Spectator } from './spectator/spectator';\r\n\r\nexport const computeDeathrattleMultiplier = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tsharedState: SharedState,\r\n): number => {\r\n\tconst rivendare = !!board.find(\r\n\t\t(entity) =>\r\n\t\t\tentity.cardId === CardIds.BaronRivendare_BG_FP1_031 || entity.cardId === CardIds.MoiraBronzebeard_BG27_518,\r\n\t);\r\n\tconst goldenRivendare = board.find(\r\n\t\t(entity) =>\r\n\t\t\tentity.cardId === CardIds.BaronRivendare_TB_BaconUps_055 ||\r\n\t\t\tentity.cardId === CardIds.MoiraBronzebeard_BG27_518_G,\r\n\t);\r\n\tconst titus = board.filter((entity) => entity.cardId === CardIds.TitusRivendare_BG25_354).length;\r\n\tconst goldenTitus = board.filter((entity) => entity.cardId === CardIds.TitusRivendare_BG25_354_G).length;\r\n\tconst tombs =\r\n\t\tboardHero.questRewardEntities?.filter((entity) => entity.cardId === CardIds.TurbulentTombs)?.length ?? 0;\r\n\tconst echoesOfArgus = sharedState.anomalies.includes(CardIds.EchoesOfArgus_BG27_Anomaly_802) ? 1 : 0;\r\n\tconst scourgeMultiplier = deadEntity.additionalCards?.includes(CardIds.ScourgeTroll) ? 2 : 1;\r\n\tconst multiplier =\r\n\t\tscourgeMultiplier *\r\n\t\t((goldenRivendare ? 3 : rivendare ? 2 : 1) + titus + 2 * goldenTitus + tombs + echoesOfArgus);\r\n\treturn multiplier;\r\n};\r\n\r\nexport const handleDeathrattleEffects = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst multiplier = computeDeathrattleMultiplier(\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tdeadEntity,\r\n\t\tsharedState,\r\n\t);\r\n\t// We do it on a case by case basis so that we deal all the damage in one go for instance\r\n\t// and avoid proccing deathrattle spawns between the times the damage triggers\r\n\r\n\tconst cardIds = [deadEntity.cardId, ...(deadEntity.additionalCards ?? [])];\r\n\tfor (const deadEntityCardId of cardIds) {\r\n\t\tswitch (deadEntityCardId) {\r\n\t\t\tcase CardIds.RylakMetalhead_BG26_801:\r\n\t\t\tcase CardIds.RylakMetalhead_BG26_801_G:\r\n\t\t\t\tconst rylakMutltiplier = deadEntityCardId === CardIds.RylakMetalhead_BG26_801_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst neighbours = getNeighbours(boardWithDeadEntity, null, deadEntityIndexFromRight);\r\n\t\t\t\t\tfor (const neighbour of neighbours) {\r\n\t\t\t\t\t\tspectator.registerPowerTarget(deadEntity, neighbour, boardWithDeadEntity);\r\n\t\t\t\t\t\tfor (let j = 0; j < rylakMutltiplier; j++) {\r\n\t\t\t\t\t\t\ttriggerBattlecry(\r\n\t\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\t\tneighbour,\r\n\t\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SelflessHero_BG_OG_221:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomDivineShield(deadEntity, boardWithDeadEntity, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SelflessHero_TB_BaconUps_014:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomDivineShield(deadEntity, boardWithDeadEntity, allCards, spectator);\r\n\t\t\t\t\tgrantRandomDivineShield(deadEntity, boardWithDeadEntity, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.OperaticBelcher_BG26_888:\r\n\t\t\tcase CardIds.OperaticBelcher_BG26_888_G:\r\n\t\t\t\tconst belcherMultiplier = deadEntityCardId === CardIds.OperaticBelcher_BG26_888_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < belcherMultiplier; j++) {\r\n\t\t\t\t\t\tconst possibleBelcherTargets = boardWithDeadEntity\r\n\t\t\t\t\t\t\t.filter((entity) => !entity.venomous)\r\n\t\t\t\t\t\t\t.filter((entity) => !entity.poisonous)\r\n\t\t\t\t\t\t\t.filter((entity) => entity.health > 0 && !entity.definitelyDead)\r\n\t\t\t\t\t\t\t.filter((entity) => hasCorrectTribe(entity, Race.MURLOC, allCards));\r\n\t\t\t\t\t\tif (possibleBelcherTargets.length > 0) {\r\n\t\t\t\t\t\t\tconst chosen = pickRandom(possibleBelcherTargets);\r\n\t\t\t\t\t\t\tchosen.venomous = true;\r\n\t\t\t\t\t\t\tspectator.registerPowerTarget(deadEntity, chosen, boardWithDeadEntity);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SpiritOfAir_TB_BaconShop_HERO_76_Buddy:\r\n\t\t\tcase CardIds.SpiritOfAir_TB_BaconShop_HERO_76_Buddy_G:\r\n\t\t\t\tconst iterations = deadEntityCardId === CardIds.SpiritOfAir_TB_BaconShop_HERO_76_Buddy_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < iterations; j++) {\r\n\t\t\t\t\t\tlet validTargets = boardWithDeadEntity.filter((entity) => !entity.divineShield);\r\n\t\t\t\t\t\tif (!validTargets?.length) {\r\n\t\t\t\t\t\t\tvalidTargets = boardWithDeadEntity.filter((entity) => !entity.taunt);\r\n\t\t\t\t\t\t\tif (!validTargets?.length) {\r\n\t\t\t\t\t\t\t\tvalidTargets = boardWithDeadEntity.filter((entity) => !entity.windfury);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tconst target = pickRandom(validTargets);\r\n\t\t\t\t\t\tif (target) {\r\n\t\t\t\t\t\t\tif (!target.divineShield) {\r\n\t\t\t\t\t\t\t\tupdateDivineShield(target, boardWithDeadEntity, true, allCards);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\ttarget.taunt = true;\r\n\t\t\t\t\t\t\ttarget.windfury = true;\r\n\t\t\t\t\t\t\tspectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.NadinaTheRed_BGS_040:\r\n\t\t\tcase CardIds.NadinaTheRed_TB_BaconUps_154:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst nadinaMultiplier = deadEntityCardId === CardIds.NadinaTheRed_TB_BaconUps_154 ? 6 : 3;\r\n\t\t\t\t\tfor (let j = 0; j < nadinaMultiplier; j++) {\r\n\t\t\t\t\t\tconst validTargets = boardWithDeadEntity\r\n\t\t\t\t\t\t\t.filter((e) => hasCorrectTribe(e, Race.DRAGON, allCards))\r\n\t\t\t\t\t\t\t.filter((entity) => !entity.divineShield);\r\n\t\t\t\t\t\tconst target = pickRandom(validTargets);\r\n\t\t\t\t\t\tif (target) {\r\n\t\t\t\t\t\t\tupdateDivineShield(target, boardWithDeadEntity, true, allCards);\r\n\t\t\t\t\t\t\tspectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SpawnOfNzoth_BG_OG_256:\r\n\t\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, multiplier * 1, multiplier * 1, allCards, spectator);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SpawnOfNzoth_TB_BaconUps_025:\r\n\t\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, multiplier * 2, multiplier * 2, allCards, spectator);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.GoldrinnTheGreatWolf_BGS_018:\r\n\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tmultiplier * 5,\r\n\t\t\t\t\tmultiplier * 5,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t\t'BEAST',\r\n\t\t\t\t);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.GoldrinnTheGreatWolf_TB_BaconUps_085:\r\n\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tmultiplier * 10,\r\n\t\t\t\t\tmultiplier * 10,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t\t'BEAST',\r\n\t\t\t\t);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.KingBagurgle_BGS_030:\r\n\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tmultiplier * 2,\r\n\t\t\t\t\tmultiplier * 3,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t\t'MURLOC',\r\n\t\t\t\t);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.KingBagurgle_TB_BaconUps_100:\r\n\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tmultiplier * 4,\r\n\t\t\t\t\tmultiplier * 6,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t\t'MURLOC',\r\n\t\t\t\t);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.FiendishServant_YOD_026:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomAttack(deadEntity, boardWithDeadEntity, deadEntity.attack, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.FiendishServant_TB_BaconUps_112:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomAttack(deadEntity, boardWithDeadEntity, deadEntity.attack, allCards, spectator);\r\n\t\t\t\t\tgrantRandomAttack(deadEntity, boardWithDeadEntity, deadEntity.attack, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ImpulsiveTrickster_BG21_006:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomHealth(deadEntity, boardWithDeadEntity, deadEntity.maxHealth, allCards, spectator, true);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ImpulsiveTrickster_BG21_006_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomHealth(deadEntity, boardWithDeadEntity, deadEntity.maxHealth, allCards, spectator, true);\r\n\t\t\t\t\tgrantRandomHealth(deadEntity, boardWithDeadEntity, deadEntity.maxHealth, allCards, spectator, true);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Leapfrogger_BG21_000:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, deadEntity, false, allCards, spectator, sharedState);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Leapfrogger_BG21_000_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, deadEntity, true, allCards, spectator, sharedState);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.PalescaleCrocolisk_BG21_001:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst target = grantRandomStats(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t6,\r\n\t\t\t\t\t\t6,\r\n\t\t\t\t\t\tRace.BEAST,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (!!target) {\r\n\t\t\t\t\t\tspectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity);\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.PalescaleCrocolisk_BG21_001_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst target = grantRandomStats(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t12,\r\n\t\t\t\t\t\t12,\r\n\t\t\t\t\t\tRace.BEAST,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (!!target) {\r\n\t\t\t\t\t\tspectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity);\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.ScarletSkull_BG25_022:\r\n\t\t\tcase CardIds.ScarletSkull_BG25_022_G:\r\n\t\t\t\tconst scarletMultiplier = deadEntityCardId === CardIds.ScarletSkull_BG25_022_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst target = grantRandomStats(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tscarletMultiplier * 1,\r\n\t\t\t\t\t\tscarletMultiplier * 2,\r\n\t\t\t\t\t\tRace.UNDEAD,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (!!target) {\r\n\t\t\t\t\t\tspectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity);\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.AnubarakNerubianKing_BG25_007:\r\n\t\t\tcase CardIds.AnubarakNerubianKing_BG25_007_G:\r\n\t\t\t\tconst anubarakMultiplier = deadEntityCardId === CardIds.AnubarakNerubianKing_BG25_007_G ? 2 : 1;\r\n\t\t\t\tconst attackBonus = anubarakMultiplier * 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tboardWithDeadEntityHero.globalInfo.UndeadAttackBonus += attackBonus;\r\n\t\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tattackBonus,\r\n\t\t\t\t\t\t0,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t\tRace[Race.UNDEAD],\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t// case CardIds.ElementiumSquirrelBombBattlegrounds_TB_BaconShop_HERO_17_Buddy:\r\n\t\t\t// \t// FIXME: I don't think this way of doing things is really accurate (as some deathrattles\r\n\t\t\t// \t// could be spawned between the shots firing), but let's say it's good enough for now\r\n\t\t\t// \tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t// \t\tconst numberOfDeadMechsThisCombat = sharedState.deaths\r\n\t\t\t// \t\t\t.filter((entity) => entity.friendly === deadEntity.friendly)\r\n\t\t\t// \t\t\t// eslint-disable-next-line prettier/prettier\r\n\t\t\t// \t\t\t.filter((entity) => isCorrectTribe(allCards.getCard(entity.cardId)?.races, Race.MECH)).length;\r\n\t\t\t// \t\tfor (let j = 0; j < numberOfDeadMechsThisCombat + 1; j++) {\r\n\t\t\t// \t\t\tdealDamageToRandomEnemy(\r\n\t\t\t// \t\t\t\totherBoard,\r\n\t\t\t// \t\t\t\totherBoardHero,\r\n\t\t\t// \t\t\t\tdeadEntity,\r\n\t\t\t// \t\t\t\t3,\r\n\t\t\t// \t\t\t\tboardWithDeadEntity,\r\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\t\tallCards,\r\n\t\t\t// \t\t\t\tcardsData,\r\n\t\t\t// \t\t\t\tsharedState,\r\n\t\t\t// \t\t\t\tspectator,\r\n\t\t\t// \t\t\t);\r\n\t\t\t// \t\t}\r\n\t\t\t// \t}\r\n\t\t\t// \tbreak;\r\n\t\t\tcase CardIds.ElementiumSquirrelBomb_TB_BaconShop_HERO_17_Buddy:\r\n\t\t\tcase CardIds.ElementiumSquirrelBomb_TB_BaconShop_HERO_17_Buddy_G:\r\n\t\t\t\t// FIXME: I don't think this way of doing things is really accurate (as some deathrattles\r\n\t\t\t\t// could be spawned between the shots firing), but let's say it's good enough for now\r\n\t\t\t\tconst squirrelDamage =\r\n\t\t\t\t\tdeadEntity.cardId === CardIds.ElementiumSquirrelBomb_TB_BaconShop_HERO_17_Buddy_G ? 4 : 2;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tconst numberOfDeadMechsThisCombat = sharedState.deaths\r\n\t\t\t\t\t\t.filter((entity) => entity.friendly === deadEntity.friendly)\r\n\t\t\t\t\t\t// eslint-disable-next-line prettier/prettier\r\n\t\t\t\t\t\t.filter((entity) => isCorrectTribe(allCards.getCard(entity.cardId)?.races, Race.MECH)).length;\r\n\t\t\t\t\tfor (let j = 0; j < numberOfDeadMechsThisCombat + 1; j++) {\r\n\t\t\t\t\t\tdealDamageToRandomEnemy(\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\tsquirrelDamage,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.KaboomBot_BG_BOT_606:\r\n\t\t\tcase CardIds.KaboomBot_TB_BaconUps_028:\r\n\t\t\t\t// FIXME: I don't think this way of doing things is really accurate (as some deathrattles\r\n\t\t\t\t// could be spawned between the shots firing), but let's say it's good enough for now\r\n\t\t\t\tconst kaboomLoops = deadEntity.cardId === CardIds.KaboomBot_TB_BaconUps_028 ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < kaboomLoops; j++) {\r\n\t\t\t\t\t\tdealDamageToRandomEnemy(\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t4,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.DrBoombox_BG25_165:\r\n\t\t\tcase CardIds.DrBoombox_BG25_165_G:\r\n\t\t\t\t// FIXME: I don't think this way of doing things is really accurate (as some deathrattles\r\n\t\t\t\t// could be spawned between the shots firing), but let's say it's good enough for now\r\n\t\t\t\tconst boomboxDamage = deadEntity.cardId === CardIds.DrBoombox_BG25_165_G ? 14 : 7;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\t// The nearest enemies use the full board info\r\n\t\t\t\t\t// const boardIncludingDeadEntityAtCorrectIndex = boardWithDeadEntity.splice(\r\n\t\t\t\t\t// \tdeadEntityIndexFromRight,\r\n\t\t\t\t\t// \t0,\r\n\t\t\t\t\t// \tdeadEntity,\r\n\t\t\t\t\t// );\r\n\t\t\t\t\tconst targets = findNearestEnemies(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\tdeadEntityIndexFromRight,\r\n\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t2,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t);\r\n\t\t\t\t\ttargets.forEach((target) => {\r\n\t\t\t\t\t\t// console.debug('dealing damage to', stringifySimpleCard(target));\r\n\t\t\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\tboomboxDamage,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.UnstableGhoul_BG_FP1_024:\r\n\t\t\tcase CardIds.UnstableGhoul_TB_BaconUps_118:\r\n\t\t\t\tconst damage = deadEntityCardId === CardIds.UnstableGhoul_TB_BaconUps_118 ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tdealDamageToAllMinions(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tdamage,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\tspectator,\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.TunnelBlaster_BG_DAL_775:\r\n\t\t\tcase CardIds.TunnelBlaster_BG_DAL_775_G:\r\n\t\t\t\tconst loops = deadEntityCardId === CardIds.TunnelBlaster_BG_DAL_775_G ? 2 : 1;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (let j = 0; j < loops; j++) {\r\n\t\t\t\t\t\tdealDamageToAllMinions(\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t3,\r\n\t\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.LeeroyTheReckless_BG23_318:\r\n\t\t\tcase CardIds.LeeroyTheReckless_BG23_318_G:\r\n\t\t\t\tif (deadEntity.lastAffectedByEntity) {\r\n\t\t\t\t\tdeadEntity.lastAffectedByEntity.definitelyDead = true;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.RadioStar_BG25_399:\r\n\t\t\tcase CardIds.RadioStar_BG25_399_G:\r\n\t\t\t\tconst radioQuantity = deadEntityCardId === CardIds.RadioStar_BG25_399_G ? 2 : 1;\r\n\t\t\t\tconst radioEntities = Array(radioQuantity).fill(deadEntity.lastAffectedByEntity);\r\n\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, allCards, spectator, radioEntities);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SrTombDiver_TB_BaconShop_HERO_41_Buddy:\r\n\t\t\t\tfor (let i = 0; i < Math.min(1, boardWithDeadEntity.length); i++) {\r\n\t\t\t\t\tconst rightMostMinion = boardWithDeadEntity[boardWithDeadEntity.length - 1 - i];\r\n\t\t\t\t\tif (rightMostMinion) {\r\n\t\t\t\t\t\tmakeMinionGolden(rightMostMinion, deadEntity, boardWithDeadEntity, allCards, spectator);\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.SrTombDiver_TB_BaconShop_HERO_41_Buddy_G:\r\n\t\t\t\tfor (let i = 0; i < Math.min(2, boardWithDeadEntity.length); i++) {\r\n\t\t\t\t\tconst rightMostMinion = boardWithDeadEntity[boardWithDeadEntity.length - 1 - i];\r\n\t\t\t\t\tif (rightMostMinion) {\r\n\t\t\t\t\t\tmakeMinionGolden(rightMostMinion, deadEntity, boardWithDeadEntity, allCards, spectator);\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.Scourfin_BG26_360:\r\n\t\t\tcase CardIds.Scourfin_BG26_360_G:\r\n\t\t\t\tconst statsScourfin = deadEntityCardId === CardIds.Scourfin_BG26_360_G ? 10 : 5;\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tgrantRandomStats(\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero.hand,\r\n\t\t\t\t\t\tstatsScourfin,\r\n\t\t\t\t\t\tstatsScourfin,\r\n\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tnull,\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.SanguineChampion_BG23_017:\r\n\t\t\tcase CardIds.SanguineChampion_BG23_017_G:\r\n\t\t\t\tconst sanguineChampionStats = deadEntityCardId === CardIds.SanguineChampion_BG23_017 ? 1 : 2;\r\n\t\t\t\tboardWithDeadEntityHero.globalInfo.BloodGemAttackBonus += sanguineChampionStats;\r\n\t\t\t\tboardWithDeadEntityHero.globalInfo.BloodGemHealthBonus += sanguineChampionStats;\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t// Putricide-only\r\n\t\t\tcase CardIds.Banshee_BG_RLK_957:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, 2, 1, allCards, spectator, Race[Race.UNDEAD]);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.LostSpirit_BG26_GIL_513:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, 1, 0, allCards, spectator, null);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.TickingAbomination_BG_ICC_099:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tfor (const entity of boardWithDeadEntity) {\r\n\t\t\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\t\t\tentity,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t5,\r\n\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.WitheredSpearhide_BG27_006:\r\n\t\t\tcase CardIds.WitheredSpearhide_BG27_006_G:\r\n\t\t\t\tconst witheredSpearhideCardsToAdd = Array(CardIds.WitheredSpearhide_BG27_006_G ? 2 : 1).fill(\r\n\t\t\t\t\tCardIds.BloodGem,\r\n\t\t\t\t);\r\n\t\t\t\taddCardsInHand(\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t\twitheredSpearhideCardsToAdd,\r\n\t\t\t\t);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.RecurringNightmare_BG26_055:\r\n\t\t\tcase CardIds.RecurringNightmare_BG26_055_G:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyRecurringNightmareDeathrattleEffect(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tdeadEntityCardId === CardIds.RecurringNightmare_BG26_055_G,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t\tsharedState,\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\t// It's important to first copy the enchantments, otherwise you could end up\r\n\t// in an infinite loop - since new enchants are added after each step\r\n\r\n\tlet enchantments: { cardId: string; originEntityId?: number; repeats?: number }[] = [\r\n\t\t...(deadEntity.enchantments ?? []),\r\n\t\t...(deadEntity.rememberedDeathrattles ?? []),\r\n\t].sort((a, b) => a.timing - b.timing);\r\n\t// In some cases it's possible that there are way too many enchantments because of the frog\r\n\t// In that case, we make a trade-off and don't trigger the \"on stats change\" trigger as\r\n\t// often as we should, so that we can have the stats themselves correct\r\n\t// We don't want to lump everything together, as it skews the stats when there are a lot of buffs\r\n\t// Instead, we build groups\r\n\tconst maxNumberOfGroups = 12;\r\n\tconst enchantmentGroups = groupByFunction((enchantment: any) => enchantment.cardId)(enchantments);\r\n\tenchantments = Object.keys(enchantmentGroups).flatMap((cardId) => {\r\n\t\tlet repeatsToApply = enchantmentGroups[cardId].map((e) => e.repeats || 1).reduce((a, b) => a + b, 0);\r\n\r\n\t\t// Frogs include the multiplers here directly\r\n\t\tif (\r\n\t\t\t[\r\n\t\t\t\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e,\r\n\t\t\t\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge,\r\n\t\t\t].includes(cardId as CardIds)\r\n\t\t) {\r\n\t\t\trepeatsToApply = repeatsToApply * multiplier;\r\n\t\t}\r\n\r\n\t\tconst results = [];\r\n\t\tconst repeatsPerBuff = Math.max(1, Math.floor(repeatsToApply / maxNumberOfGroups));\r\n\t\tlet repeatsDone = 0;\r\n\t\twhile (repeatsDone < repeatsToApply) {\r\n\t\t\tconst repeats = Math.min(repeatsPerBuff, repeatsToApply - repeatsDone);\r\n\t\t\tresults.push({\r\n\t\t\t\tcardId: cardId,\r\n\t\t\t\trepeats: repeats,\r\n\t\t\t\ttiming: Math.min(...enchantmentGroups[cardId].map((e) => e.timing)),\r\n\t\t\t});\r\n\t\t\trepeatsDone += repeatsPerBuff;\r\n\t\t}\r\n\t\treturn results;\r\n\t});\r\n\tfor (const enchantment of enchantments) {\r\n\t\tswitch (enchantment.cardId) {\r\n\t\t\tcase CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e:\r\n\t\t\tcase CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge:\r\n\t\t\t\tapplyLeapFroggerEffect(\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tenchantment.cardId === CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t\tsharedState,\r\n\t\t\t\t\tenchantment.repeats || 1,\r\n\t\t\t\t);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.EarthRecollectionEnchantment:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyEarthInvocationEnchantment(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\tspectator,\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.FireRecollectionEnchantment:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyFireInvocationEnchantment(boardWithDeadEntity, deadEntity, deadEntity, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.WaterRecollectionEnchantment:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyWaterInvocationEnchantment(boardWithDeadEntity, deadEntity, deadEntity, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.LightningRecollectionEnchantment:\r\n\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\tapplyLightningInvocationEnchantment(\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\tspectator,\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\t// const playerCopy = boardWithDeadEntity.map((e) => ({ ...e, lastAffectedByEntity: null }));\r\n\t// const oppCopy = otherBoard.map((e) => ({ ...e, lastAffectedByEntity: null }));\r\n\t// console.log('player board', boardWithDeadEntity.length, playerCopy.length, playerCopy.map((e) => JSON.stringify(e)).join('\\n'));\r\n\t// console.log('opp board', JSON.stringify(oppCopy));\r\n};\r\n\r\nexport const applyLightningInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// Because the golden version doubles all the remembered effects\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst targets = pickMultipleRandomDifferent(otherBoard, 5);\r\n\t\tfor (const target of targets) {\r\n\t\t\tdealDamageToEnemy(\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\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyWaterInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\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[boardWithDeadEntity.length - 1];\r\n\t\tif (!!target) {\r\n\t\t\tmodifyHealth(target, 3, boardWithDeadEntity, allCards);\r\n\t\t\ttarget.taunt = true;\r\n\t\t\tafterStatsUpdate(target, boardWithDeadEntity, allCards);\r\n\t\t\tspectator.registerPowerTarget(sourceEntity, target, boardWithDeadEntity);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyFireInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\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[0];\r\n\t\tif (!!target) {\r\n\t\t\tmodifyAttack(target, target.attack, boardWithDeadEntity, allCards);\r\n\t\t\tafterStatsUpdate(target, boardWithDeadEntity, allCards);\r\n\t\t\tspectator.registerPowerTarget(sourceEntity, target, boardWithDeadEntity);\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\tallCards: AllCardsService,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\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: sharedState.currentEntityId++,\r\n\t\t\t});\r\n\t\t\tspectator.registerPowerTarget(sourceEntity, minion, boardWithDeadEntity);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nconst applyLeapFroggerEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tsharedState: SharedState,\r\n\tmultiplier = 1,\r\n): void => {\r\n\tmultiplier = multiplier || 1;\r\n\tconst buffed = grantRandomStats(\r\n\t\tdeadEntity,\r\n\t\tboardWithDeadEntity,\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\tallCards,\r\n\t\tspectator,\r\n\t);\r\n\tif (buffed) {\r\n\t\tbuffed.enchantments = buffed.enchantments ?? [];\r\n\t\tbuffed.enchantments.push({\r\n\t\t\tcardId: isPremium\r\n\t\t\t\t? CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge\r\n\t\t\t\t: CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e,\r\n\t\t\toriginEntityId: deadEntity.entityId,\r\n\t\t\trepeats: multiplier > 1 ? multiplier : 1,\r\n\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t});\r\n\t\t// Don't register power effect here, since it's already done in the random stats\r\n\t\t// spectator.registerPowerTarget(deadEntity, buffed, boardWithDeadEntity);\r\n\t\t// console.log('applyLeapFroggerEffect', stringifySimpleCard(deadEntity), stringifySimpleCard(buffed));\r\n\t}\r\n};\r\n\r\nconst applyRecurringNightmareDeathrattleEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tsharedState: SharedState,\r\n\tmultiplier = 1,\r\n): void => {\r\n\tmultiplier = multiplier || 1;\r\n\tconst target = pickRandom(\r\n\t\tboardWithDeadEntity\r\n\t\t\t.filter((e) => hasCorrectTribe(e, Race.UNDEAD, allCards))\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId !== CardIds.RecurringNightmare_BG26_055 &&\r\n\t\t\t\t\te.cardId !== CardIds.RecurringNightmare_BG26_055_G,\r\n\t\t\t),\r\n\t);\r\n\tif (target) {\r\n\t\ttarget.enchantments = target.enchantments ?? [];\r\n\t\ttarget.enchantments.push({\r\n\t\t\tcardId: isPremium\r\n\t\t\t\t? CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055_Ge\r\n\t\t\t\t: CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055e,\r\n\t\t\toriginEntityId: deadEntity.entityId,\r\n\t\t\trepeats: multiplier > 1 ? multiplier : 1,\r\n\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t});\r\n\t\tspectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity);\r\n\t}\r\n};\r\n\r\nexport const applyMinionDeathEffect = (\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\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// console.log('applying minion death effect', stringifySimpleCard(deadEntity, allCards));\r\n\tif (isCorrectTribe(allCards.getCard(deadEntity.cardId).races, Race.BEAST)) {\r\n\t\tapplyScavengingHyenaEffect(boardWithDeadEntity, allCards, spectator);\r\n\t}\r\n\tif (isCorrectTribe(allCards.getCard(deadEntity.cardId).races, Race.DEMON)) {\r\n\t\tapplySoulJugglerEffect(\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\tif (isCorrectTribe(allCards.getCard(deadEntity.cardId).races, Race.MECH)) {\r\n\t\tapplyJunkbotEffect(boardWithDeadEntity, allCards, spectator);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, Race.MURLOC, allCards)) {\r\n\t\tremoveOldMurkEyeAttack(boardWithDeadEntity, allCards);\r\n\t\tremoveOldMurkEyeAttack(otherBoard, allCards);\r\n\t}\r\n\tif (deadEntity.taunt) {\r\n\t\tapplyBristlemaneScrapsmithEffect(boardWithDeadEntity, boardWithDeadEntityHero, allCards, spectator);\r\n\t\tapplyQirajiHarbringerEffect(boardWithDeadEntity, deadEntityIndexFromRight, allCards, spectator);\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, allCards, spectator);\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\tmodifyAttack(e, 1, boardWithDeadEntity, allCards);\r\n\t\t\tafterStatsUpdate(e, boardWithDeadEntity, allCards);\r\n\t\t});\r\n\r\n\tapplyRotHideGnollEffect(boardWithDeadEntity, allCards, spectator);\r\n\r\n\t// Overkill\r\n\tif (deadEntity.health < 0 && deadEntity.lastAffectedByEntity?.attacking) {\r\n\t\tif (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlame_BGS_032) {\r\n\t\t\tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t\tif (targets.length > 0) {\r\n\t\t\t\tconst target = targets[0];\r\n\t\t\t\tdealDamageToEnemy(\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\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 (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\tdealDamageToEnemy(\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\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\t// else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental && deadEntity.lastAffectedByEntity.attacking) {\r\n\t\t// \t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental) {\r\n\t\t// \t// console.log('applying WildfireElemental effect', stringifySimple(boardWithDeadEntity, allCards));\r\n\t\t// \tconst excessDamage = -deadEntity.health;\r\n\t\t// \t// Prevent propagation of the effect\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking = false;\r\n\t\t// \tconst neighbours = getNeighbours(boardWithDeadEntity, null, boardWithDeadEntity.length - deadEntityIndexFromRight);\r\n\t\t// \t// console.log('neighbours', stringifySimple(neighbours, allCards));\r\n\t\t// \tif (neighbours.length > 0) {\r\n\t\t// \t\tconst randomTarget = neighbours[Math.floor(Math.random() * neighbours.length)];\r\n\t\t// \t\tdealDamageToEnemy(\r\n\t\t// \t\t\trandomTarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\texcessDamage,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tallCards,\r\n\t\t// \t\t\tcardsData,\r\n\t\t// \t\t\tsharedState,\r\n\t\t// \t\t\tspectator,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// } else if (\r\n\t\t// \tdeadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElementalBattlegrounds &&\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking\r\n\t\t// ) {\r\n\t\t// \tconst excessDamage = -deadEntity.health;\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking = false;\r\n\t\t// \tconst neighbours = getNeighbours(boardWithDeadEntity, null, boardWithDeadEntity.length - deadEntityIndexFromRight);\r\n\t\t// \tneighbours.forEach((neighbour) =>\r\n\t\t// \t\tdealDamageToEnemy(\r\n\t\t// \t\t\tneighbour,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\texcessDamage,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tallCards,\r\n\t\t// \t\t\tcardsData,\r\n\t\t// \t\t\tsharedState,\r\n\t\t// \t\t\tspectator,\r\n\t\t// \t\t),\r\n\t\t// \t);\r\n\t\t// }\r\n\t\telse if (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn_TRL_232) {\r\n\t\t\tconst newEntities = spawnEntities(\r\n\t\t\t\tCardIds.IronhideDirehorn_IronhideRuntToken_TRL_232t,\r\n\t\t\t\t1,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t\t!deadEntity.friendly,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t\totherBoard.splice(otherBoard.length - deadEntityIndexFromRight, 0, ...newEntities);\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn_TB_BaconUps_051) {\r\n\t\t\tconst newEntities = spawnEntities(\r\n\t\t\t\tCardIds.IronhideDirehorn_IronhideRuntToken_TB_BaconUps_051t,\r\n\t\t\t\t1,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t\t!deadEntity.friendly,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t\totherBoard.splice(otherBoard.length - deadEntityIndexFromRight, 0, ...newEntities);\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath_BGS_080) {\r\n\t\t\tconst otherPirates = otherBoard\r\n\t\t\t\t.filter((entity) => isCorrectTribe(allCards.getCard(entity.cardId).races, Race.PIRATE))\r\n\t\t\t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\totherPirates.forEach((pirate) => {\r\n\t\t\t\tmodifyAttack(pirate, 2, boardWithDeadEntity, allCards);\r\n\t\t\t\tmodifyHealth(pirate, 2, boardWithDeadEntity, allCards);\r\n\t\t\t\tafterStatsUpdate(pirate, boardWithDeadEntity, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(deadEntity.lastAffectedByEntity, pirate, otherBoard);\r\n\t\t\t});\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath_TB_BaconUps_142) {\r\n\t\t\tconst otherPirates = otherBoard\r\n\t\t\t\t.filter((entity) => isCorrectTribe(allCards.getCard(entity.cardId).races, Race.PIRATE))\r\n\t\t\t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\totherPirates.forEach((pirate) => {\r\n\t\t\t\tmodifyAttack(pirate, 4, boardWithDeadEntity, allCards);\r\n\t\t\t\tmodifyHealth(pirate, 4, boardWithDeadEntity, allCards);\r\n\t\t\t\tafterStatsUpdate(pirate, boardWithDeadEntity, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(deadEntity.lastAffectedByEntity, pirate, otherBoard);\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n};\r\n\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\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\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\tdealDamageToEnemy(\r\n\t\t\tboard1[i],\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdamageSource,\r\n\t\t\tdamageDealt,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\tfor (let i = 0; i < board2.length; i++) {\r\n\t\tdealDamageToEnemy(\r\n\t\t\tboard2[i],\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdamageSource,\r\n\t\t\tdamageDealt,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n};\r\n\r\nconst applySoulJugglerEffect = (\r\n\tboardWithJugglers: BoardEntity[],\r\n\tboardWithJugglersHero: BgsPlayerEntity,\r\n\tboardToAttack: BoardEntity[],\r\n\tboardToAttackHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (boardWithJugglers.length === 0 && boardToAttack.length === 0) {\r\n\t\treturn;\r\n\t\t// return [boardWithJugglers, boardToAttack];\r\n\t}\r\n\tconst jugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler_BGS_002);\r\n\tfor (const juggler of jugglers) {\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t3,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\tconst goldenJugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler_TB_BaconUps_075);\r\n\tfor (const juggler of goldenJugglers) {\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t3,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t3,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\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 = (board: BoardEntity[], allCards: AllCardsService, spectator: Spectator): 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\tmodifyAttack(board[i], 2, board, allCards);\r\n\t\t\tmodifyHealth(board[i], 1, board, allCards);\r\n\t\t\tafterStatsUpdate(board[i], board, allCards);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t} else if (board[i].cardId === CardIds.ScavengingHyenaLegacy_TB_BaconUps_043) {\r\n\t\t\tmodifyAttack(board[i], 4, board, allCards);\r\n\t\t\tmodifyHealth(board[i], 2, board, allCards);\r\n\t\t\tafterStatsUpdate(board[i], board, allCards);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyEternalKnightEffect = (board: BoardEntity[], allCards: AllCardsService, spectator: Spectator): 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\tmodifyAttack(board[i], multiplier * 1, board, allCards);\r\n\t\t\tmodifyHealth(board[i], multiplier * 1, board, allCards);\r\n\t\t\tafterStatsUpdate(board[i], board, allCards);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyRotHideGnollEffect = (board: BoardEntity[], allCards: AllCardsService, spectator: Spectator): 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\tmodifyAttack(board[i], multiplier * 1, board, allCards);\r\n\t\t\tafterStatsUpdate(board[i], board, allCards);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyBristlemaneScrapsmithEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardPlayerEntity: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\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, allCards, spectator, cardsToAdd);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyJunkbotEffect = (board: BoardEntity[], allCards: AllCardsService, spectator: Spectator): 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\tmodifyAttack(board[i], 2, board, allCards);\r\n\t\t\tmodifyHealth(board[i], 2, board, allCards);\r\n\t\t\tafterStatsUpdate(board[i], board, allCards);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t} else if (board[i].cardId === CardIds.Junkbot_TB_BaconUps_046) {\r\n\t\t\tmodifyAttack(board[i], 4, board, allCards);\r\n\t\t\tmodifyHealth(board[i], 4, board, allCards);\r\n\t\t\tafterStatsUpdate(board[i], board, allCards);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyQirajiHarbringerEffect = (\r\n\tboard: BoardEntity[],\r\n\tdeadEntityIndexFromRight: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst qiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger_BGS_112);\r\n\tconst goldenQiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger_TB_BaconUps_303);\r\n\tconst neighbours = getNeighbours(board, null, deadEntityIndexFromRight);\r\n\r\n\t// TODO: if reactivated, properly apply buffs one by one, instead of all together\r\n\tneighbours.forEach((entity) => {\r\n\t\tmodifyAttack(entity, 2 * qiraji.length + 4 * goldenQiraji.length, board, allCards);\r\n\t\tmodifyHealth(entity, 2 * qiraji.length + 4 * goldenQiraji.length, board, allCards);\r\n\t\tafterStatsUpdate(entity, board, allCards);\r\n\t});\r\n};\r\n\r\nexport const applyMonstrosity = (\r\n\tmonstrosity: BoardEntity,\r\n\tdeadEntities: readonly BoardEntity[],\r\n\tboardWithDeadEntities: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\tfor (const deadEntity of deadEntities) {\r\n\t\tmodifyAttack(monstrosity, deadEntity.attack, boardWithDeadEntities, allCards);\r\n\t\tif (monstrosity.cardId === CardIds.Monstrosity_BG20_HERO_282_Buddy_G) {\r\n\t\t\tmodifyAttack(monstrosity, deadEntity.attack, boardWithDeadEntities, allCards);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const rememberDeathrattles = (\r\n\tfish: BoardEntity,\r\n\tdeadEntities: readonly BoardEntity[],\r\n\tcardsData: CardsData,\r\n\tallCards: AllCardsService,\r\n\tsharedState: SharedState,\r\n): void => {\r\n\tconst validDeathrattles = deadEntities\r\n\t\t.filter((entity) => cardsData.validDeathrattles.includes(entity.cardId) || isFish(entity))\r\n\t\t.map((entity) => ({ cardId: entity.cardId, repeats: 1, timing: sharedState.currentEntityId++ }));\r\n\tconst validEnchantments = deadEntities\r\n\t\t.filter((entity) => entity.enchantments?.length)\r\n\t\t.map((entity) => entity.enchantments)\r\n\t\t.reduce((a, b) => a.concat(b), [])\r\n\t\t.flatMap((enchantment) => ({\r\n\t\t\tcardId: enchantment.cardId,\r\n\t\t\trepeats: enchantment.repeats ?? 1,\r\n\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t}))\r\n\t\t.filter((enchantment) =>\r\n\t\t\t[\r\n\t\t\t\tCardIds.ReplicatingMenace_ReplicatingMenaceEnchantment_BG_BOT_312e,\r\n\t\t\t\tCardIds.ReplicatingMenace_ReplicatingMenaceEnchantment_TB_BaconUps_032e,\r\n\t\t\t\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e,\r\n\t\t\t\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge,\r\n\t\t\t\tCardIds.LivingSpores_LivingSporesEnchantment,\r\n\t\t\t\tCardIds.SneedsReplicator_ReplicateEnchantment,\r\n\t\t\t\tCardIds.EarthInvocation_ElementEarthEnchantment,\r\n\t\t\t\tCardIds.FireInvocation_ElementFireEnchantment,\r\n\t\t\t\tCardIds.WaterInvocation_ElementWaterEnchantment,\r\n\t\t\t\tCardIds.LightningInvocation,\r\n\t\t\t\tCardIds.SurfNSurf_CrabRidingEnchantment_BG27_004e,\r\n\t\t\t\tCardIds.SurfNSurf_CrabRidingEnchantment_BG27_004_Ge,\r\n\t\t\t].includes(enchantment.cardId as CardIds),\r\n\t\t);\r\n\t// Multiple fish\r\n\tconst deadEntityRememberedDeathrattles =\r\n\t\tdeadEntities.filter((e) => !!e.rememberedDeathrattles?.length).flatMap((e) => e.rememberedDeathrattles) ?? [];\r\n\tconst newDeathrattles = [...validDeathrattles, ...validEnchantments, ...deadEntityRememberedDeathrattles];\r\n\t// Order is important - the DR are triggered in the ordered the minions have died\r\n\t// console.log(\r\n\t// \t'remembering deathrattle',\r\n\t// \t'\\n',\r\n\t// \tstringifySimpleCard(fish, allCards),\r\n\t// \t'\\n',\r\n\t// \tstringifySimple(deadEntities, allCards),\r\n\t// \t'\\n',\r\n\t// \tfish.rememberedDeathrattles,\r\n\t// );\r\n\tif (isGolden(fish.cardId, allCards)) {\r\n\t\t// https://stackoverflow.com/questions/33305152/how-to-duplicate-elements-in-a-js-array\r\n\t\tconst doubleDr = newDeathrattles.reduce((res, current) => res.concat([current, current]), []);\r\n\t\tfish.rememberedDeathrattles = [...(fish.rememberedDeathrattles || []), ...doubleDr];\r\n\t} else {\r\n\t\tfish.rememberedDeathrattles = [...(fish.rememberedDeathrattles || []), ...newDeathrattles];\r\n\t}\r\n\t// console.log('remembering deathrattle after', '\\n', fish.rememberedDeathrattles);\r\n};\r\n\r\nconst removeOldMurkEyeAttack = (boardWithDeadEntity: BoardEntity[], allCards: AllCardsService) => {\r\n\tconst murkeyes = boardWithDeadEntity.filter(\r\n\t\t(entity) => entity.cardId === CardIds.OldMurkEyeLegacy || entity.cardId === CardIds.OldMurkEyeVanilla,\r\n\t);\r\n\tconst goldenMurkeyes = boardWithDeadEntity.filter((entity) => entity.cardId === CardIds.OldMurkEye);\r\n\tmurkeyes.forEach((entity) => {\r\n\t\tmodifyAttack(entity, -1, boardWithDeadEntity, allCards);\r\n\t\tafterStatsUpdate(entity, boardWithDeadEntity, allCards);\r\n\t});\r\n\tgoldenMurkeyes.forEach((entity) => {\r\n\t\tmodifyAttack(entity, -2, boardWithDeadEntity, allCards);\r\n\t\tafterStatsUpdate(entity, boardWithDeadEntity, allCards);\r\n\t});\r\n};\r\n"]}
package/dist/utils.js CHANGED
@@ -442,6 +442,9 @@ const setImplicitDataForEntity = (entity, cardsData) => {
442
442
  return entity;
443
443
  };
444
444
  const normalizeCardIdForSkin = (cardId) => {
445
+ if (!(cardId === null || cardId === void 0 ? void 0 : cardId.length)) {
446
+ return cardId;
447
+ }
445
448
  const skinMatch = cardId.match(/(.*)_SKIN_.*/);
446
449
  if (skinMatch) {
447
450
  return skinMatch[1];
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AACA,iEAAoH;AAKpH,4CAA4D;AAG5D,MAAM,UAAU,GAAG;;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typescript-eslint/no-use-before-define */\r\nimport { ALL_BG_RACES, AllCardsService, CardIds, GameTag, Race, ReferenceCard } from '@firestone-hs/reference-data';\r\nimport { SharedState } from 'src/simulation/shared-state';\r\nimport { BgsPlayerEntity } from './bgs-player-entity';\r\nimport { BoardEntity } from './board-entity';\r\nimport { CardsData } from './cards/cards-data';\r\nimport { pickRandom, shuffleArray } from './services/utils';\r\nimport { Spectator } from './simulation/spectator/spectator';\r\n\r\nconst CLEAVE_IDS = [\r\n\tCardIds.CaveHydra_BG_LOOT_078,\r\n\tCardIds.CaveHydra_TB_BaconUps_151,\r\n\tCardIds.FoeReaper4000_BG_GVG_113,\r\n\tCardIds.FoeReaper4000_TB_BaconUps_153,\r\n\tCardIds.BladeCollector_BG26_817,\r\n\tCardIds.BladeCollector_BG26_817_G,\r\n];\r\nconst ATTACK_IMMEDIATELY_IDS = [\r\n\tCardIds.Scallywag_SkyPirateToken_BGS_061t,\r\n\tCardIds.Scallywag_SkyPirateToken_TB_BaconUps_141t,\r\n\tCardIds.Onyxia_OnyxianWhelpToken,\r\n];\r\nconst CANT_ATTACK_IDS = [CardIds.ArcaneCannon_BGS_077, CardIds.ArcaneCannon_TB_BaconUps_128];\r\n\r\nexport const buildSingleBoardEntity = (\r\n\tcardId: string,\r\n\tcontrollerHero: BgsPlayerEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tfriendly: boolean,\r\n\tentityId = 1,\r\n\tspawnReborn = false,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tentityToSpawn: BoardEntity,\r\n\toriginalEntity: BoardEntity = null,\r\n): BoardEntity => {\r\n\tconst card = allCards.getCard(cardId);\r\n\tconst attackImmediately = ATTACK_IMMEDIATELY_IDS.indexOf(cardId as CardIds) !== -1;\r\n\tconst newEntity = !!entityToSpawn\r\n\t\t? ({\r\n\t\t\t\t...entityToSpawn,\r\n\t\t\t\tentityId: sharedState.currentEntityId++,\r\n\t\t\t\tdefinitelyDead: false,\r\n\t\t\t\tavengeCurrent: entityToSpawn.avengeDefault,\r\n\t\t\t\tattacking: false,\r\n\t\t\t\tdamageMultiplier: 1,\r\n\t\t\t\tfrenzyChargesLeft: 1,\r\n\t\t\t\tfriendly: friendly,\r\n\t\t } as BoardEntity)\r\n\t\t: addImpliedMechanics(\r\n\t\t\t\t{\r\n\t\t\t\t\tentityId: entityId,\r\n\t\t\t\t\tattack: card.attack,\r\n\t\t\t\t\tattacksPerformed: 0,\r\n\t\t\t\t\tcardId: cardId,\r\n\t\t\t\t\tdivineShield: hasMechanic(card, 'DIVINE_SHIELD'),\r\n\t\t\t\t\thealth: card.health,\r\n\t\t\t\t\tmaxHealth: card.health,\r\n\t\t\t\t\ttaunt: hasMechanic(card, GameTag[GameTag.TAUNT]),\r\n\t\t\t\t\treborn: hasMechanic(card, 'REBORN'),\r\n\t\t\t\t\tpoisonous: hasMechanic(card, GameTag[GameTag.POISONOUS]),\r\n\t\t\t\t\tvenomous: hasMechanic(card, GameTag[GameTag.VENOMOUS]),\r\n\t\t\t\t\twindfury:\r\n\t\t\t\t\t\thasMechanic(card, GameTag[GameTag.WINDFURY]) ||\r\n\t\t\t\t\t\tcard.referencedTags?.includes(GameTag[GameTag.WINDFURY]),\r\n\t\t\t\t\tenchantments: [],\r\n\t\t\t\t\tfriendly: friendly,\r\n\t\t\t\t\tattackImmediately: attackImmediately,\r\n\t\t\t\t\tavengeCurrent: cardsData.avengeValue(cardId),\r\n\t\t\t\t\tavengeDefault: cardsData.avengeValue(cardId),\r\n\t\t\t\t} as BoardEntity,\r\n\t\t\t\tcardsData,\r\n\t\t );\r\n\r\n\tif (spawnReborn && !entityToSpawn) {\r\n\t\tif (cardId === CardIds.BuildAnUndead_PutricidesCreationToken) {\r\n\t\t\tconst stitchedCardId = !!originalEntity.additionalCards?.length ? originalEntity.additionalCards[0] : null;\r\n\t\t\tif (stitchedCardId) {\r\n\t\t\t\tconst stitchedCard = allCards.getCard(stitchedCardId);\r\n\t\t\t\tnewEntity.attack = newEntity.attack + stitchedCard.attack;\r\n\t\t\t\tnewEntity.maxHealth = newEntity.maxHealth + stitchedCard.health;\r\n\t\t\t\tnewEntity.taunt = newEntity.taunt || hasMechanic(stitchedCard, GameTag[GameTag.TAUNT]);\r\n\t\t\t\tnewEntity.divineShield =\r\n\t\t\t\t\tnewEntity.divineShield || hasMechanic(stitchedCard, GameTag[GameTag.DIVINE_SHIELD]);\r\n\t\t\t\tnewEntity.poisonous = newEntity.poisonous || hasMechanic(stitchedCard, GameTag[GameTag.POISONOUS]);\r\n\t\t\t\tnewEntity.venomous = newEntity.venomous || hasMechanic(stitchedCard, GameTag[GameTag.VENOMOUS]);\r\n\t\t\t\tnewEntity.windfury = newEntity.windfury || hasMechanic(stitchedCard, GameTag[GameTag.WINDFURY]);\r\n\t\t\t\tnewEntity.avengeCurrent = newEntity.avengeCurrent || cardsData.avengeValue(stitchedCardId);\r\n\t\t\t\tnewEntity.avengeDefault = newEntity.avengeDefault || cardsData.avengeValue(stitchedCardId);\r\n\t\t\t}\r\n\t\t}\r\n\t\tnewEntity.health = 1;\r\n\t\tnewEntity.reborn = false;\r\n\t}\r\n\r\n\tnewEntity.hadDivineShield = newEntity.divineShield || newEntity.hadDivineShield;\r\n\treturn newEntity;\r\n};\r\n\r\nexport const buildRandomUndeadCreation = (\r\n\tcontrollerHero: BgsPlayerEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tfriendly: boolean,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n): BoardEntity => {\r\n\tconst baseCard = pickRandom(cardsData.putricidePool1);\r\n\tconst stitchedCardId =\r\n\t\tbaseCard === CardIds.EternalSummoner_BG25_009\r\n\t\t\t? pickRandom(cardsData.putridicePool2ForEternalSummoner)\r\n\t\t\t: pickRandom(cardsData.putricidePool2);\r\n\tconst newEntity = buildSingleBoardEntity(\r\n\t\tbaseCard,\r\n\t\tcontrollerHero,\r\n\t\tfriendlyBoard,\r\n\t\tallCards,\r\n\t\tfriendly,\r\n\t\tsharedState.currentEntityId++,\r\n\t\tfalse,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tnull,\r\n\t);\r\n\tconst stitchedCard = allCards.getCard(stitchedCardId);\r\n\tnewEntity.attack += stitchedCard.attack;\r\n\tnewEntity.health += stitchedCard.health;\r\n\tnewEntity.taunt = newEntity.taunt || hasMechanic(stitchedCard, GameTag[GameTag.TAUNT]);\r\n\tnewEntity.divineShield = newEntity.divineShield || hasMechanic(stitchedCard, GameTag[GameTag.DIVINE_SHIELD]);\r\n\tnewEntity.poisonous = newEntity.venomous || hasMechanic(stitchedCard, GameTag[GameTag.POISONOUS]);\r\n\tnewEntity.venomous = newEntity.poisonous || hasMechanic(stitchedCard, GameTag[GameTag.VENOMOUS]);\r\n\tnewEntity.windfury = newEntity.windfury || hasMechanic(stitchedCard, GameTag[GameTag.WINDFURY]);\r\n\tnewEntity.avengeCurrent = newEntity.avengeCurrent || cardsData.avengeValue(stitchedCardId);\r\n\tnewEntity.avengeDefault = newEntity.avengeDefault || cardsData.avengeValue(stitchedCardId);\r\n\treturn newEntity;\r\n};\r\n\r\nexport const modifyAttack = (\r\n\tentity: BoardEntity,\r\n\tamount: number,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator = null,\r\n): void => {\r\n\tconst realAmount = entity.cardId === CardIds.Tarecgosa_BG21_015_G ? 2 * amount : amount;\r\n\tentity.attack = Math.max(0, entity.attack + realAmount);\r\n\tentity.previousAttack = entity.attack;\r\n\tif (isCorrectTribe(allCards.getCard(entity.cardId).races, Race.DRAGON)) {\r\n\t\tconst whelpSmugglers = friendlyBoard.filter(\r\n\t\t\t(e) => e.cardId === CardIds.WhelpSmuggler_BG21_013 || e.cardId === CardIds.WhelpSmuggler_BG21_013_G,\r\n\t\t);\r\n\t\twhelpSmugglers.forEach((smuggler) => {\r\n\t\t\tconst buff = smuggler.cardId === CardIds.WhelpSmuggler_BG21_013_G ? 2 : 1;\r\n\t\t\tmodifyHealth(entity, buff, friendlyBoard, allCards);\r\n\t\t});\r\n\r\n\t\tif (entity.cardId !== CardIds.Stormbringer_BG26_966 && entity.cardId !== CardIds.Stormbringer_BG26_966_G) {\r\n\t\t\tconst stormbringers = friendlyBoard.filter(\r\n\t\t\t\t(e) => e.cardId === CardIds.Stormbringer_BG26_966 || e.cardId === CardIds.Stormbringer_BG26_966_G,\r\n\t\t\t);\r\n\t\t\tstormbringers.forEach((stormbringer) => {\r\n\t\t\t\tconst multiplier = stormbringer.cardId === CardIds.Stormbringer_BG26_966_G ? 2 : 1;\r\n\t\t\t\t(e) => modifyAttack(e, multiplier * amount, friendlyBoard, allCards);\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\tif (\r\n\t\tentity.cardId === CardIds.Menagerist_AmalgamToken ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A_G ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D_G\r\n\t) {\r\n\t\tconst mishmashes = friendlyBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy ||\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G,\r\n\t\t);\r\n\t\tmishmashes.forEach((mishmash) => {\r\n\t\t\tmodifyAttack(\r\n\t\t\t\tmishmash,\r\n\t\t\t\t(mishmash.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G ? 2 : 1) * realAmount,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tallCards,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\r\n\tif ([CardIds.HunterOfGatherers_BG25_027, CardIds.HunterOfGatherers_BG25_027_G].includes(entity.cardId as CardIds)) {\r\n\t\taddStatsToBoard(\r\n\t\t\tentity,\r\n\t\t\tfriendlyBoard,\r\n\t\t\t0,\r\n\t\t\tentity.cardId === CardIds.HunterOfGatherers_BG25_027_G ? 2 : 1,\r\n\t\t\tallCards,\r\n\t\t\tnull,\r\n\t\t);\r\n\t}\r\n};\r\n\r\nexport const modifyHealth = (\r\n\tentity: BoardEntity,\r\n\tamount: number,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\tconst realAmount = entity.cardId === CardIds.Tarecgosa_BG21_015 ? 2 * amount : amount;\r\n\tentity.health += realAmount;\r\n\tif (realAmount > 0) {\r\n\t\tentity.maxHealth += realAmount;\r\n\t}\r\n\tif (\r\n\t\tentity.cardId === CardIds.Menagerist_AmalgamToken ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A_G ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D_G\r\n\t) {\r\n\t\tconst mishmashes = friendlyBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy ||\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G,\r\n\t\t);\r\n\t\tmishmashes.forEach((mishmash) => {\r\n\t\t\tmodifyHealth(\r\n\t\t\t\tmishmash,\r\n\t\t\t\t(mishmash.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G ? 2 : 1) * realAmount,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tallCards,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\r\n\tconst titanicGuardians = friendlyBoard\r\n\t\t.filter((e) => e.entityId !== entity.entityId)\r\n\t\t.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy ||\r\n\t\t\t\te.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy_G,\r\n\t\t);\r\n\ttitanicGuardians.forEach((guardian) => {\r\n\t\tmodifyHealth(\r\n\t\t\tguardian,\r\n\t\t\t(guardian.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy_G ? 2 : 1) * realAmount,\r\n\t\t\tfriendlyBoard,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t});\r\n};\r\n\r\nexport const afterStatsUpdate = (\r\n\tentity: BoardEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\tif (hasCorrectTribe(entity, Race.ELEMENTAL, allCards)) {\r\n\t\tconst masterOfRealities = friendlyBoard.filter(\r\n\t\t\t(e) => e.cardId === CardIds.MasterOfRealities_BG21_036 || e.cardId === CardIds.MasterOfRealities_BG21_036_G,\r\n\t\t);\r\n\t\tmasterOfRealities.forEach((master) => {\r\n\t\t\tmodifyAttack(\r\n\t\t\t\tmaster,\r\n\t\t\t\tmaster.cardId === CardIds.MasterOfRealities_BG21_036_G ? 2 : 1,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tallCards,\r\n\t\t\t);\r\n\t\t\tmodifyHealth(\r\n\t\t\t\tmaster,\r\n\t\t\t\tmaster.cardId === CardIds.MasterOfRealities_BG21_036_G ? 2 : 1,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tallCards,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\tconst tentaclesOfCthun = friendlyBoard\r\n\t\t.filter((e) => e.entityId !== entity.entityId)\r\n\t\t.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy ||\r\n\t\t\t\te.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G,\r\n\t\t);\r\n\ttentaclesOfCthun.forEach((tentacle) => {\r\n\t\tmodifyAttack(\r\n\t\t\ttentacle,\r\n\t\t\ttentacle.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G ? 2 : 1,\r\n\t\t\tfriendlyBoard,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t\tmodifyHealth(\r\n\t\t\ttentacle,\r\n\t\t\ttentacle.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G ? 2 : 1,\r\n\t\t\tfriendlyBoard,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t});\r\n};\r\n\r\nexport const makeMinionGolden = (\r\n\ttarget: BoardEntity,\r\n\tsource: BoardEntity | BgsPlayerEntity,\r\n\tsourceBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// Typically, we are already golden\r\n\tif (isMinionGolden(target, allCards)) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst refCard = allCards.getCard(target.cardId);\r\n\tconst goldenCard = allCards.getCardFromDbfId(refCard.battlegroundsPremiumDbfId);\r\n\ttarget.cardId = goldenCard.id;\r\n\t// A minion becoming golden ignore the current death.\r\n\t// This way of handling it is not ideal, since it will still trigger if both avenges trigger at the same time, but\r\n\t// should solve the other cases\r\n\ttarget.avengeCurrent = Math.min(target.avengeDefault, target.avengeCurrent + 1);\r\n\tmodifyAttack(target, refCard.attack, sourceBoard, allCards);\r\n\tmodifyHealth(target, refCard.health, sourceBoard, allCards);\r\n\tafterStatsUpdate(target, sourceBoard, allCards);\r\n\tspectator.registerPowerTarget(source, target, sourceBoard);\r\n};\r\n\r\nexport const isMinionGolden = (entity: BoardEntity, allCards: AllCardsService): boolean => {\r\n\tconst ref = allCards.getCard(entity.cardId);\r\n\treturn !ref.battlegroundsPremiumDbfId;\r\n\t// Why this condition?\r\n\t// || !allCards.getCardFromDbfId(ref.battlegroundsPremiumDbfId).id\r\n};\r\n\r\nexport const grantRandomAttack = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tadditionalAttack: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\texcludeSource = false,\r\n): void => {\r\n\tconst candidateBoard = board\r\n\t\t.filter((e) => !excludeSource || e.entityId !== source.entityId)\r\n\t\t.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tif (candidateBoard.length > 0) {\r\n\t\tconst target = candidateBoard[Math.floor(Math.random() * candidateBoard.length)];\r\n\t\tmodifyAttack(target, additionalAttack, candidateBoard, allCards);\r\n\t\tafterStatsUpdate(target, candidateBoard, allCards);\r\n\t\tspectator.registerPowerTarget(source, target, board);\r\n\t}\r\n};\r\n\r\nexport const grantRandomHealth = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thealth: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\texcludeSource = false,\r\n): void => {\r\n\tconst candidateBoard = board\r\n\t\t.filter((e) => !excludeSource || e.entityId !== source.entityId)\r\n\t\t.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tif (candidateBoard.length > 0) {\r\n\t\tconst target = candidateBoard[Math.floor(Math.random() * candidateBoard.length)];\r\n\t\tmodifyHealth(target, health, board, allCards);\r\n\t\tafterStatsUpdate(target, board, allCards);\r\n\t\tspectator.registerPowerTarget(source, target, board);\r\n\t}\r\n};\r\n\r\nexport const grantRandomStats = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tattack: number,\r\n\thealth: number,\r\n\trace: Race,\r\n\texcludeSource: boolean,\r\n\tallCards: AllCardsService,\r\n\tspectator?: Spectator,\r\n): BoardEntity => {\r\n\tif (board.length > 0) {\r\n\t\tconst target: BoardEntity = getRandomAliveMinion(\r\n\t\t\tboard.filter((e) => (excludeSource ? e.entityId !== source.entityId : true)),\r\n\t\t\trace,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t\tif (target) {\r\n\t\t\tmodifyAttack(target, attack, board, allCards);\r\n\t\t\tmodifyHealth(target, health, board, allCards);\r\n\t\t\tafterStatsUpdate(target, board, allCards);\r\n\t\t\tif (spectator) {\r\n\t\t\t\tspectator.registerPowerTarget(source, target, board);\r\n\t\t\t}\r\n\t\t\treturn target;\r\n\t\t}\r\n\t}\r\n\treturn null;\r\n};\r\n\r\nexport const addCardsInHand = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tboard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tcardsAdded: readonly any[],\r\n): void => {\r\n\tconst previousCardsInHand = playerEntity.hand?.length ?? 0;\r\n\tconst sages = board.filter((e) => e.cardId === CardIds.DeathsHeadSage_BG20_HERO_103_Buddy);\r\n\tconst sagesGolden = board.filter((e) => e.cardId === CardIds.DeathsHeadSage_BG20_HERO_103_Buddy_G);\r\n\tconst multiplier = sages.length + 2 * sagesGolden.length;\r\n\r\n\tconst cardsThatWillBeAdded = [];\r\n\tfor (const cardAdded of cardsAdded) {\r\n\t\tconst cardToAdd: { cardId: string } = (cardAdded as BoardEntity)?.cardId\r\n\t\t\t? (cardAdded as BoardEntity)\r\n\t\t\t: ({ cardId: cardAdded as string } as BoardEntity);\r\n\t\tcardsThatWillBeAdded.push(cardToAdd);\r\n\t\tif (cardToAdd.cardId === CardIds.BloodGem) {\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tcardsThatWillBeAdded.push({ ...cardToAdd });\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tfor (let i = 0; i < cardsThatWillBeAdded.length; i++) {\r\n\t\tif (playerEntity.hand.length >= 10) {\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tplayerEntity.hand.push(cardsThatWillBeAdded[i]);\r\n\t}\r\n\r\n\tconst numCardsAdded = playerEntity.hand.length - previousCardsInHand;\r\n\r\n\tfor (let i = 0; i < numCardsAdded; i++) {\r\n\t\tconst peggys = board.filter(\r\n\t\t\t(e) => e.cardId === CardIds.PeggySturdybone_BG25_032 || e.cardId === CardIds.PeggySturdybone_BG25_032_G,\r\n\t\t);\r\n\t\tpeggys.forEach((peggy) => {\r\n\t\t\tconst pirate = getRandomAliveMinion(\r\n\t\t\t\tboard.filter((e) => e.entityId !== peggy.entityId),\r\n\t\t\t\tRace.PIRATE,\r\n\t\t\t\tallCards,\r\n\t\t\t);\r\n\t\t\tif (pirate) {\r\n\t\t\t\tmodifyAttack(pirate, peggy.cardId === CardIds.PeggySturdybone_BG25_032_G ? 2 : 1, board, allCards);\r\n\t\t\t\tmodifyHealth(pirate, peggy.cardId === CardIds.PeggySturdybone_BG25_032_G ? 2 : 1, board, allCards);\r\n\t\t\t\tafterStatsUpdate(pirate, board, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(peggy, pirate, board);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tconst thornCaptains = board.filter(\r\n\t\t\t(e) => e.cardId === CardIds.Thorncaptain_BG25_045 || e.cardId === CardIds.Thorncaptain_BG25_045_G,\r\n\t\t);\r\n\t\tthornCaptains.forEach((captain) => {\r\n\t\t\tmodifyHealth(captain, captain.cardId === CardIds.Thorncaptain_BG25_045_G ? 2 : 1, board, allCards);\r\n\t\t\tafterStatsUpdate(captain, board, allCards);\r\n\t\t\tspectator.registerPowerTarget(captain, captain, board);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const removeCardFromHand = (playerEntity: BgsPlayerEntity, card: BoardEntity): void => {\r\n\tlet cardToRemove: BoardEntity;\r\n\tif (card?.entityId) {\r\n\t\tcardToRemove = playerEntity.hand.find((c) => c?.entityId !== card.entityId);\r\n\t} else if (card?.cardId) {\r\n\t\tcardToRemove = playerEntity.hand.find((c) => c?.cardId === card.cardId);\r\n\t} else {\r\n\t\t// Remove a single random card in hand that doesn't have an entityId\r\n\t\tcardToRemove =\r\n\t\t\tpickRandom(playerEntity.hand.filter((c) => !c?.entityId && !c?.cardId)) ?? pickRandom(playerEntity.hand);\r\n\t}\r\n\t// Remove the first occurrence of the card from playerEntity.cardsInHand, even if it is null\r\n\tconst index = playerEntity.hand.indexOf(cardToRemove);\r\n\tif (index !== -1) {\r\n\t\tplayerEntity.hand.splice(index, 1);\r\n\t}\r\n};\r\n\r\nexport const grantRandomDivineShield = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst elligibleEntities = board\r\n\t\t.filter((entity) => !entity.divineShield)\r\n\t\t.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\tif (elligibleEntities.length > 0) {\r\n\t\tconst chosen = elligibleEntities[Math.floor(Math.random() * elligibleEntities.length)];\r\n\t\tupdateDivineShield(chosen, board, true, allCards);\r\n\t\tspectator.registerPowerTarget(source, chosen, board);\r\n\t}\r\n\t// return board;\r\n};\r\n\r\nexport const updateDivineShield = (\r\n\tentity: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tnewValue: boolean,\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\t// if ((entity.divineShield ?? false) === newValue) {\r\n\t// \treturn;\r\n\t// }\r\n\tentity.divineShield = newValue;\r\n\tif (entity.divineShield) {\r\n\t\tentity.hadDivineShield = true;\r\n\t}\r\n\tif (entity.divineShield) {\r\n\t\tconst boardForDrake = board;\r\n\t\tconst statsBonus =\r\n\t\t\t8 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043).length +\r\n\t\t\t16 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043_G).length;\r\n\t\t// Don't trigger all \"on attack changed\" effects, since it's an aura\r\n\t\tentity.attack += statsBonus;\r\n\t} else {\r\n\t\t// Also consider itself\r\n\t\tconst boardForDrake = board;\r\n\t\tconst statsBonus =\r\n\t\t\t8 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043).length +\r\n\t\t\t16 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043_G).length;\r\n\t\tentity.attack -= statsBonus;\r\n\t}\r\n};\r\n\r\nexport const grantAllDivineShield = (board: BoardEntity[], tribe: string, cards: AllCardsService): void => {\r\n\tconst elligibleEntities = board\r\n\t\t.filter((entity) => !entity.divineShield)\r\n\t\t.filter((entity) => isCorrectTribe(cards.getCard(entity.cardId).races, getRaceEnum(tribe)));\r\n\tfor (const entity of elligibleEntities) {\r\n\t\tupdateDivineShield(entity, board, true, cards);\r\n\t}\r\n};\r\n\r\nexport const getRandomAliveMinion = (board: BoardEntity[], race: Race, allCards: AllCardsService): BoardEntity => {\r\n\tconst validTribes = board\r\n\t\t.filter((e) => !race || isCorrectTribe(allCards.getCard(e?.cardId).races, race))\r\n\t\t.filter((e) => !!e?.health && !e.definitelyDead);\r\n\tif (!validTribes.length) {\r\n\t\treturn null;\r\n\t}\r\n\tconst randomIndex = Math.floor(Math.random() * validTribes.length);\r\n\treturn validTribes[randomIndex];\r\n};\r\n\r\nexport const getRandomMinionWithHighestHealth = (board: BoardEntity[]): BoardEntity => {\r\n\tif (!board.length) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tconst highestHealth = Math.max(...board.map((e) => e.health));\r\n\tconst validMinions = board.filter((e) => e.health === highestHealth);\r\n\treturn validMinions[Math.floor(Math.random() * validMinions.length)];\r\n};\r\n\r\nexport const addStatsToBoard = (\r\n\tsourceEntity: BoardEntity | BgsPlayerEntity,\r\n\tboard: BoardEntity[],\r\n\tattack: number,\r\n\thealth: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\ttribe?: string,\r\n): void => {\r\n\tfor (const entity of board) {\r\n\t\tif (!tribe || hasCorrectTribe(entity, Race[tribe], allCards)) {\r\n\t\t\tmodifyAttack(entity, attack, board, allCards);\r\n\t\t\tmodifyHealth(entity, health, board, allCards);\r\n\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\tspectator?.registerPowerTarget(sourceEntity, entity, board);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const grantStatsToMinionsOfEachType = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tattack: number,\r\n\thealth: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tnumberOfDifferentTypes = 99,\r\n): void => {\r\n\tif (board.length > 0) {\r\n\t\tlet boardCopy = [...board];\r\n\t\tconst allRaces = shuffleArray(ALL_BG_RACES);\r\n\t\tlet typesBuffed = 0;\r\n\t\tfor (const tribe of allRaces) {\r\n\t\t\tif (typesBuffed >= numberOfDifferentTypes) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tconst validMinion: BoardEntity = getRandomAliveMinion(boardCopy, tribe, allCards);\r\n\t\t\tif (validMinion) {\r\n\t\t\t\tmodifyAttack(validMinion, attack, board, allCards);\r\n\t\t\t\tmodifyHealth(validMinion, health, board, allCards);\r\n\t\t\t\tafterStatsUpdate(validMinion, board, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(source, validMinion, board);\r\n\t\t\t\tboardCopy = boardCopy.filter((e) => e !== validMinion);\r\n\t\t\t\ttypesBuffed++;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const hasMechanic = (card: ReferenceCard, mechanic: string): boolean => {\r\n\treturn card.mechanics?.includes(mechanic);\r\n};\r\n\r\nexport const hasCorrectTribe = (entity: BoardEntity, targetTribe: Race, allCards: AllCardsService): boolean => {\r\n\treturn isCorrectTribe(allCards.getCard(entity.cardId).races, targetTribe);\r\n};\r\n\r\nexport const isCorrectTribe = (cardRaces: readonly string[], targetTribe: Race): boolean => {\r\n\tif (!cardRaces?.length) {\r\n\t\treturn false;\r\n\t}\r\n\treturn cardRaces\r\n\t\t.map((cardRace) => getRaceEnum(cardRace))\r\n\t\t.some((raceEnum) => raceEnum === Race.ALL || raceEnum === targetTribe);\r\n};\r\n\r\nexport const getRaceEnum = (race: string): Race => {\r\n\treturn Race[race];\r\n};\r\n\r\nexport const addImpliedMechanics = (entity: BoardEntity, cardsData: CardsData): BoardEntity => {\r\n\tconst cleave = CLEAVE_IDS.indexOf(entity.cardId as CardIds) !== -1;\r\n\tconst cantAttack = CANT_ATTACK_IDS.indexOf(entity.cardId as CardIds) !== -1;\r\n\treturn setImplicitDataForEntity(\r\n\t\t{\r\n\t\t\t...entity,\r\n\t\t\tcleave: cleave,\r\n\t\t\tcantAttack: cantAttack,\r\n\t\t\timmuneWhenAttackCharges:\r\n\t\t\t\tentity.cardId === CardIds.Warpwing_BG24_004 || entity.cardId === CardIds.Warpwing_BG24_004_G\r\n\t\t\t\t\t? 99999\r\n\t\t\t\t\t: 0,\r\n\t\t\tfrenzyChargesLeft:\r\n\t\t\t\tentity.cardId === CardIds.BristlebackKnight_BG20_204_G\r\n\t\t\t\t\t? 2\r\n\t\t\t\t\t: entity.cardId === CardIds.BristlebackKnight_BG20_204\r\n\t\t\t\t\t? 1\r\n\t\t\t\t\t: 0,\r\n\t\t\t// It's not an issue adding a charge for entities without a special ability\r\n\t\t\tabiityChargesLeft: [CardIds.TransmutedBramblewitch_BG27_013_G, CardIds.Mannoroth_BG27_507_G].includes(\r\n\t\t\t\tentity.cardId as CardIds,\r\n\t\t\t)\r\n\t\t\t\t? 2\r\n\t\t\t\t: 1,\r\n\t\t} as BoardEntity,\r\n\t\tcardsData,\r\n\t);\r\n};\r\n\r\nconst setImplicitDataForEntity = (entity: BoardEntity, cardsData: CardsData): BoardEntity => {\r\n\tentity.cardId = normalizeCardIdForSkin(entity.cardId);\r\n\tentity.maxHealth = Math.max(0, entity.health);\r\n\tconst avengeValue = cardsData.avengeValue(entity.cardId);\r\n\tif (avengeValue > 0) {\r\n\t\tentity.avengeCurrent = avengeValue;\r\n\t\tentity.avengeDefault = avengeValue;\r\n\t}\r\n\treturn entity;\r\n};\r\n\r\nexport const normalizeCardIdForSkin = (cardId: string): string => {\r\n\tconst skinMatch = cardId.match(/(.*)_SKIN_.*/);\r\n\tif (skinMatch) {\r\n\t\treturn skinMatch[1];\r\n\t}\r\n\treturn cardId;\r\n};\r\n\r\nexport const stringifySimple = (board: readonly BoardEntity[], allCards: AllCardsService = null): string => {\r\n\treturn '[' + board.map((entity) => stringifySimpleCard(entity, allCards)).join(', ') + ']';\r\n};\r\n\r\nexport const stringifySimpleCard = (entity: BoardEntity, allCards: AllCardsService = null): string => {\r\n\treturn entity\r\n\t\t? `${entity.cardId}/${allCards?.getCard(entity.cardId)?.name ?? ''}/atk=${entity.attack}/hp=${\r\n\t\t\t\tentity.health\r\n\t\t }/ds=${entity.divineShield}`\r\n\t\t: null;\r\n};\r\n\r\nexport const isFish = (entity: BoardEntity): boolean => {\r\n\treturn (\r\n\t\tentity.cardId.startsWith(CardIds.AvatarOfNzoth_FishOfNzothToken) ||\r\n\t\tentity.cardId.startsWith(CardIds.FishOfNzoth) ||\r\n\t\tentity.additionalCards?.includes(CardIds.DevourerOfSouls_BG_RLK_538)\r\n\t);\r\n};\r\n\r\nexport const isGolden = (cardId: string, allCards: AllCardsService): boolean => {\r\n\treturn !!allCards.getCard(cardId).battlegroundsNormalDbfId;\r\n};\r\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AACA,iEAAoH;AAKpH,4CAA4D;AAG5D,MAAM,UAAU,GAAG;;;;;;;CAOlB,CAAC;AACF,MAAM,sBAAsB,GAAG;;;;CAI9B,CAAC;AACF,MAAM,eAAe,GAAG,8BAAoE,CAAC;AAEtF,MAAM,sBAAsB,GAAG,CACrC,MAAc,EACd,cAA+B,EAC/B,aAA4B,EAC5B,QAAyB,EACzB,QAAiB,EACjB,QAAQ,GAAG,CAAC,EACZ,WAAW,GAAG,KAAK,EACnB,SAAoB,EACpB,WAAwB,EACxB,aAA0B,EAC1B,iBAA8B,IAAI,EACpB,EAAE;;IAChB,MAAM,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C,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;AAC5F,CAAC,CAAC;AAFW,QAAA,eAAe,mBAE1B;AAEK,MAAM,mBAAmB,GAAG,CAAC,MAAmB,EAAE,WAA4B,IAAI,EAAU,EAAE;;IACpG,OAAO,MAAM;QACZ,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,IAAI,MAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,0CAAE,IAAI,mCAAI,EAAE,QAAQ,MAAM,CAAC,MAAM,OACrF,MAAM,CAAC,MACP,OAAO,MAAM,CAAC,YAAY,EAAE;QAC9B,CAAC,CAAC,IAAI,CAAC;AACT,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B;AAEK,MAAM,MAAM,GAAG,CAAC,MAAmB,EAAW,EAAE;;IACtD,OAAO,CACN,MAAM,CAAC,MAAM,CAAC,UAAU,wBAAwC;QAChE,MAAM,CAAC,MAAM,CAAC,UAAU,mBAAqB;SAC7C,MAAA,MAAM,CAAC,eAAe,0CAAE,QAAQ,cAAoC,CAAA,CACpE,CAAC;AACH,CAAC,CAAC;AANW,QAAA,MAAM,UAMjB;AAEK,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAE,QAAyB,EAAW,EAAE;IAC9E,OAAO,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,wBAAwB,CAAC;AAC5D,CAAC,CAAC;AAFW,QAAA,QAAQ,YAEnB","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { ALL_BG_RACES, AllCardsService, CardIds, GameTag, Race, ReferenceCard } from '@firestone-hs/reference-data';\r\nimport { SharedState } from 'src/simulation/shared-state';\r\nimport { BgsPlayerEntity } from './bgs-player-entity';\r\nimport { BoardEntity } from './board-entity';\r\nimport { CardsData } from './cards/cards-data';\r\nimport { pickRandom, shuffleArray } from './services/utils';\r\nimport { Spectator } from './simulation/spectator/spectator';\r\n\r\nconst CLEAVE_IDS = [\r\n\tCardIds.CaveHydra_BG_LOOT_078,\r\n\tCardIds.CaveHydra_TB_BaconUps_151,\r\n\tCardIds.FoeReaper4000_BG_GVG_113,\r\n\tCardIds.FoeReaper4000_TB_BaconUps_153,\r\n\tCardIds.BladeCollector_BG26_817,\r\n\tCardIds.BladeCollector_BG26_817_G,\r\n];\r\nconst ATTACK_IMMEDIATELY_IDS = [\r\n\tCardIds.Scallywag_SkyPirateToken_BGS_061t,\r\n\tCardIds.Scallywag_SkyPirateToken_TB_BaconUps_141t,\r\n\tCardIds.Onyxia_OnyxianWhelpToken,\r\n];\r\nconst CANT_ATTACK_IDS = [CardIds.ArcaneCannon_BGS_077, CardIds.ArcaneCannon_TB_BaconUps_128];\r\n\r\nexport const buildSingleBoardEntity = (\r\n\tcardId: string,\r\n\tcontrollerHero: BgsPlayerEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tfriendly: boolean,\r\n\tentityId = 1,\r\n\tspawnReborn = false,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tentityToSpawn: BoardEntity,\r\n\toriginalEntity: BoardEntity = null,\r\n): BoardEntity => {\r\n\tconst card = allCards.getCard(cardId);\r\n\tconst attackImmediately = ATTACK_IMMEDIATELY_IDS.indexOf(cardId as CardIds) !== -1;\r\n\tconst newEntity = !!entityToSpawn\r\n\t\t? ({\r\n\t\t\t\t...entityToSpawn,\r\n\t\t\t\tentityId: sharedState.currentEntityId++,\r\n\t\t\t\tdefinitelyDead: false,\r\n\t\t\t\tavengeCurrent: entityToSpawn.avengeDefault,\r\n\t\t\t\tattacking: false,\r\n\t\t\t\tdamageMultiplier: 1,\r\n\t\t\t\tfrenzyChargesLeft: 1,\r\n\t\t\t\tfriendly: friendly,\r\n\t\t } as BoardEntity)\r\n\t\t: addImpliedMechanics(\r\n\t\t\t\t{\r\n\t\t\t\t\tentityId: entityId,\r\n\t\t\t\t\tattack: card.attack,\r\n\t\t\t\t\tattacksPerformed: 0,\r\n\t\t\t\t\tcardId: cardId,\r\n\t\t\t\t\tdivineShield: hasMechanic(card, 'DIVINE_SHIELD'),\r\n\t\t\t\t\thealth: card.health,\r\n\t\t\t\t\tmaxHealth: card.health,\r\n\t\t\t\t\ttaunt: hasMechanic(card, GameTag[GameTag.TAUNT]),\r\n\t\t\t\t\treborn: hasMechanic(card, 'REBORN'),\r\n\t\t\t\t\tpoisonous: hasMechanic(card, GameTag[GameTag.POISONOUS]),\r\n\t\t\t\t\tvenomous: hasMechanic(card, GameTag[GameTag.VENOMOUS]),\r\n\t\t\t\t\twindfury:\r\n\t\t\t\t\t\thasMechanic(card, GameTag[GameTag.WINDFURY]) ||\r\n\t\t\t\t\t\tcard.referencedTags?.includes(GameTag[GameTag.WINDFURY]),\r\n\t\t\t\t\tenchantments: [],\r\n\t\t\t\t\tfriendly: friendly,\r\n\t\t\t\t\tattackImmediately: attackImmediately,\r\n\t\t\t\t\tavengeCurrent: cardsData.avengeValue(cardId),\r\n\t\t\t\t\tavengeDefault: cardsData.avengeValue(cardId),\r\n\t\t\t\t} as BoardEntity,\r\n\t\t\t\tcardsData,\r\n\t\t );\r\n\r\n\tif (spawnReborn && !entityToSpawn) {\r\n\t\tif (cardId === CardIds.BuildAnUndead_PutricidesCreationToken) {\r\n\t\t\tconst stitchedCardId = !!originalEntity.additionalCards?.length ? originalEntity.additionalCards[0] : null;\r\n\t\t\tif (stitchedCardId) {\r\n\t\t\t\tconst stitchedCard = allCards.getCard(stitchedCardId);\r\n\t\t\t\tnewEntity.attack = newEntity.attack + stitchedCard.attack;\r\n\t\t\t\tnewEntity.maxHealth = newEntity.maxHealth + stitchedCard.health;\r\n\t\t\t\tnewEntity.taunt = newEntity.taunt || hasMechanic(stitchedCard, GameTag[GameTag.TAUNT]);\r\n\t\t\t\tnewEntity.divineShield =\r\n\t\t\t\t\tnewEntity.divineShield || hasMechanic(stitchedCard, GameTag[GameTag.DIVINE_SHIELD]);\r\n\t\t\t\tnewEntity.poisonous = newEntity.poisonous || hasMechanic(stitchedCard, GameTag[GameTag.POISONOUS]);\r\n\t\t\t\tnewEntity.venomous = newEntity.venomous || hasMechanic(stitchedCard, GameTag[GameTag.VENOMOUS]);\r\n\t\t\t\tnewEntity.windfury = newEntity.windfury || hasMechanic(stitchedCard, GameTag[GameTag.WINDFURY]);\r\n\t\t\t\tnewEntity.avengeCurrent = newEntity.avengeCurrent || cardsData.avengeValue(stitchedCardId);\r\n\t\t\t\tnewEntity.avengeDefault = newEntity.avengeDefault || cardsData.avengeValue(stitchedCardId);\r\n\t\t\t}\r\n\t\t}\r\n\t\tnewEntity.health = 1;\r\n\t\tnewEntity.reborn = false;\r\n\t}\r\n\r\n\tnewEntity.hadDivineShield = newEntity.divineShield || newEntity.hadDivineShield;\r\n\treturn newEntity;\r\n};\r\n\r\nexport const buildRandomUndeadCreation = (\r\n\tcontrollerHero: BgsPlayerEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tfriendly: boolean,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n): BoardEntity => {\r\n\tconst baseCard = pickRandom(cardsData.putricidePool1);\r\n\tconst stitchedCardId =\r\n\t\tbaseCard === CardIds.EternalSummoner_BG25_009\r\n\t\t\t? pickRandom(cardsData.putridicePool2ForEternalSummoner)\r\n\t\t\t: pickRandom(cardsData.putricidePool2);\r\n\tconst newEntity = buildSingleBoardEntity(\r\n\t\tbaseCard,\r\n\t\tcontrollerHero,\r\n\t\tfriendlyBoard,\r\n\t\tallCards,\r\n\t\tfriendly,\r\n\t\tsharedState.currentEntityId++,\r\n\t\tfalse,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tnull,\r\n\t);\r\n\tconst stitchedCard = allCards.getCard(stitchedCardId);\r\n\tnewEntity.attack += stitchedCard.attack;\r\n\tnewEntity.health += stitchedCard.health;\r\n\tnewEntity.taunt = newEntity.taunt || hasMechanic(stitchedCard, GameTag[GameTag.TAUNT]);\r\n\tnewEntity.divineShield = newEntity.divineShield || hasMechanic(stitchedCard, GameTag[GameTag.DIVINE_SHIELD]);\r\n\tnewEntity.poisonous = newEntity.venomous || hasMechanic(stitchedCard, GameTag[GameTag.POISONOUS]);\r\n\tnewEntity.venomous = newEntity.poisonous || hasMechanic(stitchedCard, GameTag[GameTag.VENOMOUS]);\r\n\tnewEntity.windfury = newEntity.windfury || hasMechanic(stitchedCard, GameTag[GameTag.WINDFURY]);\r\n\tnewEntity.avengeCurrent = newEntity.avengeCurrent || cardsData.avengeValue(stitchedCardId);\r\n\tnewEntity.avengeDefault = newEntity.avengeDefault || cardsData.avengeValue(stitchedCardId);\r\n\treturn newEntity;\r\n};\r\n\r\nexport const modifyAttack = (\r\n\tentity: BoardEntity,\r\n\tamount: number,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator = null,\r\n): void => {\r\n\tconst realAmount = entity.cardId === CardIds.Tarecgosa_BG21_015_G ? 2 * amount : amount;\r\n\tentity.attack = Math.max(0, entity.attack + realAmount);\r\n\tentity.previousAttack = entity.attack;\r\n\tif (isCorrectTribe(allCards.getCard(entity.cardId).races, Race.DRAGON)) {\r\n\t\tconst whelpSmugglers = friendlyBoard.filter(\r\n\t\t\t(e) => e.cardId === CardIds.WhelpSmuggler_BG21_013 || e.cardId === CardIds.WhelpSmuggler_BG21_013_G,\r\n\t\t);\r\n\t\twhelpSmugglers.forEach((smuggler) => {\r\n\t\t\tconst buff = smuggler.cardId === CardIds.WhelpSmuggler_BG21_013_G ? 2 : 1;\r\n\t\t\tmodifyHealth(entity, buff, friendlyBoard, allCards);\r\n\t\t});\r\n\r\n\t\tif (entity.cardId !== CardIds.Stormbringer_BG26_966 && entity.cardId !== CardIds.Stormbringer_BG26_966_G) {\r\n\t\t\tconst stormbringers = friendlyBoard.filter(\r\n\t\t\t\t(e) => e.cardId === CardIds.Stormbringer_BG26_966 || e.cardId === CardIds.Stormbringer_BG26_966_G,\r\n\t\t\t);\r\n\t\t\tstormbringers.forEach((stormbringer) => {\r\n\t\t\t\tconst multiplier = stormbringer.cardId === CardIds.Stormbringer_BG26_966_G ? 2 : 1;\r\n\t\t\t\t(e) => modifyAttack(e, multiplier * amount, friendlyBoard, allCards);\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\tif (\r\n\t\tentity.cardId === CardIds.Menagerist_AmalgamToken ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A_G ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D_G\r\n\t) {\r\n\t\tconst mishmashes = friendlyBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy ||\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G,\r\n\t\t);\r\n\t\tmishmashes.forEach((mishmash) => {\r\n\t\t\tmodifyAttack(\r\n\t\t\t\tmishmash,\r\n\t\t\t\t(mishmash.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G ? 2 : 1) * realAmount,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tallCards,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\r\n\tif ([CardIds.HunterOfGatherers_BG25_027, CardIds.HunterOfGatherers_BG25_027_G].includes(entity.cardId as CardIds)) {\r\n\t\taddStatsToBoard(\r\n\t\t\tentity,\r\n\t\t\tfriendlyBoard,\r\n\t\t\t0,\r\n\t\t\tentity.cardId === CardIds.HunterOfGatherers_BG25_027_G ? 2 : 1,\r\n\t\t\tallCards,\r\n\t\t\tnull,\r\n\t\t);\r\n\t}\r\n};\r\n\r\nexport const modifyHealth = (\r\n\tentity: BoardEntity,\r\n\tamount: number,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\tconst realAmount = entity.cardId === CardIds.Tarecgosa_BG21_015 ? 2 * amount : amount;\r\n\tentity.health += realAmount;\r\n\tif (realAmount > 0) {\r\n\t\tentity.maxHealth += realAmount;\r\n\t}\r\n\tif (\r\n\t\tentity.cardId === CardIds.Menagerist_AmalgamToken ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A_G ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D_G\r\n\t) {\r\n\t\tconst mishmashes = friendlyBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy ||\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G,\r\n\t\t);\r\n\t\tmishmashes.forEach((mishmash) => {\r\n\t\t\tmodifyHealth(\r\n\t\t\t\tmishmash,\r\n\t\t\t\t(mishmash.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G ? 2 : 1) * realAmount,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tallCards,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\r\n\tconst titanicGuardians = friendlyBoard\r\n\t\t.filter((e) => e.entityId !== entity.entityId)\r\n\t\t.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy ||\r\n\t\t\t\te.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy_G,\r\n\t\t);\r\n\ttitanicGuardians.forEach((guardian) => {\r\n\t\tmodifyHealth(\r\n\t\t\tguardian,\r\n\t\t\t(guardian.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy_G ? 2 : 1) * realAmount,\r\n\t\t\tfriendlyBoard,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t});\r\n};\r\n\r\nexport const afterStatsUpdate = (\r\n\tentity: BoardEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\tif (hasCorrectTribe(entity, Race.ELEMENTAL, allCards)) {\r\n\t\tconst masterOfRealities = friendlyBoard.filter(\r\n\t\t\t(e) => e.cardId === CardIds.MasterOfRealities_BG21_036 || e.cardId === CardIds.MasterOfRealities_BG21_036_G,\r\n\t\t);\r\n\t\tmasterOfRealities.forEach((master) => {\r\n\t\t\tmodifyAttack(\r\n\t\t\t\tmaster,\r\n\t\t\t\tmaster.cardId === CardIds.MasterOfRealities_BG21_036_G ? 2 : 1,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tallCards,\r\n\t\t\t);\r\n\t\t\tmodifyHealth(\r\n\t\t\t\tmaster,\r\n\t\t\t\tmaster.cardId === CardIds.MasterOfRealities_BG21_036_G ? 2 : 1,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tallCards,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\tconst tentaclesOfCthun = friendlyBoard\r\n\t\t.filter((e) => e.entityId !== entity.entityId)\r\n\t\t.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy ||\r\n\t\t\t\te.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G,\r\n\t\t);\r\n\ttentaclesOfCthun.forEach((tentacle) => {\r\n\t\tmodifyAttack(\r\n\t\t\ttentacle,\r\n\t\t\ttentacle.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G ? 2 : 1,\r\n\t\t\tfriendlyBoard,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t\tmodifyHealth(\r\n\t\t\ttentacle,\r\n\t\t\ttentacle.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G ? 2 : 1,\r\n\t\t\tfriendlyBoard,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t});\r\n};\r\n\r\nexport const makeMinionGolden = (\r\n\ttarget: BoardEntity,\r\n\tsource: BoardEntity | BgsPlayerEntity,\r\n\tsourceBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// Typically, we are already golden\r\n\tif (isMinionGolden(target, allCards)) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst refCard = allCards.getCard(target.cardId);\r\n\tconst goldenCard = allCards.getCardFromDbfId(refCard.battlegroundsPremiumDbfId);\r\n\ttarget.cardId = goldenCard.id;\r\n\t// A minion becoming golden ignore the current death.\r\n\t// This way of handling it is not ideal, since it will still trigger if both avenges trigger at the same time, but\r\n\t// should solve the other cases\r\n\ttarget.avengeCurrent = Math.min(target.avengeDefault, target.avengeCurrent + 1);\r\n\tmodifyAttack(target, refCard.attack, sourceBoard, allCards);\r\n\tmodifyHealth(target, refCard.health, sourceBoard, allCards);\r\n\tafterStatsUpdate(target, sourceBoard, allCards);\r\n\tspectator.registerPowerTarget(source, target, sourceBoard);\r\n};\r\n\r\nexport const isMinionGolden = (entity: BoardEntity, allCards: AllCardsService): boolean => {\r\n\tconst ref = allCards.getCard(entity.cardId);\r\n\treturn !ref.battlegroundsPremiumDbfId;\r\n\t// Why this condition?\r\n\t// || !allCards.getCardFromDbfId(ref.battlegroundsPremiumDbfId).id\r\n};\r\n\r\nexport const grantRandomAttack = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tadditionalAttack: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\texcludeSource = false,\r\n): void => {\r\n\tconst candidateBoard = board\r\n\t\t.filter((e) => !excludeSource || e.entityId !== source.entityId)\r\n\t\t.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tif (candidateBoard.length > 0) {\r\n\t\tconst target = candidateBoard[Math.floor(Math.random() * candidateBoard.length)];\r\n\t\tmodifyAttack(target, additionalAttack, candidateBoard, allCards);\r\n\t\tafterStatsUpdate(target, candidateBoard, allCards);\r\n\t\tspectator.registerPowerTarget(source, target, board);\r\n\t}\r\n};\r\n\r\nexport const grantRandomHealth = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thealth: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\texcludeSource = false,\r\n): void => {\r\n\tconst candidateBoard = board\r\n\t\t.filter((e) => !excludeSource || e.entityId !== source.entityId)\r\n\t\t.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tif (candidateBoard.length > 0) {\r\n\t\tconst target = candidateBoard[Math.floor(Math.random() * candidateBoard.length)];\r\n\t\tmodifyHealth(target, health, board, allCards);\r\n\t\tafterStatsUpdate(target, board, allCards);\r\n\t\tspectator.registerPowerTarget(source, target, board);\r\n\t}\r\n};\r\n\r\nexport const grantRandomStats = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tattack: number,\r\n\thealth: number,\r\n\trace: Race,\r\n\texcludeSource: boolean,\r\n\tallCards: AllCardsService,\r\n\tspectator?: Spectator,\r\n): BoardEntity => {\r\n\tif (board.length > 0) {\r\n\t\tconst target: BoardEntity = getRandomAliveMinion(\r\n\t\t\tboard.filter((e) => (excludeSource ? e.entityId !== source.entityId : true)),\r\n\t\t\trace,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t\tif (target) {\r\n\t\t\tmodifyAttack(target, attack, board, allCards);\r\n\t\t\tmodifyHealth(target, health, board, allCards);\r\n\t\t\tafterStatsUpdate(target, board, allCards);\r\n\t\t\tif (spectator) {\r\n\t\t\t\tspectator.registerPowerTarget(source, target, board);\r\n\t\t\t}\r\n\t\t\treturn target;\r\n\t\t}\r\n\t}\r\n\treturn null;\r\n};\r\n\r\nexport const addCardsInHand = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tboard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tcardsAdded: readonly any[],\r\n): void => {\r\n\tconst previousCardsInHand = playerEntity.hand?.length ?? 0;\r\n\tconst sages = board.filter((e) => e.cardId === CardIds.DeathsHeadSage_BG20_HERO_103_Buddy);\r\n\tconst sagesGolden = board.filter((e) => e.cardId === CardIds.DeathsHeadSage_BG20_HERO_103_Buddy_G);\r\n\tconst multiplier = sages.length + 2 * sagesGolden.length;\r\n\r\n\tconst cardsThatWillBeAdded = [];\r\n\tfor (const cardAdded of cardsAdded) {\r\n\t\tconst cardToAdd: { cardId: string } = (cardAdded as BoardEntity)?.cardId\r\n\t\t\t? (cardAdded as BoardEntity)\r\n\t\t\t: ({ cardId: cardAdded as string } as BoardEntity);\r\n\t\tcardsThatWillBeAdded.push(cardToAdd);\r\n\t\tif (cardToAdd.cardId === CardIds.BloodGem) {\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tcardsThatWillBeAdded.push({ ...cardToAdd });\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tfor (let i = 0; i < cardsThatWillBeAdded.length; i++) {\r\n\t\tif (playerEntity.hand.length >= 10) {\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tplayerEntity.hand.push(cardsThatWillBeAdded[i]);\r\n\t}\r\n\r\n\tconst numCardsAdded = playerEntity.hand.length - previousCardsInHand;\r\n\r\n\tfor (let i = 0; i < numCardsAdded; i++) {\r\n\t\tconst peggys = board.filter(\r\n\t\t\t(e) => e.cardId === CardIds.PeggySturdybone_BG25_032 || e.cardId === CardIds.PeggySturdybone_BG25_032_G,\r\n\t\t);\r\n\t\tpeggys.forEach((peggy) => {\r\n\t\t\tconst pirate = getRandomAliveMinion(\r\n\t\t\t\tboard.filter((e) => e.entityId !== peggy.entityId),\r\n\t\t\t\tRace.PIRATE,\r\n\t\t\t\tallCards,\r\n\t\t\t);\r\n\t\t\tif (pirate) {\r\n\t\t\t\tmodifyAttack(pirate, peggy.cardId === CardIds.PeggySturdybone_BG25_032_G ? 2 : 1, board, allCards);\r\n\t\t\t\tmodifyHealth(pirate, peggy.cardId === CardIds.PeggySturdybone_BG25_032_G ? 2 : 1, board, allCards);\r\n\t\t\t\tafterStatsUpdate(pirate, board, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(peggy, pirate, board);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tconst thornCaptains = board.filter(\r\n\t\t\t(e) => e.cardId === CardIds.Thorncaptain_BG25_045 || e.cardId === CardIds.Thorncaptain_BG25_045_G,\r\n\t\t);\r\n\t\tthornCaptains.forEach((captain) => {\r\n\t\t\tmodifyHealth(captain, captain.cardId === CardIds.Thorncaptain_BG25_045_G ? 2 : 1, board, allCards);\r\n\t\t\tafterStatsUpdate(captain, board, allCards);\r\n\t\t\tspectator.registerPowerTarget(captain, captain, board);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const removeCardFromHand = (playerEntity: BgsPlayerEntity, card: BoardEntity): void => {\r\n\tlet cardToRemove: BoardEntity;\r\n\tif (card?.entityId) {\r\n\t\tcardToRemove = playerEntity.hand.find((c) => c?.entityId !== card.entityId);\r\n\t} else if (card?.cardId) {\r\n\t\tcardToRemove = playerEntity.hand.find((c) => c?.cardId === card.cardId);\r\n\t} else {\r\n\t\t// Remove a single random card in hand that doesn't have an entityId\r\n\t\tcardToRemove =\r\n\t\t\tpickRandom(playerEntity.hand.filter((c) => !c?.entityId && !c?.cardId)) ?? pickRandom(playerEntity.hand);\r\n\t}\r\n\t// Remove the first occurrence of the card from playerEntity.cardsInHand, even if it is null\r\n\tconst index = playerEntity.hand.indexOf(cardToRemove);\r\n\tif (index !== -1) {\r\n\t\tplayerEntity.hand.splice(index, 1);\r\n\t}\r\n};\r\n\r\nexport const grantRandomDivineShield = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst elligibleEntities = board\r\n\t\t.filter((entity) => !entity.divineShield)\r\n\t\t.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\tif (elligibleEntities.length > 0) {\r\n\t\tconst chosen = elligibleEntities[Math.floor(Math.random() * elligibleEntities.length)];\r\n\t\tupdateDivineShield(chosen, board, true, allCards);\r\n\t\tspectator.registerPowerTarget(source, chosen, board);\r\n\t}\r\n\t// return board;\r\n};\r\n\r\nexport const updateDivineShield = (\r\n\tentity: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tnewValue: boolean,\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\t// if ((entity.divineShield ?? false) === newValue) {\r\n\t// \treturn;\r\n\t// }\r\n\tentity.divineShield = newValue;\r\n\tif (entity.divineShield) {\r\n\t\tentity.hadDivineShield = true;\r\n\t}\r\n\tif (entity.divineShield) {\r\n\t\tconst boardForDrake = board;\r\n\t\tconst statsBonus =\r\n\t\t\t8 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043).length +\r\n\t\t\t16 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043_G).length;\r\n\t\t// Don't trigger all \"on attack changed\" effects, since it's an aura\r\n\t\tentity.attack += statsBonus;\r\n\t} else {\r\n\t\t// Also consider itself\r\n\t\tconst boardForDrake = board;\r\n\t\tconst statsBonus =\r\n\t\t\t8 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043).length +\r\n\t\t\t16 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043_G).length;\r\n\t\tentity.attack -= statsBonus;\r\n\t}\r\n};\r\n\r\nexport const grantAllDivineShield = (board: BoardEntity[], tribe: string, cards: AllCardsService): void => {\r\n\tconst elligibleEntities = board\r\n\t\t.filter((entity) => !entity.divineShield)\r\n\t\t.filter((entity) => isCorrectTribe(cards.getCard(entity.cardId).races, getRaceEnum(tribe)));\r\n\tfor (const entity of elligibleEntities) {\r\n\t\tupdateDivineShield(entity, board, true, cards);\r\n\t}\r\n};\r\n\r\nexport const getRandomAliveMinion = (board: BoardEntity[], race: Race, allCards: AllCardsService): BoardEntity => {\r\n\tconst validTribes = board\r\n\t\t.filter((e) => !race || isCorrectTribe(allCards.getCard(e?.cardId).races, race))\r\n\t\t.filter((e) => !!e?.health && !e.definitelyDead);\r\n\tif (!validTribes.length) {\r\n\t\treturn null;\r\n\t}\r\n\tconst randomIndex = Math.floor(Math.random() * validTribes.length);\r\n\treturn validTribes[randomIndex];\r\n};\r\n\r\nexport const getRandomMinionWithHighestHealth = (board: BoardEntity[]): BoardEntity => {\r\n\tif (!board.length) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tconst highestHealth = Math.max(...board.map((e) => e.health));\r\n\tconst validMinions = board.filter((e) => e.health === highestHealth);\r\n\treturn validMinions[Math.floor(Math.random() * validMinions.length)];\r\n};\r\n\r\nexport const addStatsToBoard = (\r\n\tsourceEntity: BoardEntity | BgsPlayerEntity,\r\n\tboard: BoardEntity[],\r\n\tattack: number,\r\n\thealth: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\ttribe?: string,\r\n): void => {\r\n\tfor (const entity of board) {\r\n\t\tif (!tribe || hasCorrectTribe(entity, Race[tribe], allCards)) {\r\n\t\t\tmodifyAttack(entity, attack, board, allCards);\r\n\t\t\tmodifyHealth(entity, health, board, allCards);\r\n\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\tspectator?.registerPowerTarget(sourceEntity, entity, board);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const grantStatsToMinionsOfEachType = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tattack: number,\r\n\thealth: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tnumberOfDifferentTypes = 99,\r\n): void => {\r\n\tif (board.length > 0) {\r\n\t\tlet boardCopy = [...board];\r\n\t\tconst allRaces = shuffleArray(ALL_BG_RACES);\r\n\t\tlet typesBuffed = 0;\r\n\t\tfor (const tribe of allRaces) {\r\n\t\t\tif (typesBuffed >= numberOfDifferentTypes) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tconst validMinion: BoardEntity = getRandomAliveMinion(boardCopy, tribe, allCards);\r\n\t\t\tif (validMinion) {\r\n\t\t\t\tmodifyAttack(validMinion, attack, board, allCards);\r\n\t\t\t\tmodifyHealth(validMinion, health, board, allCards);\r\n\t\t\t\tafterStatsUpdate(validMinion, board, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(source, validMinion, board);\r\n\t\t\t\tboardCopy = boardCopy.filter((e) => e !== validMinion);\r\n\t\t\t\ttypesBuffed++;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const hasMechanic = (card: ReferenceCard, mechanic: string): boolean => {\r\n\treturn card.mechanics?.includes(mechanic);\r\n};\r\n\r\nexport const hasCorrectTribe = (entity: BoardEntity, targetTribe: Race, allCards: AllCardsService): boolean => {\r\n\treturn isCorrectTribe(allCards.getCard(entity.cardId).races, targetTribe);\r\n};\r\n\r\nexport const isCorrectTribe = (cardRaces: readonly string[], targetTribe: Race): boolean => {\r\n\tif (!cardRaces?.length) {\r\n\t\treturn false;\r\n\t}\r\n\treturn cardRaces\r\n\t\t.map((cardRace) => getRaceEnum(cardRace))\r\n\t\t.some((raceEnum) => raceEnum === Race.ALL || raceEnum === targetTribe);\r\n};\r\n\r\nexport const getRaceEnum = (race: string): Race => {\r\n\treturn Race[race];\r\n};\r\n\r\nexport const addImpliedMechanics = (entity: BoardEntity, cardsData: CardsData): BoardEntity => {\r\n\tconst cleave = CLEAVE_IDS.indexOf(entity.cardId as CardIds) !== -1;\r\n\tconst cantAttack = CANT_ATTACK_IDS.indexOf(entity.cardId as CardIds) !== -1;\r\n\treturn setImplicitDataForEntity(\r\n\t\t{\r\n\t\t\t...entity,\r\n\t\t\tcleave: cleave,\r\n\t\t\tcantAttack: cantAttack,\r\n\t\t\timmuneWhenAttackCharges:\r\n\t\t\t\tentity.cardId === CardIds.Warpwing_BG24_004 || entity.cardId === CardIds.Warpwing_BG24_004_G\r\n\t\t\t\t\t? 99999\r\n\t\t\t\t\t: 0,\r\n\t\t\tfrenzyChargesLeft:\r\n\t\t\t\tentity.cardId === CardIds.BristlebackKnight_BG20_204_G\r\n\t\t\t\t\t? 2\r\n\t\t\t\t\t: entity.cardId === CardIds.BristlebackKnight_BG20_204\r\n\t\t\t\t\t? 1\r\n\t\t\t\t\t: 0,\r\n\t\t\t// It's not an issue adding a charge for entities without a special ability\r\n\t\t\tabiityChargesLeft: [CardIds.TransmutedBramblewitch_BG27_013_G, CardIds.Mannoroth_BG27_507_G].includes(\r\n\t\t\t\tentity.cardId as CardIds,\r\n\t\t\t)\r\n\t\t\t\t? 2\r\n\t\t\t\t: 1,\r\n\t\t} as BoardEntity,\r\n\t\tcardsData,\r\n\t);\r\n};\r\n\r\nconst setImplicitDataForEntity = (entity: BoardEntity, cardsData: CardsData): BoardEntity => {\r\n\tentity.cardId = normalizeCardIdForSkin(entity.cardId);\r\n\tentity.maxHealth = Math.max(0, entity.health);\r\n\tconst avengeValue = cardsData.avengeValue(entity.cardId);\r\n\tif (avengeValue > 0) {\r\n\t\tentity.avengeCurrent = avengeValue;\r\n\t\tentity.avengeDefault = avengeValue;\r\n\t}\r\n\treturn entity;\r\n};\r\n\r\nexport const normalizeCardIdForSkin = (cardId: string): string => {\r\n\tif (!cardId?.length) {\r\n\t\treturn cardId;\r\n\t}\r\n\tconst skinMatch = cardId.match(/(.*)_SKIN_.*/);\r\n\tif (skinMatch) {\r\n\t\treturn skinMatch[1];\r\n\t}\r\n\treturn cardId;\r\n};\r\n\r\nexport const stringifySimple = (board: readonly BoardEntity[], allCards: AllCardsService = null): string => {\r\n\treturn '[' + board.map((entity) => stringifySimpleCard(entity, allCards)).join(', ') + ']';\r\n};\r\n\r\nexport const stringifySimpleCard = (entity: BoardEntity, allCards: AllCardsService = null): string => {\r\n\treturn entity\r\n\t\t? `${entity.cardId}/${allCards?.getCard(entity.cardId)?.name ?? ''}/atk=${entity.attack}/hp=${\r\n\t\t\t\tentity.health\r\n\t\t }/ds=${entity.divineShield}`\r\n\t\t: null;\r\n};\r\n\r\nexport const isFish = (entity: BoardEntity): boolean => {\r\n\treturn (\r\n\t\tentity.cardId.startsWith(CardIds.AvatarOfNzoth_FishOfNzothToken) ||\r\n\t\tentity.cardId.startsWith(CardIds.FishOfNzoth) ||\r\n\t\tentity.additionalCards?.includes(CardIds.DevourerOfSouls_BG_RLK_538)\r\n\t);\r\n};\r\n\r\nexport const isGolden = (cardId: string, allCards: AllCardsService): boolean => {\r\n\treturn !!allCards.getCard(cardId).battlegroundsNormalDbfId;\r\n};\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestone-hs/simulate-bgs-battle",
3
- "version": "1.1.314",
3
+ "version": "1.1.316",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "lint": "eslint --color --fix --ext .ts .",