@firestone-hs/simulate-bgs-battle 1.1.473 → 1.1.475

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.
@@ -50,21 +50,22 @@ const buildFinalInput = (battleInput, cards, cardsData) => {
50
50
  };
51
51
  exports.buildFinalInput = buildFinalInput;
52
52
  const buildFinalInputForPlayer = (playerInfo, isPlayer, cards, cardsData, entityIdContainer) => {
53
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
53
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
54
54
  if (!playerInfo) {
55
55
  return { board: [], hand: [], player: null };
56
56
  }
57
57
  const { board, hand } = buildFinalInputBoard(playerInfo, isPlayer, cardsData, cards);
58
58
  const isGhost = ((_a = playerInfo.player) === null || _a === void 0 ? void 0 : _a.hpLeft) != null && playerInfo.player.hpLeft <= 0;
59
- playerInfo.player.secrets = (_c = (_b = playerInfo.secrets) === null || _b === void 0 ? void 0 : _b.filter((e) => !!(e === null || e === void 0 ? void 0 : e.cardId))) !== null && _c !== void 0 ? _c : [];
60
- playerInfo.player.trinkets = isGhost ? [] : (_e = (_d = playerInfo.player.trinkets) === null || _d === void 0 ? void 0 : _d.filter((e) => !!(e === null || e === void 0 ? void 0 : e.cardId))) !== null && _e !== void 0 ? _e : [];
59
+ playerInfo.player.secrets = (_d = (_c = ((_b = playerInfo.player.secrets) !== null && _b !== void 0 ? _b : playerInfo.secrets)) === null || _c === void 0 ? void 0 : _c.filter((e) => !!(e === null || e === void 0 ? void 0 : e.cardId))) !== null && _d !== void 0 ? _d : [];
60
+ playerInfo.player.secrets.forEach((secret) => (secret.scriptDataNum1 = 0));
61
+ playerInfo.player.trinkets = (_f = (_e = playerInfo.player.trinkets) === null || _e === void 0 ? void 0 : _e.filter((e) => !!(e === null || e === void 0 ? void 0 : e.cardId))) !== null && _f !== void 0 ? _f : [];
61
62
  playerInfo.player.friendly = isPlayer;
62
- playerInfo.player.globalInfo = (_f = playerInfo.player.globalInfo) !== null && _f !== void 0 ? _f : {};
63
- playerInfo.player.globalInfo.PirateAttackBonus = (_g = playerInfo.player.globalInfo.PirateAttackBonus) !== null && _g !== void 0 ? _g : 0;
63
+ playerInfo.player.globalInfo = (_g = playerInfo.player.globalInfo) !== null && _g !== void 0 ? _g : {};
64
+ playerInfo.player.globalInfo.PirateAttackBonus = (_h = playerInfo.player.globalInfo.PirateAttackBonus) !== null && _h !== void 0 ? _h : 0;
64
65
  playerInfo.player.heroPowerId =
65
- (_m = (_j = (_h = playerInfo.player.trinkets.find((t) => t.scriptDataNum6 === 3)) === null || _h === void 0 ? void 0 : _h.cardId) !== null && _j !== void 0 ? _j : ((0, reference_data_1.normalizeHeroCardId)(playerInfo.player.cardId, cards) === "BG24_HERO_100"
66
- ? (_l = (_k = playerInfo.player.questRewardEntities) === null || _k === void 0 ? void 0 : _k[0]) === null || _l === void 0 ? void 0 : _l.cardId
67
- : null)) !== null && _m !== void 0 ? _m : playerInfo.player.heroPowerId;
66
+ (_o = (_k = (_j = playerInfo.player.trinkets.find((t) => t.scriptDataNum6 === 3)) === null || _j === void 0 ? void 0 : _j.cardId) !== null && _k !== void 0 ? _k : ((0, reference_data_1.normalizeHeroCardId)(playerInfo.player.cardId, cards) === "BG24_HERO_100"
67
+ ? (_m = (_l = playerInfo.player.questRewardEntities) === null || _l === void 0 ? void 0 : _l[0]) === null || _m === void 0 ? void 0 : _m.cardId
68
+ : null)) !== null && _o !== void 0 ? _o : playerInfo.player.heroPowerId;
68
69
  playerInfo.player.cardId = isGhost ? "TB_BaconShop_HERO_KelThuzad" : playerInfo.player.cardId;
69
70
  (0, auras_1.setMissingAuras)(board, playerInfo.player, cards);
70
71
  (0, auras_1.setImplicitDataHero)(playerInfo.player, cardsData, isPlayer, entityIdContainer);
@@ -1 +1 @@
1
- {"version":3,"file":"input-sanitation.js","sourceRoot":"","sources":["../src/input-sanitation.ts"],"names":[],"mappings":";;;AAAA,iEA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AS,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IAC/E,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC;AACnD,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAC5B,UAAwB,EACxB,QAAiB,EACjB,SAAoB,EACpB,KAAsB,EAC0B,EAAE;;IAClD,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK;SAC5B,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAA,8BAAe,EAAC,MAAM,EAAE,KAAK,CAAC,CAAC;SAC/C,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC;SACtD,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAA,2BAAmB,EAAC,MAAM,EAAE,SAAS,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAkB,CAAA,CAAC,CAAC;IACtG,MAAM,IAAI,GACT,MAAA,MAAA,UAAU,CAAC,MAAM,CAAC,IAAI,0CACnB,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,EACtD,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAA,2BAAmB,EAAC,MAAM,EAAE,SAAS,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAkB,CAAA,CAAC,mCAAI,EAAE,CAAC;IAE7G,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACxB,CAAC,CAAC","sourcesContent":["import { AllCardsService, CardIds, normalizeHeroCardId } from '@firestone-hs/reference-data';\r\nimport { BgsBattleInfo } from './bgs-battle-info';\r\nimport { BgsBoardInfo } from './bgs-board-info';\r\nimport { BgsPlayerEntity } from './bgs-player-entity';\r\nimport { BoardEntity } from './board-entity';\r\nimport { CardsData } from './cards/cards-data';\r\nimport { setImplicitDataHero, setMissingAuras } from './simulation/auras';\r\nimport { fixEnchantments } from './simulation/enchantments';\r\nimport { addImpliedMechanics } from './utils';\r\n\r\nexport const buildFinalInput = (\r\n\tbattleInput: BgsBattleInfo,\r\n\tcards: AllCardsService,\r\n\tcardsData: CardsData,\r\n): BgsBattleInfo => {\r\n\tconst entityIdContainer = { entityId: 999_999_999 };\r\n\r\n\tconst {\r\n\t\tboard: playerBoard,\r\n\t\thand: playerHand,\r\n\t\tplayer: playerEntity,\r\n\t} = buildFinalInputForPlayer(battleInput.playerBoard, true, cards, cardsData, entityIdContainer);\r\n\tconst {\r\n\t\tboard: playerTeammateBoard,\r\n\t\thand: playerTeammateHand,\r\n\t\tplayer: playerTeammateEntity,\r\n\t} = buildFinalInputForPlayer(battleInput.playerTeammateBoard, true, cards, cardsData, entityIdContainer);\r\n\r\n\tconst {\r\n\t\tboard: opponentBoard,\r\n\t\thand: opponentHand,\r\n\t\tplayer: opponentEntity,\r\n\t} = buildFinalInputForPlayer(battleInput.opponentBoard, false, cards, cardsData, entityIdContainer);\r\n\tconst {\r\n\t\tboard: opponentTeammateBoard,\r\n\t\thand: opponentTeammateHand,\r\n\t\tplayer: opponentTeammateEntity,\r\n\t} = buildFinalInputForPlayer(battleInput.opponentTeammateBoard, false, cards, cardsData, entityIdContainer);\r\n\r\n\t// We do this so that we can have mutated objects inside the simulation and still\r\n\t// be able to start from a fresh copy for each simulation\r\n\tconst inputReady: BgsBattleInfo = {\r\n\t\tplayerBoard: {\r\n\t\t\tboard: playerBoard,\r\n\t\t\tplayer: {\r\n\t\t\t\t...playerEntity,\r\n\t\t\t\thand: playerHand,\r\n\t\t\t},\r\n\t\t},\r\n\t\tplayerTeammateBoard: !!playerTeammateEntity\r\n\t\t\t? {\r\n\t\t\t\t\tboard: playerTeammateBoard,\r\n\t\t\t\t\tplayer: {\r\n\t\t\t\t\t\t...playerTeammateEntity,\r\n\t\t\t\t\t\thand: playerTeammateHand,\r\n\t\t\t\t\t},\r\n\t\t\t }\r\n\t\t\t: null,\r\n\t\topponentBoard: {\r\n\t\t\tboard: opponentBoard,\r\n\t\t\tplayer: {\r\n\t\t\t\t...opponentEntity,\r\n\t\t\t\thand: opponentHand,\r\n\t\t\t},\r\n\t\t},\r\n\t\topponentTeammateBoard: !!opponentTeammateEntity\r\n\t\t\t? {\r\n\t\t\t\t\tboard: opponentTeammateBoard,\r\n\t\t\t\t\tplayer: {\r\n\t\t\t\t\t\t...opponentTeammateEntity,\r\n\t\t\t\t\t\thand: opponentTeammateHand,\r\n\t\t\t\t\t},\r\n\t\t\t }\r\n\t\t\t: null,\r\n\t\tgameState: battleInput.gameState,\r\n\t} as BgsBattleInfo;\r\n\treturn inputReady;\r\n};\r\n\r\nconst buildFinalInputForPlayer = (\r\n\tplayerInfo: BgsBoardInfo,\r\n\tisPlayer: boolean,\r\n\tcards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tentityIdContainer: { entityId: number },\r\n): { board: BoardEntity[]; hand: BoardEntity[]; player: BgsPlayerEntity } => {\r\n\tif (!playerInfo) {\r\n\t\treturn { board: [], hand: [], player: null };\r\n\t}\r\n\r\n\tconst { board, hand } = buildFinalInputBoard(playerInfo, isPlayer, cardsData, cards);\r\n\tconst isGhost = playerInfo.player?.hpLeft != null && playerInfo.player.hpLeft <= 0;\r\n\tplayerInfo.player.secrets = playerInfo.secrets?.filter((e) => !!e?.cardId) ?? [];\r\n\t// Trinkets don't seem to trigger when facing the ghost\r\n\t// http://replays.firestoneapp.com/?reviewId=4ad32e03-2620-4fb1-8b43-cad55afd30fc&turn=27&action=2\r\n\t// One of the trinkets is Blood Golem Sticker, and no Blood Golem is summoned\r\n\tplayerInfo.player.trinkets = isGhost ? [] : playerInfo.player.trinkets?.filter((e) => !!e?.cardId) ?? [];\r\n\tplayerInfo.player.friendly = isPlayer;\r\n\tplayerInfo.player.globalInfo = playerInfo.player.globalInfo ?? {};\r\n\tplayerInfo.player.globalInfo.PirateAttackBonus = playerInfo.player.globalInfo.PirateAttackBonus ?? 0;\r\n\tplayerInfo.player.heroPowerId =\r\n\t\tplayerInfo.player.trinkets.find((t) => t.scriptDataNum6 === 3)?.cardId ??\r\n\t\t(normalizeHeroCardId(playerInfo.player.cardId, cards) === CardIds.SireDenathrius_BG24_HERO_100\r\n\t\t\t? playerInfo.player.questRewardEntities?.[0]?.cardId\r\n\t\t\t: null) ??\r\n\t\tplayerInfo.player.heroPowerId;\r\n\tplayerInfo.player.cardId = isGhost ? CardIds.Kelthuzad_TB_BaconShop_HERO_KelThuzad : playerInfo.player.cardId;\r\n\t// When using the simulator, the aura is not applied when receiving the board state.\r\n\tsetMissingAuras(board, playerInfo.player, cards);\r\n\t// Avenge, maxHealth, etc.\r\n\t// setImplicitData(playerBoard, cardsData);\r\n\t// setImplicitData(opponentBoard, cardsData);\r\n\t// Avenge, globalInfo\r\n\tsetImplicitDataHero(playerInfo.player, cardsData, isPlayer, entityIdContainer);\r\n\treturn { board, hand, player: playerInfo.player };\r\n};\r\n\r\nconst buildFinalInputBoard = (\r\n\tplayerInfo: BgsBoardInfo,\r\n\tisPlayer: boolean,\r\n\tcardsData: CardsData,\r\n\tcards: AllCardsService,\r\n): { board: BoardEntity[]; hand: BoardEntity[] } => {\r\n\tconst board = playerInfo.board\r\n\t\t.map((entity) => fixEnchantments(entity, cards))\r\n\t\t.map((entity) => ({ ...entity, inInitialState: true }))\r\n\t\t.map((entity) => ({ ...addImpliedMechanics(entity, cardsData), friendly: isPlayer } as BoardEntity));\r\n\tconst hand =\r\n\t\tplayerInfo.player.hand\r\n\t\t\t?.map((entity) => ({ ...entity, inInitialState: true }))\r\n\t\t\t.map((entity) => ({ ...addImpliedMechanics(entity, cardsData), friendly: isPlayer } as BoardEntity)) ?? [];\r\n\r\n\treturn { board, hand };\r\n};\r\n"]}
1
+ {"version":3,"file":"input-sanitation.js","sourceRoot":"","sources":["../src/input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,EAAE,CAAC;AACxB,CAAC,CAAC","sourcesContent":["import { AllCardsService, CardIds, normalizeHeroCardId } from '@firestone-hs/reference-data';\r\nimport { BgsBattleInfo } from './bgs-battle-info';\r\nimport { BgsBoardInfo } from './bgs-board-info';\r\nimport { BgsPlayerEntity } from './bgs-player-entity';\r\nimport { BoardEntity } from './board-entity';\r\nimport { CardsData } from './cards/cards-data';\r\nimport { setImplicitDataHero, setMissingAuras } from './simulation/auras';\r\nimport { fixEnchantments } from './simulation/enchantments';\r\nimport { addImpliedMechanics } from './utils';\r\n\r\nexport const buildFinalInput = (\r\n\tbattleInput: BgsBattleInfo,\r\n\tcards: AllCardsService,\r\n\tcardsData: CardsData,\r\n): BgsBattleInfo => {\r\n\tconst entityIdContainer = { entityId: 999_999_999 };\r\n\r\n\tconst {\r\n\t\tboard: playerBoard,\r\n\t\thand: playerHand,\r\n\t\tplayer: playerEntity,\r\n\t} = buildFinalInputForPlayer(battleInput.playerBoard, true, cards, cardsData, entityIdContainer);\r\n\tconst {\r\n\t\tboard: playerTeammateBoard,\r\n\t\thand: playerTeammateHand,\r\n\t\tplayer: playerTeammateEntity,\r\n\t} = buildFinalInputForPlayer(battleInput.playerTeammateBoard, true, cards, cardsData, entityIdContainer);\r\n\r\n\tconst {\r\n\t\tboard: opponentBoard,\r\n\t\thand: opponentHand,\r\n\t\tplayer: opponentEntity,\r\n\t} = buildFinalInputForPlayer(battleInput.opponentBoard, false, cards, cardsData, entityIdContainer);\r\n\tconst {\r\n\t\tboard: opponentTeammateBoard,\r\n\t\thand: opponentTeammateHand,\r\n\t\tplayer: opponentTeammateEntity,\r\n\t} = buildFinalInputForPlayer(battleInput.opponentTeammateBoard, false, cards, cardsData, entityIdContainer);\r\n\r\n\t// We do this so that we can have mutated objects inside the simulation and still\r\n\t// be able to start from a fresh copy for each simulation\r\n\tconst inputReady: BgsBattleInfo = {\r\n\t\tplayerBoard: {\r\n\t\t\tboard: playerBoard,\r\n\t\t\tplayer: {\r\n\t\t\t\t...playerEntity,\r\n\t\t\t\thand: playerHand,\r\n\t\t\t},\r\n\t\t},\r\n\t\tplayerTeammateBoard: !!playerTeammateEntity\r\n\t\t\t? {\r\n\t\t\t\t\tboard: playerTeammateBoard,\r\n\t\t\t\t\tplayer: {\r\n\t\t\t\t\t\t...playerTeammateEntity,\r\n\t\t\t\t\t\thand: playerTeammateHand,\r\n\t\t\t\t\t},\r\n\t\t\t }\r\n\t\t\t: null,\r\n\t\topponentBoard: {\r\n\t\t\tboard: opponentBoard,\r\n\t\t\tplayer: {\r\n\t\t\t\t...opponentEntity,\r\n\t\t\t\thand: opponentHand,\r\n\t\t\t},\r\n\t\t},\r\n\t\topponentTeammateBoard: !!opponentTeammateEntity\r\n\t\t\t? {\r\n\t\t\t\t\tboard: opponentTeammateBoard,\r\n\t\t\t\t\tplayer: {\r\n\t\t\t\t\t\t...opponentTeammateEntity,\r\n\t\t\t\t\t\thand: opponentTeammateHand,\r\n\t\t\t\t\t},\r\n\t\t\t }\r\n\t\t\t: null,\r\n\t\tgameState: battleInput.gameState,\r\n\t} as BgsBattleInfo;\r\n\treturn inputReady;\r\n};\r\n\r\nconst buildFinalInputForPlayer = (\r\n\tplayerInfo: BgsBoardInfo,\r\n\tisPlayer: boolean,\r\n\tcards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tentityIdContainer: { entityId: number },\r\n): { board: BoardEntity[]; hand: BoardEntity[]; player: BgsPlayerEntity } => {\r\n\tif (!playerInfo) {\r\n\t\treturn { board: [], hand: [], player: null };\r\n\t}\r\n\r\n\tconst { board, hand } = buildFinalInputBoard(playerInfo, isPlayer, cardsData, cards);\r\n\tconst isGhost = playerInfo.player?.hpLeft != null && playerInfo.player.hpLeft <= 0;\r\n\tplayerInfo.player.secrets = (playerInfo.player.secrets ?? playerInfo.secrets)?.filter((e) => !!e?.cardId) ?? [];\r\n\t// Add the scriptDataNum1 only on the start of combat phase, so that it doesn't trigger too soon\r\n\tplayerInfo.player.secrets.forEach((secret) => (secret.scriptDataNum1 = 0));\r\n\t// Trinkets don't seem to trigger when facing the ghost\r\n\t// http://replays.firestoneapp.com/?reviewId=4ad32e03-2620-4fb1-8b43-cad55afd30fc&turn=27&action=2\r\n\t// One of the trinkets is Blood Golem Sticker, and no Blood Golem is summoned\r\n\t// Looks like that's not always the case:\r\n\t// http://replays.firestoneapp.com/?reviewId=9958e8d3-4388-4e6f-9b36-35f3a08be2f6&turn=25&action=4\r\n\t// playerInfo.player.trinkets = isGhost ? [] : playerInfo.player.trinkets?.filter((e) => !!e?.cardId) ?? [];\r\n\tplayerInfo.player.trinkets = playerInfo.player.trinkets?.filter((e) => !!e?.cardId) ?? [];\r\n\tplayerInfo.player.friendly = isPlayer;\r\n\tplayerInfo.player.globalInfo = playerInfo.player.globalInfo ?? {};\r\n\tplayerInfo.player.globalInfo.PirateAttackBonus = playerInfo.player.globalInfo.PirateAttackBonus ?? 0;\r\n\tplayerInfo.player.heroPowerId =\r\n\t\tplayerInfo.player.trinkets.find((t) => t.scriptDataNum6 === 3)?.cardId ??\r\n\t\t(normalizeHeroCardId(playerInfo.player.cardId, cards) === CardIds.SireDenathrius_BG24_HERO_100\r\n\t\t\t? playerInfo.player.questRewardEntities?.[0]?.cardId\r\n\t\t\t: null) ??\r\n\t\tplayerInfo.player.heroPowerId;\r\n\tplayerInfo.player.cardId = isGhost ? CardIds.Kelthuzad_TB_BaconShop_HERO_KelThuzad : playerInfo.player.cardId;\r\n\t// When using the simulator, the aura is not applied when receiving the board state.\r\n\tsetMissingAuras(board, playerInfo.player, cards);\r\n\t// Avenge, maxHealth, etc.\r\n\t// setImplicitData(playerBoard, cardsData);\r\n\t// setImplicitData(opponentBoard, cardsData);\r\n\t// Avenge, globalInfo\r\n\tsetImplicitDataHero(playerInfo.player, cardsData, isPlayer, entityIdContainer);\r\n\treturn { board, hand, player: playerInfo.player };\r\n};\r\n\r\nconst buildFinalInputBoard = (\r\n\tplayerInfo: BgsBoardInfo,\r\n\tisPlayer: boolean,\r\n\tcardsData: CardsData,\r\n\tcards: AllCardsService,\r\n): { board: BoardEntity[]; hand: BoardEntity[] } => {\r\n\tconst board = playerInfo.board\r\n\t\t.map((entity) => fixEnchantments(entity, cards))\r\n\t\t.map((entity) => ({ ...entity, inInitialState: true }))\r\n\t\t.map((entity) => ({ ...addImpliedMechanics(entity, cardsData), friendly: isPlayer } as BoardEntity));\r\n\tconst hand =\r\n\t\tplayerInfo.player.hand\r\n\t\t\t?.map((entity) => ({ ...entity, inInitialState: true }))\r\n\t\t\t.map((entity) => ({ ...addImpliedMechanics(entity, cardsData), friendly: isPlayer } as BoardEntity)) ?? [];\r\n\r\n\treturn { board, hand };\r\n};\r\n"]}
@@ -0,0 +1,4 @@
1
+ import { BgsPlayerEntity } from '../bgs-player-entity';
2
+ import { BoardEntity } from '../board-entity';
3
+ import { FullGameState } from './internal-game-state';
4
+ export declare const applyAfterAttackEffects: (attackingEntity: BoardEntity, attackingBoard: BoardEntity[], attackingBoardHero: BgsPlayerEntity, defendingEntity: BoardEntity, defendingBoardHero: BgsPlayerEntity, damageDoneByAttacker: number, damageDoneByDefender: number, gameState: FullGameState) => void;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applyAfterAttackEffects = void 0;
4
+ const reference_data_1 = require("@firestone-hs/reference-data");
5
+ const utils_1 = require("../utils");
6
+ const blood_gems_1 = require("./blood-gems");
7
+ const cards_in_hand_1 = require("./cards-in-hand");
8
+ const deathrattle_orchestration_1 = require("./deathrattle-orchestration");
9
+ const deathrattle_utils_1 = require("./deathrattle-utils");
10
+ const quest_1 = require("./quest");
11
+ const stats_1 = require("./stats");
12
+ const applyAfterAttackEffects = (attackingEntity, attackingBoard, attackingBoardHero, defendingEntity, defendingBoardHero, damageDoneByAttacker, damageDoneByDefender, gameState) => {
13
+ var _a, _b;
14
+ let secretTriggered = null;
15
+ if ((secretTriggered = (_a = defendingBoardHero.secrets) === null || _a === void 0 ? void 0 : _a.find((secret) => !secret.triggered && (secret === null || secret === void 0 ? void 0 : secret.cardId) === "TB_Bacon_Secrets_14")) != null) {
16
+ if (damageDoneByAttacker >= 3 && !(attackingEntity.health <= 0 || attackingEntity.definitelyDead)) {
17
+ secretTriggered.triggered = true;
18
+ attackingEntity.definitelyDead = true;
19
+ gameState.spectator.registerPowerTarget(secretTriggered, attackingEntity, attackingBoard, defendingBoardHero, attackingBoardHero);
20
+ }
21
+ }
22
+ if (attackingEntity.cardId === "BG20_104" || attackingEntity.cardId === "BG20_104_G") {
23
+ const quantity = attackingEntity.cardId === "BG20_104_G" ? 2 : 1;
24
+ const cards = quantity === 1 ? ["BG20_GEM"] : ["BG20_GEM", "BG20_GEM"];
25
+ (0, cards_in_hand_1.addCardsInHand)(attackingBoardHero, attackingBoard, cards, gameState);
26
+ }
27
+ else if (attackingEntity.cardId === "BG23_350" || attackingEntity.cardId === "BG23_350_G") {
28
+ const modifier = attackingEntity.cardId === "BG23_350_G" ? 2 : 1;
29
+ (0, utils_1.grantStatsToMinionsOfEachType)(attackingEntity, attackingBoard, attackingBoardHero, modifier * 1, modifier * 2, gameState);
30
+ }
31
+ else if (attackingEntity.cardId === "BG26_RLK_117" ||
32
+ attackingEntity.cardId === "BG26_RLK_117_G") {
33
+ attackingEntity.definitelyDead = true;
34
+ }
35
+ else if (attackingEntity.cardId === "BGS_078" ||
36
+ attackingEntity.cardId === "TB_BaconUps_135") {
37
+ const loops = attackingEntity.cardId === "TB_BaconUps_135" ? 2 : 1;
38
+ const validDeathrattles = (0, deathrattle_utils_1.getValidDeathrattles)(attackingBoard.filter((e) => e.entityId !== attackingEntity.entityId), gameState);
39
+ const leftMost = validDeathrattles[0];
40
+ if (!!leftMost) {
41
+ for (let i = 0; i < loops; i++) {
42
+ gameState.spectator.registerPowerTarget(attackingEntity, leftMost, attackingBoard, attackingBoardHero, defendingBoardHero);
43
+ const indexFromRight = attackingBoard.length - (attackingBoard.indexOf(leftMost) + 1);
44
+ (0, deathrattle_orchestration_1.processDeathrattleForMinion)(leftMost, indexFromRight, [leftMost], leftMost.friendly ? gameState.gameState.player : gameState.gameState.opponent, leftMost.friendly ? gameState.gameState.opponent : gameState.gameState.player, gameState, false);
45
+ }
46
+ }
47
+ }
48
+ else if ((_b = attackingEntity.additionalCards) === null || _b === void 0 ? void 0 : _b.includes("BG26_RLK_117")) {
49
+ attackingEntity.definitelyDead = true;
50
+ }
51
+ attackingBoard
52
+ .filter((e) => { var _a; return (_a = e.additionalCards) === null || _a === void 0 ? void 0 : _a.includes("BG_GIL_655"); })
53
+ .forEach((e) => {
54
+ (0, stats_1.modifyStats)(e, 1, 0, attackingBoard, attackingBoardHero, gameState);
55
+ });
56
+ attackingEntity.stealth = false;
57
+ applyOnAttackQuest(attackingEntity, attackingBoard, attackingBoardHero, gameState);
58
+ };
59
+ exports.applyAfterAttackEffects = applyAfterAttackEffects;
60
+ const applyOnAttackQuest = (attackingEntity, attackingBoard, attackingBoardHero, gameState) => {
61
+ var _a, _b;
62
+ const quests = (_a = attackingBoardHero.questEntities) !== null && _a !== void 0 ? _a : [];
63
+ for (const quest of quests) {
64
+ switch (quest.CardId) {
65
+ case "BG24_Quest_352":
66
+ (0, quest_1.onQuestProgressUpdated)(attackingBoardHero, quest, attackingBoard, gameState);
67
+ break;
68
+ }
69
+ }
70
+ const trinkets = (_b = attackingBoardHero.trinkets) !== null && _b !== void 0 ? _b : [];
71
+ for (const trinket of trinkets) {
72
+ switch (trinket.cardId) {
73
+ case "BG30_MagicItem_546":
74
+ trinket.scriptDataNum1--;
75
+ if (trinket.scriptDataNum1 <= 0) {
76
+ for (const entity of attackingBoard.filter((e) => (0, utils_1.hasCorrectTribe)(e, attackingBoardHero, reference_data_1.Race.QUILBOAR, gameState.allCards))) {
77
+ (0, blood_gems_1.playBloodGemsOn)(trinket, entity, 1, attackingBoard, attackingBoardHero, gameState);
78
+ gameState.spectator.registerPowerTarget(trinket, entity, attackingBoard, attackingBoardHero, attackingBoardHero);
79
+ }
80
+ trinket.scriptDataNum1 = gameState.cardsData.defaultScriptDataNum(trinket.cardId);
81
+ }
82
+ break;
83
+ }
84
+ }
85
+ };
86
+ //# sourceMappingURL=after-attack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"after-attack.js","sourceRoot":"","sources":["../../src/simulation/after-attack.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAG7D,oCAA0E;AAC1E,6CAA+C;AAC/C,mDAAiD;AACjD,2EAA0E;AAC1E,2DAA2D;AAE3D,mCAAiD;AACjD,mCAAsC;AAE/B,MAAM,uBAAuB,GAAG,CACtC,eAA4B,EAC5B,cAA6B,EAC7B,kBAAmC,EACnC,eAA4B,EAC5B,kBAAmC,EACnC,oBAA4B,EAC5B,oBAA4B,EAC5B,SAAwB,EACjB,EAAE;;IACT,IAAI,eAAe,GAAG,IAAI,CAAC;IAC3B,IACC,CAAC,eAAe,GAAG,MAAA,kBAAkB,CAAC,OAAO,0CAAE,IAAI,CAClD,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,IAAI,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,2BAA0C,CACzF,CAAC,IAAI,IAAI,EACT;QAED,IAAI,oBAAoB,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,MAAM,IAAI,CAAC,IAAI,eAAe,CAAC,cAAc,CAAC,EAAE;YAClG,eAAe,CAAC,SAAS,GAAG,IAAI,CAAC;YACjC,eAAe,CAAC,cAAc,GAAG,IAAI,CAAC;YACtC,SAAS,CAAC,SAAS,CAAC,mBAAmB,CACtC,eAAe,EACf,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,kBAAkB,CAClB,CAAC;SACF;KACD;IAED,IAAI,eAAe,CAAC,MAAM,eAA4B,IAAI,eAAe,CAAC,MAAM,iBAA8B,EAAE;QAC/G,MAAM,QAAQ,GAAG,eAAe,CAAC,MAAM,iBAA8B,CAAC,CAAC,CAAC,CAAC,CAAC,CA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;;IACH,MAAM,MAAM,GAAG,MAAA,kBAAkB,CAAC,aAAa,mCAAI,EAAE,CAAC;IACtD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;QAC3B,QAAQ,KAAK,CAAC,MAAM,EAAE;YACrB;gBACC,IAAA,8BAAsB,EAAC,kBAAkB,EAAE,KAAK,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;gBAC7E,MAAM;SACP;KACD;IAED,MAAM,QAAQ,GAAG,MAAA,kBAAkB,CAAC,QAAQ,mCAAI,EAAE,CAAC;IACnD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;QAC/B,QAAQ,OAAO,CAAC,MAAM,EAAE;YACvB;gBACC,OAAO,CAAC,cAAc,EAAE,CAAC;gBACzB,IAAI,OAAO,CAAC,cAAc,IAAI,CAAC,EAAE;oBAChC,KAAK,MAAM,MAAM,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAChD,IAAA,uBAAe,EAAC,CAAC,EAAE,kBAAkB,EAAE,qBAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC,CACzE,EAAE;wBACF,IAAA,4BAAe,EAAC,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,cAAc,EAAE,kBAAkB,EAAE,SAAS,CAAC,CAAC;wBACnF,SAAS,CAAC,SAAS,CAAC,mBAAmB,CACtC,OAAO,EACP,MAAM,EACN,cAAc,EACd,kBAAkB,EAClB,kBAAkB,CAClB,CAAC;qBACF;oBACD,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,SAAS,CAAC,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;iBAClF;gBACD,MAAM;SACP;KACD;AACF,CAAC,CAAC","sourcesContent":["import { CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { grantStatsToMinionsOfEachType, hasCorrectTribe } from '../utils';\r\nimport { playBloodGemsOn } from './blood-gems';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport { processDeathrattleForMinion } from './deathrattle-orchestration';\r\nimport { getValidDeathrattles } from './deathrattle-utils';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { onQuestProgressUpdated } from './quest';\r\nimport { modifyStats } from './stats';\r\n\r\nexport const applyAfterAttackEffects = (\r\n\tattackingEntity: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingEntity: BoardEntity,\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tdamageDoneByAttacker: number,\r\n\tdamageDoneByDefender: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tlet secretTriggered = null;\r\n\tif (\r\n\t\t(secretTriggered = defendingBoardHero.secrets?.find(\r\n\t\t\t(secret) => !secret.triggered && secret?.cardId === CardIds.Reckoning_TB_Bacon_Secrets_14,\r\n\t\t)) != null\r\n\t) {\r\n\t\t// console.log('triggering secret?', damageDoneByAttacker, stringifySimpleCard(attackingEntity, allCards));\r\n\t\tif (damageDoneByAttacker >= 3 && !(attackingEntity.health <= 0 || attackingEntity.definitelyDead)) {\r\n\t\t\tsecretTriggered.triggered = true;\r\n\t\t\tattackingEntity.definitelyDead = true;\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tsecretTriggered,\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\tif (attackingEntity.cardId === CardIds.Bonker_BG20_104 || attackingEntity.cardId === CardIds.Bonker_BG20_104_G) {\r\n\t\tconst quantity = attackingEntity.cardId === CardIds.Bonker_BG20_104_G ? 2 : 1;\r\n\t\tconst cards = quantity === 1 ? [CardIds.BloodGem] : [CardIds.BloodGem, CardIds.BloodGem];\r\n\t\taddCardsInHand(attackingBoardHero, attackingBoard, cards, gameState);\r\n\t} else if (attackingEntity.cardId === CardIds.Yrel_BG23_350 || attackingEntity.cardId === CardIds.Yrel_BG23_350_G) {\r\n\t\tconst modifier = attackingEntity.cardId === CardIds.Yrel_BG23_350_G ? 2 : 1;\r\n\t\tgrantStatsToMinionsOfEachType(\r\n\t\t\tattackingEntity,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tmodifier * 1,\r\n\t\t\tmodifier * 2,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t} else if (\r\n\t\tattackingEntity.cardId === CardIds.IncorporealCorporal_BG26_RLK_117 ||\r\n\t\tattackingEntity.cardId === CardIds.IncorporealCorporal_BG26_RLK_117_G\r\n\t) {\r\n\t\tattackingEntity.definitelyDead = true;\r\n\t} else if (\r\n\t\tattackingEntity.cardId === CardIds.MonstrousMacaw_BGS_078 ||\r\n\t\tattackingEntity.cardId === CardIds.MonstrousMacaw_TB_BaconUps_135\r\n\t) {\r\n\t\tconst loops = attackingEntity.cardId === CardIds.MonstrousMacaw_TB_BaconUps_135 ? 2 : 1;\r\n\t\tconst validDeathrattles = getValidDeathrattles(\r\n\t\t\tattackingBoard.filter((e) => e.entityId !== attackingEntity.entityId),\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tconst leftMost = validDeathrattles[0];\r\n\t\tif (!!leftMost) {\r\n\t\t\tfor (let i = 0; i < loops; i++) {\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattackingEntity,\r\n\t\t\t\t\tleftMost,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t);\r\n\t\t\t\tconst indexFromRight = attackingBoard.length - (attackingBoard.indexOf(leftMost) + 1);\r\n\t\t\t\tprocessDeathrattleForMinion(\r\n\t\t\t\t\tleftMost,\r\n\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\t[leftMost],\r\n\t\t\t\t\tleftMost.friendly ? gameState.gameState.player : gameState.gameState.opponent,\r\n\t\t\t\t\tleftMost.friendly ? gameState.gameState.opponent : gameState.gameState.player,\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\t// Putricide-only\r\n\telse if (attackingEntity.additionalCards?.includes(CardIds.IncorporealCorporal_BG26_RLK_117)) {\r\n\t\tattackingEntity.definitelyDead = true;\r\n\t}\r\n\r\n\tattackingBoard\r\n\t\t.filter((e) => e.additionalCards?.includes(CardIds.FesterootHulk_BG_GIL_655))\r\n\t\t.forEach((e) => {\r\n\t\t\tmodifyStats(e, 1, 0, attackingBoard, attackingBoardHero, gameState);\r\n\t\t});\r\n\r\n\tattackingEntity.stealth = false;\r\n\r\n\tapplyOnAttackQuest(attackingEntity, attackingBoard, attackingBoardHero, gameState);\r\n};\r\n\r\nconst applyOnAttackQuest = (\r\n\tattackingEntity: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst quests = attackingBoardHero.questEntities ?? [];\r\n\tfor (const quest of quests) {\r\n\t\tswitch (quest.CardId) {\r\n\t\t\tcase CardIds.CrackTheCase:\r\n\t\t\t\tonQuestProgressUpdated(attackingBoardHero, quest, attackingBoard, gameState);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tconst trinkets = attackingBoardHero.trinkets ?? [];\r\n\tfor (const trinket of trinkets) {\r\n\t\tswitch (trinket.cardId) {\r\n\t\t\tcase CardIds.JarOGems_BG30_MagicItem_546:\r\n\t\t\t\ttrinket.scriptDataNum1--;\r\n\t\t\t\tif (trinket.scriptDataNum1 <= 0) {\r\n\t\t\t\t\tfor (const entity of attackingBoard.filter((e) =>\r\n\t\t\t\t\t\thasCorrectTribe(e, attackingBoardHero, Race.QUILBOAR, gameState.allCards),\r\n\t\t\t\t\t)) {\r\n\t\t\t\t\t\tplayBloodGemsOn(trinket, entity, 1, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\ttrinket,\r\n\t\t\t\t\t\t\tentity,\r\n\t\t\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\ttrinket.scriptDataNum1 = gameState.cardsData.defaultScriptDataNum(trinket.cardId);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n"]}
@@ -5,19 +5,16 @@ const reference_data_1 = require("@firestone-hs/reference-data");
5
5
  const divine_shield_1 = require("../divine-shield");
6
6
  const utils_1 = require("../services/utils");
7
7
  const utils_2 = require("../utils");
8
- const blood_gems_1 = require("./blood-gems");
9
- const cards_in_hand_1 = require("./cards-in-hand");
8
+ const after_attack_1 = require("./after-attack");
10
9
  const damage_effects_1 = require("./damage-effects");
11
10
  const deathrattle_effects_1 = require("./deathrattle-effects");
12
11
  const deathrattle_orchestration_1 = require("./deathrattle-orchestration");
13
12
  const deathrattle_spawns_1 = require("./deathrattle-spawns");
14
- const deathrattle_utils_1 = require("./deathrattle-utils");
15
13
  const frenzy_1 = require("./frenzy");
16
14
  const minion_death_1 = require("./minion-death");
17
15
  const minion_kill_1 = require("./minion-kill");
18
16
  const on_attack_1 = require("./on-attack");
19
17
  const on_being_attacked_1 = require("./on-being-attacked");
20
- const quest_1 = require("./quest");
21
18
  const spawns_1 = require("./spawns");
22
19
  const stats_1 = require("./stats");
23
20
  const summon_when_space_1 = require("./summon-when-space");
@@ -61,7 +58,7 @@ const doFullAttack = (attackingEntity, attackingBoard, attackingBoardHero, defen
61
58
  (0, on_being_attacked_1.applyOnBeingAttackedBuffs)(attackingEntity, attackingBoard, attackingBoardHero, defendingEntity, defendingBoard, defendingBoardHero, gameState);
62
59
  (0, on_attack_1.applyOnAttackEffects)(attackingEntity, attackingBoard, attackingBoardHero, defendingEntity, defendingBoard, defendingBoardHero, gameState);
63
60
  const { damageDoneByAttacker, damageDoneByDefender } = performAttack(attackingEntity, defendingEntity, attackingBoard, attackingBoardHero, defendingBoard, defendingBoardHero, gameState);
64
- applyAfterAttackEffects(attackingEntity, attackingBoard, attackingBoardHero, defendingEntity, defendingBoardHero, damageDoneByAttacker, damageDoneByDefender, gameState);
61
+ (0, after_attack_1.applyAfterAttackEffects)(attackingEntity, attackingBoard, attackingBoardHero, defendingEntity, defendingBoardHero, damageDoneByAttacker, damageDoneByDefender, gameState);
65
62
  (0, exports.processMinionDeath)(attackingBoard, attackingBoardHero, defendingBoard, defendingBoardHero, gameState);
66
63
  (0, stats_1.applyAfterStatsUpdate)(gameState);
67
64
  attackingEntity.immuneWhenAttackCharges = Math.max(0, ((_a = attackingEntity.immuneWhenAttackCharges) !== null && _a !== void 0 ? _a : 0) - 1);
@@ -76,66 +73,6 @@ const doFullAttack = (attackingEntity, attackingBoard, attackingBoardHero, defen
76
73
  }
77
74
  };
78
75
  exports.doFullAttack = doFullAttack;
79
- const applyAfterAttackEffects = (attackingEntity, attackingBoard, attackingBoardHero, defendingEntity, defendingBoardHero, damageDoneByAttacker, damageDoneByDefender, gameState) => {
80
- var _a, _b;
81
- let secretTriggered = null;
82
- if ((secretTriggered = (_a = defendingBoardHero.secrets) === null || _a === void 0 ? void 0 : _a.find((secret) => !secret.triggered && (secret === null || secret === void 0 ? void 0 : secret.cardId) === "TB_Bacon_Secrets_14")) != null) {
83
- if (damageDoneByAttacker >= 3 && !(attackingEntity.health <= 0 || attackingEntity.definitelyDead)) {
84
- secretTriggered.triggered = true;
85
- attackingEntity.definitelyDead = true;
86
- gameState.spectator.registerPowerTarget(secretTriggered, attackingEntity, attackingBoard, defendingBoardHero, attackingBoardHero);
87
- }
88
- }
89
- if (attackingEntity.cardId === "BG20_104" || attackingEntity.cardId === "BG20_104_G") {
90
- const quantity = attackingEntity.cardId === "BG20_104_G" ? 2 : 1;
91
- const cards = quantity === 1 ? ["BG20_GEM"] : ["BG20_GEM", "BG20_GEM"];
92
- (0, cards_in_hand_1.addCardsInHand)(attackingBoardHero, attackingBoard, cards, gameState);
93
- }
94
- else if (attackingEntity.cardId === "BG23_350" || attackingEntity.cardId === "BG23_350_G") {
95
- const modifier = attackingEntity.cardId === "BG23_350_G" ? 2 : 1;
96
- (0, utils_2.grantStatsToMinionsOfEachType)(attackingEntity, attackingBoard, attackingBoardHero, modifier * 1, modifier * 2, gameState);
97
- }
98
- else if (attackingEntity.cardId === "BG26_RLK_117" ||
99
- attackingEntity.cardId === "BG26_RLK_117_G") {
100
- attackingEntity.definitelyDead = true;
101
- }
102
- else if ((_b = attackingEntity.additionalCards) === null || _b === void 0 ? void 0 : _b.includes("BG26_RLK_117")) {
103
- attackingEntity.definitelyDead = true;
104
- }
105
- attackingBoard
106
- .filter((e) => { var _a; return (_a = e.additionalCards) === null || _a === void 0 ? void 0 : _a.includes("BG_GIL_655"); })
107
- .forEach((e) => {
108
- (0, stats_1.modifyStats)(e, 1, 0, attackingBoard, attackingBoardHero, gameState);
109
- });
110
- attackingEntity.stealth = false;
111
- applyOnAttackQuest(attackingEntity, attackingBoard, attackingBoardHero, gameState);
112
- };
113
- const applyOnAttackQuest = (attackingEntity, attackingBoard, attackingBoardHero, gameState) => {
114
- var _a, _b;
115
- const quests = (_a = attackingBoardHero.questEntities) !== null && _a !== void 0 ? _a : [];
116
- for (const quest of quests) {
117
- switch (quest.CardId) {
118
- case "BG24_Quest_352":
119
- (0, quest_1.onQuestProgressUpdated)(attackingBoardHero, quest, attackingBoard, gameState);
120
- break;
121
- }
122
- }
123
- const trinkets = (_b = attackingBoardHero.trinkets) !== null && _b !== void 0 ? _b : [];
124
- for (const trinket of trinkets) {
125
- switch (trinket.cardId) {
126
- case "BG30_MagicItem_546":
127
- trinket.scriptDataNum1--;
128
- if (trinket.scriptDataNum1 <= 0) {
129
- for (const entity of attackingBoard.filter((e) => (0, utils_2.hasCorrectTribe)(e, attackingBoardHero, reference_data_1.Race.QUILBOAR, gameState.allCards))) {
130
- (0, blood_gems_1.playBloodGemsOn)(trinket, entity, 1, attackingBoard, attackingBoardHero, gameState);
131
- gameState.spectator.registerPowerTarget(trinket, entity, attackingBoard, attackingBoardHero, attackingBoardHero);
132
- }
133
- trinket.scriptDataNum1 = gameState.cardsData.defaultScriptDataNum(trinket.cardId);
134
- }
135
- break;
136
- }
137
- }
138
- };
139
76
  const performAttack = (attackingEntity, defendingEntity, attackingBoard, attackingBoardHero, defendingBoard, defendingBoardHero, gameState) => {
140
77
  let damageDoneByAttacker = 0;
141
78
  let damageDoneByDefender = 0;
@@ -244,38 +181,12 @@ const performAttack = (attackingEntity, defendingEntity, attackingBoard, attacki
244
181
  }
245
182
  }
246
183
  }
247
- if (attackingEntity.cardId === "BGS_078" ||
248
- attackingEntity.cardId === "TB_BaconUps_135") {
249
- const loops = attackingEntity.cardId === "TB_BaconUps_135" ? 2 : 1;
250
- const validDeathrattles = (0, deathrattle_utils_1.getValidDeathrattles)(attackingBoard.filter((e) => e.entityId !== attackingEntity.entityId), gameState);
251
- const leftMost = validDeathrattles[0];
252
- if (!!leftMost) {
253
- for (let i = 0; i < loops; i++) {
254
- gameState.spectator.registerPowerTarget(attackingEntity, leftMost, attackingBoard, attackingBoardHero, defendingBoardHero);
255
- const indexFromRight = attackingBoard.length - (attackingBoard.indexOf(leftMost) + 1);
256
- (0, deathrattle_orchestration_1.processDeathrattleForMinion)(leftMost, indexFromRight, [leftMost], leftMost.friendly ? gameState.gameState.player : gameState.gameState.opponent, leftMost.friendly ? gameState.gameState.opponent : gameState.gameState.player, gameState, false);
257
- }
258
- }
259
- }
260
184
  attackingEntity.attackImmediately = false;
261
185
  if (attackingEntity.enchantments.some((e) => e.cardId === "BG24_Reward_364e")) {
262
186
  attackingEntity.definitelyDead = true;
263
187
  }
264
188
  return { damageDoneByAttacker, damageDoneByDefender };
265
189
  };
