@firestone-hs/simulate-bgs-battle 1.1.486 → 1.1.488
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bgs-player-entity.d.ts +2 -1
- package/dist/bgs-player-entity.js.map +1 -1
- package/dist/board-entity.d.ts +1 -0
- package/dist/board-entity.js.map +1 -1
- package/dist/cards/card.interface.d.ts +12 -0
- package/dist/cards/card.interface.js +3 -0
- package/dist/cards/card.interface.js.map +1 -0
- package/dist/cards/cards-data.js +16 -3
- package/dist/cards/cards-data.js.map +1 -1
- package/dist/cards/impl/anomaly/anomalous-twin.d.ts +8 -0
- package/dist/cards/impl/anomaly/anomalous-twin.js +24 -0
- package/dist/cards/impl/anomaly/anomalous-twin.js.map +1 -0
- package/dist/cards/impl/anomaly/blessed-or-blighted.d.ts +5 -0
- package/dist/cards/impl/anomaly/blessed-or-blighted.js +16 -0
- package/dist/cards/impl/anomaly/blessed-or-blighted.js.map +1 -0
- package/dist/cards/impl/hero-power/aim-high.d.ts +5 -0
- package/dist/cards/impl/hero-power/aim-high.js +18 -0
- package/dist/cards/impl/hero-power/aim-high.js.map +1 -0
- package/dist/cards/impl/hero-power/aim-left.d.ts +5 -0
- package/dist/cards/impl/hero-power/aim-left.js +16 -0
- package/dist/cards/impl/hero-power/aim-left.js.map +1 -0
- package/dist/cards/impl/hero-power/aim-low.d.ts +5 -0
- package/dist/cards/impl/hero-power/aim-low.js +18 -0
- package/dist/cards/impl/hero-power/aim-low.js.map +1 -0
- package/dist/cards/impl/hero-power/aim-right.d.ts +5 -0
- package/dist/cards/impl/hero-power/aim-right.js +16 -0
- package/dist/cards/impl/hero-power/aim-right.js.map +1 -0
- package/dist/cards/impl/hero-power/all-will-burn.d.ts +5 -0
- package/dist/cards/impl/hero-power/all-will-burn.js +18 -0
- package/dist/cards/impl/hero-power/all-will-burn.js.map +1 -0
- package/dist/cards/impl/hero-power/earth-invocation.d.ts +5 -0
- package/dist/cards/impl/hero-power/earth-invocation.js +13 -0
- package/dist/cards/impl/hero-power/earth-invocation.js.map +1 -0
- package/dist/cards/impl/hero-power/embrace-your-rage.d.ts +8 -0
- package/dist/cards/impl/hero-power/embrace-your-rage.js +26 -0
- package/dist/cards/impl/hero-power/embrace-your-rage.js.map +1 -0
- package/dist/cards/impl/hero-power/fire-invocation.d.ts +5 -0
- package/dist/cards/impl/hero-power/fire-invocation.js +13 -0
- package/dist/cards/impl/hero-power/fire-invocation.js.map +1 -0
- package/dist/cards/impl/hero-power/fragrant-phylactery.d.ts +8 -0
- package/dist/cards/impl/hero-power/fragrant-phylactery.js +25 -0
- package/dist/cards/impl/hero-power/fragrant-phylactery.js.map +1 -0
- package/dist/cards/impl/hero-power/glorious-gloop.d.ts +5 -0
- package/dist/cards/impl/hero-power/glorious-gloop.js +40 -0
- package/dist/cards/impl/hero-power/glorious-gloop.js.map +1 -0
- package/dist/cards/impl/hero-power/lightning-invocation.d.ts +5 -0
- package/dist/cards/impl/hero-power/lightning-invocation.js +13 -0
- package/dist/cards/impl/hero-power/lightning-invocation.js.map +1 -0
- package/dist/cards/impl/hero-power/rapid-reanimation.d.ts +8 -0
- package/dist/cards/impl/hero-power/rapid-reanimation.js +29 -0
- package/dist/cards/impl/hero-power/rapid-reanimation.js.map +1 -0
- package/dist/cards/impl/hero-power/reborn-rites.d.ts +5 -0
- package/dist/cards/impl/hero-power/reborn-rites.js +18 -0
- package/dist/cards/impl/hero-power/reborn-rites.js.map +1 -0
- package/dist/cards/impl/hero-power/swatting-insects.d.ts +5 -0
- package/dist/cards/impl/hero-power/swatting-insects.js +21 -0
- package/dist/cards/impl/hero-power/swatting-insects.js.map +1 -0
- package/dist/cards/impl/hero-power/tentacular.d.ts +8 -0
- package/dist/cards/impl/hero-power/tentacular.js +10 -0
- package/dist/cards/impl/hero-power/tentacular.js.map +1 -0
- package/dist/cards/impl/hero-power/water-invocation.d.ts +5 -0
- package/dist/cards/impl/hero-power/water-invocation.js +13 -0
- package/dist/cards/impl/hero-power/water-invocation.js.map +1 -0
- package/dist/cards/impl/hero-power/wax-warband.d.ts +5 -0
- package/dist/cards/impl/hero-power/wax-warband.js +56 -0
- package/dist/cards/impl/hero-power/wax-warband.js.map +1 -0
- package/dist/cards/impl/minion/amber-guardian.d.ts +5 -0
- package/dist/cards/impl/minion/amber-guardian.js +31 -0
- package/dist/cards/impl/minion/amber-guardian.js.map +1 -0
- package/dist/cards/impl/minion/audacious-anchor.d.ts +5 -0
- package/dist/cards/impl/minion/audacious-anchor.js +25 -0
- package/dist/cards/impl/minion/audacious-anchor.js.map +1 -0
- package/dist/cards/impl/minion/carbonic-copy.d.ts +5 -0
- package/dist/cards/impl/minion/carbonic-copy.js +24 -0
- package/dist/cards/impl/minion/carbonic-copy.js.map +1 -0
- package/dist/cards/impl/minion/choral-mrrrglr.d.ts +5 -0
- package/dist/cards/impl/minion/choral-mrrrglr.js +14 -0
- package/dist/cards/impl/minion/choral-mrrrglr.js.map +1 -0
- package/dist/cards/impl/minion/corrupted-myrmidon.d.ts +5 -0
- package/dist/cards/impl/minion/corrupted-myrmidon.js +13 -0
- package/dist/cards/impl/minion/corrupted-myrmidon.js.map +1 -0
- package/dist/cards/impl/minion/crabby.d.ts +5 -0
- package/dist/cards/impl/minion/crabby.js +18 -0
- package/dist/cards/impl/minion/crabby.js.map +1 -0
- package/dist/cards/impl/minion/diremuck-forager.d.ts +5 -0
- package/dist/cards/impl/minion/diremuck-forager.js +32 -0
- package/dist/cards/impl/minion/diremuck-forager.js.map +1 -0
- package/dist/cards/impl/minion/elder-taggawag.d.ts +5 -0
- package/dist/cards/impl/minion/elder-taggawag.js +19 -0
- package/dist/cards/impl/minion/elder-taggawag.js.map +1 -0
- package/dist/cards/impl/minion/hawkstrider-herald.d.ts +5 -0
- package/dist/cards/impl/minion/hawkstrider-herald.js +27 -0
- package/dist/cards/impl/minion/hawkstrider-herald.js.map +1 -0
- package/dist/cards/impl/minion/hoarding-hatespawn.d.ts +5 -0
- package/dist/cards/impl/minion/hoarding-hatespawn.js +22 -0
- package/dist/cards/impl/minion/hoarding-hatespawn.js.map +1 -0
- package/dist/cards/impl/minion/humming-bird.d.ts +5 -0
- package/dist/cards/impl/minion/humming-bird.js +15 -0
- package/dist/cards/impl/minion/humming-bird.js.map +1 -0
- package/dist/cards/impl/minion/interrogator-whitemane.d.ts +5 -0
- package/dist/cards/impl/minion/interrogator-whitemane.js +33 -0
- package/dist/cards/impl/minion/interrogator-whitemane.js.map +1 -0
- package/dist/cards/impl/minion/irate-rooster.d.ts +5 -0
- package/dist/cards/impl/minion/irate-rooster.js +20 -0
- package/dist/cards/impl/minion/irate-rooster.js.map +1 -0
- package/dist/cards/impl/minion/mantid-queen.d.ts +5 -0
- package/dist/cards/impl/minion/mantid-queen.js +52 -0
- package/dist/cards/impl/minion/mantid-queen.js.map +1 -0
- package/dist/cards/impl/minion/misfit-dragonling.d.ts +5 -0
- package/dist/cards/impl/minion/misfit-dragonling.js +15 -0
- package/dist/cards/impl/minion/misfit-dragonling.js.map +1 -0
- package/dist/cards/impl/minion/piloted-whirl-o-tron.d.ts +5 -0
- package/dist/cards/impl/minion/piloted-whirl-o-tron.js +13 -0
- package/dist/cards/impl/minion/piloted-whirl-o-tron.js.map +1 -0
- package/dist/cards/impl/minion/prized-promo-drake.d.ts +5 -0
- package/dist/cards/impl/minion/prized-promo-drake.js +22 -0
- package/dist/cards/impl/minion/prized-promo-drake.js.map +1 -0
- package/dist/cards/impl/minion/red-whelp.d.ts +5 -0
- package/dist/cards/impl/minion/red-whelp.js +17 -0
- package/dist/cards/impl/minion/red-whelp.js.map +1 -0
- package/dist/cards/impl/minion/sanctum-rester.d.ts +5 -0
- package/dist/cards/impl/minion/sanctum-rester.js +20 -0
- package/dist/cards/impl/minion/sanctum-rester.js.map +1 -0
- package/dist/cards/impl/minion/sandy.d.ts +5 -0
- package/dist/cards/impl/minion/sandy.js +23 -0
- package/dist/cards/impl/minion/sandy.js.map +1 -0
- package/dist/cards/impl/minion/sky-pirate-flagbearer.d.ts +5 -0
- package/dist/cards/impl/minion/sky-pirate-flagbearer.js +24 -0
- package/dist/cards/impl/minion/sky-pirate-flagbearer.js.map +1 -0
- package/dist/cards/impl/minion/soulsplitter.d.ts +5 -0
- package/dist/cards/impl/minion/soulsplitter.js +23 -0
- package/dist/cards/impl/minion/soulsplitter.js.map +1 -0
- package/dist/cards/impl/minion/sun-screener.d.ts +5 -0
- package/dist/cards/impl/minion/sun-screener.js +15 -0
- package/dist/cards/impl/minion/sun-screener.js.map +1 -0
- package/dist/cards/impl/minion/the-uninvited-guest.d.ts +5 -0
- package/dist/cards/impl/minion/the-uninvited-guest.js +24 -0
- package/dist/cards/impl/minion/the-uninvited-guest.js.map +1 -0
- package/dist/cards/impl/minion/thousandth-paper-drake.d.ts +5 -0
- package/dist/cards/impl/minion/thousandth-paper-drake.js +24 -0
- package/dist/cards/impl/minion/thousandth-paper-drake.js.map +1 -0
- package/dist/cards/impl/minion/vaelastrasz.d.ts +5 -0
- package/dist/cards/impl/minion/vaelastrasz.js +17 -0
- package/dist/cards/impl/minion/vaelastrasz.js.map +1 -0
- package/dist/cards/impl/minion/yulon-fortune-granter.d.ts +5 -0
- package/dist/cards/impl/minion/yulon-fortune-granter.js +26 -0
- package/dist/cards/impl/minion/yulon-fortune-granter.js.map +1 -0
- package/dist/cards/impl/quest-reward/evil-twin.d.ts +5 -0
- package/dist/cards/impl/quest-reward/evil-twin.js +32 -0
- package/dist/cards/impl/quest-reward/evil-twin.js.map +1 -0
- package/dist/cards/impl/quest-reward/staff-of-origination.d.ts +5 -0
- package/dist/cards/impl/quest-reward/staff-of-origination.js +14 -0
- package/dist/cards/impl/quest-reward/staff-of-origination.js.map +1 -0
- package/dist/cards/impl/quest-reward/stolen-gold.d.ts +5 -0
- package/dist/cards/impl/quest-reward/stolen-gold.js +16 -0
- package/dist/cards/impl/quest-reward/stolen-gold.js.map +1 -0
- package/dist/cards/impl/trinket/artisanal-urn.d.ts +5 -0
- package/dist/cards/impl/trinket/artisanal-urn.js +13 -0
- package/dist/cards/impl/trinket/artisanal-urn.js.map +1 -0
- package/dist/cards/impl/trinket/automaton-portrait.d.ts +5 -0
- package/dist/cards/impl/trinket/automaton-portrait.js +15 -0
- package/dist/cards/impl/trinket/automaton-portrait.js.map +1 -0
- package/dist/cards/impl/trinket/bronze-timepiece.d.ts +5 -0
- package/dist/cards/impl/trinket/bronze-timepiece.js +17 -0
- package/dist/cards/impl/trinket/bronze-timepiece.js.map +1 -0
- package/dist/cards/impl/trinket/emerald-dreamcatcher.d.ts +5 -0
- package/dist/cards/impl/trinket/emerald-dreamcatcher.js +18 -0
- package/dist/cards/impl/trinket/emerald-dreamcatcher.js.map +1 -0
- package/dist/cards/impl/trinket/eternal-portrait.d.ts +5 -0
- package/dist/cards/impl/trinket/eternal-portrait.js +19 -0
- package/dist/cards/impl/trinket/eternal-portrait.js.map +1 -0
- package/dist/cards/impl/trinket/fishy-sticker.d.ts +5 -0
- package/dist/cards/impl/trinket/fishy-sticker.js +28 -0
- package/dist/cards/impl/trinket/fishy-sticker.js.map +1 -0
- package/dist/cards/impl/trinket/hoggy-bank.d.ts +5 -0
- package/dist/cards/impl/trinket/hoggy-bank.js +23 -0
- package/dist/cards/impl/trinket/hoggy-bank.js.map +1 -0
- package/dist/cards/impl/trinket/holly-mallet.d.ts +5 -0
- package/dist/cards/impl/trinket/holly-mallet.js +18 -0
- package/dist/cards/impl/trinket/holly-mallet.js.map +1 -0
- package/dist/cards/impl/trinket/ironforge-anvil.d.ts +5 -0
- package/dist/cards/impl/trinket/ironforge-anvil.js +23 -0
- package/dist/cards/impl/trinket/ironforge-anvil.js.map +1 -0
- package/dist/cards/impl/trinket/jarred-frostling.d.ts +5 -0
- package/dist/cards/impl/trinket/jarred-frostling.js +27 -0
- package/dist/cards/impl/trinket/jarred-frostling.js.map +1 -0
- package/dist/cards/impl/trinket/karazhan-chess-set.d.ts +5 -0
- package/dist/cards/impl/trinket/karazhan-chess-set.js +40 -0
- package/dist/cards/impl/trinket/karazhan-chess-set.js.map +1 -0
- package/dist/cards/impl/trinket/rivendare-portrait.d.ts +5 -0
- package/dist/cards/impl/trinket/rivendare-portrait.js +21 -0
- package/dist/cards/impl/trinket/rivendare-portrait.js.map +1 -0
- package/dist/cards/impl/trinket/rusty-trident.d.ts +5 -0
- package/dist/cards/impl/trinket/rusty-trident.js +23 -0
- package/dist/cards/impl/trinket/rusty-trident.js.map +1 -0
- package/dist/cards/impl/trinket/ship-in-a-bottle.d.ts +5 -0
- package/dist/cards/impl/trinket/ship-in-a-bottle.js +20 -0
- package/dist/cards/impl/trinket/ship-in-a-bottle.js.map +1 -0
- package/dist/cards/impl/trinket/summoning-sphere.d.ts +5 -0
- package/dist/cards/impl/trinket/summoning-sphere.js +31 -0
- package/dist/cards/impl/trinket/summoning-sphere.js.map +1 -0
- package/dist/cards/impl/trinket/tinyfin-onesie.d.ts +5 -0
- package/dist/cards/impl/trinket/tinyfin-onesie.js +15 -0
- package/dist/cards/impl/trinket/tinyfin-onesie.js.map +1 -0
- package/dist/cards/impl/trinket/training-certificate.d.ts +5 -0
- package/dist/cards/impl/trinket/training-certificate.js +21 -0
- package/dist/cards/impl/trinket/training-certificate.js.map +1 -0
- package/dist/cards/impl/trinket/valorous-medaillion.d.ts +5 -0
- package/dist/cards/impl/trinket/valorous-medaillion.js +12 -0
- package/dist/cards/impl/trinket/valorous-medaillion.js.map +1 -0
- package/dist/services/utils.d.ts +1 -0
- package/dist/services/utils.js +13 -1
- package/dist/services/utils.js.map +1 -1
- package/dist/simulation/add-minion-to-board.js +18 -23
- package/dist/simulation/add-minion-to-board.js.map +1 -1
- package/dist/simulation/attack.js +14 -4
- package/dist/simulation/attack.js.map +1 -1
- package/dist/simulation/auras.js +0 -2
- package/dist/simulation/auras.js.map +1 -1
- package/dist/simulation/avenge.js +24 -4
- package/dist/simulation/avenge.js.map +1 -1
- package/dist/simulation/battlecries.js +21 -5
- package/dist/simulation/battlecries.js.map +1 -1
- package/dist/simulation/blood-gems.js +8 -0
- package/dist/simulation/blood-gems.js.map +1 -1
- package/dist/simulation/deathrattle-effects.js +7 -1
- package/dist/simulation/deathrattle-effects.js.map +1 -1
- package/dist/simulation/deathrattle-on-trigger.js +5 -0
- package/dist/simulation/deathrattle-on-trigger.js.map +1 -1
- package/dist/simulation/discover.d.ts +4 -0
- package/dist/simulation/discover.js +32 -0
- package/dist/simulation/discover.js.map +1 -0
- package/dist/simulation/magnetize.js +2 -1
- package/dist/simulation/magnetize.js.map +1 -1
- package/dist/simulation/minion-death.d.ts +1 -1
- package/dist/simulation/minion-death.js +8 -8
- package/dist/simulation/minion-death.js.map +1 -1
- package/dist/simulation/remove-minion-from-board.js +0 -10
- package/dist/simulation/remove-minion-from-board.js.map +1 -1
- package/dist/simulation/simulator.js +1 -1
- package/dist/simulation/simulator.js.map +1 -1
- package/dist/simulation/start-of-combat/phases.d.ts +1 -0
- package/dist/simulation/start-of-combat/phases.js +3 -0
- package/dist/simulation/start-of-combat/phases.js.map +1 -0
- package/dist/simulation/start-of-combat/soc-action-processor.d.ts +4 -0
- package/dist/simulation/start-of-combat/soc-action-processor.js +286 -0
- package/dist/simulation/start-of-combat/soc-action-processor.js.map +1 -0
- package/dist/simulation/start-of-combat/soc-anomalies.d.ts +4 -0
- package/dist/simulation/start-of-combat/soc-anomalies.js +39 -0
- package/dist/simulation/start-of-combat/soc-anomalies.js.map +1 -0
- package/dist/simulation/start-of-combat/soc-hero-power.d.ts +5 -0
- package/dist/simulation/start-of-combat/soc-hero-power.js +77 -0
- package/dist/simulation/start-of-combat/soc-hero-power.js.map +1 -0
- package/dist/simulation/start-of-combat/soc-illidan-hero-power.d.ts +4 -0
- package/dist/simulation/start-of-combat/soc-illidan-hero-power.js +55 -0
- package/dist/simulation/start-of-combat/soc-illidan-hero-power.js.map +1 -0
- package/dist/simulation/start-of-combat/soc-minion.d.ts +6 -0
- package/dist/simulation/start-of-combat/soc-minion.js +68 -0
- package/dist/simulation/start-of-combat/soc-minion.js.map +1 -0
- package/dist/simulation/start-of-combat/soc-pre-combat-hero-power.d.ts +4 -0
- package/dist/simulation/start-of-combat/soc-pre-combat-hero-power.js +72 -0
- package/dist/simulation/start-of-combat/soc-pre-combat-hero-power.js.map +1 -0
- package/dist/simulation/start-of-combat/soc-quest-reward.d.ts +4 -0
- package/dist/simulation/start-of-combat/soc-quest-reward.js +60 -0
- package/dist/simulation/start-of-combat/soc-quest-reward.js.map +1 -0
- package/dist/simulation/start-of-combat/soc-secret.d.ts +4 -0
- package/dist/simulation/start-of-combat/soc-secret.js +54 -0
- package/dist/simulation/start-of-combat/soc-secret.js.map +1 -0
- package/dist/simulation/start-of-combat/soc-trinket.d.ts +4 -0
- package/dist/simulation/start-of-combat/soc-trinket.js +60 -0
- package/dist/simulation/start-of-combat/soc-trinket.js.map +1 -0
- package/dist/simulation/start-of-combat/start-of-combat-input.d.ts +14 -0
- package/dist/simulation/start-of-combat/start-of-combat-input.js +3 -0
- package/dist/simulation/start-of-combat/start-of-combat-input.js.map +1 -0
- package/dist/simulation/start-of-combat/start-of-combat.d.ts +4 -0
- package/dist/simulation/start-of-combat/start-of-combat.js +68 -0
- package/dist/simulation/start-of-combat/start-of-combat.js.map +1 -0
- package/dist/simulation/summon-when-space.js +5 -1
- package/dist/simulation/summon-when-space.js.map +1 -1
- package/dist/temp-card-ids.d.ts +2 -0
- package/dist/temp-card-ids.js +3 -0
- package/dist/temp-card-ids.js.map +1 -0
- package/package.json +3 -3
- package/dist/simulation/start-of-combat.d.ts +0 -8
- package/dist/simulation/start-of-combat.js +0 -1167
- package/dist/simulation/start-of-combat.js.map +0 -1
|
@@ -12,6 +12,11 @@ const onDeathrattleTriggered = (input) => {
|
|
|
12
12
|
break;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
+
input.boardWithDeadEntityHero.trinkets
|
|
16
|
+
.filter((t) => t.cardId === "BG30_MagicItem_700")
|
|
17
|
+
.forEach((t) => {
|
|
18
|
+
t.scriptDataNum1 = 0;
|
|
19
|
+
});
|
|
15
20
|
};
|
|
16
21
|
exports.onDeathrattleTriggered = onDeathrattleTriggered;
|
|
17
22
|
//# sourceMappingURL=deathrattle-on-trigger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deathrattle-on-trigger.js","sourceRoot":"","sources":["../../src/simulation/deathrattle-on-trigger.ts"],"names":[],"mappings":";;;AAIA,mCAAiD;AAW1C,MAAM,sBAAsB,GAAG,CAAC,KAAgC,EAAE,EAAE;;IAC1E,MAAM,MAAM,GAAG,MAAA,KAAK,CAAC,uBAAuB,CAAC,aAAa,mCAAI,EAAE,CAAC;IACjE,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;QAC3B,QAAQ,KAAK,CAAC,MAAM,EAAE;YACrB;gBACC,IAAA,8BAAsB,EACrB,KAAK,CAAC,uBAAuB,EAC7B,KAAK,EACL,KAAK,CAAC,mBAAmB,EACzB,KAAK,CAAC,SAAS,CACf,CAAC;gBACF,MAAM;SACP;KACD;
|
|
1
|
+
{"version":3,"file":"deathrattle-on-trigger.js","sourceRoot":"","sources":["../../src/simulation/deathrattle-on-trigger.ts"],"names":[],"mappings":";;;AAIA,mCAAiD;AAW1C,MAAM,sBAAsB,GAAG,CAAC,KAAgC,EAAE,EAAE;;IAC1E,MAAM,MAAM,GAAG,MAAA,KAAK,CAAC,uBAAuB,CAAC,aAAa,mCAAI,EAAE,CAAC;IACjE,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;QAC3B,QAAQ,KAAK,CAAC,MAAM,EAAE;YACrB;gBACC,IAAA,8BAAsB,EACrB,KAAK,CAAC,uBAAuB,EAC7B,KAAK,EACL,KAAK,CAAC,mBAAmB,EACzB,KAAK,CAAC,SAAS,CACf,CAAC;gBACF,MAAM;SACP;KACD;IAED,KAAK,CAAC,uBAAuB,CAAC,QAAQ;SACpC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,yBAAiD,CAAC;SACxE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACd,CAAC,CAAC,cAAc,GAAG,CAAC,CAAC;IACtB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AApBW,QAAA,sBAAsB,0BAoBjC","sourcesContent":["import { CardIds } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { onQuestProgressUpdated } from './quest';\r\n\r\nexport interface DeathrattleTriggeredInput {\r\n\treadonly boardWithDeadEntity: BoardEntity[];\r\n\treadonly boardWithDeadEntityHero: BgsPlayerEntity;\r\n\treadonly deadEntity: BoardEntity;\r\n\treadonly otherBoard: BoardEntity[];\r\n\treadonly otherBoardHero: BgsPlayerEntity;\r\n\treadonly gameState: FullGameState;\r\n}\r\n\r\nexport const onDeathrattleTriggered = (input: DeathrattleTriggeredInput) => {\r\n\tconst quests = input.boardWithDeadEntityHero.questEntities ?? [];\r\n\tfor (const quest of quests) {\r\n\t\tswitch (quest.CardId) {\r\n\t\t\tcase CardIds.ExhumeTheBones:\r\n\t\t\t\tonQuestProgressUpdated(\r\n\t\t\t\t\tinput.boardWithDeadEntityHero,\r\n\t\t\t\t\tquest,\r\n\t\t\t\t\tinput.boardWithDeadEntity,\r\n\t\t\t\t\tinput.gameState,\r\n\t\t\t\t);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tinput.boardWithDeadEntityHero.trinkets\r\n\t\t.filter((t) => t.cardId === CardIds.DeathlyPhylactery_BG30_MagicItem_700)\r\n\t\t.forEach((t) => {\r\n\t\t\tt.scriptDataNum1 = 0;\r\n\t\t});\r\n};\r\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { BgsPlayerEntity } from '../bgs-player-entity';
|
|
2
|
+
import { BoardEntity } from '../board-entity';
|
|
3
|
+
import { FullGameState } from './internal-game-state';
|
|
4
|
+
export declare const afterDiscover: (hero: BgsPlayerEntity, board: BoardEntity[], picked: string, ignored: string[], gameState: FullGameState) => void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.afterDiscover = void 0;
|
|
4
|
+
const cards_in_hand_1 = require("./cards-in-hand");
|
|
5
|
+
const stats_1 = require("./stats");
|
|
6
|
+
const afterDiscover = (hero, board, picked, ignored, gameState) => {
|
|
7
|
+
if (!(ignored === null || ignored === void 0 ? void 0 : ignored.length)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
for (const entity of board) {
|
|
11
|
+
switch (entity.cardId) {
|
|
12
|
+
case "BG30_115":
|
|
13
|
+
case "BG30_115_G":
|
|
14
|
+
const felfinMultiplier = entity.cardId === "BG30_115" ? 1 : 2;
|
|
15
|
+
const baseTotalAttack = ignored
|
|
16
|
+
.map((cardId) => gameState.allCards.getCard(cardId).attack)
|
|
17
|
+
.reduce((a, b) => a + b, 0);
|
|
18
|
+
const baseTotalHealth = ignored
|
|
19
|
+
.map((cardId) => gameState.allCards.getCard(cardId).health)
|
|
20
|
+
.reduce((a, b) => a + b, 0);
|
|
21
|
+
(0, stats_1.modifyStats)(entity, baseTotalAttack * felfinMultiplier, baseTotalHealth * felfinMultiplier, board, hero, gameState);
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const primalfinPortraits = hero.trinkets.filter((t) => t.cardId === "BG30_MagicItem_702").length;
|
|
26
|
+
if (!!primalfinPortraits) {
|
|
27
|
+
const cardsToAdd = new Array(primalfinPortraits).fill(null);
|
|
28
|
+
(0, cards_in_hand_1.addCardsInHand)(hero, board, cardsToAdd, gameState);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.afterDiscover = afterDiscover;
|
|
32
|
+
//# sourceMappingURL=discover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover.js","sourceRo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AAC,CAAC,MAAM,yBAAiD,CAChE,CAAC,MAAM,CAAC;IACT,IAAI,CAAC,CAAC,kBAAkB,EAAE;QACzB,MAAM,UAAU,GAAG,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5D,IAAA,8BAAc,EAAC,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;KACnD;AACF,CAAC,CAAC;AAzCW,QAAA,aAAa,iBAyCxB","sourcesContent":["import { CardIds } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { modifyStats } from './stats';\r\n\r\nexport const afterDiscover = (\r\n\thero: BgsPlayerEntity,\r\n\tboard: BoardEntity[],\r\n\tpicked: string,\r\n\tignored: string[],\r\n\tgameState: FullGameState,\r\n) => {\r\n\tif (!ignored?.length) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tfor (const entity of board) {\r\n\t\tswitch (entity.cardId) {\r\n\t\t\tcase CardIds.DepravedFelfin_BG30_115:\r\n\t\t\tcase CardIds.DepravedFelfin_BG30_115_G:\r\n\t\t\t\tconst felfinMultiplier = entity.cardId === CardIds.DepravedFelfin_BG30_115 ? 1 : 2;\r\n\t\t\t\tconst baseTotalAttack = ignored\r\n\t\t\t\t\t.map((cardId) => gameState.allCards.getCard(cardId).attack)\r\n\t\t\t\t\t.reduce((a, b) => a + b, 0);\r\n\t\t\t\tconst baseTotalHealth = ignored\r\n\t\t\t\t\t.map((cardId) => gameState.allCards.getCard(cardId).health)\r\n\t\t\t\t\t.reduce((a, b) => a + b, 0);\r\n\t\t\t\tmodifyStats(\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tbaseTotalAttack * felfinMultiplier,\r\n\t\t\t\t\tbaseTotalHealth * felfinMultiplier,\r\n\t\t\t\t\tboard,\r\n\t\t\t\t\thero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tconst primalfinPortraits = hero.trinkets.filter(\r\n\t\t(t) => t.cardId === CardIds.PrimalfinPortrait_BG30_MagicItem_702,\r\n\t).length;\r\n\tif (!!primalfinPortraits) {\r\n\t\tconst cardsToAdd = new Array(primalfinPortraits).fill(null);\r\n\t\taddCardsInHand(hero, board, cardsToAdd, gameState);\r\n\t}\r\n};\r\n"]}
|
|
@@ -5,8 +5,9 @@ const reference_data_1 = require("@firestone-hs/reference-data");
|
|
|
5
5
|
const stats_1 = require("./stats");
|
|
6
6
|
const magnetizeToTarget = (target, cardIdToMagnetize, board, hero, gameState) => {
|
|
7
7
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
8
|
+
const electromagneticDevices = hero.trinkets.filter((t) => t.cardId === "BG30_MagicItem_709").length;
|
|
8
9
|
const modularCard = gameState.allCards.getCard(cardIdToMagnetize);
|
|
9
|
-
(0, stats_1.modifyStats)(target, modularCard.attack, modularCard.health, board, hero, gameState);
|
|
10
|
+
(0, stats_1.modifyStats)(target, modularCard.attack + 2 * electromagneticDevices, modularCard.health + 2 * electromagneticDevices, board, hero, gameState);
|
|
10
11
|
target.taunt = target.taunt || ((_a = modularCard.mechanics) === null || _a === void 0 ? void 0 : _a.includes(reference_data_1.GameTag[reference_data_1.GameTag.TAUNT]));
|
|
11
12
|
target.divineShield = target.divineShield || ((_b = modularCard.mechanics) === null || _b === void 0 ? void 0 : _b.includes(reference_data_1.GameTag[reference_data_1.GameTag.DIVINE_SHIELD]));
|
|
12
13
|
target.poisonous = target.poisonous || ((_c = modularCard.mechanics) === null || _c === void 0 ? void 0 : _c.includes(reference_data_1.GameTag[reference_data_1.GameTag.POISONOUS]));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"magnetize.js","sourceRoot":"","sources":["../../src/simulation/magnetize.ts"],"names":[],"mappings":";;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,CAAC,CAAC,CAAA,CAAC;IAChG,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,KAAI,MAAA,WAAW,CAAC,SAAS,0CAAE,QAAQ,CAAC,wBAAO,CAAC,wBAAO,CAAC,QAAQ,CAAC,CAAC,CAAA,CAAC;IAChG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,KAAI,MAAA,WAAW,CAAC,SAAS,0CAAE,QAAQ,CAAC,wBAAO,CAAC,wBAAO,CAAC,MAAM,CAAC,CAAC,CAAA,CAAC;IAC1F,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,KAAI,MAAA,WAAW,CAAC,SAAS,0CAAE,QAAQ,CAAC,wBAAO,CAAC,wBAAO,CAAC,OAAO,CAAC,CAAC,CAAA,CAAC;IAE7F,MAAM,mBAAmB,GAAG,WAAW,CAAC,gBAAgB,CAAC;IACzD,IAAI,mBAAmB,EAAE;QACxB,MAAM,WAAW,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC;QACvE,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC;YACxB,MAAM,EAAE,WAAW;YACnB,cAAc,EAAE,WAAW,CAAC,KAAK;YACjC,MAAM,EAAE,SAAS,CAAC,WAAW,CAAC,eAAe,EAAE;SAC/C,CAAC,CAAC;KACH;AACF,CAAC,CAAC;AApCW,QAAA,iBAAiB,qBAoC5B","sourcesContent":["import { CardIds, GameTag } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { modifyStats } from './stats';\r\n\r\nexport const magnetizeToTarget = (\r\n\ttarget: BoardEntity,\r\n\tcardIdToMagnetize: string,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst electromagneticDevices = hero.trinkets.filter(\r\n\t\t(t) => t.cardId === CardIds.ElectromagneticDevice_BG30_MagicItem_709,\r\n\t).length;\r\n\tconst modularCard = gameState.allCards.getCard(cardIdToMagnetize);\r\n\tmodifyStats(\r\n\t\ttarget,\r\n\t\tmodularCard.attack + 2 * electromagneticDevices,\r\n\t\tmodularCard.health + 2 * electromagneticDevices,\r\n\t\tboard,\r\n\t\thero,\r\n\t\tgameState,\r\n\t);\r\n\ttarget.taunt = target.taunt || modularCard.mechanics?.includes(GameTag[GameTag.TAUNT]);\r\n\ttarget.divineShield = target.divineShield || modularCard.mechanics?.includes(GameTag[GameTag.DIVINE_SHIELD]);\r\n\ttarget.poisonous = target.poisonous || modularCard.mechanics?.includes(GameTag[GameTag.POISONOUS]);\r\n\ttarget.venomous = target.venomous || modularCard.mechanics?.includes(GameTag[GameTag.VENOMOUS]);\r\n\ttarget.windfury = target.windfury || modularCard.mechanics?.includes(GameTag[GameTag.WINDFURY]);\r\n\ttarget.reborn = target.reborn || modularCard.mechanics?.includes(GameTag[GameTag.REBORN]);\r\n\ttarget.stealth = target.stealth || modularCard.mechanics?.includes(GameTag[GameTag.STEALTH]);\r\n\r\n\tconst magneticEnchantment = modularCard.enchantmentDbfId;\r\n\tif (magneticEnchantment) {\r\n\t\tconst enchantment = gameState.allCards.getCard(magneticEnchantment).id;\r\n\t\ttarget.enchantments.push({\r\n\t\t\tcardId: enchantment,\r\n\t\t\toriginEntityId: modularCard.dbfId,\r\n\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t});\r\n\t}\r\n};\r\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BgsPlayerEntity } from '../bgs-player-entity';
|
|
2
2
|
import { BoardEntity } from '../board-entity';
|
|
3
3
|
import { FullGameState } from './internal-game-state';
|
|
4
|
-
export declare const makeMinionsDie: (board: BoardEntity[], boardHero: BgsPlayerEntity, otherBoard: BoardEntity[], otherBoardHero: BgsPlayerEntity, gameState: FullGameState) => [number[], BoardEntity[]];
|
|
4
|
+
export declare const makeMinionsDie: (board: BoardEntity[], boardHero: BgsPlayerEntity, otherBoard: BoardEntity[], otherBoardHero: BgsPlayerEntity, gameState: FullGameState) => [number[], number[], BoardEntity[]];
|
|
5
5
|
export declare const onMinionDeadHeroPower: (board: BoardEntity[], boardHero: BgsPlayerEntity, deadEntity: BoardEntity, gameState: FullGameState) => void;
|
|
6
6
|
export declare const onMinionDeadQuest: (deadEntity: BoardEntity, indexFromRight: number, board: BoardEntity[], boardHero: BgsPlayerEntity, otherBoard: BoardEntity[], otherBoardHero: BgsPlayerEntity, gameState: FullGameState) => void;
|
|
@@ -12,11 +12,13 @@ const remove_minion_from_board_1 = require("./remove-minion-from-board");
|
|
|
12
12
|
const spawns_1 = require("./spawns");
|
|
13
13
|
const stats_1 = require("./stats");
|
|
14
14
|
const makeMinionsDie = (board, boardHero, otherBoard, otherBoardHero, gameState) => {
|
|
15
|
+
const deadMinionIndexesFromLeft = [];
|
|
15
16
|
const deadMinionIndexesFromRight = [];
|
|
16
17
|
const deadEntities = [];
|
|
17
18
|
const initialBoardLength = board.length;
|
|
18
19
|
for (let i = 0; i < board.length; i++) {
|
|
19
20
|
if (board[i].health <= 0 || board[i].definitelyDead) {
|
|
21
|
+
deadMinionIndexesFromLeft.push(i);
|
|
20
22
|
deadMinionIndexesFromRight.push(initialBoardLength - (i + 1));
|
|
21
23
|
deadEntities.push(board[i]);
|
|
22
24
|
}
|
|
@@ -41,7 +43,7 @@ const makeMinionsDie = (board, boardHero, otherBoard, otherBoardHero, gameState)
|
|
|
41
43
|
(0, exports.onMinionDeadQuest)(deadEntity, indexFromRight, board, boardHero, otherBoard, otherBoardHero, gameState);
|
|
42
44
|
(0, exports.onMinionDeadQuest)(deadEntity, indexFromRight, otherBoard, otherBoardHero, board, boardHero, gameState);
|
|
43
45
|
}
|
|
44
|
-
return [indexesFromRightAfterDeath, deadEntities];
|
|
46
|
+
return [deadMinionIndexesFromLeft, indexesFromRightAfterDeath, deadEntities];
|
|
45
47
|
};
|
|
46
48
|
exports.makeMinionsDie = makeMinionsDie;
|
|
47
49
|
const onMinionDeadHeroPower = (board, boardHero, deadEntity, gameState) => {
|
|
@@ -72,13 +74,11 @@ const onMinionDeadQuest = (deadEntity, indexFromRight, board, boardHero, otherBo
|
|
|
72
74
|
case "BG30_MagicItem_433":
|
|
73
75
|
case "BG30_MagicItem_433t":
|
|
74
76
|
if (trinket.scriptDataNum1 > 0 && deadEntity.friendly === boardHero.friendly) {
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
gameState.spectator.registerPowerTarget(boardHero, target, board, boardHero, otherBoardHero);
|
|
81
|
-
}
|
|
77
|
+
const quantity = trinket.cardId === "BG30_MagicItem_433" ? 1 : 2;
|
|
78
|
+
const targets = (0, utils_1.pickMultipleRandomAlive)(board, quantity);
|
|
79
|
+
for (const target of targets) {
|
|
80
|
+
(0, stats_1.modifyStats)(target, deadEntity.maxAttack, deadEntity.maxHealth, board, boardHero, gameState);
|
|
81
|
+
gameState.spectator.registerPowerTarget(boardHero, target, board, boardHero, otherBoardHero);
|
|
82
82
|
}
|
|
83
83
|
trinket.scriptDataNum1--;
|
|
84
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minion-death.js","sourceRoot":"","sources":["../../src/simulation/minion-death.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAG7D,6CAAoD;AACpD,oCAAwE;AACxE,qCAAgD;AAChD,mDAAiD;AACjD,6DAAqD;AAErD,mCAAiD;AACjD,yEAAmE;AACnE,qCAA+C;AAC/C,mCAAsC;AAE/B,MAAM,cAAc,GAAG,CAC7B,KAAoB,EACpB,SAA0B,EAC1B,UAAyB,EACzB,cAA+B,EAC/B,SAAwB,EACI,EAAE;IAE9B,MAAM,0BAA0B,GAAa,EAAE,CAAC;IAChD,MAAM,YAAY,GAAkB,EAAE,CAAC;IACvC,MAAM,kBAAkB,GAAG,KAAK,CAAC,MAA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AG,CAAC,IAAI,cAAc,GAAG,CAAC,EAAE;4BAC7C,MAAM,MAAM,GAAG,IAAA,kCAAa,yBAE3B,CAAC,EACD,KAAK,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,SAAS,CAAC,QAAQ,EAClB,SAAS,CAAC,SAAS,EACnB,SAAS,CAAC,WAAW,EACrB,SAAS,CAAC,SAAS,EACnB,UAAU,CAAC,QAAQ,EACnB,KAAK,CACL,CAAC;4BACF,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;gCACpB,CAAC,CAAC,MAAM,GAAG,cAAc,CAAC;gCAC1B,CAAC,CAAC,MAAM,GAAG,cAAc,CAAC;4BAC3B,CAAC,CAAC,CAAC;4BACH,IAAA,4BAAmB,EAClB,MAAM,EACN,KAAK,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,UAAU,EACV,cAAc,EACd,SAAS,CACT,CAAC;4BACF,OAAO,CAAC,cAAc,EAAE,CAAC;yBACzB;qBACD;iBACD;gBACD,MAAM;SACP;KACD;AACF,CAAC,CAAC;AAnHW,QAAA,iBAAiB,qBAmH5B","sourcesContent":["import { CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { pickRandomAlive } from '../services/utils';\r\nimport { getEffectiveTribesForEntity, hasCorrectTribe } from '../utils';\r\nimport { updateAvengeCounters } from './avenge';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { onQuestProgressUpdated } from './quest';\r\nimport { removeMinionFromBoard } from './remove-minion-from-board';\r\nimport { performEntitySpawns } from './spawns';\r\nimport { modifyStats } from './stats';\r\n\r\nexport const makeMinionsDie = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): [number[], BoardEntity[]] => {\r\n\t// Because entities spawn to the left, so the right index is unchanged\r\n\tconst deadMinionIndexesFromRight: number[] = [];\r\n\tconst deadEntities: BoardEntity[] = [];\r\n\tconst initialBoardLength = board.length;\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].health <= 0 || board[i].definitelyDead) {\r\n\t\t\tdeadMinionIndexesFromRight.push(initialBoardLength - (i + 1));\r\n\t\t\tdeadEntities.push(board[i]);\r\n\t\t\t// console.log(\r\n\t\t\t// \t'\\tflagging dead minion 0',\r\n\t\t\t// \tstringifySimpleCard(board[i], allCards),\r\n\t\t\t// \tstringifySimple(board, allCards),\r\n\t\t\t// \tinitialBoardLength,\r\n\t\t\t// \ti,\r\n\t\t\t// \tdeadMinionIndexesFromRight,\r\n\t\t\t// );\r\n\t\t}\r\n\t}\r\n\r\n\t// These will always be processed from left to right afterwards\r\n\t// We compute the indexes as they will be once the new board is effective. For a\r\n\t// board of length N, having an indexFromRight at N means it will spawn at the very left\r\n\t// of the board (first minion)\r\n\tlet indexesFromRightAfterDeath = [];\r\n\tfor (let i = deadMinionIndexesFromRight.length - 1; i >= 0; i--) {\r\n\t\tconst newIndex = deadMinionIndexesFromRight[i] - indexesFromRightAfterDeath.length;\r\n\t\tindexesFromRightAfterDeath.push(newIndex);\r\n\t}\r\n\tindexesFromRightAfterDeath = indexesFromRightAfterDeath.reverse();\r\n\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].health <= 0 || board[i].definitelyDead) {\r\n\t\t\t// console.log('\\tflagging dead minion', stringifySimpleCard(board[i], allCards), deadMinionIndexesFromRight);\r\n\t\t\tremoveMinionFromBoard(board, boardHero, i, gameState);\r\n\t\t\t// We modify the original array, so we need to update teh current index accordingly\r\n\t\t\ti--;\r\n\t\t}\r\n\t}\r\n\r\n\t// console.debug('dead entities', stringifySimple(deadEntities, allCards));\r\n\t// Update the avenge counters as soon as minions die. If we wait until the \"avenge\" phase, we might\r\n\t// update the counters for entities that have been spawned after the death of the original entity\r\n\t// ISSUE: deaths are actually processed one by one. Once a minion dies, its DR triggers, then the next, etc.\r\n\t// This means that if you have a minion that summons another one, it can progress and complete and quest\r\n\t// and the next minion dying could count towards that quest progress\r\n\t// See http://replays.firestoneapp.com/?reviewId=0ce4db9c-3269-4704-b662-8a8c31f5afe1&turn=16&action=27\r\n\tfor (const deadEntity of deadEntities) {\r\n\t\tconst indexFromRight = indexesFromRightAfterDeath[deadEntities.indexOf(deadEntity)];\r\n\t\tupdateAvengeCounters(board, boardHero);\r\n\t\tonMinionDeadHeroPower(board, boardHero, deadEntity, gameState);\r\n\t\tonMinionDeadHeroPower(otherBoard, otherBoardHero, deadEntity, gameState);\r\n\t\tonMinionDeadQuest(deadEntity, indexFromRight, board, boardHero, otherBoard, otherBoardHero, gameState);\r\n\t\tonMinionDeadQuest(deadEntity, indexFromRight, otherBoard, otherBoardHero, board, boardHero, gameState);\r\n\t}\r\n\r\n\treturn [indexesFromRightAfterDeath, deadEntities];\r\n};\r\n\r\nexport const onMinionDeadHeroPower = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tif (\r\n\t\tboardHero.heroPowerId === CardIds.IllTakeThat &&\r\n\t\tboardHero.heroPowerUsed &&\r\n\t\tboardHero.heroPowerInfo2 <= 0 &&\r\n\t\tdeadEntity.friendly !== boardHero.friendly\r\n\t) {\r\n\t\taddCardsInHand(boardHero, board, [deadEntity.cardId], gameState);\r\n\t\tboardHero.heroPowerInfo2 = 1;\r\n\t}\r\n};\r\n\r\nexport const onMinionDeadQuest = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst quests = boardHero.questEntities ?? [];\r\n\tfor (const quest of quests) {\r\n\t\tswitch (quest.CardId) {\r\n\t\t\tcase CardIds.ReenactTheMurder:\r\n\t\t\t\tonQuestProgressUpdated(boardHero, quest, board, gameState);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.RoundUpTheSuspects:\r\n\t\t\t\tonQuestProgressUpdated(boardHero, quest, board, gameState);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const trinket of boardHero.trinkets) {\r\n\t\tswitch (trinket.cardId) {\r\n\t\t\tcase CardIds.AllianceKeychain_BG30_MagicItem_433:\r\n\t\t\tcase CardIds.AllianceKeychain_AllianceKeychainToken_BG30_MagicItem_433t:\r\n\t\t\t\tif (trinket.scriptDataNum1 > 0 && deadEntity.friendly === boardHero.friendly) {\r\n\t\t\t\t\tconst loops = trinket.cardId === CardIds.AllianceKeychain_BG30_MagicItem_433 ? 1 : 2;\r\n\t\t\t\t\tfor (let i = 0; i < loops; i++) {\r\n\t\t\t\t\t\tconst target = pickRandomAlive(board);\r\n\t\t\t\t\t\tif (!!target) {\r\n\t\t\t\t\t\t\tmodifyStats(\r\n\t\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\t\tdeadEntity.maxAttack,\r\n\t\t\t\t\t\t\t\tdeadEntity.maxHealth,\r\n\t\t\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\t\t\tboardHero,\r\n\t\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\t\tboardHero,\r\n\t\t\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\t\t\tboardHero,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\ttrinket.scriptDataNum1--;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.TheEyeOfDalaran_BG30_MagicItem_981:\r\n\t\t\t\tif (\r\n\t\t\t\t\tdeadEntity.friendly === boardHero.friendly &&\r\n\t\t\t\t\tgetEffectiveTribesForEntity(deadEntity, boardHero, gameState.allCards).length === 0\r\n\t\t\t\t) {\r\n\t\t\t\t\taddCardsInHand(boardHero, board, [null], gameState);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.BloodGolemSticker_BG30_MagicItem_442:\r\n\t\t\t\tif (\r\n\t\t\t\t\tdeadEntity.friendly === boardHero.friendly &&\r\n\t\t\t\t\ttrinket.scriptDataNum1 > 0 &&\r\n\t\t\t\t\thasCorrectTribe(deadEntity, boardHero, Race.QUILBOAR, gameState.allCards)\r\n\t\t\t\t) {\r\n\t\t\t\t\tlet bloodGemEnchantments = deadEntity.enchantments?.filter(\r\n\t\t\t\t\t\t(e) => e.cardId === CardIds.BloodGem_BloodGemsEnchantment,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (bloodGemEnchantments?.length === 0) {\r\n\t\t\t\t\t\tbloodGemEnchantments = deadEntity.enchantments?.filter(\r\n\t\t\t\t\t\t\t(e) => e.cardId === CardIds.BloodGem_BloodGemEnchantment,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (bloodGemEnchantments?.length > 0) {\r\n\t\t\t\t\t\tconst bloodGemAttack = bloodGemEnchantments\r\n\t\t\t\t\t\t\t.map((e) => e.tagScriptDataNum1 ?? 0)\r\n\t\t\t\t\t\t\t.reduce((a, b) => a + b, 0);\r\n\t\t\t\t\t\tconst bloodGemHealth = bloodGemEnchantments\r\n\t\t\t\t\t\t\t.map((e) => e.tagScriptDataNum2 ?? 0)\r\n\t\t\t\t\t\t\t.reduce((a, b) => a + b, 0);\r\n\t\t\t\t\t\tif (bloodGemAttack > 0 || bloodGemHealth > 0) {\r\n\t\t\t\t\t\t\tconst spawns = spawnEntities(\r\n\t\t\t\t\t\t\t\tCardIds.BloodGolemSticker_BloodGolemToken_BG30_MagicItem_442t,\r\n\t\t\t\t\t\t\t\t1,\r\n\t\t\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\t\t\tboardHero,\r\n\t\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\tspawns.forEach((b) => {\r\n\t\t\t\t\t\t\t\tb.attack = bloodGemAttack;\r\n\t\t\t\t\t\t\t\tb.health = bloodGemHealth;\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\tperformEntitySpawns(\r\n\t\t\t\t\t\t\t\tspawns,\r\n\t\t\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\t\t\tboardHero,\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\ttrinket.scriptDataNum1--;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"minion-death.js","sourceRoot":"","sources":["../../src/simulation/minion-death.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAG7D,6CAA4D;AAC5D,oCAAwE;AACxE,qCAAgD;AAChD,mDAAiD;AACjD,6DAAqD;AAErD,mCAAiD;AACjD,y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AAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;wBAC7B,MAAM,cAAc,GAAG,oBAAoB;6BACzC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,WAAC,OAAA,MAAA,CAAC,CAAC,iBAAiB,mCAAI,CAAC,CAAA,EAAA,CAAC;6BACpC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;wBAC7B,IAAI,cAAc,GAAG,CAAC,IAAI,cAAc,GAAG,CAAC,EAAE;4BAC7C,MAAM,MAAM,GAAG,IAAA,kCAAa,yBAE3B,CAAC,EACD,KAAK,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,SAAS,CAAC,QAAQ,EAClB,SAAS,CAAC,SAAS,EACnB,SAAS,CAAC,WAAW,EACrB,SAAS,CAAC,SAAS,EACnB,UAAU,CAAC,QAAQ,EACnB,KAAK,CACL,CAAC;4BACF,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;gCACpB,CAAC,CAAC,MAAM,GAAG,cAAc,CAAC;gCAC1B,CAAC,CAAC,MAAM,GAAG,cAAc,CAAC;4BAC3B,CAAC,CAAC,CAAC;4BACH,IAAA,4BAAmB,EAClB,MAAM,EACN,KAAK,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,UAAU,EACV,cAAc,EACd,SAAS,CACT,CAAC;4BACF,OAAO,CAAC,cAAc,EAAE,CAAC;yBACzB;qBACD;iBACD;gBACD,MAAM;SACP;KACD;AACF,CAAC,CAAC;AApGW,QAAA,iBAAiB,qBAoG5B","sourcesContent":["import { CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { pickMultipleRandomAlive } from '../services/utils';\r\nimport { getEffectiveTribesForEntity, hasCorrectTribe } from '../utils';\r\nimport { updateAvengeCounters } from './avenge';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { onQuestProgressUpdated } from './quest';\r\nimport { removeMinionFromBoard } from './remove-minion-from-board';\r\nimport { performEntitySpawns } from './spawns';\r\nimport { modifyStats } from './stats';\r\n\r\nexport const makeMinionsDie = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): [number[], number[], BoardEntity[]] => {\r\n\t// Because entities spawn to the left, so the right index is unchanged\r\n\tconst deadMinionIndexesFromLeft: number[] = [];\r\n\tconst deadMinionIndexesFromRight: number[] = [];\r\n\tconst deadEntities: BoardEntity[] = [];\r\n\tconst initialBoardLength = board.length;\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].health <= 0 || board[i].definitelyDead) {\r\n\t\t\tdeadMinionIndexesFromLeft.push(i);\r\n\t\t\tdeadMinionIndexesFromRight.push(initialBoardLength - (i + 1));\r\n\t\t\tdeadEntities.push(board[i]);\r\n\t\t\t// console.log(\r\n\t\t\t// \t'\\tflagging dead minion 0',\r\n\t\t\t// \tstringifySimpleCard(board[i], allCards),\r\n\t\t\t// \tstringifySimple(board, allCards),\r\n\t\t\t// \tinitialBoardLength,\r\n\t\t\t// \ti,\r\n\t\t\t// \tdeadMinionIndexesFromRight,\r\n\t\t\t// );\r\n\t\t}\r\n\t}\r\n\r\n\t// These will always be processed from left to right afterwards\r\n\t// We compute the indexes as they will be once the new board is effective. For a\r\n\t// board of length N, having an indexFromRight at N means it will spawn at the very left\r\n\t// of the board (first minion)\r\n\tlet indexesFromRightAfterDeath = [];\r\n\tfor (let i = deadMinionIndexesFromRight.length - 1; i >= 0; i--) {\r\n\t\tconst newIndex = deadMinionIndexesFromRight[i] - indexesFromRightAfterDeath.length;\r\n\t\tindexesFromRightAfterDeath.push(newIndex);\r\n\t}\r\n\tindexesFromRightAfterDeath = indexesFromRightAfterDeath.reverse();\r\n\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].health <= 0 || board[i].definitelyDead) {\r\n\t\t\t// console.log('\\tflagging dead minion', stringifySimpleCard(board[i], allCards), deadMinionIndexesFromRight);\r\n\t\t\tremoveMinionFromBoard(board, boardHero, i, gameState);\r\n\t\t\t// We modify the original array, so we need to update teh current index accordingly\r\n\t\t\ti--;\r\n\t\t}\r\n\t}\r\n\r\n\t// console.debug('dead entities', stringifySimple(deadEntities, allCards));\r\n\t// Update the avenge counters as soon as minions die. If we wait until the \"avenge\" phase, we might\r\n\t// update the counters for entities that have been spawned after the death of the original entity\r\n\t// ISSUE: deaths are actually processed one by one. Once a minion dies, its DR triggers, then the next, etc.\r\n\t// This means that if you have a minion that summons another one, it can progress and complete and quest\r\n\t// and the next minion dying could count towards that quest progress\r\n\t// See http://replays.firestoneapp.com/?reviewId=0ce4db9c-3269-4704-b662-8a8c31f5afe1&turn=16&action=27\r\n\tfor (const deadEntity of deadEntities) {\r\n\t\tconst indexFromRight = indexesFromRightAfterDeath[deadEntities.indexOf(deadEntity)];\r\n\t\tupdateAvengeCounters(board, boardHero);\r\n\t\tonMinionDeadHeroPower(board, boardHero, deadEntity, gameState);\r\n\t\tonMinionDeadHeroPower(otherBoard, otherBoardHero, deadEntity, gameState);\r\n\t\tonMinionDeadQuest(deadEntity, indexFromRight, board, boardHero, otherBoard, otherBoardHero, gameState);\r\n\t\tonMinionDeadQuest(deadEntity, indexFromRight, otherBoard, otherBoardHero, board, boardHero, gameState);\r\n\t}\r\n\r\n\treturn [deadMinionIndexesFromLeft, indexesFromRightAfterDeath, deadEntities];\r\n};\r\n\r\nexport const onMinionDeadHeroPower = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tif (\r\n\t\tboardHero.heroPowerId === CardIds.IllTakeThat &&\r\n\t\tboardHero.heroPowerUsed &&\r\n\t\tboardHero.heroPowerInfo2 <= 0 &&\r\n\t\tdeadEntity.friendly !== boardHero.friendly\r\n\t) {\r\n\t\taddCardsInHand(boardHero, board, [deadEntity.cardId], gameState);\r\n\t\tboardHero.heroPowerInfo2 = 1;\r\n\t}\r\n};\r\n\r\nexport const onMinionDeadQuest = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst quests = boardHero.questEntities ?? [];\r\n\tfor (const quest of quests) {\r\n\t\tswitch (quest.CardId) {\r\n\t\t\tcase CardIds.ReenactTheMurder:\r\n\t\t\t\tonQuestProgressUpdated(boardHero, quest, board, gameState);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.RoundUpTheSuspects:\r\n\t\t\t\tonQuestProgressUpdated(boardHero, quest, board, gameState);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const trinket of boardHero.trinkets) {\r\n\t\tswitch (trinket.cardId) {\r\n\t\t\tcase CardIds.AllianceKeychain_BG30_MagicItem_433:\r\n\t\t\tcase CardIds.AllianceKeychain_AllianceKeychainToken_BG30_MagicItem_433t:\r\n\t\t\t\tif (trinket.scriptDataNum1 > 0 && deadEntity.friendly === boardHero.friendly) {\r\n\t\t\t\t\tconst quantity = trinket.cardId === CardIds.AllianceKeychain_BG30_MagicItem_433 ? 1 : 2;\r\n\t\t\t\t\tconst targets = pickMultipleRandomAlive(board, quantity);\r\n\t\t\t\t\tfor (const target of targets) {\r\n\t\t\t\t\t\tmodifyStats(target, deadEntity.maxAttack, deadEntity.maxHealth, board, boardHero, gameState);\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(boardHero, target, board, boardHero, otherBoardHero);\r\n\t\t\t\t\t}\r\n\t\t\t\t\ttrinket.scriptDataNum1--;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.TheEyeOfDalaran_BG30_MagicItem_981:\r\n\t\t\t\tif (\r\n\t\t\t\t\tdeadEntity.friendly === boardHero.friendly &&\r\n\t\t\t\t\tgetEffectiveTribesForEntity(deadEntity, boardHero, gameState.allCards).length === 0\r\n\t\t\t\t) {\r\n\t\t\t\t\taddCardsInHand(boardHero, board, [null], gameState);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.BloodGolemSticker_BG30_MagicItem_442:\r\n\t\t\t\tif (\r\n\t\t\t\t\tdeadEntity.friendly === boardHero.friendly &&\r\n\t\t\t\t\ttrinket.scriptDataNum1 > 0 &&\r\n\t\t\t\t\thasCorrectTribe(deadEntity, boardHero, Race.QUILBOAR, gameState.allCards)\r\n\t\t\t\t) {\r\n\t\t\t\t\tlet bloodGemEnchantments = deadEntity.enchantments?.filter(\r\n\t\t\t\t\t\t(e) => e.cardId === CardIds.BloodGem_BloodGemsEnchantment,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (bloodGemEnchantments?.length === 0) {\r\n\t\t\t\t\t\tbloodGemEnchantments = deadEntity.enchantments?.filter(\r\n\t\t\t\t\t\t\t(e) => e.cardId === CardIds.BloodGem_BloodGemEnchantment,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (bloodGemEnchantments?.length > 0) {\r\n\t\t\t\t\t\tconst bloodGemAttack = bloodGemEnchantments\r\n\t\t\t\t\t\t\t.map((e) => e.tagScriptDataNum1 ?? 0)\r\n\t\t\t\t\t\t\t.reduce((a, b) => a + b, 0);\r\n\t\t\t\t\t\tconst bloodGemHealth = bloodGemEnchantments\r\n\t\t\t\t\t\t\t.map((e) => e.tagScriptDataNum2 ?? 0)\r\n\t\t\t\t\t\t\t.reduce((a, b) => a + b, 0);\r\n\t\t\t\t\t\tif (bloodGemAttack > 0 || bloodGemHealth > 0) {\r\n\t\t\t\t\t\t\tconst spawns = spawnEntities(\r\n\t\t\t\t\t\t\t\tCardIds.BloodGolemSticker_BloodGolemToken_BG30_MagicItem_442t,\r\n\t\t\t\t\t\t\t\t1,\r\n\t\t\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\t\t\tboardHero,\r\n\t\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\tspawns.forEach((b) => {\r\n\t\t\t\t\t\t\t\tb.attack = bloodGemAttack;\r\n\t\t\t\t\t\t\t\tb.health = bloodGemHealth;\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\tperformEntitySpawns(\r\n\t\t\t\t\t\t\t\tspawns,\r\n\t\t\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\t\t\tboardHero,\r\n\t\t\t\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\ttrinket.scriptDataNum1--;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n"]}
|
|
@@ -21,16 +21,6 @@ const handleMinionRemovedAuraEffect = (board, removed, boardHero, allCards, spec
|
|
|
21
21
|
e.attack = Math.max(0, e.attack - diff);
|
|
22
22
|
});
|
|
23
23
|
break;
|
|
24
|
-
case "BG26_805":
|
|
25
|
-
case "BG26_805_G":
|
|
26
|
-
board
|
|
27
|
-
.filter((e) => (0, utils_1.hasCorrectTribe)(e, boardHero, reference_data_1.Race.BEAST, allCards))
|
|
28
|
-
.filter((e) => e.entityId !== removed.entityId)
|
|
29
|
-
.forEach((e) => {
|
|
30
|
-
const diff = removed.cardId === "BG26_805_G" ? 4 : 2;
|
|
31
|
-
e.attack = Math.max(0, e.attack - diff);
|
|
32
|
-
});
|
|
33
|
-
break;
|
|
34
24
|
case "BG_NEW1_027":
|
|
35
25
|
case "TB_BaconUps_136":
|
|
36
26
|
board
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-minion-from-board.js","sourceRoot":"","sources":["../../src/simulation/remove-minion-from-board.ts"],"names":[],"mappings":";;;AAAA,iEAA8E;AAG9E,oCAA2C;AAC3C,mCAA+C;AAIxC,MAAM,qBAAqB,GAAG,CACpC,KAAoB,EACpB,SAA0B,EAC1B,KAAa,EACb,SAAwB,EACjB,EAAE;IACT,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,IAAA,qCAA6B,EAAC,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACxG,IAAA,4BAAoB,EAAC,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AACnD,CAAC,CAAC;AATW,QAAA,qBAAqB,yBAShC;AAEK,MAAM,6BAA6B,GAAG,CAC5C,KAAoB,EACpB,OAAoB,EACpB,SAA0B,EAC1B,QAAyB,EACzB,SAAoB,EACb,EAAE;IACT,QAAQ,OAAO,CAAC,MAAM,EAAE;QACvB,kBAA8C;QAC9C;YACC,KAAK;iBACH,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,uBAAe,EAAC,CAAC,EAAE,SAAS,EAAE,qBAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;iBACnE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;gBACd,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,sBAAkD,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACtF,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;YACJ,MAAM;QACP,
|
|
1
|
+
{"version":3,"file":"remove-minion-from-board.js","sourceRoot":"","sources":["../../src/simulation/remove-minion-from-board.ts"],"names":[],"mappings":";;;AAAA,iEAA8E;AAG9E,oCAA2C;AAC3C,mCAA+C;AAIxC,MAAM,qBAAqB,GAAG,CACpC,KAAoB,EACpB,SAA0B,EAC1B,KAAa,EACb,SAAwB,EACjB,EAAE;IACT,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,IAAA,qCAA6B,EAAC,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACxG,IAAA,4BAAoB,EAAC,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AACnD,CAAC,CAAC;AATW,QAAA,qBAAqB,yBAShC;AAEK,MAAM,6BAA6B,GAAG,CAC5C,KAAoB,EACpB,OAAoB,EACpB,SAA0B,EAC1B,QAAyB,EACzB,SAAoB,EACb,EAAE;IACT,QAAQ,OAAO,CAAC,MAAM,EAAE;QACvB,kBAA8C;QAC9C;YACC,KAAK;iBACH,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,uBAAe,EAAC,CAAC,EAAE,SAAS,EAAE,qBAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;iBACnE,OAAO,CAAC,CAAC,CAAC,EAA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AAG,IAAI,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;YACJ,MAAM;QACP,gBAAkC;QAClC;YACC,KAAK;iBACH,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC;iBAC7B,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;gBACd,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,iBAAmC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;gBACxE,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;YACJ,MAAM;QACP,gBAAgC;QAChC;YACC,KAAK;iBACH,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,uBAAe,EAAC,CAAC,EAAE,SAAS,EAAE,qBAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;iBACnE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;gBACd,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,iBAAiC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,UAAU,CAAC;gBAC9F,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;YACJ,MAAM;KACP;AACF,CAAC,CAAC;AAzDW,QAAA,6BAA6B,iCAyDxC","sourcesContent":["import { AllCardsService, CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { hasCorrectTribe } from '../utils';\r\nimport { updateBoardwideAuras } from './auras';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { Spectator } from './spectator/spectator';\r\n\r\nexport const removeMinionFromBoard = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tindex: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst removedEntity = board.splice(index, 1)[0];\r\n\thandleMinionRemovedAuraEffect(board, removedEntity, boardHero, gameState.allCards, gameState.spectator);\r\n\tupdateBoardwideAuras(board, boardHero, gameState);\r\n};\r\n\r\nexport const handleMinionRemovedAuraEffect = (\r\n\tboard: BoardEntity[],\r\n\tremoved: BoardEntity,\r\n\tboardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tswitch (removed.cardId) {\r\n\t\tcase CardIds.MurlocWarleaderLegacy_BG_EX1_507:\r\n\t\tcase CardIds.MurlocWarleaderLegacy_TB_BaconUps_008:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, boardHero, Race.MURLOC, allCards))\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\tconst diff = removed.cardId === CardIds.MurlocWarleaderLegacy_TB_BaconUps_008 ? 4 : 2;\r\n\t\t\t\t\te.attack = Math.max(0, e.attack - diff);\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.SouthseaCaptainLegacy_BG_NEW1_027:\r\n\t\tcase CardIds.SouthseaCaptainLegacy_TB_BaconUps_136:\r\n\t\t\t// console.debug('removing southsea captain', stringifySimpleCard(removed, allCards), stringifySimple(board, allCards));\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, boardHero, Race.PIRATE, allCards))\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\tconst diff = removed.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1;\r\n\t\t\t\t\te.attack = Math.max(0, e.attack - diff);\r\n\t\t\t\t\te.health = Math.max(1, e.health - diff);\r\n\t\t\t\t});\r\n\t\t\t// console.debug('after removing southsea captain', stringifySimpleCard(removed, allCards), stringifySimple(board, allCards));\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Kathranatir_BG21_039:\r\n\t\tcase CardIds.Kathranatir_BG21_039_G:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, boardHero, Race.DEMON, allCards))\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\tconst diff = removed.cardId === CardIds.Kathranatir_BG21_039_G ? 4 : 2;\r\n\t\t\t\t\te.attack = Math.max(0, e.attack - diff);\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.CyborgDrake_BG25_043:\r\n\t\tcase CardIds.CyborgDrake_BG25_043_G:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => e.divineShield)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\tconst diff = removed.cardId === CardIds.CyborgDrake_BG25_043_G ? 12 : 6;\r\n\t\t\t\t\te.attack = Math.max(0, e.attack - diff);\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.SoreLoser_BG27_030:\r\n\t\tcase CardIds.SoreLoser_BG27_030_G:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, boardHero, Race.UNDEAD, allCards))\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\tconst diff = (removed.cardId === CardIds.SoreLoser_BG27_030_G ? 2 : 1) * boardHero.tavernTier;\r\n\t\t\t\t\te.attack = Math.max(0, e.attack - diff);\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t}\r\n};\r\n"]}
|
|
@@ -6,7 +6,7 @@ const debug_state_1 = require("../debug-state");
|
|
|
6
6
|
const utils_1 = require("../utils");
|
|
7
7
|
const attack_1 = require("./attack");
|
|
8
8
|
const auras_1 = require("./auras");
|
|
9
|
-
const start_of_combat_1 = require("./start-of-combat");
|
|
9
|
+
const start_of_combat_1 = require("./start-of-combat/start-of-combat");
|
|
10
10
|
const summon_when_space_1 = require("./summon-when-space");
|
|
11
11
|
class Simulator {
|
|
12
12
|
constructor(gameState) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simulator.js","sourceRoot":"","sources":["../../src/simulation/simulator.ts"],"names":[],"mappings":";;;AAAA,iEAAqE;AAGrE,gDAA4C;AAE5C,oCAA2C;AAC3C,qCAA0C;AAC1C,mCAA+C;AAE/C,uDAAwD;AACxD,2DAA6D;AAG7D,MAAa,SAAS;IAOrB,YAA6B,SAAwB;QAAxB,cAAS,GAAT,SAAS,CAAe;QAL7C,yBAAoB,GAAG,CAAC,CAAC,CAAC;QAE1B,+BAA0B,GAAG,KAAK,CAAC;IAGa,CAAC;IAIlD,oBAAoB,CAAC,WAAwB,EAAE,aAA0B;;QAC/E,IAAI,WAAW,GAAkB,WAAW,CAAC,KAAK,CAAC;QACnD,IAAI,YAAY,GAAoB,WAAW,CAAC,MAAM,CAAC;QACvD,IAAI,aAAa,GAAkB,aAAa,CAAC,KAAK,CAAC;QACvD,IAAI,cAAc,GAAoB,aAAa,CAAC,MAAM,CAAC;QAC3D,OACC,CAAC,YAAY,CAAC,iBAAiB;YAC/B,CAAC,cAAc,CAAC,iBAAiB;YACjC,CAAC,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,IAAG,CAAC,IAAI,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,MAAM,IAAG,CAAC,CAAC,EACrD;YACD,IAAI,CAAC,wBAAwB,CAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;YAIxF,MAAM,oBAAoB,GACzB,WAAW,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;gBAC5B,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC;gBACxD,aAAa,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;gBAC9B,aAAa,CAAC,KAAK,CAAC,KAAK,C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,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7B,MAAM,+BAA+B,GAAG,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC;QAC/D,MAAM,uBAAuB,GAC5B,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CACV,KAAK,CAAC,CAAC,EAAE,+BAA+B,EACzC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CACf,IAAA,sCAAqB,EAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAE9F,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,mCAAI,CAAC,CAAC;QACnC,OAAO,qBAAqB,GAAG,uBAAuB,CAAC;IACxD,CAAC;CACD;AAhOD,8BAgOC","sourcesContent":["import { getEffectiveTechLevel } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { debugState } from '../debug-state';\r\nimport { SingleSimulationResult } from '../single-simulation-result';\r\nimport { stringifySimple } from '../utils';\r\nimport { simulateAttack } from './attack';\r\nimport { clearStealthIfNeeded } from './auras';\r\nimport { FullGameState, PlayerState } from './internal-game-state';\r\nimport { handleStartOfCombat } from './start-of-combat';\r\nimport { handleSummonsWhenSpace } from './summon-when-space';\r\n\r\n// New simulator should be instantiated for each match\r\nexport class Simulator {\r\n\tprivate currentAttacker: number;\r\n\tprivate currentSpeedAttacker = -1;\r\n\r\n\tprivate hasShowShortCircuitWarning = false;\r\n\r\n\t// It should come already initialized\r\n\tconstructor(private readonly gameState: FullGameState) {}\r\n\r\n\t// Here we suppose that the BoardEntity only contain at most the enchantments that are linked\r\n\t// to auras (so we probably should hand-filter that, since there are actually few auras)\r\n\tpublic simulateSingleBattle(playerState: PlayerState, opponentState: PlayerState): SingleSimulationResult {\r\n\t\tlet playerBoard: BoardEntity[] = playerState.board;\r\n\t\tlet playerEntity: BgsPlayerEntity = playerState.player;\r\n\t\tlet opponentBoard: BoardEntity[] = opponentState.board;\r\n\t\tlet opponentEntity: BgsPlayerEntity = opponentState.player;\r\n\t\twhile (\r\n\t\t\t!playerEntity.startOfCombatDone ||\r\n\t\t\t!opponentEntity.startOfCombatDone ||\r\n\t\t\t(playerBoard?.length > 0 && opponentBoard?.length > 0)\r\n\t\t) {\r\n\t\t\tthis.simulateSingleBattlePass(playerBoard, playerEntity, opponentBoard, opponentEntity);\r\n\r\n\t\t\t// The only case where there can only 0-attack minions on a board is when both boards\r\n\t\t\t// are that way (otherwise one side would kill the other)\r\n\t\t\tconst areBothBoards0Attack =\r\n\t\t\t\tplayerState.board.length > 0 &&\r\n\t\t\t\tplayerState.board.every((entity) => entity.attack === 0) &&\r\n\t\t\t\topponentState.board.length > 0 &&\r\n\t\t\t\topponentState.board.every((entity) => entity.attack === 0);\r\n\t\t\tconst isPlayerBoardEmpty = playerState.board.length === 0;\r\n\t\t\tconst isOpponentBoardEmpty = opponentState.board.length === 0;\r\n\t\t\tplayerBoard = areBothBoards0Attack || isPlayerBoardEmpty ? playerState.teammate?.board : playerState.board;\r\n\t\t\tplayerEntity =\r\n\t\t\t\tareBothBoards0Attack || isPlayerBoardEmpty ? playerState.teammate?.player : playerState.player;\r\n\t\t\topponentBoard =\r\n\t\t\t\tareBothBoards0Attack || isOpponentBoardEmpty ? opponentState.teammate?.board : opponentState.board;\r\n\t\t\topponentEntity =\r\n\t\t\t\tareBothBoards0Attack || isOpponentBoardEmpty ? opponentState.teammate?.player : opponentState.player;\r\n\t\t\t// So that gameState.player always refers to the active player\r\n\t\t\tif (isPlayerBoardEmpty) {\r\n\t\t\t\t// Reset deaths\r\n\t\t\t\tthis.gameState.sharedState.deaths = this.gameState.sharedState.deaths.filter(\r\n\t\t\t\t\t(e) => e.friendly !== this.gameState.gameState.player.player.friendly,\r\n\t\t\t\t);\r\n\t\t\t\tthis.gameState.gameState.player.teammate = {\r\n\t\t\t\t\tboard: this.gameState.gameState.player.board,\r\n\t\t\t\t\tplayer: this.gameState.gameState.player.player,\r\n\t\t\t\t};\r\n\t\t\t\tthis.gameState.gameState.player.player = playerEntity;\r\n\t\t\t\tthis.gameState.gameState.player.board = playerBoard;\r\n\r\n\t\t\t\t// const initialPlayer = this.gameState.gameState.playerInitial;\r\n\t\t\t\t// const initialPlayerTeammate = initialPlayer.teammate;\r\n\t\t\t}\r\n\t\t\tif (isOpponentBoardEmpty) {\r\n\t\t\t\t// Reset deaths\r\n\t\t\t\tthis.gameState.sharedState.deaths = this.gameState.sharedState.deaths.filter(\r\n\t\t\t\t\t(e) => e.friendly !== this.gameState.gameState.opponent.player.friendly,\r\n\t\t\t\t);\r\n\t\t\t\tthis.gameState.gameState.opponent.teammate = {\r\n\t\t\t\t\tboard: this.gameState.gameState.opponent.board,\r\n\t\t\t\t\tplayer: this.gameState.gameState.opponent.player,\r\n\t\t\t\t};\r\n\t\t\t\tthis.gameState.gameState.opponent.player = opponentEntity;\r\n\t\t\t\tthis.gameState.gameState.opponent.board = opponentBoard;\r\n\t\t\t}\r\n\r\n\t\t\tif (!playerEntity || !opponentEntity) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (\r\n\t\t\t(!playerBoard?.length && !opponentBoard?.length) ||\r\n\t\t\t// E.g. when both players have a 0-attack minion\r\n\t\t\t(playerBoard?.length > 0 && opponentBoard?.length > 0)\r\n\t\t) {\r\n\t\t\treturn {\r\n\t\t\t\tresult: 'tied',\r\n\t\t\t} as SingleSimulationResult;\r\n\t\t}\r\n\t\tif (!playerBoard?.length) {\r\n\t\t\tconst damage =\r\n\t\t\t\tthis.buildBoardTotalDamage(opponentBoard, this.gameState.gameState.opponent?.teammate?.board) +\r\n\t\t\t\topponentEntity.tavernTier;\r\n\t\t\tthis.gameState.spectator.registerOpponentAttack(playerBoard, opponentBoard, damage);\r\n\t\t\treturn {\r\n\t\t\t\tresult: 'lost',\r\n\t\t\t\tdamageDealt: damage,\r\n\t\t\t};\r\n\t\t}\r\n\t\tconst damage =\r\n\t\t\tthis.buildBoardTotalDamage(playerBoard, this.gameState.gameState.player?.teammate?.board) +\r\n\t\t\tplayerEntity.tavernTier;\r\n\t\tthis.gameState.spectator.registerPlayerAttack(playerBoard, opponentBoard, damage);\r\n\t\treturn {\r\n\t\t\tresult: 'won',\r\n\t\t\tdamageDealt: damage,\r\n\t\t};\r\n\t}\r\n\r\n\tprivate simulateSingleBattlePass(\r\n\t\tplayerBoard: BoardEntity[],\r\n\t\tplayerEntity: BgsPlayerEntity,\r\n\t\topponentBoard: BoardEntity[],\r\n\t\topponentEntity: BgsPlayerEntity,\r\n\t) {\r\n\t\tif (debugState?.active) {\r\n\t\t\tdebugState.onBattleStart();\r\n\t\t}\r\n\t\t// Start of combat happens only once, so we need to flag whether it has already happened for a\r\n\t\t// given player\r\n\t\tthis.gameState.spectator.registerStartOfCombat(playerBoard, opponentBoard, playerEntity, opponentEntity);\r\n\r\n\t\t// Who attacks first is decided by the game before the hero power comes into effect. However, the full board (with the generated minion)\r\n\t\t// is sent tothe simulator\r\n\t\t// But in fact, the first player decision takes into account that additional minion. See\r\n\t\t// https://replays.firestoneapp.com/?reviewId=ddbbbe93-464b-4400-8e8d-4abca8680a2e\r\n\t\tconst effectivePlayerBoardLength = playerBoard.length;\r\n\t\tconst effectiveOpponentBoardLength = opponentBoard.length;\r\n\t\tthis.currentAttacker =\r\n\t\t\teffectivePlayerBoardLength > effectiveOpponentBoardLength\r\n\t\t\t\t? 0\r\n\t\t\t\t: effectiveOpponentBoardLength > effectivePlayerBoardLength\r\n\t\t\t\t? 1\r\n\t\t\t\t: Math.round(Math.random());\r\n\t\tthis.gameState.sharedState.currentEntityId =\r\n\t\t\tMath.max(\r\n\t\t\t\t...playerBoard.map((entity) => entity.entityId),\r\n\t\t\t\t...opponentBoard.map((entity) => entity.entityId),\r\n\t\t\t\t...(playerEntity.hand?.map((entity) => entity.entityId) ?? []),\r\n\t\t\t\t...(opponentEntity.hand?.map((entity) => entity.entityId) ?? []),\r\n\t\t\t) + 1;\r\n\t\tconst suggestedNewCurrentAttacker = handleStartOfCombat(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tthis.currentAttacker,\r\n\t\t\tthis.gameState,\r\n\t\t);\r\n\t\tthis.currentAttacker = suggestedNewCurrentAttacker;\r\n\t\tlet counter = 0;\r\n\t\tif (debugState?.active) {\r\n\t\t\tthis.currentAttacker = debugState.forcedCurrentAttacker ?? this.currentAttacker;\r\n\t\t}\r\n\t\twhile (playerBoard.length > 0 && opponentBoard.length > 0) {\r\n\t\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, this.gameState);\r\n\t\t\tclearStealthIfNeeded(playerBoard, opponentBoard);\r\n\t\t\t// console.log('this.currentSpeedAttacker', this.currentAttacker);\r\n\t\t\t// If there are \"attack immediately\" minions, we keep the same player\r\n\t\t\t// We put it here so that it can kick in after the start of combat effects. However here we don't want\r\n\t\t\t// to change who attacks first, so we repeat that block again after all the attacks have been resolved\r\n\t\t\t// FIXME: This is not strictly correct - if there are multiple attack immediately\r\n\t\t\t// minions that spawn on both player sides it might get a bit more complex\r\n\t\t\t// but overall it works\r\n\t\t\t// Also, this doesn't work when there are several deathrattle competing\r\n\t\t\t// to know who triggers first. See the second test case of the scallywag.test.ts\r\n\t\t\t// that is not handled properly today (the attack should in some cases happen before\r\n\t\t\t// the other deathrattle procs)\r\n\t\t\tif (playerBoard.some((entity) => entity.attackImmediately)) {\r\n\t\t\t\tthis.currentSpeedAttacker = 0;\r\n\t\t\t} else if (opponentBoard.some((entity) => entity.attackImmediately)) {\r\n\t\t\t\tthis.currentSpeedAttacker = 1;\r\n\t\t\t} else {\r\n\t\t\t\tthis.currentSpeedAttacker = -1;\r\n\t\t\t}\r\n\t\t\tif (\r\n\t\t\t\tplayerBoard.filter((e) => e.attack > 0).length === 0 &&\r\n\t\t\t\topponentBoard.filter((e) => e.attack > 0).length === 0\r\n\t\t\t) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\t// console.log('this.currentSpeedAttacker 2', this.currentAttacker, this.currentSpeedAttacker);\r\n\t\t\tif (this.currentSpeedAttacker === 0 || (this.currentSpeedAttacker === -1 && this.currentAttacker === 0)) {\r\n\t\t\t\tsimulateAttack(playerBoard, playerEntity, opponentBoard, opponentEntity, this.gameState);\r\n\t\t\t} else {\r\n\t\t\t\tsimulateAttack(opponentBoard, opponentEntity, playerBoard, playerEntity, this.gameState);\r\n\t\t\t}\r\n\r\n\t\t\t// Update the attacker indices in case there were some deaths\r\n\t\t\tif (playerBoard.some((entity) => entity.attackImmediately)) {\r\n\t\t\t\tthis.currentSpeedAttacker = 0;\r\n\t\t\t} else if (opponentBoard.some((entity) => entity.attackImmediately)) {\r\n\t\t\t\tthis.currentSpeedAttacker = 1;\r\n\t\t\t} else {\r\n\t\t\t\tthis.currentSpeedAttacker = -1;\r\n\t\t\t\tthis.currentAttacker = (this.currentAttacker + 1) % 2;\r\n\t\t\t}\r\n\t\t\tcounter++;\r\n\t\t\tif (counter > 400 && !this.hasShowShortCircuitWarning) {\r\n\t\t\t\tconsole.warn(\r\n\t\t\t\t\t'short-circuiting simulation, too many iterations',\r\n\t\t\t\t\tcounter,\r\n\t\t\t\t\t'\\n',\r\n\t\t\t\t\tstringifySimple(playerBoard, this.gameState.allCards),\r\n\t\t\t\t\t'\\n',\r\n\t\t\t\t\tstringifySimple(opponentBoard, this.gameState.allCards),\r\n\t\t\t\t);\r\n\t\t\t\tthis.hasShowShortCircuitWarning = true;\r\n\t\t\t\tbreak;\r\n\t\t\t\t// return null;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tprivate buildBoardTotalDamage(playerBoard: readonly BoardEntity[], teammateBoard?: BoardEntity[]): number {\r\n\t\tconst damageFromPlayerBoard = playerBoard\r\n\t\t\t.map((entity) =>\r\n\t\t\t\tgetEffectiveTechLevel(this.gameState.allCards.getCard(entity.cardId), this.gameState.allCards),\r\n\t\t\t)\r\n\t\t\t.reduce((a, b) => a + b, 0);\r\n\t\tconst numberOfTeamateMinionsToSummnon = 7 - playerBoard.length;\r\n\t\tconst damageFromTeammateBoard =\r\n\t\t\tteammateBoard\r\n\t\t\t\t?.slice(0, numberOfTeamateMinionsToSummnon)\r\n\t\t\t\t.map((entity) =>\r\n\t\t\t\t\tgetEffectiveTechLevel(this.gameState.allCards.getCard(entity.cardId), this.gameState.allCards),\r\n\t\t\t\t)\r\n\t\t\t\t.reduce((a, b) => a + b, 0) ?? 0;\r\n\t\treturn damageFromPlayerBoard + damageFromTeammateBoard;\r\n\t}\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"simulator.js","sourceRoot":"","sources":["../../src/simulation/simulator.ts"],"names":[],"mappings":";;;AAAA,iEAAqE;AAGrE,gDAA4C;AAE5C,oCAA2C;AAC3C,qCAA0C;AAC1C,mCAA+C;AAE/C,uEAAwE;AACxE,2DAA6D;AAG7D,MAAa,SAAS;IAOrB,YAA6B,SAAwB;QAAxB,cAAS,GAAT,SAAS,CAAe;QAL7C,yBAAoB,GAAG,CAAC,CAAC,CAAC;QAE1B,+BAA0B,GAAG,KAAK,CAAC;IAGa,CAAC;IAIlD,oBAAoB,CAAC,WAAwB,EAAE,aAA0B;;QAC/E,IAAI,WAAW,GAAkB,WAAW,CAAC,KAAK,CAAC;QACnD,IAAI,YAAY,GAAoB,WAAW,CAAC,MAAM,CAAC;QACvD,IAAI,aAAa,GAAkB,aAAa,CAAC,KAAK,CAAC;QACvD,IAAI,cAAc,GAAoB,aAAa,CAAC,MAAM,CAAC;QAC3D,OACC,CAAC,YAAY,CAAC,iBAAiB;YAC/B,CAAC,cAAc,CAAC,iBAAiB;YACjC,CAAC,CAAA,WAAW,aAAX,WAAW,uBAAX,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AAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CACvD,CAAC;gBACF,IAAI,CAAC,0BAA0B,GAAG,IAAI,CAAC;gBACvC,MAAM;aAEN;SACD;IACF,CAAC;IAEO,qBAAqB,CAAC,WAAmC,EAAE,aAA6B;;QAC/F,MAAM,qBAAqB,GAAG,WAAW;aACvC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CACf,IAAA,sCAAqB,EAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAC9F;aACA,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7B,MAAM,+BAA+B,GAAG,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC;QAC/D,MAAM,uBAAuB,GAC5B,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CACV,KAAK,CAAC,CAAC,EAAE,+BAA+B,EACzC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CACf,IAAA,sCAAqB,EAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAE9F,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,mCAAI,CAAC,CAAC;QACnC,OAAO,qBAAqB,GAAG,uBAAuB,CAAC;IACxD,CAAC;CACD;AAhOD,8BAgOC","sourcesContent":["import { getEffectiveTechLevel } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { debugState } from '../debug-state';\r\nimport { SingleSimulationResult } from '../single-simulation-result';\r\nimport { stringifySimple } from '../utils';\r\nimport { simulateAttack } from './attack';\r\nimport { clearStealthIfNeeded } from './auras';\r\nimport { FullGameState, PlayerState } from './internal-game-state';\r\nimport { handleStartOfCombat } from './start-of-combat/start-of-combat';\r\nimport { handleSummonsWhenSpace } from './summon-when-space';\r\n\r\n// New simulator should be instantiated for each match\r\nexport class Simulator {\r\n\tprivate currentAttacker: number;\r\n\tprivate currentSpeedAttacker = -1;\r\n\r\n\tprivate hasShowShortCircuitWarning = false;\r\n\r\n\t// It should come already initialized\r\n\tconstructor(private readonly gameState: FullGameState) {}\r\n\r\n\t// Here we suppose that the BoardEntity only contain at most the enchantments that are linked\r\n\t// to auras (so we probably should hand-filter that, since there are actually few auras)\r\n\tpublic simulateSingleBattle(playerState: PlayerState, opponentState: PlayerState): SingleSimulationResult {\r\n\t\tlet playerBoard: BoardEntity[] = playerState.board;\r\n\t\tlet playerEntity: BgsPlayerEntity = playerState.player;\r\n\t\tlet opponentBoard: BoardEntity[] = opponentState.board;\r\n\t\tlet opponentEntity: BgsPlayerEntity = opponentState.player;\r\n\t\twhile (\r\n\t\t\t!playerEntity.startOfCombatDone ||\r\n\t\t\t!opponentEntity.startOfCombatDone ||\r\n\t\t\t(playerBoard?.length > 0 && opponentBoard?.length > 0)\r\n\t\t) {\r\n\t\t\tthis.simulateSingleBattlePass(playerBoard, playerEntity, opponentBoard, opponentEntity);\r\n\r\n\t\t\t// The only case where there can only 0-attack minions on a board is when both boards\r\n\t\t\t// are that way (otherwise one side would kill the other)\r\n\t\t\tconst areBothBoards0Attack =\r\n\t\t\t\tplayerState.board.length > 0 &&\r\n\t\t\t\tplayerState.board.every((entity) => entity.attack === 0) &&\r\n\t\t\t\topponentState.board.length > 0 &&\r\n\t\t\t\topponentState.board.every((entity) => entity.attack === 0);\r\n\t\t\tconst isPlayerBoardEmpty = playerState.board.length === 0;\r\n\t\t\tconst isOpponentBoardEmpty = opponentState.board.length === 0;\r\n\t\t\tplayerBoard = areBothBoards0Attack || isPlayerBoardEmpty ? playerState.teammate?.board : playerState.board;\r\n\t\t\tplayerEntity =\r\n\t\t\t\tareBothBoards0Attack || isPlayerBoardEmpty ? playerState.teammate?.player : playerState.player;\r\n\t\t\topponentBoard =\r\n\t\t\t\tareBothBoards0Attack || isOpponentBoardEmpty ? opponentState.teammate?.board : opponentState.board;\r\n\t\t\topponentEntity =\r\n\t\t\t\tareBothBoards0Attack || isOpponentBoardEmpty ? opponentState.teammate?.player : opponentState.player;\r\n\t\t\t// So that gameState.player always refers to the active player\r\n\t\t\tif (isPlayerBoardEmpty) {\r\n\t\t\t\t// Reset deaths\r\n\t\t\t\tthis.gameState.sharedState.deaths = this.gameState.sharedState.deaths.filter(\r\n\t\t\t\t\t(e) => e.friendly !== this.gameState.gameState.player.player.friendly,\r\n\t\t\t\t);\r\n\t\t\t\tthis.gameState.gameState.player.teammate = {\r\n\t\t\t\t\tboard: this.gameState.gameState.player.board,\r\n\t\t\t\t\tplayer: this.gameState.gameState.player.player,\r\n\t\t\t\t};\r\n\t\t\t\tthis.gameState.gameState.player.player = playerEntity;\r\n\t\t\t\tthis.gameState.gameState.player.board = playerBoard;\r\n\r\n\t\t\t\t// const initialPlayer = this.gameState.gameState.playerInitial;\r\n\t\t\t\t// const initialPlayerTeammate = initialPlayer.teammate;\r\n\t\t\t}\r\n\t\t\tif (isOpponentBoardEmpty) {\r\n\t\t\t\t// Reset deaths\r\n\t\t\t\tthis.gameState.sharedState.deaths = this.gameState.sharedState.deaths.filter(\r\n\t\t\t\t\t(e) => e.friendly !== this.gameState.gameState.opponent.player.friendly,\r\n\t\t\t\t);\r\n\t\t\t\tthis.gameState.gameState.opponent.teammate = {\r\n\t\t\t\t\tboard: this.gameState.gameState.opponent.board,\r\n\t\t\t\t\tplayer: this.gameState.gameState.opponent.player,\r\n\t\t\t\t};\r\n\t\t\t\tthis.gameState.gameState.opponent.player = opponentEntity;\r\n\t\t\t\tthis.gameState.gameState.opponent.board = opponentBoard;\r\n\t\t\t}\r\n\r\n\t\t\tif (!playerEntity || !opponentEntity) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (\r\n\t\t\t(!playerBoard?.length && !opponentBoard?.length) ||\r\n\t\t\t// E.g. when both players have a 0-attack minion\r\n\t\t\t(playerBoard?.length > 0 && opponentBoard?.length > 0)\r\n\t\t) {\r\n\t\t\treturn {\r\n\t\t\t\tresult: 'tied',\r\n\t\t\t} as SingleSimulationResult;\r\n\t\t}\r\n\t\tif (!playerBoard?.length) {\r\n\t\t\tconst damage =\r\n\t\t\t\tthis.buildBoardTotalDamage(opponentBoard, this.gameState.gameState.opponent?.teammate?.board) +\r\n\t\t\t\topponentEntity.tavernTier;\r\n\t\t\tthis.gameState.spectator.registerOpponentAttack(playerBoard, opponentBoard, damage);\r\n\t\t\treturn {\r\n\t\t\t\tresult: 'lost',\r\n\t\t\t\tdamageDealt: damage,\r\n\t\t\t};\r\n\t\t}\r\n\t\tconst damage =\r\n\t\t\tthis.buildBoardTotalDamage(playerBoard, this.gameState.gameState.player?.teammate?.board) +\r\n\t\t\tplayerEntity.tavernTier;\r\n\t\tthis.gameState.spectator.registerPlayerAttack(playerBoard, opponentBoard, damage);\r\n\t\treturn {\r\n\t\t\tresult: 'won',\r\n\t\t\tdamageDealt: damage,\r\n\t\t};\r\n\t}\r\n\r\n\tprivate simulateSingleBattlePass(\r\n\t\tplayerBoard: BoardEntity[],\r\n\t\tplayerEntity: BgsPlayerEntity,\r\n\t\topponentBoard: BoardEntity[],\r\n\t\topponentEntity: BgsPlayerEntity,\r\n\t) {\r\n\t\tif (debugState?.active) {\r\n\t\t\tdebugState.onBattleStart();\r\n\t\t}\r\n\t\t// Start of combat happens only once, so we need to flag whether it has already happened for a\r\n\t\t// given player\r\n\t\tthis.gameState.spectator.registerStartOfCombat(playerBoard, opponentBoard, playerEntity, opponentEntity);\r\n\r\n\t\t// Who attacks first is decided by the game before the hero power comes into effect. However, the full board (with the generated minion)\r\n\t\t// is sent tothe simulator\r\n\t\t// But in fact, the first player decision takes into account that additional minion. See\r\n\t\t// https://replays.firestoneapp.com/?reviewId=ddbbbe93-464b-4400-8e8d-4abca8680a2e\r\n\t\tconst effectivePlayerBoardLength = playerBoard.length;\r\n\t\tconst effectiveOpponentBoardLength = opponentBoard.length;\r\n\t\tthis.currentAttacker =\r\n\t\t\teffectivePlayerBoardLength > effectiveOpponentBoardLength\r\n\t\t\t\t? 0\r\n\t\t\t\t: effectiveOpponentBoardLength > effectivePlayerBoardLength\r\n\t\t\t\t? 1\r\n\t\t\t\t: Math.round(Math.random());\r\n\t\tthis.gameState.sharedState.currentEntityId =\r\n\t\t\tMath.max(\r\n\t\t\t\t...playerBoard.map((entity) => entity.entityId),\r\n\t\t\t\t...opponentBoard.map((entity) => entity.entityId),\r\n\t\t\t\t...(playerEntity.hand?.map((entity) => entity.entityId) ?? []),\r\n\t\t\t\t...(opponentEntity.hand?.map((entity) => entity.entityId) ?? []),\r\n\t\t\t) + 1;\r\n\t\tconst suggestedNewCurrentAttacker = handleStartOfCombat(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tthis.currentAttacker,\r\n\t\t\tthis.gameState,\r\n\t\t);\r\n\t\tthis.currentAttacker = suggestedNewCurrentAttacker;\r\n\t\tlet counter = 0;\r\n\t\tif (debugState?.active) {\r\n\t\t\tthis.currentAttacker = debugState.forcedCurrentAttacker ?? this.currentAttacker;\r\n\t\t}\r\n\t\twhile (playerBoard.length > 0 && opponentBoard.length > 0) {\r\n\t\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, this.gameState);\r\n\t\t\tclearStealthIfNeeded(playerBoard, opponentBoard);\r\n\t\t\t// console.log('this.currentSpeedAttacker', this.currentAttacker);\r\n\t\t\t// If there are \"attack immediately\" minions, we keep the same player\r\n\t\t\t// We put it here so that it can kick in after the start of combat effects. However here we don't want\r\n\t\t\t// to change who attacks first, so we repeat that block again after all the attacks have been resolved\r\n\t\t\t// FIXME: This is not strictly correct - if there are multiple attack immediately\r\n\t\t\t// minions that spawn on both player sides it might get a bit more complex\r\n\t\t\t// but overall it works\r\n\t\t\t// Also, this doesn't work when there are several deathrattle competing\r\n\t\t\t// to know who triggers first. See the second test case of the scallywag.test.ts\r\n\t\t\t// that is not handled properly today (the attack should in some cases happen before\r\n\t\t\t// the other deathrattle procs)\r\n\t\t\tif (playerBoard.some((entity) => entity.attackImmediately)) {\r\n\t\t\t\tthis.currentSpeedAttacker = 0;\r\n\t\t\t} else if (opponentBoard.some((entity) => entity.attackImmediately)) {\r\n\t\t\t\tthis.currentSpeedAttacker = 1;\r\n\t\t\t} else {\r\n\t\t\t\tthis.currentSpeedAttacker = -1;\r\n\t\t\t}\r\n\t\t\tif (\r\n\t\t\t\tplayerBoard.filter((e) => e.attack > 0).length === 0 &&\r\n\t\t\t\topponentBoard.filter((e) => e.attack > 0).length === 0\r\n\t\t\t) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\t// console.log('this.currentSpeedAttacker 2', this.currentAttacker, this.currentSpeedAttacker);\r\n\t\t\tif (this.currentSpeedAttacker === 0 || (this.currentSpeedAttacker === -1 && this.currentAttacker === 0)) {\r\n\t\t\t\tsimulateAttack(playerBoard, playerEntity, opponentBoard, opponentEntity, this.gameState);\r\n\t\t\t} else {\r\n\t\t\t\tsimulateAttack(opponentBoard, opponentEntity, playerBoard, playerEntity, this.gameState);\r\n\t\t\t}\r\n\r\n\t\t\t// Update the attacker indices in case there were some deaths\r\n\t\t\tif (playerBoard.some((entity) => entity.attackImmediately)) {\r\n\t\t\t\tthis.currentSpeedAttacker = 0;\r\n\t\t\t} else if (opponentBoard.some((entity) => entity.attackImmediately)) {\r\n\t\t\t\tthis.currentSpeedAttacker = 1;\r\n\t\t\t} else {\r\n\t\t\t\tthis.currentSpeedAttacker = -1;\r\n\t\t\t\tthis.currentAttacker = (this.currentAttacker + 1) % 2;\r\n\t\t\t}\r\n\t\t\tcounter++;\r\n\t\t\tif (counter > 400 && !this.hasShowShortCircuitWarning) {\r\n\t\t\t\tconsole.warn(\r\n\t\t\t\t\t'short-circuiting simulation, too many iterations',\r\n\t\t\t\t\tcounter,\r\n\t\t\t\t\t'\\n',\r\n\t\t\t\t\tstringifySimple(playerBoard, this.gameState.allCards),\r\n\t\t\t\t\t'\\n',\r\n\t\t\t\t\tstringifySimple(opponentBoard, this.gameState.allCards),\r\n\t\t\t\t);\r\n\t\t\t\tthis.hasShowShortCircuitWarning = true;\r\n\t\t\t\tbreak;\r\n\t\t\t\t// return null;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tprivate buildBoardTotalDamage(playerBoard: readonly BoardEntity[], teammateBoard?: BoardEntity[]): number {\r\n\t\tconst damageFromPlayerBoard = playerBoard\r\n\t\t\t.map((entity) =>\r\n\t\t\t\tgetEffectiveTechLevel(this.gameState.allCards.getCard(entity.cardId), this.gameState.allCards),\r\n\t\t\t)\r\n\t\t\t.reduce((a, b) => a + b, 0);\r\n\t\tconst numberOfTeamateMinionsToSummnon = 7 - playerBoard.length;\r\n\t\tconst damageFromTeammateBoard =\r\n\t\t\tteammateBoard\r\n\t\t\t\t?.slice(0, numberOfTeamateMinionsToSummnon)\r\n\t\t\t\t.map((entity) =>\r\n\t\t\t\t\tgetEffectiveTechLevel(this.gameState.allCards.getCard(entity.cardId), this.gameState.allCards),\r\n\t\t\t\t)\r\n\t\t\t\t.reduce((a, b) => a + b, 0) ?? 0;\r\n\t\treturn damageFromPlayerBoard + damageFromTeammateBoard;\r\n\t}\r\n}\r\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type StartOfCombatPhase = 'QuestReward' | 'Anomalies' | 'Trinket' | 'PreCombatHeroPower' | 'IllidanHeroPower' | 'HeroPower' | 'Secret' | 'Minion';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phases.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/phases.ts"],"names":[],"mappings":"","sourcesContent":["export type StartOfCombatPhase =\r\n\t| 'QuestReward'\r\n\t| 'Anomalies'\r\n\t| 'Trinket'\r\n\t| 'PreCombatHeroPower'\r\n\t| 'IllidanHeroPower'\r\n\t| 'HeroPower'\r\n\t| 'Secret'\r\n\t| 'Minion';\r\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { BoardTrinket } from '../../bgs-player-entity';
|
|
2
|
+
import { BoardEntity } from '../../board-entity';
|
|
3
|
+
import { SoCInput } from './start-of-combat-input';
|
|
4
|
+
export declare const performStartOfCombatAction: (cardId: string, entity: BoardEntity | BoardTrinket, input: SoCInput) => boolean;
|