@firestone-hs/simulate-bgs-battle 1.1.717 → 1.1.718

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 (241) hide show
  1. package/dist/bgs-battle-info.js.map +1 -1
  2. package/dist/cards/card.interface.js.map +1 -1
  3. package/dist/cards/cards-data.js.map +1 -1
  4. package/dist/cards/impl/_card-mappings.js +4 -2
  5. package/dist/cards/impl/_card-mappings.js.map +1 -1
  6. package/dist/cards/impl/bg-spell/sharing-is-caring.js.map +1 -1
  7. package/dist/cards/impl/bg-spell/shifting-tide.js.map +1 -1
  8. package/dist/cards/impl/bg-spell/toxic-tumbleweed.js.map +1 -1
  9. package/dist/cards/impl/hero-power/aim-high.js.map +1 -1
  10. package/dist/cards/impl/hero-power/aim-left.js.map +1 -1
  11. package/dist/cards/impl/hero-power/aim-low.js.map +1 -1
  12. package/dist/cards/impl/hero-power/aim-right.js.map +1 -1
  13. package/dist/cards/impl/hero-power/earth-invocation.js.map +1 -1
  14. package/dist/cards/impl/hero-power/embrace-your-rage.js.map +1 -1
  15. package/dist/cards/impl/hero-power/fire-invocation.js.map +1 -1
  16. package/dist/cards/impl/hero-power/lightning-invocation.js.map +1 -1
  17. package/dist/cards/impl/hero-power/reborn-rites.js.map +1 -1
  18. package/dist/cards/impl/hero-power/water-invocation.js.map +1 -1
  19. package/dist/cards/impl/minion/abyssal-bruiser.js +4 -2
  20. package/dist/cards/impl/minion/abyssal-bruiser.js.map +1 -1
  21. package/dist/cards/impl/minion/all-seeing-elder.js.map +1 -1
  22. package/dist/cards/impl/minion/alleycat.js.map +1 -1
  23. package/dist/cards/impl/minion/amber-guardian.js.map +1 -1
  24. package/dist/cards/impl/minion/archimonde.js.map +1 -1
  25. package/dist/cards/impl/minion/arid-atrocity.js.map +1 -1
  26. package/dist/cards/impl/minion/ashen-corruptor.js.map +1 -1
  27. package/dist/cards/impl/minion/assistant-guard.js.map +1 -1
  28. package/dist/cards/impl/minion/audacious-anchor.js.map +1 -1
  29. package/dist/cards/impl/minion/auto-assembler.js.map +1 -1
  30. package/dist/cards/impl/minion/avalanche-caller.js.map +1 -1
  31. package/dist/cards/impl/minion/baby-nzoth.d.ts +2 -0
  32. package/dist/cards/impl/minion/baby-nzoth.js +25 -0
  33. package/dist/cards/impl/minion/baby-nzoth.js.map +1 -0
  34. package/dist/cards/impl/minion/baneling.js.map +1 -1
  35. package/dist/cards/impl/minion/bigwig-bandit.js.map +1 -1
  36. package/dist/cards/impl/minion/bird-buddy.js.map +1 -1
  37. package/dist/cards/impl/minion/blazing-skyfin.js.map +1 -1
  38. package/dist/cards/impl/minion/blue-chromadrake.js +1 -1
  39. package/dist/cards/impl/minion/blue-chromadrake.js.map +1 -1
  40. package/dist/cards/impl/minion/blue-whelp.js.map +1 -1
  41. package/dist/cards/impl/minion/boar-gamer.js.map +1 -1
  42. package/dist/cards/impl/minion/briarback-bookie.js.map +1 -1
  43. package/dist/cards/impl/minion/bronze-steward.js.map +1 -1
  44. package/dist/cards/impl/minion/bubble-gunner.js.map +1 -1
  45. package/dist/cards/impl/minion/buzzing-vermin.js.map +1 -1
  46. package/dist/cards/impl/minion/cadaver-caretaker.js.map +1 -1
  47. package/dist/cards/impl/minion/captain-bonerender.js.map +1 -1
  48. package/dist/cards/impl/minion/carapace-raiser.js.map +1 -1
  49. package/dist/cards/impl/minion/carbonic-copy.js.map +1 -1
  50. package/dist/cards/impl/minion/clunker-junker.js +2 -4
  51. package/dist/cards/impl/minion/clunker-junker.js.map +1 -1
  52. package/dist/cards/impl/minion/coilskar-sapper.js.map +1 -1
  53. package/dist/cards/impl/minion/coldlight-diver.js.map +1 -1
  54. package/dist/cards/impl/minion/crystal-infuser-enchantment.js.map +1 -1
  55. package/dist/cards/impl/minion/cupcake-peddler.js.map +1 -1
  56. package/dist/cards/impl/minion/deadstomper.js.map +1 -1
  57. package/dist/cards/impl/minion/deathly-striker.js.map +1 -1
  58. package/dist/cards/impl/minion/deflecto-bot.js.map +1 -1
  59. package/dist/cards/impl/minion/devout-hellcaller.js.map +1 -1
  60. package/dist/cards/impl/minion/drakkari-embalmer.js.map +1 -1
  61. package/dist/cards/impl/minion/elder-taggawag.js.map +1 -1
  62. package/dist/cards/impl/minion/electric-synthesizer.js.map +1 -1
  63. package/dist/cards/impl/minion/elite-navigator.js.map +1 -1
  64. package/dist/cards/impl/minion/fairy-gillmother.js.map +1 -1
  65. package/dist/cards/impl/minion/firescale-hoarder.js.map +1 -1
  66. package/dist/cards/impl/minion/fireworks-fanatic.js.map +1 -1
  67. package/dist/cards/impl/minion/flotsam-flinger.js.map +1 -1
  68. package/dist/cards/impl/minion/fountain-chiller.js.map +1 -1
  69. package/dist/cards/impl/minion/friendly-geist.js.map +1 -1
  70. package/dist/cards/impl/minion/gem-rat.js.map +1 -1
  71. package/dist/cards/impl/minion/general-drakkisath.js.map +1 -1
  72. package/dist/cards/impl/minion/gentle-djinni.js.map +1 -1
  73. package/dist/cards/impl/minion/gentle-stag.js.map +1 -1
  74. package/dist/cards/impl/minion/glowing-cinder.js.map +1 -1
  75. package/dist/cards/impl/minion/gormling-gourmet.js.map +1 -1
  76. package/dist/cards/impl/minion/greedy-snaketongue.js.map +1 -1
  77. package/dist/cards/impl/minion/grimscale-elegist.js.map +1 -1
  78. package/dist/cards/impl/minion/gritty-headhunter.js.map +1 -1
  79. package/dist/cards/impl/minion/hackerfin.js.map +1 -1
  80. package/dist/cards/impl/minion/handless-forsaken.js.map +1 -1
  81. package/dist/cards/impl/minion/harmless-bonehead.js.map +1 -1
  82. package/dist/cards/impl/minion/hawkstrider-herald.js.map +1 -1
  83. package/dist/cards/impl/minion/holo-rover.js.map +1 -1
  84. package/dist/cards/impl/minion/humongozz.js.map +1 -1
  85. package/dist/cards/impl/minion/hungry-snapjaw.js.map +1 -1
  86. package/dist/cards/impl/minion/hunter-of-gatherers.js.map +1 -1
  87. package/dist/cards/impl/minion/ignition-specialist.js.map +1 -1
  88. package/dist/cards/impl/minion/immortal.js.map +1 -1
  89. package/dist/cards/impl/minion/implant-subject.js.map +1 -1
  90. package/dist/cards/impl/minion/imposing-percussionist.js.map +1 -1
  91. package/dist/cards/impl/minion/inspiring-underdog.js.map +1 -1
  92. package/dist/cards/impl/minion/interrogator-whitemane.js.map +1 -1
  93. package/dist/cards/impl/minion/kangors-apprentice.js.map +1 -1
  94. package/dist/cards/impl/minion/leeroy-the-reckless.js.map +1 -1
  95. package/dist/cards/impl/minion/lightfang-enforcer.js.map +1 -1
  96. package/dist/cards/impl/minion/lightfeather-screecher.js.map +1 -1
  97. package/dist/cards/impl/minion/living-azerite.js.map +1 -1
  98. package/dist/cards/impl/minion/lokholar-frostforger.js.map +1 -1
  99. package/dist/cards/impl/minion/lovesick-balladist.js.map +1 -1
  100. package/dist/cards/impl/minion/low-flier.js.map +1 -1
  101. package/dist/cards/impl/minion/lurker.js.map +1 -1
  102. package/dist/cards/impl/minion/manasaber.js.map +1 -1
  103. package/dist/cards/impl/minion/mantid-queen.js.map +1 -1
  104. package/dist/cards/impl/minion/marquee-ticker.js.map +1 -1
  105. package/dist/cards/impl/minion/maw-caster.js.map +1 -1
  106. package/dist/cards/impl/minion/mecha-jaraxxus.js.map +1 -1
  107. package/dist/cards/impl/minion/mechanized-gift-horse.js.map +1 -1
  108. package/dist/cards/impl/minion/mechorse.js.map +1 -1
  109. package/dist/cards/impl/minion/menagerie-jug.js.map +1 -1
  110. package/dist/cards/impl/minion/metallic-hunter.js.map +1 -1
  111. package/dist/cards/impl/minion/misfit-dragonling.js.map +1 -1
  112. package/dist/cards/impl/minion/mummifier.js +1 -1
  113. package/dist/cards/impl/minion/mummifier.js.map +1 -1
  114. package/dist/cards/impl/minion/murkbrine-expeditioner.js.map +1 -1
  115. package/dist/cards/impl/minion/murky.js.map +1 -1
  116. package/dist/cards/impl/minion/mutated-lasher.js.map +1 -1
  117. package/dist/cards/impl/minion/mythrax.js.map +1 -1
  118. package/dist/cards/impl/minion/neon-agent.js.map +1 -1
  119. package/dist/cards/impl/minion/nest-swarmer.js.map +1 -1
  120. package/dist/cards/impl/minion/nether-drake.js.map +1 -1
  121. package/dist/cards/impl/minion/nightmare-par-tea-guest.js.map +1 -1
  122. package/dist/cards/impl/minion/nimble-hatchling.js.map +1 -1
  123. package/dist/cards/impl/minion/operatic-belcher.js.map +1 -1
  124. package/dist/cards/impl/minion/outback-smolderer.js.map +1 -1
  125. package/dist/cards/impl/minion/parched-wanderer.js.map +1 -1
  126. package/dist/cards/impl/minion/primalfin-lookout.js.map +1 -1
  127. package/dist/cards/impl/minion/rapscallion-recruiter.js.map +1 -1
  128. package/dist/cards/impl/minion/razorgore-the-untamed.js.map +1 -1
  129. package/dist/cards/impl/minion/red-chromadrake.js +1 -1
  130. package/dist/cards/impl/minion/red-chromadrake.js.map +1 -1
  131. package/dist/cards/impl/minion/roach.js.map +1 -1
  132. package/dist/cards/impl/minion/roadboar.js.map +1 -1
  133. package/dist/cards/impl/minion/rodeo-performer.js.map +1 -1
  134. package/dist/cards/impl/minion/ruins-renovator.js.map +1 -1
  135. package/dist/cards/impl/minion/rylak-metalhead.js.map +1 -1
  136. package/dist/cards/impl/minion/salty-hog.js.map +1 -1
  137. package/dist/cards/impl/minion/sand-swirler.js.map +1 -1
  138. package/dist/cards/impl/minion/sandy.js.map +1 -1
  139. package/dist/cards/impl/minion/sanguine-refiner.js.map +1 -1
  140. package/dist/cards/impl/minion/scourge-harvester.js.map +1 -1
  141. package/dist/cards/impl/minion/selfless-hero.js.map +1 -1
  142. package/dist/cards/impl/minion/shadowdancer.js.map +1 -1
  143. package/dist/cards/impl/minion/sharp-eyed-sabretooth.js.map +1 -1
  144. package/dist/cards/impl/minion/sharptooth-snapper.js.map +1 -1
  145. package/dist/cards/impl/minion/ship-master-eudora.js.map +1 -1
  146. package/dist/cards/impl/minion/shipwrecked-rascal.js.map +1 -1
  147. package/dist/cards/impl/minion/silver-handed-recruit.js.map +1 -1
  148. package/dist/cards/impl/minion/slumber-sorcerer.js.map +1 -1
  149. package/dist/cards/impl/minion/smolderwing.js.map +1 -1
  150. package/dist/cards/impl/minion/sneeds-new-shredder.d.ts +2 -0
  151. package/dist/cards/impl/minion/{pilot-the-shredder.js → sneeds-new-shredder.js} +7 -4
  152. package/dist/cards/impl/minion/sneeds-new-shredder.js.map +1 -0
  153. package/dist/cards/impl/minion/soul-rewinder.js.map +1 -1
  154. package/dist/cards/impl/minion/spacefarer.js.map +1 -1
  155. package/dist/cards/impl/minion/spirited-whimsydrake.js.map +1 -1
  156. package/dist/cards/impl/minion/springy-spriggan.js.map +1 -1
  157. package/dist/cards/impl/minion/stitched-salvager.js.map +1 -1
  158. package/dist/cards/impl/minion/stray-satyr.js.map +1 -1
  159. package/dist/cards/impl/minion/sun-screener.js.map +1 -1
  160. package/dist/cards/impl/minion/surfing-slyvar.js.map +1 -1
  161. package/dist/cards/impl/minion/thorncaller.js.map +1 -1
  162. package/dist/cards/impl/minion/thousandth-paper-drake.js.map +1 -1
  163. package/dist/cards/impl/minion/thundering-abomination.js.map +1 -1
  164. package/dist/cards/impl/minion/tide-raiser.js +1 -1
  165. package/dist/cards/impl/minion/tide-raiser.js.map +1 -1
  166. package/dist/cards/impl/minion/timewarped-embalmer.js +1 -1
  167. package/dist/cards/impl/minion/timewarped-embalmer.js.map +1 -1
  168. package/dist/cards/impl/minion/timewarped-warghoul.js.map +1 -1
  169. package/dist/cards/impl/minion/tunnel-blaster.js.map +1 -1
  170. package/dist/cards/impl/minion/twilight-primordium.js.map +1 -1
  171. package/dist/cards/impl/minion/ultralisk.js.map +1 -1
  172. package/dist/cards/impl/minion/valiant-tiger.js.map +1 -1
  173. package/dist/cards/impl/minion/void-earl.js.map +1 -1
  174. package/dist/cards/impl/minion/vorkai-guardian.js.map +1 -1
  175. package/dist/cards/impl/minion/wandering-wight.js.map +1 -1
  176. package/dist/cards/impl/minion/whelp-smuggler.js.map +1 -1
  177. package/dist/cards/impl/minion/whirring-protector-enchantment.js.map +1 -1
  178. package/dist/cards/impl/minion/wildfire-elemental.js.map +1 -1
  179. package/dist/cards/impl/minion/wisp-in-the-shell.js.map +1 -1
  180. package/dist/cards/impl/minion/wrathscale-rogue.js.map +1 -1
  181. package/dist/cards/impl/minion/yorik-smite.js.map +1 -1
  182. package/dist/cards/impl/minion/yrel.js.map +1 -1
  183. package/dist/cards/impl/minion/yulon-fortune-granter.js.map +1 -1
  184. package/dist/cards/impl/quest-reward/righteous-charge.js.map +1 -1
  185. package/dist/cards/impl/trinket/all-purpose-kibble.js.map +1 -1
  186. package/dist/cards/impl/trinket/arm-of-the-empire.js.map +1 -1
  187. package/dist/cards/impl/trinket/bassgill-portrait.js.map +1 -1
  188. package/dist/cards/impl/trinket/battle-horn.js.map +1 -1
  189. package/dist/cards/impl/trinket/beetle-band.js.map +1 -1
  190. package/dist/cards/impl/trinket/bird-feeder.js.map +1 -1
  191. package/dist/cards/impl/trinket/crocheted-sungill.js.map +1 -1
  192. package/dist/cards/impl/trinket/deathtouch-apple.js +1 -1
  193. package/dist/cards/impl/trinket/deathtouch-apple.js.map +1 -1
  194. package/dist/cards/impl/trinket/eclectic-shrine.js.map +1 -1
  195. package/dist/cards/impl/trinket/eternal-portrait.d.ts +2 -0
  196. package/dist/cards/impl/trinket/eternal-portrait.js +2 -1
  197. package/dist/cards/impl/trinket/eternal-portrait.js.map +1 -1
  198. package/dist/cards/impl/trinket/faerie-dragon-scale.js.map +1 -1
  199. package/dist/cards/impl/trinket/fishy-sticker.js.map +1 -1
  200. package/dist/cards/impl/trinket/herald-sticker.js.map +1 -1
  201. package/dist/cards/impl/trinket/karazhan-chess-set.js.map +1 -1
  202. package/dist/cards/impl/trinket/rivendare-portrait.js.map +1 -1
  203. package/dist/cards/impl/trinket/soul-fermenter.js +1 -5
  204. package/dist/cards/impl/trinket/soul-fermenter.js.map +1 -1
  205. package/dist/cards/impl/trinket/sthara-sticker.js.map +1 -1
  206. package/dist/cards/impl/trinket/valorous-medaillion.js.map +1 -1
  207. package/dist/cards/impl/trinket/vashjir-anemone.js.map +1 -1
  208. package/dist/cards/impl/trinket/yulon-sticker.js.map +1 -1
  209. package/dist/debug-state.js.map +1 -1
  210. package/dist/input-clone.js +1 -1
  211. package/dist/input-clone.js.map +1 -1
  212. package/dist/input-sanitation.js +7 -6
  213. package/dist/input-sanitation.js.map +1 -1
  214. package/dist/keywords/venomous.js.map +1 -1
  215. package/dist/simulate-bgs-battle.js +4 -4
  216. package/dist/simulate-bgs-battle.js.map +1 -1
  217. package/dist/simulation/add-minion-to-board.js +4 -4
  218. package/dist/simulation/add-minion-to-board.js.map +1 -1
  219. package/dist/simulation/auras.js +2 -4
  220. package/dist/simulation/auras.js.map +1 -1
  221. package/dist/simulation/avenge.js +0 -4
  222. package/dist/simulation/avenge.js.map +1 -1
  223. package/dist/simulation/deathrattle-effects.js +10 -2
  224. package/dist/simulation/deathrattle-effects.js.map +1 -1
  225. package/dist/simulation/deathrattle-on-trigger.js.map +1 -1
  226. package/dist/simulation/discover.js.map +1 -1
  227. package/dist/simulation/frenzy.js.map +1 -1
  228. package/dist/simulation/quest.js.map +1 -1
  229. package/dist/simulation/reborn.js.map +1 -1
  230. package/dist/simulation/spectator/game-action.js +18 -17
  231. package/dist/simulation/spectator/game-action.js.map +1 -1
  232. package/dist/simulation/spectator/resolve-trinket-hero-power.d.ts +2 -0
  233. package/dist/simulation/spectator/resolve-trinket-hero-power.js +27 -0
  234. package/dist/simulation/spectator/resolve-trinket-hero-power.js.map +1 -0
  235. package/dist/simulation/spectator/spectator.js +1 -0
  236. package/dist/simulation/spectator/spectator.js.map +1 -1
  237. package/dist/simulation/start-of-combat/soc-trinket.js +1 -1
  238. package/dist/simulation/start-of-combat/soc-trinket.js.map +1 -1
  239. package/package.json +51 -51
  240. package/dist/cards/impl/minion/pilot-the-shredder.d.ts +0 -2
  241. package/dist/cards/impl/minion/pilot-the-shredder.js.map +0 -1
