@firestone-hs/simulate-bgs-battle 1.1.758 → 1.1.759
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/simulation/add-minion-to-board.js +12 -1
- package/dist/simulation/add-minion-to-board.js.map +1 -1
- package/dist/simulation/death-effects.js +8 -2
- package/dist/simulation/death-effects.js.map +1 -1
- package/dist/simulation/deity.d.ts +8 -0
- package/dist/simulation/deity.js +65 -3
- package/dist/simulation/deity.js.map +1 -1
- package/dist/simulation/spectator/game-action.d.ts +1 -0
- package/dist/simulation/spectator/game-action.js +24 -3
- package/dist/simulation/spectator/game-action.js.map +1 -1
- package/dist/simulation/spectator/spectator.js +2 -0
- package/dist/simulation/spectator/spectator.js.map +1 -1
- package/dist/simulation/start-of-combat/start-of-combat.js +3 -0
- package/dist/simulation/start-of-combat/start-of-combat.js.map +1 -1
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ const divine_shield_1 = require("../keywords/divine-shield");
|
|
|
10
10
|
const taunt_1 = require("../keywords/taunt");
|
|
11
11
|
const utils_1 = require("../services/utils");
|
|
12
12
|
const utils_2 = require("../utils");
|
|
13
|
+
const deity_1 = require("./deity");
|
|
13
14
|
const quest_1 = require("./quest");
|
|
14
15
|
const stats_1 = require("./stats");
|
|
15
16
|
const addMinionToBoard = (board, boardHero, otherBoard, otherHero, index, minionToAdd, gameState, applySelfAuras = true) => {
|
|
@@ -162,7 +163,7 @@ const handleAddedMinionAuraEffect = (board, boardHero, otherBoard, otherHero, sp
|
|
|
162
163
|
};
|
|
163
164
|
exports.handleAddedMinionAuraEffect = handleAddedMinionAuraEffect;
|
|
164
165
|
const applyAurasToSelf = (spawned, board, boardHero, gameState, applyAttackAuras = true, applyHealthAuras = true) => {
|
|
165
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
166
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
166
167
|
if (applyAttackAuras) {
|
|
167
168
|
spawned.attack += boardHero.globalInfo.AdditionalAttack;
|
|
168
169
|
}
|
|
@@ -409,6 +410,16 @@ const applyAurasToSelf = (spawned, board, boardHero, gameState, applyAttackAuras
|
|
|
409
410
|
(0, stats_1.modifyStats)(spawned, null, applyAttackAuras ? statsBonusGnoll : 0, applyHealthAuras ? 0 : 0, board, boardHero, gameState, false);
|
|
410
411
|
break;
|
|
411
412
|
}
|
|
413
|
+
if ((0, deity_1.isDeityCard)(spawned.cardId, gameState.allCards) && !(0, deity_1.consumeDeityBaseStatsAssignment)(spawned)) {
|
|
414
|
+
const { attack, health } = (0, deity_1.getDeityAuraSnapshot)(spawned, boardHero);
|
|
415
|
+
const card = gameState.allCards.getCard(spawned.cardId);
|
|
416
|
+
const auraAttack = Math.max(0, attack - ((_k = card === null || card === void 0 ? void 0 : card.attack) !== null && _k !== void 0 ? _k : 0));
|
|
417
|
+
const auraHealth = Math.max(0, health - ((_l = card === null || card === void 0 ? void 0 : card.health) !== null && _l !== void 0 ? _l : 0));
|
|
418
|
+
spawned.tags = (_m = spawned.tags) !== null && _m !== void 0 ? _m : {};
|
|
419
|
+
spawned.tags[reference_data_1.GameTag.BACON_OLD_GOD_ATTACK] = attack;
|
|
420
|
+
spawned.tags[reference_data_1.GameTag.BACON_OLD_GOD_HEALTH] = health;
|
|
421
|
+
(0, stats_1.modifyStats)(spawned, null, applyAttackAuras ? auraAttack : 0, applyHealthAuras ? auraHealth : 0, board, boardHero, gameState, false);
|
|
422
|
+
}
|
|
412
423
|
};
|
|
413
424
|
exports.applyAurasToSelf = applyAurasToSelf;
|
|
414
425
|
const removeAurasFromSelf = (entity, board, boardHero, gameState, applyAttackAuras = true, applyHealthAuras = true, isOnBoard = true) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-minion-to-board.js","sourceRoot":"","sources":["../../src/simulation/add-minion-to-board.ts"],"names":[],"mappings":";;;AAAA,iEAAoD;AAGpD,4DASiC;AACjC,oDAA8C;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,CAAC,QAAQ,KAAK,OAAO,CAAC,QAAQ,EACnC;oBACD,IAAA,mBAAW,EAAC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;oBACnE,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;iBAC3E;gBACD,MAAM;SACP;KACD;AACF,CAAC,CAAC","sourcesContent":["import { Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport {\r\n\thasAfterOtherSpawned,\r\n\thasOnDespawned,\r\n\thasOnDespawnedEnchantment,\r\n\thasOnFriendlyMinionSummonedTrinket,\r\n\thasOnOtherSpawned,\r\n\thasOnOtherAuraSpawned as hasOnOtherSpawnedAura,\r\n\thasOnSpawned,\r\n\thasOnSpawnedEnchantment,\r\n} from '../cards/card.interface';\r\nimport { isWhelp } from '../cards/cards-data';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\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 { pickRandom } from '../services/utils';\r\nimport { alreadyHasVolumizerBuff, copyEntity, hasCorrectTribe, isVolumizer } from '../utils';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { onQuestProgressUpdated } from './quest';\r\nimport { modifyStats } from './stats';\r\n\r\n// export const addMinionsToBoard = (\r\n// \tboard: BoardEntity[],\r\n// \tboardHero: BgsPlayerEntity,\r\n// \totherBoard: BoardEntity[],\r\n// \totherHero: BgsPlayerEntity,\r\n// \tindex: number,\r\n// \tminionsToAdd: readonly BoardEntity[],\r\n// \tgameState: FullGameState,\r\n// ): void => {\r\n// \t// board.splice(index, 0, ...minionsToAdd);\r\n// \tfor (const minionToAdd of [...minionsToAdd].reverse()) {\r\n// \t\taddMinionToBoard(board, boardHero, otherBoard, otherHero, index, minionToAdd, gameState, false);\r\n// \t}\r\n// \thandleAfterSpawnEffects(board, boardHero, otherBoard, otherHero, minionsToAdd, gameState);\r\n// };\r\n\r\nexport const addMinionToBoard = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tindex: number,\r\n\tminionToAdd: BoardEntity,\r\n\tgameState: FullGameState,\r\n\tapplySelfAuras = true,\r\n): void => {\r\n\tboard.splice(index, 0, minionToAdd);\r\n\t// Minion has already been removed from the board in the previous step\r\n\t// Update the global \"SummonedThisGame/Combat\" info here\r\n\thandleAddedMinionAuraEffect(board, boardHero, otherBoard, otherHero, minionToAdd, gameState, applySelfAuras);\r\n\t// Important to do this here, so that \"attack immediately\" minions can be taken into account by the quests\r\n\tonMinionSummoned(boardHero, board, gameState);\r\n\thandleSpawnEffect(board, boardHero, otherBoard, otherHero, minionToAdd, gameState, applySelfAuras);\r\n};\r\n\r\nconst handleSpawnEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tspawned: BoardEntity,\r\n\tgameState: FullGameState,\r\n\tapplySelfAuras = true,\r\n): void => {\r\n\tconst cardIds = [spawned.cardId, ...(spawned.additionalCards ?? [])];\r\n\r\n\t// https://twitter.com/LoewenMitchell/status/1491879869457879040\r\n\tif (cardIds.some((cardId) => isWhelp(cardId, gameState.allCards))) {\r\n\t\tconst manyWhelps = board.filter((entity) => entity.cardId === CardIds.ManyWhelps_BG22_HERO_305_Buddy);\r\n\t\tconst goldenManyWhelps = board.filter((entity) => entity.cardId === CardIds.ManyWhelps_BG22_HERO_305_Buddy_G);\r\n\t\tmanyWhelps.forEach((entity) => {\r\n\t\t\tmodifyStats(entity, entity, 2, 2, board, boardHero, gameState);\r\n\t\t});\r\n\t\tgoldenManyWhelps.forEach((entity) => {\r\n\t\t\tmodifyStats(entity, entity, 4, 4, board, boardHero, gameState);\r\n\t\t});\r\n\t}\r\n\r\n\tfor (const entity of board) {\r\n\t\t// The case for Reborns, and these shouldn't proc on themselves\r\n\t\tif (entity.entityId === spawned.entityId) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tconst onOtherSpawnedImpl = cardMappings[entity.cardId];\r\n\t\tif (hasOnOtherSpawned(onOtherSpawnedImpl)) {\r\n\t\t\tonOtherSpawnedImpl.onOtherSpawned(entity, {\r\n\t\t\t\tspawned: spawned,\r\n\t\t\t\thero: boardHero,\r\n\t\t\t\tboard: board,\r\n\t\t\t\totherBoard: otherBoard,\r\n\t\t\t\totherHero: otherHero,\r\n\t\t\t\tapplySelfAuras,\r\n\t\t\t\tapplyAttackAuras: true,\r\n\t\t\t\tapplyHealthAuras: true,\r\n\t\t\t\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tswitch (entity.cardId) {\r\n\t\t\tcase CardIds.CobaltGuardian:\r\n\t\t\t\tif (hasCorrectTribe(spawned, boardHero, Race.MECH, gameState.anomalies, gameState.allCards)) {\r\n\t\t\t\t\tif (!entity.divineShield) {\r\n\t\t\t\t\t\tupdateDivineShield(entity, board, boardHero, otherHero, true, gameState);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tmodifyStats(entity, entity, 2, 0, board, boardHero, gameState);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(entity, entity, board, boardHero, otherHero);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t// case CardIds.Bigfernal_BGS_204:\r\n\t\t\t// case CardIds.Bigfernal_TB_BaconUps_304:\r\n\t\t\t// \tif (hasCorrectTribe(spawned, boardHero, Race.DEMON, gameState.anomalies, gameState.allCards)) {\r\n\t\t\t// \t\tconst statsBonus = entity.cardId === CardIds.Bigfernal_TB_BaconUps_304 ? 2 : 1;\r\n\t\t\t// \t\tmodifyStats(entity, entity, statsBonus, statsBonus, board, boardHero, gameState);\r\n\t\t\t// \t\tgameState.spectator.registerPowerTarget(entity, entity, board, boardHero, otherHero);\r\n\t\t\t// \t}\r\n\t\t\t// \tbreak;\r\n\t\t\tcase CardIds.MamaBear_BGS_021:\r\n\t\t\tcase CardIds.MamaBear_TB_BaconUps_090:\r\n\t\t\t\tif (hasCorrectTribe(spawned, boardHero, Race.BEAST, gameState.anomalies, gameState.allCards)) {\r\n\t\t\t\t\tconst statsBonus = entity.cardId === CardIds.MamaBear_TB_BaconUps_090 ? 12 : 6;\r\n\t\t\t\t\tmodifyStats(spawned, entity, statsBonus, statsBonus, board, boardHero, gameState);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(entity, entity, board, boardHero, otherHero);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t// case CardIds.PapaBear_BG27_509:\r\n\t\t\t// case CardIds.PapaBear_BG27_509_G:\r\n\t\t\t// \tif (hasCorrectTribe(spawned, boardHero, Race.BEAST, gameState.anomalies, gameState.allCards)) {\r\n\t\t\t// \t\tconst statsBonus = entity.cardId === CardIds.PapaBear_BG27_509_G ? 16 : 8;\r\n\t\t\t// \t\tmodifyStats(spawned, entity, statsBonus, statsBonus, board, boardHero, gameState);\r\n\t\t\t// \t\tgameState.spectator.registerPowerTarget(entity, entity, board, boardHero, otherHero);\r\n\t\t\t// \t}\r\n\t\t\t// \tbreak;\r\n\t\t\tcase CardIds.PackLeader_BGS_017:\r\n\t\t\tcase CardIds.PackLeader_TB_BaconUps_086:\r\n\t\t\t\tif (hasCorrectTribe(spawned, boardHero, Race.BEAST, gameState.anomalies, gameState.allCards)) {\r\n\t\t\t\t\tconst statsBonus = entity.cardId === CardIds.PackLeader_TB_BaconUps_086 ? 4 : 2;\r\n\t\t\t\t\tmodifyStats(spawned, entity, statsBonus, 0, board, boardHero, gameState);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(entity, entity, board, boardHero, otherHero);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const trinket of boardHero.trinkets ?? []) {\r\n\t\tconst onOtherSpawnedImpl = cardMappings[trinket.cardId];\r\n\t\tif (hasOnOtherSpawned(onOtherSpawnedImpl)) {\r\n\t\t\tonOtherSpawnedImpl.onOtherSpawned(trinket, {\r\n\t\t\t\tspawned: spawned,\r\n\t\t\t\thero: boardHero,\r\n\t\t\t\tboard: board,\r\n\t\t\t\totherBoard: otherBoard,\r\n\t\t\t\totherHero: otherHero,\r\n\t\t\t\tapplySelfAuras,\r\n\t\t\t\tapplyAttackAuras: true,\r\n\t\t\t\tapplyHealthAuras: true,\r\n\t\t\t\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n};\r\nexport const handleAddedMinionAuraEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tspawned: BoardEntity,\r\n\tgameState: FullGameState,\r\n\tapplySelfAuras = true,\r\n\tisActuallySpawned = true,\r\n): void => {\r\n\tfor (const heroPower of boardHero.heroPowers) {\r\n\t\tswitch (heroPower.cardId) {\r\n\t\t\tcase CardIds.SproutItOut:\r\n\t\t\t\tif (isActuallySpawned) {\r\n\t\t\t\t\tupdateTaunt(spawned, true, board, boardHero, otherHero, gameState);\r\n\t\t\t\t\tmodifyStats(spawned, boardHero, 1, 2, board, boardHero, gameState);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tif (boardHero.questRewards?.includes(CardIds.TumblingDisaster_BG28_Reward_505)) {\r\n\t\tconst tumblingDisasterBonus =\r\n\t\t\tboardHero.questRewardEntities?.find((e) => e.cardId === CardIds.TumblingDisaster_BG28_Reward_505)\r\n\t\t\t\t?.scriptDataNum1 || 1;\r\n\t\tmodifyStats(spawned, boardHero, tumblingDisasterBonus, tumblingDisasterBonus, board, boardHero, gameState);\r\n\t}\r\n\r\n\tif (isActuallySpawned) {\r\n\t\tfor (const trinket of boardHero.trinkets ?? []) {\r\n\t\t\tconst summonedImpl = cardMappings[trinket.cardId];\r\n\t\t\tif (hasOnFriendlyMinionSummonedTrinket(summonedImpl)) {\r\n\t\t\t\tsummonedImpl.onFriendlyMinionSummoned(trinket, {\r\n\t\t\t\t\tspawned,\r\n\t\t\t\t\tboard,\r\n\t\t\t\t\thero: boardHero,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t});\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tswitch (trinket.cardId) {\r\n\t\t\t\tcase CardIds.BlingtronsSunglasses_BG30_MagicItem_978:\r\n\t\t\t\t\tif (hasCorrectTribe(spawned, boardHero, Race.MECH, gameState.anomalies, gameState.allCards)) {\r\n\t\t\t\t\t\tconst target = pickRandom(board.filter((e) => !e.divineShield));\r\n\t\t\t\t\t\tif (!!target) {\r\n\t\t\t\t\t\t\tupdateDivineShield(target, board, boardHero, otherHero, true, gameState);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.TwinSkyLanterns_BG30_MagicItem_822:\r\n\t\t\t\tcase CardIds.TwinSkyLanterns_TwinSkyLanternsToken_BG30_MagicItem_822t2:\r\n\t\t\t\t\tif (!trinket.rememberedMinions?.length) {\r\n\t\t\t\t\t\ttrinket.rememberedMinions = [copyEntity(spawned)];\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Apply auras to board\r\n\tconst cardIds = [spawned.cardId, ...(spawned.additionalCards ?? [])];\r\n\tfor (const spawnedCardId of cardIds) {\r\n\t\thandleMinionAddedAuraEffect(spawnedCardId, spawned, board, boardHero, gameState, isActuallySpawned);\r\n\t}\r\n\r\n\t// When we want to summon an \"exact copy\", we need to make sure we don't apply the aura twice\r\n\t// First apply self auras. This way, something like Astral Automaton won't first buff the counter,\r\n\t// then apply the aura with a buffed counter\r\n\t// THAT SEEMS WRONG! If the counter is N, then we summon the Automaton and apply N-1, already discounting\r\n\t// it\r\n\tif (applySelfAuras) {\r\n\t\t// The board here already contains the new minion\r\n\t\t// TODO: what if the additional part is a potential target for the aura effect?\r\n\t\t// 2024-08-27: changing the order to first handleMinionAddedAuraEffect so that the automatons get boosted,\r\n\t\t// then apply the aura\r\n\t\tapplyAurasToSelf(spawned, board, boardHero, gameState);\r\n\t}\r\n\r\n\tif (isActuallySpawned) {\r\n\t\tif (hasCorrectTribe(spawned, boardHero, Race.BEAST, gameState.anomalies, gameState.allCards)) {\r\n\t\t\tboardHero.globalInfo.BeastsSummonedThisCombat++;\r\n\t\t\tboardHero.globalInfo.BeastsSummonedThisGame++;\r\n\t\t}\r\n\t\tif (hasCorrectTribe(spawned, boardHero, Race.PIRATE, gameState.anomalies, gameState.allCards)) {\r\n\t\t\tboardHero.globalInfo.PiratesSummonedThisGame++;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyAurasToSelf = (\r\n\tspawned: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tapplyAttackAuras = true,\r\n\tapplyHealthAuras = true,\r\n): void => {\r\n\tif (applyAttackAuras) {\r\n\t\tspawned.attack += boardHero.globalInfo.AdditionalAttack;\r\n\t}\r\n\r\n\tif (!!boardHero.questRewards?.length) {\r\n\t\tfor (const quest of boardHero.questRewards) {\r\n\t\t\tswitch (quest) {\r\n\t\t\t\tcase CardIds.VolatileVenom:\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tspawned.attack += 7;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (applyHealthAuras) {\r\n\t\t\t\t\t\tspawned.health += 7;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tspawned.enchantments.push({\r\n\t\t\t\t\t\tcardId: CardIds.VolatileVenom_VolatileEnchantment,\r\n\t\t\t\t\t\toriginEntityId: undefined,\r\n\t\t\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t\t\t});\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.TheSmokingGun:\r\n\t\t\t\t\tspawned.attack += 4;\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (!!boardHero.trinkets?.length) {\r\n\t\tfor (const trinket of boardHero.trinkets) {\r\n\t\t\tswitch (trinket.cardId) {\r\n\t\t\t\tcase CardIds.FeralTalisman_BG30_MagicItem_880:\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tspawned.attack += 2;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (applyHealthAuras) {\r\n\t\t\t\t\t\tspawned.health += 1;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.FeralTalisman_FeralTalismanToken_BG30_MagicItem_880t:\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tspawned.attack += 8;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (applyHealthAuras) {\r\n\t\t\t\t\t\tspawned.health += 5;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.DazzlingDagger_BG32_MagicItem_934:\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tspawned.attack += trinket.scriptDataNum1 || 1;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.HordeKeychainToken_BG30_MagicItem_843t:\r\n\t\t\t\t\tif (gameState.cardsData.getTavernLevel(spawned.cardId) <= 3) {\r\n\t\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\t\tspawned.attack += 7;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif (applyHealthAuras) {\r\n\t\t\t\t\t\t\tspawned.health += 5;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.FlagbearerPortrait_BG30_MagicItem_921:\r\n\t\t\t\t\tif (\r\n\t\t\t\t\t\tspawned.cardId === CardIds.Scallywag_SkyPirateToken_BGS_061t ||\r\n\t\t\t\t\t\tspawned.cardId === CardIds.Scallywag_SkyPirateToken_TB_BaconUps_141t\r\n\t\t\t\t\t) {\r\n\t\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\t\tspawned.attack += 6;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (boardHero.globalInfo.HauntedCarapaceAttackBonus > 0) {\r\n\t\tif (applyAttackAuras) {\r\n\t\t\tmodifyStats(\r\n\t\t\t\tspawned,\r\n\t\t\t\tspawned,\r\n\t\t\t\tboardHero.globalInfo.HauntedCarapaceAttackBonus,\r\n\t\t\t\t0,\r\n\t\t\t\tboard,\r\n\t\t\t\tboardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\tif (boardHero.globalInfo.HauntedCarapaceHealthBonus > 0) {\r\n\t\tif (applyHealthAuras) {\r\n\t\t\tmodifyStats(\r\n\t\t\t\tspawned,\r\n\t\t\t\tspawned,\r\n\t\t\t\t0,\r\n\t\t\t\tboardHero.globalInfo.HauntedCarapaceHealthBonus,\r\n\t\t\t\tboard,\r\n\t\t\t\tboardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\tif (hasCorrectTribe(spawned, boardHero, Race.UNDEAD, gameState.anomalies, gameState.allCards)) {\r\n\t\tif (boardHero.globalInfo.UndeadAttackBonus > 0) {\r\n\t\t\tif (applyAttackAuras) {\r\n\t\t\t\tmodifyStats(\r\n\t\t\t\t\tspawned,\r\n\t\t\t\t\tspawned,\r\n\t\t\t\t\tboardHero.globalInfo.UndeadAttackBonus,\r\n\t\t\t\t\t0,\r\n\t\t\t\t\tboard,\r\n\t\t\t\t\tboardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (boardHero.globalInfo.UndeadHealthBonus > 0) {\r\n\t\t\tif (applyHealthAuras) {\r\n\t\t\t\tmodifyStats(\r\n\t\t\t\t\tspawned,\r\n\t\t\t\t\tspawned,\r\n\t\t\t\t\t0,\r\n\t\t\t\t\tboardHero.globalInfo.UndeadHealthBonus,\r\n\t\t\t\t\tboard,\r\n\t\t\t\t\tboardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (hasCorrectTribe(spawned, boardHero, Race.PIRATE, gameState.anomalies, gameState.allCards)) {\r\n\t\tif (boardHero.globalInfo.PirateAttackBonus > 0) {\r\n\t\t\tif (applyAttackAuras) {\r\n\t\t\t\tmodifyStats(\r\n\t\t\t\t\tspawned,\r\n\t\t\t\t\tspawned,\r\n\t\t\t\t\tboardHero.globalInfo.PirateAttackBonus,\r\n\t\t\t\t\t0,\r\n\t\t\t\t\tboard,\r\n\t\t\t\t\tboardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (hasCorrectTribe(spawned, boardHero, Race.MECH, gameState.anomalies, gameState.allCards)) {\r\n\t\tif (boardHero.globalInfo.MechAttackBonus > 0) {\r\n\t\t\tif (applyAttackAuras) {\r\n\t\t\t\tmodifyStats(\r\n\t\t\t\t\tspawned,\r\n\t\t\t\t\tspawned,\r\n\t\t\t\t\tboardHero.globalInfo.MechAttackBonus,\r\n\t\t\t\t\t0,\r\n\t\t\t\t\tboard,\r\n\t\t\t\t\tboardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (hasCorrectTribe(spawned, boardHero, Race.BEAST, gameState.anomalies, gameState.allCards)) {\r\n\t\tif (boardHero.globalInfo.GoldrinnBuffAtk > 0) {\r\n\t\t\tconst attackBuff = applyAttackAuras ? boardHero.globalInfo.GoldrinnBuffAtk : 0;\r\n\t\t\tconst healthBuff = applyHealthAuras ? boardHero.globalInfo.GoldrinnBuffHealth : 0;\r\n\t\t\tmodifyStats(spawned, spawned, attackBuff, healthBuff, board, boardHero, gameState, false);\r\n\t\t\tgameState.spectator.registerPowerTarget(boardHero, spawned, board, null, null);\r\n\t\t}\r\n\t}\r\n\tif (isWhelp(spawned.cardId, gameState.allCards)) {\r\n\t\tconst attackBuff = applyAttackAuras ? boardHero.globalInfo.WhelpAttackBuff ?? 0 : 0;\r\n\t\tconst healthBuff = applyHealthAuras ? boardHero.globalInfo.WhelpHealthBuff ?? 0 : 0;\r\n\t\tmodifyStats(spawned, spawned, attackBuff, healthBuff, board, boardHero, gameState, false);\r\n\t\tgameState.spectator.registerPowerTarget(boardHero, spawned, board, null, null);\r\n\t}\r\n\tif (\r\n\t\tisVolumizer(spawned.cardId, boardHero, gameState.anomalies, gameState.allCards) &&\r\n\t\t// https://replays.firestoneapp.com/?reviewId=75e82ef1-3442-4307-a3c8-4a3b72fcf6af&turn=11&action=2\r\n\t\t!alreadyHasVolumizerBuff(spawned, boardHero, gameState)\r\n\t) {\r\n\t\tif (boardHero.globalInfo.VolumizerAttackBuff > 0 || boardHero.globalInfo.VolumizerHealthBuff > 0) {\r\n\t\t\tconst attackBuff = applyAttackAuras ? boardHero.globalInfo.VolumizerAttackBuff ?? 0 : 0;\r\n\t\t\tconst healthBuff = applyHealthAuras ? boardHero.globalInfo.VolumizerHealthBuff ?? 0 : 0;\r\n\t\t\tmodifyStats(spawned, spawned, attackBuff, healthBuff, board, boardHero, gameState, false);\r\n\t\t\tgameState.spectator.registerPowerTarget(boardHero, spawned, board, null, null);\r\n\t\t}\r\n\t}\r\n\r\n\t// In case Putricide spawns a stictched minion whose stitched part creates an aura effect\r\n\t// const potentialAuraSources: { cardId: string; entityId: number }[] = [\r\n\t// \t{ cardId: spawned.cardId, entityId: spawned.entityId },\r\n\t// \t...(spawned.additionalCards ?? []).map((cardId) => ({ cardId, entityId: spawned.entityId })),\r\n\t// ];\r\n\r\n\tif (gameState.cardsData.getTavernLevel(spawned.cardId) % 2 === 1) {\r\n\t\tconst atkBuff = applyAttackAuras ? boardHero.globalInfo.MutatedLasherAttackBuff ?? 0 : 0;\r\n\t\tconst healthBuff = applyHealthAuras ? boardHero.globalInfo.MutatedLasherHealthBuff ?? 0 : 0;\r\n\t\tmodifyStats(spawned, spawned, atkBuff, healthBuff, board, boardHero, gameState, false);\r\n\t}\r\n\tfor (const entity of board) {\r\n\t\tconst onOtherSpawnedImpl = cardMappings[entity.cardId];\r\n\t\tif (hasOnOtherSpawnedAura(onOtherSpawnedImpl)) {\r\n\t\t\tonOtherSpawnedImpl.onOtherSpawnedAura(entity, {\r\n\t\t\t\tspawned: spawned,\r\n\t\t\t\thero: boardHero,\r\n\t\t\t\tboard: board,\r\n\t\t\t\tgameState,\r\n\t\t\t\tapplyAttackAuras,\r\n\t\t\t\tapplyHealthAuras,\r\n\t\t\t});\r\n\t\t}\r\n\t\tswitch (entity.cardId) {\r\n\t\t\tcase CardIds.MurlocWarleaderLegacy_BG_EX1_507:\r\n\t\t\tcase CardIds.MurlocWarleaderLegacy_TB_BaconUps_008:\r\n\t\t\t\tif (\r\n\t\t\t\t\thasCorrectTribe(spawned, boardHero, Race.MURLOC, gameState.anomalies, gameState.allCards) &&\r\n\t\t\t\t\tentity.entityId !== spawned.entityId\r\n\t\t\t\t) {\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tspawned.attack += entity.cardId === CardIds.MurlocWarleaderLegacy_TB_BaconUps_008 ? 4 : 2;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SouthseaCaptainLegacy_BG_NEW1_027:\r\n\t\t\tcase CardIds.SouthseaCaptainLegacy_TB_BaconUps_136:\r\n\t\t\t\tif (\r\n\t\t\t\t\thasCorrectTribe(spawned, boardHero, Race.PIRATE, gameState.anomalies, gameState.allCards) &&\r\n\t\t\t\t\tentity.entityId !== spawned.entityId\r\n\t\t\t\t) {\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tspawned.attack += entity.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (applyHealthAuras) {\r\n\t\t\t\t\t\tspawned.health += entity.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t// case CardIds.Kathranatir_BG21_039:\r\n\t\t\t// case CardIds.Kathranatir_BG21_039_G:\r\n\t\t\t// \tif (\r\n\t\t\t// \t\thasCorrectTribe(spawned, boardHero, Race.DEMON, gameState.anomalies, gameState.allCards) &&\r\n\t\t\t// \t\tentity.entityId !== spawned.entityId\r\n\t\t\t// \t) {\r\n\t\t\t// \t\tspawned.attack += entity.cardId === CardIds.Kathranatir_BG21_039_G ? 2 : 1;\r\n\t\t\t// \t}\r\n\t\t\t// \tbreak;\r\n\t\t\tcase CardIds.CyborgDrake_BG25_043:\r\n\t\t\tcase CardIds.CyborgDrake_BG25_043_G:\r\n\t\t\t\tif (spawned.divineShield) {\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tspawned.attack += entity.cardId === CardIds.CyborgDrake_BG25_043_G ? 12 : 6;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SoreLoser_BG27_030:\r\n\t\t\tcase CardIds.SoreLoser_BG27_030_G:\r\n\t\t\t\tif (\r\n\t\t\t\t\thasCorrectTribe(spawned, boardHero, Race.UNDEAD, gameState.anomalies, gameState.allCards) &&\r\n\t\t\t\t\tentity.entityId !== spawned.entityId\r\n\t\t\t\t) {\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tspawned.attack +=\r\n\t\t\t\t\t\t\t(entity.cardId === CardIds.SoreLoser_BG27_030_G ? 2 : 1) * boardHero.tavernTier;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tconst onSpawnedImpl = cardMappings[spawned.cardId];\r\n\tif (hasOnSpawned(onSpawnedImpl)) {\r\n\t\tonSpawnedImpl.onSpawned(spawned, {\r\n\t\t\thero: boardHero,\r\n\t\t\tboard: board,\r\n\t\t\tgameState: gameState,\r\n\t\t\tapplyAttackAuras,\r\n\t\t\tapplyHealthAuras,\r\n\t\t});\r\n\t}\r\n\tfor (const enchantment of spawned.enchantments) {\r\n\t\tconst onSpawnedEnchantmentImpl = cardMappings[enchantment.cardId];\r\n\t\tif (hasOnSpawnedEnchantment(onSpawnedEnchantmentImpl)) {\r\n\t\t\tonSpawnedEnchantmentImpl.onSpawnedEnchantment(spawned, enchantment, {\r\n\t\t\t\thero: boardHero,\r\n\t\t\t\tboard: board,\r\n\t\t\t\tgameState: gameState,\r\n\t\t\t\tapplyAttackAuras,\r\n\t\t\t\tapplyHealthAuras,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\tswitch (spawned.cardId) {\r\n\t\tcase CardIds.EternalKnight_BG25_008:\r\n\t\tcase CardIds.EternalKnight_BG25_008_G:\r\n\t\t\tconst multiplierKnight = spawned.cardId === CardIds.EternalKnight_BG25_008_G ? 2 : 1;\r\n\t\t\tconst statsBonusKnight = multiplierKnight * boardHero.globalInfo.EternalKnightsDeadThisGame;\r\n\t\t\tmodifyStats(\r\n\t\t\t\tspawned,\r\n\t\t\t\tnull,\r\n\t\t\t\tapplyAttackAuras\r\n\t\t\t\t\t? eternalKnightAttack * statsBonusKnight + boardHero.globalInfo.EternalKnightAttackBuff\r\n\t\t\t\t\t: 0,\r\n\t\t\t\tapplyHealthAuras\r\n\t\t\t\t\t? eternalKnightHealth * statsBonusKnight + boardHero.globalInfo.EternalKnightHealthBuff\r\n\t\t\t\t\t: 0,\r\n\t\t\t\tboard,\r\n\t\t\t\tboardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.EnsorcelledFungus_BG28_555:\r\n\t\tcase CardIds.EnsorcelledFungus_BG28_555_G:\r\n\t\t\tconst multiplierFungus = spawned.cardId === CardIds.EnsorcelledFungus_BG28_555_G ? 2 : 1;\r\n\t\t\tconst statsBonusFungus = multiplierFungus * boardHero.globalInfo.TavernSpellsCastThisGame;\r\n\t\t\tmodifyStats(\r\n\t\t\t\tspawned,\r\n\t\t\t\tnull,\r\n\t\t\t\tapplyAttackAuras ? statsBonusFungus : 0,\r\n\t\t\t\tapplyHealthAuras ? 2 * statsBonusFungus : 0,\r\n\t\t\t\tboard,\r\n\t\t\t\tboardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.SaltyLooter_BGS_081:\r\n\t\tcase CardIds.SaltyLooter_TB_BaconUps_143:\r\n\t\t\tconst multiplierLooter = spawned.cardId === CardIds.SaltyLooter_TB_BaconUps_143 ? 2 : 1;\r\n\t\t\tconst statsBonusLooter = multiplierLooter * boardHero.globalInfo.PiratesSummonedThisGame;\r\n\t\t\tmodifyStats(\r\n\t\t\t\tspawned,\r\n\t\t\t\tnull,\r\n\t\t\t\tapplyAttackAuras ? 2 * statsBonusLooter : 0,\r\n\t\t\t\tapplyHealthAuras ? 2 * multiplierLooter : 0,\r\n\t\t\t\tboard,\r\n\t\t\t\tboardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.AstralAutomaton_BG_TTN_401:\r\n\t\tcase CardIds.AstralAutomaton_BG_TTN_401_G:\r\n\t\t\tconst multiplierAstral = spawned.cardId === CardIds.AstralAutomaton_BG_TTN_401_G ? 2 : 1;\r\n\t\t\t// Don't count the yourself\r\n\t\t\tconst statsBonusAstral =\r\n\t\t\t\tmultiplierAstral * ((boardHero.globalInfo.AstralAutomatonsSummonedThisGame ?? 0) - 1);\r\n\t\t\tmodifyStats(\r\n\t\t\t\tspawned,\r\n\t\t\t\tnull,\r\n\t\t\t\tapplyAttackAuras ? 3 * statsBonusAstral : 0,\r\n\t\t\t\tapplyHealthAuras ? 2 * statsBonusAstral : 0,\r\n\t\t\t\tboard,\r\n\t\t\t\tboardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.RotHideGnoll_BG25_013:\r\n\t\tcase CardIds.RotHideGnoll_BG25_013_G:\r\n\t\t\tconst multiplierGnoll = spawned.cardId === CardIds.RotHideGnoll_BG25_013_G ? 2 : 1;\r\n\t\t\tconst statsBonusGnoll =\r\n\t\t\t\tmultiplierGnoll * gameState.sharedState.deaths.filter((e) => e.friendly === spawned.friendly).length;\r\n\t\t\tmodifyStats(\r\n\t\t\t\tspawned,\r\n\t\t\t\tnull,\r\n\t\t\t\tapplyAttackAuras ? statsBonusGnoll : 0,\r\n\t\t\t\tapplyHealthAuras ? 0 : 0,\r\n\t\t\t\tboard,\r\n\t\t\t\tboardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t}\r\n};\r\n\r\n// Introduced for Rapid Reanimation: since we will \"addMinionToBoard\" the minion afterwards, the auras will\r\n// be re-applied then, so we need to remove them first\r\nexport const removeAurasFromSelf = (\r\n\tentity: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tapplyAttackAuras = true,\r\n\tapplyHealthAuras = true,\r\n\tisOnBoard = true,\r\n): void => {\r\n\tif (applyAttackAuras) {\r\n\t\tentity.attack -= Math.max(0, boardHero.globalInfo.AdditionalAttack);\r\n\t\tentity.maxAttack -= Math.max(0, boardHero.globalInfo.AdditionalAttack);\r\n\t}\r\n\r\n\tconst onDespawnedImpl = cardMappings[entity.cardId];\r\n\tif (hasOnDespawned(onDespawnedImpl)) {\r\n\t\tonDespawnedImpl.onDespawned(entity, {\r\n\t\t\thero: boardHero,\r\n\t\t\tboard: board,\r\n\t\t\tgameState,\r\n\t\t\tapplyAttackAuras,\r\n\t\t\tapplyHealthAuras,\r\n\t\t});\r\n\t}\r\n\tfor (const enchantment of entity.enchantments) {\r\n\t\tconst onDespawnedEnchantmentImpl = cardMappings[enchantment.cardId];\r\n\t\tif (hasOnDespawnedEnchantment(onDespawnedEnchantmentImpl)) {\r\n\t\t\tonDespawnedEnchantmentImpl.onDespawnedEnchantment(entity, enchantment, {\r\n\t\t\t\thero: boardHero,\r\n\t\t\t\tboard: board,\r\n\t\t\t\tgameState: gameState,\r\n\t\t\t\tapplyAttackAuras,\r\n\t\t\t\tapplyHealthAuras,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\tfor (const enchantment of entity.enchantments) {\r\n\t\tswitch (enchantment?.cardId) {\r\n\t\t\tcase CardIds.TavernLighting_TavernLightsEnchantment:\r\n\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\tentity.attack = Math.max(0, entity.attack - enchantment.tagScriptDataNum1);\r\n\t\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - enchantment.tagScriptDataNum1);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tif (!!boardHero.questRewards?.length) {\r\n\t\tfor (const quest of boardHero.questRewards) {\r\n\t\t\tswitch (quest) {\r\n\t\t\t\tcase CardIds.VolatileVenom:\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tentity.attack = Math.max(0, entity.attack - 7);\r\n\t\t\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - 7);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (applyHealthAuras) {\r\n\t\t\t\t\t\tentity.health = Math.max(1, entity.health - 7);\r\n\t\t\t\t\t\tentity.maxHealth = Math.max(1, entity.health - 7);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tentity.enchantments = entity.enchantments.filter(\r\n\t\t\t\t\t\t(e) => e.cardId !== CardIds.VolatileVenom_VolatileEnchantment,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.TheSmokingGun:\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tentity.attack = Math.max(0, entity.attack - 7);\r\n\t\t\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - 7);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.FlagbearerPortrait_BG30_MagicItem_921:\r\n\t\t\t\t\tif (\r\n\t\t\t\t\t\tentity.cardId === CardIds.SkyPirateFlagbearer_BG30_119 ||\r\n\t\t\t\t\t\tentity.cardId === CardIds.SkyPirateFlagbearer_BG30_119_G\r\n\t\t\t\t\t) {\r\n\t\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\t\tentity.attack = Math.max(0, entity.attack - 8);\r\n\t\t\t\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - 8);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (!!boardHero.trinkets?.length) {\r\n\t\tfor (const trinket of boardHero.trinkets) {\r\n\t\t\tswitch (trinket.cardId) {\r\n\t\t\t\tcase CardIds.FeralTalisman_BG30_MagicItem_880:\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tentity.attack = Math.max(0, entity.attack - 2);\r\n\t\t\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - 2);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (applyHealthAuras) {\r\n\t\t\t\t\t\tentity.health = Math.max(1, entity.health - 1);\r\n\t\t\t\t\t\tentity.maxHealth = Math.max(1, entity.maxHealth - 1);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.FeralTalisman_FeralTalismanToken_BG30_MagicItem_880t:\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tentity.attack = Math.max(0, entity.attack - 8);\r\n\t\t\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - 8);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (applyHealthAuras) {\r\n\t\t\t\t\t\tentity.health = Math.max(1, entity.health - 5);\r\n\t\t\t\t\t\tentity.maxHealth = Math.max(1, entity.maxHealth - 5);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.DazzlingDagger_BG32_MagicItem_934:\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tentity.attack = Math.max(0, entity.attack - (trinket.scriptDataNum1 || 1));\r\n\t\t\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - (trinket.scriptDataNum1 || 1));\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.HordeKeychainToken_BG30_MagicItem_843t:\r\n\t\t\t\t\tif (gameState.cardsData.getTavernLevel(entity.cardId) <= 3) {\r\n\t\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\t\tentity.attack = Math.max(0, entity.attack - 7);\r\n\t\t\t\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - 7);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif (applyHealthAuras) {\r\n\t\t\t\t\t\t\tentity.health = Math.max(1, entity.health - 5);\r\n\t\t\t\t\t\t\tentity.maxHealth = Math.max(1, entity.maxHealth - 5);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (boardHero.globalInfo.HauntedCarapaceAttackBonus > 0) {\r\n\t\tif (applyAttackAuras) {\r\n\t\t\tentity.attack = Math.max(0, entity.attack - boardHero.globalInfo.HauntedCarapaceAttackBonus);\r\n\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - boardHero.globalInfo.HauntedCarapaceAttackBonus);\r\n\t\t}\r\n\t}\r\n\tif (boardHero.globalInfo.HauntedCarapaceHealthBonus > 0) {\r\n\t\tif (applyHealthAuras) {\r\n\t\t\tentity.health = Math.max(1, entity.health - boardHero.globalInfo.HauntedCarapaceHealthBonus);\r\n\t\t\tentity.maxHealth = Math.max(1, entity.maxHealth - boardHero.globalInfo.HauntedCarapaceHealthBonus);\r\n\t\t}\r\n\t}\r\n\tif (hasCorrectTribe(entity, boardHero, Race.UNDEAD, gameState.anomalies, gameState.allCards)) {\r\n\t\tif (boardHero.globalInfo.UndeadAttackBonus > 0) {\r\n\t\t\tif (applyAttackAuras) {\r\n\t\t\t\tentity.attack = Math.max(0, entity.attack - boardHero.globalInfo.UndeadAttackBonus);\r\n\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - boardHero.globalInfo.UndeadAttackBonus);\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (boardHero.globalInfo.UndeadHealthBonus > 0) {\r\n\t\t\tif (applyHealthAuras) {\r\n\t\t\t\tentity.health = Math.max(1, entity.health - boardHero.globalInfo.UndeadHealthBonus);\r\n\t\t\t\tentity.maxHealth = Math.max(1, entity.maxHealth - boardHero.globalInfo.UndeadHealthBonus);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (hasCorrectTribe(entity, boardHero, Race.BEAST, gameState.anomalies, gameState.allCards)) {\r\n\t\tif (boardHero.globalInfo.GoldrinnBuffAtk > 0) {\r\n\t\t\tif (applyAttackAuras) {\r\n\t\t\t\tentity.attack = Math.max(0, entity.attack - boardHero.globalInfo.GoldrinnBuffAtk);\r\n\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - boardHero.globalInfo.GoldrinnBuffAtk);\r\n\t\t\t}\r\n\t\t\tif (applyHealthAuras) {\r\n\t\t\t\tentity.health = Math.max(1, entity.health - boardHero.globalInfo.GoldrinnBuffHealth);\r\n\t\t\t\tentity.maxHealth = Math.max(1, entity.maxHealth - boardHero.globalInfo.GoldrinnBuffHealth);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const boardEntity of board) {\r\n\t\tswitch (boardEntity.cardId) {\r\n\t\t\tcase CardIds.MurlocWarleaderLegacy_BG_EX1_507:\r\n\t\t\tcase CardIds.MurlocWarleaderLegacy_TB_BaconUps_008:\r\n\t\t\t\tif (\r\n\t\t\t\t\thasCorrectTribe(entity, boardHero, Race.MURLOC, gameState.anomalies, gameState.allCards) &&\r\n\t\t\t\t\tentity.entityId !== boardEntity.entityId\r\n\t\t\t\t) {\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tentity.attack = Math.max(\r\n\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\tentity.attack -\r\n\t\t\t\t\t\t\t\t(boardEntity.cardId === CardIds.MurlocWarleaderLegacy_TB_BaconUps_008 ? 4 : 2),\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tentity.maxAttack = Math.max(\r\n\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\tentity.maxAttack -\r\n\t\t\t\t\t\t\t\t(boardEntity.cardId === CardIds.MurlocWarleaderLegacy_TB_BaconUps_008 ? 4 : 2),\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SouthseaCaptainLegacy_BG_NEW1_027:\r\n\t\t\tcase CardIds.SouthseaCaptainLegacy_TB_BaconUps_136:\r\n\t\t\t\tif (\r\n\t\t\t\t\thasCorrectTribe(entity, boardHero, Race.PIRATE, gameState.anomalies, gameState.allCards) &&\r\n\t\t\t\t\tentity.entityId !== boardEntity.entityId\r\n\t\t\t\t) {\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tentity.attack = Math.max(\r\n\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\tentity.attack -\r\n\t\t\t\t\t\t\t\t(boardEntity.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1),\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tentity.maxAttack = Math.max(\r\n\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\tentity.maxAttack -\r\n\t\t\t\t\t\t\t\t(boardEntity.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1),\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (applyHealthAuras) {\r\n\t\t\t\t\t\tentity.health = Math.max(\r\n\t\t\t\t\t\t\t1,\r\n\t\t\t\t\t\t\tentity.health -\r\n\t\t\t\t\t\t\t\t(boardEntity.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1),\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tentity.maxHealth = Math.max(\r\n\t\t\t\t\t\t\t1,\r\n\t\t\t\t\t\t\tentity.maxHealth -\r\n\t\t\t\t\t\t\t\t(boardEntity.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1),\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t// case CardIds.Kathranatir_BG21_039:\r\n\t\t\t// case CardIds.Kathranatir_BG21_039_G:\r\n\t\t\t// \tif (\r\n\t\t\t// \t\thasCorrectTribe(entity, boardHero, Race.DEMON, gameState.anomalies, gameState.allCards) &&\r\n\t\t\t// \t\tentity.entityId !== boardEntity.entityId\r\n\t\t\t// \t) {\r\n\t\t\t// \t\tentity.attack = Math.max(\r\n\t\t\t// \t\t\t0,\r\n\t\t\t// \t\t\tentity.attack - (boardEntity.cardId === CardIds.Kathranatir_BG21_039_G ? 2 : 1),\r\n\t\t\t// \t\t);\r\n\t\t\t// \t}\r\n\t\t\t// \tbreak;\r\n\t\t\tcase CardIds.CyborgDrake_BG25_043:\r\n\t\t\tcase CardIds.CyborgDrake_BG25_043_G:\r\n\t\t\t\tif (entity.divineShield) {\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tentity.attack = Math.max(\r\n\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\tentity.attack - (boardEntity.cardId === CardIds.CyborgDrake_BG25_043_G ? 12 : 6),\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tentity.maxAttack = Math.max(\r\n\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\tentity.maxAttack - (boardEntity.cardId === CardIds.CyborgDrake_BG25_043_G ? 12 : 6),\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SoreLoser_BG27_030:\r\n\t\t\tcase CardIds.SoreLoser_BG27_030_G:\r\n\t\t\t\tif (\r\n\t\t\t\t\thasCorrectTribe(entity, boardHero, Race.UNDEAD, gameState.anomalies, gameState.allCards) &&\r\n\t\t\t\t\tentity.entityId !== boardEntity.entityId\r\n\t\t\t\t) {\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tentity.attack = Math.max(\r\n\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\tentity.attack -\r\n\t\t\t\t\t\t\t\t(boardEntity.cardId === CardIds.SoreLoser_BG27_030_G ? 2 : 1) * boardHero.tavernTier,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tentity.maxAttack = Math.max(\r\n\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\tentity.maxAttack -\r\n\t\t\t\t\t\t\t\t(boardEntity.cardId === CardIds.SoreLoser_BG27_030_G ? 2 : 1) * boardHero.tavernTier,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tswitch (entity.cardId) {\r\n\t\tcase CardIds.EternalKnight_BG25_008:\r\n\t\tcase CardIds.EternalKnight_BG25_008_G:\r\n\t\t\tconst multiplierKnight = entity.cardId === CardIds.EternalKnight_BG25_008_G ? 2 : 1;\r\n\t\t\tconst statsBonusKnight = multiplierKnight * boardHero.globalInfo.EternalKnightsDeadThisGame;\r\n\t\t\tconst knightAttackToRemove =\r\n\t\t\t\teternalKnightAttack * statsBonusKnight + boardHero.globalInfo.EternalKnightAttackBuff;\r\n\t\t\tconst knightHealthToRemove =\r\n\t\t\t\teternalKnightHealth * statsBonusKnight + boardHero.globalInfo.EternalKnightHealthBuff;\r\n\t\t\tif (applyAttackAuras) {\r\n\t\t\t\tentity.attack = Math.max(eternalKnightAttack * multiplierKnight, entity.attack - knightAttackToRemove);\r\n\t\t\t\tentity.maxAttack = Math.max(\r\n\t\t\t\t\teternalKnightAttack * multiplierKnight,\r\n\t\t\t\t\tentity.maxAttack - knightAttackToRemove,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t\tif (applyHealthAuras) {\r\n\t\t\t\tentity.health = Math.max(eternalKnightHealth * multiplierKnight, entity.health - knightHealthToRemove);\r\n\t\t\t\tentity.maxHealth = Math.max(\r\n\t\t\t\t\teternalKnightHealth * multiplierKnight,\r\n\t\t\t\t\tentity.maxHealth - knightHealthToRemove,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.EnsorcelledFungus_BG28_555:\r\n\t\tcase CardIds.EnsorcelledFungus_BG28_555_G:\r\n\t\t\tconst multiplierFungus = entity.cardId === CardIds.EnsorcelledFungus_BG28_555_G ? 2 : 1;\r\n\t\t\tconst statsBonusFungus = multiplierFungus * boardHero.globalInfo.TavernSpellsCastThisGame;\r\n\t\t\tif (applyAttackAuras) {\r\n\t\t\t\tentity.attack = Math.max(0, entity.attack - statsBonusFungus);\r\n\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - statsBonusFungus);\r\n\t\t\t}\r\n\t\t\tif (applyHealthAuras) {\r\n\t\t\t\tentity.health = Math.max(1, entity.health - 2 * statsBonusFungus);\r\n\t\t\t\tentity.maxHealth = Math.max(1, entity.maxHealth - 2 * statsBonusFungus);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.AstralAutomaton_BG_TTN_401:\r\n\t\tcase CardIds.AstralAutomaton_BG_TTN_401_G:\r\n\t\t\tconst multiplierAstral = entity.cardId === CardIds.AstralAutomaton_BG_TTN_401_G ? 2 : 1;\r\n\t\t\t// We remove 1 because the AstralAutomatonsSummonedThisGame also includes the current one\r\n\t\t\t// and ancestral automaton only counts \"other\" automatons\r\n\t\t\t// When we remove the auras from a minion in hand, we shouldn't apply\r\n\t\t\t// the \"-1\", as it has not been summoned yet\r\n\t\t\tconst statsBonusAstral = Math.max(\r\n\t\t\t\t0,\r\n\t\t\t\tmultiplierAstral *\r\n\t\t\t\t\t(isOnBoard\r\n\t\t\t\t\t\t? (boardHero.globalInfo.AstralAutomatonsSummonedThisGame ?? 0) - 1\r\n\t\t\t\t\t\t: boardHero.globalInfo.AstralAutomatonsSummonedThisGame ?? 0),\r\n\t\t\t);\r\n\t\t\tif (applyAttackAuras) {\r\n\t\t\t\tentity.attack = Math.max(0, entity.attack - 3 * statsBonusAstral);\r\n\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - 3 * statsBonusAstral);\r\n\t\t\t}\r\n\t\t\tif (applyHealthAuras) {\r\n\t\t\t\tentity.health = Math.max(1, entity.health - 2 * statsBonusAstral);\r\n\t\t\t\tentity.maxHealth = Math.max(1, entity.maxHealth - 2 * statsBonusAstral);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.RotHideGnoll_BG25_013:\r\n\t\tcase CardIds.RotHideGnoll_BG25_013_G:\r\n\t\t\tconst multiplierGnoll = entity.cardId === CardIds.RotHideGnoll_BG25_013_G ? 2 : 1;\r\n\t\t\tconst statsBonusGnoll =\r\n\t\t\t\tmultiplierGnoll * gameState.sharedState.deaths.filter((e) => e.friendly === entity.friendly).length;\r\n\t\t\tif (applyAttackAuras) {\r\n\t\t\t\tentity.attack = Math.max(0, entity.attack - statsBonusGnoll);\r\n\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - statsBonusGnoll);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t}\r\n};\r\n\r\nconst handleMinionAddedAuraEffect = (\r\n\tspawnedCardId: string,\r\n\tspawned: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tisActuallySpawned = true,\r\n): void => {\r\n\tswitch (spawnedCardId) {\r\n\t\tcase CardIds.SouthseaCaptainLegacy_BG_NEW1_027:\r\n\t\tcase CardIds.SouthseaCaptainLegacy_TB_BaconUps_136:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, boardHero, Race.PIRATE, gameState.anomalies, gameState.allCards))\r\n\t\t\t\t// Other\r\n\t\t\t\t.filter((e) => e.entityId !== spawned.entityId)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += spawned.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1;\r\n\t\t\t\t\te.health += spawned.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1;\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.MurlocWarleaderLegacy_BG_EX1_507:\r\n\t\tcase CardIds.MurlocWarleaderLegacy_TB_BaconUps_008:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, boardHero, Race.MURLOC, gameState.anomalies, gameState.allCards))\r\n\t\t\t\t.filter((e) => e.entityId !== spawned.entityId)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += spawned.cardId === CardIds.MurlocWarleaderLegacy_TB_BaconUps_008 ? 4 : 2;\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\t// case CardIds.Kathranatir_BG21_039:\r\n\t\t// case CardIds.Kathranatir_BG21_039_G:\r\n\t\t// \tboard\r\n\t\t// \t\t.filter((e) => hasCorrectTribe(e, boardHero, Race.DEMON, gameState.anomalies, gameState.allCards))\r\n\t\t// \t\t.filter((e) => e.entityId !== spawned.entityId)\r\n\t\t// \t\t.forEach((e) => {\r\n\t\t// \t\t\te.attack += spawned.cardId === CardIds.Kathranatir_BG21_039_G ? 4 : 2;\r\n\t\t// \t\t});\r\n\t\t// \tbreak;\r\n\t\tcase CardIds.CyborgDrake_BG25_043:\r\n\t\tcase CardIds.CyborgDrake_BG25_043_G:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => e.divineShield)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += spawned.cardId === CardIds.CyborgDrake_BG25_043_G ? 12 : 6;\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\r\n\t\tcase CardIds.SoreLoser_BG27_030:\r\n\t\tcase CardIds.SoreLoser_BG27_030_G:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, boardHero, Race.UNDEAD, gameState.anomalies, gameState.allCards))\r\n\t\t\t\t.filter((e) => e.entityId !== spawned.entityId)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += (spawned.cardId === CardIds.SoreLoser_BG27_030_G ? 2 : 1) * boardHero.tavernTier;\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.AstralAutomaton_BG_TTN_401:\r\n\t\tcase CardIds.AstralAutomaton_BG_TTN_401_G:\r\n\t\t\t// TODO: move this somewhere else\r\n\t\t\tif (isActuallySpawned) {\r\n\t\t\t\tboardHero.globalInfo.AstralAutomatonsSummonedThisGame =\r\n\t\t\t\t\t(boardHero.globalInfo.AstralAutomatonsSummonedThisGame ?? 0) + 1;\r\n\t\t\t}\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => e.entityId !== spawned.entityId)\r\n\t\t\t\t.filter(\r\n\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\te.cardId === CardIds.AstralAutomaton_BG_TTN_401 ||\r\n\t\t\t\t\t\te.cardId === CardIds.AstralAutomaton_BG_TTN_401_G,\r\n\t\t\t\t)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\tconst multiplierAstral = e.cardId === CardIds.AstralAutomaton_BG_TTN_401_G ? 2 : 1;\r\n\t\t\t\t\tmodifyStats(e, e, 3 * multiplierAstral, 2 * multiplierAstral, board, boardHero, gameState, false);\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.DrBoomsMonster_BG31_176:\r\n\t\tcase CardIds.DrBoomsMonster_BG31_176_G:\r\n\t\t\tconst multiplierDrBoom = spawned.cardId === CardIds.DrBoomsMonster_BG31_176_G ? 2 : 1;\r\n\t\t\tmodifyStats(\r\n\t\t\t\tspawned,\r\n\t\t\t\tspawned,\r\n\t\t\t\t2 * boardHero.globalInfo.MagnetizedThisGame * multiplierDrBoom,\r\n\t\t\t\t2 * boardHero.globalInfo.MagnetizedThisGame * multiplierDrBoom,\r\n\t\t\t\tboard,\r\n\t\t\t\tboardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t}\r\n};\r\n\r\nexport const handleAfterSpawnEffects = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tallSpawned: readonly BoardEntity[],\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tfor (const spawned of allSpawned) {\r\n\t\thandleAfterSpawnEffect(board, hero, otherBoard, otherHero, spawned, gameState);\r\n\t}\r\n};\r\n\r\nexport const onMinionSummoned = (hero: BgsPlayerEntity, board: BoardEntity[], gameState: FullGameState): void => {\r\n\tconst quests = hero.questEntities ?? [];\r\n\tif (!quests.length) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tfor (const quest of quests) {\r\n\t\tswitch (quest.CardId) {\r\n\t\t\tcase CardIds.AssembleALineup:\r\n\t\t\t\tonQuestProgressUpdated(hero, quest, board, gameState);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleAfterSpawnEffect = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tspawned: BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// So that spawns don't mess up the loop\r\n\tconst initialBoard = [...board];\r\n\r\n\tfor (const trinket of hero.trinkets ?? []) {\r\n\t\tconst onAfterSpawnedImpl = cardMappings[trinket.cardId];\r\n\t\tif (hasAfterOtherSpawned(onAfterSpawnedImpl)) {\r\n\t\t\tonAfterSpawnedImpl.afterOtherSpawned(trinket, {\r\n\t\t\t\tspawned: spawned,\r\n\t\t\t\thero: hero,\r\n\t\t\t\tboard: board,\r\n\t\t\t\totherHero: otherHero,\r\n\t\t\t\totherBoard: otherBoard,\r\n\t\t\t\tgameState,\r\n\t\t\t\tapplySelfAuras: false,\r\n\t\t\t\tapplyAttackAuras: true,\r\n\t\t\t\tapplyHealthAuras: true,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const entity of initialBoard) {\r\n\t\tif (entity.entityId === spawned.entityId) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tconst onAfterSpawnedImpl = cardMappings[entity.cardId];\r\n\t\tif (hasAfterOtherSpawned(onAfterSpawnedImpl)) {\r\n\t\t\tonAfterSpawnedImpl.afterOtherSpawned(entity, {\r\n\t\t\t\tspawned: spawned,\r\n\t\t\t\thero: hero,\r\n\t\t\t\tboard: board,\r\n\t\t\t\totherHero: otherHero,\r\n\t\t\t\totherBoard: otherBoard,\r\n\t\t\t\tgameState,\r\n\t\t\t\tapplySelfAuras: false,\r\n\t\t\t\tapplyAttackAuras: true,\r\n\t\t\t\tapplyHealthAuras: true,\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tswitch (entity.cardId) {\r\n\t\t\tcase CardIds.XyloBones_BG26_172:\r\n\t\t\tcase CardIds.XyloBones_BG26_172_G:\r\n\t\t\t\tif (entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tconst xylobonesBuff = entity.cardId === CardIds.XyloBones_BG26_172_G ? 4 : 2;\r\n\t\t\t\t\tmodifyStats(entity, entity, 0, xylobonesBuff, board, hero, gameState);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(entity, entity, board, null, null);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.OctosariWrapGod_BG26_804:\r\n\t\t\tcase CardIds.OctosariWrapGod_BG26_804_G:\r\n\t\t\t\tif (entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tconst octoStats = entity.cardId === CardIds.OctosariWrapGod_BG26_804_G ? 4 : 2;\r\n\t\t\t\t\tentity.scriptDataNum1 = (entity.scriptDataNum1 ?? 0) + octoStats;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t// case CardIds.ObserverOfMyths_BG_TTN_078:\r\n\t\t\t// case CardIds.ObserverOfMyths_BG_TTN_078_G:\r\n\t\t\t// \tif (spawned.attack > entity.attack) {\r\n\t\t\t// \t\tconst observerBuff = entity.cardId === CardIds.ObserverOfMyths_BG_TTN_078_G ? 2 : 1;\r\n\t\t\t// \t\taddStatsToBoard(entity, board, hero, observerBuff, 0, gameState);\r\n\t\t\t// \t}\r\n\t\t\t// \tbreak;\r\n\t\t\tcase CardIds.ValithriaDreamwalker_TB_BaconShop_HERO_53_Buddy:\r\n\t\t\tcase CardIds.ValithriaDreamwalker_TB_BaconShop_HERO_53_Buddy_G:\r\n\t\t\t\tif (\r\n\t\t\t\t\thasCorrectTribe(spawned, hero, Race.DRAGON, gameState.anomalies, gameState.allCards) &&\r\n\t\t\t\t\tentity.entityId !== spawned.entityId\r\n\t\t\t\t) {\r\n\t\t\t\t\tconst valithriaBuff =\r\n\t\t\t\t\t\tentity.cardId === CardIds.ValithriaDreamwalker_TB_BaconShop_HERO_53_Buddy_G ? 3 : 2;\r\n\t\t\t\t\tmodifyStats(entity, entity, valithriaBuff, valithriaBuff, board, hero, gameState);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(entity, spawned, board, null, null);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t// Putricide-only\r\n\t\t\tcase CardIds.ArmsDealer_BG26_RLK_824:\r\n\t\t\t\tif (\r\n\t\t\t\t\thasCorrectTribe(spawned, hero, Race.UNDEAD, gameState.anomalies, gameState.allCards) &&\r\n\t\t\t\t\tentity.entityId !== spawned.entityId\r\n\t\t\t\t) {\r\n\t\t\t\t\tmodifyStats(spawned, spawned, 1, 0, board, hero, gameState, false);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(entity, entity, board, null, null);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport interface OnSpawnInput {\r\n\thero: BgsPlayerEntity;\r\n\tboard: BoardEntity[];\r\n\tgameState: FullGameState;\r\n\tapplyAttackAuras: boolean;\r\n\tapplyHealthAuras: boolean;\r\n}\r\nexport interface OnOtherSpawnInput {\r\n\tspawned: BoardEntity;\r\n\thero: BgsPlayerEntity;\r\n\tboard: BoardEntity[];\r\n\totherHero: BgsPlayerEntity;\r\n\totherBoard: BoardEntity[];\r\n\tgameState: FullGameState;\r\n\tapplyAttackAuras: boolean;\r\n\tapplyHealthAuras: boolean;\r\n\tapplySelfAuras: boolean;\r\n}\r\nexport interface OnOtherSpawnAuraInput {\r\n\tspawned: BoardEntity;\r\n\thero: BgsPlayerEntity;\r\n\tboard: BoardEntity[];\r\n\tgameState: FullGameState;\r\n\tapplyAttackAuras: boolean;\r\n\tapplyHealthAuras: boolean;\r\n}\r\nexport interface OnDespawnInput {\r\n\thero: BgsPlayerEntity;\r\n\tboard: BoardEntity[];\r\n\tgameState: FullGameState;\r\n\t// Slamma + Goldrinn interaction is:\r\n\t// - set the stats to (double_attack, health)\r\n\t// - re-apply only the \"attack\" portion of the aura\r\n\tapplyAttackAuras: boolean;\r\n\tapplyHealthAuras: boolean;\r\n}\r\n\r\n/** Trinket reaction when a minion is placed on the friendly board (`handleAddedMinionAuraEffect`, after hero power / quest hooks). */\r\nexport interface OnFriendlyMinionSummonedTrinketInput {\r\n\tspawned: BoardEntity;\r\n\tboard: BoardEntity[];\r\n\thero: BgsPlayerEntity;\r\n\totherBoard: BoardEntity[];\r\n\totherHero: BgsPlayerEntity;\r\n\tgameState: FullGameState;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"add-minion-to-board.js","sourceRoot":"","sources":["../../src/simulation/add-minion-to-board.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAG7D,4DASiC;AACjC,oDAA8C;AAC9C,iEAA4D;AAC5D,6EAAkG;AAClG,6DAA+D;AAC/D,6CAAgD;AAEhD,6CAA+C;AAC/C,oCAA6F;AAC7F,mCAA6F;AAE7F,mCAAiD;AACjD,mCAAsC;AAkB/B,MAAM,gBAAgB,GAAG,CAC/B,KAAoB,EACpB,SAA0B,EAC1B,UAAyB,EACzB,SAA0B,E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["import { GameTag, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport {\r\n\thasAfterOtherSpawned,\r\n\thasOnDespawned,\r\n\thasOnDespawnedEnchantment,\r\n\thasOnFriendlyMinionSummonedTrinket,\r\n\thasOnOtherSpawned,\r\n\thasOnOtherAuraSpawned as hasOnOtherSpawnedAura,\r\n\thasOnSpawned,\r\n\thasOnSpawnedEnchantment,\r\n} from '../cards/card.interface';\r\nimport { isWhelp } from '../cards/cards-data';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\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 { pickRandom } from '../services/utils';\r\nimport { alreadyHasVolumizerBuff, copyEntity, hasCorrectTribe, isVolumizer } from '../utils';\r\nimport { consumeDeityBaseStatsAssignment, getDeityAuraSnapshot, isDeityCard } from './deity';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { onQuestProgressUpdated } from './quest';\r\nimport { modifyStats } from './stats';\r\n\r\n// export const addMinionsToBoard = (\r\n// \tboard: BoardEntity[],\r\n// \tboardHero: BgsPlayerEntity,\r\n// \totherBoard: BoardEntity[],\r\n// \totherHero: BgsPlayerEntity,\r\n// \tindex: number,\r\n// \tminionsToAdd: readonly BoardEntity[],\r\n// \tgameState: FullGameState,\r\n// ): void => {\r\n// \t// board.splice(index, 0, ...minionsToAdd);\r\n// \tfor (const minionToAdd of [...minionsToAdd].reverse()) {\r\n// \t\taddMinionToBoard(board, boardHero, otherBoard, otherHero, index, minionToAdd, gameState, false);\r\n// \t}\r\n// \thandleAfterSpawnEffects(board, boardHero, otherBoard, otherHero, minionsToAdd, gameState);\r\n// };\r\n\r\nexport const addMinionToBoard = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tindex: number,\r\n\tminionToAdd: BoardEntity,\r\n\tgameState: FullGameState,\r\n\tapplySelfAuras = true,\r\n): void => {\r\n\tboard.splice(index, 0, minionToAdd);\r\n\t// Minion has already been removed from the board in the previous step\r\n\t// Update the global \"SummonedThisGame/Combat\" info here\r\n\thandleAddedMinionAuraEffect(board, boardHero, otherBoard, otherHero, minionToAdd, gameState, applySelfAuras);\r\n\t// Important to do this here, so that \"attack immediately\" minions can be taken into account by the quests\r\n\tonMinionSummoned(boardHero, board, gameState);\r\n\thandleSpawnEffect(board, boardHero, otherBoard, otherHero, minionToAdd, gameState, applySelfAuras);\r\n};\r\n\r\nconst handleSpawnEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tspawned: BoardEntity,\r\n\tgameState: FullGameState,\r\n\tapplySelfAuras = true,\r\n): void => {\r\n\tconst cardIds = [spawned.cardId, ...(spawned.additionalCards ?? [])];\r\n\r\n\t// https://twitter.com/LoewenMitchell/status/1491879869457879040\r\n\tif (cardIds.some((cardId) => isWhelp(cardId, gameState.allCards))) {\r\n\t\tconst manyWhelps = board.filter((entity) => entity.cardId === CardIds.ManyWhelps_BG22_HERO_305_Buddy);\r\n\t\tconst goldenManyWhelps = board.filter((entity) => entity.cardId === CardIds.ManyWhelps_BG22_HERO_305_Buddy_G);\r\n\t\tmanyWhelps.forEach((entity) => {\r\n\t\t\tmodifyStats(entity, entity, 2, 2, board, boardHero, gameState);\r\n\t\t});\r\n\t\tgoldenManyWhelps.forEach((entity) => {\r\n\t\t\tmodifyStats(entity, entity, 4, 4, board, boardHero, gameState);\r\n\t\t});\r\n\t}\r\n\r\n\tfor (const entity of board) {\r\n\t\t// The case for Reborns, and these shouldn't proc on themselves\r\n\t\tif (entity.entityId === spawned.entityId) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tconst onOtherSpawnedImpl = cardMappings[entity.cardId];\r\n\t\tif (hasOnOtherSpawned(onOtherSpawnedImpl)) {\r\n\t\t\tonOtherSpawnedImpl.onOtherSpawned(entity, {\r\n\t\t\t\tspawned: spawned,\r\n\t\t\t\thero: boardHero,\r\n\t\t\t\tboard: board,\r\n\t\t\t\totherBoard: otherBoard,\r\n\t\t\t\totherHero: otherHero,\r\n\t\t\t\tapplySelfAuras,\r\n\t\t\t\tapplyAttackAuras: true,\r\n\t\t\t\tapplyHealthAuras: true,\r\n\t\t\t\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tswitch (entity.cardId) {\r\n\t\t\tcase CardIds.CobaltGuardian:\r\n\t\t\t\tif (hasCorrectTribe(spawned, boardHero, Race.MECH, gameState.anomalies, gameState.allCards)) {\r\n\t\t\t\t\tif (!entity.divineShield) {\r\n\t\t\t\t\t\tupdateDivineShield(entity, board, boardHero, otherHero, true, gameState);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tmodifyStats(entity, entity, 2, 0, board, boardHero, gameState);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(entity, entity, board, boardHero, otherHero);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t// case CardIds.Bigfernal_BGS_204:\r\n\t\t\t// case CardIds.Bigfernal_TB_BaconUps_304:\r\n\t\t\t// \tif (hasCorrectTribe(spawned, boardHero, Race.DEMON, gameState.anomalies, gameState.allCards)) {\r\n\t\t\t// \t\tconst statsBonus = entity.cardId === CardIds.Bigfernal_TB_BaconUps_304 ? 2 : 1;\r\n\t\t\t// \t\tmodifyStats(entity, entity, statsBonus, statsBonus, board, boardHero, gameState);\r\n\t\t\t// \t\tgameState.spectator.registerPowerTarget(entity, entity, board, boardHero, otherHero);\r\n\t\t\t// \t}\r\n\t\t\t// \tbreak;\r\n\t\t\tcase CardIds.MamaBear_BGS_021:\r\n\t\t\tcase CardIds.MamaBear_TB_BaconUps_090:\r\n\t\t\t\tif (hasCorrectTribe(spawned, boardHero, Race.BEAST, gameState.anomalies, gameState.allCards)) {\r\n\t\t\t\t\tconst statsBonus = entity.cardId === CardIds.MamaBear_TB_BaconUps_090 ? 12 : 6;\r\n\t\t\t\t\tmodifyStats(spawned, entity, statsBonus, statsBonus, board, boardHero, gameState);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(entity, entity, board, boardHero, otherHero);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t// case CardIds.PapaBear_BG27_509:\r\n\t\t\t// case CardIds.PapaBear_BG27_509_G:\r\n\t\t\t// \tif (hasCorrectTribe(spawned, boardHero, Race.BEAST, gameState.anomalies, gameState.allCards)) {\r\n\t\t\t// \t\tconst statsBonus = entity.cardId === CardIds.PapaBear_BG27_509_G ? 16 : 8;\r\n\t\t\t// \t\tmodifyStats(spawned, entity, statsBonus, statsBonus, board, boardHero, gameState);\r\n\t\t\t// \t\tgameState.spectator.registerPowerTarget(entity, entity, board, boardHero, otherHero);\r\n\t\t\t// \t}\r\n\t\t\t// \tbreak;\r\n\t\t\tcase CardIds.PackLeader_BGS_017:\r\n\t\t\tcase CardIds.PackLeader_TB_BaconUps_086:\r\n\t\t\t\tif (hasCorrectTribe(spawned, boardHero, Race.BEAST, gameState.anomalies, gameState.allCards)) {\r\n\t\t\t\t\tconst statsBonus = entity.cardId === CardIds.PackLeader_TB_BaconUps_086 ? 4 : 2;\r\n\t\t\t\t\tmodifyStats(spawned, entity, statsBonus, 0, board, boardHero, gameState);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(entity, entity, board, boardHero, otherHero);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const trinket of boardHero.trinkets ?? []) {\r\n\t\tconst onOtherSpawnedImpl = cardMappings[trinket.cardId];\r\n\t\tif (hasOnOtherSpawned(onOtherSpawnedImpl)) {\r\n\t\t\tonOtherSpawnedImpl.onOtherSpawned(trinket, {\r\n\t\t\t\tspawned: spawned,\r\n\t\t\t\thero: boardHero,\r\n\t\t\t\tboard: board,\r\n\t\t\t\totherBoard: otherBoard,\r\n\t\t\t\totherHero: otherHero,\r\n\t\t\t\tapplySelfAuras,\r\n\t\t\t\tapplyAttackAuras: true,\r\n\t\t\t\tapplyHealthAuras: true,\r\n\t\t\t\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n};\r\nexport const handleAddedMinionAuraEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tspawned: BoardEntity,\r\n\tgameState: FullGameState,\r\n\tapplySelfAuras = true,\r\n\tisActuallySpawned = true,\r\n): void => {\r\n\tfor (const heroPower of boardHero.heroPowers) {\r\n\t\tswitch (heroPower.cardId) {\r\n\t\t\tcase CardIds.SproutItOut:\r\n\t\t\t\tif (isActuallySpawned) {\r\n\t\t\t\t\tupdateTaunt(spawned, true, board, boardHero, otherHero, gameState);\r\n\t\t\t\t\tmodifyStats(spawned, boardHero, 1, 2, board, boardHero, gameState);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tif (boardHero.questRewards?.includes(CardIds.TumblingDisaster_BG28_Reward_505)) {\r\n\t\tconst tumblingDisasterBonus =\r\n\t\t\tboardHero.questRewardEntities?.find((e) => e.cardId === CardIds.TumblingDisaster_BG28_Reward_505)\r\n\t\t\t\t?.scriptDataNum1 || 1;\r\n\t\tmodifyStats(spawned, boardHero, tumblingDisasterBonus, tumblingDisasterBonus, board, boardHero, gameState);\r\n\t}\r\n\r\n\tif (isActuallySpawned) {\r\n\t\tfor (const trinket of boardHero.trinkets ?? []) {\r\n\t\t\tconst summonedImpl = cardMappings[trinket.cardId];\r\n\t\t\tif (hasOnFriendlyMinionSummonedTrinket(summonedImpl)) {\r\n\t\t\t\tsummonedImpl.onFriendlyMinionSummoned(trinket, {\r\n\t\t\t\t\tspawned,\r\n\t\t\t\t\tboard,\r\n\t\t\t\t\thero: boardHero,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t});\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tswitch (trinket.cardId) {\r\n\t\t\t\tcase CardIds.BlingtronsSunglasses_BG30_MagicItem_978:\r\n\t\t\t\t\tif (hasCorrectTribe(spawned, boardHero, Race.MECH, gameState.anomalies, gameState.allCards)) {\r\n\t\t\t\t\t\tconst target = pickRandom(board.filter((e) => !e.divineShield));\r\n\t\t\t\t\t\tif (!!target) {\r\n\t\t\t\t\t\t\tupdateDivineShield(target, board, boardHero, otherHero, true, gameState);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.TwinSkyLanterns_BG30_MagicItem_822:\r\n\t\t\t\tcase CardIds.TwinSkyLanterns_TwinSkyLanternsToken_BG30_MagicItem_822t2:\r\n\t\t\t\t\tif (!trinket.rememberedMinions?.length) {\r\n\t\t\t\t\t\ttrinket.rememberedMinions = [copyEntity(spawned)];\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Apply auras to board\r\n\tconst cardIds = [spawned.cardId, ...(spawned.additionalCards ?? [])];\r\n\tfor (const spawnedCardId of cardIds) {\r\n\t\thandleMinionAddedAuraEffect(spawnedCardId, spawned, board, boardHero, gameState, isActuallySpawned);\r\n\t}\r\n\r\n\t// When we want to summon an \"exact copy\", we need to make sure we don't apply the aura twice\r\n\t// First apply self auras. This way, something like Astral Automaton won't first buff the counter,\r\n\t// then apply the aura with a buffed counter\r\n\t// THAT SEEMS WRONG! If the counter is N, then we summon the Automaton and apply N-1, already discounting\r\n\t// it\r\n\tif (applySelfAuras) {\r\n\t\t// The board here already contains the new minion\r\n\t\t// TODO: what if the additional part is a potential target for the aura effect?\r\n\t\t// 2024-08-27: changing the order to first handleMinionAddedAuraEffect so that the automatons get boosted,\r\n\t\t// then apply the aura\r\n\t\tapplyAurasToSelf(spawned, board, boardHero, gameState);\r\n\t}\r\n\r\n\tif (isActuallySpawned) {\r\n\t\tif (hasCorrectTribe(spawned, boardHero, Race.BEAST, gameState.anomalies, gameState.allCards)) {\r\n\t\t\tboardHero.globalInfo.BeastsSummonedThisCombat++;\r\n\t\t\tboardHero.globalInfo.BeastsSummonedThisGame++;\r\n\t\t}\r\n\t\tif (hasCorrectTribe(spawned, boardHero, Race.PIRATE, gameState.anomalies, gameState.allCards)) {\r\n\t\t\tboardHero.globalInfo.PiratesSummonedThisGame++;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyAurasToSelf = (\r\n\tspawned: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tapplyAttackAuras = true,\r\n\tapplyHealthAuras = true,\r\n): void => {\r\n\tif (applyAttackAuras) {\r\n\t\tspawned.attack += boardHero.globalInfo.AdditionalAttack;\r\n\t}\r\n\r\n\tif (!!boardHero.questRewards?.length) {\r\n\t\tfor (const quest of boardHero.questRewards) {\r\n\t\t\tswitch (quest) {\r\n\t\t\t\tcase CardIds.VolatileVenom:\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tspawned.attack += 7;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (applyHealthAuras) {\r\n\t\t\t\t\t\tspawned.health += 7;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tspawned.enchantments.push({\r\n\t\t\t\t\t\tcardId: CardIds.VolatileVenom_VolatileEnchantment,\r\n\t\t\t\t\t\toriginEntityId: undefined,\r\n\t\t\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t\t\t});\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.TheSmokingGun:\r\n\t\t\t\t\tspawned.attack += 4;\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (!!boardHero.trinkets?.length) {\r\n\t\tfor (const trinket of boardHero.trinkets) {\r\n\t\t\tswitch (trinket.cardId) {\r\n\t\t\t\tcase CardIds.FeralTalisman_BG30_MagicItem_880:\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tspawned.attack += 2;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (applyHealthAuras) {\r\n\t\t\t\t\t\tspawned.health += 1;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.FeralTalisman_FeralTalismanToken_BG30_MagicItem_880t:\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tspawned.attack += 8;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (applyHealthAuras) {\r\n\t\t\t\t\t\tspawned.health += 5;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.DazzlingDagger_BG32_MagicItem_934:\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tspawned.attack += trinket.scriptDataNum1 || 1;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.HordeKeychainToken_BG30_MagicItem_843t:\r\n\t\t\t\t\tif (gameState.cardsData.getTavernLevel(spawned.cardId) <= 3) {\r\n\t\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\t\tspawned.attack += 7;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif (applyHealthAuras) {\r\n\t\t\t\t\t\t\tspawned.health += 5;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.FlagbearerPortrait_BG30_MagicItem_921:\r\n\t\t\t\t\tif (\r\n\t\t\t\t\t\tspawned.cardId === CardIds.Scallywag_SkyPirateToken_BGS_061t ||\r\n\t\t\t\t\t\tspawned.cardId === CardIds.Scallywag_SkyPirateToken_TB_BaconUps_141t\r\n\t\t\t\t\t) {\r\n\t\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\t\tspawned.attack += 6;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (boardHero.globalInfo.HauntedCarapaceAttackBonus > 0) {\r\n\t\tif (applyAttackAuras) {\r\n\t\t\tmodifyStats(\r\n\t\t\t\tspawned,\r\n\t\t\t\tspawned,\r\n\t\t\t\tboardHero.globalInfo.HauntedCarapaceAttackBonus,\r\n\t\t\t\t0,\r\n\t\t\t\tboard,\r\n\t\t\t\tboardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\tif (boardHero.globalInfo.HauntedCarapaceHealthBonus > 0) {\r\n\t\tif (applyHealthAuras) {\r\n\t\t\tmodifyStats(\r\n\t\t\t\tspawned,\r\n\t\t\t\tspawned,\r\n\t\t\t\t0,\r\n\t\t\t\tboardHero.globalInfo.HauntedCarapaceHealthBonus,\r\n\t\t\t\tboard,\r\n\t\t\t\tboardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\tif (hasCorrectTribe(spawned, boardHero, Race.UNDEAD, gameState.anomalies, gameState.allCards)) {\r\n\t\tif (boardHero.globalInfo.UndeadAttackBonus > 0) {\r\n\t\t\tif (applyAttackAuras) {\r\n\t\t\t\tmodifyStats(\r\n\t\t\t\t\tspawned,\r\n\t\t\t\t\tspawned,\r\n\t\t\t\t\tboardHero.globalInfo.UndeadAttackBonus,\r\n\t\t\t\t\t0,\r\n\t\t\t\t\tboard,\r\n\t\t\t\t\tboardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (boardHero.globalInfo.UndeadHealthBonus > 0) {\r\n\t\t\tif (applyHealthAuras) {\r\n\t\t\t\tmodifyStats(\r\n\t\t\t\t\tspawned,\r\n\t\t\t\t\tspawned,\r\n\t\t\t\t\t0,\r\n\t\t\t\t\tboardHero.globalInfo.UndeadHealthBonus,\r\n\t\t\t\t\tboard,\r\n\t\t\t\t\tboardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (hasCorrectTribe(spawned, boardHero, Race.PIRATE, gameState.anomalies, gameState.allCards)) {\r\n\t\tif (boardHero.globalInfo.PirateAttackBonus > 0) {\r\n\t\t\tif (applyAttackAuras) {\r\n\t\t\t\tmodifyStats(\r\n\t\t\t\t\tspawned,\r\n\t\t\t\t\tspawned,\r\n\t\t\t\t\tboardHero.globalInfo.PirateAttackBonus,\r\n\t\t\t\t\t0,\r\n\t\t\t\t\tboard,\r\n\t\t\t\t\tboardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (hasCorrectTribe(spawned, boardHero, Race.MECH, gameState.anomalies, gameState.allCards)) {\r\n\t\tif (boardHero.globalInfo.MechAttackBonus > 0) {\r\n\t\t\tif (applyAttackAuras) {\r\n\t\t\t\tmodifyStats(\r\n\t\t\t\t\tspawned,\r\n\t\t\t\t\tspawned,\r\n\t\t\t\t\tboardHero.globalInfo.MechAttackBonus,\r\n\t\t\t\t\t0,\r\n\t\t\t\t\tboard,\r\n\t\t\t\t\tboardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (hasCorrectTribe(spawned, boardHero, Race.BEAST, gameState.anomalies, gameState.allCards)) {\r\n\t\tif (boardHero.globalInfo.GoldrinnBuffAtk > 0) {\r\n\t\t\tconst attackBuff = applyAttackAuras ? boardHero.globalInfo.GoldrinnBuffAtk : 0;\r\n\t\t\tconst healthBuff = applyHealthAuras ? boardHero.globalInfo.GoldrinnBuffHealth : 0;\r\n\t\t\tmodifyStats(spawned, spawned, attackBuff, healthBuff, board, boardHero, gameState, false);\r\n\t\t\tgameState.spectator.registerPowerTarget(boardHero, spawned, board, null, null);\r\n\t\t}\r\n\t}\r\n\tif (isWhelp(spawned.cardId, gameState.allCards)) {\r\n\t\tconst attackBuff = applyAttackAuras ? boardHero.globalInfo.WhelpAttackBuff ?? 0 : 0;\r\n\t\tconst healthBuff = applyHealthAuras ? boardHero.globalInfo.WhelpHealthBuff ?? 0 : 0;\r\n\t\tmodifyStats(spawned, spawned, attackBuff, healthBuff, board, boardHero, gameState, false);\r\n\t\tgameState.spectator.registerPowerTarget(boardHero, spawned, board, null, null);\r\n\t}\r\n\tif (\r\n\t\tisVolumizer(spawned.cardId, boardHero, gameState.anomalies, gameState.allCards) &&\r\n\t\t// https://replays.firestoneapp.com/?reviewId=75e82ef1-3442-4307-a3c8-4a3b72fcf6af&turn=11&action=2\r\n\t\t!alreadyHasVolumizerBuff(spawned, boardHero, gameState)\r\n\t) {\r\n\t\tif (boardHero.globalInfo.VolumizerAttackBuff > 0 || boardHero.globalInfo.VolumizerHealthBuff > 0) {\r\n\t\t\tconst attackBuff = applyAttackAuras ? boardHero.globalInfo.VolumizerAttackBuff ?? 0 : 0;\r\n\t\t\tconst healthBuff = applyHealthAuras ? boardHero.globalInfo.VolumizerHealthBuff ?? 0 : 0;\r\n\t\t\tmodifyStats(spawned, spawned, attackBuff, healthBuff, board, boardHero, gameState, false);\r\n\t\t\tgameState.spectator.registerPowerTarget(boardHero, spawned, board, null, null);\r\n\t\t}\r\n\t}\r\n\r\n\t// In case Putricide spawns a stictched minion whose stitched part creates an aura effect\r\n\t// const potentialAuraSources: { cardId: string; entityId: number }[] = [\r\n\t// \t{ cardId: spawned.cardId, entityId: spawned.entityId },\r\n\t// \t...(spawned.additionalCards ?? []).map((cardId) => ({ cardId, entityId: spawned.entityId })),\r\n\t// ];\r\n\r\n\tif (gameState.cardsData.getTavernLevel(spawned.cardId) % 2 === 1) {\r\n\t\tconst atkBuff = applyAttackAuras ? boardHero.globalInfo.MutatedLasherAttackBuff ?? 0 : 0;\r\n\t\tconst healthBuff = applyHealthAuras ? boardHero.globalInfo.MutatedLasherHealthBuff ?? 0 : 0;\r\n\t\tmodifyStats(spawned, spawned, atkBuff, healthBuff, board, boardHero, gameState, false);\r\n\t}\r\n\tfor (const entity of board) {\r\n\t\tconst onOtherSpawnedImpl = cardMappings[entity.cardId];\r\n\t\tif (hasOnOtherSpawnedAura(onOtherSpawnedImpl)) {\r\n\t\t\tonOtherSpawnedImpl.onOtherSpawnedAura(entity, {\r\n\t\t\t\tspawned: spawned,\r\n\t\t\t\thero: boardHero,\r\n\t\t\t\tboard: board,\r\n\t\t\t\tgameState,\r\n\t\t\t\tapplyAttackAuras,\r\n\t\t\t\tapplyHealthAuras,\r\n\t\t\t});\r\n\t\t}\r\n\t\tswitch (entity.cardId) {\r\n\t\t\tcase CardIds.MurlocWarleaderLegacy_BG_EX1_507:\r\n\t\t\tcase CardIds.MurlocWarleaderLegacy_TB_BaconUps_008:\r\n\t\t\t\tif (\r\n\t\t\t\t\thasCorrectTribe(spawned, boardHero, Race.MURLOC, gameState.anomalies, gameState.allCards) &&\r\n\t\t\t\t\tentity.entityId !== spawned.entityId\r\n\t\t\t\t) {\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tspawned.attack += entity.cardId === CardIds.MurlocWarleaderLegacy_TB_BaconUps_008 ? 4 : 2;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SouthseaCaptainLegacy_BG_NEW1_027:\r\n\t\t\tcase CardIds.SouthseaCaptainLegacy_TB_BaconUps_136:\r\n\t\t\t\tif (\r\n\t\t\t\t\thasCorrectTribe(spawned, boardHero, Race.PIRATE, gameState.anomalies, gameState.allCards) &&\r\n\t\t\t\t\tentity.entityId !== spawned.entityId\r\n\t\t\t\t) {\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tspawned.attack += entity.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (applyHealthAuras) {\r\n\t\t\t\t\t\tspawned.health += entity.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t// case CardIds.Kathranatir_BG21_039:\r\n\t\t\t// case CardIds.Kathranatir_BG21_039_G:\r\n\t\t\t// \tif (\r\n\t\t\t// \t\thasCorrectTribe(spawned, boardHero, Race.DEMON, gameState.anomalies, gameState.allCards) &&\r\n\t\t\t// \t\tentity.entityId !== spawned.entityId\r\n\t\t\t// \t) {\r\n\t\t\t// \t\tspawned.attack += entity.cardId === CardIds.Kathranatir_BG21_039_G ? 2 : 1;\r\n\t\t\t// \t}\r\n\t\t\t// \tbreak;\r\n\t\t\tcase CardIds.CyborgDrake_BG25_043:\r\n\t\t\tcase CardIds.CyborgDrake_BG25_043_G:\r\n\t\t\t\tif (spawned.divineShield) {\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tspawned.attack += entity.cardId === CardIds.CyborgDrake_BG25_043_G ? 12 : 6;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SoreLoser_BG27_030:\r\n\t\t\tcase CardIds.SoreLoser_BG27_030_G:\r\n\t\t\t\tif (\r\n\t\t\t\t\thasCorrectTribe(spawned, boardHero, Race.UNDEAD, gameState.anomalies, gameState.allCards) &&\r\n\t\t\t\t\tentity.entityId !== spawned.entityId\r\n\t\t\t\t) {\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tspawned.attack +=\r\n\t\t\t\t\t\t\t(entity.cardId === CardIds.SoreLoser_BG27_030_G ? 2 : 1) * boardHero.tavernTier;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tconst onSpawnedImpl = cardMappings[spawned.cardId];\r\n\tif (hasOnSpawned(onSpawnedImpl)) {\r\n\t\tonSpawnedImpl.onSpawned(spawned, {\r\n\t\t\thero: boardHero,\r\n\t\t\tboard: board,\r\n\t\t\tgameState: gameState,\r\n\t\t\tapplyAttackAuras,\r\n\t\t\tapplyHealthAuras,\r\n\t\t});\r\n\t}\r\n\tfor (const enchantment of spawned.enchantments) {\r\n\t\tconst onSpawnedEnchantmentImpl = cardMappings[enchantment.cardId];\r\n\t\tif (hasOnSpawnedEnchantment(onSpawnedEnchantmentImpl)) {\r\n\t\t\tonSpawnedEnchantmentImpl.onSpawnedEnchantment(spawned, enchantment, {\r\n\t\t\t\thero: boardHero,\r\n\t\t\t\tboard: board,\r\n\t\t\t\tgameState: gameState,\r\n\t\t\t\tapplyAttackAuras,\r\n\t\t\t\tapplyHealthAuras,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\tswitch (spawned.cardId) {\r\n\t\tcase CardIds.EternalKnight_BG25_008:\r\n\t\tcase CardIds.EternalKnight_BG25_008_G:\r\n\t\t\tconst multiplierKnight = spawned.cardId === CardIds.EternalKnight_BG25_008_G ? 2 : 1;\r\n\t\t\tconst statsBonusKnight = multiplierKnight * boardHero.globalInfo.EternalKnightsDeadThisGame;\r\n\t\t\tmodifyStats(\r\n\t\t\t\tspawned,\r\n\t\t\t\tnull,\r\n\t\t\t\tapplyAttackAuras\r\n\t\t\t\t\t? eternalKnightAttack * statsBonusKnight + boardHero.globalInfo.EternalKnightAttackBuff\r\n\t\t\t\t\t: 0,\r\n\t\t\t\tapplyHealthAuras\r\n\t\t\t\t\t? eternalKnightHealth * statsBonusKnight + boardHero.globalInfo.EternalKnightHealthBuff\r\n\t\t\t\t\t: 0,\r\n\t\t\t\tboard,\r\n\t\t\t\tboardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.EnsorcelledFungus_BG28_555:\r\n\t\tcase CardIds.EnsorcelledFungus_BG28_555_G:\r\n\t\t\tconst multiplierFungus = spawned.cardId === CardIds.EnsorcelledFungus_BG28_555_G ? 2 : 1;\r\n\t\t\tconst statsBonusFungus = multiplierFungus * boardHero.globalInfo.TavernSpellsCastThisGame;\r\n\t\t\tmodifyStats(\r\n\t\t\t\tspawned,\r\n\t\t\t\tnull,\r\n\t\t\t\tapplyAttackAuras ? statsBonusFungus : 0,\r\n\t\t\t\tapplyHealthAuras ? 2 * statsBonusFungus : 0,\r\n\t\t\t\tboard,\r\n\t\t\t\tboardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.SaltyLooter_BGS_081:\r\n\t\tcase CardIds.SaltyLooter_TB_BaconUps_143:\r\n\t\t\tconst multiplierLooter = spawned.cardId === CardIds.SaltyLooter_TB_BaconUps_143 ? 2 : 1;\r\n\t\t\tconst statsBonusLooter = multiplierLooter * boardHero.globalInfo.PiratesSummonedThisGame;\r\n\t\t\tmodifyStats(\r\n\t\t\t\tspawned,\r\n\t\t\t\tnull,\r\n\t\t\t\tapplyAttackAuras ? 2 * statsBonusLooter : 0,\r\n\t\t\t\tapplyHealthAuras ? 2 * multiplierLooter : 0,\r\n\t\t\t\tboard,\r\n\t\t\t\tboardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.AstralAutomaton_BG_TTN_401:\r\n\t\tcase CardIds.AstralAutomaton_BG_TTN_401_G:\r\n\t\t\tconst multiplierAstral = spawned.cardId === CardIds.AstralAutomaton_BG_TTN_401_G ? 2 : 1;\r\n\t\t\t// Don't count the yourself\r\n\t\t\tconst statsBonusAstral =\r\n\t\t\t\tmultiplierAstral * ((boardHero.globalInfo.AstralAutomatonsSummonedThisGame ?? 0) - 1);\r\n\t\t\tmodifyStats(\r\n\t\t\t\tspawned,\r\n\t\t\t\tnull,\r\n\t\t\t\tapplyAttackAuras ? 3 * statsBonusAstral : 0,\r\n\t\t\t\tapplyHealthAuras ? 2 * statsBonusAstral : 0,\r\n\t\t\t\tboard,\r\n\t\t\t\tboardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.RotHideGnoll_BG25_013:\r\n\t\tcase CardIds.RotHideGnoll_BG25_013_G:\r\n\t\t\tconst multiplierGnoll = spawned.cardId === CardIds.RotHideGnoll_BG25_013_G ? 2 : 1;\r\n\t\t\tconst statsBonusGnoll =\r\n\t\t\t\tmultiplierGnoll * gameState.sharedState.deaths.filter((e) => e.friendly === spawned.friendly).length;\r\n\t\t\tmodifyStats(\r\n\t\t\t\tspawned,\r\n\t\t\t\tnull,\r\n\t\t\t\tapplyAttackAuras ? statsBonusGnoll : 0,\r\n\t\t\t\tapplyHealthAuras ? 0 : 0,\r\n\t\t\t\tboard,\r\n\t\t\t\tboardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t}\r\n\r\n\t// Live: removing auras from a copied deity does not subtract these stats, and summon reapplies\r\n\t// the aura from when that minion was summoned, not the secret after later deity buffs.\r\n\t// The stored total includes the printed stats, so the aura itself is total - base.\r\n\t// Awaken and reborn already wrote these stats via applyDeityBaseStats, so skip that pass.\r\n\tif (isDeityCard(spawned.cardId, gameState.allCards) && !consumeDeityBaseStatsAssignment(spawned)) {\r\n\t\tconst { attack, health } = getDeityAuraSnapshot(spawned, boardHero);\r\n\t\tconst card = gameState.allCards.getCard(spawned.cardId);\r\n\t\tconst auraAttack = Math.max(0, attack - (card?.attack ?? 0));\r\n\t\tconst auraHealth = Math.max(0, health - (card?.health ?? 0));\r\n\t\tspawned.tags = spawned.tags ?? {};\r\n\t\tspawned.tags[GameTag.BACON_OLD_GOD_ATTACK] = attack;\r\n\t\tspawned.tags[GameTag.BACON_OLD_GOD_HEALTH] = health;\r\n\t\tmodifyStats(\r\n\t\t\tspawned,\r\n\t\t\tnull,\r\n\t\t\tapplyAttackAuras ? auraAttack : 0,\r\n\t\t\tapplyHealthAuras ? auraHealth : 0,\r\n\t\t\tboard,\r\n\t\t\tboardHero,\r\n\t\t\tgameState,\r\n\t\t\tfalse,\r\n\t\t);\r\n\t}\r\n};\r\n\r\n// Introduced for Rapid Reanimation: since we will \"addMinionToBoard\" the minion afterwards, the auras will\r\n// be re-applied then, so we need to remove them first\r\nexport const removeAurasFromSelf = (\r\n\tentity: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tapplyAttackAuras = true,\r\n\tapplyHealthAuras = true,\r\n\tisOnBoard = true,\r\n): void => {\r\n\tif (applyAttackAuras) {\r\n\t\tentity.attack -= Math.max(0, boardHero.globalInfo.AdditionalAttack);\r\n\t\tentity.maxAttack -= Math.max(0, boardHero.globalInfo.AdditionalAttack);\r\n\t}\r\n\r\n\tconst onDespawnedImpl = cardMappings[entity.cardId];\r\n\tif (hasOnDespawned(onDespawnedImpl)) {\r\n\t\tonDespawnedImpl.onDespawned(entity, {\r\n\t\t\thero: boardHero,\r\n\t\t\tboard: board,\r\n\t\t\tgameState,\r\n\t\t\tapplyAttackAuras,\r\n\t\t\tapplyHealthAuras,\r\n\t\t});\r\n\t}\r\n\tfor (const enchantment of entity.enchantments) {\r\n\t\tconst onDespawnedEnchantmentImpl = cardMappings[enchantment.cardId];\r\n\t\tif (hasOnDespawnedEnchantment(onDespawnedEnchantmentImpl)) {\r\n\t\t\tonDespawnedEnchantmentImpl.onDespawnedEnchantment(entity, enchantment, {\r\n\t\t\t\thero: boardHero,\r\n\t\t\t\tboard: board,\r\n\t\t\t\tgameState: gameState,\r\n\t\t\t\tapplyAttackAuras,\r\n\t\t\t\tapplyHealthAuras,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\tfor (const enchantment of entity.enchantments) {\r\n\t\tswitch (enchantment?.cardId) {\r\n\t\t\tcase CardIds.TavernLighting_TavernLightsEnchantment:\r\n\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\tentity.attack = Math.max(0, entity.attack - enchantment.tagScriptDataNum1);\r\n\t\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - enchantment.tagScriptDataNum1);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tif (!!boardHero.questRewards?.length) {\r\n\t\tfor (const quest of boardHero.questRewards) {\r\n\t\t\tswitch (quest) {\r\n\t\t\t\tcase CardIds.VolatileVenom:\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tentity.attack = Math.max(0, entity.attack - 7);\r\n\t\t\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - 7);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (applyHealthAuras) {\r\n\t\t\t\t\t\tentity.health = Math.max(1, entity.health - 7);\r\n\t\t\t\t\t\tentity.maxHealth = Math.max(1, entity.health - 7);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tentity.enchantments = entity.enchantments.filter(\r\n\t\t\t\t\t\t(e) => e.cardId !== CardIds.VolatileVenom_VolatileEnchantment,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.TheSmokingGun:\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tentity.attack = Math.max(0, entity.attack - 7);\r\n\t\t\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - 7);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.FlagbearerPortrait_BG30_MagicItem_921:\r\n\t\t\t\t\tif (\r\n\t\t\t\t\t\tentity.cardId === CardIds.SkyPirateFlagbearer_BG30_119 ||\r\n\t\t\t\t\t\tentity.cardId === CardIds.SkyPirateFlagbearer_BG30_119_G\r\n\t\t\t\t\t) {\r\n\t\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\t\tentity.attack = Math.max(0, entity.attack - 8);\r\n\t\t\t\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - 8);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (!!boardHero.trinkets?.length) {\r\n\t\tfor (const trinket of boardHero.trinkets) {\r\n\t\t\tswitch (trinket.cardId) {\r\n\t\t\t\tcase CardIds.FeralTalisman_BG30_MagicItem_880:\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tentity.attack = Math.max(0, entity.attack - 2);\r\n\t\t\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - 2);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (applyHealthAuras) {\r\n\t\t\t\t\t\tentity.health = Math.max(1, entity.health - 1);\r\n\t\t\t\t\t\tentity.maxHealth = Math.max(1, entity.maxHealth - 1);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.FeralTalisman_FeralTalismanToken_BG30_MagicItem_880t:\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tentity.attack = Math.max(0, entity.attack - 8);\r\n\t\t\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - 8);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (applyHealthAuras) {\r\n\t\t\t\t\t\tentity.health = Math.max(1, entity.health - 5);\r\n\t\t\t\t\t\tentity.maxHealth = Math.max(1, entity.maxHealth - 5);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.DazzlingDagger_BG32_MagicItem_934:\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tentity.attack = Math.max(0, entity.attack - (trinket.scriptDataNum1 || 1));\r\n\t\t\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - (trinket.scriptDataNum1 || 1));\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.HordeKeychainToken_BG30_MagicItem_843t:\r\n\t\t\t\t\tif (gameState.cardsData.getTavernLevel(entity.cardId) <= 3) {\r\n\t\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\t\tentity.attack = Math.max(0, entity.attack - 7);\r\n\t\t\t\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - 7);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif (applyHealthAuras) {\r\n\t\t\t\t\t\t\tentity.health = Math.max(1, entity.health - 5);\r\n\t\t\t\t\t\t\tentity.maxHealth = Math.max(1, entity.maxHealth - 5);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (boardHero.globalInfo.HauntedCarapaceAttackBonus > 0) {\r\n\t\tif (applyAttackAuras) {\r\n\t\t\tentity.attack = Math.max(0, entity.attack - boardHero.globalInfo.HauntedCarapaceAttackBonus);\r\n\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - boardHero.globalInfo.HauntedCarapaceAttackBonus);\r\n\t\t}\r\n\t}\r\n\tif (boardHero.globalInfo.HauntedCarapaceHealthBonus > 0) {\r\n\t\tif (applyHealthAuras) {\r\n\t\t\tentity.health = Math.max(1, entity.health - boardHero.globalInfo.HauntedCarapaceHealthBonus);\r\n\t\t\tentity.maxHealth = Math.max(1, entity.maxHealth - boardHero.globalInfo.HauntedCarapaceHealthBonus);\r\n\t\t}\r\n\t}\r\n\tif (hasCorrectTribe(entity, boardHero, Race.UNDEAD, gameState.anomalies, gameState.allCards)) {\r\n\t\tif (boardHero.globalInfo.UndeadAttackBonus > 0) {\r\n\t\t\tif (applyAttackAuras) {\r\n\t\t\t\tentity.attack = Math.max(0, entity.attack - boardHero.globalInfo.UndeadAttackBonus);\r\n\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - boardHero.globalInfo.UndeadAttackBonus);\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (boardHero.globalInfo.UndeadHealthBonus > 0) {\r\n\t\t\tif (applyHealthAuras) {\r\n\t\t\t\tentity.health = Math.max(1, entity.health - boardHero.globalInfo.UndeadHealthBonus);\r\n\t\t\t\tentity.maxHealth = Math.max(1, entity.maxHealth - boardHero.globalInfo.UndeadHealthBonus);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (hasCorrectTribe(entity, boardHero, Race.BEAST, gameState.anomalies, gameState.allCards)) {\r\n\t\tif (boardHero.globalInfo.GoldrinnBuffAtk > 0) {\r\n\t\t\tif (applyAttackAuras) {\r\n\t\t\t\tentity.attack = Math.max(0, entity.attack - boardHero.globalInfo.GoldrinnBuffAtk);\r\n\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - boardHero.globalInfo.GoldrinnBuffAtk);\r\n\t\t\t}\r\n\t\t\tif (applyHealthAuras) {\r\n\t\t\t\tentity.health = Math.max(1, entity.health - boardHero.globalInfo.GoldrinnBuffHealth);\r\n\t\t\t\tentity.maxHealth = Math.max(1, entity.maxHealth - boardHero.globalInfo.GoldrinnBuffHealth);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const boardEntity of board) {\r\n\t\tswitch (boardEntity.cardId) {\r\n\t\t\tcase CardIds.MurlocWarleaderLegacy_BG_EX1_507:\r\n\t\t\tcase CardIds.MurlocWarleaderLegacy_TB_BaconUps_008:\r\n\t\t\t\tif (\r\n\t\t\t\t\thasCorrectTribe(entity, boardHero, Race.MURLOC, gameState.anomalies, gameState.allCards) &&\r\n\t\t\t\t\tentity.entityId !== boardEntity.entityId\r\n\t\t\t\t) {\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tentity.attack = Math.max(\r\n\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\tentity.attack -\r\n\t\t\t\t\t\t\t\t(boardEntity.cardId === CardIds.MurlocWarleaderLegacy_TB_BaconUps_008 ? 4 : 2),\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tentity.maxAttack = Math.max(\r\n\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\tentity.maxAttack -\r\n\t\t\t\t\t\t\t\t(boardEntity.cardId === CardIds.MurlocWarleaderLegacy_TB_BaconUps_008 ? 4 : 2),\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SouthseaCaptainLegacy_BG_NEW1_027:\r\n\t\t\tcase CardIds.SouthseaCaptainLegacy_TB_BaconUps_136:\r\n\t\t\t\tif (\r\n\t\t\t\t\thasCorrectTribe(entity, boardHero, Race.PIRATE, gameState.anomalies, gameState.allCards) &&\r\n\t\t\t\t\tentity.entityId !== boardEntity.entityId\r\n\t\t\t\t) {\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tentity.attack = Math.max(\r\n\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\tentity.attack -\r\n\t\t\t\t\t\t\t\t(boardEntity.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1),\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tentity.maxAttack = Math.max(\r\n\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\tentity.maxAttack -\r\n\t\t\t\t\t\t\t\t(boardEntity.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1),\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (applyHealthAuras) {\r\n\t\t\t\t\t\tentity.health = Math.max(\r\n\t\t\t\t\t\t\t1,\r\n\t\t\t\t\t\t\tentity.health -\r\n\t\t\t\t\t\t\t\t(boardEntity.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1),\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tentity.maxHealth = Math.max(\r\n\t\t\t\t\t\t\t1,\r\n\t\t\t\t\t\t\tentity.maxHealth -\r\n\t\t\t\t\t\t\t\t(boardEntity.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1),\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t// case CardIds.Kathranatir_BG21_039:\r\n\t\t\t// case CardIds.Kathranatir_BG21_039_G:\r\n\t\t\t// \tif (\r\n\t\t\t// \t\thasCorrectTribe(entity, boardHero, Race.DEMON, gameState.anomalies, gameState.allCards) &&\r\n\t\t\t// \t\tentity.entityId !== boardEntity.entityId\r\n\t\t\t// \t) {\r\n\t\t\t// \t\tentity.attack = Math.max(\r\n\t\t\t// \t\t\t0,\r\n\t\t\t// \t\t\tentity.attack - (boardEntity.cardId === CardIds.Kathranatir_BG21_039_G ? 2 : 1),\r\n\t\t\t// \t\t);\r\n\t\t\t// \t}\r\n\t\t\t// \tbreak;\r\n\t\t\tcase CardIds.CyborgDrake_BG25_043:\r\n\t\t\tcase CardIds.CyborgDrake_BG25_043_G:\r\n\t\t\t\tif (entity.divineShield) {\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tentity.attack = Math.max(\r\n\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\tentity.attack - (boardEntity.cardId === CardIds.CyborgDrake_BG25_043_G ? 12 : 6),\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tentity.maxAttack = Math.max(\r\n\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\tentity.maxAttack - (boardEntity.cardId === CardIds.CyborgDrake_BG25_043_G ? 12 : 6),\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SoreLoser_BG27_030:\r\n\t\t\tcase CardIds.SoreLoser_BG27_030_G:\r\n\t\t\t\tif (\r\n\t\t\t\t\thasCorrectTribe(entity, boardHero, Race.UNDEAD, gameState.anomalies, gameState.allCards) &&\r\n\t\t\t\t\tentity.entityId !== boardEntity.entityId\r\n\t\t\t\t) {\r\n\t\t\t\t\tif (applyAttackAuras) {\r\n\t\t\t\t\t\tentity.attack = Math.max(\r\n\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\tentity.attack -\r\n\t\t\t\t\t\t\t\t(boardEntity.cardId === CardIds.SoreLoser_BG27_030_G ? 2 : 1) * boardHero.tavernTier,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tentity.maxAttack = Math.max(\r\n\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\tentity.maxAttack -\r\n\t\t\t\t\t\t\t\t(boardEntity.cardId === CardIds.SoreLoser_BG27_030_G ? 2 : 1) * boardHero.tavernTier,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tswitch (entity.cardId) {\r\n\t\tcase CardIds.EternalKnight_BG25_008:\r\n\t\tcase CardIds.EternalKnight_BG25_008_G:\r\n\t\t\tconst multiplierKnight = entity.cardId === CardIds.EternalKnight_BG25_008_G ? 2 : 1;\r\n\t\t\tconst statsBonusKnight = multiplierKnight * boardHero.globalInfo.EternalKnightsDeadThisGame;\r\n\t\t\tconst knightAttackToRemove =\r\n\t\t\t\teternalKnightAttack * statsBonusKnight + boardHero.globalInfo.EternalKnightAttackBuff;\r\n\t\t\tconst knightHealthToRemove =\r\n\t\t\t\teternalKnightHealth * statsBonusKnight + boardHero.globalInfo.EternalKnightHealthBuff;\r\n\t\t\tif (applyAttackAuras) {\r\n\t\t\t\tentity.attack = Math.max(eternalKnightAttack * multiplierKnight, entity.attack - knightAttackToRemove);\r\n\t\t\t\tentity.maxAttack = Math.max(\r\n\t\t\t\t\teternalKnightAttack * multiplierKnight,\r\n\t\t\t\t\tentity.maxAttack - knightAttackToRemove,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t\tif (applyHealthAuras) {\r\n\t\t\t\tentity.health = Math.max(eternalKnightHealth * multiplierKnight, entity.health - knightHealthToRemove);\r\n\t\t\t\tentity.maxHealth = Math.max(\r\n\t\t\t\t\teternalKnightHealth * multiplierKnight,\r\n\t\t\t\t\tentity.maxHealth - knightHealthToRemove,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.EnsorcelledFungus_BG28_555:\r\n\t\tcase CardIds.EnsorcelledFungus_BG28_555_G:\r\n\t\t\tconst multiplierFungus = entity.cardId === CardIds.EnsorcelledFungus_BG28_555_G ? 2 : 1;\r\n\t\t\tconst statsBonusFungus = multiplierFungus * boardHero.globalInfo.TavernSpellsCastThisGame;\r\n\t\t\tif (applyAttackAuras) {\r\n\t\t\t\tentity.attack = Math.max(0, entity.attack - statsBonusFungus);\r\n\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - statsBonusFungus);\r\n\t\t\t}\r\n\t\t\tif (applyHealthAuras) {\r\n\t\t\t\tentity.health = Math.max(1, entity.health - 2 * statsBonusFungus);\r\n\t\t\t\tentity.maxHealth = Math.max(1, entity.maxHealth - 2 * statsBonusFungus);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.AstralAutomaton_BG_TTN_401:\r\n\t\tcase CardIds.AstralAutomaton_BG_TTN_401_G:\r\n\t\t\tconst multiplierAstral = entity.cardId === CardIds.AstralAutomaton_BG_TTN_401_G ? 2 : 1;\r\n\t\t\t// We remove 1 because the AstralAutomatonsSummonedThisGame also includes the current one\r\n\t\t\t// and ancestral automaton only counts \"other\" automatons\r\n\t\t\t// When we remove the auras from a minion in hand, we shouldn't apply\r\n\t\t\t// the \"-1\", as it has not been summoned yet\r\n\t\t\tconst statsBonusAstral = Math.max(\r\n\t\t\t\t0,\r\n\t\t\t\tmultiplierAstral *\r\n\t\t\t\t\t(isOnBoard\r\n\t\t\t\t\t\t? (boardHero.globalInfo.AstralAutomatonsSummonedThisGame ?? 0) - 1\r\n\t\t\t\t\t\t: boardHero.globalInfo.AstralAutomatonsSummonedThisGame ?? 0),\r\n\t\t\t);\r\n\t\t\tif (applyAttackAuras) {\r\n\t\t\t\tentity.attack = Math.max(0, entity.attack - 3 * statsBonusAstral);\r\n\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - 3 * statsBonusAstral);\r\n\t\t\t}\r\n\t\t\tif (applyHealthAuras) {\r\n\t\t\t\tentity.health = Math.max(1, entity.health - 2 * statsBonusAstral);\r\n\t\t\t\tentity.maxHealth = Math.max(1, entity.maxHealth - 2 * statsBonusAstral);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.RotHideGnoll_BG25_013:\r\n\t\tcase CardIds.RotHideGnoll_BG25_013_G:\r\n\t\t\tconst multiplierGnoll = entity.cardId === CardIds.RotHideGnoll_BG25_013_G ? 2 : 1;\r\n\t\t\tconst statsBonusGnoll =\r\n\t\t\t\tmultiplierGnoll * gameState.sharedState.deaths.filter((e) => e.friendly === entity.friendly).length;\r\n\t\t\tif (applyAttackAuras) {\r\n\t\t\t\tentity.attack = Math.max(0, entity.attack - statsBonusGnoll);\r\n\t\t\t\tentity.maxAttack = Math.max(0, entity.maxAttack - statsBonusGnoll);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t}\r\n};\r\n\r\nconst handleMinionAddedAuraEffect = (\r\n\tspawnedCardId: string,\r\n\tspawned: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tisActuallySpawned = true,\r\n): void => {\r\n\tswitch (spawnedCardId) {\r\n\t\tcase CardIds.SouthseaCaptainLegacy_BG_NEW1_027:\r\n\t\tcase CardIds.SouthseaCaptainLegacy_TB_BaconUps_136:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, boardHero, Race.PIRATE, gameState.anomalies, gameState.allCards))\r\n\t\t\t\t// Other\r\n\t\t\t\t.filter((e) => e.entityId !== spawned.entityId)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += spawned.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1;\r\n\t\t\t\t\te.health += spawned.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1;\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.MurlocWarleaderLegacy_BG_EX1_507:\r\n\t\tcase CardIds.MurlocWarleaderLegacy_TB_BaconUps_008:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, boardHero, Race.MURLOC, gameState.anomalies, gameState.allCards))\r\n\t\t\t\t.filter((e) => e.entityId !== spawned.entityId)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += spawned.cardId === CardIds.MurlocWarleaderLegacy_TB_BaconUps_008 ? 4 : 2;\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\t// case CardIds.Kathranatir_BG21_039:\r\n\t\t// case CardIds.Kathranatir_BG21_039_G:\r\n\t\t// \tboard\r\n\t\t// \t\t.filter((e) => hasCorrectTribe(e, boardHero, Race.DEMON, gameState.anomalies, gameState.allCards))\r\n\t\t// \t\t.filter((e) => e.entityId !== spawned.entityId)\r\n\t\t// \t\t.forEach((e) => {\r\n\t\t// \t\t\te.attack += spawned.cardId === CardIds.Kathranatir_BG21_039_G ? 4 : 2;\r\n\t\t// \t\t});\r\n\t\t// \tbreak;\r\n\t\tcase CardIds.CyborgDrake_BG25_043:\r\n\t\tcase CardIds.CyborgDrake_BG25_043_G:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => e.divineShield)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += spawned.cardId === CardIds.CyborgDrake_BG25_043_G ? 12 : 6;\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\r\n\t\tcase CardIds.SoreLoser_BG27_030:\r\n\t\tcase CardIds.SoreLoser_BG27_030_G:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, boardHero, Race.UNDEAD, gameState.anomalies, gameState.allCards))\r\n\t\t\t\t.filter((e) => e.entityId !== spawned.entityId)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += (spawned.cardId === CardIds.SoreLoser_BG27_030_G ? 2 : 1) * boardHero.tavernTier;\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.AstralAutomaton_BG_TTN_401:\r\n\t\tcase CardIds.AstralAutomaton_BG_TTN_401_G:\r\n\t\t\t// TODO: move this somewhere else\r\n\t\t\tif (isActuallySpawned) {\r\n\t\t\t\tboardHero.globalInfo.AstralAutomatonsSummonedThisGame =\r\n\t\t\t\t\t(boardHero.globalInfo.AstralAutomatonsSummonedThisGame ?? 0) + 1;\r\n\t\t\t}\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => e.entityId !== spawned.entityId)\r\n\t\t\t\t.filter(\r\n\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\te.cardId === CardIds.AstralAutomaton_BG_TTN_401 ||\r\n\t\t\t\t\t\te.cardId === CardIds.AstralAutomaton_BG_TTN_401_G,\r\n\t\t\t\t)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\tconst multiplierAstral = e.cardId === CardIds.AstralAutomaton_BG_TTN_401_G ? 2 : 1;\r\n\t\t\t\t\tmodifyStats(e, e, 3 * multiplierAstral, 2 * multiplierAstral, board, boardHero, gameState, false);\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.DrBoomsMonster_BG31_176:\r\n\t\tcase CardIds.DrBoomsMonster_BG31_176_G:\r\n\t\t\tconst multiplierDrBoom = spawned.cardId === CardIds.DrBoomsMonster_BG31_176_G ? 2 : 1;\r\n\t\t\tmodifyStats(\r\n\t\t\t\tspawned,\r\n\t\t\t\tspawned,\r\n\t\t\t\t2 * boardHero.globalInfo.MagnetizedThisGame * multiplierDrBoom,\r\n\t\t\t\t2 * boardHero.globalInfo.MagnetizedThisGame * multiplierDrBoom,\r\n\t\t\t\tboard,\r\n\t\t\t\tboardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t}\r\n};\r\n\r\nexport const handleAfterSpawnEffects = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tallSpawned: readonly BoardEntity[],\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tfor (const spawned of allSpawned) {\r\n\t\thandleAfterSpawnEffect(board, hero, otherBoard, otherHero, spawned, gameState);\r\n\t}\r\n};\r\n\r\nexport const onMinionSummoned = (hero: BgsPlayerEntity, board: BoardEntity[], gameState: FullGameState): void => {\r\n\tconst quests = hero.questEntities ?? [];\r\n\tif (!quests.length) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tfor (const quest of quests) {\r\n\t\tswitch (quest.CardId) {\r\n\t\t\tcase CardIds.AssembleALineup:\r\n\t\t\t\tonQuestProgressUpdated(hero, quest, board, gameState);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleAfterSpawnEffect = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tspawned: BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// So that spawns don't mess up the loop\r\n\tconst initialBoard = [...board];\r\n\r\n\tfor (const trinket of hero.trinkets ?? []) {\r\n\t\tconst onAfterSpawnedImpl = cardMappings[trinket.cardId];\r\n\t\tif (hasAfterOtherSpawned(onAfterSpawnedImpl)) {\r\n\t\t\tonAfterSpawnedImpl.afterOtherSpawned(trinket, {\r\n\t\t\t\tspawned: spawned,\r\n\t\t\t\thero: hero,\r\n\t\t\t\tboard: board,\r\n\t\t\t\totherHero: otherHero,\r\n\t\t\t\totherBoard: otherBoard,\r\n\t\t\t\tgameState,\r\n\t\t\t\tapplySelfAuras: false,\r\n\t\t\t\tapplyAttackAuras: true,\r\n\t\t\t\tapplyHealthAuras: true,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const entity of initialBoard) {\r\n\t\tif (entity.entityId === spawned.entityId) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tconst onAfterSpawnedImpl = cardMappings[entity.cardId];\r\n\t\tif (hasAfterOtherSpawned(onAfterSpawnedImpl)) {\r\n\t\t\tonAfterSpawnedImpl.afterOtherSpawned(entity, {\r\n\t\t\t\tspawned: spawned,\r\n\t\t\t\thero: hero,\r\n\t\t\t\tboard: board,\r\n\t\t\t\totherHero: otherHero,\r\n\t\t\t\totherBoard: otherBoard,\r\n\t\t\t\tgameState,\r\n\t\t\t\tapplySelfAuras: false,\r\n\t\t\t\tapplyAttackAuras: true,\r\n\t\t\t\tapplyHealthAuras: true,\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tswitch (entity.cardId) {\r\n\t\t\tcase CardIds.XyloBones_BG26_172:\r\n\t\t\tcase CardIds.XyloBones_BG26_172_G:\r\n\t\t\t\tif (entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tconst xylobonesBuff = entity.cardId === CardIds.XyloBones_BG26_172_G ? 4 : 2;\r\n\t\t\t\t\tmodifyStats(entity, entity, 0, xylobonesBuff, board, hero, gameState);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(entity, entity, board, null, null);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.OctosariWrapGod_BG26_804:\r\n\t\t\tcase CardIds.OctosariWrapGod_BG26_804_G:\r\n\t\t\t\tif (entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tconst octoStats = entity.cardId === CardIds.OctosariWrapGod_BG26_804_G ? 4 : 2;\r\n\t\t\t\t\tentity.scriptDataNum1 = (entity.scriptDataNum1 ?? 0) + octoStats;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t// case CardIds.ObserverOfMyths_BG_TTN_078:\r\n\t\t\t// case CardIds.ObserverOfMyths_BG_TTN_078_G:\r\n\t\t\t// \tif (spawned.attack > entity.attack) {\r\n\t\t\t// \t\tconst observerBuff = entity.cardId === CardIds.ObserverOfMyths_BG_TTN_078_G ? 2 : 1;\r\n\t\t\t// \t\taddStatsToBoard(entity, board, hero, observerBuff, 0, gameState);\r\n\t\t\t// \t}\r\n\t\t\t// \tbreak;\r\n\t\t\tcase CardIds.ValithriaDreamwalker_TB_BaconShop_HERO_53_Buddy:\r\n\t\t\tcase CardIds.ValithriaDreamwalker_TB_BaconShop_HERO_53_Buddy_G:\r\n\t\t\t\tif (\r\n\t\t\t\t\thasCorrectTribe(spawned, hero, Race.DRAGON, gameState.anomalies, gameState.allCards) &&\r\n\t\t\t\t\tentity.entityId !== spawned.entityId\r\n\t\t\t\t) {\r\n\t\t\t\t\tconst valithriaBuff =\r\n\t\t\t\t\t\tentity.cardId === CardIds.ValithriaDreamwalker_TB_BaconShop_HERO_53_Buddy_G ? 3 : 2;\r\n\t\t\t\t\tmodifyStats(entity, entity, valithriaBuff, valithriaBuff, board, hero, gameState);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(entity, spawned, board, null, null);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t// Putricide-only\r\n\t\t\tcase CardIds.ArmsDealer_BG26_RLK_824:\r\n\t\t\t\tif (\r\n\t\t\t\t\thasCorrectTribe(spawned, hero, Race.UNDEAD, gameState.anomalies, gameState.allCards) &&\r\n\t\t\t\t\tentity.entityId !== spawned.entityId\r\n\t\t\t\t) {\r\n\t\t\t\t\tmodifyStats(spawned, spawned, 1, 0, board, hero, gameState, false);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(entity, entity, board, null, null);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport interface OnSpawnInput {\r\n\thero: BgsPlayerEntity;\r\n\tboard: BoardEntity[];\r\n\tgameState: FullGameState;\r\n\tapplyAttackAuras: boolean;\r\n\tapplyHealthAuras: boolean;\r\n}\r\nexport interface OnOtherSpawnInput {\r\n\tspawned: BoardEntity;\r\n\thero: BgsPlayerEntity;\r\n\tboard: BoardEntity[];\r\n\totherHero: BgsPlayerEntity;\r\n\totherBoard: BoardEntity[];\r\n\tgameState: FullGameState;\r\n\tapplyAttackAuras: boolean;\r\n\tapplyHealthAuras: boolean;\r\n\tapplySelfAuras: boolean;\r\n}\r\nexport interface OnOtherSpawnAuraInput {\r\n\tspawned: BoardEntity;\r\n\thero: BgsPlayerEntity;\r\n\tboard: BoardEntity[];\r\n\tgameState: FullGameState;\r\n\tapplyAttackAuras: boolean;\r\n\tapplyHealthAuras: boolean;\r\n}\r\nexport interface OnDespawnInput {\r\n\thero: BgsPlayerEntity;\r\n\tboard: BoardEntity[];\r\n\tgameState: FullGameState;\r\n\t// Slamma + Goldrinn interaction is:\r\n\t// - set the stats to (double_attack, health)\r\n\t// - re-apply only the \"attack\" portion of the aura\r\n\tapplyAttackAuras: boolean;\r\n\tapplyHealthAuras: boolean;\r\n}\r\n\r\n/** Trinket reaction when a minion is placed on the friendly board (`handleAddedMinionAuraEffect`, after hero power / quest hooks). */\r\nexport interface OnFriendlyMinionSummonedTrinketInput {\r\n\tspawned: BoardEntity;\r\n\tboard: BoardEntity[];\r\n\thero: BgsPlayerEntity;\r\n\totherBoard: BoardEntity[];\r\n\totherHero: BgsPlayerEntity;\r\n\tgameState: FullGameState;\r\n}\r\n"]}
|
|
@@ -16,8 +16,14 @@ const applyAfterDeathEffects = (deadEntity, deadEntityIndexFromRight, boardWithD
|
|
|
16
16
|
(0, spawns_1.performEntitySpawns)(allSpawns, boardWithDeadEntity, boardWithDeadEntityHero, deadEntity, deadEntityIndexFromRight, otherBoard, otherBoardHero, gameState);
|
|
17
17
|
const deitySpawns = (0, deity_1.onFriendlyAberrationDied)(deadEntity, deadEntityIndexFromRight, boardWithDeadEntity, boardWithDeadEntityHero, otherBoard, otherBoardHero, gameState);
|
|
18
18
|
if (deitySpawns.length > 0) {
|
|
19
|
-
(0, spawns_1.performEntitySpawns)(deitySpawns, boardWithDeadEntity, boardWithDeadEntityHero, deadEntity, 0, otherBoard, otherBoardHero, gameState);
|
|
20
|
-
|
|
19
|
+
const spawned = (0, spawns_1.performEntitySpawns)(deitySpawns, boardWithDeadEntity, boardWithDeadEntityHero, deadEntity, 0, otherBoard, otherBoardHero, gameState);
|
|
20
|
+
if (spawned.length > 0) {
|
|
21
|
+
(0, deity_1.markDeitySecretTriggered)(boardWithDeadEntityHero);
|
|
22
|
+
allSpawns.push(...spawned);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
(0, deity_1.retryDeityAwakenOnNextAberrationDeath)(boardWithDeadEntityHero);
|
|
26
|
+
}
|
|
21
27
|
}
|
|
22
28
|
return allSpawns;
|
|
23
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"death-effects.js","sourceRoot":"","sources":["../../src/simulation/death-effects.ts"],"names":[],"mappings":";;;AAEA,4DAAwG;AACxG,iEAA4D;AAE5D,6CAAoD;AACpD,6DAAqD;AACrD,mCAAmD;AAEnD,qCAA+C;AAC/C,mCAAsC;AACtC,uDAAqD;AAE9C,MAAM,sBAAsB,GAAG,CACrC,UAAuB,EACv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AAE,IAAI,CAAC,CAAC;gBAClG,MAAM;SACP;KACD;IACD,OAAO,SAAS,CAAC;AAClB,CAAC,CAAC;AAEK,MAAM,mBAAmB,GAAG,CAClC,UAAuB,EACvB,wBAAgC,EAChC,mBAAkC,EAClC,uBAAwC,EACxC,UAAyB,EACzB,cAA+B,EAC/B,SAAwB,EACvB,EAAE;IAEH,OAAO,EAAE,CAAC;AACX,CAAC,CAAC;AAXW,QAAA,mBAAmB,uBAW9B","sourcesContent":["import { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { hasOnAfterFriendlyMinionDeath, hasRebornSelfAttributeTransfer } from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { pickRandomAlive } from '../services/utils';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { onFriendlyAberrationDied } from './deity';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { performEntitySpawns } from './spawns';\r\nimport { modifyStats } from './stats';\r\nimport { copyAttribute } from './utils/entity-utils';\r\n\r\nexport const applyAfterDeathEffects = (\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): BoardEntity[] => {\r\n\tconst allSpawns = [];\r\n\r\n\tconst spawnsFromSecrets = handleAfterMinionDeathEffects(\r\n\t\tdeadEntity,\r\n\t\tdeadEntityIndexFromRight,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\totherBoard,\r\n\t\totherBoardHero,\r\n\t\tgameState,\r\n\t);\r\n\tallSpawns.push(...spawnsFromSecrets);\r\n\tperformEntitySpawns(\r\n\t\tallSpawns,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tdeadEntity,\r\n\t\tdeadEntityIndexFromRight,\r\n\t\totherBoard,\r\n\t\totherBoardHero,\r\n\t\tgameState,\r\n\t);\r\n\r\n\tconst deitySpawns = onFriendlyAberrationDied(\r\n\t\tdeadEntity,\r\n\t\tdeadEntityIndexFromRight,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\totherBoard,\r\n\t\totherBoardHero,\r\n\t\tgameState,\r\n\t);\r\n\tif (deitySpawns.length > 0) {\r\n\t\tperformEntitySpawns(\r\n\t\t\tdeitySpawns,\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\tdeadEntity,\r\n\t\t\t0,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tallSpawns.push(...deitySpawns);\r\n\t}\r\n\r\n\treturn allSpawns;\r\n};\r\n\r\nconst handleAfterMinionDeathEffects = (\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): BoardEntity[] => {\r\n\tconst allSpawns = [];\r\n\r\n\t// TODO: move this to an \"after minion dies\" phase, instead of \"whenever minion dies\"\r\n\tconst boardBeforeProcs = [...boardWithDeadEntity];\r\n\tfor (const entity of boardWithDeadEntity) {\r\n\t\tconst impl = cardMappings[entity.cardId];\r\n\t\tif (hasOnAfterFriendlyMinionDeath(impl)) {\r\n\t\t\timpl.onAfterFriendlyMinionDeath(entity, {\r\n\t\t\t\tdeadEntity,\r\n\t\t\t\tboard: boardWithDeadEntity,\r\n\t\t\t\tboardBeforeProcs,\r\n\t\t\t\thero: boardWithDeadEntityHero,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherHero: otherBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const trinket of boardWithDeadEntityHero.trinkets ?? []) {\r\n\t\tconst trinketImpl = cardMappings[trinket.cardId];\r\n\t\tif (hasOnAfterFriendlyMinionDeath(trinketImpl)) {\r\n\t\t\ttrinketImpl.onAfterFriendlyMinionDeath(trinket, {\r\n\t\t\t\tdeadEntity,\r\n\t\t\t\tboard: boardWithDeadEntity,\r\n\t\t\t\tboardBeforeProcs,\r\n\t\t\t\thero: boardWithDeadEntityHero,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherHero: otherBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const secret of (boardWithDeadEntityHero.secrets ?? []).filter((s) => !s.triggered)) {\r\n\t\tswitch (secret.cardId) {\r\n\t\t\tcase CardIds.Avenge_TB_Bacon_Secrets_08:\r\n\t\t\t\tsecret.triggered = true;\r\n\t\t\t\tconst avengeTarget = pickRandomAlive(boardWithDeadEntity);\r\n\t\t\t\tmodifyStats(avengeTarget, secret, 3, 2, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Redemption_TB_Bacon_Secrets_10:\r\n\t\t\t\tsecret.triggered = true;\r\n\t\t\t\tconst redemptionSpawns = spawnEntities(\r\n\t\t\t\t\tdeadEntity.cardId,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\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\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t\t// { ...newSpawn } as BoardEntity,\r\n\t\t\t\t);\r\n\t\t\t\tredemptionSpawns[0].health = 1;\r\n\t\t\t\t// I don't like duplicating this logic\r\n\t\t\t\tconst rebornImpl = cardMappings[redemptionSpawns[0].cardId];\r\n\t\t\t\tif (hasRebornSelfAttributeTransfer(rebornImpl)) {\r\n\t\t\t\t\trebornImpl.rebornSelfAttributeTransfer.forEach((attribute: keyof BoardEntity) => {\r\n\t\t\t\t\t\tcopyAttribute(redemptionSpawns[0], deadEntity, attribute);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\tallSpawns.push(...redemptionSpawns);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(secret, redemptionSpawns[0], boardWithDeadEntity, null, null);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Redemption_BetterRedemption_TB_Bacon_Secrets_10b:\r\n\t\t\t\tsecret.triggered = true;\r\n\t\t\t\tconst betterRedemptionSpawns = spawnEntities(\r\n\t\t\t\t\tdeadEntity.cardId,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\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\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t);\r\n\t\t\t\tfor (const spawn of betterRedemptionSpawns) {\r\n\t\t\t\t\tspawn.health = deadEntity.maxHealth;\r\n\t\t\t\t\tspawn.maxHealth = deadEntity.maxHealth;\r\n\t\t\t\t\tspawn.attack = deadEntity.attack;\r\n\t\t\t\t\tspawn.maxAttack = deadEntity.maxAttack;\r\n\t\t\t\t\tspawn.enchantments = deadEntity.enchantments;\r\n\t\t\t\t\tspawn.divineShield = deadEntity.hadDivineShield;\r\n\t\t\t\t\tconst rebornImpl = cardMappings[spawn.cardId];\r\n\t\t\t\t\tif (hasRebornSelfAttributeTransfer(rebornImpl)) {\r\n\t\t\t\t\t\trebornImpl.rebornSelfAttributeTransfer.forEach((attribute: keyof BoardEntity) => {\r\n\t\t\t\t\t\t\tcopyAttribute(spawn, deadEntity, attribute);\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tallSpawns.push(...betterRedemptionSpawns);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tsecret,\r\n\t\t\t\t\tbetterRedemptionSpawns[0],\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Effigy_TB_Bacon_Secrets_05:\r\n\t\t\t\tsecret.triggered = true;\r\n\t\t\t\tconst minionTier = gameState.cardsData.getTavernLevel(deadEntity.cardId);\r\n\t\t\t\tconst newMinion = gameState.cardsData.getRandomMinionForTavernTier(minionTier);\r\n\t\t\t\tconst effigySpawns = spawnEntities(\r\n\t\t\t\t\tnewMinion,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\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\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t);\r\n\t\t\t\tallSpawns.push(...effigySpawns);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(secret, effigySpawns[0], boardWithDeadEntity, null, null);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn allSpawns;\r\n};\r\n\r\nexport const applyOnDeathEffects = (\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) => {\r\n\t// Nothing yet\r\n\treturn [];\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"death-effects.js","sourceRoot":"","sources":["../../src/simulation/death-effects.ts"],"names":[],"mappings":";;;AAEA,4DAAwG;AACxG,iEAA4D;AAE5D,6CAAoD;AACpD,6DAAqD;AACrD,mCAIiB;AAEjB,qCAA+C;AAC/C,mCAAsC;AACtC,uDAAqD;AAE9C,MAAM,sBAAsB,GAAG,CACrC,UAAuB,EACvB,wBAAgC,EAChC,mBAAkC,EAClC,uBAAwC,EACxC,UAAyB,EACzB,cAA+B,EAC/B,SAAwB,EACR,EAAE;IAClB,MAAM,SAAS,GAAG,EAAE,CAAC;IAErB,MAAM,iBAAiB,GAAG,6BAA6B,CACtD,UAAU,EACV,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,UAAU,EACV,cAAc,EACd,SAAS,CACT,CAAC;IACF,SAAS,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC;IACrC,IAAA,4BAAmB,EAClB,SAAS,EACT,mBAAmB,EACnB,uBAAuB,EACvB,UAAU,EACV,wBAAwB,EACxB,UAAU,EACV,cAAc,EACd,SAAS,CACT,CAAC;IAEF,MAAM,WAAW,GAAG,IAAA,gCAAwB,EAC3C,UAAU,EACV,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,UAAU,EACV,cAAc,EACd,SAAS,CACT,CAAC;IACF,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;QAC3B,MAAM,OAAO,GAAG,IAAA,4BAAmB,EAClC,WAAW,EACX,mBAAmB,EACnB,uBAAuB,EACvB,UAAU,EACV,CAAC,EACD,UAAU,EACV,cAAc,EACd,SAAS,CACT,CAAC;QACF,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YACvB,IAAA,gCAAwB,EAAC,uBAAuB,CAAC,CAAC;YAClD,SAAS,CAAC,IAAI,CAAC,GAAG,O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,CAAC,SAAS,CAAC,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBACzE,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC,4BAA4B,CAAC,UAAU,CAAC,CAAC;gBAC/E,MAAM,YAAY,GAAG,IAAA,kCAAa,EACjC,SAAS,EACT,CAAC,EACD,mBAAmB,EACnB,uBAAuB,EACvB,UAAU,EACV,cAAc,EACd,SAAS,EACT,UAAU,CAAC,QAAQ,EACnB,KAAK,EACL,KAAK,EACL,IAAI,CACJ,CAAC;gBACF,SAAS,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,CAAC;gBAChC,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,mBAAmB,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;gBAClG,MAAM;SACP;KACD;IACD,OAAO,SAAS,CAAC;AAClB,CAAC,CAAC;AAEK,MAAM,mBAAmB,GAAG,CAClC,UAAuB,EACvB,wBAAgC,EAChC,mBAAkC,EAClC,uBAAwC,EACxC,UAAyB,EACzB,cAA+B,EAC/B,SAAwB,EACvB,EAAE;IAEH,OAAO,EAAE,CAAC;AACX,CAAC,CAAC;AAXW,QAAA,mBAAmB,uBAW9B","sourcesContent":["import { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { hasOnAfterFriendlyMinionDeath, hasRebornSelfAttributeTransfer } from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { pickRandomAlive } from '../services/utils';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport {\r\n\tmarkDeitySecretTriggered,\r\n\tonFriendlyAberrationDied,\r\n\tretryDeityAwakenOnNextAberrationDeath,\r\n} from './deity';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { performEntitySpawns } from './spawns';\r\nimport { modifyStats } from './stats';\r\nimport { copyAttribute } from './utils/entity-utils';\r\n\r\nexport const applyAfterDeathEffects = (\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): BoardEntity[] => {\r\n\tconst allSpawns = [];\r\n\r\n\tconst spawnsFromSecrets = handleAfterMinionDeathEffects(\r\n\t\tdeadEntity,\r\n\t\tdeadEntityIndexFromRight,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\totherBoard,\r\n\t\totherBoardHero,\r\n\t\tgameState,\r\n\t);\r\n\tallSpawns.push(...spawnsFromSecrets);\r\n\tperformEntitySpawns(\r\n\t\tallSpawns,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tdeadEntity,\r\n\t\tdeadEntityIndexFromRight,\r\n\t\totherBoard,\r\n\t\totherBoardHero,\r\n\t\tgameState,\r\n\t);\r\n\r\n\tconst deitySpawns = onFriendlyAberrationDied(\r\n\t\tdeadEntity,\r\n\t\tdeadEntityIndexFromRight,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\totherBoard,\r\n\t\totherBoardHero,\r\n\t\tgameState,\r\n\t);\r\n\tif (deitySpawns.length > 0) {\r\n\t\tconst spawned = performEntitySpawns(\r\n\t\t\tdeitySpawns,\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\tdeadEntity,\r\n\t\t\t0,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tif (spawned.length > 0) {\r\n\t\t\tmarkDeitySecretTriggered(boardWithDeadEntityHero);\r\n\t\t\tallSpawns.push(...spawned);\r\n\t\t} else {\r\n\t\t\tretryDeityAwakenOnNextAberrationDeath(boardWithDeadEntityHero);\r\n\t\t}\r\n\t}\r\n\r\n\treturn allSpawns;\r\n};\r\n\r\nconst handleAfterMinionDeathEffects = (\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): BoardEntity[] => {\r\n\tconst allSpawns = [];\r\n\r\n\t// TODO: move this to an \"after minion dies\" phase, instead of \"whenever minion dies\"\r\n\tconst boardBeforeProcs = [...boardWithDeadEntity];\r\n\tfor (const entity of boardWithDeadEntity) {\r\n\t\tconst impl = cardMappings[entity.cardId];\r\n\t\tif (hasOnAfterFriendlyMinionDeath(impl)) {\r\n\t\t\timpl.onAfterFriendlyMinionDeath(entity, {\r\n\t\t\t\tdeadEntity,\r\n\t\t\t\tboard: boardWithDeadEntity,\r\n\t\t\t\tboardBeforeProcs,\r\n\t\t\t\thero: boardWithDeadEntityHero,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherHero: otherBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const trinket of boardWithDeadEntityHero.trinkets ?? []) {\r\n\t\tconst trinketImpl = cardMappings[trinket.cardId];\r\n\t\tif (hasOnAfterFriendlyMinionDeath(trinketImpl)) {\r\n\t\t\ttrinketImpl.onAfterFriendlyMinionDeath(trinket, {\r\n\t\t\t\tdeadEntity,\r\n\t\t\t\tboard: boardWithDeadEntity,\r\n\t\t\t\tboardBeforeProcs,\r\n\t\t\t\thero: boardWithDeadEntityHero,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherHero: otherBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const secret of (boardWithDeadEntityHero.secrets ?? []).filter((s) => !s.triggered)) {\r\n\t\tswitch (secret.cardId) {\r\n\t\t\tcase CardIds.Avenge_TB_Bacon_Secrets_08:\r\n\t\t\t\tsecret.triggered = true;\r\n\t\t\t\tconst avengeTarget = pickRandomAlive(boardWithDeadEntity);\r\n\t\t\t\tmodifyStats(avengeTarget, secret, 3, 2, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Redemption_TB_Bacon_Secrets_10:\r\n\t\t\t\tsecret.triggered = true;\r\n\t\t\t\tconst redemptionSpawns = spawnEntities(\r\n\t\t\t\t\tdeadEntity.cardId,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\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\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t\t// { ...newSpawn } as BoardEntity,\r\n\t\t\t\t);\r\n\t\t\t\tredemptionSpawns[0].health = 1;\r\n\t\t\t\t// I don't like duplicating this logic\r\n\t\t\t\tconst rebornImpl = cardMappings[redemptionSpawns[0].cardId];\r\n\t\t\t\tif (hasRebornSelfAttributeTransfer(rebornImpl)) {\r\n\t\t\t\t\trebornImpl.rebornSelfAttributeTransfer.forEach((attribute: keyof BoardEntity) => {\r\n\t\t\t\t\t\tcopyAttribute(redemptionSpawns[0], deadEntity, attribute);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\tallSpawns.push(...redemptionSpawns);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(secret, redemptionSpawns[0], boardWithDeadEntity, null, null);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Redemption_BetterRedemption_TB_Bacon_Secrets_10b:\r\n\t\t\t\tsecret.triggered = true;\r\n\t\t\t\tconst betterRedemptionSpawns = spawnEntities(\r\n\t\t\t\t\tdeadEntity.cardId,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\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\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t);\r\n\t\t\t\tfor (const spawn of betterRedemptionSpawns) {\r\n\t\t\t\t\tspawn.health = deadEntity.maxHealth;\r\n\t\t\t\t\tspawn.maxHealth = deadEntity.maxHealth;\r\n\t\t\t\t\tspawn.attack = deadEntity.attack;\r\n\t\t\t\t\tspawn.maxAttack = deadEntity.maxAttack;\r\n\t\t\t\t\tspawn.enchantments = deadEntity.enchantments;\r\n\t\t\t\t\tspawn.divineShield = deadEntity.hadDivineShield;\r\n\t\t\t\t\tconst rebornImpl = cardMappings[spawn.cardId];\r\n\t\t\t\t\tif (hasRebornSelfAttributeTransfer(rebornImpl)) {\r\n\t\t\t\t\t\trebornImpl.rebornSelfAttributeTransfer.forEach((attribute: keyof BoardEntity) => {\r\n\t\t\t\t\t\t\tcopyAttribute(spawn, deadEntity, attribute);\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tallSpawns.push(...betterRedemptionSpawns);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tsecret,\r\n\t\t\t\t\tbetterRedemptionSpawns[0],\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Effigy_TB_Bacon_Secrets_05:\r\n\t\t\t\tsecret.triggered = true;\r\n\t\t\t\tconst minionTier = gameState.cardsData.getTavernLevel(deadEntity.cardId);\r\n\t\t\t\tconst newMinion = gameState.cardsData.getRandomMinionForTavernTier(minionTier);\r\n\t\t\t\tconst effigySpawns = spawnEntities(\r\n\t\t\t\t\tnewMinion,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\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\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t);\r\n\t\t\t\tallSpawns.push(...effigySpawns);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(secret, effigySpawns[0], boardWithDeadEntity, null, null);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn allSpawns;\r\n};\r\n\r\nexport const applyOnDeathEffects = (\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) => {\r\n\t// Nothing yet\r\n\treturn [];\r\n};\r\n"]}
|
|
@@ -11,8 +11,16 @@ export declare const getDeityBaseStats: (hero: BgsPlayerEntity, entity?: BoardEn
|
|
|
11
11
|
attack: number;
|
|
12
12
|
health: number;
|
|
13
13
|
};
|
|
14
|
+
export declare const getDeityAuraSnapshot: (entity: BoardEntity, hero: BgsPlayerEntity) => {
|
|
15
|
+
attack: number;
|
|
16
|
+
health: number;
|
|
17
|
+
};
|
|
18
|
+
export declare const stampOnBoardDeityAuras: (board: BoardEntity[], hero: BgsPlayerEntity, allCards: AllCardsService) => void;
|
|
14
19
|
export declare const applyDeityBaseStats: (entity: BoardEntity, hero: BgsPlayerEntity) => void;
|
|
20
|
+
export declare const consumeDeityBaseStatsAssignment: (entity: BoardEntity) => boolean;
|
|
15
21
|
export declare const buffYourDeity: (hero: BgsPlayerEntity, board: BoardEntity[], source: BoardEntity | BoardSecret | BgsPlayerEntity, attack: number, health: number, gameState: FullGameState) => void;
|
|
16
22
|
export declare const incrementDeitySecretStats: (hero: BgsPlayerEntity, attack: number, health: number) => void;
|
|
17
23
|
export declare const buffTeamDeities: (hero: BgsPlayerEntity, board: BoardEntity[], source: BoardEntity, attack: number, health: number, gameState: FullGameState) => void;
|
|
18
24
|
export declare const onFriendlyAberrationDied: (deadEntity: BoardEntity, _deadEntityIndexFromRight: number, board: BoardEntity[], hero: BgsPlayerEntity, otherBoard: BoardEntity[], otherHero: BgsPlayerEntity, gameState: FullGameState) => BoardEntity[];
|
|
25
|
+
export declare const markDeitySecretTriggered: (hero: BgsPlayerEntity) => void;
|
|
26
|
+
export declare const retryDeityAwakenOnNextAberrationDeath: (hero: BgsPlayerEntity) => void;
|
package/dist/simulation/deity.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.onFriendlyAberrationDied = exports.buffTeamDeities = exports.incrementDeitySecretStats = exports.buffYourDeity = exports.applyDeityBaseStats = exports.getDeityBaseStats = exports.getOnBoardDeity = exports.getDeitySecret = exports.isAberration = exports.isDeityCard = void 0;
|
|
3
|
+
exports.retryDeityAwakenOnNextAberrationDeath = exports.markDeitySecretTriggered = exports.onFriendlyAberrationDied = exports.buffTeamDeities = exports.incrementDeitySecretStats = exports.buffYourDeity = exports.consumeDeityBaseStatsAssignment = exports.applyDeityBaseStats = exports.stampOnBoardDeityAuras = exports.getDeityAuraSnapshot = exports.getDeityBaseStats = exports.getOnBoardDeity = exports.getDeitySecret = exports.isAberration = exports.isDeityCard = void 0;
|
|
4
4
|
const reference_data_1 = require("@firestone-hs/reference-data");
|
|
5
5
|
const card_interface_1 = require("../cards/card.interface");
|
|
6
6
|
const _card_mappings_1 = require("../cards/impl/_card-mappings");
|
|
@@ -24,6 +24,8 @@ const getOnBoardDeity = (board, allCards) => {
|
|
|
24
24
|
return board.find((e) => (0, utils_1.hasEntityMechanic)(e, reference_data_1.GameTag.BACON_OLD_GOD, allCards) && e.health > 0 && !e.definitelyDead);
|
|
25
25
|
};
|
|
26
26
|
exports.getOnBoardDeity = getOnBoardDeity;
|
|
27
|
+
const awakeningSecrets = new WeakSet();
|
|
28
|
+
const deityBaseStatsAssigned = new WeakSet();
|
|
27
29
|
const readSecretAttack = (secret) => {
|
|
28
30
|
var _a, _b, _c;
|
|
29
31
|
return (_c = (_b = (_a = secret.tags) === null || _a === void 0 ? void 0 : _a[reference_data_1.GameTag.BACON_OLD_GOD_ATTACK]) !== null && _b !== void 0 ? _b : secret.scriptDataNum2) !== null && _c !== void 0 ? _c : 1;
|
|
@@ -48,6 +50,33 @@ const getDeityBaseStats = (hero, entity) => {
|
|
|
48
50
|
return { attack, health };
|
|
49
51
|
};
|
|
50
52
|
exports.getDeityBaseStats = getDeityBaseStats;
|
|
53
|
+
const getDeityAuraSnapshot = (entity, hero) => {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
const attack = (_a = entity.tags) === null || _a === void 0 ? void 0 : _a[reference_data_1.GameTag.BACON_OLD_GOD_ATTACK];
|
|
56
|
+
const health = (_b = entity.tags) === null || _b === void 0 ? void 0 : _b[reference_data_1.GameTag.BACON_OLD_GOD_HEALTH];
|
|
57
|
+
if (attack != null && health != null) {
|
|
58
|
+
return { attack, health: Math.max(1, health) };
|
|
59
|
+
}
|
|
60
|
+
return (0, exports.getDeityBaseStats)(hero, entity);
|
|
61
|
+
};
|
|
62
|
+
exports.getDeityAuraSnapshot = getDeityAuraSnapshot;
|
|
63
|
+
const stampOnBoardDeityAuras = (board, hero, allCards) => {
|
|
64
|
+
var _a, _b, _c;
|
|
65
|
+
for (const entity of board) {
|
|
66
|
+
if (!(0, exports.isDeityCard)(entity.cardId, allCards)) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (((_a = entity.tags) === null || _a === void 0 ? void 0 : _a[reference_data_1.GameTag.BACON_OLD_GOD_ATTACK]) != null &&
|
|
70
|
+
((_b = entity.tags) === null || _b === void 0 ? void 0 : _b[reference_data_1.GameTag.BACON_OLD_GOD_HEALTH]) != null) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const { attack, health } = (0, exports.getDeityBaseStats)(hero, entity);
|
|
74
|
+
entity.tags = (_c = entity.tags) !== null && _c !== void 0 ? _c : {};
|
|
75
|
+
entity.tags[reference_data_1.GameTag.BACON_OLD_GOD_ATTACK] = attack;
|
|
76
|
+
entity.tags[reference_data_1.GameTag.BACON_OLD_GOD_HEALTH] = health;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
exports.stampOnBoardDeityAuras = stampOnBoardDeityAuras;
|
|
51
80
|
const applyDeityBaseStats = (entity, hero) => {
|
|
52
81
|
var _a;
|
|
53
82
|
const { attack, health } = (0, exports.getDeityBaseStats)(hero, entity);
|
|
@@ -58,8 +87,17 @@ const applyDeityBaseStats = (entity, hero) => {
|
|
|
58
87
|
entity.tags = (_a = entity.tags) !== null && _a !== void 0 ? _a : {};
|
|
59
88
|
entity.tags[reference_data_1.GameTag.BACON_OLD_GOD_ATTACK] = attack;
|
|
60
89
|
entity.tags[reference_data_1.GameTag.BACON_OLD_GOD_HEALTH] = health;
|
|
90
|
+
deityBaseStatsAssigned.add(entity);
|
|
61
91
|
};
|
|
62
92
|
exports.applyDeityBaseStats = applyDeityBaseStats;
|
|
93
|
+
const consumeDeityBaseStatsAssignment = (entity) => {
|
|
94
|
+
if (!deityBaseStatsAssigned.has(entity)) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
deityBaseStatsAssigned.delete(entity);
|
|
98
|
+
return true;
|
|
99
|
+
};
|
|
100
|
+
exports.consumeDeityBaseStatsAssignment = consumeDeityBaseStatsAssignment;
|
|
63
101
|
const buffYourDeity = (hero, board, source, attack, health, gameState) => {
|
|
64
102
|
const onBoard = (0, exports.getOnBoardDeity)(board, gameState.allCards);
|
|
65
103
|
if (onBoard) {
|
|
@@ -102,7 +140,7 @@ const onFriendlyAberrationDied = (deadEntity, _deadEntityIndexFromRight, board,
|
|
|
102
140
|
return [];
|
|
103
141
|
}
|
|
104
142
|
const secret = (0, exports.getDeitySecret)(hero);
|
|
105
|
-
if (!secret || secret.triggered) {
|
|
143
|
+
if (!secret || secret.triggered || awakeningSecrets.has(secret)) {
|
|
106
144
|
return [];
|
|
107
145
|
}
|
|
108
146
|
const remaining = (secret.scriptDataNum1 || 3) - 1;
|
|
@@ -110,7 +148,11 @@ const onFriendlyAberrationDied = (deadEntity, _deadEntityIndexFromRight, board,
|
|
|
110
148
|
if (remaining > 0) {
|
|
111
149
|
return [];
|
|
112
150
|
}
|
|
113
|
-
|
|
151
|
+
if (board.length >= 7) {
|
|
152
|
+
(0, exports.retryDeityAwakenOnNextAberrationDeath)(hero);
|
|
153
|
+
return [];
|
|
154
|
+
}
|
|
155
|
+
awakeningSecrets.add(secret);
|
|
114
156
|
const cardId = resolveDeityCardId(secret, gameState);
|
|
115
157
|
const spawns = (0, deathrattle_spawns_1.spawnEntities)(cardId, 1, board, hero, otherBoard, otherHero, gameState, deadEntity.friendly, false, false, true);
|
|
116
158
|
for (const spawn of spawns) {
|
|
@@ -134,7 +176,27 @@ const onFriendlyAberrationDied = (deadEntity, _deadEntityIndexFromRight, board,
|
|
|
134
176
|
});
|
|
135
177
|
}
|
|
136
178
|
}
|
|
179
|
+
if (!spawns.length) {
|
|
180
|
+
secret.triggered = true;
|
|
181
|
+
}
|
|
137
182
|
return [...spawns];
|
|
138
183
|
};
|
|
139
184
|
exports.onFriendlyAberrationDied = onFriendlyAberrationDied;
|
|
185
|
+
const markDeitySecretTriggered = (hero) => {
|
|
186
|
+
const secret = (0, exports.getDeitySecret)(hero);
|
|
187
|
+
if (secret) {
|
|
188
|
+
secret.triggered = true;
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
exports.markDeitySecretTriggered = markDeitySecretTriggered;
|
|
192
|
+
const retryDeityAwakenOnNextAberrationDeath = (hero) => {
|
|
193
|
+
const secret = (0, exports.getDeitySecret)(hero);
|
|
194
|
+
if (!secret) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
awakeningSecrets.delete(secret);
|
|
198
|
+
secret.triggered = false;
|
|
199
|
+
secret.scriptDataNum1 = 1;
|
|
200
|
+
};
|
|
201
|
+
exports.retryDeityAwakenOnNextAberrationDeath = retryDeityAwakenOnNextAberrationDeath;
|
|
140
202
|
//# sourceMappingURL=deity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deity.js","sourceRoot":"","sources":["../../src/simulation/deity.ts"],"names":[],"mappings":";;;AAKA,iEAA8E;AAI9E,4DAAsD;AACtD,iEAA4D;AAE5D,oCAA2F;AAC3F,6DAAqD;AAErD,mCAAsC;AAE/B,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,QAAyB,EAAW,EAAE;IACjF,OAAO,IAAA,mBAAW,EAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,wBAAO,CAAC,aAAa,CAAC,CAAC;AACrE,CAAC,CAAC;AAFW,QAAA,WAAW,eAEtB;AAEK,MAAM,YAAY,GAAG,CAAC,MAAmB,EAAE,IAAqB,EAAE,SAAwB,EAAW,EAAE;IAC7G,OAAO,IAAA,uBAAe,EAAC,MAAM,EAAE,IAAI,EAAE,qBAAI,CAAC,UAAU,EAAE,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;AAChG,CAAC,CAAC;AAFW,QAAA,YAAY,gBAEvB;AAEK,MAAM,cAAc,GAAG,CAAC,IAAqB,EAA2B,EAAE;;IAChF,OAAO,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,gBAAqC,CAAC,CAA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CAAC,CAAC;AA/DW,QAAA,wBAAwB,4BA+DnC","sourcesContent":["/**\r\n * Deity / BG_OldGod secret.\r\n * After 3 friendly Aberrations die each combat, awaken C'Thun or Y'Shaarj with stored stats.\r\n * scriptDataNum1 = deaths remaining, tags BACON_OLD_GOD_ATTACK/HEALTH = atk/hp, scriptDataNum6 = deity dbfId.\r\n */\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 { BoardSecret } from '../board-secret';\r\nimport { hasOnAwaken } from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { getPlayerState, hasCorrectTribe, hasEntityMechanic, hasMechanic } from '../utils';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { modifyStats } from './stats';\r\n\r\nexport const isDeityCard = (cardId: string, allCards: AllCardsService): boolean => {\r\n\treturn hasMechanic(allCards.getCard(cardId), GameTag.BACON_OLD_GOD);\r\n};\r\n\r\nexport const isAberration = (entity: BoardEntity, hero: BgsPlayerEntity, gameState: FullGameState): boolean => {\r\n\treturn hasCorrectTribe(entity, hero, Race.ABERRATION, gameState.anomalies, gameState.allCards);\r\n};\r\n\r\nexport const getDeitySecret = (hero: BgsPlayerEntity): BoardSecret | undefined => {\r\n\treturn hero.secrets?.find((s) => s.cardId === CardIds.SecretDeityDnt_BG_OldGod);\r\n};\r\n\r\nexport const getOnBoardDeity = (board: BoardEntity[], allCards: AllCardsService): BoardEntity | undefined => {\r\n\treturn board.find(\r\n\t\t(e) => hasEntityMechanic(e, GameTag.BACON_OLD_GOD, allCards) && e.health > 0 && !e.definitelyDead,\r\n\t);\r\n};\r\n\r\nconst readSecretAttack = (secret: BoardSecret): number => {\r\n\treturn secret.tags?.[GameTag.BACON_OLD_GOD_ATTACK] ?? secret.scriptDataNum2 ?? 1;\r\n};\r\n\r\nconst readSecretHealth = (secret: BoardSecret): number => {\r\n\treturn secret.tags?.[GameTag.BACON_OLD_GOD_HEALTH] ?? secret.scriptDataNum3 ?? 1;\r\n};\r\n\r\nconst writeSecretStats = (secret: BoardSecret, attack: number, health: number): void => {\r\n\tsecret.scriptDataNum2 = attack;\r\n\tsecret.scriptDataNum3 = health;\r\n\tsecret.tags = secret.tags ?? {};\r\n\tsecret.tags[GameTag.BACON_OLD_GOD_ATTACK] = attack;\r\n\tsecret.tags[GameTag.BACON_OLD_GOD_HEALTH] = health;\r\n};\r\n\r\nexport const getDeityBaseStats = (hero: BgsPlayerEntity, entity?: BoardEntity): { attack: number; health: number } => {\r\n\tconst secret = getDeitySecret(hero);\r\n\tconst attack =\r\n\t\tsecret?.tags?.[GameTag.BACON_OLD_GOD_ATTACK] ??\r\n\t\tentity?.tags?.[GameTag.BACON_OLD_GOD_ATTACK] ??\r\n\t\tsecret?.scriptDataNum2 ??\r\n\t\t1;\r\n\tconst health = Math.max(\r\n\t\t1,\r\n\t\tsecret?.tags?.[GameTag.BACON_OLD_GOD_HEALTH] ??\r\n\t\t\tentity?.tags?.[GameTag.BACON_OLD_GOD_HEALTH] ??\r\n\t\t\tsecret?.scriptDataNum3 ??\r\n\t\t\t1,\r\n\t);\r\n\treturn { attack, health };\r\n};\r\n\r\nexport const applyDeityBaseStats = (entity: BoardEntity, hero: BgsPlayerEntity): void => {\r\n\tconst { attack, health } = getDeityBaseStats(hero, entity);\r\n\tentity.attack = attack;\r\n\tentity.maxAttack = attack;\r\n\tentity.health = health;\r\n\tentity.maxHealth = health;\r\n\tentity.tags = entity.tags ?? {};\r\n\tentity.tags[GameTag.BACON_OLD_GOD_ATTACK] = attack;\r\n\tentity.tags[GameTag.BACON_OLD_GOD_HEALTH] = health;\r\n};\r\n\r\nexport const buffYourDeity = (\r\n\thero: BgsPlayerEntity,\r\n\tboard: BoardEntity[],\r\n\tsource: BoardEntity | BoardSecret | BgsPlayerEntity,\r\n\tattack: number,\r\n\thealth: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst onBoard = getOnBoardDeity(board, gameState.allCards);\r\n\tif (onBoard) {\r\n\t\tmodifyStats(onBoard, source as BoardEntity, attack, health, board, hero, gameState);\r\n\t}\r\n\tincrementDeitySecretStats(hero, attack, health);\r\n};\r\n\r\nexport const incrementDeitySecretStats = (hero: BgsPlayerEntity, attack: number, health: number): void => {\r\n\tconst secret = getDeitySecret(hero);\r\n\tif (secret) {\r\n\t\twriteSecretStats(secret, readSecretAttack(secret) + attack, readSecretHealth(secret) + health);\r\n\t}\r\n};\r\n\r\nexport const buffTeamDeities = (\r\n\thero: BgsPlayerEntity,\r\n\tboard: BoardEntity[],\r\n\tsource: BoardEntity,\r\n\tattack: number,\r\n\thealth: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tbuffYourDeity(hero, board, source, attack, health, gameState);\r\n\tconst playerState = getPlayerState(gameState.gameState, hero);\r\n\tconst teammate = playerState?.teammate;\r\n\tif (teammate?.player) {\r\n\t\tbuffYourDeity(teammate.player, teammate.board ?? [], source, attack, health, gameState);\r\n\t}\r\n};\r\n\r\nconst resolveDeityCardId = (secret: BoardSecret, gameState: FullGameState): string => {\r\n\tconst dbfId = secret.scriptDataNum6 ?? secret.tags?.[GameTag.BACON_GLOBAL_OLD_GOD_DBID];\r\n\tif (dbfId) {\r\n\t\tconst fromDbf = gameState.allCards.getCardFromDbfId(dbfId);\r\n\t\tif (fromDbf?.id) {\r\n\t\t\treturn fromDbf.id;\r\n\t\t}\r\n\t}\r\n\treturn CardIds.Cthun_BGFYM_000;\r\n};\r\n\r\nexport const onFriendlyAberrationDied = (\r\n\tdeadEntity: BoardEntity,\r\n\t_deadEntityIndexFromRight: number,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): BoardEntity[] => {\r\n\tif (!isAberration(deadEntity, hero, gameState)) {\r\n\t\treturn [];\r\n\t}\r\n\t// 2026-09-22: This seems to be an HS bug, but for now the deity doesn't spawn when facing the ghost\r\n\t// Looks like this is an intermittent bug\r\n\t// if (hero.hpLeft <= 0 || hero.cardId === CardIds.Kelthuzad_TB_BaconShop_HERO_KelThuzad) {\r\n\t// \treturn [];\r\n\t// }\r\n\tconst secret = getDeitySecret(hero);\r\n\tif (!secret || secret.triggered) {\r\n\t\treturn [];\r\n\t}\r\n\tconst remaining = (secret.scriptDataNum1 || 3) - 1;\r\n\tsecret.scriptDataNum1 = remaining;\r\n\tif (remaining > 0) {\r\n\t\treturn [];\r\n\t}\r\n\tsecret.triggered = true;\r\n\tconst cardId = resolveDeityCardId(secret, gameState);\r\n\tconst spawns = spawnEntities(\r\n\t\tcardId,\r\n\t\t1,\r\n\t\tboard,\r\n\t\thero,\r\n\t\totherBoard,\r\n\t\totherHero,\r\n\t\tgameState,\r\n\t\tdeadEntity.friendly,\r\n\t\tfalse,\r\n\t\tfalse,\r\n\t\ttrue,\r\n\t);\r\n\tfor (const spawn of spawns) {\r\n\t\tapplyDeityBaseStats(spawn, hero);\r\n\t\tif (hero.trinkets?.some((t) => t.cardId === CardIds.EvilExperiment_BG36_MagicItem_416)) {\r\n\t\t\tspawn.reborn = true;\r\n\t\t}\r\n\t}\r\n\tif (spawns[0]) {\r\n\t\tgameState.spectator.registerPowerTarget(secret, spawns[0], board, hero, otherHero);\r\n\t}\r\n\tfor (const spawn of spawns) {\r\n\t\tconst impl = cardMappings[spawn.cardId];\r\n\t\tif (hasOnAwaken(impl)) {\r\n\t\t\timpl.onAwaken(spawn, {\r\n\t\t\t\thero,\r\n\t\t\t\tboard,\r\n\t\t\t\totherHero,\r\n\t\t\t\totherBoard,\r\n\t\t\t\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\treturn [...spawns];\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"deity.js","sourceRoot":"","sources":["../../src/simulation/de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IAAI,CAAC,EAAE;YACtB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE;gBACpB,IAAI;gBACJ,KAAK;gBACL,SAAS;gBACT,UAAU;gBACV,SAAS;aACT,CAAC,CAAC;SACH;KACD;IACD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;QACnB,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC;KACxB;IACD,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC;AACpB,CAAC,CAAC;AAxEW,QAAA,wBAAwB,4BAwEnC;AAEK,MAAM,wBAAwB,GAAG,CAAC,IAAqB,EAAQ,EAAE;IACvE,MAAM,MAAM,GAAG,IAAA,sBAAc,EAAC,IAAI,CAAC,CAAC;IACpC,IAAI,MAAM,EAAE;QACX,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC;KACxB;AACF,CAAC,CAAC;AALW,QAAA,wBAAwB,4BAKnC;AAGK,MAAM,qCAAqC,GAAG,CAAC,IAAqB,EAAQ,EAAE;IACpF,MAAM,MAAM,GAAG,IAAA,sBAAc,EAAC,IAAI,CAAC,CAAC;IACpC,IAAI,CAAC,MAAM,EAAE;QACZ,OAAO;KACP;IACD,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAChC,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,MAAM,CAAC,cAAc,GAAG,CAAC,CAAC;AAC3B,CAAC,CAAC;AARW,QAAA,qCAAqC,yCAQhD","sourcesContent":["/**\r\n * Deity / BG_OldGod secret.\r\n * After 3 friendly Aberrations die each combat, awaken C'Thun or Y'Shaarj with stored stats.\r\n * scriptDataNum1 = deaths remaining, tags BACON_OLD_GOD_ATTACK/HEALTH = atk/hp, scriptDataNum6 = deity dbfId.\r\n */\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 { BoardSecret } from '../board-secret';\r\nimport { hasOnAwaken } from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { getPlayerState, hasCorrectTribe, hasEntityMechanic, hasMechanic } from '../utils';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { modifyStats } from './stats';\r\n\r\nexport const isDeityCard = (cardId: string, allCards: AllCardsService): boolean => {\r\n\treturn hasMechanic(allCards.getCard(cardId), GameTag.BACON_OLD_GOD);\r\n};\r\n\r\nexport const isAberration = (entity: BoardEntity, hero: BgsPlayerEntity, gameState: FullGameState): boolean => {\r\n\treturn hasCorrectTribe(entity, hero, Race.ABERRATION, gameState.anomalies, gameState.allCards);\r\n};\r\n\r\nexport const getDeitySecret = (hero: BgsPlayerEntity): BoardSecret | undefined => {\r\n\treturn hero.secrets?.find((s) => s.cardId === CardIds.SecretDeityDnt_BG_OldGod);\r\n};\r\n\r\nexport const getOnBoardDeity = (board: BoardEntity[], allCards: AllCardsService): BoardEntity | undefined => {\r\n\treturn board.find(\r\n\t\t(e) => hasEntityMechanic(e, GameTag.BACON_OLD_GOD, allCards) && e.health > 0 && !e.definitelyDead,\r\n\t);\r\n};\r\n\r\nconst awakeningSecrets = new WeakSet<BoardSecret>();\r\n/** Entities whose attack/health were just set to the stored aura. The next aura pass must not add them again. */\r\nconst deityBaseStatsAssigned = new WeakSet<BoardEntity>();\r\n\r\nconst readSecretAttack = (secret: BoardSecret): number => {\r\n\treturn secret.tags?.[GameTag.BACON_OLD_GOD_ATTACK] ?? secret.scriptDataNum2 ?? 1;\r\n};\r\n\r\nconst readSecretHealth = (secret: BoardSecret): number => {\r\n\treturn secret.tags?.[GameTag.BACON_OLD_GOD_HEALTH] ?? secret.scriptDataNum3 ?? 1;\r\n};\r\n\r\nconst writeSecretStats = (secret: BoardSecret, attack: number, health: number): void => {\r\n\tsecret.scriptDataNum2 = attack;\r\n\tsecret.scriptDataNum3 = health;\r\n\tsecret.tags = secret.tags ?? {};\r\n\tsecret.tags[GameTag.BACON_OLD_GOD_ATTACK] = attack;\r\n\tsecret.tags[GameTag.BACON_OLD_GOD_HEALTH] = health;\r\n};\r\n\r\nexport const getDeityBaseStats = (hero: BgsPlayerEntity, entity?: BoardEntity): { attack: number; health: number } => {\r\n\tconst secret = getDeitySecret(hero);\r\n\tconst attack =\r\n\t\tsecret?.tags?.[GameTag.BACON_OLD_GOD_ATTACK] ??\r\n\t\tentity?.tags?.[GameTag.BACON_OLD_GOD_ATTACK] ??\r\n\t\tsecret?.scriptDataNum2 ??\r\n\t\t1;\r\n\tconst health = Math.max(\r\n\t\t1,\r\n\t\tsecret?.tags?.[GameTag.BACON_OLD_GOD_HEALTH] ??\r\n\t\t\tentity?.tags?.[GameTag.BACON_OLD_GOD_HEALTH] ??\r\n\t\t\tsecret?.scriptDataNum3 ??\r\n\t\t\t1,\r\n\t);\r\n\treturn { attack, health };\r\n};\r\n\r\n/** Aura captured when this minion was summoned. Later secret growth is a separate buff. */\r\nexport const getDeityAuraSnapshot = (\r\n\tentity: BoardEntity,\r\n\thero: BgsPlayerEntity,\r\n): { attack: number; health: number } => {\r\n\tconst attack = entity.tags?.[GameTag.BACON_OLD_GOD_ATTACK];\r\n\tconst health = entity.tags?.[GameTag.BACON_OLD_GOD_HEALTH];\r\n\tif (attack != null && health != null) {\r\n\t\treturn { attack, health: Math.max(1, health) };\r\n\t}\r\n\treturn getDeityBaseStats(hero, entity);\r\n};\r\n\r\n/** Freeze the current secret onto a deity that is already in play, before combat buffs change it. */\r\nexport const stampOnBoardDeityAuras = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\tfor (const entity of board) {\r\n\t\tif (!isDeityCard(entity.cardId, allCards)) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\t\tif (\r\n\t\t\tentity.tags?.[GameTag.BACON_OLD_GOD_ATTACK] != null &&\r\n\t\t\tentity.tags?.[GameTag.BACON_OLD_GOD_HEALTH] != null\r\n\t\t) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\t\tconst { attack, health } = getDeityBaseStats(hero, entity);\r\n\t\tentity.tags = entity.tags ?? {};\r\n\t\tentity.tags[GameTag.BACON_OLD_GOD_ATTACK] = attack;\r\n\t\tentity.tags[GameTag.BACON_OLD_GOD_HEALTH] = health;\r\n\t}\r\n};\r\n\r\nexport const applyDeityBaseStats = (entity: BoardEntity, hero: BgsPlayerEntity): void => {\r\n\tconst { attack, health } = getDeityBaseStats(hero, entity);\r\n\tentity.attack = attack;\r\n\tentity.maxAttack = attack;\r\n\tentity.health = health;\r\n\tentity.maxHealth = health;\r\n\tentity.tags = entity.tags ?? {};\r\n\tentity.tags[GameTag.BACON_OLD_GOD_ATTACK] = attack;\r\n\tentity.tags[GameTag.BACON_OLD_GOD_HEALTH] = health;\r\n\tdeityBaseStatsAssigned.add(entity);\r\n};\r\n\r\n/** True once, for the aura pass that follows a fresh stat assignment (awaken, reborn). */\r\nexport const consumeDeityBaseStatsAssignment = (entity: BoardEntity): boolean => {\r\n\tif (!deityBaseStatsAssigned.has(entity)) {\r\n\t\treturn false;\r\n\t}\r\n\tdeityBaseStatsAssigned.delete(entity);\r\n\treturn true;\r\n};\r\n\r\nexport const buffYourDeity = (\r\n\thero: BgsPlayerEntity,\r\n\tboard: BoardEntity[],\r\n\tsource: BoardEntity | BoardSecret | BgsPlayerEntity,\r\n\tattack: number,\r\n\thealth: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst onBoard = getOnBoardDeity(board, gameState.allCards);\r\n\tif (onBoard) {\r\n\t\tmodifyStats(onBoard, source as BoardEntity, attack, health, board, hero, gameState);\r\n\t}\r\n\tincrementDeitySecretStats(hero, attack, health);\r\n};\r\n\r\nexport const incrementDeitySecretStats = (hero: BgsPlayerEntity, attack: number, health: number): void => {\r\n\tconst secret = getDeitySecret(hero);\r\n\tif (secret) {\r\n\t\twriteSecretStats(secret, readSecretAttack(secret) + attack, readSecretHealth(secret) + health);\r\n\t}\r\n};\r\n\r\nexport const buffTeamDeities = (\r\n\thero: BgsPlayerEntity,\r\n\tboard: BoardEntity[],\r\n\tsource: BoardEntity,\r\n\tattack: number,\r\n\thealth: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tbuffYourDeity(hero, board, source, attack, health, gameState);\r\n\tconst playerState = getPlayerState(gameState.gameState, hero);\r\n\tconst teammate = playerState?.teammate;\r\n\tif (teammate?.player) {\r\n\t\tbuffYourDeity(teammate.player, teammate.board ?? [], source, attack, health, gameState);\r\n\t}\r\n};\r\n\r\nconst resolveDeityCardId = (secret: BoardSecret, gameState: FullGameState): string => {\r\n\tconst dbfId = secret.scriptDataNum6 ?? secret.tags?.[GameTag.BACON_GLOBAL_OLD_GOD_DBID];\r\n\tif (dbfId) {\r\n\t\tconst fromDbf = gameState.allCards.getCardFromDbfId(dbfId);\r\n\t\tif (fromDbf?.id) {\r\n\t\t\treturn fromDbf.id;\r\n\t\t}\r\n\t}\r\n\treturn CardIds.Cthun_BGFYM_000;\r\n};\r\n\r\nexport const onFriendlyAberrationDied = (\r\n\tdeadEntity: BoardEntity,\r\n\t_deadEntityIndexFromRight: number,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): BoardEntity[] => {\r\n\tif (!isAberration(deadEntity, hero, gameState)) {\r\n\t\treturn [];\r\n\t}\r\n\t// 2026-09-22: This seems to be an HS bug, but for now the deity doesn't spawn when facing the ghost\r\n\t// Looks like this is an intermittent bug\r\n\t// if (hero.hpLeft <= 0 || hero.cardId === CardIds.Kelthuzad_TB_BaconShop_HERO_KelThuzad) {\r\n\t// \treturn [];\r\n\t// }\r\n\tconst secret = getDeitySecret(hero);\r\n\tif (!secret || secret.triggered || awakeningSecrets.has(secret)) {\r\n\t\treturn [];\r\n\t}\r\n\tconst remaining = (secret.scriptDataNum1 || 3) - 1;\r\n\tsecret.scriptDataNum1 = remaining;\r\n\tif (remaining > 0) {\r\n\t\treturn [];\r\n\t}\r\n\t// A full board skips this awaken. The next friendly Aberration death tries again.\r\n\tif (board.length >= 7) {\r\n\t\tretryDeityAwakenOnNextAberrationDeath(hero);\r\n\t\treturn [];\r\n\t}\r\n\t// Keep the secret visible in the replay until the summon action is recorded.\r\n\tawakeningSecrets.add(secret);\r\n\tconst cardId = resolveDeityCardId(secret, gameState);\r\n\tconst spawns = spawnEntities(\r\n\t\tcardId,\r\n\t\t1,\r\n\t\tboard,\r\n\t\thero,\r\n\t\totherBoard,\r\n\t\totherHero,\r\n\t\tgameState,\r\n\t\tdeadEntity.friendly,\r\n\t\tfalse,\r\n\t\tfalse,\r\n\t\ttrue,\r\n\t);\r\n\tfor (const spawn of spawns) {\r\n\t\tapplyDeityBaseStats(spawn, hero);\r\n\t\tif (hero.trinkets?.some((t) => t.cardId === CardIds.EvilExperiment_BG36_MagicItem_416)) {\r\n\t\t\tspawn.reborn = true;\r\n\t\t}\r\n\t}\r\n\tif (spawns[0]) {\r\n\t\tgameState.spectator.registerPowerTarget(secret, spawns[0], board, hero, otherHero);\r\n\t}\r\n\tfor (const spawn of spawns) {\r\n\t\tconst impl = cardMappings[spawn.cardId];\r\n\t\tif (hasOnAwaken(impl)) {\r\n\t\t\timpl.onAwaken(spawn, {\r\n\t\t\t\thero,\r\n\t\t\t\tboard,\r\n\t\t\t\totherHero,\r\n\t\t\t\totherBoard,\r\n\t\t\t\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\tif (!spawns.length) {\r\n\t\tsecret.triggered = true;\r\n\t}\r\n\treturn [...spawns];\r\n};\r\n\r\nexport const markDeitySecretTriggered = (hero: BgsPlayerEntity): void => {\r\n\tconst secret = getDeitySecret(hero);\r\n\tif (secret) {\r\n\t\tsecret.triggered = true;\r\n\t}\r\n};\r\n\r\n/** Board was full, so this awaken did not happen. The next Aberration death starts the summon again. */\r\nexport const retryDeityAwakenOnNextAberrationDeath = (hero: BgsPlayerEntity): void => {\r\n\tconst secret = getDeitySecret(hero);\r\n\tif (!secret) {\r\n\t\treturn;\r\n\t}\r\n\tawakeningSecrets.delete(secret);\r\n\tsecret.triggered = false;\r\n\tsecret.scriptDataNum1 = 1;\r\n};\r\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BgsHeroPower, BgsPlayerEntity, BoardTrinket } from '../../bgs-player-entity';
|
|
2
2
|
import { BoardEntity } from '../../board-entity';
|
|
3
3
|
import { BoardSecret } from '../../board-secret';
|
|
4
|
+
export declare const copySecrets: (secrets: readonly BoardSecret[] | undefined) => readonly BoardSecret[] | undefined;
|
|
4
5
|
export interface GameAction {
|
|
5
6
|
type: 'damage' | 'attack' | 'spawn' | 'minion-death' | 'power-target' | 'start-of-combat' | 'player-attack' | 'opponent-attack';
|
|
6
7
|
playerBoard: readonly BoardEntity[];
|
|
@@ -1,14 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildGameAction = void 0;
|
|
3
|
+
exports.buildGameAction = exports.copySecrets = void 0;
|
|
4
4
|
const resolve_trinket_hero_power_1 = require("./resolve-trinket-hero-power");
|
|
5
|
+
const copySecrets = (secrets) => {
|
|
6
|
+
if (!secrets) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
return secrets.map((secret) => ({
|
|
10
|
+
entityId: secret.entityId,
|
|
11
|
+
cardId: secret.cardId,
|
|
12
|
+
triggered: secret.triggered,
|
|
13
|
+
scriptDataNum1: secret.scriptDataNum1,
|
|
14
|
+
scriptDataNum2: secret.scriptDataNum2,
|
|
15
|
+
scriptDataNum3: secret.scriptDataNum3,
|
|
16
|
+
scriptDataNum6: secret.scriptDataNum6,
|
|
17
|
+
triggersLeft: secret.triggersLeft,
|
|
18
|
+
tags: secret.tags ? { ...secret.tags } : undefined,
|
|
19
|
+
}));
|
|
20
|
+
};
|
|
21
|
+
exports.copySecrets = copySecrets;
|
|
5
22
|
const buildGameAction = (playerHero, opponentHero, action) => {
|
|
6
23
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
|
|
7
24
|
const isPlayerSireD = (_a = playerHero === null || playerHero === void 0 ? void 0 : playerHero.cardId) === null || _a === void 0 ? void 0 : _a.startsWith("BG24_HERO_100");
|
|
8
25
|
const isOpponentSireD = (_b = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.cardId) === null || _b === void 0 ? void 0 : _b.startsWith("BG24_HERO_100");
|
|
9
26
|
const result = {
|
|
10
27
|
...action,
|
|
11
|
-
playerSecrets:
|
|
28
|
+
playerSecrets: playerHero
|
|
29
|
+
? (0, exports.copySecrets)(((_c = playerHero.secrets) !== null && _c !== void 0 ? _c : []).filter((s) => !s.triggered))
|
|
30
|
+
: undefined,
|
|
12
31
|
playerCardId: playerHero === null || playerHero === void 0 ? void 0 : playerHero.cardId,
|
|
13
32
|
playerEntityId: playerHero === null || playerHero === void 0 ? void 0 : playerHero.entityId,
|
|
14
33
|
playerHeroPowerCardId: (_g = (_d = (0, resolve_trinket_hero_power_1.resolveTrinketHeroPowerCardId)(playerHero === null || playerHero === void 0 ? void 0 : playerHero.trinkets)) !== null && _d !== void 0 ? _d : (isPlayerSireD ? (_f = (_e = playerHero.questRewardEntities) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.cardId : null)) !== null && _g !== void 0 ? _g : (_h = playerHero === null || playerHero === void 0 ? void 0 : playerHero.heroPowers[0]) === null || _h === void 0 ? void 0 : _h.cardId,
|
|
@@ -25,7 +44,9 @@ const buildGameAction = (playerHero, opponentHero, action) => {
|
|
|
25
44
|
? null
|
|
26
45
|
: (_w = (_v = (_u = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewardEntities) === null || _u === void 0 ? void 0 : _u[0]) === null || _v === void 0 ? void 0 : _v.scriptDataNum1) !== null && _w !== void 0 ? _w : 0,
|
|
27
46
|
playerTrinkets: playerHero === null || playerHero === void 0 ? void 0 : playerHero.trinkets,
|
|
28
|
-
opponentSecrets:
|
|
47
|
+
opponentSecrets: opponentHero
|
|
48
|
+
? (0, exports.copySecrets)(((_x = opponentHero.secrets) !== null && _x !== void 0 ? _x : []).filter((s) => !s.triggered))
|
|
49
|
+
: undefined,
|
|
29
50
|
opponentCardId: opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.cardId,
|
|
30
51
|
opponentEntityId: opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.entityId,
|
|
31
52
|
opponentHeroPowerCardId: (_3 = (_1 = (_y = (0, resolve_trinket_hero_power_1.resolveTrinketHeroPowerCardId)(opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.trinkets)) !== null && _y !== void 0 ? _y : (isOpponentSireD ? (_0 = (_z = opponentHero.questRewardEntities) === null || _z === void 0 ? void 0 : _z[0]) === null || _0 === void 0 ? void 0 : _0.cardId : null)) !== null && _1 !== void 0 ? _1 : (_2 = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.heroPowers[0]) === null || _2 === void 0 ? void 0 : _2.cardId) !== null && _3 !== void 0 ? _3 : opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.heroPowerId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"game-action.js","sourceRoot":"","sources":["../../../src/simulation/spectator/game-action.ts"],"names":[],"mappings":";;;AAIA,6EAA6E;
|
|
1
|
+
{"version":3,"file":"game-action.js","sourceRoot":"","sources":["../../../src/simulation/spectator/game-action.ts"],"names":[],"mappings":";;;AAIA,6EAA6E;AAGtE,MAAM,WAAW,GAAG,CAAC,OAA2C,EAAsC,EAAE;IAC9G,IAAI,CAAC,OAAO,EAAE;QACb,OAAO,SAAS,CAAC;KACjB;IAC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C,MAAA,MAAA,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,mBAAmB,0CAAG,CAAC,CAAC,0CAAE,MAAM,mCAAI,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,YAAY,0CAAG,CAAC,CAAC;QACrF,sBAAsB,EACrB,eAAe,IAAI,CAAA,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,mBAAmB,0CAAE,MAAM,IAAG,CAAC;YAC/D,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,OAAA,OAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,mBAAmB,4CAAG,CAAC,CAAC,4CAAE,QAAQ;QACpD,kBAAkB,EACjB,eAAe,IAAI,CAAA,OAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,mBAAmB,4CAAE,MAAM,IAAG,CAAC;YAC/D,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,OAAA,OAAA,OAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,mBAAmB,4CAAG,CAAC,CAAC,4CAAE,cAAc,qCAAI,CAAC;QAC/D,gBAAgB,EAAE,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,QAAQ;KAC1B,CAAC;IAChB,OAAO,MAAM,CAAC;AACf,CAAC,CAAC;AAlEW,QAAA,eAAe,mBAkE1B","sourcesContent":["import { CardIds } from '../../services/card-ids';\r\nimport { BgsHeroPower, BgsPlayerEntity, BoardTrinket } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { BoardSecret } from '../../board-secret';\r\nimport { resolveTrinketHeroPowerCardId } from './resolve-trinket-hero-power';\r\n\r\n/** Detach from the live secret. Combat mutates scriptDataNum and tags in place. */\r\nexport const copySecrets = (secrets: readonly BoardSecret[] | undefined): readonly BoardSecret[] | undefined => {\r\n\tif (!secrets) {\r\n\t\treturn undefined;\r\n\t}\r\n\treturn secrets.map((secret) => ({\r\n\t\tentityId: secret.entityId,\r\n\t\tcardId: secret.cardId,\r\n\t\ttriggered: secret.triggered,\r\n\t\tscriptDataNum1: secret.scriptDataNum1,\r\n\t\tscriptDataNum2: secret.scriptDataNum2,\r\n\t\tscriptDataNum3: secret.scriptDataNum3,\r\n\t\tscriptDataNum6: secret.scriptDataNum6,\r\n\t\ttriggersLeft: secret.triggersLeft,\r\n\t\ttags: secret.tags ? { ...secret.tags } : undefined,\r\n\t}));\r\n};\r\n\r\nexport interface GameAction {\r\n\ttype:\r\n\t\t| 'damage'\r\n\t\t| 'attack'\r\n\t\t| 'spawn'\r\n\t\t| 'minion-death'\r\n\t\t| 'power-target'\r\n\t\t| 'start-of-combat'\r\n\t\t| 'player-attack'\r\n\t\t| 'opponent-attack';\r\n\tplayerBoard: readonly BoardEntity[];\r\n\tplayerHand: readonly BoardEntity[];\r\n\tplayerSecrets: readonly BoardSecret[];\r\n\tplayerTrinkets: readonly BoardTrinket[];\r\n\topponentBoard: readonly BoardEntity[];\r\n\topponentHand: readonly BoardEntity[];\r\n\topponentSecrets: readonly BoardSecret[];\r\n\topponentTrinkets: readonly BoardTrinket[];\r\n\tplayerCardId: string;\r\n\tplayerEntityId: number;\r\n\tplayerHeroPowerCardId: string;\r\n\tplayerHeroPowerEntityId: number;\r\n\tplayerHeroPowerUsed: boolean;\r\n\tplayerHeroPowers: readonly BgsHeroPower[];\r\n\topponentCardId: string;\r\n\topponentEntityId: number;\r\n\topponentHeroPowerCardId: string;\r\n\topponentHeroPowerEntityId: number;\r\n\topponentHeroPowerUsed: boolean;\r\n\topponentHeroPowers: readonly BgsHeroPower[];\r\n\tplayerRewardCardId: string;\r\n\tplayerRewardEntityId: number;\r\n\tplayerRewardData: number;\r\n\topponentRewardCardId: string;\r\n\topponentRewardEntityId: number;\r\n\topponentRewardData: number;\r\n\tsourceEntityId?: number;\r\n\t/** @deprecated */\r\n\ttargetEntityId?: number;\r\n\ttargetEntityIds?: number[];\r\n\r\n\tdamages?: Damage[];\r\n\tspawns?: readonly BoardEntity[];\r\n\tdeaths?: readonly BoardEntity[];\r\n\tdeadMinionsPositionsOnBoard?: readonly number[];\r\n}\r\n\r\nexport interface Damage {\r\n\treadonly sourceEntityId?: number;\r\n\treadonly targetEntityId?: number;\r\n\treadonly damage?: number;\r\n}\r\n\r\nexport const buildGameAction = (\r\n\tplayerHero: BgsPlayerEntity,\r\n\topponentHero: BgsPlayerEntity,\r\n\taction: Partial<GameAction>,\r\n): GameAction => {\r\n\tconst isPlayerSireD = playerHero?.cardId?.startsWith(CardIds.SireDenathrius_BG24_HERO_100);\r\n\tconst isOpponentSireD = opponentHero?.cardId?.startsWith(CardIds.SireDenathrius_BG24_HERO_100);\r\n\tconst result: GameAction = {\r\n\t\t...action,\r\n\r\n\t\tplayerSecrets: playerHero\r\n\t\t\t? copySecrets((playerHero.secrets ?? []).filter((s) => !s.triggered))\r\n\t\t\t: undefined,\r\n\t\tplayerCardId: playerHero?.cardId,\r\n\t\tplayerEntityId: playerHero?.entityId,\r\n\r\n\t\tplayerHeroPowerCardId:\r\n\t\t\tresolveTrinketHeroPowerCardId(playerHero?.trinkets) ??\r\n\t\t\t(isPlayerSireD ? playerHero.questRewardEntities?.[0]?.cardId : null) ??\r\n\t\t\tplayerHero?.heroPowers[0]?.cardId,\r\n\t\tplayerHeroPowerEntityId: 100000002,\r\n\t\tplayerHeroPowerUsed: playerHero?.heroPowers[0]?.used,\r\n\t\tplayerHeroPowers: playerHero?.heroPowers,\r\n\r\n\t\tplayerRewardCardId:\r\n\t\t\tisPlayerSireD && playerHero?.questRewardEntities?.length < 2\r\n\t\t\t\t? null\r\n\t\t\t\t: playerHero?.questRewardEntities?.[1]?.cardId ?? playerHero?.questRewards?.[0],\r\n\t\tplayerRewardEntityId:\r\n\t\t\tisPlayerSireD && playerHero?.questRewardEntities?.length < 2\r\n\t\t\t\t? null\r\n\t\t\t\t: playerHero?.questRewardEntities?.[1]?.entityId,\r\n\t\tplayerRewardData:\r\n\t\t\tisPlayerSireD && playerHero?.questRewardEntities?.length < 2\r\n\t\t\t\t? null\r\n\t\t\t\t: playerHero?.questRewardEntities?.[0]?.scriptDataNum1 ?? 0,\r\n\t\tplayerTrinkets: playerHero?.trinkets,\r\n\r\n\t\topponentSecrets: opponentHero\r\n\t\t\t? copySecrets((opponentHero.secrets ?? []).filter((s) => !s.triggered))\r\n\t\t\t: undefined,\r\n\t\topponentCardId: opponentHero?.cardId,\r\n\t\topponentEntityId: opponentHero?.entityId,\r\n\t\topponentHeroPowerCardId:\r\n\t\t\tresolveTrinketHeroPowerCardId(opponentHero?.trinkets) ??\r\n\t\t\t(isOpponentSireD ? opponentHero.questRewardEntities?.[0]?.cardId : null) ??\r\n\t\t\topponentHero?.heroPowers[0]?.cardId ??\r\n\t\t\topponentHero?.heroPowerId,\r\n\t\topponentHeroPowerEntityId: 200000002,\r\n\t\topponentHeroPowerUsed: opponentHero?.heroPowerUsed,\r\n\t\topponentHeroPowers: opponentHero?.heroPowers,\r\n\t\topponentRewardCardId:\r\n\t\t\tisOpponentSireD && opponentHero?.questRewardEntities?.length < 2\r\n\t\t\t\t? null\r\n\t\t\t\t: opponentHero?.questRewardEntities?.[1]?.cardId ?? opponentHero?.questRewards?.[0],\r\n\t\topponentRewardEntityId:\r\n\t\t\tisOpponentSireD && opponentHero?.questRewardEntities?.length < 2\r\n\t\t\t\t? null\r\n\t\t\t\t: opponentHero?.questRewardEntities?.[1]?.entityId,\r\n\t\topponentRewardData:\r\n\t\t\tisOpponentSireD && opponentHero?.questRewardEntities?.length < 2\r\n\t\t\t\t? null\r\n\t\t\t\t: opponentHero?.questRewardEntities?.[0]?.scriptDataNum1 ?? 0,\r\n\t\topponentTrinkets: opponentHero?.trinkets,\r\n\t} as GameAction;\r\n\treturn result;\r\n};\r\n"]}
|
|
@@ -304,6 +304,8 @@ class Spectator {
|
|
|
304
304
|
deaths: this.sanitize(actions[i].deaths),
|
|
305
305
|
playerTrinkets: this.sanitizeTrinkets(actions[i].playerTrinkets),
|
|
306
306
|
opponentTrinkets: this.sanitizeTrinkets(actions[i].opponentTrinkets),
|
|
307
|
+
playerSecrets: (0, game_action_1.copySecrets)(actions[i].playerSecrets),
|
|
308
|
+
opponentSecrets: (0, game_action_1.copySecrets)(actions[i].opponentSecrets),
|
|
307
309
|
};
|
|
308
310
|
const lastAction = result.length > 0 ? result[result.length - 1] : null;
|
|
309
311
|
if (lastAction) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spectator.js","sourceRoot":"","sources":["../../../src/simulation/spectator/spectator.ts"],"names":[],"mappings":";;;AAIA,+CAA4D;AAG5D,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB,MAAM,aAAa,GAAiB,EAAE,CAAC;AACvC,MAAM,aAAa,GAAiB,EAAE,CAAC;AAEvC,MAAa,SAAS;IAWrB,YAA6B,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;QAFrC,cAAS,GAAG,KAAK,CAAC;QAGzB,IAAI,OAAO,EAAE;YACZ,IAAI,CAAC,uBAAuB,GAAG,EAAE,CAAC;YAClC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;YACrB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;YACtB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;SACtB;aAAM;YACN,IAAI,CAAC,uBAAuB,GAAG,aAAa,CAAC;YAC7C,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC;YAChC,IAAI,CAAC,WAAW,GAAG,aAAa,CAAC;YACjC,IAAI,CAAC,WAAW,GAAG,aAAa,CAAC;SACjC;IACF,CAAC;IAEM,cAAc;QACpB,IAAI,IAAI,CAAC,OAAO,EAAE;YACjB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;SACtB;IACF,CAAC;IAEM,aAAa;QACnB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,IAAI,CAAC,OAAO,EAAE;YACjB,IAAI,CAAC,uBAAuB,GAAG,EAAE,CAAC;SACl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E,MAAM,CAAA,EAAE;YACtB,OAAO,SAAS,CAAC;SACjB;QACD,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAC1B,CAAC,CAAC,EAAE,EAAE,CACL,CAAC;YACA,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,cAAc,EAAE,CAAC,CAAC,cAAc;YAChC,cAAc,EAAE,CAAC,CAAC,cAAc;YAChC,IAAI,EAAE,CAAC,CAAC,IAAI;SACK,CAAA,CACnB,CAAC;QACF,OAAO,MAAM,CAAC;IACf,CAAC;CACD;AA/gBD,8BA+gBC;AAGY,QAAA,aAAa,GAAG,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC","sourcesContent":["import { BgsGameState } from '../../bgs-battle-info';\r\nimport { BgsPlayerEntity, BoardTrinket } from '../../bgs-player-entity';\r\nimport { BoardEnchantment, BoardEntity } from '../../board-entity';\r\nimport { BoardSecret } from '../../board-secret';\r\nimport { GameAction, buildGameAction } from './game-action';\r\nimport { GameSample } from './game-sample';\r\n\r\nconst MAX_SAMPLES = 1;\r\nconst EMPTY_ACTIONS: GameAction[] = [];\r\nconst EMPTY_SAMPLES: GameSample[] = [];\r\n\r\nexport class Spectator {\r\n\tprivate actionsForCurrentBattle: GameAction[];\r\n\tprivate wonBattles: GameSample[];\r\n\tprivate tiedBattles: GameSample[];\r\n\tprivate lostBattles: GameSample[];\r\n\t// Recording every action is a significant part of the total simulation cost, so the\r\n\t// main simulation loop runs with recording off. Outcome samples are captured post-hoc:\r\n\t// once the outcome distribution is known, a few battles are re-run with recording\r\n\t// explicitly turned on until each outcome bucket that occurred has a sample.\r\n\tprivate recording = false;\r\n\r\n\tconstructor(private readonly enabled: boolean) {\r\n\t\tif (enabled) {\r\n\t\t\tthis.actionsForCurrentBattle = [];\r\n\t\t\tthis.wonBattles = [];\r\n\t\t\tthis.tiedBattles = [];\r\n\t\t\tthis.lostBattles = [];\r\n\t\t} else {\r\n\t\t\tthis.actionsForCurrentBattle = EMPTY_ACTIONS;\r\n\t\t\tthis.wonBattles = EMPTY_SAMPLES;\r\n\t\t\tthis.tiedBattles = EMPTY_SAMPLES;\r\n\t\t\tthis.lostBattles = EMPTY_SAMPLES;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic startRecording(): void {\r\n\t\tif (this.enabled) {\r\n\t\t\tthis.recording = true;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic stopRecording(): void {\r\n\t\tthis.recording = false;\r\n\t\tif (this.enabled) {\r\n\t\t\tthis.actionsForCurrentBattle = [];\r\n\t\t}\r\n\t}\r\n\r\n\tpublic hasSampleFor(result: 'won' | 'lost' | 'tied'): boolean {\r\n\t\tswitch (result) {\r\n\t\t\tcase 'won':\r\n\t\t\t\treturn this.wonBattles.length >= MAX_SAMPLES;\r\n\t\t\tcase 'lost':\r\n\t\t\t\treturn this.lostBattles.length >= MAX_SAMPLES;\r\n\t\t\tcase 'tied':\r\n\t\t\t\treturn this.tiedBattles.length >= MAX_SAMPLES;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic prune(): void {\r\n\t\tthis.wonBattles = this.wonBattles.slice(0, MAX_SAMPLES);\r\n\t\tthis.lostBattles = this.lostBattles.slice(0, MAX_SAMPLES);\r\n\t\tthis.tiedBattles = this.tiedBattles.slice(0, MAX_SAMPLES);\r\n\t}\r\n\r\n\tpublic buildOutcomeSamples(gameState: BgsGameState): {\r\n\t\twon: readonly GameSample[];\r\n\t\tlost: readonly GameSample[];\r\n\t\ttied: readonly GameSample[];\r\n\t} {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn {\r\n\t\t\t\twon: [],\r\n\t\t\t\tlost: [],\r\n\t\t\t\ttied: [],\r\n\t\t\t};\r\n\t\t}\r\n\t\treturn {\r\n\t\t\twon: this.wonBattles?.map((battle) => this.cleanUpActions(battle, gameState)),\r\n\t\t\tlost: this.lostBattles?.map((battle) => this.cleanUpActions(battle, gameState)),\r\n\t\t\ttied: this.tiedBattles?.map((battle) => this.cleanUpActions(battle, gameState)),\r\n\t\t};\r\n\t}\r\n\r\n\tprivate cleanUpActions(battle: GameSample, gameState: BgsGameState): GameSample {\r\n\t\tconst collapsed = this.collapseActions(battle.actions);\r\n\t\tconst result: GameSample = {\r\n\t\t\t...battle,\r\n\t\t\tactions: collapsed,\r\n\t\t\tanomalies: gameState.anomalies,\r\n\t\t};\r\n\t\treturn result;\r\n\t}\r\n\r\n\tpublic commitBattleResult(result: 'won' | 'lost' | 'tied'): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!this.recording) {\r\n\t\t\tthis.actionsForCurrentBattle = [];\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst actionsForBattle = this.actionsForCurrentBattle;\r\n\t\tthis.actionsForCurrentBattle = [];\r\n\r\n\t\tconst battle: GameSample = {\r\n\t\t\tactions: actionsForBattle,\r\n\t\t\tanomalies: [],\r\n\t\t};\r\n\t\t// Only keep the sample if this bucket still needs one (prune() would discard the\r\n\t\t// extras anyway, and holding on to them wastes memory)\r\n\t\tswitch (result) {\r\n\t\t\tcase 'won':\r\n\t\t\t\tif (this.wonBattles.length < MAX_SAMPLES) {\r\n\t\t\t\t\tthis.wonBattles.push(battle);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'lost':\r\n\t\t\t\tif (this.lostBattles.length < MAX_SAMPLES) {\r\n\t\t\t\t\tthis.lostBattles.push(battle);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'tied':\r\n\t\t\t\tif (this.tiedBattles.length < MAX_SAMPLES) {\r\n\t\t\t\t\tthis.tiedBattles.push(battle);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic registerAttack(\r\n\t\tattackingEntity: BoardEntity,\r\n\t\tdefendingEntity: BoardEntity,\r\n\t\tattackingBoard: readonly BoardEntity[],\r\n\t\tdefendingBoard: readonly BoardEntity[],\r\n\t\tattackingBoardHero: BgsPlayerEntity,\r\n\t\tdefendingBoardHero: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!this.recording) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// console.debug(\r\n\t\t// \t'\\n register attack',\r\n\t\t// \tstringifySimple(attackingBoard),\r\n\t\t// \t'\\n',\r\n\t\t// \tstringifySimple(defendingBoard),\r\n\t\t// \t'\\n',\r\n\t\t// \tattackingBoard.find((e) => e.entityId === 2441),\r\n\t\t// \t'\\n',\r\n\t\t// \tattackingBoard.find((e) => e.entityId === 2442),\r\n\t\t// );\r\n\t\tconst isAttackerFriendly = attackingBoard.every((entity) => entity.friendly);\r\n\t\tconst playerHero = isAttackerFriendly ? attackingBoardHero : defendingBoardHero;\r\n\t\tconst opponentHero = isAttackerFriendly ? defendingBoardHero : attackingBoardHero;\r\n\t\tconst friendlyBoard = isAttackerFriendly ? attackingBoard : defendingBoard;\r\n\t\tconst opponentBoard = isAttackerFriendly ? defendingBoard : attackingBoard;\r\n\t\tconst action: GameAction = buildGameAction(playerHero, opponentHero, {\r\n\t\t\ttype: 'attack',\r\n\t\t\tsourceEntityId: attackingEntity.entityId,\r\n\t\t\ttargetEntityId: defendingEntity.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\tplayerHand: this.sanitize(playerHero.hand),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\topponentHand: this.sanitize(opponentHero.hand),\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerStartOfCombat(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tfriendlyHero: BgsPlayerEntity,\r\n\t\topponentHero: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!this.recording) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(friendlyHero, opponentHero, {\r\n\t\t\ttype: 'start-of-combat',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: this.sanitize(friendlyHero.hand),\r\n\t\t\topponentHand: this.sanitize(opponentHero.hand),\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerPlayerAttack(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tdamage: number,\r\n\t): void {\r\n\t\tif (!this.recording) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'player-attack',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tdamage: damage,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerOpponentAttack(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tdamage: number,\r\n\t): void {\r\n\t\tif (!this.recording) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'opponent-attack',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tdamage: damage,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerDamageDealt(\r\n\t\tdamagingEntity: BoardEntity,\r\n\t\tdamagedEntity: BoardEntity,\r\n\t\tdamageTaken: number,\r\n\t\tdamagedEntityBoard: BoardEntity[],\r\n\t): void {\r\n\t\tif (!this.recording) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!damagingEntity.entityId) {\r\n\t\t\t// console.error('missing damaging entity id', damagingEntity.cardId);\r\n\t\t}\r\n\t\tconst friendlyBoard = damagedEntityBoard.every((entity) => entity.friendly) ? damagedEntityBoard : null;\r\n\t\tconst opponentBoard = damagedEntityBoard.every((entity) => !entity.friendly) ? damagedEntityBoard : null;\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'damage',\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tsourceEntityId: damagingEntity.entityId,\r\n\t\t\t\t\ttargetEntityId: damagedEntity.entityId,\r\n\t\t\t\t\tdamage: damageTaken,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerPowerTarget(\r\n\t\tsourceEntity: BoardEntity | BgsPlayerEntity | BoardSecret | BoardTrinket | BoardEnchantment,\r\n\t\ttargetEntity: BoardEntity | BgsPlayerEntity,\r\n\t\ttargetBoard: BoardEntity[],\r\n\t\thero1: BgsPlayerEntity,\r\n\t\thero2: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!this.recording) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!targetEntity) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// console.log('registerPowerTarget', stringifySimpleCard(sourceEntity), stringifySimpleCard(targetEntity), new Error().stack);\r\n\t\tconst friendlyBoard = targetBoard?.every((entity) => entity.friendly) ? targetBoard : null;\r\n\t\tconst opponentBoard = targetBoard?.every((entity) => !entity.friendly) ? targetBoard : null;\r\n\t\tconst friendlyHero = hero1?.friendly ? hero1 : hero2?.friendly ? hero2 : null;\r\n\t\tconst opponentHero = hero1?.friendly ? hero2 : hero2?.friendly ? hero1 : null;\r\n\t\tconst action: GameAction = buildGameAction(friendlyHero, opponentHero, {\r\n\t\t\ttype: 'power-target',\r\n\t\t\tsourceEntityId:\r\n\t\t\t\t(sourceEntity as BoardEnchantment)?.originEntityId ?? (sourceEntity as BoardEntity).entityId,\r\n\t\t\ttargetEntityId: targetEntity.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: this.sanitize(friendlyHero?.hand),\r\n\t\t\topponentHand: this.sanitize(opponentHero?.hand),\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerPowerTargets(\r\n\t\tsourceEntity: BoardEntity | BgsPlayerEntity | BoardSecret | BoardTrinket,\r\n\t\ttargetEntities: (BoardEntity | BgsPlayerEntity)[],\r\n\t\ttargetBoard: BoardEntity[],\r\n\t\thero1: BgsPlayerEntity,\r\n\t\thero2: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!this.recording) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!targetEntities?.length) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// console.log('registerPowerTarget', stringifySimpleCard(sourceEntity), stringifySimpleCard(targetEntity), new Error().stack);\r\n\t\tconst friendlyBoard = targetBoard?.every((entity) => entity.friendly) ? targetBoard : null;\r\n\t\tconst opponentBoard = targetBoard?.every((entity) => !entity.friendly) ? targetBoard : null;\r\n\t\tconst friendlyHero = hero1?.friendly ? hero1 : hero2?.friendly ? hero2 : null;\r\n\t\tconst opponentHero = hero1?.friendly ? hero2 : hero2?.friendly ? hero1 : null;\r\n\t\tconst action: GameAction = buildGameAction(friendlyHero, opponentHero, {\r\n\t\t\ttype: 'power-target',\r\n\t\t\tsourceEntityId: sourceEntity.entityId,\r\n\t\t\ttargetEntityIds: targetEntities.map((entity) => entity.entityId),\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: this.sanitize(friendlyHero?.hand),\r\n\t\t\topponentHand: this.sanitize(opponentHero?.hand),\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerMinionsSpawn(\r\n\t\tsourceEntity: BoardEntity | BgsPlayerEntity | BoardTrinket,\r\n\t\tboardOnWhichToSpawn: BoardEntity[],\r\n\t\tspawnedEntities: readonly BoardEntity[],\r\n\t): void {\r\n\t\tif (!this.recording) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!spawnedEntities || spawnedEntities.length === 0) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (!sourceEntity?.entityId) {\r\n\t\t\t// console.error('missing spawn source entity id', sourceEntity);\r\n\t\t}\r\n\t\tconst friendlyBoard = boardOnWhichToSpawn.every((entity) => entity.friendly) ? boardOnWhichToSpawn : null;\r\n\t\tconst opponentBoard = boardOnWhichToSpawn.every((entity) => !entity.friendly) ? boardOnWhichToSpawn : null;\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'spawn',\r\n\t\t\tspawns: this.sanitize(spawnedEntities),\r\n\t\t\tsourceEntityId: sourceEntity?.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerDeadEntities(\r\n\t\tdeadMinionIndexes1: number[],\r\n\t\tdeadEntities1: BoardEntity[],\r\n\t\tboard1: BoardEntity[],\r\n\t\tdeadMinionIndexes2: number[],\r\n\t\tdeadEntities2: BoardEntity[],\r\n\t\tboard2: BoardEntity[],\r\n\t): void {\r\n\t\tif (!this.recording) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst deaths = [...(deadEntities1 || []), ...(deadEntities2 || [])];\r\n\t\tif (!deaths || deaths.length === 0) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'minion-death',\r\n\t\t\tdeaths: this.sanitize(deaths),\r\n\t\t\tdeadMinionsPositionsOnBoard: [\r\n\t\t\t\t...(deadMinionIndexes1 || []).map((i) => board1.length - i),\r\n\t\t\t\t...(deadMinionIndexes2 || []).map((i) => board2.length - i),\r\n\t\t\t],\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tprivate addAction(action: GameAction) {\r\n\t\tthis.actionsForCurrentBattle.push(action);\r\n\t}\r\n\r\n\tprivate collapseActions(actions: readonly GameAction[]): readonly GameAction[] {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\t\tif (!actions || actions.length === 0) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\t\tconst result: GameAction[] = [];\r\n\t\tfor (let i = 0; i < actions.length; i++) {\r\n\t\t\tconst action: GameAction = {\r\n\t\t\t\t...actions[i],\r\n\t\t\t\tplayerBoard: this.sanitize(actions[i].playerBoard),\r\n\t\t\t\topponentBoard: this.sanitize(actions[i].opponentBoard),\r\n\t\t\t\tplayerHand: this.sanitize(actions[i].playerHand),\r\n\t\t\t\topponentHand: this.sanitize(actions[i].opponentHand),\r\n\t\t\t\t// spawns: this.sanitize(actions[i].spawns),\r\n\t\t\t\tdeaths: this.sanitize(actions[i].deaths),\r\n\t\t\t\tplayerTrinkets: this.sanitizeTrinkets(actions[i].playerTrinkets),\r\n\t\t\t\topponentTrinkets: this.sanitizeTrinkets(actions[i].opponentTrinkets),\r\n\t\t\t};\r\n\t\t\t// action.playerBoard && console.debug('\\naction playerboard', stringifySimple(action.playerBoard));\r\n\t\t\tconst lastAction = result.length > 0 ? result[result.length - 1] : null;\r\n\r\n\t\t\tif (lastAction) {\r\n\t\t\t\taction.playerBoard = action.playerBoard ?? lastAction.playerBoard;\r\n\t\t\t\taction.opponentBoard = action.opponentBoard ?? lastAction.opponentBoard;\r\n\t\t\t\taction.playerHand = action.playerHand ?? lastAction.playerHand;\r\n\t\t\t\taction.opponentHand = action.opponentHand ?? lastAction.opponentHand;\r\n\t\t\t\taction.playerSecrets = action.playerSecrets ?? lastAction.playerSecrets;\r\n\t\t\t\taction.opponentSecrets = action.opponentSecrets ?? lastAction.opponentSecrets;\r\n\t\t\t\taction.playerRewardCardId = action.playerRewardCardId ?? lastAction.playerRewardCardId;\r\n\t\t\t\taction.playerRewardEntityId = action.playerRewardEntityId ?? lastAction.playerRewardEntityId;\r\n\t\t\t\taction.playerRewardData = action.playerRewardData ?? lastAction.playerRewardData;\r\n\t\t\t\taction.opponentRewardCardId = action.opponentRewardCardId ?? lastAction.opponentRewardCardId;\r\n\t\t\t\taction.opponentRewardEntityId = action.opponentRewardEntityId ?? lastAction.opponentRewardEntityId;\r\n\t\t\t\taction.opponentRewardData = action.opponentRewardData ?? lastAction.opponentRewardData;\r\n\t\t\t\taction.playerCardId = action.playerCardId ?? lastAction.playerCardId;\r\n\t\t\t\taction.playerEntityId = action.playerEntityId ?? lastAction.playerEntityId;\r\n\t\t\t\taction.playerHeroPowerCardId = action.playerHeroPowerCardId ?? lastAction.playerHeroPowerCardId;\r\n\t\t\t\taction.playerHeroPowerEntityId = action.playerHeroPowerEntityId ?? lastAction.playerHeroPowerEntityId;\r\n\t\t\t\taction.playerHeroPowerUsed = action.playerHeroPowerUsed ?? lastAction.playerHeroPowerUsed;\r\n\t\t\t\taction.opponentCardId = action.opponentCardId ?? lastAction.opponentCardId;\r\n\t\t\t\taction.opponentEntityId = action.opponentEntityId ?? lastAction.opponentEntityId;\r\n\t\t\t\taction.opponentHeroPowerCardId = action.opponentHeroPowerCardId ?? lastAction.opponentHeroPowerCardId;\r\n\t\t\t\taction.opponentHeroPowerEntityId =\r\n\t\t\t\t\taction.opponentHeroPowerEntityId ?? lastAction.opponentHeroPowerEntityId;\r\n\t\t\t\taction.opponentHeroPowerUsed = action.opponentHeroPowerUsed ?? lastAction.opponentHeroPowerUsed;\r\n\t\t\t\taction.playerTrinkets = action.playerTrinkets ?? lastAction.playerTrinkets;\r\n\t\t\t\taction.opponentTrinkets = action.opponentTrinkets ?? lastAction.opponentTrinkets;\r\n\t\t\t}\r\n\r\n\t\t\tif (lastAction && action.type === 'damage' && lastAction.type === 'attack') {\r\n\t\t\t\tlastAction.damages = lastAction.damages || [];\r\n\t\t\t\tlastAction.damages.push({\r\n\t\t\t\t\tdamage: action.damages[0].damage,\r\n\t\t\t\t\tsourceEntityId: action.damages[0].sourceEntityId,\r\n\t\t\t\t\ttargetEntityId: action.damages[0].targetEntityId,\r\n\t\t\t\t});\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t\tlastAction.playerTrinkets = action.playerTrinkets;\r\n\t\t\t\tlastAction.opponentTrinkets = action.opponentTrinkets;\r\n\t\t\t} else if (lastAction && action.type === 'damage' && lastAction.type === 'damage') {\r\n\t\t\t\tlastAction.damages = lastAction.damages || [];\r\n\t\t\t\tlastAction.damages.push({\r\n\t\t\t\t\tdamage: action.damages[0].damage,\r\n\t\t\t\t\tsourceEntityId: action.damages[0].sourceEntityId,\r\n\t\t\t\t\ttargetEntityId: action.damages[0].targetEntityId,\r\n\t\t\t\t});\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t\tlastAction.playerTrinkets = action.playerTrinkets;\r\n\t\t\t\tlastAction.opponentTrinkets = action.opponentTrinkets;\r\n\t\t\t} else if (\r\n\t\t\t\tlastAction &&\r\n\t\t\t\taction.type === 'power-target' &&\r\n\t\t\t\tlastAction.type === 'power-target' &&\r\n\t\t\t\taction.sourceEntityId === lastAction.sourceEntityId\r\n\t\t\t) {\r\n\t\t\t\tlastAction.targetEntityIds =\r\n\t\t\t\t\tlastAction.targetEntityIds ?? (lastAction.targetEntityId ? [lastAction.targetEntityId] : []);\r\n\t\t\t\taction.targetEntityIds =\r\n\t\t\t\t\taction.targetEntityIds ?? (action.targetEntityId ? [action.targetEntityId] : []);\r\n\t\t\t\tlastAction.targetEntityIds.push(...action.targetEntityIds);\r\n\t\t\t\t// So that when multiple Leapfroggers enchantments target the same minion,\r\n\t\t\t\t// we can count them in the replay viewer's text\r\n\t\t\t\t// lastAction.targetEntityIds = [...new Set(lastAction.targetEntityIds)];\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t\tlastAction.playerTrinkets = action.playerTrinkets;\r\n\t\t\t\tlastAction.opponentTrinkets = action.opponentTrinkets;\r\n\t\t\t} else {\r\n\t\t\t\tresult.push(action);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\t// Calling sanitize every time before we add an action to the list is mandatory, since\r\n\t// the entities and boards are mutable\r\n\tprivate sanitize(board: readonly BoardEntity[]): readonly BoardEntity[] {\r\n\t\tif (!board) {\r\n\t\t\treturn undefined;\r\n\t\t}\r\n\t\treturn board.map(\r\n\t\t\t(entity) =>\r\n\t\t\t\t({\r\n\t\t\t\t\tentityId: entity.entityId,\r\n\t\t\t\t\tcardId: entity.cardId,\r\n\t\t\t\t\tfriendly: entity.friendly,\r\n\t\t\t\t\tattack: entity.attack,\r\n\t\t\t\t\thealth: entity.health,\r\n\t\t\t\t\tmaxHealth: entity.maxHealth,\r\n\t\t\t\t\ttaunt: entity.taunt,\r\n\t\t\t\t\tdivineShield: entity.divineShield,\r\n\t\t\t\t\tpoisonous: entity.poisonous,\r\n\t\t\t\t\tvenomous: entity.venomous,\r\n\t\t\t\t\treborn: entity.reborn,\r\n\t\t\t\t\twindfury: entity.windfury,\r\n\t\t\t\t\tstealth: entity.stealth,\r\n\t\t\t\t} as BoardEntity),\r\n\t\t);\r\n\t}\r\n\r\n\tprivate sanitizeTrinkets(trinkets: readonly BoardTrinket[]): readonly BoardTrinket[] {\r\n\t\tif (!trinkets?.length) {\r\n\t\t\treturn undefined;\r\n\t\t}\r\n\t\tconst result = trinkets.map(\r\n\t\t\t(t) =>\r\n\t\t\t\t({\r\n\t\t\t\t\tcardId: t.cardId,\r\n\t\t\t\t\tentityId: t.entityId,\r\n\t\t\t\t\tscriptDataNum1: t.scriptDataNum1,\r\n\t\t\t\t\tscriptDataNum6: t.scriptDataNum6,\r\n\t\t\t\t\ttags: t.tags,\r\n\t\t\t\t} as BoardTrinket),\r\n\t\t);\r\n\t\treturn result;\r\n\t}\r\n}\r\n\r\n/** Shared no-op spectator for single-combat / tavern triggers (no sample arrays). */\r\nexport const noopSpectator = new Spectator(false);\r\n\r\n"]}
|
|
1
|
+
{"version":3,"file":"spectator.js","sourceRoot":"","sources":["../../../src/simulation/spectator/spectator.ts"],"names":[],"mappings":";;;AAIA,+CAAyE;AAGzE,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB,MAAM,aAAa,GAAiB,EAAE,CAAC;AACvC,MAAM,aAAa,GAAiB,EAAE,CAAC;AAEvC,MAAa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;QACF,OAAO,MAAM,CAAC;IACf,CAAC;CACD;AAjhBD,8BAihBC;AAGY,QAAA,aAAa,GAAG,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC","sourcesContent":["import { BgsGameState } from '../../bgs-battle-info';\r\nimport { BgsPlayerEntity, BoardTrinket } from '../../bgs-player-entity';\r\nimport { BoardEnchantment, BoardEntity } from '../../board-entity';\r\nimport { BoardSecret } from '../../board-secret';\r\nimport { GameAction, buildGameAction, copySecrets } from './game-action';\r\nimport { GameSample } from './game-sample';\r\n\r\nconst MAX_SAMPLES = 1;\r\nconst EMPTY_ACTIONS: GameAction[] = [];\r\nconst EMPTY_SAMPLES: GameSample[] = [];\r\n\r\nexport class Spectator {\r\n\tprivate actionsForCurrentBattle: GameAction[];\r\n\tprivate wonBattles: GameSample[];\r\n\tprivate tiedBattles: GameSample[];\r\n\tprivate lostBattles: GameSample[];\r\n\t// Recording every action is a significant part of the total simulation cost, so the\r\n\t// main simulation loop runs with recording off. Outcome samples are captured post-hoc:\r\n\t// once the outcome distribution is known, a few battles are re-run with recording\r\n\t// explicitly turned on until each outcome bucket that occurred has a sample.\r\n\tprivate recording = false;\r\n\r\n\tconstructor(private readonly enabled: boolean) {\r\n\t\tif (enabled) {\r\n\t\t\tthis.actionsForCurrentBattle = [];\r\n\t\t\tthis.wonBattles = [];\r\n\t\t\tthis.tiedBattles = [];\r\n\t\t\tthis.lostBattles = [];\r\n\t\t} else {\r\n\t\t\tthis.actionsForCurrentBattle = EMPTY_ACTIONS;\r\n\t\t\tthis.wonBattles = EMPTY_SAMPLES;\r\n\t\t\tthis.tiedBattles = EMPTY_SAMPLES;\r\n\t\t\tthis.lostBattles = EMPTY_SAMPLES;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic startRecording(): void {\r\n\t\tif (this.enabled) {\r\n\t\t\tthis.recording = true;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic stopRecording(): void {\r\n\t\tthis.recording = false;\r\n\t\tif (this.enabled) {\r\n\t\t\tthis.actionsForCurrentBattle = [];\r\n\t\t}\r\n\t}\r\n\r\n\tpublic hasSampleFor(result: 'won' | 'lost' | 'tied'): boolean {\r\n\t\tswitch (result) {\r\n\t\t\tcase 'won':\r\n\t\t\t\treturn this.wonBattles.length >= MAX_SAMPLES;\r\n\t\t\tcase 'lost':\r\n\t\t\t\treturn this.lostBattles.length >= MAX_SAMPLES;\r\n\t\t\tcase 'tied':\r\n\t\t\t\treturn this.tiedBattles.length >= MAX_SAMPLES;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic prune(): void {\r\n\t\tthis.wonBattles = this.wonBattles.slice(0, MAX_SAMPLES);\r\n\t\tthis.lostBattles = this.lostBattles.slice(0, MAX_SAMPLES);\r\n\t\tthis.tiedBattles = this.tiedBattles.slice(0, MAX_SAMPLES);\r\n\t}\r\n\r\n\tpublic buildOutcomeSamples(gameState: BgsGameState): {\r\n\t\twon: readonly GameSample[];\r\n\t\tlost: readonly GameSample[];\r\n\t\ttied: readonly GameSample[];\r\n\t} {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn {\r\n\t\t\t\twon: [],\r\n\t\t\t\tlost: [],\r\n\t\t\t\ttied: [],\r\n\t\t\t};\r\n\t\t}\r\n\t\treturn {\r\n\t\t\twon: this.wonBattles?.map((battle) => this.cleanUpActions(battle, gameState)),\r\n\t\t\tlost: this.lostBattles?.map((battle) => this.cleanUpActions(battle, gameState)),\r\n\t\t\ttied: this.tiedBattles?.map((battle) => this.cleanUpActions(battle, gameState)),\r\n\t\t};\r\n\t}\r\n\r\n\tprivate cleanUpActions(battle: GameSample, gameState: BgsGameState): GameSample {\r\n\t\tconst collapsed = this.collapseActions(battle.actions);\r\n\t\tconst result: GameSample = {\r\n\t\t\t...battle,\r\n\t\t\tactions: collapsed,\r\n\t\t\tanomalies: gameState.anomalies,\r\n\t\t};\r\n\t\treturn result;\r\n\t}\r\n\r\n\tpublic commitBattleResult(result: 'won' | 'lost' | 'tied'): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!this.recording) {\r\n\t\t\tthis.actionsForCurrentBattle = [];\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst actionsForBattle = this.actionsForCurrentBattle;\r\n\t\tthis.actionsForCurrentBattle = [];\r\n\r\n\t\tconst battle: GameSample = {\r\n\t\t\tactions: actionsForBattle,\r\n\t\t\tanomalies: [],\r\n\t\t};\r\n\t\t// Only keep the sample if this bucket still needs one (prune() would discard the\r\n\t\t// extras anyway, and holding on to them wastes memory)\r\n\t\tswitch (result) {\r\n\t\t\tcase 'won':\r\n\t\t\t\tif (this.wonBattles.length < MAX_SAMPLES) {\r\n\t\t\t\t\tthis.wonBattles.push(battle);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'lost':\r\n\t\t\t\tif (this.lostBattles.length < MAX_SAMPLES) {\r\n\t\t\t\t\tthis.lostBattles.push(battle);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'tied':\r\n\t\t\t\tif (this.tiedBattles.length < MAX_SAMPLES) {\r\n\t\t\t\t\tthis.tiedBattles.push(battle);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic registerAttack(\r\n\t\tattackingEntity: BoardEntity,\r\n\t\tdefendingEntity: BoardEntity,\r\n\t\tattackingBoard: readonly BoardEntity[],\r\n\t\tdefendingBoard: readonly BoardEntity[],\r\n\t\tattackingBoardHero: BgsPlayerEntity,\r\n\t\tdefendingBoardHero: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!this.recording) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// console.debug(\r\n\t\t// \t'\\n register attack',\r\n\t\t// \tstringifySimple(attackingBoard),\r\n\t\t// \t'\\n',\r\n\t\t// \tstringifySimple(defendingBoard),\r\n\t\t// \t'\\n',\r\n\t\t// \tattackingBoard.find((e) => e.entityId === 2441),\r\n\t\t// \t'\\n',\r\n\t\t// \tattackingBoard.find((e) => e.entityId === 2442),\r\n\t\t// );\r\n\t\tconst isAttackerFriendly = attackingBoard.every((entity) => entity.friendly);\r\n\t\tconst playerHero = isAttackerFriendly ? attackingBoardHero : defendingBoardHero;\r\n\t\tconst opponentHero = isAttackerFriendly ? defendingBoardHero : attackingBoardHero;\r\n\t\tconst friendlyBoard = isAttackerFriendly ? attackingBoard : defendingBoard;\r\n\t\tconst opponentBoard = isAttackerFriendly ? defendingBoard : attackingBoard;\r\n\t\tconst action: GameAction = buildGameAction(playerHero, opponentHero, {\r\n\t\t\ttype: 'attack',\r\n\t\t\tsourceEntityId: attackingEntity.entityId,\r\n\t\t\ttargetEntityId: defendingEntity.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\tplayerHand: this.sanitize(playerHero.hand),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\topponentHand: this.sanitize(opponentHero.hand),\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerStartOfCombat(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tfriendlyHero: BgsPlayerEntity,\r\n\t\topponentHero: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!this.recording) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(friendlyHero, opponentHero, {\r\n\t\t\ttype: 'start-of-combat',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: this.sanitize(friendlyHero.hand),\r\n\t\t\topponentHand: this.sanitize(opponentHero.hand),\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerPlayerAttack(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tdamage: number,\r\n\t): void {\r\n\t\tif (!this.recording) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'player-attack',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tdamage: damage,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerOpponentAttack(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tdamage: number,\r\n\t): void {\r\n\t\tif (!this.recording) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'opponent-attack',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tdamage: damage,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerDamageDealt(\r\n\t\tdamagingEntity: BoardEntity,\r\n\t\tdamagedEntity: BoardEntity,\r\n\t\tdamageTaken: number,\r\n\t\tdamagedEntityBoard: BoardEntity[],\r\n\t): void {\r\n\t\tif (!this.recording) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!damagingEntity.entityId) {\r\n\t\t\t// console.error('missing damaging entity id', damagingEntity.cardId);\r\n\t\t}\r\n\t\tconst friendlyBoard = damagedEntityBoard.every((entity) => entity.friendly) ? damagedEntityBoard : null;\r\n\t\tconst opponentBoard = damagedEntityBoard.every((entity) => !entity.friendly) ? damagedEntityBoard : null;\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'damage',\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tsourceEntityId: damagingEntity.entityId,\r\n\t\t\t\t\ttargetEntityId: damagedEntity.entityId,\r\n\t\t\t\t\tdamage: damageTaken,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerPowerTarget(\r\n\t\tsourceEntity: BoardEntity | BgsPlayerEntity | BoardSecret | BoardTrinket | BoardEnchantment,\r\n\t\ttargetEntity: BoardEntity | BgsPlayerEntity,\r\n\t\ttargetBoard: BoardEntity[],\r\n\t\thero1: BgsPlayerEntity,\r\n\t\thero2: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!this.recording) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!targetEntity) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// console.log('registerPowerTarget', stringifySimpleCard(sourceEntity), stringifySimpleCard(targetEntity), new Error().stack);\r\n\t\tconst friendlyBoard = targetBoard?.every((entity) => entity.friendly) ? targetBoard : null;\r\n\t\tconst opponentBoard = targetBoard?.every((entity) => !entity.friendly) ? targetBoard : null;\r\n\t\tconst friendlyHero = hero1?.friendly ? hero1 : hero2?.friendly ? hero2 : null;\r\n\t\tconst opponentHero = hero1?.friendly ? hero2 : hero2?.friendly ? hero1 : null;\r\n\t\tconst action: GameAction = buildGameAction(friendlyHero, opponentHero, {\r\n\t\t\ttype: 'power-target',\r\n\t\t\tsourceEntityId:\r\n\t\t\t\t(sourceEntity as BoardEnchantment)?.originEntityId ?? (sourceEntity as BoardEntity).entityId,\r\n\t\t\ttargetEntityId: targetEntity.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: this.sanitize(friendlyHero?.hand),\r\n\t\t\topponentHand: this.sanitize(opponentHero?.hand),\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerPowerTargets(\r\n\t\tsourceEntity: BoardEntity | BgsPlayerEntity | BoardSecret | BoardTrinket,\r\n\t\ttargetEntities: (BoardEntity | BgsPlayerEntity)[],\r\n\t\ttargetBoard: BoardEntity[],\r\n\t\thero1: BgsPlayerEntity,\r\n\t\thero2: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!this.recording) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!targetEntities?.length) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// console.log('registerPowerTarget', stringifySimpleCard(sourceEntity), stringifySimpleCard(targetEntity), new Error().stack);\r\n\t\tconst friendlyBoard = targetBoard?.every((entity) => entity.friendly) ? targetBoard : null;\r\n\t\tconst opponentBoard = targetBoard?.every((entity) => !entity.friendly) ? targetBoard : null;\r\n\t\tconst friendlyHero = hero1?.friendly ? hero1 : hero2?.friendly ? hero2 : null;\r\n\t\tconst opponentHero = hero1?.friendly ? hero2 : hero2?.friendly ? hero1 : null;\r\n\t\tconst action: GameAction = buildGameAction(friendlyHero, opponentHero, {\r\n\t\t\ttype: 'power-target',\r\n\t\t\tsourceEntityId: sourceEntity.entityId,\r\n\t\t\ttargetEntityIds: targetEntities.map((entity) => entity.entityId),\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: this.sanitize(friendlyHero?.hand),\r\n\t\t\topponentHand: this.sanitize(opponentHero?.hand),\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerMinionsSpawn(\r\n\t\tsourceEntity: BoardEntity | BgsPlayerEntity | BoardTrinket,\r\n\t\tboardOnWhichToSpawn: BoardEntity[],\r\n\t\tspawnedEntities: readonly BoardEntity[],\r\n\t): void {\r\n\t\tif (!this.recording) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!spawnedEntities || spawnedEntities.length === 0) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (!sourceEntity?.entityId) {\r\n\t\t\t// console.error('missing spawn source entity id', sourceEntity);\r\n\t\t}\r\n\t\tconst friendlyBoard = boardOnWhichToSpawn.every((entity) => entity.friendly) ? boardOnWhichToSpawn : null;\r\n\t\tconst opponentBoard = boardOnWhichToSpawn.every((entity) => !entity.friendly) ? boardOnWhichToSpawn : null;\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'spawn',\r\n\t\t\tspawns: this.sanitize(spawnedEntities),\r\n\t\t\tsourceEntityId: sourceEntity?.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerDeadEntities(\r\n\t\tdeadMinionIndexes1: number[],\r\n\t\tdeadEntities1: BoardEntity[],\r\n\t\tboard1: BoardEntity[],\r\n\t\tdeadMinionIndexes2: number[],\r\n\t\tdeadEntities2: BoardEntity[],\r\n\t\tboard2: BoardEntity[],\r\n\t): void {\r\n\t\tif (!this.recording) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst deaths = [...(deadEntities1 || []), ...(deadEntities2 || [])];\r\n\t\tif (!deaths || deaths.length === 0) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'minion-death',\r\n\t\t\tdeaths: this.sanitize(deaths),\r\n\t\t\tdeadMinionsPositionsOnBoard: [\r\n\t\t\t\t...(deadMinionIndexes1 || []).map((i) => board1.length - i),\r\n\t\t\t\t...(deadMinionIndexes2 || []).map((i) => board2.length - i),\r\n\t\t\t],\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tprivate addAction(action: GameAction) {\r\n\t\tthis.actionsForCurrentBattle.push(action);\r\n\t}\r\n\r\n\tprivate collapseActions(actions: readonly GameAction[]): readonly GameAction[] {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\t\tif (!actions || actions.length === 0) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\t\tconst result: GameAction[] = [];\r\n\t\tfor (let i = 0; i < actions.length; i++) {\r\n\t\t\tconst action: GameAction = {\r\n\t\t\t\t...actions[i],\r\n\t\t\t\tplayerBoard: this.sanitize(actions[i].playerBoard),\r\n\t\t\t\topponentBoard: this.sanitize(actions[i].opponentBoard),\r\n\t\t\t\tplayerHand: this.sanitize(actions[i].playerHand),\r\n\t\t\t\topponentHand: this.sanitize(actions[i].opponentHand),\r\n\t\t\t\t// spawns: this.sanitize(actions[i].spawns),\r\n\t\t\t\tdeaths: this.sanitize(actions[i].deaths),\r\n\t\t\t\tplayerTrinkets: this.sanitizeTrinkets(actions[i].playerTrinkets),\r\n\t\t\t\topponentTrinkets: this.sanitizeTrinkets(actions[i].opponentTrinkets),\r\n\t\t\t\tplayerSecrets: copySecrets(actions[i].playerSecrets),\r\n\t\t\t\topponentSecrets: copySecrets(actions[i].opponentSecrets),\r\n\t\t\t};\r\n\t\t\t// action.playerBoard && console.debug('\\naction playerboard', stringifySimple(action.playerBoard));\r\n\t\t\tconst lastAction = result.length > 0 ? result[result.length - 1] : null;\r\n\r\n\t\t\tif (lastAction) {\r\n\t\t\t\taction.playerBoard = action.playerBoard ?? lastAction.playerBoard;\r\n\t\t\t\taction.opponentBoard = action.opponentBoard ?? lastAction.opponentBoard;\r\n\t\t\t\taction.playerHand = action.playerHand ?? lastAction.playerHand;\r\n\t\t\t\taction.opponentHand = action.opponentHand ?? lastAction.opponentHand;\r\n\t\t\t\taction.playerSecrets = action.playerSecrets ?? lastAction.playerSecrets;\r\n\t\t\t\taction.opponentSecrets = action.opponentSecrets ?? lastAction.opponentSecrets;\r\n\t\t\t\taction.playerRewardCardId = action.playerRewardCardId ?? lastAction.playerRewardCardId;\r\n\t\t\t\taction.playerRewardEntityId = action.playerRewardEntityId ?? lastAction.playerRewardEntityId;\r\n\t\t\t\taction.playerRewardData = action.playerRewardData ?? lastAction.playerRewardData;\r\n\t\t\t\taction.opponentRewardCardId = action.opponentRewardCardId ?? lastAction.opponentRewardCardId;\r\n\t\t\t\taction.opponentRewardEntityId = action.opponentRewardEntityId ?? lastAction.opponentRewardEntityId;\r\n\t\t\t\taction.opponentRewardData = action.opponentRewardData ?? lastAction.opponentRewardData;\r\n\t\t\t\taction.playerCardId = action.playerCardId ?? lastAction.playerCardId;\r\n\t\t\t\taction.playerEntityId = action.playerEntityId ?? lastAction.playerEntityId;\r\n\t\t\t\taction.playerHeroPowerCardId = action.playerHeroPowerCardId ?? lastAction.playerHeroPowerCardId;\r\n\t\t\t\taction.playerHeroPowerEntityId = action.playerHeroPowerEntityId ?? lastAction.playerHeroPowerEntityId;\r\n\t\t\t\taction.playerHeroPowerUsed = action.playerHeroPowerUsed ?? lastAction.playerHeroPowerUsed;\r\n\t\t\t\taction.opponentCardId = action.opponentCardId ?? lastAction.opponentCardId;\r\n\t\t\t\taction.opponentEntityId = action.opponentEntityId ?? lastAction.opponentEntityId;\r\n\t\t\t\taction.opponentHeroPowerCardId = action.opponentHeroPowerCardId ?? lastAction.opponentHeroPowerCardId;\r\n\t\t\t\taction.opponentHeroPowerEntityId =\r\n\t\t\t\t\taction.opponentHeroPowerEntityId ?? lastAction.opponentHeroPowerEntityId;\r\n\t\t\t\taction.opponentHeroPowerUsed = action.opponentHeroPowerUsed ?? lastAction.opponentHeroPowerUsed;\r\n\t\t\t\taction.playerTrinkets = action.playerTrinkets ?? lastAction.playerTrinkets;\r\n\t\t\t\taction.opponentTrinkets = action.opponentTrinkets ?? lastAction.opponentTrinkets;\r\n\t\t\t}\r\n\r\n\t\t\tif (lastAction && action.type === 'damage' && lastAction.type === 'attack') {\r\n\t\t\t\tlastAction.damages = lastAction.damages || [];\r\n\t\t\t\tlastAction.damages.push({\r\n\t\t\t\t\tdamage: action.damages[0].damage,\r\n\t\t\t\t\tsourceEntityId: action.damages[0].sourceEntityId,\r\n\t\t\t\t\ttargetEntityId: action.damages[0].targetEntityId,\r\n\t\t\t\t});\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t\tlastAction.playerTrinkets = action.playerTrinkets;\r\n\t\t\t\tlastAction.opponentTrinkets = action.opponentTrinkets;\r\n\t\t\t} else if (lastAction && action.type === 'damage' && lastAction.type === 'damage') {\r\n\t\t\t\tlastAction.damages = lastAction.damages || [];\r\n\t\t\t\tlastAction.damages.push({\r\n\t\t\t\t\tdamage: action.damages[0].damage,\r\n\t\t\t\t\tsourceEntityId: action.damages[0].sourceEntityId,\r\n\t\t\t\t\ttargetEntityId: action.damages[0].targetEntityId,\r\n\t\t\t\t});\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t\tlastAction.playerTrinkets = action.playerTrinkets;\r\n\t\t\t\tlastAction.opponentTrinkets = action.opponentTrinkets;\r\n\t\t\t} else if (\r\n\t\t\t\tlastAction &&\r\n\t\t\t\taction.type === 'power-target' &&\r\n\t\t\t\tlastAction.type === 'power-target' &&\r\n\t\t\t\taction.sourceEntityId === lastAction.sourceEntityId\r\n\t\t\t) {\r\n\t\t\t\tlastAction.targetEntityIds =\r\n\t\t\t\t\tlastAction.targetEntityIds ?? (lastAction.targetEntityId ? [lastAction.targetEntityId] : []);\r\n\t\t\t\taction.targetEntityIds =\r\n\t\t\t\t\taction.targetEntityIds ?? (action.targetEntityId ? [action.targetEntityId] : []);\r\n\t\t\t\tlastAction.targetEntityIds.push(...action.targetEntityIds);\r\n\t\t\t\t// So that when multiple Leapfroggers enchantments target the same minion,\r\n\t\t\t\t// we can count them in the replay viewer's text\r\n\t\t\t\t// lastAction.targetEntityIds = [...new Set(lastAction.targetEntityIds)];\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t\tlastAction.playerTrinkets = action.playerTrinkets;\r\n\t\t\t\tlastAction.opponentTrinkets = action.opponentTrinkets;\r\n\t\t\t} else {\r\n\t\t\t\tresult.push(action);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\t// Calling sanitize every time before we add an action to the list is mandatory, since\r\n\t// the entities and boards are mutable\r\n\tprivate sanitize(board: readonly BoardEntity[]): readonly BoardEntity[] {\r\n\t\tif (!board) {\r\n\t\t\treturn undefined;\r\n\t\t}\r\n\t\treturn board.map(\r\n\t\t\t(entity) =>\r\n\t\t\t\t({\r\n\t\t\t\t\tentityId: entity.entityId,\r\n\t\t\t\t\tcardId: entity.cardId,\r\n\t\t\t\t\tfriendly: entity.friendly,\r\n\t\t\t\t\tattack: entity.attack,\r\n\t\t\t\t\thealth: entity.health,\r\n\t\t\t\t\tmaxHealth: entity.maxHealth,\r\n\t\t\t\t\ttaunt: entity.taunt,\r\n\t\t\t\t\tdivineShield: entity.divineShield,\r\n\t\t\t\t\tpoisonous: entity.poisonous,\r\n\t\t\t\t\tvenomous: entity.venomous,\r\n\t\t\t\t\treborn: entity.reborn,\r\n\t\t\t\t\twindfury: entity.windfury,\r\n\t\t\t\t\tstealth: entity.stealth,\r\n\t\t\t\t} as BoardEntity),\r\n\t\t);\r\n\t}\r\n\r\n\tprivate sanitizeTrinkets(trinkets: readonly BoardTrinket[]): readonly BoardTrinket[] {\r\n\t\tif (!trinkets?.length) {\r\n\t\t\treturn undefined;\r\n\t\t}\r\n\t\tconst result = trinkets.map(\r\n\t\t\t(t) =>\r\n\t\t\t\t({\r\n\t\t\t\t\tcardId: t.cardId,\r\n\t\t\t\t\tentityId: t.entityId,\r\n\t\t\t\t\tscriptDataNum1: t.scriptDataNum1,\r\n\t\t\t\t\tscriptDataNum6: t.scriptDataNum6,\r\n\t\t\t\t\ttags: t.tags,\r\n\t\t\t\t} as BoardTrinket),\r\n\t\t);\r\n\t\treturn result;\r\n\t}\r\n}\r\n\r\n/** Shared no-op spectator for single-combat / tavern triggers (no sample arrays). */\r\nexport const noopSpectator = new Spectator(false);\r\n\r\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handleStartOfCombat = void 0;
|
|
4
|
+
const deity_1 = require("../deity");
|
|
4
5
|
const pending_effects_1 = require("../pending-effects");
|
|
5
6
|
const stats_1 = require("../stats");
|
|
6
7
|
const soc_anomalies_1 = require("./soc-anomalies");
|
|
@@ -12,6 +13,8 @@ const soc_quest_reward_1 = require("./soc-quest-reward");
|
|
|
12
13
|
const soc_secret_1 = require("./soc-secret");
|
|
13
14
|
const soc_trinket_1 = require("./soc-trinket");
|
|
14
15
|
const handleStartOfCombat = (playerEntity, playerBoard, opponentEntity, opponentBoard, currentAttacker, gameState) => {
|
|
16
|
+
(0, deity_1.stampOnBoardDeityAuras)(playerBoard, playerEntity, gameState.allCards);
|
|
17
|
+
(0, deity_1.stampOnBoardDeityAuras)(opponentBoard, opponentEntity, gameState.allCards);
|
|
15
18
|
const shouldRecomputeCurrentAttacker = true;
|
|
16
19
|
if (shouldRecomputeCurrentAttacker) {
|
|
17
20
|
currentAttacker =
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-of-combat.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/start-of-combat.ts"],"names":[],"mappings":";;;AAIA,wDAA2D;AAC3D,oCAAiD;AAEjD,mDAA+D;AAC/D,qDAAiE;AACjE,qEAAmE;AACnE,6CAA0D;AAC1D,2EAAwE;AACxE,yDAAqE;AACrE,6CAA0D;AAC1D,+CAA4D;AASrD,MAAM,mBAAmB,GAAG,CAClC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IACX,MAAM,8BAA8B,GAAG,IAAI,CAAC;IAC5C,IAAI,8BAA8B,EAAE;QACnC,eAAe;YACd,WAAW,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM;gBACxC,CAAC,CAAC,CAAC;gBACH,CAAC,CAAC,aAAa,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM;oBAC3C,CAAC,CAAC,CAAC;oBACH,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;KAC9B;IAYD,MAAM,MAAM,GAAkC;QAC7C,aAAa;QACb,WAAW;QACX,SAAS;QAWT,oBAAoB;QACpB,kBAAkB;QAClB,WAAW;QACX,QAAQ;QACR,QAAQ;KACR,CAAC;IACF,IAAI,iBAAiB,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3D,IAAI,mBAAmB,GAAG,aAA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,EACd,aAAa,EACb,eAAe,EACf,SAAS,CACT,CAAC;YACF,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QACpD,KAAK,QAAQ;YACZ,eAAe,GAAG,IAAA,uCAA0B,EAC3C,YAAY,EACZ,WAAW,EACX,cAAc,EACd,aAAa,EACb,eAAe,EACf,SAAS,CACT,CAAC;YACF,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QACpD,KAAK,QAAQ;YACZ,eAAe,GAAG,IAAA,uCAA0B,EAC3C,YAAY,EACZ,WAAW,EACX,cAAc,EACd,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,SAAS,CACT,CAAC;YACF,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;KACpD;IAED,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AACpD,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { FullGameState } from '../internal-game-state';\r\nimport { resolvePendingEffects } from '../pending-effects';\r\nimport { applyAfterStatsUpdate } from '../stats';\r\nimport { StartOfCombatPhase } from './phases';\r\nimport { handleStartOfCombatAnomalies } from './soc-anomalies';\r\nimport { handleStartOfCombatHeroPowers } from './soc-hero-power';\r\nimport { handleIllidanHeroPowers } from './soc-illidan-hero-power';\r\nimport { handleStartOfCombatMinions } from './soc-minion';\r\nimport { handlePreCombatHeroPowers } from './soc-pre-combat-hero-power';\r\nimport { handleStartOfCombatQuestRewards } from './soc-quest-reward';\r\nimport { handleStartOfCombatSecrets } from './soc-secret';\r\nimport { handleStartOfCombatTrinkets } from './soc-trinket';\r\n\r\n// TODO 20/04/2024: I'm not too sure about some ordering. The way I understand it, the Start of Combat has\r\n// multiple phases, and in each phase the player order is random\r\n// However, looking at http://replays.firestoneapp.com/?reviewId=a577602e-06f3-4c4b-928d-36ea98c2e6d5&turn=5&action=0,\r\n// it feels that a \"start of combat\" minion effect could trigger before an opponent's hero power effect\r\n// Or is that limited to Bru'kan?\r\n// I feel that I've asked a lot of questions recently, so I don't want to add that one to the list, as the interaction\r\n// is for now pretty marginal\r\nexport const handleStartOfCombat = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tconst shouldRecomputeCurrentAttacker = true;\r\n\tif (shouldRecomputeCurrentAttacker) {\r\n\t\tcurrentAttacker =\r\n\t\t\tplayerBoard.length > opponentBoard.length\r\n\t\t\t\t? 0\r\n\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t? 1\r\n\t\t\t\t: Math.round(Math.random());\r\n\t}\r\n\r\n\t// UPDATE 2024-10-10: changed in 30.6, according to a message from Mitchell on Discord\r\n\t// UPDATE 2026-02-21:\r\n\t// K I double checked in-game and documentation and this is the trigger order:\r\n\t// Trinket/Quest Reward\r\n\t// Pre-combat hero powers (e.g. Lich King)\r\n\t// Combat First hero powers (e.g. Illidan)\r\n\t// Start of combat hero powers (e.g. Basically all other hero powers)\r\n\t// Spells (e.g. Fleeting Vigor)\r\n\t// Minions in hand (e.g. Flighty Scout)\r\n\t// Minions in play (e.g. Promo-Drake)\r\n\tconst phases: readonly StartOfCombatPhase[] = [\r\n\t\t'QuestReward',\r\n\t\t'Anomalies',\r\n\t\t'Trinket',\r\n\t\t// https://twitter.com/DCalkosz/status/1488361384320528388?s=20&t=1ECxRZFdjqwEa2fRsXk32Q\r\n\t\t// There’s a certain order for Start of Combat hero powers, rather than “coin flips” where\r\n\t\t// an unlucky trigger order could mess up some positioning you had planned for your own hero\r\n\t\t// power. “Precombat” (Al’Akir, Y’Shaarj), then Illidan, then others.\r\n\t\t// Update: this seems to have changed: https://x.com/LoewenMitchell/status/1737588920139825335?s=20\r\n\t\t// now you have all hero powers trigger in a first phase, then you have Illidan, and once everything has triggered, you have Tavish\r\n\t\t// All Hero powers are split up in to 3 categories:\r\n\t\t// 1st - Precombat Hero Power Triggers (things we want to go before Illidan e.g. Lich King). Should be Lich King, Teron, Brukan\r\n\t\t// 2nd - Hero Power Triggers First In Combat (Illidan)\r\n\t\t// 3rd - All other Start of Combat Hero Powers\r\n\t\t'PreCombatHeroPower',\r\n\t\t'IllidanHeroPower',\r\n\t\t'HeroPower',\r\n\t\t'Secret',\r\n\t\t'Minion',\r\n\t];\r\n\tlet playerBoardBefore = playerBoard.map((e) => ({ ...e }));\r\n\tlet opponentBoardBefore = opponentBoard.map((e) => ({ ...e }));\r\n\r\n\tlet forcedAttacker = null;\r\n\tfor (const phase of phases) {\r\n\t\tconst { attacker: newAttacker, force: newForce } = handlePhase(\r\n\t\t\tphase,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerBoardBefore,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentBoardBefore,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tcurrentAttacker = newAttacker;\r\n\t\tif (newForce) {\r\n\t\t\tforcedAttacker = newAttacker;\r\n\t\t}\r\n\t\tif (phase === 'PreCombatHeroPower') {\r\n\t\t\tplayerBoardBefore = playerBoard.map((e) => ({ ...e }));\r\n\t\t\topponentBoardBefore = opponentBoard.map((e) => ({ ...e }));\r\n\t\t}\r\n\t}\r\n\tplayerEntity.startOfCombatDone = true;\r\n\topponentEntity.startOfCombatDone = true;\r\n\tapplyAfterStatsUpdate(gameState);\r\n\tresolvePendingEffects(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn forcedAttacker != null ? forcedAttacker : currentAttacker;\r\n};\r\n\r\nconst handlePhase = (\r\n\tphase: StartOfCombatPhase,\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerBoardBefore: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentBoardBefore: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): { attacker: number; force: boolean } => {\r\n\tswitch (phase) {\r\n\t\tcase 'QuestReward':\r\n\t\t\tcurrentAttacker = handleStartOfCombatQuestRewards(\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\tcurrentAttacker,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\treturn { attacker: currentAttacker, force: false };\r\n\t\tcase 'Anomalies':\r\n\t\t\tcurrentAttacker = handleStartOfCombatAnomalies(\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\tcurrentAttacker,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\treturn { attacker: currentAttacker, force: false };\r\n\t\tcase 'Trinket':\r\n\t\t\tcurrentAttacker = handleStartOfCombatTrinkets(\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\tcurrentAttacker,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\treturn { attacker: currentAttacker, force: false };\r\n\t\tcase 'PreCombatHeroPower':\r\n\t\t\tcurrentAttacker = handlePreCombatHeroPowers(\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\tcurrentAttacker,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\treturn { attacker: currentAttacker, force: false };\r\n\t\tcase 'IllidanHeroPower':\r\n\t\t\tconst { attacker: newAttacker, force: newForce } = handleIllidanHeroPowers(\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\tcurrentAttacker,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\treturn { attacker: newAttacker, force: newForce };\r\n\t\tcase 'HeroPower':\r\n\t\t\tcurrentAttacker = handleStartOfCombatHeroPowers(\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\tcurrentAttacker,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\treturn { attacker: currentAttacker, force: false };\r\n\t\tcase 'Secret':\r\n\t\t\tcurrentAttacker = handleStartOfCombatSecrets(\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\tcurrentAttacker,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\treturn { attacker: currentAttacker, force: false };\r\n\t\tcase 'Minion':\r\n\t\t\tcurrentAttacker = handleStartOfCombatMinions(\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\tcurrentAttacker,\r\n\t\t\t\tplayerBoardBefore,\r\n\t\t\t\topponentBoardBefore,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\treturn { attacker: currentAttacker, force: false };\r\n\t}\r\n\r\n\treturn { attacker: currentAttacker, force: false };\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"start-of-combat.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/start-of-combat.ts"],"names":[],"mappings":";;;AAGA,oCAA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YAAY,EACZ,WAAW,EACX,cAAc,EACd,aAAa,EACb,eAAe,EACf,SAAS,CACT,CAAC;YACF,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QACpD,KAAK,QAAQ;YACZ,eAAe,GAAG,IAAA,uCAA0B,EAC3C,YAAY,EACZ,WAAW,EACX,cAAc,EACd,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,SAAS,CACT,CAAC;YACF,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;KACpD;IAED,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AACpD,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { stampOnBoardDeityAuras } from '../deity';\r\nimport { FullGameState } from '../internal-game-state';\r\nimport { resolvePendingEffects } from '../pending-effects';\r\nimport { applyAfterStatsUpdate } from '../stats';\r\nimport { StartOfCombatPhase } from './phases';\r\nimport { handleStartOfCombatAnomalies } from './soc-anomalies';\r\nimport { handleStartOfCombatHeroPowers } from './soc-hero-power';\r\nimport { handleIllidanHeroPowers } from './soc-illidan-hero-power';\r\nimport { handleStartOfCombatMinions } from './soc-minion';\r\nimport { handlePreCombatHeroPowers } from './soc-pre-combat-hero-power';\r\nimport { handleStartOfCombatQuestRewards } from './soc-quest-reward';\r\nimport { handleStartOfCombatSecrets } from './soc-secret';\r\nimport { handleStartOfCombatTrinkets } from './soc-trinket';\r\n\r\n// TODO 20/04/2024: I'm not too sure about some ordering. The way I understand it, the Start of Combat has\r\n// multiple phases, and in each phase the player order is random\r\n// However, looking at http://replays.firestoneapp.com/?reviewId=a577602e-06f3-4c4b-928d-36ea98c2e6d5&turn=5&action=0,\r\n// it feels that a \"start of combat\" minion effect could trigger before an opponent's hero power effect\r\n// Or is that limited to Bru'kan?\r\n// I feel that I've asked a lot of questions recently, so I don't want to add that one to the list, as the interaction\r\n// is for now pretty marginal\r\nexport const handleStartOfCombat = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tstampOnBoardDeityAuras(playerBoard, playerEntity, gameState.allCards);\r\n\tstampOnBoardDeityAuras(opponentBoard, opponentEntity, gameState.allCards);\r\n\r\n\tconst shouldRecomputeCurrentAttacker = true;\r\n\tif (shouldRecomputeCurrentAttacker) {\r\n\t\tcurrentAttacker =\r\n\t\t\tplayerBoard.length > opponentBoard.length\r\n\t\t\t\t? 0\r\n\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t? 1\r\n\t\t\t\t: Math.round(Math.random());\r\n\t}\r\n\r\n\t// UPDATE 2024-10-10: changed in 30.6, according to a message from Mitchell on Discord\r\n\t// UPDATE 2026-02-21:\r\n\t// K I double checked in-game and documentation and this is the trigger order:\r\n\t// Trinket/Quest Reward\r\n\t// Pre-combat hero powers (e.g. Lich King)\r\n\t// Combat First hero powers (e.g. Illidan)\r\n\t// Start of combat hero powers (e.g. Basically all other hero powers)\r\n\t// Spells (e.g. Fleeting Vigor)\r\n\t// Minions in hand (e.g. Flighty Scout)\r\n\t// Minions in play (e.g. Promo-Drake)\r\n\tconst phases: readonly StartOfCombatPhase[] = [\r\n\t\t'QuestReward',\r\n\t\t'Anomalies',\r\n\t\t'Trinket',\r\n\t\t// https://twitter.com/DCalkosz/status/1488361384320528388?s=20&t=1ECxRZFdjqwEa2fRsXk32Q\r\n\t\t// There’s a certain order for Start of Combat hero powers, rather than “coin flips” where\r\n\t\t// an unlucky trigger order could mess up some positioning you had planned for your own hero\r\n\t\t// power. “Precombat” (Al’Akir, Y’Shaarj), then Illidan, then others.\r\n\t\t// Update: this seems to have changed: https://x.com/LoewenMitchell/status/1737588920139825335?s=20\r\n\t\t// now you have all hero powers trigger in a first phase, then you have Illidan, and once everything has triggered, you have Tavish\r\n\t\t// All Hero powers are split up in to 3 categories:\r\n\t\t// 1st - Precombat Hero Power Triggers (things we want to go before Illidan e.g. Lich King). Should be Lich King, Teron, Brukan\r\n\t\t// 2nd - Hero Power Triggers First In Combat (Illidan)\r\n\t\t// 3rd - All other Start of Combat Hero Powers\r\n\t\t'PreCombatHeroPower',\r\n\t\t'IllidanHeroPower',\r\n\t\t'HeroPower',\r\n\t\t'Secret',\r\n\t\t'Minion',\r\n\t];\r\n\tlet playerBoardBefore = playerBoard.map((e) => ({ ...e }));\r\n\tlet opponentBoardBefore = opponentBoard.map((e) => ({ ...e }));\r\n\r\n\tlet forcedAttacker = null;\r\n\tfor (const phase of phases) {\r\n\t\tconst { attacker: newAttacker, force: newForce } = handlePhase(\r\n\t\t\tphase,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerBoardBefore,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentBoardBefore,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tcurrentAttacker = newAttacker;\r\n\t\tif (newForce) {\r\n\t\t\tforcedAttacker = newAttacker;\r\n\t\t}\r\n\t\tif (phase === 'PreCombatHeroPower') {\r\n\t\t\tplayerBoardBefore = playerBoard.map((e) => ({ ...e }));\r\n\t\t\topponentBoardBefore = opponentBoard.map((e) => ({ ...e }));\r\n\t\t}\r\n\t}\r\n\tplayerEntity.startOfCombatDone = true;\r\n\topponentEntity.startOfCombatDone = true;\r\n\tapplyAfterStatsUpdate(gameState);\r\n\tresolvePendingEffects(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn forcedAttacker != null ? forcedAttacker : currentAttacker;\r\n};\r\n\r\nconst handlePhase = (\r\n\tphase: StartOfCombatPhase,\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerBoardBefore: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentBoardBefore: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): { attacker: number; force: boolean } => {\r\n\tswitch (phase) {\r\n\t\tcase 'QuestReward':\r\n\t\t\tcurrentAttacker = handleStartOfCombatQuestRewards(\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\tcurrentAttacker,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\treturn { attacker: currentAttacker, force: false };\r\n\t\tcase 'Anomalies':\r\n\t\t\tcurrentAttacker = handleStartOfCombatAnomalies(\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\tcurrentAttacker,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\treturn { attacker: currentAttacker, force: false };\r\n\t\tcase 'Trinket':\r\n\t\t\tcurrentAttacker = handleStartOfCombatTrinkets(\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\tcurrentAttacker,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\treturn { attacker: currentAttacker, force: false };\r\n\t\tcase 'PreCombatHeroPower':\r\n\t\t\tcurrentAttacker = handlePreCombatHeroPowers(\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\tcurrentAttacker,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\treturn { attacker: currentAttacker, force: false };\r\n\t\tcase 'IllidanHeroPower':\r\n\t\t\tconst { attacker: newAttacker, force: newForce } = handleIllidanHeroPowers(\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\tcurrentAttacker,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\treturn { attacker: newAttacker, force: newForce };\r\n\t\tcase 'HeroPower':\r\n\t\t\tcurrentAttacker = handleStartOfCombatHeroPowers(\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\tcurrentAttacker,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\treturn { attacker: currentAttacker, force: false };\r\n\t\tcase 'Secret':\r\n\t\t\tcurrentAttacker = handleStartOfCombatSecrets(\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\tcurrentAttacker,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\treturn { attacker: currentAttacker, force: false };\r\n\t\tcase 'Minion':\r\n\t\t\tcurrentAttacker = handleStartOfCombatMinions(\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\tcurrentAttacker,\r\n\t\t\t\tplayerBoardBefore,\r\n\t\t\t\topponentBoardBefore,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\treturn { attacker: currentAttacker, force: false };\r\n\t}\r\n\r\n\treturn { attacker: currentAttacker, force: false };\r\n};\r\n"]}
|