@firestone-hs/simulate-bgs-battle 1.1.500 → 1.1.502

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 (278) hide show
  1. package/dist/bgs-player-entity.d.ts +6 -0
  2. package/dist/bgs-player-entity.js.map +1 -1
  3. package/dist/cards/card.interface.d.ts +110 -1
  4. package/dist/cards/card.interface.js +45 -0
  5. package/dist/cards/card.interface.js.map +1 -1
  6. package/dist/cards/cards-data.d.ts +5 -1
  7. package/dist/cards/cards-data.js +39 -6
  8. package/dist/cards/cards-data.js.map +1 -1
  9. package/dist/cards/impl/_card-mappings.d.ts +4 -0
  10. package/dist/cards/impl/_card-mappings.js +120 -0
  11. package/dist/cards/impl/_card-mappings.js.map +1 -0
  12. package/dist/cards/impl/anomaly/blessed-or-blighted.js +3 -2
  13. package/dist/cards/impl/anomaly/blessed-or-blighted.js.map +1 -1
  14. package/dist/cards/impl/bg-spell/boon-of-beetles.js +1 -1
  15. package/dist/cards/impl/bg-spell/boon-of-beetles.js.map +1 -1
  16. package/dist/cards/impl/enchantments/crystal-infuser-enchantment.d.ts +2 -0
  17. package/dist/cards/impl/enchantments/crystal-infuser-enchantment.js +16 -0
  18. package/dist/cards/impl/enchantments/crystal-infuser-enchantment.js.map +1 -0
  19. package/dist/cards/impl/hero-power/reborn-rites.js +2 -1
  20. package/dist/cards/impl/hero-power/reborn-rites.js.map +1 -1
  21. package/dist/cards/impl/hero-power/swatting-insects.js +5 -3
  22. package/dist/cards/impl/hero-power/swatting-insects.js.map +1 -1
  23. package/dist/cards/impl/hero-power/water-invocation.js +1 -1
  24. package/dist/cards/impl/hero-power/water-invocation.js.map +1 -1
  25. package/dist/cards/impl/minion/amber-guardian.js +1 -1
  26. package/dist/cards/impl/minion/amber-guardian.js.map +1 -1
  27. package/dist/cards/impl/minion/arcane-cannoneer.d.ts +2 -0
  28. package/dist/cards/impl/minion/arcane-cannoneer.js +15 -0
  29. package/dist/cards/impl/minion/arcane-cannoneer.js.map +1 -0
  30. package/dist/cards/impl/minion/bannerboar.d.ts +2 -0
  31. package/dist/cards/impl/minion/bannerboar.js +16 -0
  32. package/dist/cards/impl/minion/bannerboar.js.map +1 -0
  33. package/dist/cards/impl/minion/beetle.d.ts +2 -0
  34. package/dist/cards/impl/minion/beetle.js +16 -0
  35. package/dist/cards/impl/minion/beetle.js.map +1 -0
  36. package/dist/cards/impl/minion/bird-buddy.d.ts +2 -0
  37. package/dist/cards/impl/minion/bird-buddy.js +14 -0
  38. package/dist/cards/impl/minion/bird-buddy.js.map +1 -0
  39. package/dist/cards/impl/minion/boar-gamer.d.ts +2 -0
  40. package/dist/cards/impl/minion/boar-gamer.js +12 -0
  41. package/dist/cards/impl/minion/boar-gamer.js.map +1 -0
  42. package/dist/cards/impl/minion/bubble-gunner.d.ts +2 -0
  43. package/dist/cards/impl/minion/bubble-gunner.js +44 -0
  44. package/dist/cards/impl/minion/bubble-gunner.js.map +1 -0
  45. package/dist/cards/impl/minion/buzzing-vermin.d.ts +2 -0
  46. package/dist/cards/impl/minion/buzzing-vermin.js +12 -0
  47. package/dist/cards/impl/minion/buzzing-vermin.js.map +1 -0
  48. package/dist/cards/impl/minion/cadaver-caretaker.d.ts +2 -0
  49. package/dist/cards/impl/minion/cadaver-caretaker.js +12 -0
  50. package/dist/cards/impl/minion/cadaver-caretaker.js.map +1 -0
  51. package/dist/cards/impl/minion/deathly-striker.d.ts +2 -0
  52. package/dist/cards/impl/minion/deathly-striker.js +32 -0
  53. package/dist/cards/impl/minion/deathly-striker.js.map +1 -0
  54. package/dist/cards/impl/minion/efficient-engineer.d.ts +2 -0
  55. package/dist/cards/impl/minion/efficient-engineer.js +24 -0
  56. package/dist/cards/impl/minion/efficient-engineer.js.map +1 -0
  57. package/dist/cards/impl/minion/electric-synthesizer.d.ts +2 -0
  58. package/dist/cards/impl/minion/electric-synthesizer.js +24 -0
  59. package/dist/cards/impl/minion/electric-synthesizer.js.map +1 -0
  60. package/dist/cards/impl/minion/fairy-gillmother.d.ts +2 -0
  61. package/dist/cards/impl/minion/fairy-gillmother.js +18 -0
  62. package/dist/cards/impl/minion/fairy-gillmother.js.map +1 -0
  63. package/dist/cards/impl/minion/forest-rover.d.ts +2 -0
  64. package/dist/cards/impl/minion/forest-rover.js +23 -0
  65. package/dist/cards/impl/minion/forest-rover.js.map +1 -0
  66. package/dist/cards/impl/minion/fountain-chiller.d.ts +2 -0
  67. package/dist/cards/impl/minion/fountain-chiller.js +27 -0
  68. package/dist/cards/impl/minion/fountain-chiller.js.map +1 -0
  69. package/dist/cards/impl/minion/gem-rat.d.ts +2 -0
  70. package/dist/cards/impl/minion/gem-rat.js +12 -0
  71. package/dist/cards/impl/minion/gem-rat.js.map +1 -0
  72. package/dist/cards/impl/minion/gentle-djinni.d.ts +2 -0
  73. package/dist/cards/impl/minion/gentle-djinni.js +25 -0
  74. package/dist/cards/impl/minion/gentle-djinni.js.map +1 -0
  75. package/dist/cards/impl/minion/goldrinn-the-great-wolf.d.ts +2 -0
  76. package/dist/cards/impl/minion/goldrinn-the-great-wolf.js +15 -0
  77. package/dist/cards/impl/minion/goldrinn-the-great-wolf.js.map +1 -0
  78. package/dist/cards/impl/minion/gritty-headhunter.d.ts +2 -0
  79. package/dist/cards/impl/minion/gritty-headhunter.js +14 -0
  80. package/dist/cards/impl/minion/gritty-headhunter.js.map +1 -0
  81. package/dist/cards/impl/minion/hackerfin.d.ts +2 -0
  82. package/dist/cards/impl/minion/hackerfin.js +21 -0
  83. package/dist/cards/impl/minion/hackerfin.js.map +1 -0
  84. package/dist/cards/impl/minion/handless-forsaken.d.ts +2 -0
  85. package/dist/cards/impl/minion/handless-forsaken.js +12 -0
  86. package/dist/cards/impl/minion/handless-forsaken.js.map +1 -0
  87. package/dist/cards/impl/minion/harmless-bonehead.d.ts +2 -0
  88. package/dist/cards/impl/minion/harmless-bonehead.js +12 -0
  89. package/dist/cards/impl/minion/harmless-bonehead.js.map +1 -0
  90. package/dist/cards/impl/minion/holo-rover.d.ts +2 -0
  91. package/dist/cards/impl/minion/holo-rover.js +16 -0
  92. package/dist/cards/impl/minion/holo-rover.js.map +1 -0
  93. package/dist/cards/impl/minion/humming-bird.d.ts +2 -5
  94. package/dist/cards/impl/minion/humming-bird.js +1 -0
  95. package/dist/cards/impl/minion/humming-bird.js.map +1 -1
  96. package/dist/cards/impl/minion/hungry-snapjaw.d.ts +2 -0
  97. package/dist/cards/impl/minion/hungry-snapjaw.js +17 -0
  98. package/dist/cards/impl/minion/hungry-snapjaw.js.map +1 -0
  99. package/dist/cards/impl/minion/implant-subject.d.ts +2 -0
  100. package/dist/cards/impl/minion/implant-subject.js +42 -0
  101. package/dist/cards/impl/minion/implant-subject.js.map +1 -0
  102. package/dist/cards/impl/minion/indomitable-mount.d.ts +2 -0
  103. package/dist/cards/impl/minion/indomitable-mount.js +23 -0
  104. package/dist/cards/impl/minion/indomitable-mount.js.map +1 -0
  105. package/dist/cards/impl/minion/interrogator-whitemane.js +5 -4
  106. package/dist/cards/impl/minion/interrogator-whitemane.js.map +1 -1
  107. package/dist/cards/impl/minion/karmic-chameleon.d.ts +2 -0
  108. package/dist/cards/impl/minion/karmic-chameleon.js +27 -0
  109. package/dist/cards/impl/minion/karmic-chameleon.js.map +1 -0
  110. package/dist/cards/impl/minion/manasaber.d.ts +2 -0
  111. package/dist/cards/impl/minion/manasaber.js +14 -0
  112. package/dist/cards/impl/minion/manasaber.js.map +1 -0
  113. package/dist/cards/impl/minion/mantid-queen.js +6 -3
  114. package/dist/cards/impl/minion/mantid-queen.js.map +1 -1
  115. package/dist/cards/impl/minion/marquee-ticker.d.ts +2 -0
  116. package/dist/cards/impl/minion/marquee-ticker.js +12 -0
  117. package/dist/cards/impl/minion/marquee-ticker.js.map +1 -0
  118. package/dist/cards/impl/minion/mechanized-gift-horse.d.ts +2 -0
  119. package/dist/cards/impl/minion/mechanized-gift-horse.js +13 -0
  120. package/dist/cards/impl/minion/mechanized-gift-horse.js.map +1 -0
  121. package/dist/cards/impl/minion/mechorse.d.ts +2 -0
  122. package/dist/cards/impl/minion/mechorse.js +16 -0
  123. package/dist/cards/impl/minion/mechorse.js.map +1 -0
  124. package/dist/cards/impl/minion/moonsteel-juggernaut.d.ts +2 -0
  125. package/dist/cards/impl/minion/moonsteel-juggernaut.js +15 -0
  126. package/dist/cards/impl/minion/moonsteel-juggernaut.js.map +1 -0
  127. package/dist/cards/impl/minion/mutated-lasher.d.ts +2 -0
  128. package/dist/cards/impl/minion/mutated-lasher.js +26 -0
  129. package/dist/cards/impl/minion/mutated-lasher.js.map +1 -0
  130. package/dist/cards/impl/minion/neon-agent.d.ts +2 -0
  131. package/dist/cards/impl/minion/neon-agent.js +18 -0
  132. package/dist/cards/impl/minion/neon-agent.js.map +1 -0
  133. package/dist/cards/impl/minion/nest-swarmer.d.ts +2 -0
  134. package/dist/cards/impl/minion/nest-swarmer.js +12 -0
  135. package/dist/cards/impl/minion/nest-swarmer.js.map +1 -0
  136. package/dist/cards/impl/minion/nether-drake.d.ts +2 -0
  137. package/dist/cards/impl/minion/nether-drake.js +15 -0
  138. package/dist/cards/impl/minion/nether-drake.js.map +1 -0
  139. package/dist/cards/impl/minion/niuzao.d.ts +2 -0
  140. package/dist/cards/impl/minion/niuzao.js +21 -0
  141. package/dist/cards/impl/minion/niuzao.js.map +1 -0
  142. package/dist/cards/impl/minion/outback-smolderer.d.ts +2 -0
  143. package/dist/cards/impl/minion/outback-smolderer.js +17 -0
  144. package/dist/cards/impl/minion/outback-smolderer.js.map +1 -0
  145. package/dist/cards/impl/minion/razorgore-the-untamed.d.ts +2 -0
  146. package/dist/cards/impl/minion/razorgore-the-untamed.js +20 -0
  147. package/dist/cards/impl/minion/razorgore-the-untamed.js.map +1 -0
  148. package/dist/cards/impl/minion/reckless-cliffdiver.d.ts +2 -0
  149. package/dist/cards/impl/minion/reckless-cliffdiver.js +19 -0
  150. package/dist/cards/impl/minion/reckless-cliffdiver.js.map +1 -0
  151. package/dist/cards/impl/minion/runed-progenitor.d.ts +2 -0
  152. package/dist/cards/impl/minion/runed-progenitor.js +24 -0
  153. package/dist/cards/impl/minion/runed-progenitor.js.map +1 -0
  154. package/dist/cards/impl/minion/rylak-metalhead.d.ts +2 -0
  155. package/dist/cards/impl/minion/rylak-metalhead.js +22 -0
  156. package/dist/cards/impl/minion/rylak-metalhead.js.map +1 -0
  157. package/dist/cards/impl/minion/salty-hog.d.ts +2 -0
  158. package/dist/cards/impl/minion/salty-hog.js +17 -0
  159. package/dist/cards/impl/minion/salty-hog.js.map +1 -0
  160. package/dist/cards/impl/minion/showy-cyclist.d.ts +2 -0
  161. package/dist/cards/impl/minion/showy-cyclist.js +14 -0
  162. package/dist/cards/impl/minion/showy-cyclist.js.map +1 -0
  163. package/dist/cards/impl/minion/silver-handed-recruit.d.ts +2 -0
  164. package/dist/cards/impl/minion/silver-handed-recruit.js +17 -0
  165. package/dist/cards/impl/minion/silver-handed-recruit.js.map +1 -0
  166. package/dist/cards/impl/minion/sly-raptor.d.ts +2 -0
  167. package/dist/cards/impl/minion/sly-raptor.js +18 -0
  168. package/dist/cards/impl/minion/sly-raptor.js.map +1 -0
  169. package/dist/cards/impl/minion/soulsplitter.js +2 -1
  170. package/dist/cards/impl/minion/soulsplitter.js.map +1 -1
  171. package/dist/cards/impl/minion/spacefarer.d.ts +2 -0
  172. package/dist/cards/impl/minion/spacefarer.js +20 -0
  173. package/dist/cards/impl/minion/spacefarer.js.map +1 -0
  174. package/dist/cards/impl/minion/sun-screener.js +1 -1
  175. package/dist/cards/impl/minion/sun-screener.js.map +1 -1
  176. package/dist/cards/impl/minion/thousandth-paper-drake.js +2 -1
  177. package/dist/cards/impl/minion/thousandth-paper-drake.js.map +1 -1
  178. package/dist/cards/impl/minion/turquoise-skitterer.d.ts +2 -0
  179. package/dist/cards/impl/minion/turquoise-skitterer.js +25 -0
  180. package/dist/cards/impl/minion/turquoise-skitterer.js.map +1 -0
  181. package/dist/cards/impl/minion/twilight-primordium.d.ts +2 -0
  182. package/dist/cards/impl/minion/twilight-primordium.js +24 -0
  183. package/dist/cards/impl/minion/twilight-primordium.js.map +1 -0
  184. package/dist/cards/impl/minion/ultraviolet-ascendant.d.ts +2 -0
  185. package/dist/cards/impl/minion/ultraviolet-ascendant.js +14 -0
  186. package/dist/cards/impl/minion/ultraviolet-ascendant.js.map +1 -0
  187. package/dist/cards/impl/minion/wandering-wight.d.ts +2 -0
  188. package/dist/cards/impl/minion/wandering-wight.js +12 -0
  189. package/dist/cards/impl/minion/wandering-wight.js.map +1 -0
  190. package/dist/cards/impl/minion/wisp-in-the-shell.d.ts +2 -0
  191. package/dist/cards/impl/minion/wisp-in-the-shell.js +19 -0
  192. package/dist/cards/impl/minion/wisp-in-the-shell.js.map +1 -0
  193. package/dist/cards/impl/trinket/eternal-portrait.js +4 -2
  194. package/dist/cards/impl/trinket/eternal-portrait.js.map +1 -1
  195. package/dist/cards/impl/trinket/holly-mallet.js +1 -1
  196. package/dist/cards/impl/trinket/holly-mallet.js.map +1 -1
  197. package/dist/{divine-shield.d.ts → keywords/divine-shield.d.ts} +9 -3
  198. package/dist/{divine-shield.js → keywords/divine-shield.js} +18 -5
  199. package/dist/keywords/divine-shield.js.map +1 -0
  200. package/dist/keywords/reborn.d.ts +10 -0
  201. package/dist/keywords/reborn.js +22 -0
  202. package/dist/keywords/reborn.js.map +1 -0
  203. package/dist/keywords/stealth.d.ts +10 -0
  204. package/dist/keywords/stealth.js +22 -0
  205. package/dist/keywords/stealth.js.map +1 -0
  206. package/dist/keywords/taunt.d.ts +10 -0
  207. package/dist/keywords/taunt.js +22 -0
  208. package/dist/keywords/taunt.js.map +1 -0
  209. package/dist/keywords/venomous.d.ts +10 -0
  210. package/dist/keywords/venomous.js +33 -0
  211. package/dist/keywords/venomous.js.map +1 -0
  212. package/dist/keywords/windfury.d.ts +10 -0
  213. package/dist/keywords/windfury.js +22 -0
  214. package/dist/keywords/windfury.js.map +1 -0
  215. package/dist/simulate-bgs-battle.d.ts +2 -2
  216. package/dist/simulate-bgs-battle.js +19 -2
  217. package/dist/simulate-bgs-battle.js.map +1 -1
  218. package/dist/simulation/add-minion-to-board.d.ts +18 -2
  219. package/dist/simulation/add-minion-to-board.js +46 -15
  220. package/dist/simulation/add-minion-to-board.js.map +1 -1
  221. package/dist/simulation/after-attack.js +2 -1
  222. package/dist/simulation/after-attack.js.map +1 -1
  223. package/dist/simulation/attack.js +7 -24
  224. package/dist/simulation/attack.js.map +1 -1
  225. package/dist/simulation/auras.d.ts +1 -1
  226. package/dist/simulation/auras.js +21 -15
  227. package/dist/simulation/auras.js.map +1 -1
  228. package/dist/simulation/avenge.d.ts +7 -0
  229. package/dist/simulation/avenge.js +223 -229
  230. package/dist/simulation/avenge.js.map +1 -1
  231. package/dist/simulation/battlecries.d.ts +8 -0
  232. package/dist/simulation/battlecries.js +634 -609
  233. package/dist/simulation/battlecries.js.map +1 -1
  234. package/dist/simulation/blood-gems.js +1 -1
  235. package/dist/simulation/blood-gems.js.map +1 -1
  236. package/dist/simulation/cards-in-hand.d.ts +7 -1
  237. package/dist/simulation/cards-in-hand.js +14 -0
  238. package/dist/simulation/cards-in-hand.js.map +1 -1
  239. package/dist/simulation/damage-effects.js +1 -1
  240. package/dist/simulation/damage-effects.js.map +1 -1
  241. package/dist/simulation/deathrattle-effects.d.ts +1 -1
  242. package/dist/simulation/deathrattle-effects.js +498 -516
  243. package/dist/simulation/deathrattle-effects.js.map +1 -1
  244. package/dist/simulation/deathrattle-on-trigger.d.ts +1 -0
  245. package/dist/simulation/deathrattle-on-trigger.js.map +1 -1
  246. package/dist/simulation/deathrattle-spawns.d.ts +2 -0
  247. package/dist/simulation/deathrattle-spawns.js +324 -384
  248. package/dist/simulation/deathrattle-spawns.js.map +1 -1
  249. package/dist/simulation/deathrattle-utils.js +1 -1
  250. package/dist/simulation/deathrattle-utils.js.map +1 -1
  251. package/dist/simulation/frenzy.js +1 -1
  252. package/dist/simulation/frenzy.js.map +1 -1
  253. package/dist/simulation/magnetize.js.map +1 -1
  254. package/dist/simulation/on-attack.d.ts +13 -1
  255. package/dist/simulation/on-attack.js +21 -1
  256. package/dist/simulation/on-attack.js.map +1 -1
  257. package/dist/simulation/on-being-attacked.js +7 -4
  258. package/dist/simulation/on-being-attacked.js.map +1 -1
  259. package/dist/simulation/simulator.js +23 -8
  260. package/dist/simulation/simulator.js.map +1 -1
  261. package/dist/simulation/spawns.js +1 -1
  262. package/dist/simulation/spawns.js.map +1 -1
  263. package/dist/simulation/start-of-combat/soc-action-processor.js +6 -4
  264. package/dist/simulation/start-of-combat/soc-action-processor.js.map +1 -1
  265. package/dist/simulation/start-of-combat/soc-pre-combat-hero-power.js +12 -4
  266. package/dist/simulation/start-of-combat/soc-pre-combat-hero-power.js.map +1 -1
  267. package/dist/simulation/stats.d.ts +8 -0
  268. package/dist/simulation/stats.js +21 -4
  269. package/dist/simulation/stats.js.map +1 -1
  270. package/dist/simulation/summon-when-space.js +2 -12
  271. package/dist/simulation/summon-when-space.js.map +1 -1
  272. package/dist/temp-card-ids.d.ts +70 -0
  273. package/dist/temp-card-ids.js.map +1 -1
  274. package/dist/utils.d.ts +0 -1
  275. package/dist/utils.js +30 -36
  276. package/dist/utils.js.map +1 -1
  277. package/package.json +2 -2
  278. package/dist/divine-shield.js.map +0 -1