266
- const triggerRandomDeathrattle = (sourceEntity, attackingBoard, attackingBoardHero, defendingBoard, defendingBoardHero, gameState, excludeSource = false) => {
267
- const validDeathrattles = (0, deathrattle_utils_1.getValidDeathrattles)(attackingBoard, gameState).filter((entity) => !excludeSource || entity.entityId !== sourceEntity.entityId);
268
- if (validDeathrattles.length === 0) {
269
- return;
270
- }
271
- const targetEntity = (0, utils_1.pickRandom)(validDeathrattles);
272
- if (!(targetEntity === null || targetEntity === void 0 ? void 0 : targetEntity.cardId)) {
273
- console.error('missing card id when triggering random deathrattle', (0, utils_2.stringifySimpleCard)(targetEntity, gameState.allCards), targetEntity, validDeathrattles.length, (0, utils_2.stringifySimple)(validDeathrattles, gameState.allCards), (0, utils_2.stringifySimple)(attackingBoard, gameState.allCards), excludeSource, (0, utils_2.stringifySimpleCard)(sourceEntity, gameState.allCards));
274
- }
275
- gameState.spectator.registerPowerTarget(sourceEntity, targetEntity, attackingBoard, attackingBoardHero, defendingBoardHero);
276
- const indexFromRight = attackingBoard.length - (attackingBoard.indexOf(targetEntity) + 1);
277
- (0, deathrattle_orchestration_1.processDeathrattleForMinion)(targetEntity, indexFromRight, [targetEntity], targetEntity.friendly ? gameState.gameState.player : gameState.gameState.opponent, targetEntity.friendly ? gameState.gameState.opponent : gameState.gameState.player, gameState, false);
278
- };
279
190
  const getAttackingEntity = (attackingBoard, allCards) => {
280
191
  const debug = attackingBoard.map((e) => {
281
192
  var _a;