@@ -31,7 +31,7 @@ const cloneBoard = (board) => {
31
31
  questRewards: (_c = board.player.questRewards) === null || _c === void 0 ? void 0 : _c.map((reward) => reward),
32
32
  hand: (_d = board.player.hand) === null || _d === void 0 ? void 0 : _d.map((entity) => cloneEntity(entity)),
33
33
  secrets: (_e = board.player.secrets) === null || _e === void 0 ? void 0 : _e.map((secret) => ({ ...secret })).sort((a, b) => a.entityId - b.entityId),
34
- trinkets: (_f = board.player.trinkets) === null || _f === void 0 ? void 0 : _f.map((trinket) => ({ ...trinket, tags: { ...trinket.tags } })),
34
+ trinkets: (_f = board.player.trinkets) === null || _f === void 0 ? void 0 : _f.map((trinket) => ({ ...trinket })),
35
35
  globalInfo: { ...board.player.globalInfo },
36
36
  heroPowers: (_g = board.player.heroPowers) === null || _g === void 0 ? void 0 : _g.map((heroPower) => ({ ...heroPower })),
37
37
  },
@@ -1 +1 @@
1
- {"version":3,"file":"input-clone.js","sourceRoot":"","sources":["../src/input-clone.ts"],"names":[],"mappings":";;;AAWO,MAAM,WAAW,GAAG,CAAC,KAAoB,EAAiB,EAAE;IAClE,MAAM,MAAM,GAAkB;QAC7B,SAAS,EAAE;YACV,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW;YACxC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,SAAS;YACpC,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW;SACxC;QACD,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,WAAW,EAAE,IAAA,kBAAU,EAAC,KAAK,CAAC,WAAW,CAAC;QAC1C,aAAa,EAAE,IAAA,kBAAU,EAAC,KAAK,CAAC,aAAa,CAAC;QAC9C,mBAAmB,EAAE,IAAA,kBAAU,EAAC,KAAK,CAAC,mBAAmB,CAAC;QAC1D,qBAAqB,EAAE,IAAA,kBAAU,EAAC,KAAK,CAAC,qBAAqB,CAAC;QAC9D,OAAO,EAAE,IAAI;KACb,CAAC;IACF,OAAO,MAAM,CAAC;AACf,CAAC,CAAC;AAfW,QAAA,WAAW,eAetB;AAEK,MAAM,UAAU,GAAG,CAAC,KAAmB,EAAgB,EAA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CAAC,MAAM,CAAC,UAAU,0CAAE,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC;SAC3E;QACD,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;KACvD,CAAC;IACF,OAAO,MAAM,CAAC;AACf,CAAC,CAAC;AAnBW,QAAA,UAAU,cAmBrB;AAEF,MAAM,WAAW,GAAG,CAAC,MAAmB,EAAe,EAAE;;IACxD,MAAM,MAAM,GAAgB;QAC3B,GAAG,MAAM;QACT,YAAY,EAAE,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;QACpE,kBAAkB,EAAE,EAAE;QACtB,eAAe,EAAE,MAAA,MAAM,CAAC,eAAe,0CAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;QAC5D,sBAAsB,EAAE,EAAE;KAC1B,CAAC;IACF,OAAO,MAAM,CAAC;AACf,CAAC,CAAC","sourcesContent":["import { BgsBattleInfo } from './bgs-battle-info';\r\nimport { BgsBoardInfo } from './bgs-board-info';\r\nimport { BoardEntity } from './board-entity';\r\n\r\n// const cloneInput = (input: BgsBattleInfo): BgsBattleInfo => {\r\n// \treturn structuredClone(input);\r\n// };\r\n// const cloneInput2 = (input: string): BgsBattleInfo => {\r\n// \treturn JSON.parse(input);\r\n// };\r\n\r\nexport const cloneInput3 = (input: BgsBattleInfo): BgsBattleInfo => {\r\n\tconst result: BgsBattleInfo = {\r\n\t\tgameState: {\r\n\t\t\tcurrentTurn: input.gameState.currentTurn,\r\n\t\t\tanomalies: input.gameState.anomalies,\r\n\t\t\tvalidTribes: input.gameState.validTribes,\r\n\t\t},\r\n\t\theroHasDied: input.heroHasDied,\r\n\t\tplayerBoard: cloneBoard(input.playerBoard),\r\n\t\topponentBoard: cloneBoard(input.opponentBoard),\r\n\t\tplayerTeammateBoard: cloneBoard(input.playerTeammateBoard),\r\n\t\topponentTeammateBoard: cloneBoard(input.opponentTeammateBoard),\r\n\t\toptions: null,\r\n\t};\r\n\treturn result;\r\n};\r\n\r\nexport const cloneBoard = (board: BgsBoardInfo): BgsBoardInfo => {\r\n\tif (!board) {\r\n\t\treturn null;\r\n\t}\r\n\tconst result: BgsBoardInfo = {\r\n\t\tplayer: {\r\n\t\t\t...board.player,\r\n\t\t\tquestEntities: board.player.questEntities?.map((quest) => ({ ...quest })),\r\n\t\t\tquestRewardEntities: board.player.questRewardEntities?.map((reward) => ({ ...reward })),\r\n\t\t\tquestRewards: board.player.questRewards?.map((reward) => reward),\r\n\t\t\thand: board.player.hand?.map((entity) => cloneEntity(entity)),\r\n\t\t\tsecrets: board.player.secrets?.map((secret) => ({ ...secret })).sort((a, b) => a.entityId - b.entityId),\r\n\t\t\ttrinkets: board.player.trinkets?.map((trinket) => ({ ...trinket, tags: { ...trinket.tags } })),\r\n\t\t\tglobalInfo: { ...board.player.globalInfo },\r\n\t\t\theroPowers: board.player.heroPowers?.map((heroPower) => ({ ...heroPower })),\r\n\t\t},\r\n\t\tboard: board.board.map((entity) => cloneEntity(entity)),\r\n\t};\r\n\treturn result;\r\n};\r\n\r\nconst cloneEntity = (entity: BoardEntity): BoardEntity => {\r\n\tconst result: BoardEntity = {\r\n\t\t...entity,\r\n\t\tenchantments: entity.enchantments.map((enchant) => ({ ...enchant })),\r\n\t\tpendingAttackBuffs: [],\r\n\t\tadditionalCards: entity.additionalCards?.map((card) => card),\r\n\t\trememberedDeathrattles: [],\r\n\t};\r\n\treturn result;\r\n};\r\n"]}
1
+ {"version":3,"file":"input-clone.js","sourceRoot":"","sources":["../src/input-clone.ts"],"names":[],"mappings":";;;AAWO,MAAM,WAAW,GAAG,CAAC,KAAoB,EAAiB,EAAE;IAClE,MAAM,MAAM,GAAkB;QAC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,EAAE,EAAE;KAC1B,CAAC;IACF,OAAO,MAAM,CAAC;AACf,CAAC,CAAC","sourcesContent":["import { BgsBattleInfo } from './bgs-battle-info';\r\nimport { BgsBoardInfo } from './bgs-board-info';\r\nimport { BoardEntity } from './board-entity';\r\n\r\n// const cloneInput = (input: BgsBattleInfo): BgsBattleInfo => {\r\n// \treturn structuredClone(input);\r\n// };\r\n// const cloneInput2 = (input: string): BgsBattleInfo => {\r\n// \treturn JSON.parse(input);\r\n// };\r\n\r\nexport const cloneInput3 = (input: BgsBattleInfo): BgsBattleInfo => {\r\n\tconst result: BgsBattleInfo = {\r\n\t\tgameState: {\r\n\t\t\tcurrentTurn: input.gameState.currentTurn,\r\n\t\t\tanomalies: input.gameState.anomalies,\r\n\t\t\tvalidTribes: input.gameState.validTribes,\r\n\t\t},\r\n\t\theroHasDied: input.heroHasDied,\r\n\t\tplayerBoard: cloneBoard(input.playerBoard),\r\n\t\topponentBoard: cloneBoard(input.opponentBoard),\r\n\t\tplayerTeammateBoard: cloneBoard(input.playerTeammateBoard),\r\n\t\topponentTeammateBoard: cloneBoard(input.opponentTeammateBoard),\r\n\t\toptions: null,\r\n\t};\r\n\treturn result;\r\n};\r\n\r\nexport const cloneBoard = (board: BgsBoardInfo): BgsBoardInfo => {\r\n\tif (!board) {\r\n\t\treturn null;\r\n\t}\r\n\tconst result: BgsBoardInfo = {\r\n\t\tplayer: {\r\n\t\t\t...board.player,\r\n\t\t\tquestEntities: board.player.questEntities?.map((quest) => ({ ...quest })),\r\n\t\t\tquestRewardEntities: board.player.questRewardEntities?.map((reward) => ({ ...reward })),\r\n\t\t\tquestRewards: board.player.questRewards?.map((reward) => reward),\r\n\t\t\thand: board.player.hand?.map((entity) => cloneEntity(entity)),\r\n\t\t\tsecrets: board.player.secrets?.map((secret) => ({ ...secret })).sort((a, b) => a.entityId - b.entityId),\r\n\t\t\ttrinkets: board.player.trinkets?.map((trinket) => ({ ...trinket })),\r\n\t\t\tglobalInfo: { ...board.player.globalInfo },\r\n\t\t\theroPowers: board.player.heroPowers?.map((heroPower) => ({ ...heroPower })),\r\n\t\t},\r\n\t\tboard: board.board.map((entity) => cloneEntity(entity)),\r\n\t};\r\n\treturn result;\r\n};\r\n\r\nconst cloneEntity = (entity: BoardEntity): BoardEntity => {\r\n\tconst result: BoardEntity = {\r\n\t\t...entity,\r\n\t\tenchantments: entity.enchantments.map((enchant) => ({ ...enchant })),\r\n\t\tpendingAttackBuffs: [],\r\n\t\tadditionalCards: entity.additionalCards?.map((card) => card),\r\n\t\trememberedDeathrattles: [],\r\n\t};\r\n\treturn result;\r\n};\r\n"]}
@@ -53,19 +53,20 @@ const buildFinalInput = (battleInput, cards, cardsData) => {
53
53
  };