@@ -5,7 +5,10 @@ const summon_when_space_1 = require("../summon-when-space");
5
5
  const soc_action_processor_1 = require("./soc-action-processor");
6
6
  const soc_hero_power_1 = require("./soc-hero-power");
7
7
  const handlePreCombatHeroPowers = (playerEntity, playerBoard, opponentEntity, opponentBoard, currentAttacker, gameState) => {
8
- if (Math.random() < 0.5) {
8
+ let initialPlayerBoardSize = playerBoard.length;
9
+ let initialOpponentBoardSize = opponentBoard.length;
10
+ const random = Math.random();
11
+ if (random < 0.5) {
9
12
  currentAttacker = handlePreCombatHeroPowersForPlayer({
10
13
  playerEntity: playerEntity,
11
14
  playerBoard: playerBoard,
@@ -15,6 +18,8 @@ const handlePreCombatHeroPowers = (playerEntity, playerBoard, opponentEntity, op
15
18
  playerIsFriendly: true,
16
19
  gameState,
17
20
  });
21
+ initialPlayerBoardSize = playerBoard.length;
22
+ (0, summon_when_space_1.handleSummonsWhenSpace)(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);
18
23
  currentAttacker = handlePreCombatHeroPowersForPlayer({
19
24
  playerEntity: opponentEntity,
20
25
  playerBoard: opponentBoard,
@@ -24,6 +29,8 @@ const handlePreCombatHeroPowers = (playerEntity, playerBoard, opponentEntity, op
24
29
  playerIsFriendly: false,
25
30
  gameState,
26
31
  });
32
+ initialOpponentBoardSize = opponentBoard.length;
33
+ (0, summon_when_space_1.handleSummonsWhenSpace)(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);
27
34
  }
28
35
  else {
29
36
  currentAttacker = handlePreCombatHeroPowersForPlayer({
@@ -35,6 +42,8 @@ const handlePreCombatHeroPowers = (playerEntity, playerBoard, opponentEntity, op
35
42
  playerIsFriendly: false,
36
43
  gameState,
37
44
  });
45
+ initialOpponentBoardSize = opponentBoard.length;
46
+ (0, summon_when_space_1.handleSummonsWhenSpace)(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);
38
47
  currentAttacker = handlePreCombatHeroPowersForPlayer({
39
48
  playerEntity: playerEntity,
40
49
  playerBoard: playerBoard,
@@ -44,10 +53,9 @@ const handlePreCombatHeroPowers = (playerEntity, playerBoard, opponentEntity, op
44
53
  playerIsFriendly: true,
45
54
  gameState,
46
55
  });
56
+ initialPlayerBoardSize = playerBoard.length;
57
+ (0, summon_when_space_1.handleSummonsWhenSpace)(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);
47
58
  }
48
- const initialPlayerBoardSize = playerBoard.length;
49
- const initialOpponentBoardSize = opponentBoard.length;
50
- (0, summon_when_space_1.handleSummonsWhenSpace)(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);
51
59
  if (playerBoard.length !== initialPlayerBoardSize || opponentBoard.length !== initialOpponentBoardSize) {
52
60
  currentAttacker =
53
61
  playerBoard.length > opponentBoard.length
@@ -1 +1 @@
1
- {"version":3,"file":"soc-pre-combat-hero-power.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-pre-combat-hero-power.ts"],"names":[],"mappings":";;;AAGA,4DAA8D;AAC9D,iEAAoE;AACpE,qDAAuD;AAGhD,MAAM,yBAAyB,GAAG,CACxC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IACX,IAAI,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,EAAE;QACxB,eAAe,GAAG,kCAAkC,CAAC;YACpD,YAAY,EAAE,YAAY;YAC1B,WAAW,EAAE,WAAW;YACxB,cAAc,EAAE,cAAc;YAC9B,aAAa,EAAE,aAAa;YAC5B,eAAe;YACf,gBAAgB,EAAE,IAAI;YACtB,SAAS;SACT,CAAC,CAAC;QACH,eAAe,GAAG,kCAAkC,CAAC;YACpD,YAAY,EAAE,cAAc;YAC5B,WAAW,EAAE,aAAa;YAC1B,cAAc,EAAE,YAAY;YAC5B,aAAa,EAAE,WAAW;YAC1B,eAAe;YACf,gBAAgB,EAAE,KAAK;YACvB,SAAS;SACT,CAAC,CAAC;KACH;SAAM;QACN,eAAe,GAAG,kCAAkC,CAAC;YACpD,YAAY,EAAE,cAAc;YAC5B,WAAW,EAAE,aAAa;YAC1B,cAAc,EAAE,YAAY;YAC5B,aAAa,EAAE,WAAW;YAC1B,eAAe;YACf,gBAAgB,EAAE,KAAK;YACvB,SAAS;SACT,CAAC,CAAC;QACH,eAAe,GAAG,kCAAkC,CAAC;YACpD,YAAY,EAAE,YAAY;YAC1B,WAAW,EAAE,WAAW;YACxB,cAAc,EAAE,cAAc;YAC9B,aAAa,EAAE,aAAa;YAC5B,eAAe;YACf,gBAAgB,EAAE,IAAI;YACtB,SAAS;SACT,CAAC,CAAC;KACH;IACD,MAAM,sBAAsB,GAAG,WAAW,CAAC,MAAM,CAAC;IAClD,MAAM,wBAAwB,GAAG,aAAa,CAAC,MAAM,CAAC;IAGtD,IAAA,0CAAsB,EAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;IAE5F,IAAI,WAAW,CAAC,MAAM,KAAK,sBAAsB,IAAI,aAAa,CAAC,MAAM,KAAK,wBAAwB,EAAE;QACvG,eAAe;YACd,WAAW,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM;gBACxC,CAAC,CAAC,CAAC;gBACH,CAAC,CAAC,aAAa,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM;oBAC3C,CAAC,CAAC,CAAC;oBACH,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;KAC9B;IACD,OAAO,eAAe,CAAC;AACxB,CAAC,CAAC;AA9DW,QAAA,yBAAyB,6BA8DpC;AAEF,MAAM,kCAAkC,GAAG,CAAC,KAAe,EAAU,EAAE;IACtE,IAAI,KAAK,CAAC,YAAY,CAAC,iBAAiB,IAAI,KAAK,CAAC,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE;QAC3E,OAAO,KAAK,CAAC,eAAe,CAAC;KAC7B;IAED,MAAM,iBAAiB,GAAG,KAAK,CAAC,YAAY,CAAC,WAAW,IAAI,IAAA,oCAAmB,EAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC3G,IAAA,iDAA0B,EAAC,iBAAiB,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;IAE7F,OAAO,KAAK,CAAC,eAAe,CAAC;AAC9B,CAAC,CAAC","sourcesContent":["import { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { FullGameState } from '../internal-game-state';\r\nimport { handleSummonsWhenSpace } from '../summon-when-space';\r\nimport { performStartOfCombatAction } from './soc-action-processor';\r\nimport { getHeroPowerForHero } from './soc-hero-power';\r\nimport { SoCInput } from './start-of-combat-input';\r\n\r\nexport const handlePreCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t} else {\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t}\r\n\tconst initialPlayerBoardSize = playerBoard.length;\r\n\tconst initialOpponentBoardSize = opponentBoard.length;\r\n\t// Ozumat's Tentaclecan cause the first player to be recomputed\r\n\t// https://replays.firestoneapp.com/?reviewId=f15c90de-8b3c-4017-960d-365fe09eb7ab&turn=5&action=1\r\n\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\r\n\tif (playerBoard.length !== initialPlayerBoardSize || opponentBoard.length !== initialOpponentBoardSize) {\r\n\t\tcurrentAttacker =\r\n\t\t\tplayerBoard.length > opponentBoard.length\r\n\t\t\t\t? 0\r\n\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t? 1\r\n\t\t\t\t: Math.round(Math.random());\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePreCombatHeroPowersForPlayer = (input: SoCInput): number => {\r\n\tif (input.playerEntity.startOfCombatDone || input.playerEntity.hpLeft <= 0) {\r\n\t\treturn input.currentAttacker;\r\n\t}\r\n\r\n\tconst playerHeroPowerId = input.playerEntity.heroPowerId || getHeroPowerForHero(input.playerEntity.cardId);\r\n\tperformStartOfCombatAction(playerHeroPowerId, input.playerEntity, input, true, 'pre-combat');\r\n\r\n\treturn input.currentAttacker;\r\n};\r\n"]}
1
+ {"version":3,"file":"soc-pre-combat-hero-power.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-pre-combat-hero-power.ts"],"names":[],"mappings":";;;AAGA,4DAA8D;AAC9D,iEAAoE;AACpE,qDAAuD;AAGhD,MAAM,yBAAyB,GAAG,CACxC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IACX,IAAI,sBAAsB,GAAG,WAAW,CAAC,MAAM,CAAC;IAChD,IAAI,wBAAwB,GAAG,aAAa,CAAC,MAAM,CAAC;IACpD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC7B,IAAI,MAAM,GAAG,GAAG,EAAE;QACjB,eAAe,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,CAAC,MAAM,CAAC;QAC5C,IAAA,0CAAsB,EAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;KAC5F;IAGD,IAAI,WAAW,CAAC,MAAM,KAAK,sBAAsB,IAAI,aAAa,CAAC,MAAM,KAAK,wBAAwB,EAAE;QACvG,eAAe;YACd,WAAW,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM;gBACxC,CAAC,CAAC,CAAC;gBACH,CAAC,CAAC,aAAa,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM;oBAC3C,CAAC,CAAC,CAAC;oBACH,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;KAC9B;IACD,OAAO,eAAe,CAAC;AACxB,CAAC,CAAC;AArEW,QAAA,yBAAyB,6BAqEpC;AAEF,MAAM,kCAAkC,GAAG,CAAC,KAAe,EAAU,EAAE;IACtE,IAAI,KAAK,CAAC,YAAY,CAAC,iBAAiB,IAAI,KAAK,CAAC,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE;QAC3E,OAAO,KAAK,CAAC,eAAe,CAAC;KAC7B;IAED,MAAM,iBAAiB,GAAG,KAAK,CAAC,YAAY,CAAC,WAAW,IAAI,IAAA,oCAAmB,EAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC3G,IAAA,iDAA0B,EAAC,iBAAiB,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;IAE7F,OAAO,KAAK,CAAC,eAAe,CAAC;AAC9B,CAAC,CAAC","sourcesContent":["import { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { FullGameState } from '../internal-game-state';\r\nimport { handleSummonsWhenSpace } from '../summon-when-space';\r\nimport { performStartOfCombatAction } from './soc-action-processor';\r\nimport { getHeroPowerForHero } from './soc-hero-power';\r\nimport { SoCInput } from './start-of-combat-input';\r\n\r\nexport const handlePreCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tlet initialPlayerBoardSize = playerBoard.length;\r\n\tlet initialOpponentBoardSize = opponentBoard.length;\r\n\tconst random = Math.random();\r\n\tif (random < 0.5) {\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialPlayerBoardSize = playerBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialOpponentBoardSize = opponentBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t} else {\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialOpponentBoardSize = opponentBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialPlayerBoardSize = playerBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t}\r\n\t// Ozumat's Tentaclecan cause the first player to be recomputed\r\n\t// https://replays.firestoneapp.com/?reviewId=f15c90de-8b3c-4017-960d-365fe09eb7ab&turn=5&action=1\r\n\tif (playerBoard.length !== initialPlayerBoardSize || opponentBoard.length !== initialOpponentBoardSize) {\r\n\t\tcurrentAttacker =\r\n\t\t\tplayerBoard.length > opponentBoard.length\r\n\t\t\t\t? 0\r\n\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t? 1\r\n\t\t\t\t: Math.round(Math.random());\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePreCombatHeroPowersForPlayer = (input: SoCInput): number => {\r\n\tif (input.playerEntity.startOfCombatDone || input.playerEntity.hpLeft <= 0) {\r\n\t\treturn input.currentAttacker;\r\n\t}\r\n\r\n\tconst playerHeroPowerId = input.playerEntity.heroPowerId || getHeroPowerForHero(input.playerEntity.cardId);\r\n\tperformStartOfCombatAction(playerHeroPowerId, input.playerEntity, input, true, 'pre-combat');\r\n\r\n\treturn input.currentAttacker;\r\n};\r\n"]}
@@ -5,3 +5,11 @@ import { Spectator } from './spectator/spectator';
5
5
  export declare const setEntityStats: (entity: BoardEntity, attack: number | null, health: number | null, board: BoardEntity[], boardHero: BgsPlayerEntity, gameState: FullGameState) => void;
6
6
  export declare const modifyStats: (entity: BoardEntity, attackAmount: number, healthAmount: number, friendlyBoard: BoardEntity[], friendlyBoardHero: BgsPlayerEntity, gameState: FullGameState, spectator?: Spectator) => void;
7
7
  export declare const applyAfterStatsUpdate: (gameState: FullGameState) => void;
8
+ export interface OnStatsChangedInput {
9
+ target: BoardEntity;
10
+ attackAmount: number;
11
+ healthAmount: number;
12
+ board: BoardEntity[];
13
+ hero: BgsPlayerEntity;
14
+ gameState: FullGameState;
15
+ }
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.applyAfterStatsUpdate = exports.modifyStats = exports.setEntityStats = void 0;
4
4
  const reference_data_1 = require("@firestone-hs/reference-data");
5
+ const card_interface_1 = require("../cards/card.interface");
6
+ const _card_mappings_1 = require("../cards/impl/_card-mappings");
5
7
  const utils_1 = require("../utils");
6
8
  const add_minion_to_board_1 = require("./add-minion-to-board");
7
9
  const attack_1 = require("./attack");
@@ -104,11 +106,11 @@ const modifyStats = (entity, attackAmount, healthAmount, friendlyBoard, friendly
104
106
  (0, exports.modifyStats)(mishmash, (mishmash.cardId === "TB_BaconShop_HERO_33_Buddy_G" ? 2 : 1) * realAttackAmount, (mishmash.cardId === "TB_BaconShop_HERO_33_Buddy_G" ? 2 : 1) * realHealthAmount, friendlyBoard, friendlyBoardHero, gameState);
105
107
  });
106
108
  }
107
- onStatsUpdate(entity, friendlyBoard, friendlyBoardHero, gameState);
109
+ onStatsUpdate(entity, realAttackAmount, realHealthAmount, friendlyBoard, friendlyBoardHero, gameState);
108
110
  };
109
111
  exports.modifyStats = modifyStats;
110
- const onStatsUpdate = (entity, friendlyBoard, friendlyHero, gameState) => {
111
- onStatUpdateMinions(entity, friendlyBoard, friendlyHero, gameState);
112
+ const onStatsUpdate = (entity, realAttackAmount, realHealthAmount, friendlyBoard, friendlyHero, gameState) => {
113
+ onStatUpdateMinions(entity, realAttackAmount, realHealthAmount, friendlyBoard, friendlyHero, gameState);
112
114
  onStatUpdateQuests(entity, friendlyBoard, friendlyHero, gameState);
113
115
  };
114
116
  const applyAfterStatsUpdate = (gameState) => {
@@ -143,7 +145,22 @@ const onStatUpdateQuests = (entity, board, hero, gameState) => {
143
145
  }
144
146
  }
145
147
  };
146
- const onStatUpdateMinions = (entity, friendlyBoard, friendlyBoardHero, gameState) => {
148
+ const onStatUpdateMinions = (entity, attackAmount, healthAmount, friendlyBoard, friendlyBoardHero, gameState) => {
149
+ if (attackAmount > 0 || healthAmount > 0) {
150
+ for (const boardEntity of friendlyBoard) {
151
+ const onStatsChangedImpl = _card_mappings_1.cardMappings[boardEntity.cardId];
152
+ if ((0, card_interface_1.hasOnStatsChanged)(onStatsChangedImpl)) {
153
+ onStatsChangedImpl.onStatsChanged(boardEntity, {
154
+ target: entity,
155
+ attackAmount: attackAmount,
156
+ healthAmount: healthAmount,
157
+ board: friendlyBoard,
158
+ hero: friendlyBoardHero,
159
+ gameState: gameState,
160
+ });
161
+ }
162
+ }
163
+ }
147
164
  if ((0, utils_1.hasCorrectTribe)(entity, friendlyBoardHero, reference_data_1.Race.ELEMENTAL, gameState.allCards)) {
148
165
  const masterOfRealities = friendlyBoard.filter((e) => e.cardId === "BG21_036" || e.cardId === "BG21_036_G");
149
166
  masterOfRealities.forEach((master) => {
@@ -1 +1 @@
1
- {"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/simulation/stats.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAG7D,oCAA4D;AAC5D,+DAAyD;AACzD,qCAAyC;AAEzC,mCAAiD;AAG1C,MAAM,cAAc,GAAG,CAC7B,MAAmB,EACnB,MAAqB,EACrB,MAAqB,EACrB,KAAoB,EACpB,SAA0B,EAC1B,SAAwB,EACjB,EAAE;IACT,IAAI,MAAM,KAAK,IAAI,EAAE;QACpB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;QACvB,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC;KAC1B;IACD,IAAI,MAAM,KAAK,IAAI,EAAE;QACpB,MAAM,CAAC,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":["import { CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { addStatsToBoard, hasCorrectTribe } from '../utils';\r\nimport { applyAurasToSelf } from './add-minion-to-board';\r\nimport { getNeighbours } from './attack';\r\nimport { FullGameState, PlayerState } from './internal-game-state';\r\nimport { onQuestProgressUpdated } from './quest';\r\nimport { Spectator } from './spectator/spectator';\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): void => {\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);\r\n};\r\n\r\nexport const modifyStats = (\r\n\tentity: BoardEntity,\r\n\tattackAmount: number,\r\n\thealthAmount: number,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tspectator: Spectator = null,\r\n): void => {\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 += 3 * buff;\r\n\t\thealthAmount += 2 * buff;\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 neighbours = getNeighbours(friendlyBoard, entity);\r\n\tconst poetMultipliers = hasCorrectTribe(entity, friendlyBoardHero, Race.DRAGON, gameState.allCards)\r\n\t\t? neighbours.filter((e) => e.cardId === CardIds.PersistentPoet_BG29_813_G).length * 2 || 1\r\n\t\t: 1;\r\n\tconst tarecgosaMultiplier = 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\r\n\tentity.attack = Math.max(0, entity.attack + realAttackAmount);\r\n\tentity.previousAttack = entity.attack;\r\n\tentity.pendingAttackBuffs = entity.pendingAttackBuffs || [];\r\n\tentity.pendingAttackBuffs.push(realAttackAmount);\r\n\tentity.health += realHealthAmount;\r\n\r\n\tif (realAttackAmount > 0) {\r\n\t\tentity.maxAttack += realAttackAmount;\r\n\t\tif (hasCorrectTribe(entity, friendlyBoardHero, Race.DRAGON, gameState.allCards)) {\r\n\t\t\tconst whelpSmugglers = friendlyBoard.filter(\r\n\t\t\t\t(e) => e.cardId === CardIds.WhelpSmuggler_BG21_013 || e.cardId === CardIds.WhelpSmuggler_BG21_013_G,\r\n\t\t\t);\r\n\t\t\twhelpSmugglers.forEach((smuggler) => {\r\n\t\t\t\tconst buff = smuggler.cardId === CardIds.WhelpSmuggler_BG21_013_G ? 2 : 1;\r\n\t\t\t\tmodifyStats(entity, 0, buff, friendlyBoard, friendlyBoardHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tsmuggler,\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tfriendlyBoard,\r\n\t\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\r\n\t\t\tif (entity.cardId !== CardIds.Stormbringer_BG26_966 && entity.cardId !== CardIds.Stormbringer_BG26_966_G) {\r\n\t\t\t\tconst stormbringers = friendlyBoard.filter(\r\n\t\t\t\t\t(e) => e.cardId === CardIds.Stormbringer_BG26_966 || e.cardId === CardIds.Stormbringer_BG26_966_G,\r\n\t\t\t\t);\r\n\t\t\t\tstormbringers.forEach((stormbringer) => {\r\n\t\t\t\t\tconst multiplier = stormbringer.cardId === CardIds.Stormbringer_BG26_966_G ? 2 : 1;\r\n\t\t\t\t\t// This is never called?\r\n\t\t\t\t\t(e) => {\r\n\t\t\t\t\t\te.attack += multiplier * realAttackAmount;\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\tstormbringer,\r\n\t\t\t\t\t\t\tentity,\r\n\t\t\t\t\t\t\tfriendlyBoard,\r\n\t\t\t\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\t\t\t\totherBoardHero,\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\r\n\t\t// Sinestra\r\n\t\tfriendlyBoard\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId === CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy ||\r\n\t\t\t\t\te.cardId === CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy_G,\r\n\t\t\t)\r\n\t\t\t.forEach((sinestra) => {\r\n\t\t\t\tconst buff = sinestra.cardId === CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy_G ? 2 : 1;\r\n\t\t\t\tentity.health += buff;\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tsinestra,\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tfriendlyBoard,\r\n\t\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\r\n\t\t// TODO: what happens if the Hunter is killed during the attack?\r\n\t\tif (\r\n\t\t\t[CardIds.HunterOfGatherers_BG25_027, CardIds.HunterOfGatherers_BG25_027_G].includes(\r\n\t\t\t\tentity.cardId as CardIds,\r\n\t\t\t)\r\n\t\t) {\r\n\t\t\taddStatsToBoard(\r\n\t\t\t\tentity,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\t0,\r\n\t\t\t\tentity.cardId === CardIds.HunterOfGatherers_BG25_027_G ? 4 : 2,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t} else if (\r\n\t\t\tentity.cardId === CardIds.DefiantShipwright_BG21_018 ||\r\n\t\t\tentity.cardId === CardIds.DefiantShipwright_BG21_018_G\r\n\t\t) {\r\n\t\t\tconst stat = entity.cardId === CardIds.DefiantShipwright_BG21_018_G ? 2 : 1;\r\n\t\t\tentity.health += stat;\r\n\t\t}\r\n\t}\r\n\r\n\tif (realHealthAmount > 0) {\r\n\t\tentity.maxHealth += realHealthAmount;\r\n\t\tconst titanicGuardians = friendlyBoard\r\n\t\t\t.filter((e) => e.entityId !== entity.entityId)\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy ||\r\n\t\t\t\t\te.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy_G,\r\n\t\t\t);\r\n\t\ttitanicGuardians.forEach((guardian) => {\r\n\t\t\tconst buff =\r\n\t\t\t\t(guardian.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy_G ? 2 : 1) * realHealthAmount;\r\n\t\t\tif (buff > 0) {\r\n\t\t\t\tguardian.health += buff;\r\n\t\t\t\tguardian.maxHealth += buff;\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tif (\r\n\t\tentity.cardId === CardIds.Menagerist_AmalgamToken ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A_G ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D_G\r\n\t) {\r\n\t\tconst mishmashes = friendlyBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy ||\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G,\r\n\t\t);\r\n\t\tmishmashes.forEach((mishmash) => {\r\n\t\t\tmodifyStats(\r\n\t\t\t\tmishmash,\r\n\t\t\t\t(mishmash.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G ? 2 : 1) * realAttackAmount,\r\n\t\t\t\t(mishmash.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G ? 2 : 1) * realHealthAmount,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\r\n\tonStatsUpdate(entity, friendlyBoard, friendlyBoardHero, gameState);\r\n};\r\n\r\nconst onStatsUpdate = (\r\n\tentity: BoardEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tonStatUpdateMinions(entity, friendlyBoard, friendlyHero, gameState);\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\t// Attack buffs\r\n\t// Actually this was a bug, and the stats update happen at the same time\r\n\t// Keeping the structure here in case it's useful in the future\r\n\t// for (const attackBuff of entity.pendingAttackBuffs) {\r\n\t// \tif (isCorrectTribe(gameState.allCards.getCard(entity.cardId).races, Race.DRAGON)) {\r\n\t// \t\tconst whelpSmugglers = playerState.board.filter(\r\n\t// \t\t\t(e) => e.cardId === CardIds.WhelpSmuggler_BG21_013 || e.cardId === CardIds.WhelpSmuggler_BG21_013_G,\r\n\t// \t\t);\r\n\t// \t\twhelpSmugglers.forEach((smuggler) => {\r\n\t// \t\t\tconst buff = smuggler.cardId === CardIds.WhelpSmuggler_BG21_013_G ? 2 : 1;\r\n\t// \t\t\tmodifyHealth(entity, buff, playerState.board, playerState.player, gameState);\r\n\t// \t\t\tgameState.spectator.registerPowerTarget(\r\n\t// \t\t\t\tsmuggler,\r\n\t// \t\t\t\tentity,\r\n\t// \t\t\t\tplayerState.board,\r\n\t// \t\t\t\tplayerState.player,\r\n\t// \t\t\t\topponentState.player,\r\n\t// \t\t\t);\r\n\t// \t\t});\r\n\r\n\t// \t\tif (entity.cardId !== CardIds.Stormbringer_BG26_966 && entity.cardId !== CardIds.Stormbringer_BG26_966_G) {\r\n\t// \t\t\tconst stormbringers = playerState.board.filter(\r\n\t// \t\t\t\t(e) => e.cardId === CardIds.Stormbringer_BG26_966 || e.cardId === CardIds.Stormbringer_BG26_966_G,\r\n\t// \t\t\t);\r\n\t// \t\t\tstormbringers.forEach((stormbringer) => {\r\n\t// \t\t\t\tconst multiplier = stormbringer.cardId === CardIds.Stormbringer_BG26_966_G ? 2 : 1;\r\n\t// \t\t\t\t(e) => {\r\n\t// \t\t\t\t\tmodifyAttack(e, multiplier * attackBuff, playerState.board, playerState.player, gameState);\r\n\t// \t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t// \t\t\t\t\t\tstormbringer,\r\n\t// \t\t\t\t\t\tentity,\r\n\t// \t\t\t\t\t\tplayerState.board,\r\n\t// \t\t\t\t\t\tplayerState.player,\r\n\t// \t\t\t\t\t\topponentState.player,\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\r\n\t// \t// TODO: what happens if the Hunter is killed during the attack?\r\n\t// \tif (\r\n\t// \t\t[CardIds.HunterOfGatherers_BG25_027, CardIds.HunterOfGatherers_BG25_027_G].includes(\r\n\t// \t\t\tentity.cardId as CardIds,\r\n\t// \t\t)\r\n\t// \t) {\r\n\t// \t\taddStatsToBoard(\r\n\t// \t\t\tentity,\r\n\t// \t\t\tplayerState.board,\r\n\t// \t\t\tplayerState.player,\r\n\t// \t\t\t0,\r\n\t// \t\t\tentity.cardId === CardIds.HunterOfGatherers_BG25_027_G ? 2 : 1,\r\n\t// \t\t\tgameState,\r\n\t// \t\t);\r\n\t// \t}\r\n\t// }\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\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (hasCorrectTribe(entity, friendlyBoardHero, Race.ELEMENTAL, gameState.allCards)) {\r\n\t\tconst masterOfRealities = friendlyBoard.filter(\r\n\t\t\t(e) => e.cardId === CardIds.MasterOfRealities_BG21_036 || e.cardId === CardIds.MasterOfRealities_BG21_036_G,\r\n\t\t);\r\n\t\tmasterOfRealities.forEach((master) => {\r\n\t\t\tmodifyStats(\r\n\t\t\t\tmaster,\r\n\t\t\t\tmaster.cardId === CardIds.MasterOfRealities_BG21_036_G ? 2 : 1,\r\n\t\t\t\tmaster.cardId === CardIds.MasterOfRealities_BG21_036_G ? 2 : 1,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\tconst tentaclesOfCthun = friendlyBoard\r\n\t\t.filter((e) => e.entityId !== entity.entityId)\r\n\t\t.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy ||\r\n\t\t\t\te.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G,\r\n\t\t);\r\n\ttentaclesOfCthun.forEach((tentacle) => {\r\n\t\ttentacle.attack += tentacle.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G ? 2 : 1;\r\n\t\ttentacle.health += tentacle.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G ? 2 : 1;\r\n\t});\r\n};\r\n"]}
1
+ {"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/simulation/stats.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAG7D,4DAA4D;AAC5D,iEAA4D;AAC5D,oCAA4D;AAC5D,+DAAyD;AACzD,qCAAyC;AA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,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YACpC,IAAA,mBAAW,EACV,MAAM,EACN,MAAM,CAAC,MAAM,iBAAyC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC9D,MAAM,CAAC,MAAM,iBAAyC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC9D,aAAa,EACb,iBAAiB,EACjB,SAAS,CACT,CAAC;QACH,CAAC,CAAC,CAAC;KACH;IACD,MAAM,gBAAgB,GAAG,aAAa;SACpC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,QAAQ,CAAC;SAC7C,MAAM,CACN,CAAC,CAAC,EAAE,EAAE,CACL,CAAC,CAAC,MAAM,iCAAuD;QAC/D,CAAC,CAAC,MAAM,mCAAyD,CAClE,CAAC;IACH,gBAAgB,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;QACrC,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM,mCAAyD,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACpG,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM,mCAAyD,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACrG,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { hasOnStatsChanged } from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { addStatsToBoard, hasCorrectTribe } from '../utils';\r\nimport { applyAurasToSelf } from './add-minion-to-board';\r\nimport { getNeighbours } from './attack';\r\nimport { FullGameState, PlayerState } from './internal-game-state';\r\nimport { onQuestProgressUpdated } from './quest';\r\nimport { Spectator } from './spectator/spectator';\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): void => {\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);\r\n};\r\n\r\nexport const modifyStats = (\r\n\tentity: BoardEntity,\r\n\tattackAmount: number,\r\n\thealthAmount: number,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tspectator: Spectator = null,\r\n): void => {\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 += 3 * buff;\r\n\t\thealthAmount += 2 * buff;\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 neighbours = getNeighbours(friendlyBoard, entity);\r\n\tconst poetMultipliers = hasCorrectTribe(entity, friendlyBoardHero, Race.DRAGON, gameState.allCards)\r\n\t\t? neighbours.filter((e) => e.cardId === CardIds.PersistentPoet_BG29_813_G).length * 2 || 1\r\n\t\t: 1;\r\n\tconst tarecgosaMultiplier = 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\r\n\tentity.attack = Math.max(0, entity.attack + realAttackAmount);\r\n\tentity.previousAttack = entity.attack;\r\n\tentity.pendingAttackBuffs = entity.pendingAttackBuffs || [];\r\n\tentity.pendingAttackBuffs.push(realAttackAmount);\r\n\tentity.health += realHealthAmount;\r\n\r\n\tif (realAttackAmount > 0) {\r\n\t\tentity.maxAttack += realAttackAmount;\r\n\r\n\t\tif (hasCorrectTribe(entity, friendlyBoardHero, Race.DRAGON, gameState.allCards)) {\r\n\t\t\tconst whelpSmugglers = friendlyBoard.filter(\r\n\t\t\t\t(e) => e.cardId === CardIds.WhelpSmuggler_BG21_013 || e.cardId === CardIds.WhelpSmuggler_BG21_013_G,\r\n\t\t\t);\r\n\t\t\twhelpSmugglers.forEach((smuggler) => {\r\n\t\t\t\tconst buff = smuggler.cardId === CardIds.WhelpSmuggler_BG21_013_G ? 2 : 1;\r\n\t\t\t\tmodifyStats(entity, 0, buff, friendlyBoard, friendlyBoardHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tsmuggler,\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tfriendlyBoard,\r\n\t\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\r\n\t\t\tif (entity.cardId !== CardIds.Stormbringer_BG26_966 && entity.cardId !== CardIds.Stormbringer_BG26_966_G) {\r\n\t\t\t\tconst stormbringers = friendlyBoard.filter(\r\n\t\t\t\t\t(e) => e.cardId === CardIds.Stormbringer_BG26_966 || e.cardId === CardIds.Stormbringer_BG26_966_G,\r\n\t\t\t\t);\r\n\t\t\t\tstormbringers.forEach((stormbringer) => {\r\n\t\t\t\t\tconst multiplier = stormbringer.cardId === CardIds.Stormbringer_BG26_966_G ? 2 : 1;\r\n\t\t\t\t\t// This is never called?\r\n\t\t\t\t\t(e) => {\r\n\t\t\t\t\t\te.attack += multiplier * realAttackAmount;\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\tstormbringer,\r\n\t\t\t\t\t\t\tentity,\r\n\t\t\t\t\t\t\tfriendlyBoard,\r\n\t\t\t\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\t\t\t\totherBoardHero,\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\r\n\t\t// Sinestra\r\n\t\tfriendlyBoard\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId === CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy ||\r\n\t\t\t\t\te.cardId === CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy_G,\r\n\t\t\t)\r\n\t\t\t.forEach((sinestra) => {\r\n\t\t\t\tconst buff = sinestra.cardId === CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy_G ? 2 : 1;\r\n\t\t\t\tentity.health += buff;\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tsinestra,\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tfriendlyBoard,\r\n\t\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\r\n\t\t// TODO: what happens if the Hunter is killed during the attack?\r\n\t\tif (\r\n\t\t\t[CardIds.HunterOfGatherers_BG25_027, CardIds.HunterOfGatherers_BG25_027_G].includes(\r\n\t\t\t\tentity.cardId as CardIds,\r\n\t\t\t)\r\n\t\t) {\r\n\t\t\taddStatsToBoard(\r\n\t\t\t\tentity,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\t0,\r\n\t\t\t\tentity.cardId === CardIds.HunterOfGatherers_BG25_027_G ? 4 : 2,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t} else if (\r\n\t\t\tentity.cardId === CardIds.DefiantShipwright_BG21_018 ||\r\n\t\t\tentity.cardId === CardIds.DefiantShipwright_BG21_018_G\r\n\t\t) {\r\n\t\t\tconst stat = entity.cardId === CardIds.DefiantShipwright_BG21_018_G ? 2 : 1;\r\n\t\t\tentity.health += stat;\r\n\t\t}\r\n\t}\r\n\r\n\tif (realHealthAmount > 0) {\r\n\t\tentity.maxHealth += realHealthAmount;\r\n\t\tconst titanicGuardians = friendlyBoard\r\n\t\t\t.filter((e) => e.entityId !== entity.entityId)\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy ||\r\n\t\t\t\t\te.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy_G,\r\n\t\t\t);\r\n\t\ttitanicGuardians.forEach((guardian) => {\r\n\t\t\tconst buff =\r\n\t\t\t\t(guardian.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy_G ? 2 : 1) * realHealthAmount;\r\n\t\t\tif (buff > 0) {\r\n\t\t\t\tguardian.health += buff;\r\n\t\t\t\tguardian.maxHealth += buff;\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tif (\r\n\t\tentity.cardId === CardIds.Menagerist_AmalgamToken ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A_G ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D_G\r\n\t) {\r\n\t\tconst mishmashes = friendlyBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy ||\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G,\r\n\t\t);\r\n\t\tmishmashes.forEach((mishmash) => {\r\n\t\t\tmodifyStats(\r\n\t\t\t\tmishmash,\r\n\t\t\t\t(mishmash.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G ? 2 : 1) * realAttackAmount,\r\n\t\t\t\t(mishmash.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G ? 2 : 1) * realHealthAmount,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\r\n\tonStatsUpdate(entity, realAttackAmount, realHealthAmount, friendlyBoard, friendlyBoardHero, gameState);\r\n};\r\n\r\nconst onStatsUpdate = (\r\n\tentity: BoardEntity,\r\n\trealAttackAmount: number,\r\n\trealHealthAmount: number,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tonStatUpdateMinions(entity, realAttackAmount, realHealthAmount, friendlyBoard, friendlyHero, gameState);\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\t// Attack buffs\r\n\t// Actually this was a bug, and the stats update happen at the same time\r\n\t// Keeping the structure here in case it's useful in the future\r\n\t// for (const attackBuff of entity.pendingAttackBuffs) {\r\n\t// \tif (isCorrectTribe(gameState.allCards.getCard(entity.cardId).races, Race.DRAGON)) {\r\n\t// \t\tconst whelpSmugglers = playerState.board.filter(\r\n\t// \t\t\t(e) => e.cardId === CardIds.WhelpSmuggler_BG21_013 || e.cardId === CardIds.WhelpSmuggler_BG21_013_G,\r\n\t// \t\t);\r\n\t// \t\twhelpSmugglers.forEach((smuggler) => {\r\n\t// \t\t\tconst buff = smuggler.cardId === CardIds.WhelpSmuggler_BG21_013_G ? 2 : 1;\r\n\t// \t\t\tmodifyHealth(entity, buff, playerState.board, playerState.player, gameState);\r\n\t// \t\t\tgameState.spectator.registerPowerTarget(\r\n\t// \t\t\t\tsmuggler,\r\n\t// \t\t\t\tentity,\r\n\t// \t\t\t\tplayerState.board,\r\n\t// \t\t\t\tplayerState.player,\r\n\t// \t\t\t\topponentState.player,\r\n\t// \t\t\t);\r\n\t// \t\t});\r\n\r\n\t// \t\tif (entity.cardId !== CardIds.Stormbringer_BG26_966 && entity.cardId !== CardIds.Stormbringer_BG26_966_G) {\r\n\t// \t\t\tconst stormbringers = playerState.board.filter(\r\n\t// \t\t\t\t(e) => e.cardId === CardIds.Stormbringer_BG26_966 || e.cardId === CardIds.Stormbringer_BG26_966_G,\r\n\t// \t\t\t);\r\n\t// \t\t\tstormbringers.forEach((stormbringer) => {\r\n\t// \t\t\t\tconst multiplier = stormbringer.cardId === CardIds.Stormbringer_BG26_966_G ? 2 : 1;\r\n\t// \t\t\t\t(e) => {\r\n\t// \t\t\t\t\tmodifyAttack(e, multiplier * attackBuff, playerState.board, playerState.player, gameState);\r\n\t// \t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t// \t\t\t\t\t\tstormbringer,\r\n\t// \t\t\t\t\t\tentity,\r\n\t// \t\t\t\t\t\tplayerState.board,\r\n\t// \t\t\t\t\t\tplayerState.player,\r\n\t// \t\t\t\t\t\topponentState.player,\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\r\n\t// \t// TODO: what happens if the Hunter is killed during the attack?\r\n\t// \tif (\r\n\t// \t\t[CardIds.HunterOfGatherers_BG25_027, CardIds.HunterOfGatherers_BG25_027_G].includes(\r\n\t// \t\t\tentity.cardId as CardIds,\r\n\t// \t\t)\r\n\t// \t) {\r\n\t// \t\taddStatsToBoard(\r\n\t// \t\t\tentity,\r\n\t// \t\t\tplayerState.board,\r\n\t// \t\t\tplayerState.player,\r\n\t// \t\t\t0,\r\n\t// \t\t\tentity.cardId === CardIds.HunterOfGatherers_BG25_027_G ? 2 : 1,\r\n\t// \t\t\tgameState,\r\n\t// \t\t);\r\n\t// \t}\r\n\t// }\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\tattackAmount: number,\r\n\thealthAmount: number,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\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\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\tgameState: gameState,\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (hasCorrectTribe(entity, friendlyBoardHero, Race.ELEMENTAL, gameState.allCards)) {\r\n\t\tconst masterOfRealities = friendlyBoard.filter(\r\n\t\t\t(e) => e.cardId === CardIds.MasterOfRealities_BG21_036 || e.cardId === CardIds.MasterOfRealities_BG21_036_G,\r\n\t\t);\r\n\t\tmasterOfRealities.forEach((master) => {\r\n\t\t\tmodifyStats(\r\n\t\t\t\tmaster,\r\n\t\t\t\tmaster.cardId === CardIds.MasterOfRealities_BG21_036_G ? 2 : 1,\r\n\t\t\t\tmaster.cardId === CardIds.MasterOfRealities_BG21_036_G ? 2 : 1,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\tconst tentaclesOfCthun = friendlyBoard\r\n\t\t.filter((e) => e.entityId !== entity.entityId)\r\n\t\t.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy ||\r\n\t\t\t\te.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G,\r\n\t\t);\r\n\ttentaclesOfCthun.forEach((tentacle) => {\r\n\t\ttentacle.attack += tentacle.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G ? 2 : 1;\r\n\t\ttentacle.health += tentacle.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G ? 2 : 1;\r\n\t});\r\n};\r\n\r\nexport interface OnStatsChangedInput {\r\n\ttarget: BoardEntity;\r\n\tattackAmount: number;\r\n\thealthAmount: number;\r\n\tboard: BoardEntity[];\r\n\thero: BgsPlayerEntity;\r\n\tgameState: FullGameState;\r\n}\r\n"]}
@@ -50,8 +50,8 @@ const handleBoomControllerForPlayer = (trinket, playerBoard, playerEntity, oppon
50
50
  ? 0
51
51
  : Math.min(playerBoard.length, Math.max(0, playerBoard.length - initialIndexFromLeft));
52
52
  const target = (0, deathrattle_spawns_1.spawnEntities)(spawn.cardId, 1, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState.allCards, gameState.cardsData, gameState.sharedState, gameState.spectator, playerEntity.friendly, true, false, false, spawn);
53
- (0, spawns_1.performEntitySpawns)(target, playerBoard, playerEntity, playerEntity, indexFromRight, opponentBoard, opponentEntity, gameState);
54
- target.forEach((t) => gameState.spectator.registerPowerTarget(playerEntity, t, playerBoard, playerEntity, opponentEntity));
53
+ const actualSpawns = (0, spawns_1.performEntitySpawns)(target, playerBoard, playerEntity, playerEntity, indexFromRight, opponentBoard, opponentEntity, gameState);
54
+ actualSpawns.forEach((t) => gameState.spectator.registerPowerTarget(playerEntity, t, playerBoard, playerEntity, opponentEntity));
55
55
  trinket.scriptDataNum1 = 0;
56
56
  }
57
57
  }
@@ -115,16 +115,6 @@ const handleRapidReanimationForPlayer = (playerBoard, playerEntity, opponentBoar
115
115
  const hasSummoned = handleSummon(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState, playerEntity.rapidReanimationMinion.cardId, indexFromRight, playerEntity.rapidReanimationMinion);
116
116
  if (hasSummoned) {
117
117
  playerEntity.rapidReanimationMinion = null;
118
- hasSummoned.forEach((entity) => {
119
- switch (entity.cardId) {
120
- case "BG_TTN_401":
121
- case "BG_TTN_401_G":
122
- const overstatMult = entity.cardId === "BG_TTN_401" ? 1 : 2;
123
- entity.attack = Math.max(1, entity.attack - 2 * overstatMult);
124
- entity.health = Math.max(0, entity.health - overstatMult);
125
- break;
126
- }
127
- });
128
118
  }
129
119
  };
130
120
  const handleSummon = (playerBoard, playerEntity, opponentBoard, opponentEntity, gameState, cardId, indexFromRight, minion = null) => {
@@ -1 +1 @@
1
- {"version":3,"file":"summon-when-space.js","sourceRoot":"","sources":["../../src/simulation/summon-when-space.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAG7D,oCAA+E;AAC/E,+DAA4D;AAC5D,6DAAqD;AAErD,qCAA+C;AAExC,MAAM,sBAAsB,GAAG,CACrC,WAA0B,EAC1B,YAA6B,EAC7B,aAA4B,EAC5B,cAA+B,EAC/B,SAAwB,EACvB,EAAE;IACH,+BAA+B,CAAC,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;IACnH,+BAA+B,CAC9B,cAAc,EACd,aAAa,EACb,cAAc,EACd,WAAW,EACX,YAAY,EACZ,SAAS,CACT,CAAC;AACH,CAAC,CAAC;AAhBW,QAAA,sBAAsB,0BAgBjC;AAGF,MAAM,+BAA+B,GAAG,CACvC,YAA6B,EAC7B,WAA0B,EAC1B,YAA6B,EAC7B,aAA4B,EAC5B,cAA+B,EAC/B,SAAwB,EACvB,EAAE;;IACH,IAAI,YAAY,CAAC,sBAAsB,EAAE;QACxC,+BAA+B,CAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;KACrG;IACD,IAAI,MAAA,YAAY,CAAC,YAAY,0CAAE,QAAQ,mBAA4C,EAAE;QACpF,iCAAiC,CAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;KACvG;IACD,IAAI,MAAA,YAAY,CAAC,OAAO,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,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AW,EACX,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,aAAa,EACb,cAAc,EACd,SAAS,EACT,KAAK,CACL,CAAC;IACF,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAAC,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC1F,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity, BoardTrinket } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { buildSingleBoardEntity, copyEntity, hasCorrectTribe } from '../utils';\r\nimport { removeAurasFromSelf } from './add-minion-to-board';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { performEntitySpawns } from './spawns';\r\n\r\nexport const handleSummonsWhenSpace = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\thandleSummonsWhenSpaceForPlayer(playerEntity, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\thandleSummonsWhenSpaceForPlayer(\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\tgameState,\r\n\t);\r\n};\r\n\r\n// TODO: Twin Sky Lanterns wait for 2 spaces\r\nconst handleSummonsWhenSpaceForPlayer = (\r\n\ttargetEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tif (targetEntity.rapidReanimationMinion) {\r\n\t\thandleRapidReanimationForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t}\r\n\tif (targetEntity.questRewards?.includes(CardIds.StableAmalgamation_BG28_Reward_518)) {\r\n\t\thandleStableAmalgamationForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t}\r\n\tif (targetEntity.secrets?.some((s) => s.cardId === CardIds.BoonOfBeetles_BG28_603)) {\r\n\t\thandleBoonOfBeetlesForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t}\r\n\tif (targetEntity.heroPowerId === CardIds.Ozumat_Tentacular) {\r\n\t\thandleOzumatForPlayer(\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\ttargetEntity.friendly,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\ttargetEntity.trinkets\r\n\t\t.filter(\r\n\t\t\t(t) =>\r\n\t\t\t\tt.cardId === CardIds.TwinSkyLanterns_BG30_MagicItem_822 ||\r\n\t\t\t\tt.cardId === CardIds.TwinSkyLanterns_TwinSkyLanternsToken_BG30_MagicItem_822t2,\r\n\t\t)\r\n\t\t.forEach((t) => {\r\n\t\t\thandleTwinSkyLanternsForPlayer(t, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t});\r\n\ttargetEntity.trinkets\r\n\t\t.filter((t) => t.cardId === CardIds.BoomController_BG30_MagicItem_440)\r\n\t\t.forEach((t) => {\r\n\t\t\thandleBoomControllerForPlayer(t, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t});\r\n};\r\n\r\nconst handleBoomControllerForPlayer = (\r\n\ttrinket: BoardTrinket,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (playerBoard.length < 7 && trinket.scriptDataNum1 > 0) {\r\n\t\tconst candidate = gameState.sharedState.deaths\r\n\t\t\t.filter((d) => d.friendly === playerEntity.friendly)\r\n\t\t\t.filter((d) => hasCorrectTribe(d, playerEntity, Race.MECH, gameState.allCards))[0];\r\n\t\tif (!!candidate) {\r\n\t\t\tconst spawn = copyEntity(candidate);\r\n\t\t\tremoveAurasFromSelf(spawn, playerBoard, playerEntity, gameState);\r\n\t\t\tconst initialIndexFromLeft = candidate.indexFromLeftAtTimeOfDeath;\r\n\t\t\tconst indexFromRight =\r\n\t\t\t\tinitialIndexFromLeft == null\r\n\t\t\t\t\t? 0\r\n\t\t\t\t\t: Math.min(playerBoard.length, Math.max(0, playerBoard.length - initialIndexFromLeft));\r\n\t\t\tconst target = spawnEntities(\r\n\t\t\t\tspawn.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState.allCards,\r\n\t\t\t\tgameState.cardsData,\r\n\t\t\t\tgameState.sharedState,\r\n\t\t\t\tgameState.spectator,\r\n\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\ttrue,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tspawn,\r\n\t\t\t);\r\n\t\t\t// FIXME: here it should try to match the position at which the original minions died\r\n\t\t\tperformEntitySpawns(\r\n\t\t\t\ttarget,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\ttarget.forEach((t) =>\r\n\t\t\t\tgameState.spectator.registerPowerTarget(playerEntity, t, playerBoard, playerEntity, opponentEntity),\r\n\t\t\t);\r\n\t\t\ttrinket.scriptDataNum1 = 0;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleTwinSkyLanternsForPlayer = (\r\n\ttrinket: BoardTrinket,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst spawnNumber = trinket.scriptDataNum1;\r\n\tconst canTrigger = spawnNumber >= 1;\r\n\tif (playerBoard.length <= 7 - spawnNumber && trinket.rememberedMinion && canTrigger) {\r\n\t\ttrinket.scriptDataNum1 = 0;\r\n\t\tconst spawn = copyEntity(trinket.rememberedMinion);\r\n\t\tremoveAurasFromSelf(spawn, playerBoard, playerEntity, gameState);\r\n\t\tconst target = spawnEntities(\r\n\t\t\tspawn.cardId,\r\n\t\t\tspawnNumber,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState.allCards,\r\n\t\t\tgameState.cardsData,\r\n\t\t\tgameState.sharedState,\r\n\t\t\tgameState.spectator,\r\n\t\t\tplayerEntity.friendly,\r\n\t\t\ttrue,\r\n\t\t\tfalse,\r\n\t\t\tfalse,\r\n\t\t\tspawn,\r\n\t\t);\r\n\t\tperformEntitySpawns(\r\n\t\t\ttarget,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerEntity,\r\n\t\t\t0,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\ttarget.forEach((t) =>\r\n\t\t\tgameState.spectator.registerPowerTarget(playerEntity, t, playerBoard, playerEntity, opponentEntity),\r\n\t\t);\r\n\t}\r\n};\r\n\r\nconst handleOzumatForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (playerBoard.length < 7 && playerEntity.heroPowerActivated === false) {\r\n\t\tconst tentacularSize = +playerEntity.heroPowerInfo;\r\n\t\tconst tentacular = spawnEntities(\r\n\t\t\tCardIds.Tentacular_OzumatsTentacleToken_BG23_HERO_201pt,\r\n\t\t\t1,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState.allCards,\r\n\t\t\tgameState.cardsData,\r\n\t\t\tgameState.sharedState,\r\n\t\t\tgameState.spectator,\r\n\t\t\tfriendly,\r\n\t\t\ttrue,\r\n\t\t\tfalse,\r\n\t\t\tfalse,\r\n\t\t);\r\n\t\ttentacular[0].attack = tentacularSize;\r\n\t\ttentacular[0].health = tentacularSize;\r\n\t\tconst indexFromRight = 0;\r\n\t\tperformEntitySpawns(\r\n\t\t\ttentacular,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerEntity,\r\n\t\t\tindexFromRight,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tgameState.spectator.registerPowerTarget(playerEntity, tentacular[0], playerBoard, playerEntity, opponentEntity);\r\n\t\tplayerEntity.heroPowerActivated = true;\r\n\t}\r\n};\r\n\r\nconst handleBoonOfBeetlesForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst secretEntity = playerEntity.secrets.find((entity) => entity.cardId === CardIds.BoonOfBeetles_BG28_603);\r\n\tif (secretEntity && secretEntity.scriptDataNum1 > 0) {\r\n\t\twhile (secretEntity.scriptDataNum1 > 0) {\r\n\t\t\tconst hasSummoned = handleSummon(\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tCardIds.BoonOfBeetles_BeetleToken_BG28_603t,\r\n\t\t\t\t0,\r\n\t\t\t);\r\n\t\t\tif (hasSummoned) {\r\n\t\t\t\tsecretEntity.scriptDataNum1--;\r\n\t\t\t} else {\r\n\t\t\t\t// No room to summon, we stop here\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\nconst handleStableAmalgamationForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst rewardEntity = playerEntity.questRewardEntities.find(\r\n\t\t(entity) => entity.cardId === CardIds.StableAmalgamation_BG28_Reward_518,\r\n\t);\r\n\tif (rewardEntity && rewardEntity.scriptDataNum1 > 0) {\r\n\t\twhile (rewardEntity.scriptDataNum1 > 0) {\r\n\t\t\tconst hasSummoned = handleSummon(\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tCardIds.StableAmalgamation_TotallyNormalHorseToken_BG28_Reward_518t,\r\n\t\t\t\t0,\r\n\t\t\t);\r\n\t\t\tif (hasSummoned) {\r\n\t\t\t\trewardEntity.scriptDataNum1--;\r\n\t\t\t} else {\r\n\t\t\t\t// No room to summon, we stop here\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleRapidReanimationForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst indexFromRight =\r\n\t\tplayerEntity.rapidReanimationIndexFromLeft === 0\r\n\t\t\t? Math.max(0, playerBoard.length - playerEntity.rapidReanimationIndexFromLeft)\r\n\t\t\t: playerEntity.rapidReanimationIndexFromRight;\r\n\tconst hasSummoned = handleSummon(\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tgameState,\r\n\t\tplayerEntity.rapidReanimationMinion.cardId,\r\n\t\tindexFromRight,\r\n\t\tplayerEntity.rapidReanimationMinion,\r\n\t);\r\n\tif (hasSummoned) {\r\n\t\tplayerEntity.rapidReanimationMinion = null;\r\n\t\t// Hard-coding a correction for Astral Automation\r\n\t\thasSummoned.forEach((entity) => {\r\n\t\t\tswitch (entity.cardId) {\r\n\t\t\t\tcase CardIds.AstralAutomaton_BG_TTN_401:\r\n\t\t\t\tcase CardIds.AstralAutomaton_BG_TTN_401_G:\r\n\t\t\t\t\tconst overstatMult = entity.cardId === CardIds.AstralAutomaton_BG_TTN_401 ? 1 : 2;\r\n\t\t\t\t\tentity.attack = Math.max(1, entity.attack - 2 * overstatMult);\r\n\t\t\t\t\tentity.health = Math.max(0, entity.health - overstatMult);\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n};\r\n\r\nconst handleSummon = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tcardId: string,\r\n\tindexFromRight: number,\r\n\tminion: BoardEntity = null,\r\n): readonly BoardEntity[] => {\r\n\tif (playerBoard.length >= 7) {\r\n\t\treturn null;\r\n\t}\r\n\tconst newMinion = buildSingleBoardEntity(\r\n\t\tcardId,\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\tgameState.allCards,\r\n\t\tplayerEntity.friendly,\r\n\t\tgameState.sharedState.currentEntityId++,\r\n\t\tfalse,\r\n\t\tgameState.cardsData,\r\n\t\tgameState.sharedState,\r\n\t\tminion,\r\n\t\tnull,\r\n\t);\r\n\t// Don't reapply auras in this particular case? See https://x.com/ZerotoHeroes_HS/status/1737422727118487808?s=20\r\n\tconst spawned = performEntitySpawns(\r\n\t\t[newMinion],\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\tplayerEntity,\r\n\t\tindexFromRight,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tgameState,\r\n\t\tfalse,\r\n\t);\r\n\tgameState.spectator.registerPowerTarget(playerEntity, newMinion, playerBoard, null, null);\r\n\treturn spawned;\r\n};\r\n"]}
1
+ {"version":3,"file":"summon-when-space.js","sourceRoot":"","sources":["../../src/simulation/summon-when-space.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAG7D,oCAA+E;AAC/E,+DAA4D;AAC5D,6DAAqD;AAErD,qCAA+C;AAExC,MAAM,sBAAsB,GAAG,CACrC,WAA0B,EAC1B,YAA6B,EAC7B,aAA4B,EAC5B,cAA+B,EAC/B,SAAwB,EACvB,EAAE;IACH,+BAA+B,CAAC,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;IACnH,+BAA+B,CAC9B,cAAc,EACd,aAAa,EACb,cAAc,EACd,WAAW,EACX,YAAY,EACZ,SAAS,CACT,CAAC;AACH,CAAC,CAAC;AAhBW,QAAA,sBAAsB,0BAgBjC;AAGF,MAAM,+BAA+B,GAAG,CACvC,YAA6B,EAC7B,WAA0B,EAC1B,YAA6B,EAC7B,aAA4B,EAC5B,cAA+B,EAC/B,SAAwB,EACvB,EAAE;;IACH,IAAI,YAAY,CAAC,sBAAsB,EAAE;QACxC,+BAA+B,CAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;KACrG;IACD,IAAI,MAAA,YAAY,CAAC,YAAY,0CAAE,QAAQ,mBAA4C,EAAE;QACpF,iCAAiC,CAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAA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A6B,CAAC;QAC9E,CAAC,CAAC,YAAY,CAAC,8BAA8B,CAAC;IAChD,MAAM,WAAW,GAAG,YAAY,CAC/B,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,SAAS,EACT,YAAY,CAAC,sBAAsB,CAAC,MAAM,EAC1C,cAAc,EACd,YAAY,CAAC,sBAAsB,CACnC,CAAC;IACF,IAAI,WAAW,EAAE;QAChB,YAAY,CAAC,sBAAsB,GAAG,IAAI,CAAC;KAc3C;AACF,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CACpB,WAA0B,EAC1B,YAA6B,EAC7B,aAA4B,EAC5B,cAA+B,EAC/B,SAAwB,EACxB,MAAc,EACd,cAAsB,EACtB,SAAsB,IAAI,EACD,EAAE;IAC3B,IAAI,WAAW,CAAC,MAAM,IAAI,CAAC,EAAE;QAC5B,OAAO,IAAI,CAAC;KACZ;IACD,MAAM,SAAS,GAAG,IAAA,8BAAsB,EACvC,MAAM,EACN,YAAY,EACZ,WAAW,EACX,SAAS,CAAC,QAAQ,EAClB,YAAY,CAAC,QAAQ,EACrB,SAAS,CAAC,WAAW,CAAC,eAAe,EAAE,EACvC,KAAK,EACL,SAAS,CAAC,SAAS,EACnB,SAAS,CAAC,WAAW,EACrB,MAAM,EACN,IAAI,CACJ,CAAC;IAEF,MAAM,OAAO,GAAG,IAAA,4BAAmB,EAClC,CAAC,SAAS,CAAC,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,aAAa,EACb,cAAc,EACd,SAAS,EACT,KAAK,CACL,CAAC;IACF,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAAC,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC1F,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity, BoardTrinket } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { buildSingleBoardEntity, copyEntity, hasCorrectTribe } from '../utils';\r\nimport { removeAurasFromSelf } from './add-minion-to-board';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { performEntitySpawns } from './spawns';\r\n\r\nexport const handleSummonsWhenSpace = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\thandleSummonsWhenSpaceForPlayer(playerEntity, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\thandleSummonsWhenSpaceForPlayer(\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\tgameState,\r\n\t);\r\n};\r\n\r\n// TODO: Twin Sky Lanterns wait for 2 spaces\r\nconst handleSummonsWhenSpaceForPlayer = (\r\n\ttargetEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tif (targetEntity.rapidReanimationMinion) {\r\n\t\thandleRapidReanimationForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t}\r\n\tif (targetEntity.questRewards?.includes(CardIds.StableAmalgamation_BG28_Reward_518)) {\r\n\t\thandleStableAmalgamationForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t}\r\n\tif (targetEntity.secrets?.some((s) => s.cardId === CardIds.BoonOfBeetles_BG28_603)) {\r\n\t\thandleBoonOfBeetlesForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t}\r\n\tif (targetEntity.heroPowerId === CardIds.Ozumat_Tentacular) {\r\n\t\thandleOzumatForPlayer(\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\ttargetEntity.friendly,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\ttargetEntity.trinkets\r\n\t\t.filter(\r\n\t\t\t(t) =>\r\n\t\t\t\tt.cardId === CardIds.TwinSkyLanterns_BG30_MagicItem_822 ||\r\n\t\t\t\tt.cardId === CardIds.TwinSkyLanterns_TwinSkyLanternsToken_BG30_MagicItem_822t2,\r\n\t\t)\r\n\t\t.forEach((t) => {\r\n\t\t\thandleTwinSkyLanternsForPlayer(t, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t});\r\n\ttargetEntity.trinkets\r\n\t\t.filter((t) => t.cardId === CardIds.BoomController_BG30_MagicItem_440)\r\n\t\t.forEach((t) => {\r\n\t\t\thandleBoomControllerForPlayer(t, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t});\r\n};\r\n\r\nconst handleBoomControllerForPlayer = (\r\n\ttrinket: BoardTrinket,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (playerBoard.length < 7 && trinket.scriptDataNum1 > 0) {\r\n\t\tconst candidate = gameState.sharedState.deaths\r\n\t\t\t.filter((d) => d.friendly === playerEntity.friendly)\r\n\t\t\t.filter((d) => hasCorrectTribe(d, playerEntity, Race.MECH, gameState.allCards))[0];\r\n\t\tif (!!candidate) {\r\n\t\t\tconst spawn = copyEntity(candidate);\r\n\t\t\tremoveAurasFromSelf(spawn, playerBoard, playerEntity, gameState);\r\n\t\t\tconst initialIndexFromLeft = candidate.indexFromLeftAtTimeOfDeath;\r\n\t\t\tconst indexFromRight =\r\n\t\t\t\tinitialIndexFromLeft == null\r\n\t\t\t\t\t? 0\r\n\t\t\t\t\t: Math.min(playerBoard.length, Math.max(0, playerBoard.length - initialIndexFromLeft));\r\n\t\t\tconst target = spawnEntities(\r\n\t\t\t\tspawn.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState.allCards,\r\n\t\t\t\tgameState.cardsData,\r\n\t\t\t\tgameState.sharedState,\r\n\t\t\t\tgameState.spectator,\r\n\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\ttrue,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tspawn,\r\n\t\t\t);\r\n\t\t\t// FIXME: here it should try to match the position at which the original minions died\r\n\t\t\tconst actualSpawns = performEntitySpawns(\r\n\t\t\t\ttarget,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tactualSpawns.forEach((t) =>\r\n\t\t\t\tgameState.spectator.registerPowerTarget(playerEntity, t, playerBoard, playerEntity, opponentEntity),\r\n\t\t\t);\r\n\t\t\ttrinket.scriptDataNum1 = 0;\r\n\t\t\t// It summons an exact copy\r\n\t\t\t// actualSpawns.forEach((entity) => {\r\n\t\t\t// \tswitch (entity.cardId) {\r\n\t\t\t// \t\tcase CardIds.AstralAutomaton_BG_TTN_401:\r\n\t\t\t// \t\tcase CardIds.AstralAutomaton_BG_TTN_401_G:\r\n\t\t\t// \t\t\tconst overstatMult = entity.cardId === CardIds.AstralAutomaton_BG_TTN_401 ? 1 : 2;\r\n\t\t\t// \t\t\tentity.attack = Math.max(1, entity.attack - 2 * overstatMult);\r\n\t\t\t// \t\t\tentity.health = Math.max(0, entity.health - overstatMult);\r\n\t\t\t// \t\t\tbreak;\r\n\t\t\t// \t}\r\n\t\t\t// });\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleTwinSkyLanternsForPlayer = (\r\n\ttrinket: BoardTrinket,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst spawnNumber = trinket.scriptDataNum1;\r\n\tconst canTrigger = spawnNumber >= 1;\r\n\tif (playerBoard.length <= 7 - spawnNumber && trinket.rememberedMinion && canTrigger) {\r\n\t\ttrinket.scriptDataNum1 = 0;\r\n\t\tconst spawn = copyEntity(trinket.rememberedMinion);\r\n\t\tremoveAurasFromSelf(spawn, playerBoard, playerEntity, gameState);\r\n\t\tconst target = spawnEntities(\r\n\t\t\tspawn.cardId,\r\n\t\t\tspawnNumber,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState.allCards,\r\n\t\t\tgameState.cardsData,\r\n\t\t\tgameState.sharedState,\r\n\t\t\tgameState.spectator,\r\n\t\t\tplayerEntity.friendly,\r\n\t\t\ttrue,\r\n\t\t\tfalse,\r\n\t\t\tfalse,\r\n\t\t\tspawn,\r\n\t\t);\r\n\t\tperformEntitySpawns(\r\n\t\t\ttarget,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerEntity,\r\n\t\t\t0,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\ttarget.forEach((t) =>\r\n\t\t\tgameState.spectator.registerPowerTarget(playerEntity, t, playerBoard, playerEntity, opponentEntity),\r\n\t\t);\r\n\t}\r\n};\r\n\r\nconst handleOzumatForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (playerBoard.length < 7 && playerEntity.heroPowerActivated === false) {\r\n\t\tconst tentacularSize = +playerEntity.heroPowerInfo;\r\n\t\tconst tentacular = spawnEntities(\r\n\t\t\tCardIds.Tentacular_OzumatsTentacleToken_BG23_HERO_201pt,\r\n\t\t\t1,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState.allCards,\r\n\t\t\tgameState.cardsData,\r\n\t\t\tgameState.sharedState,\r\n\t\t\tgameState.spectator,\r\n\t\t\tfriendly,\r\n\t\t\ttrue,\r\n\t\t\tfalse,\r\n\t\t\tfalse,\r\n\t\t);\r\n\t\ttentacular[0].attack = tentacularSize;\r\n\t\ttentacular[0].health = tentacularSize;\r\n\t\tconst indexFromRight = 0;\r\n\t\tperformEntitySpawns(\r\n\t\t\ttentacular,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerEntity,\r\n\t\t\tindexFromRight,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tgameState.spectator.registerPowerTarget(playerEntity, tentacular[0], playerBoard, playerEntity, opponentEntity);\r\n\t\tplayerEntity.heroPowerActivated = true;\r\n\t}\r\n};\r\n\r\nconst handleBoonOfBeetlesForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst secretEntity = playerEntity.secrets.find((entity) => entity.cardId === CardIds.BoonOfBeetles_BG28_603);\r\n\tif (secretEntity && secretEntity.scriptDataNum1 > 0) {\r\n\t\twhile (secretEntity.scriptDataNum1 > 0) {\r\n\t\t\tconst hasSummoned = handleSummon(\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tCardIds.BoonOfBeetles_BeetleToken_BG28_603t,\r\n\t\t\t\t0,\r\n\t\t\t);\r\n\t\t\tif (hasSummoned) {\r\n\t\t\t\tsecretEntity.scriptDataNum1--;\r\n\t\t\t} else {\r\n\t\t\t\t// No room to summon, we stop here\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\nconst handleStableAmalgamationForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst rewardEntity = playerEntity.questRewardEntities.find(\r\n\t\t(entity) => entity.cardId === CardIds.StableAmalgamation_BG28_Reward_518,\r\n\t);\r\n\tif (rewardEntity && rewardEntity.scriptDataNum1 > 0) {\r\n\t\twhile (rewardEntity.scriptDataNum1 > 0) {\r\n\t\t\tconst hasSummoned = handleSummon(\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tCardIds.StableAmalgamation_TotallyNormalHorseToken_BG28_Reward_518t,\r\n\t\t\t\t0,\r\n\t\t\t);\r\n\t\t\tif (hasSummoned) {\r\n\t\t\t\trewardEntity.scriptDataNum1--;\r\n\t\t\t} else {\r\n\t\t\t\t// No room to summon, we stop here\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleRapidReanimationForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst indexFromRight =\r\n\t\tplayerEntity.rapidReanimationIndexFromLeft === 0\r\n\t\t\t? Math.max(0, playerBoard.length - playerEntity.rapidReanimationIndexFromLeft)\r\n\t\t\t: playerEntity.rapidReanimationIndexFromRight;\r\n\tconst hasSummoned = handleSummon(\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tgameState,\r\n\t\tplayerEntity.rapidReanimationMinion.cardId,\r\n\t\tindexFromRight,\r\n\t\tplayerEntity.rapidReanimationMinion,\r\n\t);\r\n\tif (hasSummoned) {\r\n\t\tplayerEntity.rapidReanimationMinion = null;\r\n\t\t// Hard-coding a correction for Ancestral Automaton\r\n\t\t// Update 2024-11-22: looks like the new summoned copy now correctly includes the boost\r\n\t\t// https://replays.firestoneapp.com/?reviewId=295c1da2-44be-461e-8162-5a19eaa420a4&turn=7&action=2\r\n\t\t// hasSummoned.forEach((entity) => {\r\n\t\t// \tswitch (entity.cardId) {\r\n\t\t// \t\tcase CardIds.AstralAutomaton_BG_TTN_401:\r\n\t\t// \t\tcase CardIds.AstralAutomaton_BG_TTN_401_G:\r\n\t\t// \t\t\tconst overstatMult = entity.cardId === CardIds.AstralAutomaton_BG_TTN_401 ? 1 : 2;\r\n\t\t// \t\t\tentity.attack = Math.max(1, entity.attack - 2 * overstatMult);\r\n\t\t// \t\t\tentity.health = Math.max(0, entity.health - overstatMult);\r\n\t\t// \t\t\tbreak;\r\n\t\t// \t}\r\n\t\t// });\r\n\t}\r\n};\r\n\r\nconst handleSummon = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tcardId: string,\r\n\tindexFromRight: number,\r\n\tminion: BoardEntity = null,\r\n): readonly BoardEntity[] => {\r\n\tif (playerBoard.length >= 7) {\r\n\t\treturn null;\r\n\t}\r\n\tconst newMinion = buildSingleBoardEntity(\r\n\t\tcardId,\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\tgameState.allCards,\r\n\t\tplayerEntity.friendly,\r\n\t\tgameState.sharedState.currentEntityId++,\r\n\t\tfalse,\r\n\t\tgameState.cardsData,\r\n\t\tgameState.sharedState,\r\n\t\tminion,\r\n\t\tnull,\r\n\t);\r\n\t// Don't reapply auras in this particular case? See https://x.com/ZerotoHeroes_HS/status/1737422727118487808?s=20\r\n\tconst spawned = performEntitySpawns(\r\n\t\t[newMinion],\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\tplayerEntity,\r\n\t\tindexFromRight,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tgameState,\r\n\t\tfalse,\r\n\t);\r\n\tgameState.spectator.registerPowerTarget(playerEntity, newMinion, playerBoard, null, null);\r\n\treturn spawned;\r\n};\r\n"]}
@@ -1,2 +1,72 @@
1
1
  export declare const enum TempCardIds {
2
+ WispInTheShell = "",
3
+ WispInTheShell_G = "",
4
+ DeathlyStriker = "",
5
+ DeathlyStriker_G = "",
6
+ WanderingWight = "",
7
+ WanderingWight_G = "",
8
+ Banerboar = "",
9
+ Banerboar_G = "",
10
+ BoarGamer = "",
11
+ BoarGamer_G = "",
12
+ GemDay = "",
13
+ GemRat = "",
14
+ GemRat_G = "",
15
+ MaraudersContract = "MaraudersContract",
16
+ CrystalInfuserEnchantment = "CrystalInfuserEnchantment",
17
+ CrystalInfuserEnchantment_G = "CrystalInfuserEnchantment_G",
18
+ GrittyHeadhunter = "GrittyHeadhunter",
19
+ GrittyHeadhunter_G = "GrittyHeadhunter_G",
20
+ HoloRover = "HoloRover",
21
+ HoloRover_G = "HoloRover_G",
22
+ ForestRover = "ForestRover",
23
+ ForestRover_G = "ForestRover_G",
24
+ BeetleToken = "BeetleToken",
25
+ BeetleToken_G = "BeetleToken_G",
26
+ BuzzingVermin = "BuzzingVermin",
27
+ BuzzingVermin_G = "BuzzingVermin_G",
28
+ NestSwarmer = "NestSwarmer",
29
+ NestSwarmer_G = "NestSwarmer_G",
30
+ RunedProgenitor = "RunedProgenitor",
31
+ RunedProgenitor_G = "RunedProgenitor_G",
32
+ TurquoiseSkitterer = "TurquoiseSkitterer",
33
+ TurquoiseSkitterer_G = "TurquoiseSkitterer_G",
34
+ EfficientEngineer = "EfficientEngineer",
35
+ EfficientEngineer_G = "EfficientEngineer_G",
36
+ UltravioletAscendant = "UltravioletAscendant",
37
+ UltravioletAscendant_G = "UltravioletAscendant_G",
38
+ TwilightPrimordium = "TwilightPrimordium",
39
+ TwilightPrimordium_G = "TwilightPrimordium_G",
40
+ MoonsteelJuggernaut = "MoonsteelJuggernaut",
41
+ MoonsteelJuggernaut_G = "MoonsteelJuggernaut_G",
42
+ Satellite = "Satellite",
43
+ Satellite_G = "Satellite_G",
44
+ MarqueeTicker = "MarqueeTicker",
45
+ MarqueeTicker_G = "MarqueeTicker_G",
46
+ RecklessCliffdiver = "RecklessCliffdiver",
47
+ RecklessCliffdiver_G = "RecklessCliffdiver_G",
48
+ FountainChiller = "FountainChiller",
49
+ FountainChiller_G = "FountainChiller_G",
50
+ NeonAgent = "NeonAgent",
51
+ NeonAgent_G = "NeonAgent_G",
52
+ ImplantSubject = "ImplantSubject",
53
+ ImplantSubject_G = "ImplantSubject_G",
54
+ Hackerfin = "Hackerfin",
55
+ Hackerfin_G = "Hackerfin_G",
56
+ BubbleGunner = "BubbleGunner",
57
+ BubbleGunner_G = "BubbleGunner_G",
58
+ FairyGillmother = "FairyGillmother",
59
+ FairyGillmother_G = "FairyGillmother_G",
60
+ ShowyCyclist = "ShowyCyclist",
61
+ ShowyCyclist_G = "ShowyCyclist_G",
62
+ ArcaneCannoneer = "ArcaneCannoneer",
63
+ ArcaneCannoneer_G = "ArcaneCannoneer_G",
64
+ MutatedLasher = "MutatedLasher",
65
+ MutatedLasher_G = "MutatedLasher_G",
66
+ SilverHandedRecruit = "SilverHandedRecruit",
67
+ SilverHandedRecruit_G = "SilverHandedRecruit_G",
68
+ SaltyHog = "SaltyHog",
69
+ SaltyHog_G = "SaltyHog_G",
70
+ Spacefarer = "Spacefarer",
71
+ Spacefarer_G = "Spacefarer_G"
2
72
  }
@@ -1 +1 @@
1
- {"version":3,"file":"temp-card-ids.js","sourceRoot":"","sources":["../src/temp-card-ids.ts"],"names":[],"mappings":"","sourcesContent":["export declare const enum TempCardIds {}\r\n"]}
1
+ {"version":3,"file":"temp-card-ids.js","sourceRoot":"","sources":["../src/temp-card-ids.ts"],"names":[],"mappings":"","sourcesContent":["export declare const enum TempCardIds {\r\n\tWispInTheShell = '',\r\n\tWispInTheShell_G = '',\r\n\tDeathlyStriker = '',\r\n\tDeathlyStriker_G = '',\r\n\tWanderingWight = '',\r\n\tWanderingWight_G = '',\r\n\tBanerboar = '',\r\n\tBanerboar_G = '',\r\n\tBoarGamer = '',\r\n\tBoarGamer_G = '',\r\n\tGemDay = '',\r\n\tGemRat = '',\r\n\tGemRat_G = '',\r\n\tMaraudersContract = 'MaraudersContract',\r\n\tCrystalInfuserEnchantment = 'CrystalInfuserEnchantment',\r\n\tCrystalInfuserEnchantment_G = 'CrystalInfuserEnchantment_G',\r\n\tGrittyHeadhunter = 'GrittyHeadhunter',\r\n\tGrittyHeadhunter_G = 'GrittyHeadhunter_G',\r\n\tHoloRover = 'HoloRover',\r\n\tHoloRover_G = 'HoloRover_G',\r\n\tForestRover = 'ForestRover',\r\n\tForestRover_G = 'ForestRover_G',\r\n\tBeetleToken = 'BeetleToken',\r\n\tBeetleToken_G = 'BeetleToken_G',\r\n\tBuzzingVermin = 'BuzzingVermin',\r\n\tBuzzingVermin_G = 'BuzzingVermin_G',\r\n\tNestSwarmer = 'NestSwarmer',\r\n\tNestSwarmer_G = 'NestSwarmer_G',\r\n\tRunedProgenitor = 'RunedProgenitor',\r\n\tRunedProgenitor_G = 'RunedProgenitor_G',\r\n\tTurquoiseSkitterer = 'TurquoiseSkitterer',\r\n\tTurquoiseSkitterer_G = 'TurquoiseSkitterer_G',\r\n\tEfficientEngineer = 'EfficientEngineer',\r\n\tEfficientEngineer_G = 'EfficientEngineer_G',\r\n\tUltravioletAscendant = 'UltravioletAscendant',\r\n\tUltravioletAscendant_G = 'UltravioletAscendant_G',\r\n\tTwilightPrimordium = 'TwilightPrimordium',\r\n\tTwilightPrimordium_G = 'TwilightPrimordium_G',\r\n\tMoonsteelJuggernaut = 'MoonsteelJuggernaut',\r\n\tMoonsteelJuggernaut_G = 'MoonsteelJuggernaut_G',\r\n\tSatellite = 'Satellite',\r\n\tSatellite_G = 'Satellite_G',\r\n\tMarqueeTicker = 'MarqueeTicker',\r\n\tMarqueeTicker_G = 'MarqueeTicker_G',\r\n\tRecklessCliffdiver = 'RecklessCliffdiver',\r\n\tRecklessCliffdiver_G = 'RecklessCliffdiver_G',\r\n\tFountainChiller = 'FountainChiller',\r\n\tFountainChiller_G = 'FountainChiller_G',\r\n\tNeonAgent = 'NeonAgent',\r\n\tNeonAgent_G = 'NeonAgent_G',\r\n\tImplantSubject = 'ImplantSubject',\r\n\tImplantSubject_G = 'ImplantSubject_G',\r\n\tHackerfin = 'Hackerfin',\r\n\tHackerfin_G = 'Hackerfin_G',\r\n\tBubbleGunner = 'BubbleGunner',\r\n\tBubbleGunner_G = 'BubbleGunner_G',\r\n\tFairyGillmother = 'FairyGillmother',\r\n\tFairyGillmother_G = 'FairyGillmother_G',\r\n\tShowyCyclist = 'ShowyCyclist',\r\n\tShowyCyclist_G = 'ShowyCyclist_G',\r\n\tArcaneCannoneer = 'ArcaneCannoneer',\r\n\tArcaneCannoneer_G = 'ArcaneCannoneer_G',\r\n\tMutatedLasher = 'MutatedLasher',\r\n\tMutatedLasher_G = 'MutatedLasher_G',\r\n\tSilverHandedRecruit = 'SilverHandedRecruit',\r\n\tSilverHandedRecruit_G = 'SilverHandedRecruit_G',\r\n\tSaltyHog = 'SaltyHog',\r\n\tSaltyHog_G = 'SaltyHog_G',\r\n\tSpacefarer = 'Spacefarer',\r\n\tSpacefarer_G = 'Spacefarer_G',\r\n}\r\n"]}
package/dist/utils.d.ts CHANGED
@@ -10,7 +10,6 @@ export declare const buildRandomUndeadCreation: (controllerHero: BgsPlayerEntity
10
10
  export declare const grantRandomAttack: (source: BoardEntity, board: BoardEntity[], hero: BgsPlayerEntity, additionalAttack: number, gameState: FullGameState, excludeSource?: boolean) => void;
11
11
  export declare const grantRandomHealth: (source: BoardEntity, board: BoardEntity[], hero: BgsPlayerEntity, health: number, gameState: FullGameState, excludeSource?: boolean) => void;
12
12
  export declare const grantRandomStats: (source: BoardEntity, board: BoardEntity[], hero: BgsPlayerEntity, attack: number, health: number, race: Race, excludeSource: boolean, gameState: FullGameState) => BoardEntity;
13
- export declare const updateVenomous: (entity: BoardEntity, newValue: boolean, board: BoardEntity[], boardHero: BgsPlayerEntity, gameState: FullGameState) => void;
14
13
  export declare const getRandomAliveMinion: (board: BoardEntity[], hero: BgsPlayerEntity, race: Race, allCards: AllCardsService) => BoardEntity;
15
14
  export declare const getRandomRevivableMinion: (board: BoardEntity[], hero: BgsPlayerEntity, race: Race, allCards: AllCardsService) => BoardEntity;
16
15
  export declare const getRandomMinionWithHighestHealth: (board: BoardEntity[]) => BoardEntity;
package/dist/utils.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.copyEntity = exports.getTeammateInitialState = exports.getPlayerState = exports.isGolden = exports.isPilotedWhirlOTron = exports.isFish = exports.stringifySimpleCard = exports.stringifySimple = exports.normalizeCardIdForSkin = exports.addImpliedMechanics = exports.getRaceEnum = exports.isCorrectTribe = exports.getEffectiveTribesForEntity = exports.hasCorrectTribe = exports.hasMechanic = exports.getMinionsOfDifferentTypes = exports.grantStatsToMinionsOfEachType = exports.addStatsToAliveBoard = exports.addStatsToBoard = exports.getRandomMinionWithHighestHealth = exports.getRandomRevivableMinion = exports.getRandomAliveMinion = exports.updateVenomous = exports.grantRandomStats = exports.grantRandomHealth = exports.grantRandomAttack = exports.buildRandomUndeadCreation = exports.buildSingleBoardEntity = void 0;
3
+ exports.copyEntity = exports.getTeammateInitialState = exports.getPlayerState = exports.isGolden = exports.isPilotedWhirlOTron = exports.isFish = exports.stringifySimpleCard = exports.stringifySimple = exports.normalizeCardIdForSkin = exports.addImpliedMechanics = exports.getRaceEnum = exports.isCorrectTribe = exports.getEffectiveTribesForEntity = exports.hasCorrectTribe = exports.hasMechanic = exports.getMinionsOfDifferentTypes = exports.grantStatsToMinionsOfEachType = exports.addStatsToAliveBoard = exports.addStatsToBoard = exports.getRandomMinionWithHighestHealth = exports.getRandomRevivableMinion = exports.getRandomAliveMinion = exports.grantRandomStats = exports.grantRandomHealth = exports.grantRandomAttack = exports.buildRandomUndeadCreation = exports.buildSingleBoardEntity = void 0;
4
4
  const reference_data_1 = require("@firestone-hs/reference-data");
5
+ const card_interface_1 = require("./cards/card.interface");
6
+ const _card_mappings_1 = require("./cards/impl/_card-mappings");
5
7
  const utils_1 = require("./services/utils");
6
8
  const stats_1 = require("./simulation/stats");
7
9
  const CLEAVE_IDS = [
@@ -162,20 +164,6 @@ const grantRandomStats = (source, board, hero, attack, health, race, excludeSour
162
164
  return null;
163
165
  };
164
166
  exports.grantRandomStats = grantRandomStats;
165
- const updateVenomous = (entity, newValue, board, boardHero, gameState) => {
166
- const lostVenomous = entity.venomous && !newValue;
167
- entity.venomous = newValue;
168
- if (lostVenomous) {
169
- const belcherPortraits = boardHero.trinkets.filter((t) => t.cardId === "BG30_MagicItem_432" ||
170
- t.cardId === "BG30_MagicItem_432t");
171
- belcherPortraits.forEach((p) => {
172
- const buff = p.cardId === "BG30_MagicItem_432t" ? 14 : 4;
173
- (0, stats_1.modifyStats)(entity, buff, buff, board, boardHero, gameState);
174
- gameState.spectator.registerPowerTarget(p, entity, board, null, null);
175
- });
176
- }
177
- };
178
- exports.updateVenomous = updateVenomous;
179
167
  const getRandomAliveMinion = (board, hero, race, allCards) => {
180
168
  const validTribes = board
181
169
  .filter((e) => !race || (0, exports.hasCorrectTribe)(e, hero, race, allCards))
@@ -335,28 +323,34 @@ const addImpliedMechanics = (entity, cardsData) => {
335
323
  : entity.cardId === "BG20_204"
336
324
  ? 1
337
325
  : 0;
338
- entity.abiityChargesLeft = [
339
- "BG29_610",
340
- "BG29_610_G",
341
- "BG26_590",
342
- "BG26_590_G",
343
- "BG29_831",
344
- "BG29_831_G",
345
- "BG29_160",
346
- "BG29_160_G",
347
- ].includes(entity.cardId)
348
- ? 3
349
- : [
350
- "BG27_013_G",
351
- "BG27_507_G",
352
- "TB_BaconShop_HERO_08_Buddy_G",
353
- "BG28_404_G",
354
- "BG29_844",
355
- "BG29_844_G",
356
- "BG30_111_G",
326
+ const defaultChargesImpl = _card_mappings_1.cardMappings[entity.cardId];
327
+ if ((0, card_interface_1.hasDefaultCharges)(defaultChargesImpl)) {
328
+ entity.abiityChargesLeft = defaultChargesImpl.defaultCharges;
329
+ }
330
+ else {
331
+ entity.abiityChargesLeft = [
332
+ "BG29_610",
333
+ "BG29_610_G",
334
+ "BG26_590",
335
+ "BG26_590_G",
336
+ "BG29_831",
337
+ "BG29_831_G",
338
+ "BG29_160",
339
+ "BG29_160_G",
357
340
  ].includes(entity.cardId)
358
- ? 2
359
- : 1;
341
+ ? 3
342
+ : [
343
+ "BG27_013_G",
344
+ "BG27_507_G",
345
+ "TB_BaconShop_HERO_08_Buddy_G",
346
+ "BG28_404_G",
347
+ "BG29_844",
348
+ "BG29_844_G",
349
+ "BG30_111_G",
350
+ ].includes(entity.cardId)
351
+ ? 2
352
+ : 1;
353
+ }
360
354
  return setImplicitDataForEntity(entity, cardsData);
361
355
  };
362
356
  exports.addImpliedMechanics = addImpliedMechanics;