@firestone-hs/simulate-bgs-battle 1.1.630 → 1.1.631
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cards/impl/hero-power/fragrant-phylactery.js +8 -6
- package/dist/cards/impl/hero-power/fragrant-phylactery.js.map +1 -1
- package/dist/simulation/deathrattle-effects.js +0 -1
- package/dist/simulation/deathrattle-effects.js.map +1 -1
- package/dist/simulation/summon-when-space.js +3 -3
- package/dist/simulation/summon-when-space.js.map +1 -1
- package/package.json +1 -1
|
@@ -7,12 +7,14 @@ exports.FragrantPhylactery = {
|
|
|
7
7
|
cardIds: ["BG20_HERO_282p"],
|
|
8
8
|
startOfCombat: (trinket, input) => {
|
|
9
9
|
const lowestAttack = (0, utils_1.pickRandomLowestAttack)(input.playerBoard);
|
|
10
|
-
lowestAttack
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
if (!!lowestAttack) {
|
|
11
|
+
lowestAttack.enchantments.push({
|
|
12
|
+
cardId: "BG20_HERO_282pe",
|
|
13
|
+
originEntityId: trinket.entityId,
|
|
14
|
+
timing: input.gameState.sharedState.currentEntityId++,
|
|
15
|
+
});
|
|
16
|
+
input.gameState.spectator.registerPowerTarget(input.playerEntity, lowestAttack, input.playerBoard, null, null);
|
|
17
|
+
}
|
|
16
18
|
return { hasTriggered: true, shouldRecomputeCurrentAttacker: false };
|
|
17
19
|
},
|
|
18
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fragrant-phylactery.js","sourceRoot":"","sources":["../../../../src/cards/impl/hero-power/fragrant-phylactery.ts"],"names":[],"mappings":";;;AAEA,mDAAiE;AAIpD,QAAA,kBAAkB,GAAsB;IACpD,mBAAmB,EAAE,YAAY;IACjC,OAAO,EAAE,kBAAwC;IACjD,aAAa,EAAE,CAAC,OAAqB,EAAE,KAAe,EAAE,EAAE;QACzD,MAAM,YAAY,GAAG,IAAA,8BAAsB,EAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC/D,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"fragrant-phylactery.js","sourceRoot":"","sources":["../../../../src/cards/impl/hero-power/fragrant-phylactery.ts"],"names":[],"mappings":";;;AAEA,mDAAiE;AAIpD,QAAA,kBAAkB,GAAsB;IACpD,mBAAmB,EAAE,YAAY;IACjC,OAAO,EAAE,kBAAwC;IACjD,aAAa,EAAE,CAAC,OAAqB,EAAE,KAAe,EAAE,EAAE;QACzD,MAAM,YAAY,GAAG,IAAA,8BAAsB,EAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC/D,IAAI,CAAC,CAAC,YAAY,EAAE;YACnB,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC;gBAC9B,MAAM,mBAAgD;gBACtD,cAAc,EAAE,OAAO,CAAC,QAAQ;gBAChC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,eAAe,EAAE;aACrD,CAAC,CAAC;YACH,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAC5C,KAAK,CAAC,YAAY,EAClB,YAAY,EACZ,KAAK,CAAC,WAAW,EACjB,IAAI,EACJ,IAAI,CACJ,CAAC;SACF;QACD,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,8BAA8B,EAAE,KAAK,EAAE,CAAC;IACtE,CAAC;CACD,CAAC","sourcesContent":["import { BoardTrinket } from '../../../bgs-player-entity';\r\nimport { CardIds } from '../../../services/card-ids';\r\nimport { pickRandomLowestAttack } from '../../../services/utils';\r\nimport { SoCInput } from '../../../simulation/start-of-combat/start-of-combat-input';\r\nimport { StartOfCombatCard } from '../../card.interface';\r\n\r\nexport const FragrantPhylactery: StartOfCombatCard = {\r\n\tstartOfCombatTiming: 'pre-combat',\r\n\tcardIds: [CardIds.TamsinRoame_FragrantPhylactery],\r\n\tstartOfCombat: (trinket: BoardTrinket, input: SoCInput) => {\r\n\t\tconst lowestAttack = pickRandomLowestAttack(input.playerBoard);\r\n\t\tif (!!lowestAttack) {\r\n\t\t\tlowestAttack.enchantments.push({\r\n\t\t\t\tcardId: CardIds.FragrantPhylactery_FragrantEnchantment,\r\n\t\t\t\toriginEntityId: trinket.entityId,\r\n\t\t\t\ttiming: input.gameState.sharedState.currentEntityId++,\r\n\t\t\t});\r\n\t\t\tinput.gameState.spectator.registerPowerTarget(\r\n\t\t\t\tinput.playerEntity,\r\n\t\t\t\tlowestAttack,\r\n\t\t\t\tinput.playerBoard,\r\n\t\t\t\tnull,\r\n\t\t\t\tnull,\r\n\t\t\t);\r\n\t\t}\r\n\t\treturn { hasTriggered: true, shouldRecomputeCurrentAttacker: false };\r\n\t},\r\n};\r\n"]}
|
|
@@ -54,7 +54,6 @@ const applyWaterInvocationEnchantment = (boardWithDeadEntity, boardWithDeadEntit
|
|
|
54
54
|
if (!!target) {
|
|
55
55
|
(0, taunt_1.updateTaunt)(target, true, boardWithDeadEntity, boardWithDeadEntityHero, otherHero, gameState);
|
|
56
56
|
(0, divine_shield_1.updateDivineShield)(target, boardWithDeadEntity, boardWithDeadEntityHero, otherHero, true, gameState);
|
|
57
|
-
(0, stats_1.modifyStats)(target, sourceEntity, 0, 3, boardWithDeadEntity, boardWithDeadEntityHero, gameState);
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
59
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deathrattle-effects.js","sourceRoot":"","sources":["../../src/simulation/deathrattle-effects.ts"],"names":[],"mappings":";;;AACA,iEAA8E;AAI9E,6EAAkG;AAClG,6DAA+D;AAC/D,6CAAgD;AAEhD,6CAAgE;AAChE,gEAAuE;AACvE,oCAOkB;AAClB,qCAA8C;AAC9C,mDAAiD;AACjD,6DAAqD;AAErD,qEAAwE;AAExE,mCAAsC;AAEtC,MAAM,2BAA2B,GAAG,0BAAwE,CAAC;AAEtG,MAAM,4BAA4B,GAAG,CAC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AsB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,IAAI,EAAE,CAAC,EAAE,GAAG,eAAe,CAAC,CAAC;SAC3F;QAED,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,WAAC,OAAA,MAAA,CAAC,CAAC,MAAM,0CAAE,UAAU,YAA8B,CAAA,EAAA,CAAC,EAAE;YAKpF,MAAM,uBAAuB,GAAG,IAAA,qDAA4B,EAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;YAC1F,IAAI,CAAC,sBAAsB,GAAG;gBAC7B,GAAG,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,WAAC,OAAA,CAAC,CAAA,MAAA,CAAC,CAAC,MAAM,0CAAE,UAAU,YAA8B,CAAA,CAAA,EAAA,CAAC;gBACjG,GAAG,uBAAuB;aAC1B,CAAC;SACF;KACD;AAYF,CAAC,CAAC;AAnFW,QAAA,oBAAoB,wBAmF/B;AAEF,MAAM,sBAAsB,GAAG,CAC9B,mBAAkC,EAClC,IAAqB,EACrB,SAAwB,EACvB,EAAE;AAWJ,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, GameTag, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardsData } from '../cards/cards-data';\r\nimport { eternalKnightAttack, eternalKnightHealth } from '../cards/impl/trinket/eternal-portrait';\r\nimport { updateDivineShield } from '../keywords/divine-shield';\r\nimport { updateTaunt } from '../keywords/taunt';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { pickMultipleRandomDifferent } from '../services/utils';\r\nimport { isValidDeathrattleEnchantment } from '../simulate-bgs-battle';\r\nimport {\r\n\tgetRandomMinionWithHighestHealth,\r\n\tgrantRandomStats,\r\n\thasCorrectTribe,\r\n\tisDead,\r\n\tisFish,\r\n\tisGolden,\r\n} from '../utils';\r\nimport { dealDamageToMinion } from './attack';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { groupLeapfroggerDeathrattles } from './remembered-deathrattle';\r\nimport { SharedState } from './shared-state';\r\nimport { modifyStats } from './stats';\r\n\r\nconst DEATHRATTLES_REQUIRE_MEMORY = [CardIds.StitchedSalvager_BG31_999, CardIds.StitchedSalvager_BG31_999_G];\r\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 =\r\n\t\t!!board.find(\r\n\t\t\t(entity) =>\r\n\t\t\t\tentity.cardId === CardIds.BaronRivendare_BG_FP1_031 ||\r\n\t\t\t\tentity.cardId === CardIds.MoiraBronzebeard_BG27_518,\r\n\t\t) || boardHero.secrets?.some((e) => e.cardId === CardIds.TitusTribute_BG28_843);\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 deathlyPhylacteries = boardHero.trinkets.filter(\r\n\t\t(t) => t.cardId === CardIds.DeathlyPhylactery_BG30_MagicItem_700 && t.scriptDataNum1 > 0,\r\n\t).length;\r\n\tconst tombs =\r\n\t\tboardHero.questRewardEntities?.filter((entity) => entity.cardId === CardIds.TurbulentTombs)?.length ?? 0;\r\n\tconst echoesOfArgus = sharedState.anomalies.includes(CardIds.EchoesOfArgus_BG27_Anomaly_802) ? 1 : 0;\r\n\tconst scourgeMultiplier = deadEntity.additionalCards?.includes(CardIds.ScourgeTroll) ? 2 : 1;\r\n\r\n\tconst multiplier =\r\n\t\tscourgeMultiplier *\r\n\t\t((goldenRivendare ? 3 : rivendare ? 2 : 1) +\r\n\t\t\tdeathlyPhylacteries +\r\n\t\t\ttitus +\r\n\t\t\t2 * goldenTitus +\r\n\t\t\ttombs +\r\n\t\t\techoesOfArgus);\r\n\treturn multiplier;\r\n};\r\n\r\nexport const applyLightningInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity | BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// Because the golden version doubles all the remembered effects\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst targets = pickMultipleRandomDifferent(otherBoard, 5);\r\n\t\tfor (const target of targets) {\r\n\t\t\tdealDamageToMinion(\r\n\t\t\t\ttarget,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tdeadEntity,\r\n\t\t\t\t1,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyWaterInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity, // Can be null when trinket is used\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst validBoard = boardWithDeadEntity.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\t\tconst target: BoardEntity = validBoard[validBoard.length - 1];\r\n\t\tif (!!target) {\r\n\t\t\tupdateTaunt(target, true, boardWithDeadEntity, boardWithDeadEntityHero, otherHero, gameState);\r\n\t\t\tupdateDivineShield(target, boardWithDeadEntity, boardWithDeadEntityHero, otherHero, true, gameState);\r\n\t\t\tmodifyStats(target, sourceEntity, 0, 3, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyFireInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst target: BoardEntity = boardWithDeadEntity.filter((e) => e.health > 0 && !e.definitelyDead)[0];\r\n\t\tif (!!target) {\r\n\t\t\tmodifyStats(\r\n\t\t\t\ttarget,\r\n\t\t\t\tsourceEntity,\r\n\t\t\t\ttarget.attack,\r\n\t\t\t\t0,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyEarthInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst minionsGrantedDeathrattle: BoardEntity[] = pickMultipleRandomDifferent(boardWithDeadEntity, 4);\r\n\t\tminionsGrantedDeathrattle.forEach((minion) => {\r\n\t\t\tminion.enchantments.push({\r\n\t\t\t\tcardId: CardIds.EarthInvocation_ElementEarthEnchantment,\r\n\t\t\t\toriginEntityId: deadEntity?.entityId,\r\n\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t});\r\n\t\t\tgameState.spectator.registerPowerTarget(sourceEntity, minion, boardWithDeadEntity, null, null);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const applyLeapFroggerEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tgameState: FullGameState,\r\n\tmultiplier: number,\r\n): void => {\r\n\tmultiplier = multiplier ?? deadEntity.deathrattleRepeats ?? 1;\r\n\t// console.debug('applying leapfrogger effect', deadEntity.entityId, multiplier);\r\n\tconst buffed = grantRandomStats(\r\n\t\tdeadEntity,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tmultiplier * (isPremium ? 2 : 1),\r\n\t\tmultiplier * (isPremium ? 2 : 1),\r\n\t\tRace.BEAST,\r\n\t\tfalse,\r\n\t\tgameState,\r\n\t);\r\n\tif (buffed) {\r\n\t\tbuffed.enchantments = 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: gameState.sharedState.currentEntityId++,\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const applyRecurringNightmareDeathrattleEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tgameState: FullGameState,\r\n\tmultiplier = 1,\r\n): void => {\r\n\t// multiplier = multiplier || 1;\r\n\t// const target = pickRandom(\r\n\t// \tboardWithDeadEntity\r\n\t// \t\t.filter((e) =>\r\n\t// \t\t\thasCorrectTribe(e, boardWithDeadEntityHero, Race.UNDEAD, gameState.anomalies, gameState.allCards),\r\n\t// \t\t)\r\n\t// \t\t.filter(\r\n\t// \t\t\t(e) =>\r\n\t// \t\t\t\te.cardId !== CardIds.RecurringNightmare_BG26_055 &&\r\n\t// \t\t\t\te.cardId !== CardIds.RecurringNightmare_BG26_055_G,\r\n\t// \t\t),\r\n\t// );\r\n\t// if (target) {\r\n\t// \ttarget.enchantments = target.enchantments ?? [];\r\n\t// \ttarget.enchantments.push({\r\n\t// \t\tcardId: isPremium\r\n\t// \t\t\t? CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055_Ge\r\n\t// \t\t\t: CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055e,\r\n\t// \t\toriginEntityId: deadEntity.entityId,\r\n\t// \t\trepeats: multiplier > 1 ? multiplier : 1,\r\n\t// \t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t// \t});\r\n\t// \tgameState.spectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity, null, null);\r\n\t// }\r\n};\r\n\r\n// Some minions like Icesnarl can revive themselves when killing a minion, so it needs to be handled before\r\n// we actually make the minion die\r\nexport const handleWheneverMinionsKillEffect = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\thandleWheneverMinionsKillEffectForBoard(board, hero, otherBoard, otherHero, gameState);\r\n\t// It's called once for each board already, so don't duplicate it here\r\n\t// handleWheneverMinionsKillEffectForBoard(otherBoard, otherHero, board, hero, gameState);\r\n};\r\n\r\nconst handleWheneverMinionsKillEffectForBoard = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].health <= 0 || board[i].definitelyDead) {\r\n\t\t\tconst futureDeadEntity = board[i];\r\n\t\t\tconst killer = futureDeadEntity.lastAffectedByEntity;\r\n\t\t\tif (!killer) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Killed an enemy minion\r\n\t\t\tif (killer.friendly !== futureDeadEntity.friendly) {\r\n\t\t\t\tfor (const heroPower of otherHero.heroPowers) {\r\n\t\t\t\t\t// Can't be used to resurrect a dead minion\r\n\t\t\t\t\t// https://replays.firestoneapp.com/?reviewId=d1fffee8-0bc3-40f5-9a59-85eef8367095&turn=11&action=4\r\n\t\t\t\t\tif (heroPower.cardId === CardIds.Rokara_GloryOfCombat && !isDead(killer)) {\r\n\t\t\t\t\t\tmodifyStats(killer, otherHero, 1, 0, otherBoard, otherHero, gameState);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Icesnarl the Mighty\r\n\t\t\t\totherBoard\r\n\t\t\t\t\t.filter(\r\n\t\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\t\te.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy ||\r\n\t\t\t\t\t\t\te.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy_G,\r\n\t\t\t\t\t)\r\n\t\t\t\t\t.forEach((icesnarl) => {\r\n\t\t\t\t\t\tmodifyStats(\r\n\t\t\t\t\t\t\ticesnarl,\r\n\t\t\t\t\t\t\ticesnarl,\r\n\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\ticesnarl.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy_G ? 2 : 1,\r\n\t\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\t\thero,\r\n\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const handleAfterMinionKillsEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// Moved to \"whenever kills\", as these can revive the minion that kills\r\n\t// const killer = deadEntity.lastAffectedByEntity;\r\n\t// if (!killer) {\r\n\t// \treturn;\r\n\t// }\r\n\t// // Killed an enemy minion\r\n\t// if (killer.friendly !== deadEntity.friendly) {\r\n\t// }\r\n};\r\n\r\nexport const applyAfterMinionDiesEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.DEMON, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplySoulJugglerEffect(boardWithDeadEntity, boardWithDeadEntityHero, otherBoard, otherBoardHero, gameState);\r\n\t}\r\n};\r\n\r\nexport const applyWheneverMinionDiesEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// console.log('applying minion death effect', stringifySimpleCard(deadEntity, allCards));\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.BEAST, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplyScavengingHyenaEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.MECH, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplyJunkbotEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.MURLOC, gameState.anomalies, gameState.allCards)) {\r\n\t\tremoveOldMurkEyeAttack(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\tremoveOldMurkEyeAttack(otherBoard, otherBoardHero, gameState);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.ELEMENTAL, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplyMossOfTheSchlossEffect(deadEntity, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\r\n\tif (deadEntity.taunt) {\r\n\t\tapplyBristlemaneScrapsmithEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\tapplyQirajiHarbringerEffect(boardWithDeadEntity, boardWithDeadEntityHero, deadEntityIndexFromRight, gameState);\r\n\t}\r\n\r\n\tif (\r\n\t\tdeadEntity.cardId === CardIds.EternalKnight_BG25_008 ||\r\n\t\tdeadEntity.cardId === CardIds.EternalKnight_BG25_008_G\r\n\t) {\r\n\t\tapplyEternalKnightEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\r\n\t// Putricide-only\r\n\tboardWithDeadEntity\r\n\t\t.filter((e) => e.additionalCards?.includes(CardIds.FlesheatingGhoulLegacy_BG26_tt_004))\r\n\t\t.forEach((e) => {\r\n\t\t\tmodifyStats(e, null, 1, 0, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t});\r\n\r\n\tapplyRotHideGnollEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\r\n\t// Overkill\r\n\tif (\r\n\t\tdeadEntity.health < 0 &&\r\n\t\tgameState.sharedState.currentAttackerEntityId != null &&\r\n\t\tgameState.sharedState.currentAttackerEntityId === deadEntity.lastAffectedByEntity?.entityId\r\n\t) {\r\n\t\t// if (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlame_BGS_032) {\r\n\t\t// \tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t// \tif (targets.length > 0) {\r\n\t\t// \t\tconst target = targets[0];\r\n\t\t// \t\tdealDamageToMinion(\r\n\t\t// \t\t\ttarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\t3,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tgameState,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlame_TB_BaconUps_103) {\r\n\t\t// \tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t// \tif (targets.length > 0) {\r\n\t\t// \t\tconst target = targets[0];\r\n\t\t// \t\tdealDamageToMinion(\r\n\t\t// \t\t\ttarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\t6,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tgameState,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// }\r\n\t\t// else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental && deadEntity.lastAffectedByEntity.attacking) {\r\n\t\t// \t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental) {\r\n\t\t// \t// console.log('applying WildfireElemental effect', stringifySimple(boardWithDeadEntity, allCards));\r\n\t\t// \tconst excessDamage = -deadEntity.health;\r\n\t\t// \t// Prevent propagation of the effect\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking = false;\r\n\t\t// \tconst neighbours = getNeighbours(boardWithDeadEntity, null, boardWithDeadEntity.length - deadEntityIndexFromRight);\r\n\t\t// \t// console.log('neighbours', stringifySimple(neighbours, allCards));\r\n\t\t// \tif (neighbours.length > 0) {\r\n\t\t// \t\tconst randomTarget = neighbours[Math.floor(Math.random() * neighbours.length)];\r\n\t\t// \t\tdealDamageToEnemy(\r\n\t\t// \t\t\trandomTarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\texcessDamage,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tallCards,\r\n\t\t// \t\t\tcardsData,\r\n\t\t// \t\t\tsharedState,\r\n\t\t// \t\t\tspectator,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// } else if (\r\n\t\t// \tdeadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElementalBattlegrounds &&\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking\r\n\t\t// ) {\r\n\t\t// \tconst excessDamage = -deadEntity.health;\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking = false;\r\n\t\t// \tconst neighbours = getNeighbours(boardWithDeadEntity, null, boardWithDeadEntity.length - deadEntityIndexFromRight);\r\n\t\t// \tneighbours.forEach((neighbour) =>\r\n\t\t// \t\tdealDamageToEnemy(\r\n\t\t// \t\t\tneighbour,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\texcessDamage,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tallCards,\r\n\t\t// \t\t\tcardsData,\r\n\t\t// \t\t\tsharedState,\r\n\t\t// \t\t\tspectator,\r\n\t\t// \t\t),\r\n\t\t// \t);\r\n\t\t// }\r\n\t\tif (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn_TRL_232) {\r\n\t\t\tconst newEntities = spawnEntities(\r\n\t\t\t\tCardIds.IronhideDirehorn_IronhideRuntToken_TRL_232t,\r\n\t\t\t\t1,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\t!deadEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t\totherBoard.splice(otherBoard.length - deadEntityIndexFromRight, 0, ...newEntities);\r\n\t\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn_TB_BaconUps_051) {\r\n\t\t\t// \tconst newEntities = spawnEntities(\r\n\t\t\t// \t\tCardIds.IronhideDirehorn_IronhideRuntToken_TB_BaconUps_051t,\r\n\t\t\t// \t\t1,\r\n\t\t\t// \t\totherBoard,\r\n\t\t\t// \t\totherBoardHero,\r\n\t\t\t// \t\tboardWithDeadEntity,\r\n\t\t\t// \t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\tgameState,\r\n\t\t\t// \t\t!deadEntity.friendly,\r\n\t\t\t// \t\tfalse,\r\n\t\t\t// \t);\r\n\t\t\t// \totherBoard.splice(otherBoard.length - deadEntityIndexFromRight, 0, ...newEntities);\r\n\t\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath_BGS_080) {\r\n\t\t\t// \tconst otherPirates = otherBoard\r\n\t\t\t// \t\t.filter((entity) =>\r\n\t\t\t// \t\t\thasCorrectTribe(\r\n\t\t\t// \t\t\t\tentity,\r\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\t\tRace.PIRATE,\r\n\t\t\t// \t\t\t\tgameState.anomalies,\r\n\t\t\t// \t\t\t\tgameState.allCards,\r\n\t\t\t// \t\t\t),\r\n\t\t\t// \t\t)\r\n\t\t\t// \t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\t// \totherPirates.forEach((pirate) => {\r\n\t\t\t// \t\tmodifyStats(\r\n\t\t\t// \t\t\tpirate,\r\n\t\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t// \t\t\t2,\r\n\t\t\t// \t\t\t2,\r\n\t\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\tgameState,\r\n\t\t\t// \t\t);\r\n\t\t\t// \t});\r\n\t\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath_TB_BaconUps_142) {\r\n\t\t\t// \tconst otherPirates = otherBoard\r\n\t\t\t// \t\t.filter((entity) =>\r\n\t\t\t// \t\t\thasCorrectTribe(\r\n\t\t\t// \t\t\t\tentity,\r\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\t\tRace.PIRATE,\r\n\t\t\t// \t\t\t\tgameState.anomalies,\r\n\t\t\t// \t\t\t\tgameState.allCards,\r\n\t\t\t// \t\t\t),\r\n\t\t\t// \t\t)\r\n\t\t\t// \t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\t// \totherPirates.forEach((pirate) => {\r\n\t\t\t// \t\tmodifyStats(\r\n\t\t\t// \t\t\tpirate,\r\n\t\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t// \t\t\t4,\r\n\t\t\t// \t\t\t4,\r\n\t\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\tgameState,\r\n\t\t\t// \t\t);\r\n\t\t\t// \t});\r\n\t\t}\r\n\t}\r\n};\r\n\r\n/** @deprecated */\r\nexport const dealDamageToAllMinions = (\r\n\tboard1: BoardEntity[],\r\n\tboard1Hero: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tboard2Hero: BgsPlayerEntity,\r\n\tdamageSource: BoardEntity,\r\n\tdamageDealt: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (board1.length === 0 && board2.length === 0) {\r\n\t\treturn;\r\n\t}\r\n\tfor (let i = 0; i < board1.length; i++) {\r\n\t\tdealDamageToMinion(board1[i], board1, board1Hero, damageSource, damageDealt, board2, board2Hero, gameState);\r\n\t}\r\n\tfor (let i = 0; i < board2.length; i++) {\r\n\t\tdealDamageToMinion(board2[i], board2, board2Hero, damageSource, damageDealt, board1, board1Hero, gameState);\r\n\t}\r\n};\r\n\r\nexport const applySoulJugglerEffect = (\r\n\tboardWithJugglers: BoardEntity[],\r\n\tboardWithJugglersHero: BgsPlayerEntity,\r\n\tboardToAttack: BoardEntity[],\r\n\tboardToAttackHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (boardWithJugglers.length === 0 && boardToAttack.length === 0) {\r\n\t\treturn;\r\n\t\t// return [boardWithJugglers, boardToAttack];\r\n\t}\r\n\tconst jugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler_BGS_002);\r\n\tfor (const juggler of jugglers) {\r\n\t\tconst target = getRandomMinionWithHighestHealth(boardToAttack);\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tjuggler,\r\n\t\t\ttarget,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tboardToAttackHero,\r\n\t\t);\r\n\t\tdealDamageToMinion(\r\n\t\t\ttarget,\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t4,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\tconst goldenJugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler_TB_BaconUps_075);\r\n\tfor (const juggler of goldenJugglers) {\r\n\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\tconst target = getRandomMinionWithHighestHealth(boardToAttack);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tjuggler,\r\n\t\t\t\ttarget,\r\n\t\t\t\tboardWithJugglers,\r\n\t\t\t\tboardWithJugglersHero,\r\n\t\t\t\tboardToAttackHero,\r\n\t\t\t);\r\n\t\t\tdealDamageToMinion(\r\n\t\t\t\ttarget,\r\n\t\t\t\tboardToAttack,\r\n\t\t\t\tboardToAttackHero,\r\n\t\t\t\tjuggler,\r\n\t\t\t\t4,\r\n\t\t\t\tboardWithJugglers,\r\n\t\t\t\tboardWithJugglersHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\t// processMinionDeath(\r\n\t// \tboardWithJugglers,\r\n\t// \tboardWithJugglersHero,\r\n\t// \tboardToAttack,\r\n\t// \tboardToAttackHero,\r\n\t// \tallCards,\r\n\t// \tcardsData,\r\n\t// \tsharedState,\r\n\t// \tspectator,\r\n\t// );\r\n};\r\n\r\nconst applyScavengingHyenaEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// const copy = [...board];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.ScavengingHyenaLegacy_BG_EX1_531) {\r\n\t\t\tmodifyStats(board[i], null, 2, 1, board, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t} else if (board[i].cardId === CardIds.ScavengingHyenaLegacy_TB_BaconUps_043) {\r\n\t\t\tmodifyStats(board[i], null, 4, 2, board, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyEternalKnightEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (\r\n\t\t\tboard[i].cardId === CardIds.EternalKnight_BG25_008 ||\r\n\t\t\tboard[i].cardId === CardIds.EternalKnight_BG25_008_G\r\n\t\t) {\r\n\t\t\tconst multiplier = board[i].cardId === CardIds.EternalKnight_BG25_008_G ? 2 : 1;\r\n\t\t\tmodifyStats(\r\n\t\t\t\tboard[i],\r\n\t\t\t\tnull,\r\n\t\t\t\tmultiplier * eternalKnightAttack,\r\n\t\t\t\tmultiplier * eternalKnightHealth,\r\n\t\t\t\tboard,\r\n\t\t\t\thero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyRotHideGnollEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.RotHideGnoll_BG25_013 || board[i].cardId === CardIds.RotHideGnoll_BG25_013_G) {\r\n\t\t\tconst multiplier = board[i].cardId === CardIds.RotHideGnoll_BG25_013_G ? 2 : 1;\r\n\t\t\tmodifyStats(board[i], null, multiplier * 1, 0, board, hero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyBristlemaneScrapsmithEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardPlayerEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (\r\n\t\t\tboard[i].cardId === CardIds.BristlemaneScrapsmith_BG24_707 ||\r\n\t\t\tboard[i].cardId === CardIds.BristlemaneScrapsmith_BG24_707_G\r\n\t\t) {\r\n\t\t\tconst cardsToAdd = Array(CardIds.BristlemaneScrapsmith_BG24_707_G ? 2 : 1).fill(CardIds.BloodGem);\r\n\t\t\taddCardsInHand(boardPlayerEntity, board, cardsToAdd, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, boardPlayerEntity, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyMossOfTheSchlossEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tboard\r\n\t\t.filter(\r\n\t\t\t(e) => e.cardId === CardIds.MossOfTheSchloss_BG30_111 || e.cardId === CardIds.MossOfTheSchloss_BG30_111_G,\r\n\t\t)\r\n\t\t.filter((e) => e.abiityChargesLeft > 0)\r\n\t\t.forEach((entity) => {\r\n\t\t\tmodifyStats(entity, null, deadEntity.maxAttack, deadEntity.maxHealth, board, hero, gameState);\r\n\t\t\tentity.abiityChargesLeft--;\r\n\t\t\tgameState.spectator.registerPowerTarget(entity, entity, board, null, null);\r\n\t\t});\r\n};\r\n\r\nconst applyJunkbotEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.Junkbot_GVG_106) {\r\n\t\t\tmodifyStats(board[i], board[i], 2, 2, board, hero, gameState);\r\n\t\t\t// } else if (board[i].cardId === CardIds.Junkbot_TB_BaconUps_046) {\r\n\t\t\t// \tmodifyStats(board[i], board[i], 4, 4, board, hero, gameState);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyQirajiHarbringerEffect = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// const qiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger_BGS_112);\r\n\t// const goldenQiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger_TB_BaconUps_303);\r\n\t// // TODO: if reactivated, properly apply buffs one by one, instead of all together\r\n\t// if (qiraji.length + goldenQiraji.length > 0) {\r\n\t// \tconst neighbours = getNeighbours(board, null, deadEntityIndexFromRight);\r\n\t// \tconst buff = 2 * qiraji.length + 4 * goldenQiraji.length;\r\n\t// \tneighbours.forEach((entity) => {\r\n\t// \t\tmodifyStats(entity, null, buff, buff, board, hero, gameState);\r\n\t// \t});\r\n\t// }\r\n};\r\n\r\nexport const rememberDeathrattles = (\r\n\tfish: BoardEntity,\r\n\tinputDeadEntities: readonly BoardEntity[],\r\n\tcardsData: CardsData,\r\n\tallCards: AllCardsService,\r\n\tsharedState: SharedState,\r\n): void => {\r\n\tconst deadEntities = inputDeadEntities.filter((e) => !isFish(e));\r\n\tif (!deadEntities?.length) {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// Some infinite loops going on?\r\n\tif (fish.rememberedDeathrattles?.length > 100) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst debug = deadEntities.some((e) => e.cardId === CardIds.CorruptedBristler_BG32_431);\r\n\r\n\tconst validDeathrattles = deadEntities\r\n\t\t.filter((entity) => allCards.getCard(entity.cardId).mechanics?.includes(GameTag[GameTag.DEATHRATTLE]))\r\n\t\t.filter((e) => !DEATHRATTLES_REQUIRE_MEMORY.includes(e.cardId as CardIds) || e.memory)\r\n\t\t.map((entity) => ({\r\n\t\t\tcardId: entity.cardId,\r\n\t\t\trepeats: 1,\r\n\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t\tmemory: entity.memory,\r\n\t\t\tscriptDataNum1: entity.scriptDataNum1,\r\n\t\t\tscriptDataNum2: entity.scriptDataNum2,\r\n\t\t}));\r\n\tconst validEnchantments = deadEntities\r\n\t\t.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) => isValidDeathrattleEnchantment(enchantment.cardId));\r\n\t// Multiple fish\r\n\tconst deadEntityRememberedDeathrattles =\r\n\t\tdeadEntities\r\n\t\t\t.filter((e) => !!e.rememberedDeathrattles?.length)\r\n\t\t\t// If the fish has reborn, it will inherit its own Deathrattles, and we don't want that\r\n\t\t\t.filter((e) => e.entityId !== fish.rebornFromEntityId)\r\n\t\t\t.filter((e) => !DEATHRATTLES_REQUIRE_MEMORY.includes(e.cardId as CardIds) || e.memory)\r\n\t\t\t.flatMap((e) => e.rememberedDeathrattles) ?? [];\r\n\tconst newDeathrattles = [...validDeathrattles, ...validEnchantments, ...deadEntityRememberedDeathrattles];\r\n\r\n\tif (newDeathrattles.length > 0) {\r\n\t\t// Order is important - the DR are triggered in the order d the minions have died\r\n\t\tif (isGolden(fish.cardId, allCards)) {\r\n\t\t\t// https://stackoverflow.com/questions/33305152/how-to-duplicate-elements-in-a-js-array\r\n\t\t\tconst doubleDr = newDeathrattles.reduce((res, current) => res.concat([current, current]), []);\r\n\t\t\tfish.rememberedDeathrattles = [...(fish.rememberedDeathrattles || []), ...doubleDr];\r\n\t\t} else {\r\n\t\t\tfish.rememberedDeathrattles = [...(fish.rememberedDeathrattles || []), ...newDeathrattles];\r\n\t\t}\r\n\r\n\t\tif (newDeathrattles.some((d) => d.cardId?.startsWith(CardIds.Leapfrogger_BG21_000))) {\r\n\t\t\t// Not sure exactly why, but if a leapfrogger dies first, then a manasaber,\r\n\t\t\t// when the fish dies, the manasaber's effect (spawning tokens) is triggered first\r\n\t\t\t// https://replays.firestoneapp.com/?reviewId=521733fb-8ba1-4663-9a87-3da58e8a09c8&turn=21&action=3\r\n\t\t\t// HACK: So I will hardcode a rule for now to put leapfrogger effects last\r\n\t\t\tconst leapfroggerDeathrattles = groupLeapfroggerDeathrattles(fish.rememberedDeathrattles);\r\n\t\t\tfish.rememberedDeathrattles = [\r\n\t\t\t\t...fish.rememberedDeathrattles.filter((d) => !d.cardId?.startsWith(CardIds.Leapfrogger_BG21_000)),\r\n\t\t\t\t...leapfroggerDeathrattles,\r\n\t\t\t];\r\n\t\t}\r\n\t}\r\n\t// console.debug(\r\n\t// \t'remembered',\r\n\t// \tfish.cardId,\r\n\t// \tfish.entityId,\r\n\t// \tfish.rememberedDeathrattles.map((d) => ({\r\n\t// \t\tcardId: d.cardId,\r\n\t// \t\tname: allCards.getCard(d.cardId)?.name,\r\n\t// \t\t// repeats: d.repeats,\r\n\t// \t\t// timing: d.timing,\r\n\t// \t})),\r\n\t// );\r\n};\r\n\r\nconst removeOldMurkEyeAttack = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\t// const murkeyes = boardWithDeadEntity.filter(\r\n\t// \t(entity) => entity.cardId === CardIds.OldMurkEyeLegacy || entity.cardId === CardIds.OldMurkEyeVanilla,\r\n\t// );\r\n\t// const goldenMurkeyes = boardWithDeadEntity.filter((entity) => entity.cardId === CardIds.OldMurkEye);\r\n\t// murkeyes.forEach((entity) => {\r\n\t// \tmodifyStats(entity, null, -1, 0, boardWithDeadEntity, hero, gameState);\r\n\t// });\r\n\t// goldenMurkeyes.forEach((entity) => {\r\n\t// \tmodifyStats(entity, null, -2, 0, boardWithDeadEntity, hero, gameState);\r\n\t// });\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"deathrattle-effects.js","sourceRoot":"","sources":["../../src/simulation/death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AAC;YAC9F,IAAI,CAAC,sBAAsB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,IAAI,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAC;SACpF;aAAM;YACN,IAAI,CAAC,sBAAsB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,IAAI,EAAE,CAAC,EAAE,GAAG,eAAe,CAAC,CAAC;SAC3F;QAED,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,WAAC,OAAA,MAAA,CAAC,CAAC,MAAM,0CAAE,UAAU,YAA8B,CAAA,EAAA,CAAC,EAAE;YAKpF,MAAM,uBAAuB,GAAG,IAAA,qDAA4B,EAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;YAC1F,IAAI,CAAC,sBAAsB,GAAG;gBAC7B,GAAG,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,WAAC,OAAA,CAAC,CAAA,MAAA,CAAC,CAAC,MAAM,0CAAE,UAAU,YAA8B,CAAA,CAAA,EAAA,CAAC;gBACjG,GAAG,uBAAuB;aAC1B,CAAC;SACF;KACD;AAYF,CAAC,CAAC;AAnFW,QAAA,oBAAoB,wBAmF/B;AAEF,MAAM,sBAAsB,GAAG,CAC9B,mBAAkC,EAClC,IAAqB,EACrB,SAAwB,EACvB,EAAE;AAWJ,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, GameTag, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardsData } from '../cards/cards-data';\r\nimport { eternalKnightAttack, eternalKnightHealth } from '../cards/impl/trinket/eternal-portrait';\r\nimport { updateDivineShield } from '../keywords/divine-shield';\r\nimport { updateTaunt } from '../keywords/taunt';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { pickMultipleRandomDifferent } from '../services/utils';\r\nimport { isValidDeathrattleEnchantment } from '../simulate-bgs-battle';\r\nimport {\r\n\tgetRandomMinionWithHighestHealth,\r\n\tgrantRandomStats,\r\n\thasCorrectTribe,\r\n\tisDead,\r\n\tisFish,\r\n\tisGolden,\r\n} from '../utils';\r\nimport { dealDamageToMinion } from './attack';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { groupLeapfroggerDeathrattles } from './remembered-deathrattle';\r\nimport { SharedState } from './shared-state';\r\nimport { modifyStats } from './stats';\r\n\r\nconst DEATHRATTLES_REQUIRE_MEMORY = [CardIds.StitchedSalvager_BG31_999, CardIds.StitchedSalvager_BG31_999_G];\r\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 =\r\n\t\t!!board.find(\r\n\t\t\t(entity) =>\r\n\t\t\t\tentity.cardId === CardIds.BaronRivendare_BG_FP1_031 ||\r\n\t\t\t\tentity.cardId === CardIds.MoiraBronzebeard_BG27_518,\r\n\t\t) || boardHero.secrets?.some((e) => e.cardId === CardIds.TitusTribute_BG28_843);\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 deathlyPhylacteries = boardHero.trinkets.filter(\r\n\t\t(t) => t.cardId === CardIds.DeathlyPhylactery_BG30_MagicItem_700 && t.scriptDataNum1 > 0,\r\n\t).length;\r\n\tconst tombs =\r\n\t\tboardHero.questRewardEntities?.filter((entity) => entity.cardId === CardIds.TurbulentTombs)?.length ?? 0;\r\n\tconst echoesOfArgus = sharedState.anomalies.includes(CardIds.EchoesOfArgus_BG27_Anomaly_802) ? 1 : 0;\r\n\tconst scourgeMultiplier = deadEntity.additionalCards?.includes(CardIds.ScourgeTroll) ? 2 : 1;\r\n\r\n\tconst multiplier =\r\n\t\tscourgeMultiplier *\r\n\t\t((goldenRivendare ? 3 : rivendare ? 2 : 1) +\r\n\t\t\tdeathlyPhylacteries +\r\n\t\t\ttitus +\r\n\t\t\t2 * goldenTitus +\r\n\t\t\ttombs +\r\n\t\t\techoesOfArgus);\r\n\treturn multiplier;\r\n};\r\n\r\nexport const applyLightningInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity | BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// Because the golden version doubles all the remembered effects\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst targets = pickMultipleRandomDifferent(otherBoard, 5);\r\n\t\tfor (const target of targets) {\r\n\t\t\tdealDamageToMinion(\r\n\t\t\t\ttarget,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tdeadEntity,\r\n\t\t\t\t1,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyWaterInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity, // Can be null when trinket is used\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst validBoard = boardWithDeadEntity.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\t\tconst target: BoardEntity = validBoard[validBoard.length - 1];\r\n\t\tif (!!target) {\r\n\t\t\tupdateTaunt(target, true, boardWithDeadEntity, boardWithDeadEntityHero, otherHero, gameState);\r\n\t\t\tupdateDivineShield(target, boardWithDeadEntity, boardWithDeadEntityHero, otherHero, true, gameState);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyFireInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst target: BoardEntity = boardWithDeadEntity.filter((e) => e.health > 0 && !e.definitelyDead)[0];\r\n\t\tif (!!target) {\r\n\t\t\tmodifyStats(\r\n\t\t\t\ttarget,\r\n\t\t\t\tsourceEntity,\r\n\t\t\t\ttarget.attack,\r\n\t\t\t\t0,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyEarthInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst minionsGrantedDeathrattle: BoardEntity[] = pickMultipleRandomDifferent(boardWithDeadEntity, 4);\r\n\t\tminionsGrantedDeathrattle.forEach((minion) => {\r\n\t\t\tminion.enchantments.push({\r\n\t\t\t\tcardId: CardIds.EarthInvocation_ElementEarthEnchantment,\r\n\t\t\t\toriginEntityId: deadEntity?.entityId,\r\n\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t});\r\n\t\t\tgameState.spectator.registerPowerTarget(sourceEntity, minion, boardWithDeadEntity, null, null);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const applyLeapFroggerEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tgameState: FullGameState,\r\n\tmultiplier: number,\r\n): void => {\r\n\tmultiplier = multiplier ?? deadEntity.deathrattleRepeats ?? 1;\r\n\t// console.debug('applying leapfrogger effect', deadEntity.entityId, multiplier);\r\n\tconst buffed = grantRandomStats(\r\n\t\tdeadEntity,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tmultiplier * (isPremium ? 2 : 1),\r\n\t\tmultiplier * (isPremium ? 2 : 1),\r\n\t\tRace.BEAST,\r\n\t\tfalse,\r\n\t\tgameState,\r\n\t);\r\n\tif (buffed) {\r\n\t\tbuffed.enchantments = 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: gameState.sharedState.currentEntityId++,\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const applyRecurringNightmareDeathrattleEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tgameState: FullGameState,\r\n\tmultiplier = 1,\r\n): void => {\r\n\t// multiplier = multiplier || 1;\r\n\t// const target = pickRandom(\r\n\t// \tboardWithDeadEntity\r\n\t// \t\t.filter((e) =>\r\n\t// \t\t\thasCorrectTribe(e, boardWithDeadEntityHero, Race.UNDEAD, gameState.anomalies, gameState.allCards),\r\n\t// \t\t)\r\n\t// \t\t.filter(\r\n\t// \t\t\t(e) =>\r\n\t// \t\t\t\te.cardId !== CardIds.RecurringNightmare_BG26_055 &&\r\n\t// \t\t\t\te.cardId !== CardIds.RecurringNightmare_BG26_055_G,\r\n\t// \t\t),\r\n\t// );\r\n\t// if (target) {\r\n\t// \ttarget.enchantments = target.enchantments ?? [];\r\n\t// \ttarget.enchantments.push({\r\n\t// \t\tcardId: isPremium\r\n\t// \t\t\t? CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055_Ge\r\n\t// \t\t\t: CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055e,\r\n\t// \t\toriginEntityId: deadEntity.entityId,\r\n\t// \t\trepeats: multiplier > 1 ? multiplier : 1,\r\n\t// \t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t// \t});\r\n\t// \tgameState.spectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity, null, null);\r\n\t// }\r\n};\r\n\r\n// Some minions like Icesnarl can revive themselves when killing a minion, so it needs to be handled before\r\n// we actually make the minion die\r\nexport const handleWheneverMinionsKillEffect = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\thandleWheneverMinionsKillEffectForBoard(board, hero, otherBoard, otherHero, gameState);\r\n\t// It's called once for each board already, so don't duplicate it here\r\n\t// handleWheneverMinionsKillEffectForBoard(otherBoard, otherHero, board, hero, gameState);\r\n};\r\n\r\nconst handleWheneverMinionsKillEffectForBoard = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].health <= 0 || board[i].definitelyDead) {\r\n\t\t\tconst futureDeadEntity = board[i];\r\n\t\t\tconst killer = futureDeadEntity.lastAffectedByEntity;\r\n\t\t\tif (!killer) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Killed an enemy minion\r\n\t\t\tif (killer.friendly !== futureDeadEntity.friendly) {\r\n\t\t\t\tfor (const heroPower of otherHero.heroPowers) {\r\n\t\t\t\t\t// Can't be used to resurrect a dead minion\r\n\t\t\t\t\t// https://replays.firestoneapp.com/?reviewId=d1fffee8-0bc3-40f5-9a59-85eef8367095&turn=11&action=4\r\n\t\t\t\t\tif (heroPower.cardId === CardIds.Rokara_GloryOfCombat && !isDead(killer)) {\r\n\t\t\t\t\t\tmodifyStats(killer, otherHero, 1, 0, otherBoard, otherHero, gameState);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Icesnarl the Mighty\r\n\t\t\t\totherBoard\r\n\t\t\t\t\t.filter(\r\n\t\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\t\te.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy ||\r\n\t\t\t\t\t\t\te.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy_G,\r\n\t\t\t\t\t)\r\n\t\t\t\t\t.forEach((icesnarl) => {\r\n\t\t\t\t\t\tmodifyStats(\r\n\t\t\t\t\t\t\ticesnarl,\r\n\t\t\t\t\t\t\ticesnarl,\r\n\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\ticesnarl.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy_G ? 2 : 1,\r\n\t\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\t\thero,\r\n\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const handleAfterMinionKillsEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// Moved to \"whenever kills\", as these can revive the minion that kills\r\n\t// const killer = deadEntity.lastAffectedByEntity;\r\n\t// if (!killer) {\r\n\t// \treturn;\r\n\t// }\r\n\t// // Killed an enemy minion\r\n\t// if (killer.friendly !== deadEntity.friendly) {\r\n\t// }\r\n};\r\n\r\nexport const applyAfterMinionDiesEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.DEMON, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplySoulJugglerEffect(boardWithDeadEntity, boardWithDeadEntityHero, otherBoard, otherBoardHero, gameState);\r\n\t}\r\n};\r\n\r\nexport const applyWheneverMinionDiesEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// console.log('applying minion death effect', stringifySimpleCard(deadEntity, allCards));\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.BEAST, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplyScavengingHyenaEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.MECH, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplyJunkbotEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.MURLOC, gameState.anomalies, gameState.allCards)) {\r\n\t\tremoveOldMurkEyeAttack(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\tremoveOldMurkEyeAttack(otherBoard, otherBoardHero, gameState);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.ELEMENTAL, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplyMossOfTheSchlossEffect(deadEntity, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\r\n\tif (deadEntity.taunt) {\r\n\t\tapplyBristlemaneScrapsmithEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\tapplyQirajiHarbringerEffect(boardWithDeadEntity, boardWithDeadEntityHero, deadEntityIndexFromRight, gameState);\r\n\t}\r\n\r\n\tif (\r\n\t\tdeadEntity.cardId === CardIds.EternalKnight_BG25_008 ||\r\n\t\tdeadEntity.cardId === CardIds.EternalKnight_BG25_008_G\r\n\t) {\r\n\t\tapplyEternalKnightEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\r\n\t// Putricide-only\r\n\tboardWithDeadEntity\r\n\t\t.filter((e) => e.additionalCards?.includes(CardIds.FlesheatingGhoulLegacy_BG26_tt_004))\r\n\t\t.forEach((e) => {\r\n\t\t\tmodifyStats(e, null, 1, 0, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t});\r\n\r\n\tapplyRotHideGnollEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\r\n\t// Overkill\r\n\tif (\r\n\t\tdeadEntity.health < 0 &&\r\n\t\tgameState.sharedState.currentAttackerEntityId != null &&\r\n\t\tgameState.sharedState.currentAttackerEntityId === deadEntity.lastAffectedByEntity?.entityId\r\n\t) {\r\n\t\t// if (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlame_BGS_032) {\r\n\t\t// \tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t// \tif (targets.length > 0) {\r\n\t\t// \t\tconst target = targets[0];\r\n\t\t// \t\tdealDamageToMinion(\r\n\t\t// \t\t\ttarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\t3,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tgameState,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlame_TB_BaconUps_103) {\r\n\t\t// \tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t// \tif (targets.length > 0) {\r\n\t\t// \t\tconst target = targets[0];\r\n\t\t// \t\tdealDamageToMinion(\r\n\t\t// \t\t\ttarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\t6,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tgameState,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// }\r\n\t\t// else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental && deadEntity.lastAffectedByEntity.attacking) {\r\n\t\t// \t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental) {\r\n\t\t// \t// console.log('applying WildfireElemental effect', stringifySimple(boardWithDeadEntity, allCards));\r\n\t\t// \tconst excessDamage = -deadEntity.health;\r\n\t\t// \t// Prevent propagation of the effect\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking = false;\r\n\t\t// \tconst neighbours = getNeighbours(boardWithDeadEntity, null, boardWithDeadEntity.length - deadEntityIndexFromRight);\r\n\t\t// \t// console.log('neighbours', stringifySimple(neighbours, allCards));\r\n\t\t// \tif (neighbours.length > 0) {\r\n\t\t// \t\tconst randomTarget = neighbours[Math.floor(Math.random() * neighbours.length)];\r\n\t\t// \t\tdealDamageToEnemy(\r\n\t\t// \t\t\trandomTarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\texcessDamage,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tallCards,\r\n\t\t// \t\t\tcardsData,\r\n\t\t// \t\t\tsharedState,\r\n\t\t// \t\t\tspectator,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// } else if (\r\n\t\t// \tdeadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElementalBattlegrounds &&\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking\r\n\t\t// ) {\r\n\t\t// \tconst excessDamage = -deadEntity.health;\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking = false;\r\n\t\t// \tconst neighbours = getNeighbours(boardWithDeadEntity, null, boardWithDeadEntity.length - deadEntityIndexFromRight);\r\n\t\t// \tneighbours.forEach((neighbour) =>\r\n\t\t// \t\tdealDamageToEnemy(\r\n\t\t// \t\t\tneighbour,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\texcessDamage,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tallCards,\r\n\t\t// \t\t\tcardsData,\r\n\t\t// \t\t\tsharedState,\r\n\t\t// \t\t\tspectator,\r\n\t\t// \t\t),\r\n\t\t// \t);\r\n\t\t// }\r\n\t\tif (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn_TRL_232) {\r\n\t\t\tconst newEntities = spawnEntities(\r\n\t\t\t\tCardIds.IronhideDirehorn_IronhideRuntToken_TRL_232t,\r\n\t\t\t\t1,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\t!deadEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t\totherBoard.splice(otherBoard.length - deadEntityIndexFromRight, 0, ...newEntities);\r\n\t\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn_TB_BaconUps_051) {\r\n\t\t\t// \tconst newEntities = spawnEntities(\r\n\t\t\t// \t\tCardIds.IronhideDirehorn_IronhideRuntToken_TB_BaconUps_051t,\r\n\t\t\t// \t\t1,\r\n\t\t\t// \t\totherBoard,\r\n\t\t\t// \t\totherBoardHero,\r\n\t\t\t// \t\tboardWithDeadEntity,\r\n\t\t\t// \t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\tgameState,\r\n\t\t\t// \t\t!deadEntity.friendly,\r\n\t\t\t// \t\tfalse,\r\n\t\t\t// \t);\r\n\t\t\t// \totherBoard.splice(otherBoard.length - deadEntityIndexFromRight, 0, ...newEntities);\r\n\t\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath_BGS_080) {\r\n\t\t\t// \tconst otherPirates = otherBoard\r\n\t\t\t// \t\t.filter((entity) =>\r\n\t\t\t// \t\t\thasCorrectTribe(\r\n\t\t\t// \t\t\t\tentity,\r\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\t\tRace.PIRATE,\r\n\t\t\t// \t\t\t\tgameState.anomalies,\r\n\t\t\t// \t\t\t\tgameState.allCards,\r\n\t\t\t// \t\t\t),\r\n\t\t\t// \t\t)\r\n\t\t\t// \t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\t// \totherPirates.forEach((pirate) => {\r\n\t\t\t// \t\tmodifyStats(\r\n\t\t\t// \t\t\tpirate,\r\n\t\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t// \t\t\t2,\r\n\t\t\t// \t\t\t2,\r\n\t\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\tgameState,\r\n\t\t\t// \t\t);\r\n\t\t\t// \t});\r\n\t\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath_TB_BaconUps_142) {\r\n\t\t\t// \tconst otherPirates = otherBoard\r\n\t\t\t// \t\t.filter((entity) =>\r\n\t\t\t// \t\t\thasCorrectTribe(\r\n\t\t\t// \t\t\t\tentity,\r\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\t\tRace.PIRATE,\r\n\t\t\t// \t\t\t\tgameState.anomalies,\r\n\t\t\t// \t\t\t\tgameState.allCards,\r\n\t\t\t// \t\t\t),\r\n\t\t\t// \t\t)\r\n\t\t\t// \t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\t// \totherPirates.forEach((pirate) => {\r\n\t\t\t// \t\tmodifyStats(\r\n\t\t\t// \t\t\tpirate,\r\n\t\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t// \t\t\t4,\r\n\t\t\t// \t\t\t4,\r\n\t\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\tgameState,\r\n\t\t\t// \t\t);\r\n\t\t\t// \t});\r\n\t\t}\r\n\t}\r\n};\r\n\r\n/** @deprecated */\r\nexport const dealDamageToAllMinions = (\r\n\tboard1: BoardEntity[],\r\n\tboard1Hero: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tboard2Hero: BgsPlayerEntity,\r\n\tdamageSource: BoardEntity,\r\n\tdamageDealt: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (board1.length === 0 && board2.length === 0) {\r\n\t\treturn;\r\n\t}\r\n\tfor (let i = 0; i < board1.length; i++) {\r\n\t\tdealDamageToMinion(board1[i], board1, board1Hero, damageSource, damageDealt, board2, board2Hero, gameState);\r\n\t}\r\n\tfor (let i = 0; i < board2.length; i++) {\r\n\t\tdealDamageToMinion(board2[i], board2, board2Hero, damageSource, damageDealt, board1, board1Hero, gameState);\r\n\t}\r\n};\r\n\r\nexport const applySoulJugglerEffect = (\r\n\tboardWithJugglers: BoardEntity[],\r\n\tboardWithJugglersHero: BgsPlayerEntity,\r\n\tboardToAttack: BoardEntity[],\r\n\tboardToAttackHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (boardWithJugglers.length === 0 && boardToAttack.length === 0) {\r\n\t\treturn;\r\n\t\t// return [boardWithJugglers, boardToAttack];\r\n\t}\r\n\tconst jugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler_BGS_002);\r\n\tfor (const juggler of jugglers) {\r\n\t\tconst target = getRandomMinionWithHighestHealth(boardToAttack);\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tjuggler,\r\n\t\t\ttarget,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tboardToAttackHero,\r\n\t\t);\r\n\t\tdealDamageToMinion(\r\n\t\t\ttarget,\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t4,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\tconst goldenJugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler_TB_BaconUps_075);\r\n\tfor (const juggler of goldenJugglers) {\r\n\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\tconst target = getRandomMinionWithHighestHealth(boardToAttack);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tjuggler,\r\n\t\t\t\ttarget,\r\n\t\t\t\tboardWithJugglers,\r\n\t\t\t\tboardWithJugglersHero,\r\n\t\t\t\tboardToAttackHero,\r\n\t\t\t);\r\n\t\t\tdealDamageToMinion(\r\n\t\t\t\ttarget,\r\n\t\t\t\tboardToAttack,\r\n\t\t\t\tboardToAttackHero,\r\n\t\t\t\tjuggler,\r\n\t\t\t\t4,\r\n\t\t\t\tboardWithJugglers,\r\n\t\t\t\tboardWithJugglersHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\t// processMinionDeath(\r\n\t// \tboardWithJugglers,\r\n\t// \tboardWithJugglersHero,\r\n\t// \tboardToAttack,\r\n\t// \tboardToAttackHero,\r\n\t// \tallCards,\r\n\t// \tcardsData,\r\n\t// \tsharedState,\r\n\t// \tspectator,\r\n\t// );\r\n};\r\n\r\nconst applyScavengingHyenaEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// const copy = [...board];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.ScavengingHyenaLegacy_BG_EX1_531) {\r\n\t\t\tmodifyStats(board[i], null, 2, 1, board, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t} else if (board[i].cardId === CardIds.ScavengingHyenaLegacy_TB_BaconUps_043) {\r\n\t\t\tmodifyStats(board[i], null, 4, 2, board, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyEternalKnightEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (\r\n\t\t\tboard[i].cardId === CardIds.EternalKnight_BG25_008 ||\r\n\t\t\tboard[i].cardId === CardIds.EternalKnight_BG25_008_G\r\n\t\t) {\r\n\t\t\tconst multiplier = board[i].cardId === CardIds.EternalKnight_BG25_008_G ? 2 : 1;\r\n\t\t\tmodifyStats(\r\n\t\t\t\tboard[i],\r\n\t\t\t\tnull,\r\n\t\t\t\tmultiplier * eternalKnightAttack,\r\n\t\t\t\tmultiplier * eternalKnightHealth,\r\n\t\t\t\tboard,\r\n\t\t\t\thero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyRotHideGnollEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.RotHideGnoll_BG25_013 || board[i].cardId === CardIds.RotHideGnoll_BG25_013_G) {\r\n\t\t\tconst multiplier = board[i].cardId === CardIds.RotHideGnoll_BG25_013_G ? 2 : 1;\r\n\t\t\tmodifyStats(board[i], null, multiplier * 1, 0, board, hero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyBristlemaneScrapsmithEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardPlayerEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (\r\n\t\t\tboard[i].cardId === CardIds.BristlemaneScrapsmith_BG24_707 ||\r\n\t\t\tboard[i].cardId === CardIds.BristlemaneScrapsmith_BG24_707_G\r\n\t\t) {\r\n\t\t\tconst cardsToAdd = Array(CardIds.BristlemaneScrapsmith_BG24_707_G ? 2 : 1).fill(CardIds.BloodGem);\r\n\t\t\taddCardsInHand(boardPlayerEntity, board, cardsToAdd, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, boardPlayerEntity, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyMossOfTheSchlossEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tboard\r\n\t\t.filter(\r\n\t\t\t(e) => e.cardId === CardIds.MossOfTheSchloss_BG30_111 || e.cardId === CardIds.MossOfTheSchloss_BG30_111_G,\r\n\t\t)\r\n\t\t.filter((e) => e.abiityChargesLeft > 0)\r\n\t\t.forEach((entity) => {\r\n\t\t\tmodifyStats(entity, null, deadEntity.maxAttack, deadEntity.maxHealth, board, hero, gameState);\r\n\t\t\tentity.abiityChargesLeft--;\r\n\t\t\tgameState.spectator.registerPowerTarget(entity, entity, board, null, null);\r\n\t\t});\r\n};\r\n\r\nconst applyJunkbotEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.Junkbot_GVG_106) {\r\n\t\t\tmodifyStats(board[i], board[i], 2, 2, board, hero, gameState);\r\n\t\t\t// } else if (board[i].cardId === CardIds.Junkbot_TB_BaconUps_046) {\r\n\t\t\t// \tmodifyStats(board[i], board[i], 4, 4, board, hero, gameState);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyQirajiHarbringerEffect = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// const qiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger_BGS_112);\r\n\t// const goldenQiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger_TB_BaconUps_303);\r\n\t// // TODO: if reactivated, properly apply buffs one by one, instead of all together\r\n\t// if (qiraji.length + goldenQiraji.length > 0) {\r\n\t// \tconst neighbours = getNeighbours(board, null, deadEntityIndexFromRight);\r\n\t// \tconst buff = 2 * qiraji.length + 4 * goldenQiraji.length;\r\n\t// \tneighbours.forEach((entity) => {\r\n\t// \t\tmodifyStats(entity, null, buff, buff, board, hero, gameState);\r\n\t// \t});\r\n\t// }\r\n};\r\n\r\nexport const rememberDeathrattles = (\r\n\tfish: BoardEntity,\r\n\tinputDeadEntities: readonly BoardEntity[],\r\n\tcardsData: CardsData,\r\n\tallCards: AllCardsService,\r\n\tsharedState: SharedState,\r\n): void => {\r\n\tconst deadEntities = inputDeadEntities.filter((e) => !isFish(e));\r\n\tif (!deadEntities?.length) {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// Some infinite loops going on?\r\n\tif (fish.rememberedDeathrattles?.length > 100) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst debug = deadEntities.some((e) => e.cardId === CardIds.CorruptedBristler_BG32_431);\r\n\r\n\tconst validDeathrattles = deadEntities\r\n\t\t.filter((entity) => allCards.getCard(entity.cardId).mechanics?.includes(GameTag[GameTag.DEATHRATTLE]))\r\n\t\t.filter((e) => !DEATHRATTLES_REQUIRE_MEMORY.includes(e.cardId as CardIds) || e.memory)\r\n\t\t.map((entity) => ({\r\n\t\t\tcardId: entity.cardId,\r\n\t\t\trepeats: 1,\r\n\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t\tmemory: entity.memory,\r\n\t\t\tscriptDataNum1: entity.scriptDataNum1,\r\n\t\t\tscriptDataNum2: entity.scriptDataNum2,\r\n\t\t}));\r\n\tconst validEnchantments = deadEntities\r\n\t\t.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) => isValidDeathrattleEnchantment(enchantment.cardId));\r\n\t// Multiple fish\r\n\tconst deadEntityRememberedDeathrattles =\r\n\t\tdeadEntities\r\n\t\t\t.filter((e) => !!e.rememberedDeathrattles?.length)\r\n\t\t\t// If the fish has reborn, it will inherit its own Deathrattles, and we don't want that\r\n\t\t\t.filter((e) => e.entityId !== fish.rebornFromEntityId)\r\n\t\t\t.filter((e) => !DEATHRATTLES_REQUIRE_MEMORY.includes(e.cardId as CardIds) || e.memory)\r\n\t\t\t.flatMap((e) => e.rememberedDeathrattles) ?? [];\r\n\tconst newDeathrattles = [...validDeathrattles, ...validEnchantments, ...deadEntityRememberedDeathrattles];\r\n\r\n\tif (newDeathrattles.length > 0) {\r\n\t\t// Order is important - the DR are triggered in the order d the minions have died\r\n\t\tif (isGolden(fish.cardId, allCards)) {\r\n\t\t\t// https://stackoverflow.com/questions/33305152/how-to-duplicate-elements-in-a-js-array\r\n\t\t\tconst doubleDr = newDeathrattles.reduce((res, current) => res.concat([current, current]), []);\r\n\t\t\tfish.rememberedDeathrattles = [...(fish.rememberedDeathrattles || []), ...doubleDr];\r\n\t\t} else {\r\n\t\t\tfish.rememberedDeathrattles = [...(fish.rememberedDeathrattles || []), ...newDeathrattles];\r\n\t\t}\r\n\r\n\t\tif (newDeathrattles.some((d) => d.cardId?.startsWith(CardIds.Leapfrogger_BG21_000))) {\r\n\t\t\t// Not sure exactly why, but if a leapfrogger dies first, then a manasaber,\r\n\t\t\t// when the fish dies, the manasaber's effect (spawning tokens) is triggered first\r\n\t\t\t// https://replays.firestoneapp.com/?reviewId=521733fb-8ba1-4663-9a87-3da58e8a09c8&turn=21&action=3\r\n\t\t\t// HACK: So I will hardcode a rule for now to put leapfrogger effects last\r\n\t\t\tconst leapfroggerDeathrattles = groupLeapfroggerDeathrattles(fish.rememberedDeathrattles);\r\n\t\t\tfish.rememberedDeathrattles = [\r\n\t\t\t\t...fish.rememberedDeathrattles.filter((d) => !d.cardId?.startsWith(CardIds.Leapfrogger_BG21_000)),\r\n\t\t\t\t...leapfroggerDeathrattles,\r\n\t\t\t];\r\n\t\t}\r\n\t}\r\n\t// console.debug(\r\n\t// \t'remembered',\r\n\t// \tfish.cardId,\r\n\t// \tfish.entityId,\r\n\t// \tfish.rememberedDeathrattles.map((d) => ({\r\n\t// \t\tcardId: d.cardId,\r\n\t// \t\tname: allCards.getCard(d.cardId)?.name,\r\n\t// \t\t// repeats: d.repeats,\r\n\t// \t\t// timing: d.timing,\r\n\t// \t})),\r\n\t// );\r\n};\r\n\r\nconst removeOldMurkEyeAttack = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\t// const murkeyes = boardWithDeadEntity.filter(\r\n\t// \t(entity) => entity.cardId === CardIds.OldMurkEyeLegacy || entity.cardId === CardIds.OldMurkEyeVanilla,\r\n\t// );\r\n\t// const goldenMurkeyes = boardWithDeadEntity.filter((entity) => entity.cardId === CardIds.OldMurkEye);\r\n\t// murkeyes.forEach((entity) => {\r\n\t// \tmodifyStats(entity, null, -1, 0, boardWithDeadEntity, hero, gameState);\r\n\t// });\r\n\t// goldenMurkeyes.forEach((entity) => {\r\n\t// \tmodifyStats(entity, null, -2, 0, boardWithDeadEntity, hero, gameState);\r\n\t// });\r\n};\r\n"]}
|
|
@@ -122,6 +122,7 @@ const handleOzumatForPlayer = (heroPower, playerBoard, playerEntity, opponentBoa
|
|
|
122
122
|
};
|
|
123
123
|
const handleFrostwolfFervorForPlayer = (heroPower, playerBoard, playerEntity, opponentBoard, opponentEntity, friendly, gameState) => {
|
|
124
124
|
if (playerBoard.length < 7) {
|
|
125
|
+
heroPower.activated = true;
|
|
125
126
|
const target = (0, utils_1.pickRandomHighestAttack)(playerBoard);
|
|
126
127
|
if (!!target) {
|
|
127
128
|
const copy = (0, utils_2.copyEntity)(target);
|
|
@@ -130,12 +131,12 @@ const handleFrostwolfFervorForPlayer = (heroPower, playerBoard, playerEntity, op
|
|
|
130
131
|
const spawns = (0, spawns_1.performEntitySpawns)(newMinions, playerBoard, playerEntity, playerEntity, indexFromRight, opponentBoard, opponentEntity, gameState);
|
|
131
132
|
gameState.spectator.registerPowerTarget(playerEntity, spawns[0], playerBoard, playerEntity, opponentEntity);
|
|
132
133
|
}
|
|
133
|
-
heroPower.activated = true;
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
136
|
const handleLockAndLoadForPlayer = (heroPower, playerBoard, playerEntity, opponentBoard, opponentEntity, friendly, gameState) => {
|
|
137
137
|
if (playerBoard.length < 7) {
|
|
138
138
|
const summoned = heroPower.info;
|
|
139
|
+
heroPower.activated = true;
|
|
139
140
|
if (!!(summoned === null || summoned === void 0 ? void 0 : summoned.cardId)) {
|
|
140
141
|
const copy = (0, utils_2.copyEntity)(summoned);
|
|
141
142
|
copy.attackImmediately = true;
|
|
@@ -144,11 +145,11 @@ const handleLockAndLoadForPlayer = (heroPower, playerBoard, playerEntity, oppone
|
|
|
144
145
|
const spawns = (0, spawns_1.performEntitySpawns)(newMinions, playerBoard, playerEntity, playerEntity, indexFromRight, opponentBoard, opponentEntity, gameState);
|
|
145
146
|
gameState.spectator.registerPowerTarget(playerEntity, spawns[0], playerBoard, playerEntity, opponentEntity);
|
|
146
147
|
}
|
|
147
|
-
heroPower.activated = true;
|
|
148
148
|
}
|
|
149
149
|
};
|
|
150
150
|
const handleStormpikeStrengthForPlayer = (heroPower, playerBoard, playerEntity, opponentBoard, opponentEntity, friendly, gameState) => {
|
|
151
151
|
if (playerBoard.length < 7) {
|
|
152
|
+
heroPower.activated = true;
|
|
152
153
|
const target = (0, utils_1.pickRandomHighestHealth)(playerBoard);
|
|
153
154
|
if (!!target) {
|
|
154
155
|
const copy = (0, utils_2.copyEntity)(target);
|
|
@@ -157,7 +158,6 @@ const handleStormpikeStrengthForPlayer = (heroPower, playerBoard, playerEntity,
|
|
|
157
158
|
const spawns = (0, spawns_1.performEntitySpawns)(newMinions, playerBoard, playerEntity, playerEntity, indexFromRight, opponentBoard, opponentEntity, gameState);
|
|
158
159
|
gameState.spectator.registerPowerTarget(playerEntity, spawns[0], playerBoard, playerEntity, opponentEntity);
|
|
159
160
|
}
|
|
160
|
-
heroPower.activated = true;
|
|
161
161
|
}
|
|
162
162
|
};
|
|
163
163
|
const handleBoonOfBeetlesForPlayer = (playerBoard, playerEntity, opponentBoard, opponentEntity, gameState) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summon-when-space.js","sourceRoot":"","sources":["../../src/simulation/summon-when-space.ts"],"names":[],"mappings":";;;AAAA,iEAAoD;AAGpD,6CAAgD;AAEhD,6CAAqF;AACrF,oCAA+E;AAC/E,+DAA4D;AAC5D,6DAAqD;AAErD,qCAA+C;AAExC,MAAM,sBAAsB,GAAG,CACrC,WAA0B,EAC1B,YAA6B,EAC7B,aAA4B,EAC5B,cAA+B,EAC/B,SAAwB,EACvB,EAAE;IACH,IAAI,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,EAAE;QACxB,+BAA+B,CAC9B,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,SAAS,CACT,CAAC;QACF,+BAA+B,CAC9B,cAAc,EACd,aAAa,EACb,cAAc,EACd,WAAW,EACX,YAAY,EACZ,SAAS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AAW,CAAC,eAAe,EAAE,EACvC,KAAK,EACL,SAAS,CAAC,SAAS,EACnB,SAAS,CAAC,WAAW,EACrB,MAAM,EACN,IAAI,CACJ,CAAC;IAEF,MAAM,OAAO,GAAG,IAAA,4BAAmB,EAClC,CAAC,SAAS,CAAC,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,aAAa,EACb,cAAc,EACd,SAAS,EACT,UAAU,CACV,CAAC;IACF,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAAC,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC1F,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { Race } from '@firestone-hs/reference-data';\r\nimport { BgsHeroPower, BgsPlayerEntity, BoardTrinket } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { updateTaunt } from '../keywords/taunt';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { pickRandomHighestAttack, pickRandomHighestHealth } from '../services/utils';\r\nimport { buildSingleBoardEntity, copyEntity, hasCorrectTribe } from '../utils';\r\nimport { removeAurasFromSelf } from './add-minion-to-board';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { performEntitySpawns } from './spawns';\r\n\r\nexport const handleSummonsWhenSpace = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tif (Math.random() < 0.5) {\r\n\t\thandleSummonsWhenSpaceForPlayer(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\thandleSummonsWhenSpaceForPlayer(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t} else {\r\n\t\thandleSummonsWhenSpaceForPlayer(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\thandleSummonsWhenSpaceForPlayer(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n};\r\n\r\n// TODO: Twin Sky Lanterns wait for 2 spaces\r\nconst handleSummonsWhenSpaceForPlayer = (\r\n\ttargetEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tif (targetEntity.rapidReanimationMinion) {\r\n\t\thandleRapidReanimationForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t}\r\n\tif (targetEntity.questRewards?.includes(CardIds.StableAmalgamation_BG28_Reward_518)) {\r\n\t\thandleStableAmalgamationForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t}\r\n\tif (targetEntity.secrets?.some((s) => s.cardId === CardIds.BoonOfBeetles_BG28_603)) {\r\n\t\thandleBoonOfBeetlesForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t}\r\n\tfor (const heroPower of targetEntity.heroPowers) {\r\n\t\tif (heroPower.cardId === CardIds.Ozumat_Tentacular) {\r\n\t\t\thandleOzumatForPlayer(\r\n\t\t\t\theroPower,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\ttargetEntity.friendly,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t\t// TODO: use one of these existing tag to make it unlocked\r\n\t\telse if (\r\n\t\t\theroPower.cardId === CardIds.Drekthar_LeadTheFrostwolves &&\r\n\t\t\t!heroPower.locked &&\r\n\t\t\t!heroPower.activated\r\n\t\t) {\r\n\t\t\thandleFrostwolfFervorForPlayer(\r\n\t\t\t\theroPower,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\ttargetEntity.friendly,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t} else if (\r\n\t\t\theroPower.cardId === CardIds.VanndarStormpike_LeadTheStormpikes &&\r\n\t\t\t!heroPower.locked &&\r\n\t\t\t!heroPower.activated\r\n\t\t) {\r\n\t\t\thandleStormpikeStrengthForPlayer(\r\n\t\t\t\theroPower,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\ttargetEntity.friendly,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t} else if (heroPower.cardId === CardIds.LockAndLoadToken_BG22_HERO_000p_Alt && !heroPower.activated) {\r\n\t\t\thandleLockAndLoadForPlayer(\r\n\t\t\t\theroPower,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\ttargetEntity.friendly,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\ttargetEntity.trinkets\r\n\t\t.filter(\r\n\t\t\t(t) =>\r\n\t\t\t\tt.cardId === CardIds.TwinSkyLanterns_BG30_MagicItem_822 ||\r\n\t\t\t\tt.cardId === CardIds.TwinSkyLanterns_TwinSkyLanternsToken_BG30_MagicItem_822t2,\r\n\t\t)\r\n\t\t.forEach((t) => {\r\n\t\t\thandleTwinSkyLanternsForPlayer(t, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t});\r\n\ttargetEntity.trinkets\r\n\t\t.filter((t) => t.cardId === CardIds.BoomController_BG30_MagicItem_440)\r\n\t\t.forEach((t) => {\r\n\t\t\thandleBoomControllerForPlayer(t, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t});\r\n\tplayerBoard\r\n\t\t.filter(\r\n\t\t\t(e) => e.cardId === CardIds.SharptoothSnapper_BG32_201 || e.cardId === CardIds.SharptoothSnapper_BG32_201_G,\r\n\t\t)\r\n\t\t.forEach((e) => {\r\n\t\t\thandleSharptoothSnapperForPlayer(e, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t});\r\n};\r\n\r\nexport const handleSharptoothSnapperForPlayer = (\r\n\tentity: BoardEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\twhile (playerBoard.length < 7 && entity.abiityChargesLeft > 0) {\r\n\t\tconst candidates = spawnEntities(\r\n\t\t\tCardIds.SharptoothSnapper_PiranhaToken_BG32_201t,\r\n\t\t\t1,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t\tplayerEntity.friendly,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t\tcandidates.forEach((t) => (t.attackImmediately = true));\r\n\t\tconst actualSpawns = performEntitySpawns(\r\n\t\t\tcandidates,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard.length - 1 - playerBoard.indexOf(entity),\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tentity.abiityChargesLeft--;\r\n\t}\r\n};\r\n\r\nconst handleBoomControllerForPlayer = (\r\n\ttrinket: BoardTrinket,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (playerBoard.length < 7 && trinket.scriptDataNum1 > 0) {\r\n\t\tconst candidate = gameState.sharedState.deaths\r\n\t\t\t.filter((d) => d.friendly === playerEntity.friendly)\r\n\t\t\t.filter((d) => hasCorrectTribe(d, playerEntity, Race.MECH, gameState.anomalies, gameState.allCards))[0];\r\n\t\tif (!!candidate) {\r\n\t\t\tconst spawn = copyEntity(candidate);\r\n\t\t\tremoveAurasFromSelf(spawn, playerBoard, playerEntity, gameState);\r\n\t\t\tconst initialIndexFromLeft = candidate.indexFromLeftAtTimeOfDeath;\r\n\t\t\tconst indexFromRight =\r\n\t\t\t\tinitialIndexFromLeft == null\r\n\t\t\t\t\t? 0\r\n\t\t\t\t\t: Math.min(playerBoard.length, Math.max(0, playerBoard.length - initialIndexFromLeft));\r\n\t\t\tconst target = spawnEntities(\r\n\t\t\t\tspawn.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\ttrue,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tspawn,\r\n\t\t\t);\r\n\t\t\t// FIXME: here it should try to match the position at which the original minions died\r\n\t\t\tconst actualSpawns = performEntitySpawns(\r\n\t\t\t\ttarget,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tactualSpawns.forEach((t) =>\r\n\t\t\t\tgameState.spectator.registerPowerTarget(playerEntity, t, playerBoard, playerEntity, opponentEntity),\r\n\t\t\t);\r\n\t\t\ttrinket.scriptDataNum1 = 0;\r\n\t\t\t// It summons an exact copy\r\n\t\t\t// actualSpawns.forEach((entity) => {\r\n\t\t\t// \tswitch (entity.cardId) {\r\n\t\t\t// \t\tcase CardIds.AstralAutomaton_BG_TTN_401:\r\n\t\t\t// \t\tcase CardIds.AstralAutomaton_BG_TTN_401_G:\r\n\t\t\t// \t\t\tconst overstatMult = entity.cardId === CardIds.AstralAutomaton_BG_TTN_401 ? 1 : 2;\r\n\t\t\t// \t\t\tentity.attack = Math.max(1, entity.attack - 2 * overstatMult);\r\n\t\t\t// \t\t\tentity.health = Math.max(0, entity.health - overstatMult);\r\n\t\t\t// \t\t\tbreak;\r\n\t\t\t// \t}\r\n\t\t\t// });\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleTwinSkyLanternsForPlayer = (\r\n\ttrinket: BoardTrinket,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst spawnNumber = trinket.scriptDataNum1 ?? 0;\r\n\tconst canTrigger = spawnNumber >= 1;\r\n\tif (playerBoard.length <= 7 - spawnNumber && trinket.rememberedMinion && canTrigger) {\r\n\t\ttrinket.scriptDataNum1 = 0;\r\n\t\tconst spawn = copyEntity(trinket.rememberedMinion);\r\n\t\tremoveAurasFromSelf(spawn, playerBoard, playerEntity, gameState);\r\n\t\tconst target = spawnEntities(\r\n\t\t\tspawn.cardId,\r\n\t\t\tspawnNumber,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t\tplayerEntity.friendly,\r\n\t\t\ttrue,\r\n\t\t\tfalse,\r\n\t\t\tfalse,\r\n\t\t\tspawn,\r\n\t\t);\r\n\t\tperformEntitySpawns(\r\n\t\t\ttarget,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerEntity,\r\n\t\t\t0,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\ttarget.forEach((t) =>\r\n\t\t\tgameState.spectator.registerPowerTarget(playerEntity, t, playerBoard, playerEntity, opponentEntity),\r\n\t\t);\r\n\t}\r\n};\r\n\r\nconst handleOzumatForPlayer = (\r\n\theroPower: BgsHeroPower,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (playerBoard.length < 7 && heroPower.activated === false) {\r\n\t\tconst tentacularSize = +heroPower.info;\r\n\t\tconst tentacular = spawnEntities(\r\n\t\t\tCardIds.Tentacular_OzumatsTentacleToken_BG23_HERO_201pt,\r\n\t\t\t1,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t\tfriendly,\r\n\t\t\ttrue,\r\n\t\t\tfalse,\r\n\t\t\tfalse,\r\n\t\t);\r\n\t\ttentacular[0].attack = tentacularSize;\r\n\t\ttentacular[0].health = tentacularSize;\r\n\t\ttentacular[0].maxHealth = tentacularSize;\r\n\t\ttentacular[0].maxAttack = tentacularSize;\r\n\t\tconst indexFromRight = 0;\r\n\t\tperformEntitySpawns(\r\n\t\t\ttentacular,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerEntity,\r\n\t\t\tindexFromRight,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tgameState.spectator.registerPowerTarget(playerEntity, tentacular[0], playerBoard, playerEntity, opponentEntity);\r\n\t\theroPower.activated = true;\r\n\t}\r\n};\r\n\r\nconst handleFrostwolfFervorForPlayer = (\r\n\theroPower: BgsHeroPower,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (playerBoard.length < 7) {\r\n\t\tconst target = pickRandomHighestAttack(playerBoard);\r\n\t\tif (!!target) {\r\n\t\t\tconst copy = copyEntity(target);\r\n\t\t\tconst indexFromRight = 0;\r\n\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\tcopy.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tcopy,\r\n\t\t\t);\r\n\t\t\tconst spawns = performEntitySpawns(\r\n\t\t\t\tnewMinions,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(playerEntity, spawns[0], playerBoard, playerEntity, opponentEntity);\r\n\t\t}\r\n\t\theroPower.activated = true;\r\n\t}\r\n};\r\n\r\nconst handleLockAndLoadForPlayer = (\r\n\theroPower: BgsHeroPower,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (playerBoard.length < 7) {\r\n\t\tconst summoned = heroPower.info as BoardEntity;\r\n\t\tif (!!summoned?.cardId) {\r\n\t\t\tconst copy = copyEntity(summoned);\r\n\t\t\tcopy.attackImmediately = true;\r\n\t\t\tconst indexFromRight = 0;\r\n\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\tcopy.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tcopy,\r\n\t\t\t);\r\n\t\t\tconst spawns = performEntitySpawns(\r\n\t\t\t\tnewMinions,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(playerEntity, spawns[0], playerBoard, playerEntity, opponentEntity);\r\n\t\t}\r\n\t\theroPower.activated = true;\r\n\t}\r\n};\r\n\r\nconst handleStormpikeStrengthForPlayer = (\r\n\theroPower: BgsHeroPower,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (playerBoard.length < 7) {\r\n\t\tconst target = pickRandomHighestHealth(playerBoard);\r\n\t\tif (!!target) {\r\n\t\t\tconst copy = copyEntity(target);\r\n\t\t\tconst indexFromRight = 0;\r\n\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\tcopy.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tcopy,\r\n\t\t\t);\r\n\t\t\tconst spawns = performEntitySpawns(\r\n\t\t\t\tnewMinions,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(playerEntity, spawns[0], playerBoard, playerEntity, opponentEntity);\r\n\t\t}\r\n\t\theroPower.activated = true;\r\n\t}\r\n};\r\n\r\nconst handleBoonOfBeetlesForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst secretEntity = playerEntity.secrets.find((entity) => entity.cardId === CardIds.BoonOfBeetles_BG28_603);\r\n\tif (secretEntity && secretEntity.triggersLeft > 0) {\r\n\t\twhile (secretEntity.triggersLeft > 0) {\r\n\t\t\tconst hasSummoned = handleSummon(\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tCardIds.BoonOfBeetles_BeetleToken_BG28_603t,\r\n\t\t\t\t0,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t\tif (hasSummoned) {\r\n\t\t\t\thasSummoned.forEach((entity) => {\r\n\t\t\t\t\tupdateTaunt(entity, true, playerBoard, playerEntity, opponentEntity, gameState);\r\n\t\t\t\t});\r\n\t\t\t\tsecretEntity.triggersLeft--;\r\n\t\t\t} else {\r\n\t\t\t\t// No room to summon, we stop here\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\nconst handleStableAmalgamationForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst rewardEntity = playerEntity.questRewardEntities.find(\r\n\t\t(entity) => entity.cardId === CardIds.StableAmalgamation_BG28_Reward_518,\r\n\t);\r\n\tif (rewardEntity && rewardEntity.scriptDataNum1 > 0) {\r\n\t\twhile (rewardEntity.scriptDataNum1 > 0) {\r\n\t\t\tconst hasSummoned = handleSummon(\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tCardIds.StableAmalgamation_TotallyNormalHorseToken_BG28_Reward_518t,\r\n\t\t\t\t0,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t\tif (hasSummoned) {\r\n\t\t\t\trewardEntity.scriptDataNum1--;\r\n\t\t\t} else {\r\n\t\t\t\t// No room to summon, we stop here\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleRapidReanimationForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst indexFromRight =\r\n\t\tplayerEntity.rapidReanimationIndexFromLeft === 0\r\n\t\t\t? Math.max(0, playerBoard.length - playerEntity.rapidReanimationIndexFromLeft)\r\n\t\t\t: playerEntity.rapidReanimationIndexFromRight;\r\n\tconst hasSummoned = handleSummon(\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tgameState,\r\n\t\tplayerEntity.rapidReanimationMinion.cardId,\r\n\t\tindexFromRight,\r\n\t\ttrue, // (Goldrinn gets buffed, so it seems we reapply auras? This is a mess tbh)\r\n\t\tplayerEntity.rapidReanimationMinion,\r\n\t);\r\n\tif (hasSummoned) {\r\n\t\tplayerEntity.rapidReanimationMinion = null;\r\n\t\t// Hard-coding a correction for Ancestral Automaton\r\n\t\t// Shold not be necessary if we reapply auras\r\n\t\t// hasSummoned.forEach((entity) => {\r\n\t\t// \tswitch (entity.cardId) {\r\n\t\t// \t\tcase CardIds.AstralAutomaton_BG_TTN_401:\r\n\t\t// \t\tcase CardIds.AstralAutomaton_BG_TTN_401_G:\r\n\t\t// \t\t\tconst overstatMult = entity.cardId === CardIds.AstralAutomaton_BG_TTN_401 ? 1 : 2;\r\n\t\t// \t\t\tentity.attack = Math.max(1, entity.attack + 2 * overstatMult);\r\n\t\t// \t\t\tentity.health = Math.max(0, entity.health + 2 * overstatMult);\r\n\t\t// \t\t\tbreak;\r\n\t\t// \t\tcase CardIds.EternalKnight_BG25_008:\r\n\t\t// \t\tcase CardIds.EternalKnight_BG25_008_G:\r\n\t\t// \t\t\tconst knightMult = entity.cardId === CardIds.EternalKnight_BG25_008 ? 1 : 2;\r\n\t\t// \t\t\tentity.attack = Math.max(1, entity.attack + 1 * knightMult);\r\n\t\t// \t\t\tentity.health = Math.max(0, entity.health + 1 * knightMult);\r\n\t\t// \t\t\tbreak;\r\n\t\t// \t}\r\n\t\t// });\r\n\t}\r\n};\r\n\r\nconst handleSummon = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tcardId: string,\r\n\tindexFromRight: number,\r\n\tapplyAuras: boolean,\r\n\tminion: BoardEntity = null,\r\n): readonly BoardEntity[] => {\r\n\tif (playerBoard.length >= 7) {\r\n\t\treturn null;\r\n\t}\r\n\tconst newMinion = buildSingleBoardEntity(\r\n\t\tcardId,\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\tgameState.allCards,\r\n\t\tplayerEntity.friendly,\r\n\t\tgameState.sharedState.currentEntityId++,\r\n\t\tfalse,\r\n\t\tgameState.cardsData,\r\n\t\tgameState.sharedState,\r\n\t\tminion,\r\n\t\tnull,\r\n\t);\r\n\t// Don't reapply auras in this particular case? See https://x.com/ZerotoHeroes_HS/status/1737422727118487808?s=20\r\n\tconst spawned = performEntitySpawns(\r\n\t\t[newMinion],\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\tplayerEntity,\r\n\t\tindexFromRight,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tgameState,\r\n\t\tapplyAuras,\r\n\t);\r\n\tgameState.spectator.registerPowerTarget(playerEntity, newMinion, playerBoard, null, null);\r\n\treturn spawned;\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"summon-when-space.js","sourceRoot":"","sources":["../../src/simulation/summon-when-space.ts"],"names":[],"mappings":";;;AAAA,iEAAoD;AAGpD,6CAAgD;AAEhD,6CAAqF;AACrF,oCAA+E;AAC/E,+DAA4D;AAC5D,6DAAqD;AAErD,qCAA+C;AAExC,MAAM,sBAAsB,GAAG,CACrC,WAA0B,EAC1B,YAA6B,EAC7B,aAA4B,EAC5B,cAA+B,EAC/B,SAAwB,EACvB,EAAE;IACH,IAAI,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,EAAE;QACxB,+BAA+B,CAC9B,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,SAAS,CACT,CAAC;QACF,+BAA+B,CAC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SAAS,CAAC,QAAQ,EAClB,YAAY,CAAC,QAAQ,EACrB,SAAS,CAAC,WAAW,CAAC,eAAe,EAAE,EACvC,KAAK,EACL,SAAS,CAAC,SAAS,EACnB,SAAS,CAAC,WAAW,EACrB,MAAM,EACN,IAAI,CACJ,CAAC;IAEF,MAAM,OAAO,GAAG,IAAA,4BAAmB,EAClC,CAAC,SAAS,CAAC,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,aAAa,EACb,cAAc,EACd,SAAS,EACT,UAAU,CACV,CAAC;IACF,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAAC,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC1F,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { Race } from '@firestone-hs/reference-data';\r\nimport { BgsHeroPower, BgsPlayerEntity, BoardTrinket } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { updateTaunt } from '../keywords/taunt';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { pickRandomHighestAttack, pickRandomHighestHealth } from '../services/utils';\r\nimport { buildSingleBoardEntity, copyEntity, hasCorrectTribe } from '../utils';\r\nimport { removeAurasFromSelf } from './add-minion-to-board';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { performEntitySpawns } from './spawns';\r\n\r\nexport const handleSummonsWhenSpace = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tif (Math.random() < 0.5) {\r\n\t\thandleSummonsWhenSpaceForPlayer(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\thandleSummonsWhenSpaceForPlayer(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t} else {\r\n\t\thandleSummonsWhenSpaceForPlayer(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\thandleSummonsWhenSpaceForPlayer(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n};\r\n\r\n// TODO: Twin Sky Lanterns wait for 2 spaces\r\nconst handleSummonsWhenSpaceForPlayer = (\r\n\ttargetEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tif (targetEntity.rapidReanimationMinion) {\r\n\t\thandleRapidReanimationForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t}\r\n\tif (targetEntity.questRewards?.includes(CardIds.StableAmalgamation_BG28_Reward_518)) {\r\n\t\thandleStableAmalgamationForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t}\r\n\tif (targetEntity.secrets?.some((s) => s.cardId === CardIds.BoonOfBeetles_BG28_603)) {\r\n\t\thandleBoonOfBeetlesForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t}\r\n\tfor (const heroPower of targetEntity.heroPowers) {\r\n\t\tif (heroPower.cardId === CardIds.Ozumat_Tentacular) {\r\n\t\t\thandleOzumatForPlayer(\r\n\t\t\t\theroPower,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\ttargetEntity.friendly,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t\t// TODO: use one of these existing tag to make it unlocked\r\n\t\telse if (\r\n\t\t\theroPower.cardId === CardIds.Drekthar_LeadTheFrostwolves &&\r\n\t\t\t!heroPower.locked &&\r\n\t\t\t!heroPower.activated\r\n\t\t) {\r\n\t\t\thandleFrostwolfFervorForPlayer(\r\n\t\t\t\theroPower,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\ttargetEntity.friendly,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t} else if (\r\n\t\t\theroPower.cardId === CardIds.VanndarStormpike_LeadTheStormpikes &&\r\n\t\t\t!heroPower.locked &&\r\n\t\t\t!heroPower.activated\r\n\t\t) {\r\n\t\t\thandleStormpikeStrengthForPlayer(\r\n\t\t\t\theroPower,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\ttargetEntity.friendly,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t} else if (heroPower.cardId === CardIds.LockAndLoadToken_BG22_HERO_000p_Alt && !heroPower.activated) {\r\n\t\t\thandleLockAndLoadForPlayer(\r\n\t\t\t\theroPower,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\ttargetEntity.friendly,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\ttargetEntity.trinkets\r\n\t\t.filter(\r\n\t\t\t(t) =>\r\n\t\t\t\tt.cardId === CardIds.TwinSkyLanterns_BG30_MagicItem_822 ||\r\n\t\t\t\tt.cardId === CardIds.TwinSkyLanterns_TwinSkyLanternsToken_BG30_MagicItem_822t2,\r\n\t\t)\r\n\t\t.forEach((t) => {\r\n\t\t\thandleTwinSkyLanternsForPlayer(t, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t});\r\n\ttargetEntity.trinkets\r\n\t\t.filter((t) => t.cardId === CardIds.BoomController_BG30_MagicItem_440)\r\n\t\t.forEach((t) => {\r\n\t\t\thandleBoomControllerForPlayer(t, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t});\r\n\tplayerBoard\r\n\t\t.filter(\r\n\t\t\t(e) => e.cardId === CardIds.SharptoothSnapper_BG32_201 || e.cardId === CardIds.SharptoothSnapper_BG32_201_G,\r\n\t\t)\r\n\t\t.forEach((e) => {\r\n\t\t\thandleSharptoothSnapperForPlayer(e, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t});\r\n};\r\n\r\nexport const handleSharptoothSnapperForPlayer = (\r\n\tentity: BoardEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\twhile (playerBoard.length < 7 && entity.abiityChargesLeft > 0) {\r\n\t\tconst candidates = spawnEntities(\r\n\t\t\tCardIds.SharptoothSnapper_PiranhaToken_BG32_201t,\r\n\t\t\t1,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t\tplayerEntity.friendly,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t\tcandidates.forEach((t) => (t.attackImmediately = true));\r\n\t\tconst actualSpawns = performEntitySpawns(\r\n\t\t\tcandidates,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard.length - 1 - playerBoard.indexOf(entity),\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tentity.abiityChargesLeft--;\r\n\t}\r\n};\r\n\r\nconst handleBoomControllerForPlayer = (\r\n\ttrinket: BoardTrinket,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (playerBoard.length < 7 && trinket.scriptDataNum1 > 0) {\r\n\t\tconst candidate = gameState.sharedState.deaths\r\n\t\t\t.filter((d) => d.friendly === playerEntity.friendly)\r\n\t\t\t.filter((d) => hasCorrectTribe(d, playerEntity, Race.MECH, gameState.anomalies, gameState.allCards))[0];\r\n\t\tif (!!candidate) {\r\n\t\t\tconst spawn = copyEntity(candidate);\r\n\t\t\tremoveAurasFromSelf(spawn, playerBoard, playerEntity, gameState);\r\n\t\t\tconst initialIndexFromLeft = candidate.indexFromLeftAtTimeOfDeath;\r\n\t\t\tconst indexFromRight =\r\n\t\t\t\tinitialIndexFromLeft == null\r\n\t\t\t\t\t? 0\r\n\t\t\t\t\t: Math.min(playerBoard.length, Math.max(0, playerBoard.length - initialIndexFromLeft));\r\n\t\t\tconst target = spawnEntities(\r\n\t\t\t\tspawn.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\ttrue,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tspawn,\r\n\t\t\t);\r\n\t\t\t// FIXME: here it should try to match the position at which the original minions died\r\n\t\t\tconst actualSpawns = performEntitySpawns(\r\n\t\t\t\ttarget,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tactualSpawns.forEach((t) =>\r\n\t\t\t\tgameState.spectator.registerPowerTarget(playerEntity, t, playerBoard, playerEntity, opponentEntity),\r\n\t\t\t);\r\n\t\t\ttrinket.scriptDataNum1 = 0;\r\n\t\t\t// It summons an exact copy\r\n\t\t\t// actualSpawns.forEach((entity) => {\r\n\t\t\t// \tswitch (entity.cardId) {\r\n\t\t\t// \t\tcase CardIds.AstralAutomaton_BG_TTN_401:\r\n\t\t\t// \t\tcase CardIds.AstralAutomaton_BG_TTN_401_G:\r\n\t\t\t// \t\t\tconst overstatMult = entity.cardId === CardIds.AstralAutomaton_BG_TTN_401 ? 1 : 2;\r\n\t\t\t// \t\t\tentity.attack = Math.max(1, entity.attack - 2 * overstatMult);\r\n\t\t\t// \t\t\tentity.health = Math.max(0, entity.health - overstatMult);\r\n\t\t\t// \t\t\tbreak;\r\n\t\t\t// \t}\r\n\t\t\t// });\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleTwinSkyLanternsForPlayer = (\r\n\ttrinket: BoardTrinket,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst spawnNumber = trinket.scriptDataNum1 ?? 0;\r\n\tconst canTrigger = spawnNumber >= 1;\r\n\tif (playerBoard.length <= 7 - spawnNumber && trinket.rememberedMinion && canTrigger) {\r\n\t\ttrinket.scriptDataNum1 = 0;\r\n\t\tconst spawn = copyEntity(trinket.rememberedMinion);\r\n\t\tremoveAurasFromSelf(spawn, playerBoard, playerEntity, gameState);\r\n\t\tconst target = spawnEntities(\r\n\t\t\tspawn.cardId,\r\n\t\t\tspawnNumber,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t\tplayerEntity.friendly,\r\n\t\t\ttrue,\r\n\t\t\tfalse,\r\n\t\t\tfalse,\r\n\t\t\tspawn,\r\n\t\t);\r\n\t\tperformEntitySpawns(\r\n\t\t\ttarget,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerEntity,\r\n\t\t\t0,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\ttarget.forEach((t) =>\r\n\t\t\tgameState.spectator.registerPowerTarget(playerEntity, t, playerBoard, playerEntity, opponentEntity),\r\n\t\t);\r\n\t}\r\n};\r\n\r\nconst handleOzumatForPlayer = (\r\n\theroPower: BgsHeroPower,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (playerBoard.length < 7 && heroPower.activated === false) {\r\n\t\tconst tentacularSize = +heroPower.info;\r\n\t\tconst tentacular = spawnEntities(\r\n\t\t\tCardIds.Tentacular_OzumatsTentacleToken_BG23_HERO_201pt,\r\n\t\t\t1,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t\tfriendly,\r\n\t\t\ttrue,\r\n\t\t\tfalse,\r\n\t\t\tfalse,\r\n\t\t);\r\n\t\ttentacular[0].attack = tentacularSize;\r\n\t\ttentacular[0].health = tentacularSize;\r\n\t\ttentacular[0].maxHealth = tentacularSize;\r\n\t\ttentacular[0].maxAttack = tentacularSize;\r\n\t\tconst indexFromRight = 0;\r\n\t\tperformEntitySpawns(\r\n\t\t\ttentacular,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerEntity,\r\n\t\t\tindexFromRight,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tgameState.spectator.registerPowerTarget(playerEntity, tentacular[0], playerBoard, playerEntity, opponentEntity);\r\n\t\theroPower.activated = true;\r\n\t}\r\n};\r\n\r\nconst handleFrostwolfFervorForPlayer = (\r\n\theroPower: BgsHeroPower,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (playerBoard.length < 7) {\r\n\t\theroPower.activated = true;\r\n\t\tconst target = pickRandomHighestAttack(playerBoard);\r\n\t\tif (!!target) {\r\n\t\t\tconst copy = copyEntity(target);\r\n\t\t\tconst indexFromRight = 0;\r\n\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\tcopy.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tcopy,\r\n\t\t\t);\r\n\t\t\tconst spawns = performEntitySpawns(\r\n\t\t\t\tnewMinions,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(playerEntity, spawns[0], playerBoard, playerEntity, opponentEntity);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleLockAndLoadForPlayer = (\r\n\theroPower: BgsHeroPower,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (playerBoard.length < 7) {\r\n\t\tconst summoned = heroPower.info as BoardEntity;\r\n\t\theroPower.activated = true;\r\n\t\tif (!!summoned?.cardId) {\r\n\t\t\tconst copy = copyEntity(summoned);\r\n\t\t\tcopy.attackImmediately = true;\r\n\t\t\tconst indexFromRight = 0;\r\n\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\tcopy.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tcopy,\r\n\t\t\t);\r\n\t\t\tconst spawns = performEntitySpawns(\r\n\t\t\t\tnewMinions,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(playerEntity, spawns[0], playerBoard, playerEntity, opponentEntity);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleStormpikeStrengthForPlayer = (\r\n\theroPower: BgsHeroPower,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (playerBoard.length < 7) {\r\n\t\theroPower.activated = true;\r\n\t\tconst target = pickRandomHighestHealth(playerBoard);\r\n\t\tif (!!target) {\r\n\t\t\tconst copy = copyEntity(target);\r\n\t\t\tconst indexFromRight = 0;\r\n\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\tcopy.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tcopy,\r\n\t\t\t);\r\n\t\t\tconst spawns = performEntitySpawns(\r\n\t\t\t\tnewMinions,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(playerEntity, spawns[0], playerBoard, playerEntity, opponentEntity);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleBoonOfBeetlesForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst secretEntity = playerEntity.secrets.find((entity) => entity.cardId === CardIds.BoonOfBeetles_BG28_603);\r\n\tif (secretEntity && secretEntity.triggersLeft > 0) {\r\n\t\twhile (secretEntity.triggersLeft > 0) {\r\n\t\t\tconst hasSummoned = handleSummon(\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tCardIds.BoonOfBeetles_BeetleToken_BG28_603t,\r\n\t\t\t\t0,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t\tif (hasSummoned) {\r\n\t\t\t\thasSummoned.forEach((entity) => {\r\n\t\t\t\t\tupdateTaunt(entity, true, playerBoard, playerEntity, opponentEntity, gameState);\r\n\t\t\t\t});\r\n\t\t\t\tsecretEntity.triggersLeft--;\r\n\t\t\t} else {\r\n\t\t\t\t// No room to summon, we stop here\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\nconst handleStableAmalgamationForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst rewardEntity = playerEntity.questRewardEntities.find(\r\n\t\t(entity) => entity.cardId === CardIds.StableAmalgamation_BG28_Reward_518,\r\n\t);\r\n\tif (rewardEntity && rewardEntity.scriptDataNum1 > 0) {\r\n\t\twhile (rewardEntity.scriptDataNum1 > 0) {\r\n\t\t\tconst hasSummoned = handleSummon(\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tCardIds.StableAmalgamation_TotallyNormalHorseToken_BG28_Reward_518t,\r\n\t\t\t\t0,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t\tif (hasSummoned) {\r\n\t\t\t\trewardEntity.scriptDataNum1--;\r\n\t\t\t} else {\r\n\t\t\t\t// No room to summon, we stop here\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleRapidReanimationForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst indexFromRight =\r\n\t\tplayerEntity.rapidReanimationIndexFromLeft === 0\r\n\t\t\t? Math.max(0, playerBoard.length - playerEntity.rapidReanimationIndexFromLeft)\r\n\t\t\t: playerEntity.rapidReanimationIndexFromRight;\r\n\tconst hasSummoned = handleSummon(\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tgameState,\r\n\t\tplayerEntity.rapidReanimationMinion.cardId,\r\n\t\tindexFromRight,\r\n\t\ttrue, // (Goldrinn gets buffed, so it seems we reapply auras? This is a mess tbh)\r\n\t\tplayerEntity.rapidReanimationMinion,\r\n\t);\r\n\tif (hasSummoned) {\r\n\t\tplayerEntity.rapidReanimationMinion = null;\r\n\t\t// Hard-coding a correction for Ancestral Automaton\r\n\t\t// Shold not be necessary if we reapply auras\r\n\t\t// hasSummoned.forEach((entity) => {\r\n\t\t// \tswitch (entity.cardId) {\r\n\t\t// \t\tcase CardIds.AstralAutomaton_BG_TTN_401:\r\n\t\t// \t\tcase CardIds.AstralAutomaton_BG_TTN_401_G:\r\n\t\t// \t\t\tconst overstatMult = entity.cardId === CardIds.AstralAutomaton_BG_TTN_401 ? 1 : 2;\r\n\t\t// \t\t\tentity.attack = Math.max(1, entity.attack + 2 * overstatMult);\r\n\t\t// \t\t\tentity.health = Math.max(0, entity.health + 2 * overstatMult);\r\n\t\t// \t\t\tbreak;\r\n\t\t// \t\tcase CardIds.EternalKnight_BG25_008:\r\n\t\t// \t\tcase CardIds.EternalKnight_BG25_008_G:\r\n\t\t// \t\t\tconst knightMult = entity.cardId === CardIds.EternalKnight_BG25_008 ? 1 : 2;\r\n\t\t// \t\t\tentity.attack = Math.max(1, entity.attack + 1 * knightMult);\r\n\t\t// \t\t\tentity.health = Math.max(0, entity.health + 1 * knightMult);\r\n\t\t// \t\t\tbreak;\r\n\t\t// \t}\r\n\t\t// });\r\n\t}\r\n};\r\n\r\nconst handleSummon = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tcardId: string,\r\n\tindexFromRight: number,\r\n\tapplyAuras: boolean,\r\n\tminion: BoardEntity = null,\r\n): readonly BoardEntity[] => {\r\n\tif (playerBoard.length >= 7) {\r\n\t\treturn null;\r\n\t}\r\n\tconst newMinion = buildSingleBoardEntity(\r\n\t\tcardId,\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\tgameState.allCards,\r\n\t\tplayerEntity.friendly,\r\n\t\tgameState.sharedState.currentEntityId++,\r\n\t\tfalse,\r\n\t\tgameState.cardsData,\r\n\t\tgameState.sharedState,\r\n\t\tminion,\r\n\t\tnull,\r\n\t);\r\n\t// Don't reapply auras in this particular case? See https://x.com/ZerotoHeroes_HS/status/1737422727118487808?s=20\r\n\tconst spawned = performEntitySpawns(\r\n\t\t[newMinion],\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\tplayerEntity,\r\n\t\tindexFromRight,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tgameState,\r\n\t\tapplyAuras,\r\n\t);\r\n\tgameState.spectator.registerPowerTarget(playerEntity, newMinion, playerBoard, null, null);\r\n\treturn spawned;\r\n};\r\n"]}
|