@firestone-hs/simulate-bgs-battle 1.1.733 → 1.1.734

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/cards/impl/enchantments/offensive-sacrifice.js +4 -2
  2. package/dist/cards/impl/enchantments/offensive-sacrifice.js.map +1 -1
  3. package/dist/cards/impl/enchantments/resistance.js +1 -1
  4. package/dist/cards/impl/enchantments/resistance.js.map +1 -1
  5. package/dist/cards/impl/enchantments/toreths-blessing.js +1 -0
  6. package/dist/cards/impl/enchantments/toreths-blessing.js.map +1 -1
  7. package/dist/cards/impl/minion/deathstrider.d.ts +2 -2
  8. package/dist/cards/impl/minion/deathstrider.js +1 -1
  9. package/dist/cards/impl/minion/deathstrider.js.map +1 -1
  10. package/dist/cards/impl/minion/flourishing-frostling.js +0 -2
  11. package/dist/cards/impl/minion/flourishing-frostling.js.map +1 -1
  12. package/dist/cards/impl/minion/glowing-cinder.js +1 -1
  13. package/dist/cards/impl/minion/glowing-cinder.js.map +1 -1
  14. package/dist/cards/impl/minion/polarizing-beatboxer.js +2 -1
  15. package/dist/cards/impl/minion/polarizing-beatboxer.js.map +1 -1
  16. package/dist/cards/impl/trinket/deathtouch-apple.d.ts +2 -2
  17. package/dist/cards/impl/trinket/deathtouch-apple.js +0 -1
  18. package/dist/cards/impl/trinket/deathtouch-apple.js.map +1 -1
  19. package/dist/services/utils.d.ts +1 -1
  20. package/dist/services/utils.js +2 -2
  21. package/dist/services/utils.js.map +1 -1
  22. package/dist/simulation/after-attack.d.ts +1 -1
  23. package/dist/simulation/after-attack.js +21 -3
  24. package/dist/simulation/after-attack.js.map +1 -1
  25. package/dist/simulation/attack.d.ts +1 -1
  26. package/dist/simulation/attack.js +5 -4
  27. package/dist/simulation/attack.js.map +1 -1
  28. package/dist/simulation/auras.js +9 -6
  29. package/dist/simulation/auras.js.map +1 -1
  30. package/dist/simulation/magnetize.d.ts +2 -3
  31. package/dist/simulation/magnetize.js +15 -16
  32. package/dist/simulation/magnetize.js.map +1 -1
  33. package/dist/simulation/remove-minion-from-board.js.map +1 -1
  34. package/dist/simulation/spectator/spectator.d.ts +2 -2
  35. package/dist/simulation/spectator/spectator.js +2 -1
  36. package/dist/simulation/spectator/spectator.js.map +1 -1
  37. package/dist/simulation/stats.d.ts +2 -2
  38. package/dist/simulation/stats.js +4 -5
  39. package/dist/simulation/stats.js.map +1 -1
  40. package/package.json +1 -1
@@ -7,7 +7,7 @@ const _card_mappings_1 = require("../cards/impl/_card-mappings");
7
7
  const utils_1 = require("../utils");
8
8
  const stats_1 = require("./stats");
9
9
  const magnetizeToTarget = (inputTargets, source, cardsToMagnetize, board, hero, otherBoard, otherHero, gameState, isFirstTimeMagnetize = true) => {
10
- var _a, _b, _c, _d, _e, _f, _g, _h;
10
+ var _a;
11
11
  const electromagneticDevices = hero.trinkets.filter((t) => t.cardId === "BG30_MagicItem_709").length;
12
12
  const greaterElecromagneticDevices = hero.trinkets.filter((t) => t.cardId === "BG30_MagicItem_709t").length;
13
13
  const magnetMult = board.some((e) => e.cardId === "BG34_177_G")
@@ -41,7 +41,7 @@ const magnetizeToTarget = (inputTargets, source, cardsToMagnetize, board, hero,
41
41
  onBeforeMagnetizeImpl.onBeforeMagnetize(boardEntity, {
42
42
  board: board,
43
43
  hero: hero,
44
- magnetizedCard: modularCard,
44
+ magnetizedCard: modularBoardEntity,
45
45
  magnetizeTarget: target,
46
46
  gameState: gameState,
47
47
  });
@@ -53,21 +53,20 @@ const magnetizeToTarget = (inputTargets, source, cardsToMagnetize, board, hero,
53
53
  onBeforeMagnetizeImpl.onBeforeMagnetize(trinket, {
54
54
  board: board,
55
55
  hero: hero,
56
- magnetizedCard: modularCard,
56
+ magnetizedCard: modularBoardEntity,
57
57
  magnetizeTarget: target,
58
58
  gameState: gameState,
59
59
  });
60
60
  }
61
61
  }
62
62
  (0, stats_1.modifyStats)(target, source, modularBoardEntity.attack + 2 * electromagneticDevices + 4 * greaterElecromagneticDevices, modularBoardEntity.health + 2 * electromagneticDevices + 4 * greaterElecromagneticDevices, board, hero, gameState);
63
- target.taunt = target.taunt || ((_a = modularCard.mechanics) === null || _a === void 0 ? void 0 : _a.includes(reference_data_1.GameTag[reference_data_1.GameTag.TAUNT]));
64
- target.divineShield =
65
- target.divineShield || ((_b = modularCard.mechanics) === null || _b === void 0 ? void 0 : _b.includes(reference_data_1.GameTag[reference_data_1.GameTag.DIVINE_SHIELD]));
66
- target.poisonous = target.poisonous || ((_c = modularCard.mechanics) === null || _c === void 0 ? void 0 : _c.includes(reference_data_1.GameTag[reference_data_1.GameTag.POISONOUS]));
67
- target.venomous = target.venomous || ((_d = modularCard.mechanics) === null || _d === void 0 ? void 0 : _d.includes(reference_data_1.GameTag[reference_data_1.GameTag.VENOMOUS]));
68
- target.windfury = target.windfury || ((_e = modularCard.mechanics) === null || _e === void 0 ? void 0 : _e.includes(reference_data_1.GameTag[reference_data_1.GameTag.WINDFURY]));
69
- target.reborn = target.reborn || ((_f = modularCard.mechanics) === null || _f === void 0 ? void 0 : _f.includes(reference_data_1.GameTag[reference_data_1.GameTag.REBORN]));
70
- target.stealth = target.stealth || ((_g = modularCard.mechanics) === null || _g === void 0 ? void 0 : _g.includes(reference_data_1.GameTag[reference_data_1.GameTag.STEALTH]));
63
+ target.taunt = target.taunt || modularBoardEntity.taunt;
64
+ target.divineShield = target.divineShield || modularBoardEntity.divineShield;
65
+ target.poisonous = target.poisonous || modularBoardEntity.poisonous;
66
+ target.venomous = target.venomous || modularBoardEntity.venomous;
67
+ target.windfury = target.windfury || modularBoardEntity.windfury;
68
+ target.reborn = target.reborn || modularBoardEntity.reborn;
69
+ target.stealth = target.stealth || modularBoardEntity.stealth;
71
70
  const magneticEnchantment = modularCard.enchantmentDbfId;
72
71
  if (magneticEnchantment) {
73
72
  const enchantment = gameState.allCards.getCard(magneticEnchantment).id;
@@ -100,7 +99,7 @@ const magnetizeToTarget = (inputTargets, source, cardsToMagnetize, board, hero,
100
99
  gameState: gameState,
101
100
  });
102
101
  }
103
- const onAfterMagnetizeImpl = _card_mappings_1.cardMappings[modularCard.id];
102
+ const onAfterMagnetizeImpl = _card_mappings_1.cardMappings[modularBoardEntity.cardId];
104
103
  if ((0, card_interface_1.hasOnAfterMagnetizeSelf)(onAfterMagnetizeImpl)) {
105
104
  onAfterMagnetizeImpl.onAfterMagnetizeSelf(target, {
106
105
  board: board,
@@ -108,7 +107,7 @@ const magnetizeToTarget = (inputTargets, source, cardsToMagnetize, board, hero,
108
107
  source: source,
109
108
  otherHero: otherHero,
110
109
  otherBoard: otherBoard,
111
- magnetizedCard: modularCard,
110
+ magnetizedCard: modularBoardEntity,
112
111
  magnetizeTarget: target,
113
112
  gameState: gameState,
114
113
  });
@@ -122,13 +121,13 @@ const magnetizeToTarget = (inputTargets, source, cardsToMagnetize, board, hero,
122
121
  source: source,
123
122
  otherHero: otherHero,
124
123
  otherBoard: otherBoard,
125
- magnetizedCard: modularCard,
124
+ magnetizedCard: modularBoardEntity,
126
125
  magnetizeTarget: target,
127
126
  gameState: gameState,
128
127
  });
129
128
  }
130
129
  }