54
54
  exports.buildFinalInput = buildFinalInput;
55
55
  const buildFinalInputForPlayer = (playerInfo, isPlayer, anomalies, cards, cardsData, entityIdContainer) => {
56
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
56
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
57
57
  if (!playerInfo) {
58
58
  return { board: [], hand: [], player: null };
59
59
  }
60
60
  const { board, hand } = buildFinalInputBoard(playerInfo, isPlayer, cardsData, cards);
61
61
  const isGhost = ((_a = playerInfo.player) === null || _a === void 0 ? void 0 : _a.hpLeft) != null && playerInfo.player.hpLeft <= 0;
62
62
  playerInfo.player.secrets = (_d = (_c = ((_b = playerInfo.player.secrets) !== null && _b !== void 0 ? _b : playerInfo.secrets)) === null || _c === void 0 ? void 0 : _c.filter((e) => !!(e === null || e === void 0 ? void 0 : e.cardId))) !== null && _d !== void 0 ? _d : [];
63
- playerInfo.player.trinkets = ((_f = (_e = playerInfo.player.trinkets) === null || _e === void 0 ? void 0 : _e.filter((e) => !!(e === null || e === void 0 ? void 0 : e.cardId))) !== null && _f !== void 0 ? _f : []).sort((a, b) => a.entityId - b.entityId);
63
+ const fixedTrinkets = (_e = playerInfo.player.trinkets) === null || _e === void 0 ? void 0 : _e.filter((e) => !!(e === null || e === void 0 ? void 0 : e.cardId));
64
+ playerInfo.player.trinkets = (fixedTrinkets !== null && fixedTrinkets !== void 0 ? fixedTrinkets : []).sort((a, b) => a.entityId - b.entityId);
64
65
  playerInfo.player.friendly = isPlayer;
65
- playerInfo.player.globalInfo = (_g = playerInfo.player.globalInfo) !== null && _g !== void 0 ? _g : {};
66
- playerInfo.player.globalInfo.PirateAttackBonus = (_h = playerInfo.player.globalInfo.PirateAttackBonus) !== null && _h !== void 0 ? _h : 0;
67
- playerInfo.player.globalInfo.MechAttackBonus = (_j = playerInfo.player.globalInfo.MechAttackBonus) !== null && _j !== void 0 ? _j : 0;
68
- playerInfo.player.heroPowers = ((_k = playerInfo.player.heroPowers) === null || _k === void 0 ? void 0 : _k.length)
66
+ playerInfo.player.globalInfo = (_f = playerInfo.player.globalInfo) !== null && _f !== void 0 ? _f : {};
67
+ playerInfo.player.globalInfo.PirateAttackBonus = (_g = playerInfo.player.globalInfo.PirateAttackBonus) !== null && _g !== void 0 ? _g : 0;
68
+ playerInfo.player.globalInfo.MechAttackBonus = (_h = playerInfo.player.globalInfo.MechAttackBonus) !== null && _h !== void 0 ? _h : 0;
69
+ playerInfo.player.heroPowers = ((_j = playerInfo.player.heroPowers) === null || _j === void 0 ? void 0 : _j.length)
69
70
  ? playerInfo.player.heroPowers.map((hp, index) => sanitizeHeroPower(hp, index, playerInfo.player, cards))
70
71
  : [
71
72
  {
@@ -1 +1 @@
1
- {"version":3,"file":"input-sanitation.js","sourceRoot":"","sources":["../src/input-sanitation.ts"],"names":[],"mappings":";;;AAOA,8CAA0E;AAC1E,4DAA4D;AAC5D,mCAA8C;AAEvC,MAAM,eAAe,GAAG,CAC9B,WAA0B,EAC1B,KAAsB,EACtB,SAAoB,EACJ,EAAE;;IAClB,MAAM,iBAAiB,GAAG,EAAE,QAAQ,EAAE,SAAW,EAAE,CAAC;IAEpD,MAAM,EACL,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,YAAY,GACp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,MAAM,CAAC,cAAc;KACtF,CAAC,CAAC;SACF,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAA,2BAAmB,EAAC,MAAM,EAAE,SAAS,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAkB,CAAA,CAAC,CAAC;IACtG,MAAM,IAAI,GACT,MAAA,MAAA,UAAU,CAAC,MAAM,CAAC,IAAI,0CACnB,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,EACtD,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAA,8BAAe,EAAC,MAAM,EAAE,KAAK,CAAC,EAC9C,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAA,2BAAmB,EAAC,MAAM,EAAE,SAAS,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAkB,CAAA,CAAC,mCAAI,EAAE,CAAC;IAE7G,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACxB,CAAC,CAAC","sourcesContent":["import { AllCardsService } from '@firestone-hs/reference-data';\r\nimport { BgsBattleInfo } from './bgs-battle-info';\r\nimport { BgsBoardInfo } from './bgs-board-info';\r\nimport { BgsHeroPower, BgsPlayerEntity } from './bgs-player-entity';\r\nimport { BoardEntity } from './board-entity';\r\nimport { CardsData } from './cards/cards-data';\r\nimport { CardIds } from './services/card-ids';\r\nimport { setImplicitDataHero, setMissingAuras } from './simulation/auras';\r\nimport { fixEnchantments } from './simulation/enchantments';\r\nimport { addImpliedMechanics } from './utils';\r\n\r\nexport const buildFinalInput = (\r\n\tbattleInput: BgsBattleInfo,\r\n\tcards: AllCardsService,\r\n\tcardsData: CardsData,\r\n): BgsBattleInfo => {\r\n\tconst entityIdContainer = { entityId: 999_999_999 };\r\n\r\n\tconst {\r\n\t\tboard: playerBoard,\r\n\t\thand: playerHand,\r\n\t\tplayer: playerEntity,\r\n\t} = buildFinalInputForPlayer(\r\n\t\tbattleInput.playerBoard,\r\n\t\ttrue,\r\n\t\tbattleInput.gameState.anomalies,\r\n\t\tcards,\r\n\t\tcardsData,\r\n\t\tentityIdContainer,\r\n\t);\r\n\tconst {\r\n\t\tboard: playerTeammateBoard,\r\n\t\thand: playerTeammateHand,\r\n\t\tplayer: playerTeammateEntity,\r\n\t} = buildFinalInputForPlayer(\r\n\t\tbattleInput.playerTeammateBoard,\r\n\t\ttrue,\r\n\t\tbattleInput.gameState.anomalies,\r\n\t\tcards,\r\n\t\tcardsData,\r\n\t\tentityIdContainer,\r\n\t);\r\n\r\n\tconst {\r\n\t\tboard: opponentBoard,\r\n\t\thand: opponentHand,\r\n\t\tplayer: opponentEntity,\r\n\t} = buildFinalInputForPlayer(\r\n\t\tbattleInput.opponentBoard,\r\n\t\tfalse,\r\n\t\tbattleInput.gameState.anomalies,\r\n\t\tcards,\r\n\t\tcardsData,\r\n\t\tentityIdContainer,\r\n\t);\r\n\tconst {\r\n\t\tboard: opponentTeammateBoard,\r\n\t\thand: opponentTeammateHand,\r\n\t\tplayer: opponentTeammateEntity,\r\n\t} = buildFinalInputForPlayer(\r\n\t\tbattleInput.opponentTeammateBoard,\r\n\t\tfalse,\r\n\t\tbattleInput.gameState.anomalies,\r\n\t\tcards,\r\n\t\tcardsData,\r\n\t\tentityIdContainer,\r\n\t);\r\n\r\n\t// We do this so that we can have mutated objects inside the simulation and still\r\n\t// be able to start from a fresh copy for each simulation\r\n\tconst inputReady: BgsBattleInfo = {\r\n\t\tplayerBoard: {\r\n\t\t\tboard: playerBoard,\r\n\t\t\tplayer: {\r\n\t\t\t\t...playerEntity,\r\n\t\t\t\thand: playerHand,\r\n\t\t\t},\r\n\t\t},\r\n\t\tplayerTeammateBoard: !!playerTeammateEntity\r\n\t\t\t? {\r\n\t\t\t\t\tboard: playerTeammateBoard,\r\n\t\t\t\t\tplayer: {\r\n\t\t\t\t\t\t...playerTeammateEntity,\r\n\t\t\t\t\t\thand: playerTeammateHand,\r\n\t\t\t\t\t},\r\n\t\t\t }\r\n\t\t\t: null,\r\n\t\topponentBoard: {\r\n\t\t\tboard: opponentBoard,\r\n\t\t\tplayer: {\r\n\t\t\t\t...opponentEntity,\r\n\t\t\t\thand: opponentHand,\r\n\t\t\t},\r\n\t\t},\r\n\t\topponentTeammateBoard: !!opponentTeammateEntity\r\n\t\t\t? {\r\n\t\t\t\t\tboard: opponentTeammateBoard,\r\n\t\t\t\t\tplayer: {\r\n\t\t\t\t\t\t...opponentTeammateEntity,\r\n\t\t\t\t\t\thand: opponentTeammateHand,\r\n\t\t\t\t\t},\r\n\t\t\t }\r\n\t\t\t: null,\r\n\t\tgameState: {\r\n\t\t\t...battleInput.gameState,\r\n\t\t\tanomalies: battleInput.gameState.anomalies?.filter((a) => !!a) ?? ([] as readonly string[]),\r\n\t\t},\r\n\t} as BgsBattleInfo;\r\n\treturn inputReady;\r\n};\r\n\r\nconst buildFinalInputForPlayer = (\r\n\tplayerInfo: BgsBoardInfo,\r\n\tisPlayer: boolean,\r\n\tanomalies: readonly string[],\r\n\tcards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tentityIdContainer: { entityId: number },\r\n): { board: BoardEntity[]; hand: BoardEntity[]; player: BgsPlayerEntity } => {\r\n\tif (!playerInfo) {\r\n\t\treturn { board: [], hand: [], player: null };\r\n\t}\r\n\r\n\tconst { board, hand } = buildFinalInputBoard(playerInfo, isPlayer, cardsData, cards);\r\n\tconst isGhost = playerInfo.player?.hpLeft != null && playerInfo.player.hpLeft <= 0;\r\n\tplayerInfo.player.secrets = (playerInfo.player.secrets ?? playerInfo.secrets)?.filter((e) => !!e?.cardId) ?? [];\r\n\t// Add the scriptDataNum1 only on the start of combat phase, so that it doesn't trigger too soon\r\n\t// Don't do this, as secrets like Fleeting Vigor use this info to tell how much buff it will apply\r\n\t// playerInfo.player.secrets.forEach((secret) => (secret.scriptDataNum1 = 0));\r\n\t// Trinkets don't seem to trigger when facing the ghost\r\n\t// http://replays.firestoneapp.com/?reviewId=4ad32e03-2620-4fb1-8b43-cad55afd30fc&turn=27&action=2\r\n\t// One of the trinkets is Blood Golem Sticker, and no Blood Golem is summoned\r\n\t// Looks like that's not always the case:\r\n\t// http://replays.firestoneapp.com/?reviewId=9958e8d3-4388-4e6f-9b36-35f3a08be2f6&turn=25&action=4\r\n\t// playerInfo.player.trinkets = isGhost ? [] : playerInfo.player.trinkets?.filter((e) => !!e?.cardId) ?? [];\r\n\tplayerInfo.player.trinkets = (playerInfo.player.trinkets?.filter((e) => !!e?.cardId) ?? []).sort(\r\n\t\t(a, b) => a.entityId - b.entityId,\r\n\t);\r\n\tplayerInfo.player.friendly = isPlayer;\r\n\tplayerInfo.player.globalInfo = playerInfo.player.globalInfo ?? {};\r\n\tplayerInfo.player.globalInfo.PirateAttackBonus = playerInfo.player.globalInfo.PirateAttackBonus ?? 0;\r\n\tplayerInfo.player.globalInfo.MechAttackBonus = playerInfo.player.globalInfo.MechAttackBonus ?? 0;\r\n\tplayerInfo.player.heroPowers = playerInfo.player.heroPowers?.length\r\n\t\t? playerInfo.player.heroPowers.map((hp, index) => sanitizeHeroPower(hp, index, playerInfo.player, cards))\r\n\t\t: [\r\n\t\t\t\t{\r\n\t\t\t\t\tcardId: playerInfo.player.heroPowerId,\r\n\t\t\t\t\tentityId: playerInfo.player.heroPowerEntityId,\r\n\t\t\t\t\tused: playerInfo.player.heroPowerUsed,\r\n\t\t\t\t\tinfo: playerInfo.player.heroPowerInfo,\r\n\t\t\t\t\tinfo2: playerInfo.player.heroPowerInfo2,\r\n\t\t\t\t} as BgsHeroPower,\r\n\t\t ];\r\n\t// playerInfo.player.heroPowerId =\r\n\t// \tplayerInfo.player.trinkets.find((t) => t.scriptDataNum6 === 3)?.cardId ??\r\n\t// \t(normalizeHeroCardId(playerInfo.player.cardId, cards) === CardIds.SireDenathrius_BG24_HERO_100\r\n\t// \t\t? playerInfo.player.questRewardEntities?.[0]?.cardId\r\n\t// \t\t: null) ??\r\n\t// \tplayerInfo.player.heroPowerId;\r\n\tplayerInfo.player.cardId = isGhost ? CardIds.Kelthuzad_TB_BaconShop_HERO_KelThuzad : playerInfo.player.cardId;\r\n\tplayerInfo.player.hpLeft = Math.max(1, playerInfo.player.hpLeft);\r\n\t// When using the simulator, the aura is not applied when receiving the board state.\r\n\tsetMissingAuras(board, playerInfo.player, anomalies, cards);\r\n\t// Avenge, maxHealth, etc.\r\n\t// setImplicitData(playerBoard, cardsData);\r\n\t// setImplicitData(opponentBoard, cardsData);\r\n\t// Avenge, globalInfo\r\n\tsetImplicitDataHero(playerInfo.player, cardsData, isPlayer, entityIdContainer);\r\n\treturn { board, hand, player: playerInfo.player };\r\n};\r\n\r\nconst sanitizeHeroPower = (\r\n\thp: BgsHeroPower,\r\n\tindex: number,\r\n\tplayer: BgsPlayerEntity,\r\n\tcards: AllCardsService,\r\n): BgsHeroPower => {\r\n\treturn hp;\r\n\t// FIXME: fix this when the situation presents itself. At the moment, we already have trinkets / hero powers / quest rewards\r\n\t// handled separately, so maybe there is no need to map a quest reward to one of Sire D.'s hero power\r\n\t// if (index !== 0) {\r\n\t// \treturn hp;\r\n\t// }\r\n\r\n\t// hp.cardId =\r\n\t// \tplayer.trinkets.find((t) => t.scriptDataNum6 === 3)?.cardId ??\r\n\t// \t(normalizeHeroCardId(player.cardId, cards) === CardIds.SireDenathrius_BG24_HERO_100\r\n\t// \t\t? player.questRewardEntities?.[0]?.cardId\r\n\t// \t\t: null) ??\r\n\t// \thp.cardId;\r\n\t// return hp;\r\n};\r\n\r\nconst buildFinalInputBoard = (\r\n\tplayerInfo: BgsBoardInfo,\r\n\tisPlayer: boolean,\r\n\tcardsData: CardsData,\r\n\tcards: AllCardsService,\r\n): { board: BoardEntity[]; hand: BoardEntity[] } => {\r\n\tconst board = playerInfo.board\r\n\t\t.map((entity) => fixEnchantments(entity, cards))\r\n\t\t.map((entity) => ({\r\n\t\t\t...entity,\r\n\t\t\tinInitialState: true,\r\n\t\t\tscriptDataNum1: cardsData.defaultScriptDataNum(entity.cardId) || entity.scriptDataNum1,\r\n\t\t}))\r\n\t\t.map((entity) => ({ ...addImpliedMechanics(entity, cardsData), friendly: isPlayer } as BoardEntity));\r\n\tconst hand =\r\n\t\tplayerInfo.player.hand\r\n\t\t\t?.map((entity) => ({ ...entity, inInitialState: true }))\r\n\t\t\t.map((entity) => fixEnchantments(entity, cards))\r\n\t\t\t.map((entity) => ({ ...addImpliedMechanics(entity, cardsData), friendly: isPlayer } as BoardEntity)) ?? [];\r\n\r\n\treturn { board, hand };\r\n};\r\n"]}
1
+ {"version":3,"file":"input-sanitation.js","sourceRoot":"","sources":["../src/input-sanitation.ts"],"names":[],"mappings":";;;AAOA,8CAA0E;AAC1E,4DAA4D;AAC5D,mCAA8C;AAEvC,MAAM,eAAe,GAAG,CAC9B,WAA0B,EAC1B,KAAsB,EACtB,SAAoB,EACJ,EAAE;;IAClB,MAAM,iBAAiB,GAAG,EAAE,QAAQ,EAAE,SAAW,EAAE,CAAC;IAEpD,MAAM,EACL,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,YAAY,GACpB,GAAG,wBAAwB,CAC3B,WAAW,CAAC,WAAW,EACvB,IAAI,EACJ,WAAW,CAAC,SAAS,CAAC,SAAS,EAC/B,KAAK,EACL,SAAS,EACT,iBAAiB,CACjB,CAAC;IACF,MAAM,EACL,KAAK,EAAE,mBAAmB,EAC1B,IAAI,EAAE,kBAAkB,EACxB,MAAM,EAAE,oBAAoB,GAC5B,GAAG,wBAAwB,CAC3B,WAAW,CAAC,mBAAmB,EAC/B,IAAI,EACJ,WAAW,CAAC,SAAS,CAAC,SAAS,EAC/B,KAAK,EACL,SAAS,EACT,iBAAiB,CACjB,CAAC;IAEF,MAAM,EACL,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,cAAc,GACtB,GAAG,wBAAwB,CAC3B,W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EAAC,MAAM,EAAE,KAAK,CAAC,EAC9C,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAA,2BAAmB,EAAC,MAAM,EAAE,SAAS,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAkB,CAAA,CAAC,mCAAI,EAAE,CAAC;IAE7G,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACxB,CAAC,CAAC","sourcesContent":["import { AllCardsService } from '@firestone-hs/reference-data';\r\nimport { BgsBattleInfo } from './bgs-battle-info';\r\nimport { BgsBoardInfo } from './bgs-board-info';\r\nimport { BgsHeroPower, BgsPlayerEntity } from './bgs-player-entity';\r\nimport { BoardEntity } from './board-entity';\r\nimport { CardsData } from './cards/cards-data';\r\nimport { CardIds } from './services/card-ids';\r\nimport { setImplicitDataHero, setMissingAuras } from './simulation/auras';\r\nimport { fixEnchantments } from './simulation/enchantments';\r\nimport { addImpliedMechanics } from './utils';\r\n\r\nexport const buildFinalInput = (\r\n\tbattleInput: BgsBattleInfo,\r\n\tcards: AllCardsService,\r\n\tcardsData: CardsData,\r\n): BgsBattleInfo => {\r\n\tconst entityIdContainer = { entityId: 999_999_999 };\r\n\r\n\tconst {\r\n\t\tboard: playerBoard,\r\n\t\thand: playerHand,\r\n\t\tplayer: playerEntity,\r\n\t} = buildFinalInputForPlayer(\r\n\t\tbattleInput.playerBoard,\r\n\t\ttrue,\r\n\t\tbattleInput.gameState.anomalies,\r\n\t\tcards,\r\n\t\tcardsData,\r\n\t\tentityIdContainer,\r\n\t);\r\n\tconst {\r\n\t\tboard: playerTeammateBoard,\r\n\t\thand: playerTeammateHand,\r\n\t\tplayer: playerTeammateEntity,\r\n\t} = buildFinalInputForPlayer(\r\n\t\tbattleInput.playerTeammateBoard,\r\n\t\ttrue,\r\n\t\tbattleInput.gameState.anomalies,\r\n\t\tcards,\r\n\t\tcardsData,\r\n\t\tentityIdContainer,\r\n\t);\r\n\r\n\tconst {\r\n\t\tboard: opponentBoard,\r\n\t\thand: opponentHand,\r\n\t\tplayer: opponentEntity,\r\n\t} = buildFinalInputForPlayer(\r\n\t\tbattleInput.opponentBoard,\r\n\t\tfalse,\r\n\t\tbattleInput.gameState.anomalies,\r\n\t\tcards,\r\n\t\tcardsData,\r\n\t\tentityIdContainer,\r\n\t);\r\n\tconst {\r\n\t\tboard: opponentTeammateBoard,\r\n\t\thand: opponentTeammateHand,\r\n\t\tplayer: opponentTeammateEntity,\r\n\t} = buildFinalInputForPlayer(\r\n\t\tbattleInput.opponentTeammateBoard,\r\n\t\tfalse,\r\n\t\tbattleInput.gameState.anomalies,\r\n\t\tcards,\r\n\t\tcardsData,\r\n\t\tentityIdContainer,\r\n\t);\r\n\r\n\t// We do this so that we can have mutated objects inside the simulation and still\r\n\t// be able to start from a fresh copy for each simulation\r\n\tconst inputReady: BgsBattleInfo = {\r\n\t\tplayerBoard: {\r\n\t\t\tboard: playerBoard,\r\n\t\t\tplayer: {\r\n\t\t\t\t...playerEntity,\r\n\t\t\t\thand: playerHand,\r\n\t\t\t},\r\n\t\t},\r\n\t\tplayerTeammateBoard: !!playerTeammateEntity\r\n\t\t\t? {\r\n\t\t\t\t\tboard: playerTeammateBoard,\r\n\t\t\t\t\tplayer: {\r\n\t\t\t\t\t\t...playerTeammateEntity,\r\n\t\t\t\t\t\thand: playerTeammateHand,\r\n\t\t\t\t\t},\r\n\t\t\t }\r\n\t\t\t: null,\r\n\t\topponentBoard: {\r\n\t\t\tboard: opponentBoard,\r\n\t\t\tplayer: {\r\n\t\t\t\t...opponentEntity,\r\n\t\t\t\thand: opponentHand,\r\n\t\t\t},\r\n\t\t},\r\n\t\topponentTeammateBoard: !!opponentTeammateEntity\r\n\t\t\t? {\r\n\t\t\t\t\tboard: opponentTeammateBoard,\r\n\t\t\t\t\tplayer: {\r\n\t\t\t\t\t\t...opponentTeammateEntity,\r\n\t\t\t\t\t\thand: opponentTeammateHand,\r\n\t\t\t\t\t},\r\n\t\t\t }\r\n\t\t\t: null,\r\n\t\tgameState: {\r\n\t\t\t...battleInput.gameState,\r\n\t\t\tanomalies: battleInput.gameState.anomalies?.filter((a) => !!a) ?? ([] as readonly string[]),\r\n\t\t},\r\n\t} as BgsBattleInfo;\r\n\treturn inputReady;\r\n};\r\n\r\nconst buildFinalInputForPlayer = (\r\n\tplayerInfo: BgsBoardInfo,\r\n\tisPlayer: boolean,\r\n\tanomalies: readonly string[],\r\n\tcards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tentityIdContainer: { entityId: number },\r\n): { board: BoardEntity[]; hand: BoardEntity[]; player: BgsPlayerEntity } => {\r\n\tif (!playerInfo) {\r\n\t\treturn { board: [], hand: [], player: null };\r\n\t}\r\n\r\n\tconst { board, hand } = buildFinalInputBoard(playerInfo, isPlayer, cardsData, cards);\r\n\tconst isGhost = playerInfo.player?.hpLeft != null && playerInfo.player.hpLeft <= 0;\r\n\tplayerInfo.player.secrets = (playerInfo.player.secrets ?? playerInfo.secrets)?.filter((e) => !!e?.cardId) ?? [];\r\n\t// Add the scriptDataNum1 only on the start of combat phase, so that it doesn't trigger too soon\r\n\t// Don't do this, as secrets like Fleeting Vigor use this info to tell how much buff it will apply\r\n\t// playerInfo.player.secrets.forEach((secret) => (secret.scriptDataNum1 = 0));\r\n\t// Trinkets don't seem to trigger when facing the ghost\r\n\t// http://replays.firestoneapp.com/?reviewId=4ad32e03-2620-4fb1-8b43-cad55afd30fc&turn=27&action=2\r\n\t// One of the trinkets is Blood Golem Sticker, and no Blood Golem is summoned\r\n\t// Looks like that's not always the case:\r\n\t// http://replays.firestoneapp.com/?reviewId=9958e8d3-4388-4e6f-9b36-35f3a08be2f6&turn=25&action=4\r\n\t// playerInfo.player.trinkets = isGhost ? [] : playerInfo.player.trinkets?.filter((e) => !!e?.cardId) ?? [];\r\n\tconst fixedTrinkets = playerInfo.player.trinkets?.filter((e) => !!e?.cardId);\r\n\tplayerInfo.player.trinkets = (fixedTrinkets ?? []).sort((a, b) => a.entityId - b.entityId);\r\n\tplayerInfo.player.friendly = isPlayer;\r\n\tplayerInfo.player.globalInfo = playerInfo.player.globalInfo ?? {};\r\n\tplayerInfo.player.globalInfo.PirateAttackBonus = playerInfo.player.globalInfo.PirateAttackBonus ?? 0;\r\n\tplayerInfo.player.globalInfo.MechAttackBonus = playerInfo.player.globalInfo.MechAttackBonus ?? 0;\r\n\tplayerInfo.player.heroPowers = playerInfo.player.heroPowers?.length\r\n\t\t? playerInfo.player.heroPowers.map((hp, index) => sanitizeHeroPower(hp, index, playerInfo.player, cards))\r\n\t\t: [\r\n\t\t\t\t{\r\n\t\t\t\t\tcardId: playerInfo.player.heroPowerId,\r\n\t\t\t\t\tentityId: playerInfo.player.heroPowerEntityId,\r\n\t\t\t\t\tused: playerInfo.player.heroPowerUsed,\r\n\t\t\t\t\tinfo: playerInfo.player.heroPowerInfo,\r\n\t\t\t\t\tinfo2: playerInfo.player.heroPowerInfo2,\r\n\t\t\t\t} as BgsHeroPower,\r\n\t\t ];\r\n\t// playerInfo.player.heroPowerId =\r\n\t// \tplayerInfo.player.trinkets.find((t) => t.scriptDataNum6 === 3)?.cardId ??\r\n\t// \t(normalizeHeroCardId(playerInfo.player.cardId, cards) === CardIds.SireDenathrius_BG24_HERO_100\r\n\t// \t\t? playerInfo.player.questRewardEntities?.[0]?.cardId\r\n\t// \t\t: null) ??\r\n\t// \tplayerInfo.player.heroPowerId;\r\n\tplayerInfo.player.cardId = isGhost ? CardIds.Kelthuzad_TB_BaconShop_HERO_KelThuzad : playerInfo.player.cardId;\r\n\tplayerInfo.player.hpLeft = Math.max(1, playerInfo.player.hpLeft);\r\n\t// When using the simulator, the aura is not applied when receiving the board state.\r\n\tsetMissingAuras(board, playerInfo.player, anomalies, cards);\r\n\t// Avenge, maxHealth, etc.\r\n\t// setImplicitData(playerBoard, cardsData);\r\n\t// setImplicitData(opponentBoard, cardsData);\r\n\t// Avenge, globalInfo\r\n\tsetImplicitDataHero(playerInfo.player, cardsData, isPlayer, entityIdContainer);\r\n\treturn { board, hand, player: playerInfo.player };\r\n};\r\n\r\nconst sanitizeHeroPower = (\r\n\thp: BgsHeroPower,\r\n\tindex: number,\r\n\tplayer: BgsPlayerEntity,\r\n\tcards: AllCardsService,\r\n): BgsHeroPower => {\r\n\treturn hp;\r\n\t// FIXME: fix this when the situation presents itself. At the moment, we already have trinkets / hero powers / quest rewards\r\n\t// handled separately, so maybe there is no need to map a quest reward to one of Sire D.'s hero power\r\n\t// if (index !== 0) {\r\n\t// \treturn hp;\r\n\t// }\r\n\r\n\t// hp.cardId =\r\n\t// \tplayer.trinkets.find((t) => t.scriptDataNum6 === 3)?.cardId ??\r\n\t// \t(normalizeHeroCardId(player.cardId, cards) === CardIds.SireDenathrius_BG24_HERO_100\r\n\t// \t\t? player.questRewardEntities?.[0]?.cardId\r\n\t// \t\t: null) ??\r\n\t// \thp.cardId;\r\n\t// return hp;\r\n};\r\n\r\nconst buildFinalInputBoard = (\r\n\tplayerInfo: BgsBoardInfo,\r\n\tisPlayer: boolean,\r\n\tcardsData: CardsData,\r\n\tcards: AllCardsService,\r\n): { board: BoardEntity[]; hand: BoardEntity[] } => {\r\n\tconst board = playerInfo.board\r\n\t\t.map((entity) => fixEnchantments(entity, cards))\r\n\t\t.map((entity) => ({\r\n\t\t\t...entity,\r\n\t\t\tinInitialState: true,\r\n\t\t\tscriptDataNum1: cardsData.defaultScriptDataNum(entity.cardId) || entity.scriptDataNum1,\r\n\t\t}))\r\n\t\t.map((entity) => ({ ...addImpliedMechanics(entity, cardsData), friendly: isPlayer } as BoardEntity));\r\n\tconst hand =\r\n\t\tplayerInfo.player.hand\r\n\t\t\t?.map((entity) => ({ ...entity, inInitialState: true }))\r\n\t\t\t.map((entity) => fixEnchantments(entity, cards))\r\n\t\t\t.map((entity) => ({ ...addImpliedMechanics(entity, cardsData), friendly: isPlayer } as BoardEntity)) ?? [];\r\n\r\n\treturn { board, hand };\r\n};\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"venomous.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KAAK,EAAE,KAAK;gBACZ,IAAI,EAAE,IAAI;gBACV,SAAS,EAAE,SAAS;gBACpB,SAAS,EAAE,SAAS;aACpB,CAAC,CAAC;SACH;KACD;AACF,CAAC,CAAC;AAnCW,QAAA,cAAc,kBAmCzB","sourcesContent":["import { CardIds } from '../services/card-ids';\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { hasOnVenomousUpdated } from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { FullGameState } from '../simulation/internal-game-state';\r\nimport { modifyStats } from '../simulation/stats';\r\n\r\nexport const updateVenomous = (\r\n\tentity: BoardEntity,\r\n\tnewValue: boolean,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst previousValue = entity.venomous;\r\n\tconst lostVenomous = entity.venomous && !newValue;\r\n\tentity.venomous = newValue;\r\n\tif (lostVenomous) {\r\n\t\tconst belcherPortraits = hero.trinkets.filter(\r\n\t\t\t(t) =>\r\n\t\t\t\tt.cardId === CardIds.BelcherPortrait_BG30_MagicItem_432 ||\r\n\t\t\t\tt.cardId === CardIds.BelcherPortrait_BelcherPortraitToken_BG30_MagicItem_432t,\r\n\t\t);\r\n\t\tbelcherPortraits.forEach((p) => {\r\n\t\t\tconst buff = p.cardId === CardIds.BelcherPortrait_BelcherPortraitToken_BG30_MagicItem_432t ? 14 : 4;\r\n\t\t\tmodifyStats(entity, p, buff, buff, board, hero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(p, entity, board, null, null);\r\n\t\t});\r\n\t}\r\n\r\n\tfor (const boardEntity of board) {\r\n\t\tconst onVenomousUpdatedImpl = cardMappings[boardEntity.cardId];\r\n\t\tif (hasOnVenomousUpdated(onVenomousUpdatedImpl)) {\r\n\t\t\tonVenomousUpdatedImpl.onVenomousUpdated(boardEntity, entity, previousValue, {\r\n\t\t\t\tboard: board,\r\n\t\t\t\thero: hero,\r\n\t\t\t\totherHero: otherHero,\r\n\t\t\t\tgameState: gameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport interface OnVenomousUpdatedInput {\r\n\tboard: BoardEntity[];\r\n\thero: BgsPlayerEntity;\r\n\totherHero: BgsPlayerEntity;\r\n\tgameState: FullGameState;\r\n}\r\n"]}
1
+ {"version":3,"file":"venomous.js","sourceRoot":"","sources":["../../src/keywords/venomous.ts"],"names":[],"mappings":";;;AAGA,4DAA+D;AAC/D,iEAA4D;AAE5D,+CAAkD;AAE3C,MAAM,cAAc,GAAG,CAC7B,MAAmB,EACnB,QAAiB,EACjB,KAAoB,EACpB,IAAqB,EACrB,SAA0B,EAC1B,SAAwB,EACjB,EAAE;IACT,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,CAAC;IACtC,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC;IAClD,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,IAAI,YAAY,EAAE;QACjB,MAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAC5C,CAAC,CAAC,EAAE,EAAE,CACL,CAAC,CAAC,MAAM,yBAA+C;YACvD,CAAC,CAAC,MAAM,0BAAqE,CAC9E,CAAC;QACF,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YAC9B,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,0BAAqE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YACpG,IAAA,mBAAW,EAAC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;YAC3D,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;KACH;IAED,KAAK,MAAM,WAAW,IAAI,KAAK,EAAE;QAChC,MAAM,qBAAqB,GAAG,6BAAY,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAC/D,IAAI,IAAA,qCAAoB,EAAC,qBAAqB,CAAC,EAAE;YAChD,qBAAqB,CAAC,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE;gBAC3E,KAAK,EAAE,KAAK;gBACZ,IAAI,EAAE,IAAI;gBACV,SAAS,EAAE,SAAS;gBACpB,SAAS,EAAE,SAAS;aACpB,CAAC,CAAC;SACH;KACD;AACF,CAAC,CAAC;AAnCW,QAAA,cAAc,kBAmCzB","sourcesContent":["import { CardIds } from '../services/card-ids';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { hasOnVenomousUpdated } from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { FullGameState } from '../simulation/internal-game-state';\r\nimport { modifyStats } from '../simulation/stats';\r\n\r\nexport const updateVenomous = (\r\n\tentity: BoardEntity,\r\n\tnewValue: boolean,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst previousValue = entity.venomous;\r\n\tconst lostVenomous = entity.venomous && !newValue;\r\n\tentity.venomous = newValue;\r\n\tif (lostVenomous) {\r\n\t\tconst belcherPortraits = hero.trinkets.filter(\r\n\t\t\t(t) =>\r\n\t\t\t\tt.cardId === CardIds.BelcherPortrait_BG30_MagicItem_432 ||\r\n\t\t\t\tt.cardId === CardIds.BelcherPortrait_BelcherPortraitToken_BG30_MagicItem_432t,\r\n\t\t);\r\n\t\tbelcherPortraits.forEach((p) => {\r\n\t\t\tconst buff = p.cardId === CardIds.BelcherPortrait_BelcherPortraitToken_BG30_MagicItem_432t ? 14 : 4;\r\n\t\t\tmodifyStats(entity, p, buff, buff, board, hero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(p, entity, board, null, null);\r\n\t\t});\r\n\t}\r\n\r\n\tfor (const boardEntity of board) {\r\n\t\tconst onVenomousUpdatedImpl = cardMappings[boardEntity.cardId];\r\n\t\tif (hasOnVenomousUpdated(onVenomousUpdatedImpl)) {\r\n\t\t\tonVenomousUpdatedImpl.onVenomousUpdated(boardEntity, entity, previousValue, {\r\n\t\t\t\tboard: board,\r\n\t\t\t\thero: hero,\r\n\t\t\t\totherHero: otherHero,\r\n\t\t\t\tgameState: gameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport interface OnVenomousUpdatedInput {\r\n\tboard: BoardEntity[];\r\n\thero: BgsPlayerEntity;\r\n\totherHero: BgsPlayerEntity;\r\n\tgameState: FullGameState;\r\n}\r\n"]}
@@ -128,6 +128,10 @@ const simulateBattle = function* (battleInput, cards, cardsData) {
128
128
  };
129
129
  const simulator = new simulator_1.Simulator(gameState);
130
130
  const battleResult = simulator.simulateSingleBattle(gameState.gameState.player, gameState.gameState.opponent);
131
+ if (Date.now() - start > maxAcceptableDuration && !hideMaxSimulationDurationWarning) {
132
+ console.warn('Stopping simulation after', i, 'iterations and ', Date.now() - start, 'ms');
133
+ break;
134
+ }
131
135
  if (!battleResult) {
132
136
  continue;
133
137
  }
@@ -153,10 +157,6 @@ const simulateBattle = function* (battleInput, cards, cardsData) {
153
157
  simulationResult.tied++;
154
158
  }
155
159
  spectator.commitBattleResult(battleResult.result);
156
- if (Date.now() - start > maxAcceptableDuration && !hideMaxSimulationDurationWarning) {
157
- console.warn('Stopping simulation after', i, 'iterations and ', Date.now() - start, 'ms');
158
- break;
159
- }
160
160
  if (!!intermediateSteps && i > 0 && i % intermediateSteps === 0) {
161
161
  updateSimulationResult(simulationResult, inputReady, damageConfidence);
162
162
  yield simulationResult;
@@ -1 +1 @@
1
- {"version":3,"file":"simulate-bgs-battle.js","sourceRoot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U,EAAE;QACxD,OAAO,IAAI,CAAC;KACZ;IACD,OAAO,YAAY,CAAC;AACrB,CAAC,CAAC;AAGF,MAAM,8BAA8B,GAAG;;;;;;;;;;;;;;;;;;;;;;CA0BtC,CAAC;AACF,MAAM,uCAAuC,GAAG,EAAE,CAAC;AAC5C,MAAM,6BAA6B,GAAG,CAAC,MAAc,EAAW,EAAE;IACxE,IAAI,8BAA8B,CAAC,QAAQ,CAAC,MAAiB,CAAC,EAAE;QAC/D,OAAO,IAAI,CAAC;KACZ;IACD,IAAI,uCAAuC,CAAC,MAAM,KAAK,CAAC,EAAE;QACzD,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,6BAAY,CAAC,EAAE;YAEnD,IAAI,IAAA,+CAA8B,EAAC,QAAQ,CAAC,EAAE;gBAC7C,uCAAuC,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;aAClE;SACD;KACD;IACD,OAAO,uCAAuC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACjE,CAAC,CAAC;AAbW,QAAA,6BAA6B,iCAaxC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport { AllCardsService } from '@firestone-hs/reference-data';\nimport { BgsBattleInfo } from './bgs-battle-info';\nimport { hasDeathrattleSpawnEnchantment } from './cards/card.interface';\nimport { CardsData } from './cards/cards-data';\nimport { cardMappings } from './cards/impl/_card-mappings';\nimport { debugState } from './debug-state';\nimport { cloneInput3 } from './input-clone';\nimport { buildFinalInput } from './input-sanitation';\nimport { CardIds } from './services/card-ids';\nimport { SimulationResult } from './simulation-result';\nimport { FullGameState } from './simulation/internal-game-state';\nimport { SharedState } from './simulation/shared-state';\nimport { Simulator } from './simulation/simulator';\nimport { Spectator } from './simulation/spectator/spectator';\n\nlet globalCards = new AllCardsService();\n\nexport const assignCards = (cards: AllCardsService) => {\n\tglobalCards = cards;\n};\n\n// This example demonstrates a NodeJS 8.10 async handler[1], however of course you could use\n// the more traditional callback-style handler.\n// [1]: https://aws.amazon.com/blogs/compute/node-js-8-10-runtime-now-available-in-aws-lambda/\nexport default async (event): Promise<any> => {\n\tif (!event.body?.length) {\n\t\tconsole.warn('missing event body', event);\n\t\treturn;\n\t}\n\n\tconst battleInput: BgsBattleInfo = JSON.parse(event.body);\n\tconst cards = globalCards;\n\tawait cards.initializeCardsDb();\n\tconst cardsData = new CardsData(cards, false);\n\tcardsData.inititialize(\n\t\tbattleInput.gameState?.validTribes ?? battleInput.options?.validTribes,\n\t\tbattleInput.gameState?.anomalies ?? [],\n\t);\n\tconst battleIterator = simulateBattle(battleInput, cards, cardsData);\n\n\t// Iterate through all intermediate results to reach the final result\n\tlet result = battleIterator.next();\n\twhile (!result.done) {\n\t\tresult = battleIterator.next();\n\t}\n\n\tconst simulationResult = result.value;\n\t// console.debug('simulationResult', simulationResult);\n\n\tconst response = {\n\t\tstatusCode: 200,\n\t\tisBase64Encoded: false,\n\t\tbody: JSON.stringify(simulationResult),\n\t};\n\treturn response;\n};\n\nexport const simulateBattle = function* (\n\tbattleInput: BgsBattleInfo,\n\tcards: AllCardsService,\n\tcardsData: CardsData,\n): Generator<SimulationResult, SimulationResult, void> {\n\tif (!cards?.getCards()?.length) {\n\t\tconsole.error('[simulate-bgs-battle] reference cards are empty, cannot simulate battle', cards);\n\t\treturn null;\n\t}\n\t// !battleInput.options?.skipInfoLogs && console.time('full-sim');\n\tconst start = Date.now();\n\tconst maxAcceptableDuration = battleInput.options?.maxAcceptableDuration || 8000;\n\tconst hideMaxSimulationDurationWarning = battleInput.options?.hideMaxSimulationDurationWarning ?? false;\n\tconst numberOfSimulations = battleInput.options?.numberOfSimulations || 8000;\n\tconst intermediateSteps = battleInput.options?.intermediateResults ?? 200;\n\tconst damageConfidence = battleInput.options?.damageConfidence ?? 0.9;\n\tconst includeOutcomeSamples = battleInput.options?.includeOutcomeSamples ?? true;\n\tconst simulationResult: SimulationResult = {\n\t\twonLethal: 0,\n\t\twon: 0,\n\t\ttied: 0,\n\t\tlost: 0,\n\t\tlostLethal: 0,\n\t\tdamageWons: [],\n\t\tdamageWon: 0,\n\t\tdamageWonRange: null,\n\t\tdamageLosts: [],\n\t\tdamageLost: 0,\n\t\tdamageLostRange: null,\n\t\twonLethalPercent: undefined,\n\t\twonPercent: undefined,\n\t\ttiedPercent: undefined,\n\t\tlostPercent: undefined,\n\t\tlostLethalPercent: undefined,\n\t\taverageDamageWon: undefined,\n\t\taverageDamageLost: undefined,\n\t};\n\n\tconst spectator = new Spectator(includeOutcomeSamples);\n\tconst inputReady = buildFinalInput(battleInput, cards, cardsData);\n\n\t// Apply debug state from input when present (e.g. from bug report)\n\tif (battleInput.debugState) {\n\t\tdebugState.active = true;\n\t\tdebugState.forcedCurrentAttacker = battleInput.debugState.forcedCurrentAttacker;\n\t\tdebugState.forcedFaceOffBase = battleInput.debugState.forcedFaceOffBase.map((f) => ({\n\t\t\tattacker: { ...f.attacker },\n\t\t\tdefender: { ...f.defender },\n\t\t}));\n\t\tconst rawPicks = battleInput.debugState.forcedRandomPicks ?? [];\n\t\tdebugState.forcedRandomPicksBase = rawPicks.map((p) => ({\n\t\t\tsource: { ...p.source },\n\t\t\ttarget: { ...p.target },\n\t\t\t...(p.chosenCardId && { chosenCardId: p.chosenCardId }),\n\t\t}));\n\t}\n\n\ttry {\n\t\t!battleInput.options?.skipInfoLogs && console.time('simulation');\n\t\tconst outcomes = {};\n\t\tfor (let i = 0; i < numberOfSimulations; i++) {\n\t\t\tconst input: BgsBattleInfo = cloneInput3(inputReady);\n\t\t\tconst inputClone: BgsBattleInfo = cloneInput3(inputReady);\n\t\t\tconst gameState: FullGameState = {\n\t\t\t\tallCards: cards,\n\t\t\t\tcardsData: cardsData,\n\t\t\t\tspectator: spectator,\n\t\t\t\tsharedState: new SharedState(),\n\t\t\t\tcurrentTurn: input.gameState.currentTurn,\n\t\t\t\tvalidTribes: input.gameState.validTribes,\n\t\t\t\tanomalies: input.gameState.anomalies,\n\t\t\t\tgameState: {\n\t\t\t\t\tplayer: {\n\t\t\t\t\t\tplayer: input.playerBoard.player,\n\t\t\t\t\t\tboard: input.playerBoard.board,\n\t\t\t\t\t\tteammate: input.playerTeammateBoard,\n\t\t\t\t\t},\n\t\t\t\t\topponent: {\n\t\t\t\t\t\tplayer: input.opponentBoard.player,\n\t\t\t\t\t\tboard: input.opponentBoard.board,\n\t\t\t\t\t\tteammate: input.opponentTeammateBoard,\n\t\t\t\t\t},\n\t\t\t\t\tplayerInitial: {\n\t\t\t\t\t\tplayer: inputClone.playerBoard.player,\n\t\t\t\t\t\tboard: inputClone.playerBoard.board,\n\t\t\t\t\t\tteammate: inputClone.playerTeammateBoard,\n\t\t\t\t\t},\n\t\t\t\t\topponentInitial: {\n\t\t\t\t\t\tplayer: inputClone.opponentBoard.player,\n\t\t\t\t\t\tboard: inputClone.opponentBoard.board,\n\t\t\t\t\t\tteammate: inputClone.opponentTeammateBoard,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t\tconst simulator = new Simulator(gameState);\n\t\t\tconst battleResult = simulator.simulateSingleBattle(\n\t\t\t\tgameState.gameState.player,\n\t\t\t\tgameState.gameState.opponent,\n\t\t\t);\n\t\t\tif (!battleResult) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (battleResult.result === 'won') {\n\t\t\t\tsimulationResult.won++;\n\t\t\t\tsimulationResult.damageWon += battleResult.damageDealt;\n\t\t\t\tsimulationResult.damageWons.push(battleResult.damageDealt);\n\t\t\t\tif (battleResult.damageDealt >= battleInput.opponentBoard.player.hpLeft) {\n\t\t\t\t\tsimulationResult.wonLethal++;\n\t\t\t\t}\n\t\t\t} else if (battleResult.result === 'lost') {\n\t\t\t\tsimulationResult.lost++;\n\t\t\t\tsimulationResult.damageLost += battleResult.damageDealt;\n\t\t\t\tsimulationResult.damageLosts.push(battleResult.damageDealt);\n\t\t\t\toutcomes[battleResult.damageDealt] = (outcomes[battleResult.damageDealt] ?? 0) + 1;\n\t\t\t\tif (\n\t\t\t\t\tbattleInput.playerBoard.player.hpLeft &&\n\t\t\t\t\tbattleResult.damageDealt >= battleInput.playerBoard.player.hpLeft\n\t\t\t\t) {\n\t\t\t\t\tsimulationResult.lostLethal++;\n\t\t\t\t}\n\t\t\t} else if (battleResult.result === 'tied') {\n\t\t\t\tsimulationResult.tied++;\n\t\t\t}\n\t\t\tspectator.commitBattleResult(battleResult.result);\n\n\t\t\tif (Date.now() - start > maxAcceptableDuration && !hideMaxSimulationDurationWarning) {\n\t\t\t\t// Can happen in case of inifinite boards, or a bug. Don't hog the user's computer in that case\n\t\t\t\tconsole.warn('Stopping simulation after', i, 'iterations and ', Date.now() - start, 'ms');\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Yield intermediate result every 200 iterations\n\t\t\tif (!!intermediateSteps && i > 0 && i % intermediateSteps === 0) {\n\t\t\t\tupdateSimulationResult(simulationResult, inputReady, damageConfidence);\n\t\t\t\tyield simulationResult;\n\t\t\t}\n\t\t}\n\t\tupdateSimulationResult(simulationResult, inputReady, damageConfidence);\n\t\t!battleInput.options?.skipInfoLogs && console.timeEnd('simulation');\n\t\tspectator.prune();\n\t\tsimulationResult.outcomeSamples = spectator.buildOutcomeSamples(battleInput.gameState);\n\t\t// Avoid sending this verbose data\n\n\t\tsimulationResult.damageWons = [];\n\t\tsimulationResult.damageLosts = [];\n\t\t// !battleInput.options?.skipInfoLogs && console.timeEnd('full-sim');\n\t\treturn simulationResult;\n\t} finally {\n\t\tif (battleInput.debugState) {\n\t\t\tdebugState.active = false;\n\t\t}\n\t}\n};\n\nconst updateSimulationResult = (simulationResult: SimulationResult, input: BgsBattleInfo, damageConfidence: number) => {\n\tconst totalMatches = simulationResult.won + simulationResult.tied + simulationResult.lost;\n\tsimulationResult.wonPercent = checkRounding(\n\t\tMath.round((10 * (100 * simulationResult.won)) / totalMatches) / 10,\n\t\tsimulationResult.won,\n\t\ttotalMatches,\n\t);\n\tsimulationResult.wonLethalPercent = checkRounding(\n\t\tMath.round((10 * (100 * simulationResult.wonLethal)) / totalMatches) / 10,\n\t\tsimulationResult.wonLethal,\n\t\ttotalMatches,\n\t);\n\tsimulationResult.lostPercent = checkRounding(\n\t\tMath.round((10 * (100 * simulationResult.lost)) / totalMatches) / 10,\n\t\tsimulationResult.lost,\n\t\ttotalMatches,\n\t);\n\tsimulationResult.lostLethalPercent = checkRounding(\n\t\tMath.round((10 * (100 * simulationResult.lostLethal)) / totalMatches) / 10,\n\t\tsimulationResult.lostLethal,\n\t\ttotalMatches,\n\t);\n\tsimulationResult.tiedPercent = checkRounding(\n\t\tMath.max(0, 100 - simulationResult.lostPercent - simulationResult.wonPercent),\n\t\tsimulationResult.tied,\n\t\ttotalMatches,\n\t);\n\n\t// simulationResult.wonLethalPercent = Math.round((10 * (100 * simulationResult.wonLethal)) / totalMatches) / 10;\n\t// simulationResult.lostLethalPercent = Math.round((10 * (100 * simulationResult.lostLethal)) / totalMatches) / 10;\n\tconst totalDamageWon = simulationResult.damageWons.reduce((a, b) => a + b, 0);\n\tconst totalDamageLost = simulationResult.damageLosts.reduce((a, b) => a + b, 0);\n\tconst damageWonRange = calculateDamageRange(simulationResult.damageWons, damageConfidence);\n\tconst damageLostRange = calculateDamageRange(simulationResult.damageLosts, damageConfidence);\n\tsimulationResult.averageDamageWon = simulationResult.won ? totalDamageWon / simulationResult.won : 0;\n\tsimulationResult.averageDamageLost = simulationResult.lost ? totalDamageLost / simulationResult.lost : 0;\n\tsimulationResult.damageWonRange = simulationResult.won ? damageWonRange : null;\n\tsimulationResult.damageLostRange = simulationResult.lost ? damageLostRange : null;\n\n\tif (\n\t\tsimulationResult.averageDamageWon > 0 &&\n\t\tsimulationResult.averageDamageWon < input.playerBoard.player.tavernTier\n\t) {\n\t\tconsole.warn('average damage won issue');\n\t}\n\tif (\n\t\tsimulationResult.averageDamageLost > 0 &&\n\t\tsimulationResult.averageDamageLost < input.opponentBoard.player.tavernTier\n\t) {\n\t\tconsole.warn('average damage lost issue');\n\t}\n};\n\nconst calculateDamageRange = (damageArray: number[], damageConfidence: number): { min: number; max: number } => {\n\tif (damageArray.length === 0) {\n\t\treturn { min: 0, max: 0 };\n\t}\n\n\t// Sort the array\n\tconst sortedDamage = [...damageArray].sort((a, b) => a - b);\n\n\t// Calculate the 10th and 90th percentiles\n\tconst percentile = (arr: number[], p: number) => {\n\t\tconst index = Math.floor(p * arr.length);\n\t\treturn arr[index];\n\t};\n\n\tconst minDamage = percentile(sortedDamage, 1 - damageConfidence);\n\tconst maxDamage = percentile(sortedDamage, damageConfidence);\n\n\treturn { min: minDamage, max: maxDamage };\n};\n\nconst checkRounding = (roundedValue: number, initialValue: number, totalValue: number): number => {\n\tif (roundedValue === 0 && initialValue !== 0) {\n\t\treturn 0.01;\n\t}\n\tif (roundedValue === 100 && initialValue !== totalValue) {\n\t\treturn 99.9;\n\t}\n\treturn roundedValue;\n};\n\n// Used when triggering random deathrattles\nconst VALID_DEATHRATTLE_ENCHANTMENTS = [\n\tCardIds.ReplicatingMenace_ReplicatingMenaceEnchantment_BG_BOT_312e,\n\tCardIds.ReplicatingMenace_ReplicatingMenaceEnchantment_TB_BaconUps_032e,\n\tCardIds.LivingSpores_LivingSporesEnchantment,\n\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e,\n\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge,\n\tCardIds.Sneed_SneedsReplicator,\n\tCardIds.SneedsReplicator_ReplicateEnchantment,\n\tCardIds.EarthRecollectionEnchantment, // Spirit Raptor\n\tCardIds.FireRecollectionEnchantment,\n\tCardIds.LightningRecollectionEnchantment,\n\tCardIds.WaterRecollectionEnchantment,\n\tCardIds.EarthInvocation_ElementEarthEnchantment, // Summon a 1/1\n\tCardIds.LightningInvocation, // Deal 1 damage to 5 enemy minions\n\t// CardIds.SurfNSurf_CrabRidingEnchantment_BG27_004e,\n\t// CardIds.SurfNSurf_CrabRidingEnchantment_BG27_004_Ge,\n\t// CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055e,\n\t// CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055_Ge,\n\tCardIds.BoonOfBeetles_BeetleSwarmEnchantment_BG28_603e,\n\tCardIds.RustyTrident_TridentsTreasureEnchantment_BG30_MagicItem_917e,\n\tCardIds.HoggyBank_GemInTheBankEnchantment_BG30_MagicItem_411e,\n\tCardIds.JarredFrostling_FrostyGlobeEnchantment_BG30_MagicItem_952e,\n\tCardIds.CaduceusReactor_CaduceusReactorEnchantment_BG31_HERO_801ptee,\n\tCardIds.AutoAssembler_AutoAssemblerEnchantment_BG32_172e,\n\tCardIds.AutoAssembler_AutoAssemblerEnchantment_BG32_172_Ge,\n\tCardIds.TamsinRoame_ImpendingSacrificeEnchantment_BG20_HERO_282e2,\n];\nconst validDeathrattleEnchantmentsFromMapping = [];\nexport const isValidDeathrattleEnchantment = (cardId: string): boolean => {\n\tif (VALID_DEATHRATTLE_ENCHANTMENTS.includes(cardId as CardIds)) {\n\t\treturn true;\n\t}\n\tif (validDeathrattleEnchantmentsFromMapping.length === 0) {\n\t\tfor (const cardImpl of Object.values(cardMappings)) {\n\t\t\t// Also includes non-enchantments, but since we only match this against the enchants list, it's fine\n\t\t\tif (hasDeathrattleSpawnEnchantment(cardImpl)) {\n\t\t\t\tvalidDeathrattleEnchantmentsFromMapping.push(...cardImpl.cardIds);\n\t\t\t}\n\t\t}\n\t}\n\treturn validDeathrattleEnchantmentsFromMapping.includes(cardId);\n};\n\n// const cleanEnchantmentsForEntity = (\n// \tenchantments: { cardId: string; originEntityId?: number; timing: number }[],\n// \tentityIds: readonly number[],\n// ): { cardId: string; originEntityId?: number; timing: number }[] => {\n// \treturn enchantments.filter(\n// \t\t(enchant) =>\n// \t\t\tentityIds.indexOf(enchant.originEntityId) !== -1 ||\n// \t\t\tvalidEnchantments.indexOf(enchant.cardId as CardIds) !== -1,\n// \t);\n// };\n"]}
1
+ {"version":3,"file":"simulate-bgs-battle.js","sourceRoot":"","sources":["../src/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D,OAAO,IAAI,CAAC;KACZ;IACD,OAAO,YAAY,CAAC;AACrB,CAAC,CAAC;AAGF,MAAM,8BAA8B,GAAG;;;;;;;;;;;;;;;;;;;;;;CA0BtC,CAAC;AACF,MAAM,uCAAuC,GAAG,EAAE,CAAC;AAC5C,MAAM,6BAA6B,GAAG,CAAC,MAAc,EAAW,EAAE;IACxE,IAAI,8BAA8B,CAAC,QAAQ,CAAC,MAAiB,CAAC,EAAE;QAC/D,OAAO,IAAI,CAAC;KACZ;IACD,IAAI,uCAAuC,CAAC,MAAM,KAAK,CAAC,EAAE;QACzD,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,6BAAY,CAAC,EAAE;YAEnD,IAAI,IAAA,+CAA8B,EAAC,QAAQ,CAAC,EAAE;gBAC7C,uCAAuC,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;aAClE;SACD;KACD;IACD,OAAO,uCAAuC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACjE,CAAC,CAAC;AAbW,QAAA,6BAA6B,iCAaxC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService } from '@firestone-hs/reference-data';\r\nimport { BgsBattleInfo } from './bgs-battle-info';\r\nimport { hasDeathrattleSpawnEnchantment } from './cards/card.interface';\r\nimport { CardsData } from './cards/cards-data';\r\nimport { cardMappings } from './cards/impl/_card-mappings';\r\nimport { debugState } from './debug-state';\r\nimport { cloneInput3 } from './input-clone';\r\nimport { buildFinalInput } from './input-sanitation';\r\nimport { CardIds } from './services/card-ids';\r\nimport { SimulationResult } from './simulation-result';\r\nimport { FullGameState } from './simulation/internal-game-state';\r\nimport { SharedState } from './simulation/shared-state';\r\nimport { Simulator } from './simulation/simulator';\r\nimport { Spectator } from './simulation/spectator/spectator';\r\n\r\nlet globalCards = new AllCardsService();\r\n\r\nexport const assignCards = (cards: AllCardsService) => {\r\n\tglobalCards = cards;\r\n};\r\n\r\n// This example demonstrates a NodeJS 8.10 async handler[1], however of course you could use\r\n// the more traditional callback-style handler.\r\n// [1]: https://aws.amazon.com/blogs/compute/node-js-8-10-runtime-now-available-in-aws-lambda/\r\nexport default async (event): Promise<any> => {\r\n\tif (!event.body?.length) {\r\n\t\tconsole.warn('missing event body', event);\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst battleInput: BgsBattleInfo = JSON.parse(event.body);\r\n\tconst cards = globalCards;\r\n\tawait cards.initializeCardsDb();\r\n\tconst cardsData = new CardsData(cards, false);\r\n\tcardsData.inititialize(\r\n\t\tbattleInput.gameState?.validTribes ?? battleInput.options?.validTribes,\r\n\t\tbattleInput.gameState?.anomalies ?? [],\r\n\t);\r\n\tconst battleIterator = simulateBattle(battleInput, cards, cardsData);\r\n\r\n\t// Iterate through all intermediate results to reach the final result\r\n\tlet result = battleIterator.next();\r\n\twhile (!result.done) {\r\n\t\tresult = battleIterator.next();\r\n\t}\r\n\r\n\tconst simulationResult = result.value;\r\n\t// console.debug('simulationResult', simulationResult);\r\n\r\n\tconst response = {\r\n\t\tstatusCode: 200,\r\n\t\tisBase64Encoded: false,\r\n\t\tbody: JSON.stringify(simulationResult),\r\n\t};\r\n\treturn response;\r\n};\r\n\r\nexport const simulateBattle = function* (\r\n\tbattleInput: BgsBattleInfo,\r\n\tcards: AllCardsService,\r\n\tcardsData: CardsData,\r\n): Generator<SimulationResult, SimulationResult, void> {\r\n\tif (!cards?.getCards()?.length) {\r\n\t\tconsole.error('[simulate-bgs-battle] reference cards are empty, cannot simulate battle', cards);\r\n\t\treturn null;\r\n\t}\r\n\t// !battleInput.options?.skipInfoLogs && console.time('full-sim');\r\n\tconst start = Date.now();\r\n\tconst maxAcceptableDuration = battleInput.options?.maxAcceptableDuration || 8000;\r\n\tconst hideMaxSimulationDurationWarning = battleInput.options?.hideMaxSimulationDurationWarning ?? false;\r\n\tconst numberOfSimulations = battleInput.options?.numberOfSimulations || 8000;\r\n\tconst intermediateSteps = battleInput.options?.intermediateResults ?? 200;\r\n\tconst damageConfidence = battleInput.options?.damageConfidence ?? 0.9;\r\n\tconst includeOutcomeSamples = battleInput.options?.includeOutcomeSamples ?? true;\r\n\tconst simulationResult: SimulationResult = {\r\n\t\twonLethal: 0,\r\n\t\twon: 0,\r\n\t\ttied: 0,\r\n\t\tlost: 0,\r\n\t\tlostLethal: 0,\r\n\t\tdamageWons: [],\r\n\t\tdamageWon: 0,\r\n\t\tdamageWonRange: null,\r\n\t\tdamageLosts: [],\r\n\t\tdamageLost: 0,\r\n\t\tdamageLostRange: null,\r\n\t\twonLethalPercent: undefined,\r\n\t\twonPercent: undefined,\r\n\t\ttiedPercent: undefined,\r\n\t\tlostPercent: undefined,\r\n\t\tlostLethalPercent: undefined,\r\n\t\taverageDamageWon: undefined,\r\n\t\taverageDamageLost: undefined,\r\n\t};\r\n\r\n\tconst spectator = new Spectator(includeOutcomeSamples);\r\n\tconst inputReady = buildFinalInput(battleInput, cards, cardsData);\r\n\r\n\t// Apply debug state from input when present (e.g. from bug report)\r\n\tif (battleInput.debugState) {\r\n\t\tdebugState.active = true;\r\n\t\tdebugState.forcedCurrentAttacker = battleInput.debugState.forcedCurrentAttacker;\r\n\t\tdebugState.forcedFaceOffBase = battleInput.debugState.forcedFaceOffBase.map((f) => ({\r\n\t\t\tattacker: { ...f.attacker },\r\n\t\t\tdefender: { ...f.defender },\r\n\t\t}));\r\n\t\tconst rawPicks = battleInput.debugState.forcedRandomPicks ?? [];\r\n\t\tdebugState.forcedRandomPicksBase = rawPicks.map((p) => ({\r\n\t\t\tsource: { ...p.source },\r\n\t\t\ttarget: { ...p.target },\r\n\t\t\t...(p.chosenCardId && { chosenCardId: p.chosenCardId }),\r\n\t\t}));\r\n\t}\r\n\r\n\ttry {\r\n\t\t!battleInput.options?.skipInfoLogs && console.time('simulation');\r\n\t\tconst outcomes = {};\r\n\t\tfor (let i = 0; i < numberOfSimulations; i++) {\r\n\t\t\tconst input: BgsBattleInfo = cloneInput3(inputReady);\r\n\t\t\tconst inputClone: BgsBattleInfo = cloneInput3(inputReady);\r\n\t\t\tconst gameState: FullGameState = {\r\n\t\t\t\tallCards: cards,\r\n\t\t\t\tcardsData: cardsData,\r\n\t\t\t\tspectator: spectator,\r\n\t\t\t\tsharedState: new SharedState(),\r\n\t\t\t\tcurrentTurn: input.gameState.currentTurn,\r\n\t\t\t\tvalidTribes: input.gameState.validTribes,\r\n\t\t\t\tanomalies: input.gameState.anomalies,\r\n\t\t\t\tgameState: {\r\n\t\t\t\t\tplayer: {\r\n\t\t\t\t\t\tplayer: input.playerBoard.player,\r\n\t\t\t\t\t\tboard: input.playerBoard.board,\r\n\t\t\t\t\t\tteammate: input.playerTeammateBoard,\r\n\t\t\t\t\t},\r\n\t\t\t\t\topponent: {\r\n\t\t\t\t\t\tplayer: input.opponentBoard.player,\r\n\t\t\t\t\t\tboard: input.opponentBoard.board,\r\n\t\t\t\t\t\tteammate: input.opponentTeammateBoard,\r\n\t\t\t\t\t},\r\n\t\t\t\t\tplayerInitial: {\r\n\t\t\t\t\t\tplayer: inputClone.playerBoard.player,\r\n\t\t\t\t\t\tboard: inputClone.playerBoard.board,\r\n\t\t\t\t\t\tteammate: inputClone.playerTeammateBoard,\r\n\t\t\t\t\t},\r\n\t\t\t\t\topponentInitial: {\r\n\t\t\t\t\t\tplayer: inputClone.opponentBoard.player,\r\n\t\t\t\t\t\tboard: inputClone.opponentBoard.board,\r\n\t\t\t\t\t\tteammate: inputClone.opponentTeammateBoard,\r\n\t\t\t\t\t},\r\n\t\t\t\t},\r\n\t\t\t};\r\n\t\t\tconst simulator = new Simulator(gameState);\r\n\t\t\tconst battleResult = simulator.simulateSingleBattle(\r\n\t\t\t\tgameState.gameState.player,\r\n\t\t\t\tgameState.gameState.opponent,\r\n\t\t\t);\r\n\t\t\tif (Date.now() - start > maxAcceptableDuration && !hideMaxSimulationDurationWarning) {\r\n\t\t\t\t// Can happen in case of inifinite boards, or a bug. Don't hog the user's computer in that case\r\n\t\t\t\tconsole.warn('Stopping simulation after', i, 'iterations and ', Date.now() - start, 'ms');\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tif (!battleResult) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tif (battleResult.result === 'won') {\r\n\t\t\t\tsimulationResult.won++;\r\n\t\t\t\tsimulationResult.damageWon += battleResult.damageDealt;\r\n\t\t\t\tsimulationResult.damageWons.push(battleResult.damageDealt);\r\n\t\t\t\tif (battleResult.damageDealt >= battleInput.opponentBoard.player.hpLeft) {\r\n\t\t\t\t\tsimulationResult.wonLethal++;\r\n\t\t\t\t}\r\n\t\t\t} else if (battleResult.result === 'lost') {\r\n\t\t\t\tsimulationResult.lost++;\r\n\t\t\t\tsimulationResult.damageLost += battleResult.damageDealt;\r\n\t\t\t\tsimulationResult.damageLosts.push(battleResult.damageDealt);\r\n\t\t\t\toutcomes[battleResult.damageDealt] = (outcomes[battleResult.damageDealt] ?? 0) + 1;\r\n\t\t\t\tif (\r\n\t\t\t\t\tbattleInput.playerBoard.player.hpLeft &&\r\n\t\t\t\t\tbattleResult.damageDealt >= battleInput.playerBoard.player.hpLeft\r\n\t\t\t\t) {\r\n\t\t\t\t\tsimulationResult.lostLethal++;\r\n\t\t\t\t}\r\n\t\t\t} else if (battleResult.result === 'tied') {\r\n\t\t\t\tsimulationResult.tied++;\r\n\t\t\t}\r\n\t\t\tspectator.commitBattleResult(battleResult.result);\r\n\r\n\t\t\t// Yield intermediate result every 200 iterations\r\n\t\t\tif (!!intermediateSteps && i > 0 && i % intermediateSteps === 0) {\r\n\t\t\t\tupdateSimulationResult(simulationResult, inputReady, damageConfidence);\r\n\t\t\t\tyield simulationResult;\r\n\t\t\t}\r\n\t\t}\r\n\t\tupdateSimulationResult(simulationResult, inputReady, damageConfidence);\r\n\t\t!battleInput.options?.skipInfoLogs && console.timeEnd('simulation');\r\n\t\tspectator.prune();\r\n\t\tsimulationResult.outcomeSamples = spectator.buildOutcomeSamples(battleInput.gameState);\r\n\t\t// Avoid sending this verbose data\r\n\r\n\t\tsimulationResult.damageWons = [];\r\n\t\tsimulationResult.damageLosts = [];\r\n\t\t// !battleInput.options?.skipInfoLogs && console.timeEnd('full-sim');\r\n\t\treturn simulationResult;\r\n\t} finally {\r\n\t\tif (battleInput.debugState) {\r\n\t\t\tdebugState.active = false;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst updateSimulationResult = (simulationResult: SimulationResult, input: BgsBattleInfo, damageConfidence: number) => {\r\n\tconst totalMatches = simulationResult.won + simulationResult.tied + simulationResult.lost;\r\n\tsimulationResult.wonPercent = checkRounding(\r\n\t\tMath.round((10 * (100 * simulationResult.won)) / totalMatches) / 10,\r\n\t\tsimulationResult.won,\r\n\t\ttotalMatches,\r\n\t);\r\n\tsimulationResult.wonLethalPercent = checkRounding(\r\n\t\tMath.round((10 * (100 * simulationResult.wonLethal)) / totalMatches) / 10,\r\n\t\tsimulationResult.wonLethal,\r\n\t\ttotalMatches,\r\n\t);\r\n\tsimulationResult.lostPercent = checkRounding(\r\n\t\tMath.round((10 * (100 * simulationResult.lost)) / totalMatches) / 10,\r\n\t\tsimulationResult.lost,\r\n\t\ttotalMatches,\r\n\t);\r\n\tsimulationResult.lostLethalPercent = checkRounding(\r\n\t\tMath.round((10 * (100 * simulationResult.lostLethal)) / totalMatches) / 10,\r\n\t\tsimulationResult.lostLethal,\r\n\t\ttotalMatches,\r\n\t);\r\n\tsimulationResult.tiedPercent = checkRounding(\r\n\t\tMath.max(0, 100 - simulationResult.lostPercent - simulationResult.wonPercent),\r\n\t\tsimulationResult.tied,\r\n\t\ttotalMatches,\r\n\t);\r\n\r\n\t// simulationResult.wonLethalPercent = Math.round((10 * (100 * simulationResult.wonLethal)) / totalMatches) / 10;\r\n\t// simulationResult.lostLethalPercent = Math.round((10 * (100 * simulationResult.lostLethal)) / totalMatches) / 10;\r\n\tconst totalDamageWon = simulationResult.damageWons.reduce((a, b) => a + b, 0);\r\n\tconst totalDamageLost = simulationResult.damageLosts.reduce((a, b) => a + b, 0);\r\n\tconst damageWonRange = calculateDamageRange(simulationResult.damageWons, damageConfidence);\r\n\tconst damageLostRange = calculateDamageRange(simulationResult.damageLosts, damageConfidence);\r\n\tsimulationResult.averageDamageWon = simulationResult.won ? totalDamageWon / simulationResult.won : 0;\r\n\tsimulationResult.averageDamageLost = simulationResult.lost ? totalDamageLost / simulationResult.lost : 0;\r\n\tsimulationResult.damageWonRange = simulationResult.won ? damageWonRange : null;\r\n\tsimulationResult.damageLostRange = simulationResult.lost ? damageLostRange : null;\r\n\r\n\tif (\r\n\t\tsimulationResult.averageDamageWon > 0 &&\r\n\t\tsimulationResult.averageDamageWon < input.playerBoard.player.tavernTier\r\n\t) {\r\n\t\tconsole.warn('average damage won issue');\r\n\t}\r\n\tif (\r\n\t\tsimulationResult.averageDamageLost > 0 &&\r\n\t\tsimulationResult.averageDamageLost < input.opponentBoard.player.tavernTier\r\n\t) {\r\n\t\tconsole.warn('average damage lost issue');\r\n\t}\r\n};\r\n\r\nconst calculateDamageRange = (damageArray: number[], damageConfidence: number): { min: number; max: number } => {\r\n\tif (damageArray.length === 0) {\r\n\t\treturn { min: 0, max: 0 };\r\n\t}\r\n\r\n\t// Sort the array\r\n\tconst sortedDamage = [...damageArray].sort((a, b) => a - b);\r\n\r\n\t// Calculate the 10th and 90th percentiles\r\n\tconst percentile = (arr: number[], p: number) => {\r\n\t\tconst index = Math.floor(p * arr.length);\r\n\t\treturn arr[index];\r\n\t};\r\n\r\n\tconst minDamage = percentile(sortedDamage, 1 - damageConfidence);\r\n\tconst maxDamage = percentile(sortedDamage, damageConfidence);\r\n\r\n\treturn { min: minDamage, max: maxDamage };\r\n};\r\n\r\nconst checkRounding = (roundedValue: number, initialValue: number, totalValue: number): number => {\r\n\tif (roundedValue === 0 && initialValue !== 0) {\r\n\t\treturn 0.01;\r\n\t}\r\n\tif (roundedValue === 100 && initialValue !== totalValue) {\r\n\t\treturn 99.9;\r\n\t}\r\n\treturn roundedValue;\r\n};\r\n\r\n// Used when triggering random deathrattles\r\nconst VALID_DEATHRATTLE_ENCHANTMENTS = [\r\n\tCardIds.ReplicatingMenace_ReplicatingMenaceEnchantment_BG_BOT_312e,\r\n\tCardIds.ReplicatingMenace_ReplicatingMenaceEnchantment_TB_BaconUps_032e,\r\n\tCardIds.LivingSpores_LivingSporesEnchantment,\r\n\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e,\r\n\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge,\r\n\tCardIds.Sneed_SneedsReplicator,\r\n\tCardIds.SneedsReplicator_ReplicateEnchantment,\r\n\tCardIds.EarthRecollectionEnchantment, // Spirit Raptor\r\n\tCardIds.FireRecollectionEnchantment,\r\n\tCardIds.LightningRecollectionEnchantment,\r\n\tCardIds.WaterRecollectionEnchantment,\r\n\tCardIds.EarthInvocation_ElementEarthEnchantment, // Summon a 1/1\r\n\tCardIds.LightningInvocation, // Deal 1 damage to 5 enemy minions\r\n\t// CardIds.SurfNSurf_CrabRidingEnchantment_BG27_004e,\r\n\t// CardIds.SurfNSurf_CrabRidingEnchantment_BG27_004_Ge,\r\n\t// CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055e,\r\n\t// CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055_Ge,\r\n\tCardIds.BoonOfBeetles_BeetleSwarmEnchantment_BG28_603e,\r\n\tCardIds.RustyTrident_TridentsTreasureEnchantment_BG30_MagicItem_917e,\r\n\tCardIds.HoggyBank_GemInTheBankEnchantment_BG30_MagicItem_411e,\r\n\tCardIds.JarredFrostling_FrostyGlobeEnchantment_BG30_MagicItem_952e,\r\n\tCardIds.CaduceusReactor_CaduceusReactorEnchantment_BG31_HERO_801ptee,\r\n\tCardIds.AutoAssembler_AutoAssemblerEnchantment_BG32_172e,\r\n\tCardIds.AutoAssembler_AutoAssemblerEnchantment_BG32_172_Ge,\r\n\tCardIds.TamsinRoame_ImpendingSacrificeEnchantment_BG20_HERO_282e2,\r\n];\r\nconst validDeathrattleEnchantmentsFromMapping = [];\r\nexport const isValidDeathrattleEnchantment = (cardId: string): boolean => {\r\n\tif (VALID_DEATHRATTLE_ENCHANTMENTS.includes(cardId as CardIds)) {\r\n\t\treturn true;\r\n\t}\r\n\tif (validDeathrattleEnchantmentsFromMapping.length === 0) {\r\n\t\tfor (const cardImpl of Object.values(cardMappings)) {\r\n\t\t\t// Also includes non-enchantments, but since we only match this against the enchants list, it's fine\r\n\t\t\tif (hasDeathrattleSpawnEnchantment(cardImpl)) {\r\n\t\t\t\tvalidDeathrattleEnchantmentsFromMapping.push(...cardImpl.cardIds);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn validDeathrattleEnchantmentsFromMapping.includes(cardId);\r\n};\r\n\r\n// const cleanEnchantmentsForEntity = (\r\n// \tenchantments: { cardId: string; originEntityId?: number; timing: number }[],\r\n// \tentityIds: readonly number[],\r\n// ): { cardId: string; originEntityId?: number; timing: number }[] => {\r\n// \treturn enchantments.filter(\r\n// \t\t(enchant) =>\r\n// \t\t\tentityIds.indexOf(enchant.originEntityId) !== -1 ||\r\n// \t\t\tvalidEnchantments.indexOf(enchant.cardId as CardIds) !== -1,\r\n// \t);\r\n// };\r\n"]}
@@ -592,12 +592,12 @@ const removeAurasFromSelf = (entity, board, boardHero, gameState, applyAttackAur
592
592
  const multiplierKnight = entity.cardId === "BG25_008_G" ? 2 : 1;
593
593
  const statsBonusKnight = multiplierKnight * boardHero.globalInfo.EternalKnightsDeadThisGame;
594
594
  if (applyAttackAuras) {
595
- entity.attack = Math.max(0, entity.attack - eternal_portrait_1.eternalKnightAttack * statsBonusKnight);
596
- entity.maxAttack = Math.max(0, entity.maxAttack - eternal_portrait_1.eternalKnightAttack * statsBonusKnight);
595
+ entity.attack = Math.max(eternal_portrait_1.eternalKnightAttack * multiplierKnight, entity.attack - eternal_portrait_1.eternalKnightAttack * statsBonusKnight);
596
+ entity.maxAttack = Math.max(eternal_portrait_1.eternalKnightAttack * multiplierKnight, entity.maxAttack - eternal_portrait_1.eternalKnightAttack * statsBonusKnight);
597
597
  }
598
598
  if (applyHealthAuras) {
599
- entity.health = Math.max(1, entity.health - eternal_portrait_1.eternalKnightHealth * statsBonusKnight);
600
- entity.maxHealth = Math.max(1, entity.maxHealth - eternal_portrait_1.eternalKnightHealth * statsBonusKnight);
599
+ entity.health = Math.max(eternal_portrait_1.eternalKnightHealth * multiplierKnight, entity.health - eternal_portrait_1.eternalKnightHealth * statsBonusKnight);
600
+ entity.maxHealth = Math.max(eternal_portrait_1.eternalKnightHealth * multiplierKnight, entity.maxHealth - eternal_portrait_1.eternalKnightHealth * statsBonusKnight);
601
601
  }
602
602
  break;
603
603
  case "BG28_555":