131
- for (const trinket of (_h = hero.trinkets) !== null && _h !== void 0 ? _h : []) {
130
+ for (const trinket of (_a = hero.trinkets) !== null && _a !== void 0 ? _a : []) {
132
131
  const onAfterMagnetizeImpl = _card_mappings_1.cardMappings[trinket.cardId];
133
132
  if ((0, card_interface_1.hasOnAfterMagnetize)(onAfterMagnetizeImpl)) {
134
133
  onAfterMagnetizeImpl.onAfterMagnetize(trinket, {
@@ -137,7 +136,7 @@ const magnetizeToTarget = (inputTargets, source, cardsToMagnetize, board, hero,
137
136
  source: source,
138
137
  otherHero: otherHero,
139
138
  otherBoard: otherBoard,
140
- magnetizedCard: modularCard,
139
+ magnetizedCard: modularBoardEntity,
141
140
  magnetizeTarget: target,
142
141
  gameState: gameState,
143
142
  });
@@ -1 +1 @@
1
- {"version":3,"file":"magnetize.js","sourceRoot":"","sources":["../../src/simulation/magnetize.ts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MAAA,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,0CAAE,QAAQ,CAAC,wBAAO,CAAC,wBAAO,CAAC,OAAO,CAAC,CAAC,CAAA,EAAA,CAClF,CAAC,MAAM,CAAC;AACV,CAAC,CAAC;AAJW,QAAA,iBAAiB,qBAI5B","sourcesContent":["import { GameTag, ReferenceCard } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity, BoardTrinket } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport {\r\n\thasOnAfterMagnetize,\r\n\thasOnAfterMagnetizeSelf,\r\n\thasOnAfterMagnetizeToSelf,\r\n\thasOnBeforeMagnetize,\r\n\thasOnBeforeMagnetizeSelf,\r\n} from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { Mutable } from '../services/utils';\r\nimport { buildSingleBoardEntity } from '../utils';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { modifyStats } from './stats';\r\n\r\nexport const magnetizeToTarget = (\r\n\tinputTargets: BoardEntity[] | (() => BoardEntity[]),\r\n\tsource: BoardEntity | BoardTrinket,\r\n\tcardsToMagnetize: string[] | ReferenceCard[],\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tisFirstTimeMagnetize = true,\r\n) => {\r\n\tconst electromagneticDevices = hero.trinkets.filter(\r\n\t\t(t) => t.cardId === CardIds.ElectromagneticDevice_BG30_MagicItem_709,\r\n\t).length;\r\n\tconst greaterElecromagneticDevices = hero.trinkets.filter(\r\n\t\t(t) => t.cardId === CardIds.ElectromagneticDevice_ElectromagneticDeviceToken_BG30_MagicItem_709t,\r\n\t).length;\r\n\r\n\tconst magnetMult = board.some((e) => e.cardId === CardIds.DoubleDemolisher_BG34_177_G)\r\n\t\t? 3\r\n\t\t: board.some((e) => e.cardId === CardIds.DoubleDemolisher_BG34_177)\r\n\t\t? 2\r\n\t\t: 1;\r\n\tfor (let i = 0; i < magnetMult; i++) {\r\n\t\tconst actualTargets = typeof inputTargets === 'function' ? inputTargets() : inputTargets;\r\n\t\tfor (const target of actualTargets) {\r\n\t\t\tfor (const cardToMagnetize of cardsToMagnetize) {\r\n\t\t\t\tconst modularCard =\r\n\t\t\t\t\ttypeof cardToMagnetize === 'string'\r\n\t\t\t\t\t\t? { ...gameState.allCards.getCard(cardToMagnetize) }\r\n\t\t\t\t\t\t: cardToMagnetize;\r\n\t\t\t\tconst modularBoardEntity = buildSingleBoardEntity(\r\n\t\t\t\t\tmodularCard.id,\r\n\t\t\t\t\thero,\r\n\t\t\t\t\tboard,\r\n\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\thero.friendly,\r\n\t\t\t\t\tgameState.sharedState.currentEntityId++,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treferenceCardToUse: modularCard,\r\n\t\t\t\t\t},\r\n\t\t\t\t);\r\n\t\t\t\tconst onBeforeMagnetizeSelfImpl = cardMappings[modularBoardEntity.cardId];\r\n\t\t\t\tif (hasOnBeforeMagnetizeSelf(onBeforeMagnetizeSelfImpl)) {\r\n\t\t\t\t\tonBeforeMagnetizeSelfImpl.onBeforeMagnetizeSelf(modularBoardEntity, {\r\n\t\t\t\t\t\tboard: board,\r\n\t\t\t\t\t\thero: hero,\r\n\t\t\t\t\t\tmagnetizeTarget: target,\r\n\t\t\t\t\t\tgameState: gameState,\r\n\t\t\t\t\t\tisFirstTimeMagnetize: isFirstTimeMagnetize,\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\r\n\t\t\t\tfor (const boardEntity of board) {\r\n\t\t\t\t\tconst onBeforeMagnetizeImpl = cardMappings[boardEntity.cardId];\r\n\t\t\t\t\tif (hasOnBeforeMagnetize(onBeforeMagnetizeImpl)) {\r\n\t\t\t\t\t\tonBeforeMagnetizeImpl.onBeforeMagnetize(boardEntity, {\r\n\t\t\t\t\t\t\tboard: board,\r\n\t\t\t\t\t\t\thero: hero,\r\n\t\t\t\t\t\t\tmagnetizedCard: modularCard,\r\n\t\t\t\t\t\t\tmagnetizeTarget: target,\r\n\t\t\t\t\t\t\tgameState: gameState,\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\tfor (const trinket of hero.trinkets) {\r\n\t\t\t\t\tconst onBeforeMagnetizeImpl = cardMappings[trinket.cardId];\r\n\t\t\t\t\tif (hasOnBeforeMagnetize(onBeforeMagnetizeImpl)) {\r\n\t\t\t\t\t\tonBeforeMagnetizeImpl.onBeforeMagnetize(trinket, {\r\n\t\t\t\t\t\t\tboard: board,\r\n\t\t\t\t\t\t\thero: hero,\r\n\t\t\t\t\t\t\tmagnetizedCard: modularCard,\r\n\t\t\t\t\t\t\tmagnetizeTarget: target,\r\n\t\t\t\t\t\t\tgameState: gameState,\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tmodifyStats(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tsource,\r\n\t\t\t\t\tmodularBoardEntity.attack + 2 * electromagneticDevices + 4 * greaterElecromagneticDevices,\r\n\t\t\t\t\tmodularBoardEntity.health + 2 * electromagneticDevices + 4 * greaterElecromagneticDevices,\r\n\t\t\t\t\tboard,\r\n\t\t\t\t\thero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t\ttarget.taunt = target.taunt || modularCard.mechanics?.includes(GameTag[GameTag.TAUNT]);\r\n\t\t\t\ttarget.divineShield =\r\n\t\t\t\t\ttarget.divineShield || modularCard.mechanics?.includes(GameTag[GameTag.DIVINE_SHIELD]);\r\n\t\t\t\ttarget.poisonous = target.poisonous || modularCard.mechanics?.includes(GameTag[GameTag.POISONOUS]);\r\n\t\t\t\ttarget.venomous = target.venomous || modularCard.mechanics?.includes(GameTag[GameTag.VENOMOUS]);\r\n\t\t\t\ttarget.windfury = target.windfury || modularCard.mechanics?.includes(GameTag[GameTag.WINDFURY]);\r\n\t\t\t\ttarget.reborn = target.reborn || modularCard.mechanics?.includes(GameTag[GameTag.REBORN]);\r\n\t\t\t\ttarget.stealth = target.stealth || modularCard.mechanics?.includes(GameTag[GameTag.STEALTH]);\r\n\r\n\t\t\t\tconst magneticEnchantment = modularCard.enchantmentDbfId;\r\n\t\t\t\tif (magneticEnchantment) {\r\n\t\t\t\t\tconst enchantment = gameState.allCards.getCard(magneticEnchantment).id;\r\n\t\t\t\t\ttarget.enchantments.push({\r\n\t\t\t\t\t\tcardId: enchantment,\r\n\t\t\t\t\t\toriginEntityId: modularCard.dbfId,\r\n\t\t\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\tif (\r\n\t\t\t\t\t[CardIds.DrBoomsMonster_BG31_176, CardIds.DrBoomsMonster_BG31_176_G].includes(\r\n\t\t\t\t\t\tcardToMagnetize as CardIds,\r\n\t\t\t\t\t)\r\n\t\t\t\t) {\r\n\t\t\t\t\tconst mult = cardToMagnetize === CardIds.DrBoomsMonster_BG31_176 ? 1 : 2;\r\n\t\t\t\t\ttarget.attack += 2 * hero.globalInfo.MagnetizedThisGame * mult;\r\n\t\t\t\t\ttarget.health += 2 * hero.globalInfo.MagnetizedThisGame * mult;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Dr Boom's Monster?\r\n\t\t\t\thero.globalInfo.MagnetizedThisGame = hero.globalInfo.MagnetizedThisGame + 1;\r\n\t\t\t\tfor (const entity of board) {\r\n\t\t\t\t\tconst drBoomBases =\r\n\t\t\t\t\t\t(entity.cardId === CardIds.DrBoomsMonster_BG31_176 ? 1 : 0) +\r\n\t\t\t\t\t\tentity.enchantments.filter(\r\n\t\t\t\t\t\t\t(e) => e.cardId === CardIds.DrBoomsMonster_DrBoomsMonsterEnchantment_BG31_176e,\r\n\t\t\t\t\t\t).length;\r\n\t\t\t\t\tconst drBoomGoldens =\r\n\t\t\t\t\t\t(entity.cardId === CardIds.DrBoomsMonster_BG31_176_G ? 1 : 0) +\r\n\t\t\t\t\t\tentity.enchantments.filter(\r\n\t\t\t\t\t\t\t(e) => e.cardId === CardIds.DrBoomsMonster_DrBoomsMonsterEnchantment_BG31_176_Ge,\r\n\t\t\t\t\t\t).length;\r\n\t\t\t\t\tentity.attack += drBoomBases * 2 + drBoomGoldens * 4;\r\n\t\t\t\t\tentity.health += drBoomBases * 2 + drBoomGoldens * 4;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tconst onAfterMagnetizeSelfImpl = cardMappings[modularBoardEntity.cardId];\r\n\t\t\t\tif (hasOnAfterMagnetizeToSelf(onAfterMagnetizeSelfImpl)) {\r\n\t\t\t\t\tonAfterMagnetizeSelfImpl.onAfterMagnetizeToSelf(modularBoardEntity, {\r\n\t\t\t\t\t\tboard: board,\r\n\t\t\t\t\t\thero: hero,\r\n\t\t\t\t\t\tmagnetizeTarget: target,\r\n\t\t\t\t\t\tgameState: gameState,\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\r\n\t\t\t\tconst onAfterMagnetizeImpl = cardMappings[modularCard.id];\r\n\t\t\t\tif (hasOnAfterMagnetizeSelf(onAfterMagnetizeImpl)) {\r\n\t\t\t\t\tonAfterMagnetizeImpl.onAfterMagnetizeSelf(target, {\r\n\t\t\t\t\t\tboard: board,\r\n\t\t\t\t\t\thero: hero,\r\n\t\t\t\t\t\tsource: source,\r\n\t\t\t\t\t\totherHero: otherHero,\r\n\t\t\t\t\t\totherBoard: otherBoard,\r\n\t\t\t\t\t\tmagnetizedCard: modularCard,\r\n\t\t\t\t\t\tmagnetizeTarget: target,\r\n\t\t\t\t\t\tgameState: gameState,\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\r\n\t\t\t\tfor (const boardEntity of board) {\r\n\t\t\t\t\tconst onAfterMagnetizeImpl = cardMappings[boardEntity.cardId];\r\n\t\t\t\t\tif (hasOnAfterMagnetize(onAfterMagnetizeImpl)) {\r\n\t\t\t\t\t\tonAfterMagnetizeImpl.onAfterMagnetize(boardEntity, {\r\n\t\t\t\t\t\t\tboard: board,\r\n\t\t\t\t\t\t\thero: hero,\r\n\t\t\t\t\t\t\tsource: source,\r\n\t\t\t\t\t\t\totherHero: otherHero,\r\n\t\t\t\t\t\t\totherBoard: otherBoard,\r\n\t\t\t\t\t\t\tmagnetizedCard: modularCard,\r\n\t\t\t\t\t\t\tmagnetizeTarget: target,\r\n\t\t\t\t\t\t\tgameState: gameState,\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\tfor (const trinket of hero.trinkets ?? []) {\r\n\t\t\t\t\tconst onAfterMagnetizeImpl = cardMappings[trinket.cardId];\r\n\t\t\t\t\tif (hasOnAfterMagnetize(onAfterMagnetizeImpl)) {\r\n\t\t\t\t\t\tonAfterMagnetizeImpl.onAfterMagnetize(trinket, {\r\n\t\t\t\t\t\t\tboard: board,\r\n\t\t\t\t\t\t\thero: hero,\r\n\t\t\t\t\t\t\tsource: source,\r\n\t\t\t\t\t\t\totherHero: otherHero,\r\n\t\t\t\t\t\t\totherBoard: otherBoard,\r\n\t\t\t\t\t\t\tmagnetizedCard: modularCard,\r\n\t\t\t\t\t\t\tmagnetizeTarget: target,\r\n\t\t\t\t\t\t\tgameState: gameState,\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}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const getMagnetizations = (entity: BoardEntity, gameState: FullGameState) => {\r\n\treturn entity.enchantments.filter((e) =>\r\n\t\tgameState.allCards.getCard(e.cardId).mechanics?.includes(GameTag[GameTag.MODULAR]),\r\n\t).length;\r\n};\r\n\r\nexport interface OnBeforeMagnetizeInput {\r\n\tboard: BoardEntity[];\r\n\thero: BgsPlayerEntity;\r\n\tmagnetizedCard: Mutable<ReferenceCard>;\r\n\tmagnetizeTarget: BoardEntity;\r\n\tgameState: FullGameState;\r\n}\r\n\r\nexport interface OnBeforeMagnetizeSelfInput {\r\n\tboard: BoardEntity[];\r\n\thero: BgsPlayerEntity;\r\n\tmagnetizeTarget: BoardEntity;\r\n\tgameState: FullGameState;\r\n\tisFirstTimeMagnetize: boolean;\r\n}\r\n\r\nexport interface OnAfterMagnetizeSelfInput {\r\n\tboard: BoardEntity[];\r\n\thero: BgsPlayerEntity;\r\n\tmagnetizeTarget: BoardEntity;\r\n\tgameState: FullGameState;\r\n}\r\n\r\nexport interface OnAfterMagnetizeInput {\r\n\tsource: BoardEntity | BoardTrinket;\r\n\tboard: BoardEntity[];\r\n\thero: BgsPlayerEntity;\r\n\totherHero: BgsPlayerEntity;\r\n\totherBoard: BoardEntity[];\r\n\tmagnetizedCard: ReferenceCard;\r\n\tmagnetizeTarget: BoardEntity;\r\n\tgameState: FullGameState;\r\n}\r\n"]}
1
+ {"version":3,"file":"magnetize.js","sourceRoot":"","sources":["../../src/simulation/magnetize.ts"],"names":[],"mappings":";;;AAAA,iEAAsE;AAGtE,4DAMiC;AACjC,iEAA4D;AAE5D,oCAAkD;AAElD,mCAAsC;AAE/B,MAAM,iBAAiB,GAAG,CAChC,YAAmD,EACnD,MAAkC,EAClC,gBAA4C,EAC5C,KAAoB,EACpB,IAAqB,EACrB,UAAyB,EACzB,SAA0B,EAC1B,SAAwB,EACxB,oBAAoB,GAAG,IAAI,EAC1B,EAAE;;IACH,MAAM,sBAAsB,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAClD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,yBAAqD,CACpE,CAAC,MAAM,CAAC;IACT,MAAM,4BAA4B,GAAG,IAAI,CAAC,QAA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,SAAS,EAAE,SAAS;yBACpB,CAAC,CAAC;qBACH;iBACD;aACD;SACD;KACD;AACF,CAAC,CAAC;AAjMW,QAAA,iBAAiB,qBAiM5B;AAEK,MAAM,iBAAiB,GAAG,CAAC,MAAmB,EAAE,SAAwB,EAAE,EAAE;IAClF,OAAO,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,WACvC,OAAA,MAAA,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,0CAAE,QAAQ,CAAC,wBAAO,CAAC,wBAAO,CAAC,OAAO,CAAC,CAAC,CAAA,EAAA,CAClF,CAAC,MAAM,CAAC;AACV,CAAC,CAAC;AAJW,QAAA,iBAAiB,qBAI5B","sourcesContent":["import { GameTag, ReferenceCard } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity, BoardTrinket } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport {\r\n\thasOnAfterMagnetize,\r\n\thasOnAfterMagnetizeSelf,\r\n\thasOnAfterMagnetizeToSelf,\r\n\thasOnBeforeMagnetize,\r\n\thasOnBeforeMagnetizeSelf,\r\n} from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { buildSingleBoardEntity } from '../utils';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { modifyStats } from './stats';\r\n\r\nexport const magnetizeToTarget = (\r\n\tinputTargets: BoardEntity[] | (() => BoardEntity[]),\r\n\tsource: BoardEntity | BoardTrinket,\r\n\tcardsToMagnetize: string[] | ReferenceCard[],\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tisFirstTimeMagnetize = true,\r\n) => {\r\n\tconst electromagneticDevices = hero.trinkets.filter(\r\n\t\t(t) => t.cardId === CardIds.ElectromagneticDevice_BG30_MagicItem_709,\r\n\t).length;\r\n\tconst greaterElecromagneticDevices = hero.trinkets.filter(\r\n\t\t(t) => t.cardId === CardIds.ElectromagneticDevice_ElectromagneticDeviceToken_BG30_MagicItem_709t,\r\n\t).length;\r\n\r\n\tconst magnetMult = board.some((e) => e.cardId === CardIds.DoubleDemolisher_BG34_177_G)\r\n\t\t? 3\r\n\t\t: board.some((e) => e.cardId === CardIds.DoubleDemolisher_BG34_177)\r\n\t\t? 2\r\n\t\t: 1;\r\n\tfor (let i = 0; i < magnetMult; i++) {\r\n\t\tconst actualTargets = typeof inputTargets === 'function' ? inputTargets() : inputTargets;\r\n\t\tfor (const target of actualTargets) {\r\n\t\t\tfor (const cardToMagnetize of cardsToMagnetize) {\r\n\t\t\t\tconst modularCard =\r\n\t\t\t\t\ttypeof cardToMagnetize === 'string'\r\n\t\t\t\t\t\t? { ...gameState.allCards.getCard(cardToMagnetize) }\r\n\t\t\t\t\t\t: cardToMagnetize;\r\n\t\t\t\tconst modularBoardEntity = buildSingleBoardEntity(\r\n\t\t\t\t\tmodularCard.id,\r\n\t\t\t\t\thero,\r\n\t\t\t\t\tboard,\r\n\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\thero.friendly,\r\n\t\t\t\t\tgameState.sharedState.currentEntityId++,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treferenceCardToUse: modularCard,\r\n\t\t\t\t\t},\r\n\t\t\t\t);\r\n\t\t\t\tconst onBeforeMagnetizeSelfImpl = cardMappings[modularBoardEntity.cardId];\r\n\t\t\t\tif (hasOnBeforeMagnetizeSelf(onBeforeMagnetizeSelfImpl)) {\r\n\t\t\t\t\tonBeforeMagnetizeSelfImpl.onBeforeMagnetizeSelf(modularBoardEntity, {\r\n\t\t\t\t\t\tboard: board,\r\n\t\t\t\t\t\thero: hero,\r\n\t\t\t\t\t\tmagnetizeTarget: target,\r\n\t\t\t\t\t\tgameState: gameState,\r\n\t\t\t\t\t\tisFirstTimeMagnetize: isFirstTimeMagnetize,\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\r\n\t\t\t\tfor (const boardEntity of board) {\r\n\t\t\t\t\tconst onBeforeMagnetizeImpl = cardMappings[boardEntity.cardId];\r\n\t\t\t\t\tif (hasOnBeforeMagnetize(onBeforeMagnetizeImpl)) {\r\n\t\t\t\t\t\tonBeforeMagnetizeImpl.onBeforeMagnetize(boardEntity, {\r\n\t\t\t\t\t\t\tboard: board,\r\n\t\t\t\t\t\t\thero: hero,\r\n\t\t\t\t\t\t\tmagnetizedCard: modularBoardEntity,\r\n\t\t\t\t\t\t\tmagnetizeTarget: target,\r\n\t\t\t\t\t\t\tgameState: gameState,\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\tfor (const trinket of hero.trinkets) {\r\n\t\t\t\t\tconst onBeforeMagnetizeImpl = cardMappings[trinket.cardId];\r\n\t\t\t\t\tif (hasOnBeforeMagnetize(onBeforeMagnetizeImpl)) {\r\n\t\t\t\t\t\tonBeforeMagnetizeImpl.onBeforeMagnetize(trinket, {\r\n\t\t\t\t\t\t\tboard: board,\r\n\t\t\t\t\t\t\thero: hero,\r\n\t\t\t\t\t\t\tmagnetizedCard: modularBoardEntity,\r\n\t\t\t\t\t\t\tmagnetizeTarget: target,\r\n\t\t\t\t\t\t\tgameState: gameState,\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tmodifyStats(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tsource,\r\n\t\t\t\t\tmodularBoardEntity.attack + 2 * electromagneticDevices + 4 * greaterElecromagneticDevices,\r\n\t\t\t\t\tmodularBoardEntity.health + 2 * electromagneticDevices + 4 * greaterElecromagneticDevices,\r\n\t\t\t\t\tboard,\r\n\t\t\t\t\thero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t\ttarget.taunt = target.taunt || modularBoardEntity.taunt;\r\n\t\t\t\ttarget.divineShield = target.divineShield || modularBoardEntity.divineShield;\r\n\t\t\t\ttarget.poisonous = target.poisonous || modularBoardEntity.poisonous;\r\n\t\t\t\ttarget.venomous = target.venomous || modularBoardEntity.venomous;\r\n\t\t\t\ttarget.windfury = target.windfury || modularBoardEntity.windfury;\r\n\t\t\t\ttarget.reborn = target.reborn || modularBoardEntity.reborn;\r\n\t\t\t\ttarget.stealth = target.stealth || modularBoardEntity.stealth;\r\n\r\n\t\t\t\tconst magneticEnchantment = modularCard.enchantmentDbfId;\r\n\t\t\t\tif (magneticEnchantment) {\r\n\t\t\t\t\tconst enchantment = gameState.allCards.getCard(magneticEnchantment).id;\r\n\t\t\t\t\ttarget.enchantments.push({\r\n\t\t\t\t\t\tcardId: enchantment,\r\n\t\t\t\t\t\toriginEntityId: modularCard.dbfId,\r\n\t\t\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\tif (\r\n\t\t\t\t\t[CardIds.DrBoomsMonster_BG31_176, CardIds.DrBoomsMonster_BG31_176_G].includes(\r\n\t\t\t\t\t\tcardToMagnetize as CardIds,\r\n\t\t\t\t\t)\r\n\t\t\t\t) {\r\n\t\t\t\t\tconst mult = cardToMagnetize === CardIds.DrBoomsMonster_BG31_176 ? 1 : 2;\r\n\t\t\t\t\ttarget.attack += 2 * hero.globalInfo.MagnetizedThisGame * mult;\r\n\t\t\t\t\ttarget.health += 2 * hero.globalInfo.MagnetizedThisGame * mult;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Dr Boom's Monster?\r\n\t\t\t\thero.globalInfo.MagnetizedThisGame = hero.globalInfo.MagnetizedThisGame + 1;\r\n\t\t\t\tfor (const entity of board) {\r\n\t\t\t\t\tconst drBoomBases =\r\n\t\t\t\t\t\t(entity.cardId === CardIds.DrBoomsMonster_BG31_176 ? 1 : 0) +\r\n\t\t\t\t\t\tentity.enchantments.filter(\r\n\t\t\t\t\t\t\t(e) => e.cardId === CardIds.DrBoomsMonster_DrBoomsMonsterEnchantment_BG31_176e,\r\n\t\t\t\t\t\t).length;\r\n\t\t\t\t\tconst drBoomGoldens =\r\n\t\t\t\t\t\t(entity.cardId === CardIds.DrBoomsMonster_BG31_176_G ? 1 : 0) +\r\n\t\t\t\t\t\tentity.enchantments.filter(\r\n\t\t\t\t\t\t\t(e) => e.cardId === CardIds.DrBoomsMonster_DrBoomsMonsterEnchantment_BG31_176_Ge,\r\n\t\t\t\t\t\t).length;\r\n\t\t\t\t\tentity.attack += drBoomBases * 2 + drBoomGoldens * 4;\r\n\t\t\t\t\tentity.health += drBoomBases * 2 + drBoomGoldens * 4;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tconst onAfterMagnetizeSelfImpl = cardMappings[modularBoardEntity.cardId];\r\n\t\t\t\tif (hasOnAfterMagnetizeToSelf(onAfterMagnetizeSelfImpl)) {\r\n\t\t\t\t\tonAfterMagnetizeSelfImpl.onAfterMagnetizeToSelf(modularBoardEntity, {\r\n\t\t\t\t\t\tboard: board,\r\n\t\t\t\t\t\thero: hero,\r\n\t\t\t\t\t\tmagnetizeTarget: target,\r\n\t\t\t\t\t\tgameState: gameState,\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\r\n\t\t\t\tconst onAfterMagnetizeImpl = cardMappings[modularBoardEntity.cardId];\r\n\t\t\t\tif (hasOnAfterMagnetizeSelf(onAfterMagnetizeImpl)) {\r\n\t\t\t\t\tonAfterMagnetizeImpl.onAfterMagnetizeSelf(target, {\r\n\t\t\t\t\t\tboard: board,\r\n\t\t\t\t\t\thero: hero,\r\n\t\t\t\t\t\tsource: source,\r\n\t\t\t\t\t\totherHero: otherHero,\r\n\t\t\t\t\t\totherBoard: otherBoard,\r\n\t\t\t\t\t\tmagnetizedCard: modularBoardEntity,\r\n\t\t\t\t\t\tmagnetizeTarget: target,\r\n\t\t\t\t\t\tgameState: gameState,\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\r\n\t\t\t\tfor (const boardEntity of board) {\r\n\t\t\t\t\tconst onAfterMagnetizeImpl = cardMappings[boardEntity.cardId];\r\n\t\t\t\t\tif (hasOnAfterMagnetize(onAfterMagnetizeImpl)) {\r\n\t\t\t\t\t\tonAfterMagnetizeImpl.onAfterMagnetize(boardEntity, {\r\n\t\t\t\t\t\t\tboard: board,\r\n\t\t\t\t\t\t\thero: hero,\r\n\t\t\t\t\t\t\tsource: source,\r\n\t\t\t\t\t\t\totherHero: otherHero,\r\n\t\t\t\t\t\t\totherBoard: otherBoard,\r\n\t\t\t\t\t\t\tmagnetizedCard: modularBoardEntity,\r\n\t\t\t\t\t\t\tmagnetizeTarget: target,\r\n\t\t\t\t\t\t\tgameState: gameState,\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\tfor (const trinket of hero.trinkets ?? []) {\r\n\t\t\t\t\tconst onAfterMagnetizeImpl = cardMappings[trinket.cardId];\r\n\t\t\t\t\tif (hasOnAfterMagnetize(onAfterMagnetizeImpl)) {\r\n\t\t\t\t\t\tonAfterMagnetizeImpl.onAfterMagnetize(trinket, {\r\n\t\t\t\t\t\t\tboard: board,\r\n\t\t\t\t\t\t\thero: hero,\r\n\t\t\t\t\t\t\tsource: source,\r\n\t\t\t\t\t\t\totherHero: otherHero,\r\n\t\t\t\t\t\t\totherBoard: otherBoard,\r\n\t\t\t\t\t\t\tmagnetizedCard: modularBoardEntity,\r\n\t\t\t\t\t\t\tmagnetizeTarget: target,\r\n\t\t\t\t\t\t\tgameState: gameState,\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}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const getMagnetizations = (entity: BoardEntity, gameState: FullGameState) => {\r\n\treturn entity.enchantments.filter((e) =>\r\n\t\tgameState.allCards.getCard(e.cardId).mechanics?.includes(GameTag[GameTag.MODULAR]),\r\n\t).length;\r\n};\r\n\r\nexport interface OnBeforeMagnetizeInput {\r\n\tboard: BoardEntity[];\r\n\thero: BgsPlayerEntity;\r\n\tmagnetizedCard: BoardEntity;\r\n\tmagnetizeTarget: BoardEntity;\r\n\tgameState: FullGameState;\r\n}\r\n\r\nexport interface OnBeforeMagnetizeSelfInput {\r\n\tboard: BoardEntity[];\r\n\thero: BgsPlayerEntity;\r\n\tmagnetizeTarget: BoardEntity;\r\n\tgameState: FullGameState;\r\n\tisFirstTimeMagnetize: boolean;\r\n}\r\n\r\nexport interface OnAfterMagnetizeSelfInput {\r\n\tboard: BoardEntity[];\r\n\thero: BgsPlayerEntity;\r\n\tmagnetizeTarget: BoardEntity;\r\n\tgameState: FullGameState;\r\n}\r\n\r\nexport interface OnAfterMagnetizeInput {\r\n\tsource: BoardEntity | BoardTrinket;\r\n\tboard: BoardEntity[];\r\n\thero: BgsPlayerEntity;\r\n\totherHero: BgsPlayerEntity;\r\n\totherBoard: BoardEntity[];\r\n\tmagnetizedCard: BoardEntity;\r\n\tmagnetizeTarget: BoardEntity;\r\n\tgameState: FullGameState;\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"remove-minion-from-board.js","sourceRoot":"","sources":["../../src/simulation/remove-minion-from-board.ts"],"names":[],"mappings":";;;AAAA,iEAAoD;AAGpD,4DAAyD;AACzD,iEAA4D;AAE5D,oCAA2C;AAGpC,MAAM,qBAAqB,GAAG,CACpC,KAAoB,EACpB,SAA0B,EAC1B,KAAa,EACb,SAAwB,EACjB,EAAE;IACT,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,IAAA,qCAA6B,EAAC,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AAC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,MAAM,GAAG,IAAI,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;YACJ,MAAM;KACP;AACF,CAAC,CAAC;AArEW,QAAA,6BAA6B,iCAqExC","sourcesContent":["import { Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { hasOnDespawned } from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { hasCorrectTribe } from '../utils';\r\nimport { FullGameState } from './internal-game-state';\r\n\r\nexport const removeMinionFromBoard = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tindex: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst removedEntity = board.splice(index, 1)[0];\r\n\thandleMinionRemovedAuraEffect(board, removedEntity, boardHero, gameState);\r\n};\r\n\r\nexport const handleMinionRemovedAuraEffect = (\r\n\tboard: BoardEntity[],\r\n\tremoved: BoardEntity,\r\n\tboardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tapplyAttackAuras = true,\r\n\tapplyHealthAuras = true,\r\n): void => {\r\n\tconst onDespawnedImpl = cardMappings[removed.cardId];\r\n\tif (hasOnDespawned(onDespawnedImpl)) {\r\n\t\tonDespawnedImpl.onDespawned(removed, {\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\r\n\tswitch (removed.cardId) {\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.forEach((e) => {\r\n\t\t\t\t\tconst diff = removed.cardId === CardIds.MurlocWarleaderLegacy_TB_BaconUps_008 ? 4 : 2;\r\n\t\t\t\t\te.attack = Math.max(0, e.attack - diff);\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.SouthseaCaptainLegacy_BG_NEW1_027:\r\n\t\tcase CardIds.SouthseaCaptainLegacy_TB_BaconUps_136:\r\n\t\t\t// console.debug('removing southsea captain', stringifySimpleCard(removed, allCards), stringifySimple(board, allCards));\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.forEach((e) => {\r\n\t\t\t\t\tconst diff = removed.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1;\r\n\t\t\t\t\te.attack = Math.max(0, e.attack - diff);\r\n\t\t\t\t\te.health = Math.max(1, e.health - diff);\r\n\t\t\t\t});\r\n\t\t\t// console.debug('after removing southsea captain', stringifySimpleCard(removed, allCards), stringifySimple(board, allCards));\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.forEach((e) => {\r\n\t\t// \t\t\tconst diff = removed.cardId === CardIds.Kathranatir_BG21_039_G ? 4 : 2;\r\n\t\t// \t\t\te.attack = Math.max(0, e.attack - diff);\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\tconst diff = removed.cardId === CardIds.CyborgDrake_BG25_043_G ? 12 : 6;\r\n\t\t\t\t\te.attack = Math.max(0, e.attack - diff);\r\n\t\t\t\t});\r\n\t\t\tbreak;\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.forEach((e) => {\r\n\t\t\t\t\tconst diff = (removed.cardId === CardIds.SoreLoser_BG27_030_G ? 2 : 1) * boardHero.tavernTier;\r\n\t\t\t\t\te.attack = Math.max(0, e.attack - diff);\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t}\r\n};\r\n"]}
1
+ {"version":3,"file":"remove-minion-from-board.js","sourceRoot":"","sources":["../../src/simulation/remove-minion-from-board.ts"],"names":[],"mappings":";;;AAAA,iEAAoD;AAGpD,4DAAyD;AACzD,iEAA4D;AAE5D,oCAA2C;AAGpC,MAAM,qBAAqB,GAAG,CACpC,KAAoB,EACpB,SAA0B,EAC1B,KAAa,EACb,SAAwB,EACjB,EAAE;IACT,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAGhD,IAAA,qCAA6B,EAAC,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AAC3E,CAAC,CAAC;AAVW,QAAA,qBAAqB,yBAUhC;AAEK,MAAM,6BAA6B,GAAG,CAC5C,KAAoB,EACpB,OAAoB,EACpB,SAA0B,EAC1B,SAAwB,EACxB,gBAAgB,GAAG,IAAI,EACvB,gBAAgB,GAAG,IAAI,EAChB,EAAE;IACT,MAAM,eAAe,GAAG,6BAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACrD,IAAI,IAAA,+BAAc,EAAC,eAAe,CAAC,EAAE;QACpC,eAAe,CAAC,WAAW,CAAC,OAAO,EAAE;YACpC,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,KAAK;YACZ,SAAS;YACT,gBAAgB;YA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,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC;iBAC7B,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;gBACd,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,iBAAmC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;gBACxE,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;YACJ,MAAM;QACP,gBAAgC;QAChC;YACC,KAAK;iBACH,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,uBAAe,EAAC,CAAC,EAAE,SAAS,EAAE,qBAAI,CAAC,MAAM,EAAE,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;iBAClG,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;gBACd,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,iBAAiC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,UAAU,CAAC;gBAC9F,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;YACJ,MAAM;KACP;AACF,CAAC,CAAC;AArEW,QAAA,6BAA6B,iCAqExC","sourcesContent":["import { Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { hasOnDespawned } from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { hasCorrectTribe } from '../utils';\r\nimport { FullGameState } from './internal-game-state';\r\n\r\nexport const removeMinionFromBoard = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tindex: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst removedEntity = board.splice(index, 1)[0];\r\n\t// Don't remove the auras, so that the dead minion keeps them, which can be useful when we want to compute\r\n\t// deathrattle triggers that are based on the minion's stats\r\n\thandleMinionRemovedAuraEffect(board, removedEntity, boardHero, gameState);\r\n};\r\n\r\nexport const handleMinionRemovedAuraEffect = (\r\n\tboard: BoardEntity[],\r\n\tremoved: BoardEntity,\r\n\tboardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tapplyAttackAuras = true,\r\n\tapplyHealthAuras = true,\r\n): void => {\r\n\tconst onDespawnedImpl = cardMappings[removed.cardId];\r\n\tif (hasOnDespawned(onDespawnedImpl)) {\r\n\t\tonDespawnedImpl.onDespawned(removed, {\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\r\n\tswitch (removed.cardId) {\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.forEach((e) => {\r\n\t\t\t\t\tconst diff = removed.cardId === CardIds.MurlocWarleaderLegacy_TB_BaconUps_008 ? 4 : 2;\r\n\t\t\t\t\te.attack = Math.max(0, e.attack - diff);\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.SouthseaCaptainLegacy_BG_NEW1_027:\r\n\t\tcase CardIds.SouthseaCaptainLegacy_TB_BaconUps_136:\r\n\t\t\t// console.debug('removing southsea captain', stringifySimpleCard(removed, allCards), stringifySimple(board, allCards));\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.forEach((e) => {\r\n\t\t\t\t\tconst diff = removed.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1;\r\n\t\t\t\t\te.attack = Math.max(0, e.attack - diff);\r\n\t\t\t\t\te.health = Math.max(1, e.health - diff);\r\n\t\t\t\t});\r\n\t\t\t// console.debug('after removing southsea captain', stringifySimpleCard(removed, allCards), stringifySimple(board, allCards));\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.forEach((e) => {\r\n\t\t// \t\t\tconst diff = removed.cardId === CardIds.Kathranatir_BG21_039_G ? 4 : 2;\r\n\t\t// \t\t\te.attack = Math.max(0, e.attack - diff);\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\tconst diff = removed.cardId === CardIds.CyborgDrake_BG25_043_G ? 12 : 6;\r\n\t\t\t\t\te.attack = Math.max(0, e.attack - diff);\r\n\t\t\t\t});\r\n\t\t\tbreak;\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.forEach((e) => {\r\n\t\t\t\t\tconst diff = (removed.cardId === CardIds.SoreLoser_BG27_030_G ? 2 : 1) * boardHero.tavernTier;\r\n\t\t\t\t\te.attack = Math.max(0, e.attack - diff);\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t}\r\n};\r\n"]}
@@ -1,6 +1,6 @@
1
1
  import { BgsGameState } from '../../bgs-battle-info';
2
2
  import { BgsPlayerEntity, BoardTrinket } from '../../bgs-player-entity';
3
- import { BoardEntity } from '../../board-entity';
3
+ import { BoardEnchantment, BoardEntity } from '../../board-entity';
4
4
  import { BoardSecret } from '../../board-secret';
5
5
  import { GameSample } from './game-sample';
6
6
  export declare class Spectator {
@@ -27,7 +27,7 @@ export declare class Spectator {
27
27
  registerPlayerAttack(friendlyBoard: readonly BoardEntity[], opponentBoard: readonly BoardEntity[], damage: number): void;
28
28
  registerOpponentAttack(friendlyBoard: readonly BoardEntity[], opponentBoard: readonly BoardEntity[], damage: number): void;
29
29
  registerDamageDealt(damagingEntity: BoardEntity, damagedEntity: BoardEntity, damageTaken: number, damagedEntityBoard: BoardEntity[]): void;
30
- registerPowerTarget(sourceEntity: BoardEntity | BgsPlayerEntity | BoardSecret | BoardTrinket, targetEntity: BoardEntity | BgsPlayerEntity, targetBoard: BoardEntity[], hero1: BgsPlayerEntity, hero2: BgsPlayerEntity): void;
30
+ registerPowerTarget(sourceEntity: BoardEntity | BgsPlayerEntity | BoardSecret | BoardTrinket | BoardEnchantment, targetEntity: BoardEntity | BgsPlayerEntity, targetBoard: BoardEntity[], hero1: BgsPlayerEntity, hero2: BgsPlayerEntity): void;
31
31
  registerPowerTargets(sourceEntity: BoardEntity | BgsPlayerEntity | BoardSecret | BoardTrinket, targetEntities: (BoardEntity | BgsPlayerEntity)[], targetBoard: BoardEntity[], hero1: BgsPlayerEntity, hero2: BgsPlayerEntity): void;
32
32
  registerMinionsSpawn(sourceEntity: BoardEntity | BgsPlayerEntity | BoardTrinket, boardOnWhichToSpawn: BoardEntity[], spawnedEntities: readonly BoardEntity[]): void;
33
33
  registerDeadEntities(deadMinionIndexes1: number[], deadEntities1: BoardEntity[], board1: BoardEntity[], deadMinionIndexes2: number[], deadEntities2: BoardEntity[], board2: BoardEntity[]): void;
@@ -183,6 +183,7 @@ class Spectator {
183
183
  this.addAction(action);
184
184
  }
185
185
  registerPowerTarget(sourceEntity, targetEntity, targetBoard, hero1, hero2) {
186
+ var _a;
186
187
  if (!this.recording) {
187
188
  return;
188
189
  }
@@ -195,7 +196,7 @@ class Spectator {
195
196
  const opponentHero = (hero1 === null || hero1 === void 0 ? void 0 : hero1.friendly) ? hero2 : (hero2 === null || hero2 === void 0 ? void 0 : hero2.friendly) ? hero1 : null;
196
197
  const action = (0, game_action_1.buildGameAction)(friendlyHero, opponentHero, {
197
198
  type: 'power-target',
198
- sourceEntityId: sourceEntity.entityId,
199
+ sourceEntityId: (_a = sourceEntity === null || sourceEntity === void 0 ? void 0 : sourceEntity.originEntityId) !== null && _a !== void 0 ? _a : sourceEntity.entityId,
199
200
  targetEntityId: targetEntity.entityId,
200
201
  playerBoard: this.sanitize(friendlyBoard),
201
202
  opponentBoard: this.sanitize(opponentBoard),
@@ -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;AAEtB,MAAa,SAAS;IAWrB,YAA6B,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;QAFrC,cAAS,GAAG,KAAK,CAAC;QAGzB,IAAI,CAAC,uBAAuB,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACvB,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,CAAC,uBAAuB,GAAG,EAAE,CAAC;IACnC,CAAC;I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A,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;AAlgBD,8BAkgBC","sourcesContent":["import { BgsGameState } from '../../bgs-battle-info';\r\nimport { BgsPlayerEntity, BoardTrinket } from '../../bgs-player-entity';\r\nimport { 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\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\tthis.actionsForCurrentBattle = [];\r\n\t\tthis.wonBattles = [];\r\n\t\tthis.tiedBattles = [];\r\n\t\tthis.lostBattles = [];\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\tthis.actionsForCurrentBattle = [];\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.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,\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: sourceEntity.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"]}
1
+ {"version":3,"file":"spectator.js","sourceRoot":"","sources":["../../../src/simulation/spectator/spectator.ts"],"names":[],"mappings":";;;AAIA,+CAA4D;AAG5D,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,MAAa,SAAS;IAWrB,YAA6B,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;QAFrC,cAAS,GAAG,KAAK,CAAC;QAGzB,IAAI,CAAC,uBAAuB,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACvB,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,CAAC,uBAAuB,GAAG,EAAE,CAAC;IACnC,CAAC;IAEM,YAAY,CAAC,MAA+B;QAClD,QAAQ,MAAM,EAAE;YACf,KAAK,KAAK;gBACT,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,IAAI,WAAW,CAAC;YAC9C,KAAK,MAAM;gBACV,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,WAAW,CAAC;YAC/C,KAAK,MAAM;gBACV,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,WAAW,CAAC;SAC/C;IACF,CAAC;IA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AAngBD,8BAmgBC","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\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\tthis.actionsForCurrentBattle = [];\r\n\t\tthis.wonBattles = [];\r\n\t\tthis.tiedBattles = [];\r\n\t\tthis.lostBattles = [];\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\tthis.actionsForCurrentBattle = [];\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.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"]}
@@ -1,10 +1,10 @@
1
1
  import { BgsHeroPower, BgsPlayerEntity, BoardTrinket } from '../bgs-player-entity';
2
- import { BoardEntity } from '../board-entity';
2
+ import { BoardEnchantment, BoardEntity } from '../board-entity';
3
3
  import { BoardSecret } from '../board-secret';
4
4
  import { FullGameState } from './internal-game-state';
5
5
  export declare const setEntityStats: (entity: BoardEntity, attack: number | null, health: number | null, board: BoardEntity[], boardHero: BgsPlayerEntity, gameState: FullGameState, applyAttackAuras?: boolean, applyHealthAuras?: boolean) => void;
6
6
  export declare const multiplyStats: (entity: BoardEntity, multiplier: number | null, board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState) => void;
7
- export declare const modifyStats: (entity: BoardEntity, source: BoardEntity | BoardSecret | BoardTrinket | BgsPlayerEntity | BgsHeroPower, attackAmount: number, healthAmount: number, friendlyBoard: BoardEntity[], friendlyBoardHero: BgsPlayerEntity, gameState: FullGameState, registerSpectator?: boolean, isEnchantment?: boolean, countsAsStatsGain?: boolean) => void;
7
+ export declare const modifyStats: (entity: BoardEntity, source: BoardEntity | BoardSecret | BoardTrinket | BgsPlayerEntity | BgsHeroPower | BoardEnchantment, attackAmount: number, healthAmount: number, friendlyBoard: BoardEntity[], friendlyBoardHero: BgsPlayerEntity, gameState: FullGameState, registerSpectator?: boolean, isEnchantment?: boolean, countsAsStatsGain?: boolean) => void;
8
8
  export declare const applyAfterStatsUpdate: (gameState: FullGameState) => void;
9
9
  export interface OnStatsChangedInput {
10
10
  target: BoardEntity;
@@ -58,7 +58,7 @@ const modifyStats = (entity, source, attackAmount, healthAmount, friendlyBoard,
58
58
  }
59
59
  const sourceEntity = source;
60
60
  const globalInfo = friendlyBoardHero.globalInfo;
61
- if (entity.entityId !== (source === null || source === void 0 ? void 0 : source.entityId) &&
61
+ if (entity.entityId !== (sourceEntity === null || sourceEntity === void 0 ? void 0 : sourceEntity.entityId) &&
62
62
  (sourceEntity === null || sourceEntity === void 0 ? void 0 : sourceEntity.maxHealth) &&
63
63
  attackAmount >= 0 &&
64
64
  healthAmount >= 0 &&
@@ -119,10 +119,10 @@ const modifyStats = (entity, source, attackAmount, healthAmount, friendlyBoard,
119
119
  entity.pendingAttackBuffs.push(safeAtk);
120
120
  entity.health += safeHp;
121
121
  if (safeAtk > 0) {
122
- entity.maxAttack += safeAtk;
122
+ entity.maxAttack = entity.attack;
123
123
  }
124
124
  if (safeHp > 0) {
125
- entity.maxHealth += safeHp;
125
+ entity.maxHealth = entity.health;
126
126
  }
127
127
  if (safeAtk > 0 || safeHp > 0) {
128
128
  const checkStormbringer = safeAtk > 0 &&
@@ -133,8 +133,7 @@ const modifyStats = (entity, source, attackAmount, healthAmount, friendlyBoard,
133
133
  const otherCardId = other.cardId;
134
134
  if (safeAtk > 0) {
135
135
  if (checkStormbringer &&
136
- (otherCardId === "BG26_966" ||
137
- otherCardId === "BG26_966_G")) {
136
+ (otherCardId === "BG26_966" || otherCardId === "BG26_966_G")) {
138
137
  const multiplier = otherCardId === "BG26_966_G" ? 2 : 1;
139
138
  other.attack += multiplier * safeAtk;
140
139
  gameState.spectator.registerPowerTarget(other, other, friendlyBoard, friendlyBoardHero, otherBoardHero);
@@ -1 +1 @@
1
- {"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/simulation/stats.ts"],"names":[],"mappings":";;;AAAA,iEAAoD;AAIpD,4DAA4D;AAC5D,iEAA4D;AAE5D,oCAAuD;AACvD,+DAA8E;AAE9E,mCAAiD;AAE1C,MAAM,cAAc,GAAG,CAC7B,MAAmB,EACnB,MAAqB,EACrB,MAAqB,EACrB,KAAoB,EACpB,SAA0B,EAC1B,SAAwB,EACxB,gBAAgB,GAAG,IAAI,EACvB,gBAAgB,GAAG,IAAI,EAChB,EAAE;IACT,IAAA,yCAAmB,EAAC,MAAM,EAAE,KA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AC,MAAM,iBAAyC,CAAC,EACtD;YACD,MAAM,QAAQ,GAAG,CAAC,CAAC;YACnB,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,iBAAyC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3E,IAAA,mBAAW,EAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI,EAAE,QAAQ,GAAG,IAAI,EAAE,aAAa,EAAE,iBAAiB,EAAE,SAAS,CAAC,CAAC;SACzG;QACD,IACC,KAAK,CAAC,QAAQ,KAAK,MAAM,CAAC,QAAQ;YAClC,CAAC,KAAK,CAAC,MAAM,iCAAuD;gBACnE,KAAK,CAAC,MAAM,mCAAyD,CAAC,EACtE;YACD,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,mCAAyD,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3F,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC;YACrB,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC;SACrB;KACD;AACF,CAAC,CAAC","sourcesContent":["import { Race } from '@firestone-hs/reference-data';\r\nimport { BgsHeroPower, BgsPlayerEntity, BoardTrinket } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { BoardSecret } from '../board-secret';\r\nimport { hasOnStatsChanged } from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { getEffectiveTribesForEntity } from '../utils';\r\nimport { applyAurasToSelf, removeAurasFromSelf } from './add-minion-to-board';\r\nimport { FullGameState, PlayerState } from './internal-game-state';\r\nimport { onQuestProgressUpdated } from './quest';\r\n\r\nexport const setEntityStats = (\r\n\tentity: BoardEntity,\r\n\tattack: number | null,\r\n\thealth: number | null,\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\tremoveAurasFromSelf(entity, board, boardHero, gameState, applyAttackAuras, applyHealthAuras);\r\n\tif (attack !== null) {\r\n\t\tentity.attack = attack;\r\n\t\tentity.maxAttack = attack;\r\n\t}\r\n\tif (health !== null) {\r\n\t\tentity.health = health;\r\n\t\tentity.maxHealth = health;\r\n\t}\r\n\tapplyAurasToSelf(entity, board, boardHero, gameState, applyAttackAuras, applyHealthAuras);\r\n};\r\n\r\nexport const multiplyStats = (\r\n\tentity: BoardEntity,\r\n\tmultiplier: number | null,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tmodifyStats(\r\n\t\tentity,\r\n\t\tentity,\r\n\t\t(multiplier - 1) * entity.maxAttack,\r\n\t\t(multiplier - 1) * entity.maxHealth,\r\n\t\tboard,\r\n\t\thero,\r\n\t\tgameState,\r\n\t);\r\n\tapplyAurasToSelf(entity, board, hero, gameState);\r\n};\r\n\r\nexport const modifyStats = (\r\n\tentity: BoardEntity,\r\n\tsource: BoardEntity | BoardSecret | BoardTrinket | BgsPlayerEntity | BgsHeroPower,\r\n\tattackAmount: number,\r\n\thealthAmount: number,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tregisterSpectator = true,\r\n\t// All stat modifications become enchantments, excepted the ones coming from gilding a minion\r\n\tisEnchantment = true,\r\n\tcountsAsStatsGain = true,\r\n): void => {\r\n\t// Not a minion - can happen when buffing the whole hand, so we don't have to filter first\r\n\tif (!entity?.maxHealth) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (!Number.isFinite(attackAmount)) {\r\n\t\tattackAmount = 0;\r\n\t}\r\n\tif (!Number.isFinite(healthAmount)) {\r\n\t\thealthAmount = 0;\r\n\t}\r\n\tif (!Number.isFinite(entity.attack)) {\r\n\t\tentity.attack = 0;\r\n\t}\r\n\tif (!Number.isFinite(entity.health)) {\r\n\t\tentity.health = 1;\r\n\t}\r\n\tif (!Number.isFinite(entity.maxAttack as number)) {\r\n\t\tentity.maxAttack = entity.attack;\r\n\t}\r\n\tif (!Number.isFinite(entity.maxHealth as number)) {\r\n\t\tentity.maxHealth = entity.health;\r\n\t}\r\n\r\n\tif (attackAmount === 0 && healthAmount === 0) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (entity.cardId === CardIds.LocPrince_BG29_889 || entity.cardId === CardIds.LocPrince_BG29_889_G) {\r\n\t\tconst buff = entity.cardId === CardIds.LocPrince_BG29_889_G ? 2 : 1;\r\n\t\tattackAmount += 2 * buff;\r\n\t\thealthAmount += 1 * buff;\r\n\t}\r\n\r\n\tconst sourceEntity = source as BoardEntity;\r\n\tconst globalInfo = friendlyBoardHero.globalInfo;\r\n\tif (\r\n\t\tentity.entityId !== source?.entityId &&\r\n\t\tsourceEntity?.maxHealth &&\r\n\t\tattackAmount >= 0 &&\r\n\t\thealthAmount >= 0 &&\r\n\t\t// Resolving the source's tribes is only useful when one of these global buffs is\r\n\t\t// active, and this is one of the hottest paths of the simulation\r\n\t\t(globalInfo.ElementalAttackBuff ||\r\n\t\t\tglobalInfo.ElementalHealthBuff ||\r\n\t\t\tglobalInfo.PirateAttackBuff ||\r\n\t\t\tglobalInfo.PirateHealthBuff)\r\n\t) {\r\n\t\tconst sourceTribes = getEffectiveTribesForEntity(\r\n\t\t\tsourceEntity,\r\n\t\t\tfriendlyBoardHero,\r\n\t\t\tgameState.anomalies,\r\n\t\t\tgameState.allCards,\r\n\t\t);\r\n\t\tconst sourceIsAllTribes = sourceTribes.includes(Race.ALL);\r\n\t\tif (sourceIsAllTribes || sourceTribes.includes(Race.ELEMENTAL)) {\r\n\t\t\tattackAmount += globalInfo.ElementalAttackBuff || 0;\r\n\t\t\thealthAmount += globalInfo.ElementalHealthBuff || 0;\r\n\t\t}\r\n\t\tif (sourceIsAllTribes || sourceTribes.includes(Race.PIRATE)) {\r\n\t\t\tattackAmount += globalInfo.PirateAttackBuff || 0;\r\n\t\t\thealthAmount += globalInfo.PirateHealthBuff || 0;\r\n\t\t}\r\n\t}\r\n\t// The only spell for now that grants stats is the Fleeting Vigor secret, and the stats it grants\r\n\t// are in scriptDataNum1 and 2\r\n\t// if (\r\n\t// \tentity?.entityId !== source?.entityId &&\r\n\t// \tgameState.allCards.getCard(source?.cardId).type?.toUpperCase() === CardType[CardType.BATTLEGROUND_SPELL] &&\r\n\t// \t// Safeguard\r\n\t// \tattackAmount >= 0 &&\r\n\t// \thealthAmount >= 0\r\n\t// ) {\r\n\t// \tattackAmount += friendlyBoardHero.globalInfo.TavernSpellAttackBuff;\r\n\t// \thealthAmount += friendlyBoardHero.globalInfo.TavernSpellHealthBuff;\r\n\t// }\r\n\r\n\tconst otherBoardHero: BgsPlayerEntity =\r\n\t\tgameState.gameState.player.player === friendlyBoardHero\r\n\t\t\t? gameState.gameState.opponent.player\r\n\t\t\t: gameState.gameState.player.player;\r\n\r\n\tconst effectiveTribes = getEffectiveTribesForEntity(\r\n\t\tentity,\r\n\t\tfriendlyBoardHero,\r\n\t\tgameState.anomalies,\r\n\t\tgameState.allCards,\r\n\t);\r\n\tconst isAllTribes = effectiveTribes.includes(Race.ALL);\r\n\tconst isDragon = isAllTribes || effectiveTribes.includes(Race.DRAGON);\r\n\tconst isElemental = isAllTribes || effectiveTribes.includes(Race.ELEMENTAL);\r\n\tlet poetMultipliers = 1;\r\n\tif (isEnchantment && isDragon) {\r\n\t\tlet entityIndex = -1;\r\n\t\tlet timewarpedPoetCount = 0;\r\n\t\tfor (let i = 0; i < friendlyBoard.length; i++) {\r\n\t\t\tif (friendlyBoard[i].entityId === entity.entityId) {\r\n\t\t\t\tentityIndex = i;\r\n\t\t\t}\r\n\t\t\tif (friendlyBoard[i].cardId === CardIds.TimewarpedPoet_BG34_Giant_314_G) {\r\n\t\t\t\ttimewarpedPoetCount++;\r\n\t\t\t}\r\n\t\t}\r\n\t\tlet poetCount = 0;\r\n\t\tif (friendlyBoard[entityIndex - 1]?.cardId === CardIds.PersistentPoet_BG29_813_G) {\r\n\t\t\tpoetCount++;\r\n\t\t}\r\n\t\tif (friendlyBoard[entityIndex + 1]?.cardId === CardIds.PersistentPoet_BG29_813_G) {\r\n\t\t\tpoetCount++;\r\n\t\t}\r\n\t\tpoetMultipliers = poetCount * 2 + timewarpedPoetCount * 2 || 1;\r\n\t}\r\n\tconst tarecgosaMultiplier = isEnchantment && entity.cardId === CardIds.Tarecgosa_BG21_015_G ? 2 : 1;\r\n\r\n\tconst realAttackAmount = attackAmount * poetMultipliers * tarecgosaMultiplier;\r\n\tconst realHealthAmount = healthAmount * poetMultipliers * tarecgosaMultiplier;\r\n\tif (!Number.isFinite(realAttackAmount) && !Number.isFinite(realHealthAmount)) {\r\n\t\treturn;\r\n\t}\r\n\tconst safeAtk = Number.isFinite(realAttackAmount) ? realAttackAmount : 0;\r\n\tconst safeHp = Number.isFinite(realHealthAmount) ? realHealthAmount : 0;\r\n\r\n\tentity.attack = Math.max(0, entity.attack + safeAtk);\r\n\tentity.previousAttack = entity.attack;\r\n\tentity.pendingAttackBuffs = entity.pendingAttackBuffs || [];\r\n\tentity.pendingAttackBuffs.push(safeAtk);\r\n\tentity.health += safeHp;\r\n\r\n\tif (safeAtk > 0) {\r\n\t\tentity.maxAttack += safeAtk;\r\n\t}\r\n\tif (safeHp > 0) {\r\n\t\tentity.maxHealth += safeHp;\r\n\t}\r\n\tif (safeAtk > 0 || safeHp > 0) {\r\n\t\t// Single pass over the board for all the \"when a minion gains stats\" watchers\r\n\t\t// (Stormbringer, Titanic Guardian). Their effects are independent of\r\n\t\t// each other, so interleaving them per board position is equivalent to the\r\n\t\t// previous one-loop-per-effect version, and much cheaper on this hot path\r\n\t\tconst checkStormbringer =\r\n\t\t\tsafeAtk > 0 &&\r\n\t\t\tisDragon &&\r\n\t\t\tentity.cardId !== CardIds.Stormbringer_BG26_966 &&\r\n\t\t\tentity.cardId !== CardIds.Stormbringer_BG26_966_G;\r\n\t\tfor (const other of friendlyBoard) {\r\n\t\t\tconst otherCardId = other.cardId;\r\n\t\t\tif (safeAtk > 0) {\r\n\t\t\t\tif (\r\n\t\t\t\t\tcheckStormbringer &&\r\n\t\t\t\t\t(otherCardId === CardIds.Stormbringer_BG26_966 ||\r\n\t\t\t\t\t\totherCardId === CardIds.Stormbringer_BG26_966_G)\r\n\t\t\t\t) {\r\n\t\t\t\t\tconst multiplier = otherCardId === CardIds.Stormbringer_BG26_966_G ? 2 : 1;\r\n\t\t\t\t\tother.attack += multiplier * safeAtk;\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\tother,\r\n\t\t\t\t\t\tother,\r\n\t\t\t\t\t\tfriendlyBoard,\r\n\t\t\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (\r\n\t\t\t\tsafeHp > 0 &&\r\n\t\t\t\tother.entityId !== entity.entityId &&\r\n\t\t\t\t(otherCardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy ||\r\n\t\t\t\t\totherCardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy_G)\r\n\t\t\t) {\r\n\t\t\t\tconst buff =\r\n\t\t\t\t\t(otherCardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy_G ? 2 : 1) * safeHp;\r\n\t\t\t\tother.health += buff;\r\n\t\t\t\tother.maxHealth += buff;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (registerSpectator && !!source) {\r\n\t\tgameState.spectator.registerPowerTarget(source, entity, friendlyBoard, friendlyBoardHero, otherBoardHero);\r\n\t}\r\n\r\n\tif (countsAsStatsGain) {\r\n\t\tonStatsUpdate(\r\n\t\t\tentity,\r\n\t\t\tsource,\r\n\t\t\tsafeAtk,\r\n\t\t\tsafeHp,\r\n\t\t\tfriendlyBoard,\r\n\t\t\tfriendlyBoardHero,\r\n\t\t\totherBoardHero,\r\n\t\t\tgameState,\r\n\t\t\tisElemental,\r\n\t\t);\r\n\t}\r\n};\r\n\r\nconst onStatsUpdate = (\r\n\tentity: BoardEntity,\r\n\tsource: BoardEntity | BoardSecret | BoardTrinket | BgsPlayerEntity | BgsHeroPower,\r\n\trealAttackAmount: number,\r\n\trealHealthAmount: number,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyHero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tisElemental: boolean,\r\n): void => {\r\n\tonStatUpdateMinions(\r\n\t\tentity,\r\n\t\tsource,\r\n\t\trealAttackAmount,\r\n\t\trealHealthAmount,\r\n\t\tfriendlyBoard,\r\n\t\tfriendlyHero,\r\n\t\totherHero,\r\n\t\tgameState,\r\n\t\tisElemental,\r\n\t);\r\n\tonStatUpdateQuests(entity, friendlyBoard, friendlyHero, gameState);\r\n};\r\n\r\nexport const applyAfterStatsUpdate = (gameState: FullGameState) => {\r\n\tfor (const entity of gameState.gameState.player.board) {\r\n\t\tapplyAfterStatsUpdateForEntity(entity, gameState.gameState.player, gameState.gameState.opponent, gameState);\r\n\t}\r\n\tfor (const entity of gameState.gameState.opponent.board) {\r\n\t\tapplyAfterStatsUpdateForEntity(entity, gameState.gameState.opponent, gameState.gameState.player, gameState);\r\n\t}\r\n};\r\n\r\nconst applyAfterStatsUpdateForEntity = (\r\n\tentity: BoardEntity,\r\n\tplayerState: PlayerState,\r\n\topponentState: PlayerState,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tentity.pendingAttackBuffs = [];\r\n};\r\n\r\nconst onStatUpdateQuests = (\r\n\tentity: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): 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.FindTheMurderWeapon:\r\n\t\t\t\tonQuestProgressUpdated(hero, quest, board, gameState);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.PressureTheAuthorities:\r\n\t\t\t\tconst totalAttack = board.map((e) => e.attack).reduce((a, b) => a + b, 0);\r\n\t\t\t\tif (totalAttack >= 35) {\r\n\t\t\t\t\tonQuestProgressUpdated(hero, quest, board, gameState);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst onStatUpdateMinions = (\r\n\tentity: BoardEntity,\r\n\tsource: BoardEntity | BoardSecret | BoardTrinket | BgsPlayerEntity | BgsHeroPower,\r\n\tattackAmount: number,\r\n\thealthAmount: number,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyBoardHero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tisElemental: boolean,\r\n): void => {\r\n\tif (attackAmount > 0 || healthAmount > 0) {\r\n\t\tfor (const boardEntity of friendlyBoard) {\r\n\t\t\tconst onStatsChangedImpl = cardMappings[boardEntity.cardId];\r\n\t\t\tif (hasOnStatsChanged(onStatsChangedImpl)) {\r\n\t\t\t\tonStatsChangedImpl.onStatsChanged(boardEntity, {\r\n\t\t\t\t\ttarget: entity,\r\n\t\t\t\t\tsource: source,\r\n\t\t\t\t\tattackAmount: attackAmount,\r\n\t\t\t\t\thealthAmount: healthAmount,\r\n\t\t\t\t\tboard: friendlyBoard,\r\n\t\t\t\t\thero: friendlyBoardHero,\r\n\t\t\t\t\totherHero: otherHero,\r\n\t\t\t\t\tgameState: gameState,\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Single pass for Master of Realities and Tentacle of C'Thun (their effects are\r\n\t// independent, so interleaving them is equivalent to separate loops)\r\n\tfor (const other of friendlyBoard) {\r\n\t\tif (\r\n\t\t\tisElemental &&\r\n\t\t\t(other.cardId === CardIds.MasterOfRealities_BG21_036 ||\r\n\t\t\t\tother.cardId === CardIds.MasterOfRealities_BG21_036_G)\r\n\t\t) {\r\n\t\t\tconst baseBuff = 2;\r\n\t\t\tconst mult = other.cardId === CardIds.MasterOfRealities_BG21_036_G ? 2 : 1;\r\n\t\t\tmodifyStats(other, other, baseBuff * mult, baseBuff * mult, friendlyBoard, friendlyBoardHero, gameState);\r\n\t\t}\r\n\t\tif (\r\n\t\t\tother.entityId !== entity.entityId &&\r\n\t\t\t(other.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy ||\r\n\t\t\t\tother.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G)\r\n\t\t) {\r\n\t\t\tconst buff = other.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G ? 2 : 1;\r\n\t\t\tother.attack += buff;\r\n\t\t\tother.health += buff;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport interface OnStatsChangedInput {\r\n\ttarget: BoardEntity;\r\n\tsource: BoardEntity | BoardSecret | BoardTrinket | BgsPlayerEntity | BgsHeroPower;\r\n\tattackAmount: number;\r\n\thealthAmount: number;\r\n\tboard: BoardEntity[];\r\n\thero: BgsPlayerEntity;\r\n\totherHero: BgsPlayerEntity;\r\n\tgameState: FullGameState;\r\n}\r\n"]}
1
+ {"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/simulation/stats.ts"],"names":[],"mappings":";;;AAAA,iEAAoD;AAIpD,4DAA4D;AAC5D,iEAA4D;AAE5D,oCAAuD;AACvD,+DAA8E;AAE9E,mCAAiD;AAE1C,MAAM,cAAc,GAAG,CAC7B,MAAmB,EACnB,MAAqB,EACrB,MAAqB,EACrB,KAAoB,EACpB,SAA0B,EAC1B,SAAwB,EACxB,gBAAgB,GAAG,IAAI,EACvB,gBAAgB,GAAG,IAAI,EAChB,EAAE;IACT,IAAA,yCAAmB,EAAC,MAAM,EAAE,KAAK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M,eAAuC;gBACnD,KAAK,CAAC,MAAM,iBAAyC,CAAC,EACtD;YACD,MAAM,QAAQ,GAAG,CAAC,CAAC;YACnB,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,iBAAyC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3E,IAAA,mBAAW,EAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI,EAAE,QAAQ,GAAG,IAAI,EAAE,aAAa,EAAE,iBAAiB,EAAE,SAAS,CAAC,CAAC;SACzG;QACD,IACC,KAAK,CAAC,QAAQ,KAAK,MAAM,CAAC,QAAQ;YAClC,CAAC,KAAK,CAAC,MAAM,iCAAuD;gBACnE,KAAK,CAAC,MAAM,mCAAyD,CAAC,EACtE;YACD,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,mCAAyD,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3F,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC;YACrB,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC;SACrB;KACD;AACF,CAAC,CAAC","sourcesContent":["import { Race } from '@firestone-hs/reference-data';\r\nimport { BgsHeroPower, BgsPlayerEntity, BoardTrinket } from '../bgs-player-entity';\r\nimport { BoardEnchantment, BoardEntity } from '../board-entity';\r\nimport { BoardSecret } from '../board-secret';\r\nimport { hasOnStatsChanged } from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { getEffectiveTribesForEntity } from '../utils';\r\nimport { applyAurasToSelf, removeAurasFromSelf } from './add-minion-to-board';\r\nimport { FullGameState, PlayerState } from './internal-game-state';\r\nimport { onQuestProgressUpdated } from './quest';\r\n\r\nexport const setEntityStats = (\r\n\tentity: BoardEntity,\r\n\tattack: number | null,\r\n\thealth: number | null,\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\tremoveAurasFromSelf(entity, board, boardHero, gameState, applyAttackAuras, applyHealthAuras);\r\n\tif (attack !== null) {\r\n\t\tentity.attack = attack;\r\n\t\tentity.maxAttack = attack;\r\n\t}\r\n\tif (health !== null) {\r\n\t\tentity.health = health;\r\n\t\tentity.maxHealth = health;\r\n\t}\r\n\tapplyAurasToSelf(entity, board, boardHero, gameState, applyAttackAuras, applyHealthAuras);\r\n};\r\n\r\nexport const multiplyStats = (\r\n\tentity: BoardEntity,\r\n\tmultiplier: number | null,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tmodifyStats(\r\n\t\tentity,\r\n\t\tentity,\r\n\t\t(multiplier - 1) * entity.maxAttack,\r\n\t\t(multiplier - 1) * entity.maxHealth,\r\n\t\tboard,\r\n\t\thero,\r\n\t\tgameState,\r\n\t);\r\n\tapplyAurasToSelf(entity, board, hero, gameState);\r\n};\r\n\r\nexport const modifyStats = (\r\n\tentity: BoardEntity,\r\n\tsource: BoardEntity | BoardSecret | BoardTrinket | BgsPlayerEntity | BgsHeroPower | BoardEnchantment,\r\n\tattackAmount: number,\r\n\thealthAmount: number,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tregisterSpectator = true,\r\n\t// All stat modifications become enchantments, excepted the ones coming from gilding a minion\r\n\tisEnchantment = true,\r\n\tcountsAsStatsGain = true,\r\n): void => {\r\n\t// Not a minion - can happen when buffing the whole hand, so we don't have to filter first\r\n\tif (!entity?.maxHealth) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (!Number.isFinite(attackAmount)) {\r\n\t\tattackAmount = 0;\r\n\t}\r\n\tif (!Number.isFinite(healthAmount)) {\r\n\t\thealthAmount = 0;\r\n\t}\r\n\tif (!Number.isFinite(entity.attack)) {\r\n\t\tentity.attack = 0;\r\n\t}\r\n\tif (!Number.isFinite(entity.health)) {\r\n\t\tentity.health = 1;\r\n\t}\r\n\tif (!Number.isFinite(entity.maxAttack as number)) {\r\n\t\tentity.maxAttack = entity.attack;\r\n\t}\r\n\tif (!Number.isFinite(entity.maxHealth as number)) {\r\n\t\tentity.maxHealth = entity.health;\r\n\t}\r\n\r\n\tif (attackAmount === 0 && healthAmount === 0) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (entity.cardId === CardIds.LocPrince_BG29_889 || entity.cardId === CardIds.LocPrince_BG29_889_G) {\r\n\t\tconst buff = entity.cardId === CardIds.LocPrince_BG29_889_G ? 2 : 1;\r\n\t\tattackAmount += 2 * buff;\r\n\t\thealthAmount += 1 * buff;\r\n\t}\r\n\r\n\tconst sourceEntity = source as BoardEntity;\r\n\tconst globalInfo = friendlyBoardHero.globalInfo;\r\n\tif (\r\n\t\tentity.entityId !== sourceEntity?.entityId &&\r\n\t\tsourceEntity?.maxHealth &&\r\n\t\tattackAmount >= 0 &&\r\n\t\thealthAmount >= 0 &&\r\n\t\t// Resolving the source's tribes is only useful when one of these global buffs is\r\n\t\t// active, and this is one of the hottest paths of the simulation\r\n\t\t(globalInfo.ElementalAttackBuff ||\r\n\t\t\tglobalInfo.ElementalHealthBuff ||\r\n\t\t\tglobalInfo.PirateAttackBuff ||\r\n\t\t\tglobalInfo.PirateHealthBuff)\r\n\t) {\r\n\t\tconst sourceTribes = getEffectiveTribesForEntity(\r\n\t\t\tsourceEntity,\r\n\t\t\tfriendlyBoardHero,\r\n\t\t\tgameState.anomalies,\r\n\t\t\tgameState.allCards,\r\n\t\t);\r\n\t\tconst sourceIsAllTribes = sourceTribes.includes(Race.ALL);\r\n\t\tif (sourceIsAllTribes || sourceTribes.includes(Race.ELEMENTAL)) {\r\n\t\t\tattackAmount += globalInfo.ElementalAttackBuff || 0;\r\n\t\t\thealthAmount += globalInfo.ElementalHealthBuff || 0;\r\n\t\t}\r\n\t\tif (sourceIsAllTribes || sourceTribes.includes(Race.PIRATE)) {\r\n\t\t\tattackAmount += globalInfo.PirateAttackBuff || 0;\r\n\t\t\thealthAmount += globalInfo.PirateHealthBuff || 0;\r\n\t\t}\r\n\t}\r\n\t// The only spell for now that grants stats is the Fleeting Vigor secret, and the stats it grants\r\n\t// are in scriptDataNum1 and 2\r\n\t// if (\r\n\t// \tentity?.entityId !== source?.entityId &&\r\n\t// \tgameState.allCards.getCard(source?.cardId).type?.toUpperCase() === CardType[CardType.BATTLEGROUND_SPELL] &&\r\n\t// \t// Safeguard\r\n\t// \tattackAmount >= 0 &&\r\n\t// \thealthAmount >= 0\r\n\t// ) {\r\n\t// \tattackAmount += friendlyBoardHero.globalInfo.TavernSpellAttackBuff;\r\n\t// \thealthAmount += friendlyBoardHero.globalInfo.TavernSpellHealthBuff;\r\n\t// }\r\n\r\n\tconst otherBoardHero: BgsPlayerEntity =\r\n\t\tgameState.gameState.player.player === friendlyBoardHero\r\n\t\t\t? gameState.gameState.opponent.player\r\n\t\t\t: gameState.gameState.player.player;\r\n\r\n\tconst effectiveTribes = getEffectiveTribesForEntity(\r\n\t\tentity,\r\n\t\tfriendlyBoardHero,\r\n\t\tgameState.anomalies,\r\n\t\tgameState.allCards,\r\n\t);\r\n\tconst isAllTribes = effectiveTribes.includes(Race.ALL);\r\n\tconst isDragon = isAllTribes || effectiveTribes.includes(Race.DRAGON);\r\n\tconst isElemental = isAllTribes || effectiveTribes.includes(Race.ELEMENTAL);\r\n\tlet poetMultipliers = 1;\r\n\tif (isEnchantment && isDragon) {\r\n\t\tlet entityIndex = -1;\r\n\t\tlet timewarpedPoetCount = 0;\r\n\t\tfor (let i = 0; i < friendlyBoard.length; i++) {\r\n\t\t\tif (friendlyBoard[i].entityId === entity.entityId) {\r\n\t\t\t\tentityIndex = i;\r\n\t\t\t}\r\n\t\t\tif (friendlyBoard[i].cardId === CardIds.TimewarpedPoet_BG34_Giant_314_G) {\r\n\t\t\t\ttimewarpedPoetCount++;\r\n\t\t\t}\r\n\t\t}\r\n\t\tlet poetCount = 0;\r\n\t\tif (friendlyBoard[entityIndex - 1]?.cardId === CardIds.PersistentPoet_BG29_813_G) {\r\n\t\t\tpoetCount++;\r\n\t\t}\r\n\t\tif (friendlyBoard[entityIndex + 1]?.cardId === CardIds.PersistentPoet_BG29_813_G) {\r\n\t\t\tpoetCount++;\r\n\t\t}\r\n\t\tpoetMultipliers = poetCount * 2 + timewarpedPoetCount * 2 || 1;\r\n\t}\r\n\tconst tarecgosaMultiplier = isEnchantment && entity.cardId === CardIds.Tarecgosa_BG21_015_G ? 2 : 1;\r\n\r\n\tconst realAttackAmount = attackAmount * poetMultipliers * tarecgosaMultiplier;\r\n\tconst realHealthAmount = healthAmount * poetMultipliers * tarecgosaMultiplier;\r\n\tif (!Number.isFinite(realAttackAmount) && !Number.isFinite(realHealthAmount)) {\r\n\t\treturn;\r\n\t}\r\n\tconst safeAtk = Number.isFinite(realAttackAmount) ? realAttackAmount : 0;\r\n\tconst safeHp = Number.isFinite(realHealthAmount) ? realHealthAmount : 0;\r\n\r\n\tentity.attack = Math.max(0, entity.attack + safeAtk);\r\n\tentity.previousAttack = entity.attack;\r\n\tentity.pendingAttackBuffs = entity.pendingAttackBuffs || [];\r\n\tentity.pendingAttackBuffs.push(safeAtk);\r\n\tentity.health += safeHp;\r\n\r\n\tif (safeAtk > 0) {\r\n\t\tentity.maxAttack = entity.attack;\r\n\t}\r\n\tif (safeHp > 0) {\r\n\t\tentity.maxHealth = entity.health;\r\n\t}\r\n\tif (safeAtk > 0 || safeHp > 0) {\r\n\t\t// Single pass over the board for all the \"when a minion gains stats\" watchers\r\n\t\t// (Stormbringer, Titanic Guardian). Their effects are independent of\r\n\t\t// each other, so interleaving them per board position is equivalent to the\r\n\t\t// previous one-loop-per-effect version, and much cheaper on this hot path\r\n\t\tconst checkStormbringer =\r\n\t\t\tsafeAtk > 0 &&\r\n\t\t\tisDragon &&\r\n\t\t\tentity.cardId !== CardIds.Stormbringer_BG26_966 &&\r\n\t\t\tentity.cardId !== CardIds.Stormbringer_BG26_966_G;\r\n\t\tfor (const other of friendlyBoard) {\r\n\t\t\tconst otherCardId = other.cardId;\r\n\t\t\tif (safeAtk > 0) {\r\n\t\t\t\tif (\r\n\t\t\t\t\tcheckStormbringer &&\r\n\t\t\t\t\t(otherCardId === CardIds.Stormbringer_BG26_966 || otherCardId === CardIds.Stormbringer_BG26_966_G)\r\n\t\t\t\t) {\r\n\t\t\t\t\tconst multiplier = otherCardId === CardIds.Stormbringer_BG26_966_G ? 2 : 1;\r\n\t\t\t\t\tother.attack += multiplier * safeAtk;\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\tother,\r\n\t\t\t\t\t\tother,\r\n\t\t\t\t\t\tfriendlyBoard,\r\n\t\t\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (\r\n\t\t\t\tsafeHp > 0 &&\r\n\t\t\t\tother.entityId !== entity.entityId &&\r\n\t\t\t\t(otherCardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy ||\r\n\t\t\t\t\totherCardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy_G)\r\n\t\t\t) {\r\n\t\t\t\tconst buff = (otherCardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy_G ? 2 : 1) * safeHp;\r\n\t\t\t\tother.health += buff;\r\n\t\t\t\tother.maxHealth += buff;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (registerSpectator && !!source) {\r\n\t\tgameState.spectator.registerPowerTarget(source, entity, friendlyBoard, friendlyBoardHero, otherBoardHero);\r\n\t}\r\n\r\n\tif (countsAsStatsGain) {\r\n\t\tonStatsUpdate(\r\n\t\t\tentity,\r\n\t\t\tsource,\r\n\t\t\tsafeAtk,\r\n\t\t\tsafeHp,\r\n\t\t\tfriendlyBoard,\r\n\t\t\tfriendlyBoardHero,\r\n\t\t\totherBoardHero,\r\n\t\t\tgameState,\r\n\t\t\tisElemental,\r\n\t\t);\r\n\t}\r\n};\r\n\r\nconst onStatsUpdate = (\r\n\tentity: BoardEntity,\r\n\tsource: BoardEntity | BoardSecret | BoardTrinket | BgsPlayerEntity | BgsHeroPower | BoardEnchantment,\r\n\trealAttackAmount: number,\r\n\trealHealthAmount: number,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyHero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tisElemental: boolean,\r\n): void => {\r\n\tonStatUpdateMinions(\r\n\t\tentity,\r\n\t\tsource,\r\n\t\trealAttackAmount,\r\n\t\trealHealthAmount,\r\n\t\tfriendlyBoard,\r\n\t\tfriendlyHero,\r\n\t\totherHero,\r\n\t\tgameState,\r\n\t\tisElemental,\r\n\t);\r\n\tonStatUpdateQuests(entity, friendlyBoard, friendlyHero, gameState);\r\n};\r\n\r\nexport const applyAfterStatsUpdate = (gameState: FullGameState) => {\r\n\tfor (const entity of gameState.gameState.player.board) {\r\n\t\tapplyAfterStatsUpdateForEntity(entity, gameState.gameState.player, gameState.gameState.opponent, gameState);\r\n\t}\r\n\tfor (const entity of gameState.gameState.opponent.board) {\r\n\t\tapplyAfterStatsUpdateForEntity(entity, gameState.gameState.opponent, gameState.gameState.player, gameState);\r\n\t}\r\n};\r\n\r\nconst applyAfterStatsUpdateForEntity = (\r\n\tentity: BoardEntity,\r\n\tplayerState: PlayerState,\r\n\topponentState: PlayerState,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tentity.pendingAttackBuffs = [];\r\n};\r\n\r\nconst onStatUpdateQuests = (\r\n\tentity: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): 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.FindTheMurderWeapon:\r\n\t\t\t\tonQuestProgressUpdated(hero, quest, board, gameState);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.PressureTheAuthorities:\r\n\t\t\t\tconst totalAttack = board.map((e) => e.attack).reduce((a, b) => a + b, 0);\r\n\t\t\t\tif (totalAttack >= 35) {\r\n\t\t\t\t\tonQuestProgressUpdated(hero, quest, board, gameState);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst onStatUpdateMinions = (\r\n\tentity: BoardEntity,\r\n\tsource: BoardEntity | BoardSecret | BoardTrinket | BgsPlayerEntity | BgsHeroPower | BoardEnchantment,\r\n\tattackAmount: number,\r\n\thealthAmount: number,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyBoardHero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tisElemental: boolean,\r\n): void => {\r\n\tif (attackAmount > 0 || healthAmount > 0) {\r\n\t\tfor (const boardEntity of friendlyBoard) {\r\n\t\t\tconst onStatsChangedImpl = cardMappings[boardEntity.cardId];\r\n\t\t\tif (hasOnStatsChanged(onStatsChangedImpl)) {\r\n\t\t\t\tonStatsChangedImpl.onStatsChanged(boardEntity, {\r\n\t\t\t\t\ttarget: entity,\r\n\t\t\t\t\tsource: source as BoardEntity,\r\n\t\t\t\t\tattackAmount: attackAmount,\r\n\t\t\t\t\thealthAmount: healthAmount,\r\n\t\t\t\t\tboard: friendlyBoard,\r\n\t\t\t\t\thero: friendlyBoardHero,\r\n\t\t\t\t\totherHero: otherHero,\r\n\t\t\t\t\tgameState: gameState,\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Single pass for Master of Realities and Tentacle of C'Thun (their effects are\r\n\t// independent, so interleaving them is equivalent to separate loops)\r\n\tfor (const other of friendlyBoard) {\r\n\t\tif (\r\n\t\t\tisElemental &&\r\n\t\t\t(other.cardId === CardIds.MasterOfRealities_BG21_036 ||\r\n\t\t\t\tother.cardId === CardIds.MasterOfRealities_BG21_036_G)\r\n\t\t) {\r\n\t\t\tconst baseBuff = 2;\r\n\t\t\tconst mult = other.cardId === CardIds.MasterOfRealities_BG21_036_G ? 2 : 1;\r\n\t\t\tmodifyStats(other, other, baseBuff * mult, baseBuff * mult, friendlyBoard, friendlyBoardHero, gameState);\r\n\t\t}\r\n\t\tif (\r\n\t\t\tother.entityId !== entity.entityId &&\r\n\t\t\t(other.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy ||\r\n\t\t\t\tother.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G)\r\n\t\t) {\r\n\t\t\tconst buff = other.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G ? 2 : 1;\r\n\t\t\tother.attack += buff;\r\n\t\t\tother.health += buff;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport interface OnStatsChangedInput {\r\n\ttarget: BoardEntity;\r\n\tsource: BoardEntity | BoardSecret | BoardTrinket | BgsPlayerEntity | BgsHeroPower;\r\n\tattackAmount: number;\r\n\thealthAmount: number;\r\n\tboard: BoardEntity[];\r\n\thero: BgsPlayerEntity;\r\n\totherHero: BgsPlayerEntity;\r\n\tgameState: FullGameState;\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestone-hs/simulate-bgs-battle",
3
- "version": "1.1.733",
3
+ "version": "1.1.734",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "lint": "eslint --color --fix --ext .ts .",