@firestone-hs/simulate-bgs-battle 1.1.737 → 1.1.739
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 +5 -0
- package/dist/bgs-player-entity.js.map +1 -1
- package/dist/cards/card.interface.d.ts +4 -0
- package/dist/cards/card.interface.js +4 -2
- package/dist/cards/card.interface.js.map +1 -1
- package/dist/cards/cards-data.d.ts +1 -0
- package/dist/cards/cards-data.js +71 -36
- package/dist/cards/cards-data.js.map +1 -1
- package/dist/cards/impl/_card-mappings.js +4 -0
- package/dist/cards/impl/_card-mappings.js.map +1 -1
- package/dist/cards/impl/enchantments/demonology.d.ts +2 -0
- package/dist/cards/impl/enchantments/demonology.js +14 -0
- package/dist/cards/impl/enchantments/demonology.js.map +1 -0
- package/dist/cards/impl/enchantments/fresh-perspective.d.ts +2 -0
- package/dist/cards/impl/enchantments/fresh-perspective.js +15 -0
- package/dist/cards/impl/enchantments/fresh-perspective.js.map +1 -0
- package/dist/cards/impl/minion/abyssal-bruiser.js +8 -5
- package/dist/cards/impl/minion/abyssal-bruiser.js.map +1 -1
- package/dist/cards/impl/minion/beetle.js +2 -1
- package/dist/cards/impl/minion/beetle.js.map +1 -1
- package/dist/cards/impl/minion/bellowing-tyrant.js +2 -1
- package/dist/cards/impl/minion/bellowing-tyrant.js.map +1 -1
- package/dist/cards/impl/minion/falling-sky-golem.js +2 -1
- package/dist/cards/impl/minion/falling-sky-golem.js.map +1 -1
- package/dist/cards/impl/minion/flourishing-frostling.js +4 -5
- package/dist/cards/impl/minion/flourishing-frostling.js.map +1 -1
- package/dist/cards/impl/minion/malorne.js +2 -1
- package/dist/cards/impl/minion/malorne.js.map +1 -1
- package/dist/cards/impl/minion/maritime-extortionist.js +2 -1
- package/dist/cards/impl/minion/maritime-extortionist.js.map +1 -1
- package/dist/cards/impl/minion/raptor-elder.js +2 -1
- package/dist/cards/impl/minion/raptor-elder.js.map +1 -1
- package/dist/cards/impl/minion/showy-cyclist.d.ts +2 -2
- package/dist/cards/impl/minion/showy-cyclist.js +1 -0
- package/dist/cards/impl/minion/showy-cyclist.js.map +1 -1
- package/dist/cards/impl/minion/spellbound-soul.js +2 -1
- package/dist/cards/impl/minion/spellbound-soul.js.map +1 -1
- package/dist/cards/impl/minion/timewarped-recycler.js +4 -0
- package/dist/cards/impl/minion/timewarped-recycler.js.map +1 -1
- package/dist/cards/impl/minion/timewarped-traveler.js +7 -1
- package/dist/cards/impl/minion/timewarped-traveler.js.map +1 -1
- package/dist/cards/impl/trinket/soul-fermenter.js +1 -1
- package/dist/cards/impl/trinket/soul-fermenter.js.map +1 -1
- package/dist/input-sanitation.js +12 -9
- package/dist/input-sanitation.js.map +1 -1
- package/dist/mechanics/rally.js +6 -3
- package/dist/mechanics/rally.js.map +1 -1
- package/dist/simulate-bgs-battle.d.ts +8 -0
- package/dist/simulate-bgs-battle.js +124 -21
- package/dist/simulate-bgs-battle.js.map +1 -1
- package/dist/simulation/after-attack.d.ts +1 -1
- package/dist/simulation/after-attack.js +21 -21
- package/dist/simulation/after-attack.js.map +1 -1
- package/dist/simulation/attack.d.ts +1 -0
- package/dist/simulation/attack.js +1 -1
- package/dist/simulation/attack.js.map +1 -1
- package/dist/simulation/auras.js +24 -6
- package/dist/simulation/auras.js.map +1 -1
- package/dist/simulation/combat-profile.d.ts +13 -0
- package/dist/simulation/combat-profile.js +37 -0
- package/dist/simulation/combat-profile.js.map +1 -0
- package/dist/simulation/death-effects.js +16 -0
- package/dist/simulation/death-effects.js.map +1 -1
- package/dist/simulation/internal-game-state.d.ts +1 -0
- package/dist/simulation/internal-game-state.js.map +1 -1
- package/dist/simulation/reborn.js +6 -0
- package/dist/simulation/reborn.js.map +1 -1
- package/dist/simulation/simulator.js +88 -20
- package/dist/simulation/simulator.js.map +1 -1
- package/dist/simulation/spectator/spectator.d.ts +1 -0
- package/dist/simulation/spectator/spectator.js +22 -6
- package/dist/simulation/spectator/spectator.js.map +1 -1
- package/dist/simulation/start-of-combat/soc-action-processor.js +10 -0
- package/dist/simulation/start-of-combat/soc-action-processor.js.map +1 -1
- package/dist/simulation/utils/entity-utils.d.ts +1 -0
- package/dist/simulation/utils/entity-utils.js +5 -1
- package/dist/simulation/utils/entity-utils.js.map +1 -1
- package/dist/single-simulation-result.d.ts +36 -0
- package/dist/single-simulation-result.js.map +1 -1
- package/dist/utils.js +17 -18
- package/dist/utils.js.map +1 -1
- package/package.json +2 -2
|
@@ -7,6 +7,7 @@ const utils_1 = require("../services/utils");
|
|
|
7
7
|
const deathrattle_spawns_1 = require("./deathrattle-spawns");
|
|
8
8
|
const spawns_1 = require("./spawns");
|
|
9
9
|
const stats_1 = require("./stats");
|
|
10
|
+
const entity_utils_1 = require("./utils/entity-utils");
|
|
10
11
|
const applyAfterDeathEffects = (deadEntity, deadEntityIndexFromRight, boardWithDeadEntity, boardWithDeadEntityHero, otherBoard, otherBoardHero, gameState) => {
|
|
11
12
|
const allSpawns = [];
|
|
12
13
|
const spawnsFromSecrets = handleAfterMinionDeathEffects(deadEntity, deadEntityIndexFromRight, boardWithDeadEntity, boardWithDeadEntityHero, otherBoard, otherBoardHero, gameState);
|
|
@@ -18,12 +19,14 @@ exports.applyAfterDeathEffects = applyAfterDeathEffects;
|
|
|
18
19
|
const handleAfterMinionDeathEffects = (deadEntity, deadEntityIndexFromRight, boardWithDeadEntity, boardWithDeadEntityHero, otherBoard, otherBoardHero, gameState) => {
|
|
19
20
|
var _a, _b;
|
|
20
21
|
const allSpawns = [];
|
|
22
|
+
const boardBeforeProcs = [...boardWithDeadEntity];
|
|
21
23
|
for (const entity of boardWithDeadEntity) {
|
|
22
24
|
const impl = _card_mappings_1.cardMappings[entity.cardId];
|
|
23
25
|
if ((0, card_interface_1.hasOnAfterFriendlyMinionDeath)(impl)) {
|
|
24
26
|
impl.onAfterFriendlyMinionDeath(entity, {
|
|
25
27
|
deadEntity,
|
|
26
28
|
board: boardWithDeadEntity,
|
|
29
|
+
boardBeforeProcs,
|
|
27
30
|
hero: boardWithDeadEntityHero,
|
|
28
31
|
otherBoard,
|
|
29
32
|
otherHero: otherBoardHero,
|
|
@@ -37,6 +40,7 @@ const handleAfterMinionDeathEffects = (deadEntity, deadEntityIndexFromRight, boa
|
|
|
37
40
|
trinketImpl.onAfterFriendlyMinionDeath(trinket, {
|
|
38
41
|
deadEntity,
|
|
39
42
|
board: boardWithDeadEntity,
|
|
43
|
+
boardBeforeProcs,
|
|
40
44
|
hero: boardWithDeadEntityHero,
|
|
41
45
|
otherBoard,
|
|
42
46
|
otherHero: otherBoardHero,
|
|
@@ -55,6 +59,12 @@ const handleAfterMinionDeathEffects = (deadEntity, deadEntityIndexFromRight, boa
|
|
|
55
59
|
secret.triggered = true;
|
|
56
60
|
const redemptionSpawns = (0, deathrattle_spawns_1.spawnEntities)(deadEntity.cardId, 1, boardWithDeadEntity, boardWithDeadEntityHero, otherBoard, otherBoardHero, gameState, deadEntity.friendly, false, false, true);
|
|
57
61
|
redemptionSpawns[0].health = 1;
|
|
62
|
+
const rebornImpl = _card_mappings_1.cardMappings[redemptionSpawns[0].cardId];
|
|
63
|
+
if ((0, card_interface_1.hasRebornSelfAttributeTransfer)(rebornImpl)) {
|
|
64
|
+
rebornImpl.rebornSelfAttributeTransfer.forEach((attribute) => {
|
|
65
|
+
(0, entity_utils_1.copyAttribute)(redemptionSpawns[0], deadEntity, attribute);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
58
68
|
allSpawns.push(...redemptionSpawns);
|
|
59
69
|
gameState.spectator.registerPowerTarget(secret, redemptionSpawns[0], boardWithDeadEntity, null, null);
|
|
60
70
|
break;
|
|
@@ -68,6 +78,12 @@ const handleAfterMinionDeathEffects = (deadEntity, deadEntityIndexFromRight, boa
|
|
|
68
78
|
spawn.maxAttack = deadEntity.maxAttack;
|
|
69
79
|
spawn.enchantments = deadEntity.enchantments;
|
|
70
80
|
spawn.divineShield = deadEntity.hadDivineShield;
|
|
81
|
+
const rebornImpl = _card_mappings_1.cardMappings[spawn.cardId];
|
|
82
|
+
if ((0, card_interface_1.hasRebornSelfAttributeTransfer)(rebornImpl)) {
|
|
83
|
+
rebornImpl.rebornSelfAttributeTransfer.forEach((attribute) => {
|
|
84
|
+
(0, entity_utils_1.copyAttribute)(spawn, deadEntity, attribute);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
71
87
|
}
|
|
72
88
|
allSpawns.push(...betterRedemptionSpawns);
|
|
73
89
|
gameState.spectator.registerPowerTarget(secret, betterRedemptionSpawns[0], boardWithDeadEntity, null, null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"death-effects.js","sourceRoot":"","sources":["../../src/simulation/death-effects.ts"],"names":[],"mappings":";;;AAEA,4DAAwE;AACxE,iEAA4D;AAE5D,6CAAoD;AACpD,6DAAqD;AAErD,qCAA+C;AAC/C,mCAAsC;AAE/B,MAAM,sBAAsB,GAAG,CACrC,UAAuB,EACvB,wBAAgC,EAChC,mBAAkC,EAClC,uBAAwC,EACxC,UAAyB,EACzB,cAA+B,EAC/B,SAAwB,EACR,EAAE;IAClB,MAAM,SAAS,GAAG,EAAE,CAAC;IAErB,MAAM,iBAAiB,GAAG,6BAA6B,CACtD,UAAU,EACV,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,UAAU,EACV,cAAc,EACd,SAAS,CACT,CAAC;IACF,SAAS,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC;IACrC,IAAA,4BAAmB,EAClB,SAAS,EACT,mBAAmB,EACnB,uBAAuB,EACvB,UAAU,EACV,wBAAwB,EACxB,UAAU,EACV,cAAc,EACd,SAAS,CACT,CAAC;IAEF,OAAO,SAAS,CAAC;AAClB,CAAC,CAAC;AAjCW,QAAA,sBAAsB,0BAiCjC;AAEF,MAAM,6BAA6B,GAAG,CACrC,UAAuB,EACvB,wBAAgC,EAChC,mBAAkC,EAClC,uBAAwC,EACxC,UAAyB,EACzB,cAA+B,EAC/B,SAAwB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AAC;gBAC1C,SAAS,CAAC,SAAS,CAAC,mBAAmB,CACtC,MAAM,EACN,sBAAsB,CAAC,CAAC,CAAC,EACzB,mBAAmB,EACnB,IAAI,EACJ,IAAI,CACJ,CAAC;gBACF,MAAM;YACP;gBACC,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC;gBACxB,MAAM,UAAU,GAAG,SAAS,CAAC,SAAS,CAAC,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBACzE,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC,4BAA4B,CAAC,UAAU,CAAC,CAAC;gBAC/E,MAAM,YAAY,GAAG,IAAA,kCAAa,EACjC,SAAS,EACT,CAAC,EACD,mBAAmB,EACnB,uBAAuB,EACvB,UAAU,EACV,cAAc,EACd,SAAS,EACT,UAAU,CAAC,QAAQ,EACnB,KAAK,EACL,KAAK,EACL,IAAI,CACJ,CAAC;gBACF,SAAS,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,CAAC;gBAChC,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,mBAAmB,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;gBAClG,MAAM;SACP;KACD;IACD,OAAO,SAAS,CAAC;AAClB,CAAC,CAAC;AAEK,MAAM,mBAAmB,GAAG,CAClC,UAAuB,EACvB,wBAAgC,EAChC,mBAAkC,EAClC,uBAAwC,EACxC,UAAyB,EACzB,cAA+B,EAC/B,SAAwB,EACvB,EAAE;IAEH,OAAO,EAAE,CAAC;AACX,CAAC,CAAC;AAXW,QAAA,mBAAmB,uBAW9B","sourcesContent":["import { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { hasOnAfterFriendlyMinionDeath } from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { pickRandomAlive } from '../services/utils';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { performEntitySpawns } from './spawns';\r\nimport { modifyStats } from './stats';\r\n\r\nexport const applyAfterDeathEffects = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): BoardEntity[] => {\r\n\tconst allSpawns = [];\r\n\r\n\tconst spawnsFromSecrets = handleAfterMinionDeathEffects(\r\n\t\tdeadEntity,\r\n\t\tdeadEntityIndexFromRight,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\totherBoard,\r\n\t\totherBoardHero,\r\n\t\tgameState,\r\n\t);\r\n\tallSpawns.push(...spawnsFromSecrets);\r\n\tperformEntitySpawns(\r\n\t\tallSpawns,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tdeadEntity,\r\n\t\tdeadEntityIndexFromRight,\r\n\t\totherBoard,\r\n\t\totherBoardHero,\r\n\t\tgameState,\r\n\t);\r\n\r\n\treturn allSpawns;\r\n};\r\n\r\nconst handleAfterMinionDeathEffects = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): BoardEntity[] => {\r\n\tconst allSpawns = [];\r\n\r\n\t// TODO: move this to an \"after minion dies\" phase, instead of \"whenever minion dies\"\r\n\tfor (const entity of boardWithDeadEntity) {\r\n\t\tconst impl = cardMappings[entity.cardId];\r\n\t\tif (hasOnAfterFriendlyMinionDeath(impl)) {\r\n\t\t\timpl.onAfterFriendlyMinionDeath(entity, {\r\n\t\t\t\tdeadEntity,\r\n\t\t\t\tboard: boardWithDeadEntity,\r\n\t\t\t\thero: boardWithDeadEntityHero,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherHero: otherBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const trinket of boardWithDeadEntityHero.trinkets ?? []) {\r\n\t\tconst trinketImpl = cardMappings[trinket.cardId];\r\n\t\tif (hasOnAfterFriendlyMinionDeath(trinketImpl)) {\r\n\t\t\ttrinketImpl.onAfterFriendlyMinionDeath(trinket, {\r\n\t\t\t\tdeadEntity,\r\n\t\t\t\tboard: boardWithDeadEntity,\r\n\t\t\t\thero: boardWithDeadEntityHero,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherHero: otherBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const secret of (boardWithDeadEntityHero.secrets ?? []).filter((s) => !s.triggered)) {\r\n\t\tswitch (secret.cardId) {\r\n\t\t\tcase CardIds.Avenge_TB_Bacon_Secrets_08:\r\n\t\t\t\tsecret.triggered = true;\r\n\t\t\t\tconst avengeTarget = pickRandomAlive(boardWithDeadEntity);\r\n\t\t\t\tmodifyStats(avengeTarget, secret, 3, 2, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Redemption_TB_Bacon_Secrets_10:\r\n\t\t\t\tsecret.triggered = true;\r\n\t\t\t\tconst redemptionSpawns = spawnEntities(\r\n\t\t\t\t\tdeadEntity.cardId,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t\t// { ...newSpawn } as BoardEntity,\r\n\t\t\t\t);\r\n\t\t\t\tredemptionSpawns[0].health = 1;\r\n\t\t\t\tallSpawns.push(...redemptionSpawns);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(secret, redemptionSpawns[0], boardWithDeadEntity, null, null);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Redemption_BetterRedemption_TB_Bacon_Secrets_10b:\r\n\t\t\t\tsecret.triggered = true;\r\n\t\t\t\tconst betterRedemptionSpawns = spawnEntities(\r\n\t\t\t\t\tdeadEntity.cardId,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t);\r\n\t\t\t\tfor (const spawn of betterRedemptionSpawns) {\r\n\t\t\t\t\tspawn.health = deadEntity.maxHealth;\r\n\t\t\t\t\tspawn.maxHealth = deadEntity.maxHealth;\r\n\t\t\t\t\tspawn.attack = deadEntity.attack;\r\n\t\t\t\t\tspawn.maxAttack = deadEntity.maxAttack;\r\n\t\t\t\t\tspawn.enchantments = deadEntity.enchantments;\r\n\t\t\t\t\tspawn.divineShield = deadEntity.hadDivineShield;\r\n\t\t\t\t}\r\n\t\t\t\tallSpawns.push(...betterRedemptionSpawns);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tsecret,\r\n\t\t\t\t\tbetterRedemptionSpawns[0],\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Effigy_TB_Bacon_Secrets_05:\r\n\t\t\t\tsecret.triggered = true;\r\n\t\t\t\tconst minionTier = gameState.cardsData.getTavernLevel(deadEntity.cardId);\r\n\t\t\t\tconst newMinion = gameState.cardsData.getRandomMinionForTavernTier(minionTier);\r\n\t\t\t\tconst effigySpawns = spawnEntities(\r\n\t\t\t\t\tnewMinion,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t);\r\n\t\t\t\tallSpawns.push(...effigySpawns);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(secret, effigySpawns[0], boardWithDeadEntity, null, null);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn allSpawns;\r\n};\r\n\r\nexport const applyOnDeathEffects = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\t// Nothing yet\r\n\treturn [];\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"death-effects.js","sourceRoot":"","sources":["../../src/simulation/death-effects.ts"],"names":[],"mappings":";;;AAEA,4DAAwG;AACxG,iEAA4D;AAE5D,6CAAoD;AACpD,6DAAqD;AAErD,qCAA+C;AAC/C,mCAAsC;AACtC,uDAAqD;AAE9C,MAAM,sBAAsB,GAAG,CACrC,UAAuB,EACvB,wBAAgC,EAChC,mBAAkC,EAClC,uBAAwC,EACxC,UAAyB,EACzB,cAA+B,EAC/B,SAAwB,EACR,EAAE;IAClB,MAAM,SAAS,GAA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G,sBAAsB,CAAC,CAAC;gBAC1C,SAAS,CAAC,SAAS,CAAC,mBAAmB,CACtC,MAAM,EACN,sBAAsB,CAAC,CAAC,CAAC,EACzB,mBAAmB,EACnB,IAAI,EACJ,IAAI,CACJ,CAAC;gBACF,MAAM;YACP;gBACC,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC;gBACxB,MAAM,UAAU,GAAG,SAAS,CAAC,SAAS,CAAC,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBACzE,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC,4BAA4B,CAAC,UAAU,CAAC,CAAC;gBAC/E,MAAM,YAAY,GAAG,IAAA,kCAAa,EACjC,SAAS,EACT,CAAC,EACD,mBAAmB,EACnB,uBAAuB,EACvB,UAAU,EACV,cAAc,EACd,SAAS,EACT,UAAU,CAAC,QAAQ,EACnB,KAAK,EACL,KAAK,EACL,IAAI,CACJ,CAAC;gBACF,SAAS,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,CAAC;gBAChC,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,mBAAmB,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;gBAClG,MAAM;SACP;KACD;IACD,OAAO,SAAS,CAAC;AAClB,CAAC,CAAC;AAEK,MAAM,mBAAmB,GAAG,CAClC,UAAuB,EACvB,wBAAgC,EAChC,mBAAkC,EAClC,uBAAwC,EACxC,UAAyB,EACzB,cAA+B,EAC/B,SAAwB,EACvB,EAAE;IAEH,OAAO,EAAE,CAAC;AACX,CAAC,CAAC;AAXW,QAAA,mBAAmB,uBAW9B","sourcesContent":["import { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { hasOnAfterFriendlyMinionDeath, hasRebornSelfAttributeTransfer } from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { pickRandomAlive } from '../services/utils';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { performEntitySpawns } from './spawns';\r\nimport { modifyStats } from './stats';\r\nimport { copyAttribute } from './utils/entity-utils';\r\n\r\nexport const applyAfterDeathEffects = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): BoardEntity[] => {\r\n\tconst allSpawns = [];\r\n\r\n\tconst spawnsFromSecrets = handleAfterMinionDeathEffects(\r\n\t\tdeadEntity,\r\n\t\tdeadEntityIndexFromRight,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\totherBoard,\r\n\t\totherBoardHero,\r\n\t\tgameState,\r\n\t);\r\n\tallSpawns.push(...spawnsFromSecrets);\r\n\tperformEntitySpawns(\r\n\t\tallSpawns,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tdeadEntity,\r\n\t\tdeadEntityIndexFromRight,\r\n\t\totherBoard,\r\n\t\totherBoardHero,\r\n\t\tgameState,\r\n\t);\r\n\r\n\treturn allSpawns;\r\n};\r\n\r\nconst handleAfterMinionDeathEffects = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): BoardEntity[] => {\r\n\tconst allSpawns = [];\r\n\r\n\t// TODO: move this to an \"after minion dies\" phase, instead of \"whenever minion dies\"\r\n\tconst boardBeforeProcs = [...boardWithDeadEntity];\r\n\tfor (const entity of boardWithDeadEntity) {\r\n\t\tconst impl = cardMappings[entity.cardId];\r\n\t\tif (hasOnAfterFriendlyMinionDeath(impl)) {\r\n\t\t\timpl.onAfterFriendlyMinionDeath(entity, {\r\n\t\t\t\tdeadEntity,\r\n\t\t\t\tboard: boardWithDeadEntity,\r\n\t\t\t\tboardBeforeProcs,\r\n\t\t\t\thero: boardWithDeadEntityHero,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherHero: otherBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const trinket of boardWithDeadEntityHero.trinkets ?? []) {\r\n\t\tconst trinketImpl = cardMappings[trinket.cardId];\r\n\t\tif (hasOnAfterFriendlyMinionDeath(trinketImpl)) {\r\n\t\t\ttrinketImpl.onAfterFriendlyMinionDeath(trinket, {\r\n\t\t\t\tdeadEntity,\r\n\t\t\t\tboard: boardWithDeadEntity,\r\n\t\t\t\tboardBeforeProcs,\r\n\t\t\t\thero: boardWithDeadEntityHero,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherHero: otherBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const secret of (boardWithDeadEntityHero.secrets ?? []).filter((s) => !s.triggered)) {\r\n\t\tswitch (secret.cardId) {\r\n\t\t\tcase CardIds.Avenge_TB_Bacon_Secrets_08:\r\n\t\t\t\tsecret.triggered = true;\r\n\t\t\t\tconst avengeTarget = pickRandomAlive(boardWithDeadEntity);\r\n\t\t\t\tmodifyStats(avengeTarget, secret, 3, 2, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Redemption_TB_Bacon_Secrets_10:\r\n\t\t\t\tsecret.triggered = true;\r\n\t\t\t\tconst redemptionSpawns = spawnEntities(\r\n\t\t\t\t\tdeadEntity.cardId,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t\t// { ...newSpawn } as BoardEntity,\r\n\t\t\t\t);\r\n\t\t\t\tredemptionSpawns[0].health = 1;\r\n\t\t\t\t// I don't like duplicating this logic\r\n\t\t\t\tconst rebornImpl = cardMappings[redemptionSpawns[0].cardId];\r\n\t\t\t\tif (hasRebornSelfAttributeTransfer(rebornImpl)) {\r\n\t\t\t\t\trebornImpl.rebornSelfAttributeTransfer.forEach((attribute: keyof BoardEntity) => {\r\n\t\t\t\t\t\tcopyAttribute(redemptionSpawns[0], deadEntity, attribute);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\tallSpawns.push(...redemptionSpawns);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(secret, redemptionSpawns[0], boardWithDeadEntity, null, null);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Redemption_BetterRedemption_TB_Bacon_Secrets_10b:\r\n\t\t\t\tsecret.triggered = true;\r\n\t\t\t\tconst betterRedemptionSpawns = spawnEntities(\r\n\t\t\t\t\tdeadEntity.cardId,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t);\r\n\t\t\t\tfor (const spawn of betterRedemptionSpawns) {\r\n\t\t\t\t\tspawn.health = deadEntity.maxHealth;\r\n\t\t\t\t\tspawn.maxHealth = deadEntity.maxHealth;\r\n\t\t\t\t\tspawn.attack = deadEntity.attack;\r\n\t\t\t\t\tspawn.maxAttack = deadEntity.maxAttack;\r\n\t\t\t\t\tspawn.enchantments = deadEntity.enchantments;\r\n\t\t\t\t\tspawn.divineShield = deadEntity.hadDivineShield;\r\n\t\t\t\t\tconst rebornImpl = cardMappings[spawn.cardId];\r\n\t\t\t\t\tif (hasRebornSelfAttributeTransfer(rebornImpl)) {\r\n\t\t\t\t\t\trebornImpl.rebornSelfAttributeTransfer.forEach((attribute: keyof BoardEntity) => {\r\n\t\t\t\t\t\t\tcopyAttribute(spawn, deadEntity, attribute);\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\tallSpawns.push(...betterRedemptionSpawns);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tsecret,\r\n\t\t\t\t\tbetterRedemptionSpawns[0],\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Effigy_TB_Bacon_Secrets_05:\r\n\t\t\t\tsecret.triggered = true;\r\n\t\t\t\tconst minionTier = gameState.cardsData.getTavernLevel(deadEntity.cardId);\r\n\t\t\t\tconst newMinion = gameState.cardsData.getRandomMinionForTavernTier(minionTier);\r\n\t\t\t\tconst effigySpawns = spawnEntities(\r\n\t\t\t\t\tnewMinion,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t);\r\n\t\t\t\tallSpawns.push(...effigySpawns);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(secret, effigySpawns[0], boardWithDeadEntity, null, null);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn allSpawns;\r\n};\r\n\r\nexport const applyOnDeathEffects = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\t// Nothing yet\r\n\treturn [];\r\n};\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-game-state.js","sourceRoot":"","sources":["../../src/simulation/internal-game-state.ts"],"names":[],"mappings":"","sourcesContent":["import { AllCardsService, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardsData } from '../cards/cards-data';\r\nimport { SharedState } from './shared-state';\r\nimport { Spectator } from './spectator/spectator';\r\n\r\nexport interface FullGameState {\r\n\tallCards: AllCardsService;\r\n\tcardsData: CardsData;\r\n\tspectator: Spectator;\r\n\tsharedState: SharedState;\r\n\tcurrentTurn: number;\r\n\t/** Heroes still alive in the lobby; used when applyDamageCap is set. */\r\n\tnumberOfPlayersAlive?: number;\r\n\t/** When true, apply the Battlegrounds lobby damage cap. Default off. */\r\n\tapplyDamageCap?: boolean;\r\n\t/** When true, Ice Block can prevent end-of-combat face damage. Default off. */\r\n\tapplyIceBlock?: boolean;\r\n\tvalidTribes: readonly Race[];\r\n\tanomalies: readonly string[];\r\n\tgameState: GameState;\r\n}\r\n\r\nexport interface GameState {\r\n\tplayer: PlayerState;\r\n\topponent: PlayerState;\r\n\tplayerInitial: PlayerState;\r\n\topponentInitial: PlayerState;\r\n}\r\n\r\nexport interface PlayerState {\r\n\tboard: BoardEntity[];\r\n\tplayer: BgsPlayerEntity;\r\n\tteammate?: PlayerState;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"internal-game-state.js","sourceRoot":"","sources":["../../src/simulation/internal-game-state.ts"],"names":[],"mappings":"","sourcesContent":["import { AllCardsService, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardsData } from '../cards/cards-data';\r\nimport { SharedState } from './shared-state';\r\nimport { Spectator } from './spectator/spectator';\r\n\r\nexport interface FullGameState {\r\n\tallCards: AllCardsService;\r\n\tcardsData: CardsData;\r\n\tspectator: Spectator;\r\n\tsharedState: SharedState;\r\n\tcurrentTurn: number;\r\n\t/** Heroes still alive in the lobby; used when applyDamageCap is set. */\r\n\tnumberOfPlayersAlive?: number;\r\n\t/** When true, apply the Battlegrounds lobby damage cap. Default off. */\r\n\tapplyDamageCap?: boolean;\r\n\t/** When true, Ice Block can prevent end-of-combat face damage. Default off. */\r\n\tapplyIceBlock?: boolean;\r\n\t/** True when the battle input had a teammate board (Duos). Do not infer from in-fight teammate shells. */\r\n\tisDuos?: boolean;\r\n\tvalidTribes: readonly Race[];\r\n\tanomalies: readonly string[];\r\n\tgameState: GameState;\r\n}\r\n\r\nexport interface GameState {\r\n\tplayer: PlayerState;\r\n\topponent: PlayerState;\r\n\tplayerInitial: PlayerState;\r\n\topponentInitial: PlayerState;\r\n}\r\n\r\nexport interface PlayerState {\r\n\tboard: BoardEntity[];\r\n\tplayer: BgsPlayerEntity;\r\n\tteammate?: PlayerState;\r\n}\r\n"]}
|
|
@@ -8,6 +8,7 @@ const sinrunner_blanchy_1 = require("../cards/impl/minion/sinrunner-blanchy");
|
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
9
|
const deathrattle_spawns_1 = require("./deathrattle-spawns");
|
|
10
10
|
const spawns_1 = require("./spawns");
|
|
11
|
+
const entity_utils_1 = require("./utils/entity-utils");
|
|
11
12
|
const handleRebornForEntity = (boardWithKilledMinion, boardWithKilledMinionHero, deadEntity, deadMinionIndexFromRight, opponentBoard, opponentBoardHero, gameState) => {
|
|
12
13
|
var _a, _b;
|
|
13
14
|
const numberOfReborns = 1;
|
|
@@ -45,6 +46,11 @@ const handleRebornForEntity = (boardWithKilledMinion, boardWithKilledMinionHero,
|
|
|
45
46
|
}
|
|
46
47
|
for (const entity of entitiesFromReborn) {
|
|
47
48
|
const rebornImpl = _card_mappings_1.cardMappings[entity.cardId];
|
|
49
|
+
if ((0, card_interface_1.hasRebornSelfAttributeTransfer)(rebornImpl)) {
|
|
50
|
+
rebornImpl.rebornSelfAttributeTransfer.forEach((attribute) => {
|
|
51
|
+
(0, entity_utils_1.copyAttribute)(entity, deadEntity, attribute);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
48
54
|
if ((0, card_interface_1.hasRebornSelfEffect)(rebornImpl)) {
|
|
49
55
|
rebornImpl.rebornSelfEffect(entity, {
|
|
50
56
|
rebornEntity: deadEntity,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reborn.js","sourceRoot":"","sources":["../../src/simulation/reborn.ts"],"names":[],"mappings":";;;AAEA,4DAKiC;AACjC,iEAA4D;AAC5D,oFAAmF;AACnF,8EAA+G;AAE/G,oCAA2C;AAC3C,6DAAqD;AAErD,qCAA+C;AAExC,MAAM,qBAAqB,GAAG,CACpC,qBAAoC,EACpC,yBAA0C,EAC1C,UAAuB,EACvB,wBAAgC,EAChC,aAA4B,EAC5B,iBAAkC,EAClC,SAAwB,EACjB,EAAE;;IACT,MAAM,eAAe,GAAG,CAAC,CAAC;IAC1B,IAAI,aAAa,GAAgB,IAAI,CAAC;IACtC,IACC,IAAA,sCAAkB,EAAC,UAAU,CAAC,MAAM,CAAC;QACrC,IAAA,uCAAmB,EAAC,UAAU,CAAC;SAC/B,MAAA,UAAU,CAAC,YAAY,0CAAE,IAAI,CAC5B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,wBAAuE,CACtF,CAAA,EACA;QACD,aAAa,GAAG,IAAA,qDAAiC,EAA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AC,CAAC,CAAC,CAAC,CAAC;YAC9E,IAAA,uBAAe,EACd,CAAC,EACD,qBAAqB,EACrB,yBAAyB,EACzB,UAAU,GAAG,CAAC,EACd,UAAU,GAAG,CAAC,EACd,SAAS,CACT,CAAC;QACH,CAAC,CAAC,CAAC;KACJ;AACF,CAAC,CAAC;AAvKW,QAAA,qBAAqB,yBAuKhC","sourcesContent":["import { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport {\r\n\thasAfterReborn,\r\n\thasBeforeRebornSelfEffect,\r\n\thasRebornEffect,\r\n\thasRebornSelfEffect,\r\n} from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { hasPersistingHorror } from '../cards/impl/enchantments/persisting-horror';\r\nimport { buildSinrunnerBlanchyRebornEntity, isSinrunnerBlanchy } from '../cards/impl/minion/sinrunner-blanchy';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { addStatsToBoard } from '../utils';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { performEntitySpawns } from './spawns';\r\n\r\nexport const handleRebornForEntity = (\r\n\tboardWithKilledMinion: BoardEntity[],\r\n\tboardWithKilledMinionHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tdeadMinionIndexFromRight: number,\r\n\topponentBoard: BoardEntity[],\r\n\topponentBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst numberOfReborns = 1;\r\n\tlet entityToSpawn: BoardEntity = null;\r\n\tif (\r\n\t\tisSinrunnerBlanchy(deadEntity.cardId) ||\r\n\t\thasPersistingHorror(deadEntity) ||\r\n\t\tdeadEntity.enchantments?.some(\r\n\t\t\t(e) => e.cardId === CardIds.UltraCapacitor_UltraCapacitorEnchantment_BG31_HERO_801ptje,\r\n\t\t)\r\n\t) {\r\n\t\tentityToSpawn = buildSinrunnerBlanchyRebornEntity(deadEntity);\r\n\t}\r\n\r\n\tconst rebornImpl = cardMappings[deadEntity.cardId];\r\n\tif (hasBeforeRebornSelfEffect(rebornImpl)) {\r\n\t\trebornImpl.beforeRebornSelfEffect(deadEntity, {\r\n\t\t\trebornEntity: deadEntity,\r\n\t\t\tboardWithKilledMinion,\r\n\t\t\tboardWithKilledMinionHero,\r\n\t\t\topponentBoard,\r\n\t\t\topponentBoardHero,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t}\r\n\r\n\tconst entitiesFromReborn: readonly BoardEntity[] =\r\n\t\tdeadEntity.reborn && deadMinionIndexFromRight >= 0\r\n\t\t\t? spawnEntities(\r\n\t\t\t\t\tdeadEntity.cardId,\r\n\t\t\t\t\tnumberOfReborns,\r\n\t\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t\tentityToSpawn,\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t )\r\n\t\t\t: [];\r\n\tif (!entitiesFromReborn.length) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (\r\n\t\tdeadEntity.cardId === CardIds.WannabeGargoyle_BG30_109 ||\r\n\t\tdeadEntity.cardId === CardIds.WannabeGargoyle_BG30_109_G\r\n\t) {\r\n\t\tentitiesFromReborn.forEach((e) => {\r\n\t\t\tconst attack = deadEntity.maxAttack;\r\n\t\t\tconst health = deadEntity.cardId === CardIds.WannabeGargoyle_BG30_109_G ? deadEntity.maxHealth : 1;\r\n\t\t\te.attack = attack;\r\n\t\t\te.health = health;\r\n\t\t});\r\n\t}\r\n\r\n\tfor (const entity of entitiesFromReborn) {\r\n\t\tconst rebornImpl = cardMappings[entity.cardId];\r\n\t\tif (hasRebornSelfEffect(rebornImpl)) {\r\n\t\t\trebornImpl.rebornSelfEffect(entity, {\r\n\t\t\t\trebornEntity: deadEntity,\r\n\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const entity of boardWithKilledMinion) {\r\n\t\tconst rebornImpl = cardMappings[entity.cardId];\r\n\t\tif (hasRebornEffect(rebornImpl)) {\r\n\t\t\trebornImpl.rebornEffect(entity, {\r\n\t\t\t\trebornEntity: deadEntity,\r\n\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tconst entitiesThatWereReborn = performEntitySpawns(\r\n\t\tentitiesFromReborn,\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\tdeadEntity,\r\n\t\tdeadMinionIndexFromRight,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tgameState,\r\n\t);\r\n\tentitiesThatWereReborn.forEach((e) => (e.rebornFromEntityId = deadEntity.entityId));\r\n\tconst entityRightToSpawns =\r\n\t\tdeadMinionIndexFromRight === 0\r\n\t\t\t? null\r\n\t\t\t: boardWithKilledMinion[boardWithKilledMinion.length - deadMinionIndexFromRight];\r\n\tentitiesThatWereReborn.forEach((entity) => {\r\n\t\tentity.hasAttacked = deadEntity.hasAttacked > 1 ? 1 : entityRightToSpawns?.hasAttacked ?? undefined;\r\n\t});\r\n\r\n\tfor (const rebornEntity of entitiesThatWereReborn) {\r\n\t\tfor (const entity of boardWithKilledMinion) {\r\n\t\t\t// The entity was not there when the minion died, so we don't trigger its effect\r\n\t\t\tif (entitiesThatWereReborn.includes(entity)) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tconst rebornImpl = cardMappings[entity.cardId];\r\n\t\t\tif (hasAfterReborn(rebornImpl)) {\r\n\t\t\t\trebornImpl.afterReborn(entity, {\r\n\t\t\t\t\trebornEntity: rebornEntity,\r\n\t\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t\tfor (const trinket of boardWithKilledMinionHero.trinkets ?? []) {\r\n\t\t\tconst rebornImpl = cardMappings[trinket.cardId];\r\n\t\t\tif (hasAfterReborn(rebornImpl)) {\r\n\t\t\t\trebornImpl.afterReborn(trinket, {\r\n\t\t\t\t\trebornEntity: rebornEntity,\r\n\t\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tconst numberOfTriggersForDeathwhisper = Math.min(entitiesThatWereReborn.length, 1);\r\n\tfor (let i = 0; i < numberOfTriggersForDeathwhisper; i++) {\r\n\t\tboardWithKilledMinion\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId === CardIds.SisterDeathwhisper_BG25_020 ||\r\n\t\t\t\t\te.cardId === CardIds.SisterDeathwhisper_BG25_020_G,\r\n\t\t\t)\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\tconst multiplier = e.cardId === CardIds.SisterDeathwhisper_BG25_020_G ? 2 : 1;\r\n\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\te,\r\n\t\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\t\tmultiplier * 1,\r\n\t\t\t\t\tmultiplier * 3,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t}\r\n};\r\n\r\nexport interface RebornEffectInput {\r\n\treadonly rebornEntity: BoardEntity;\r\n\treadonly boardWithKilledMinion: BoardEntity[];\r\n\treadonly boardWithKilledMinionHero: BgsPlayerEntity;\r\n\treadonly opponentBoard: BoardEntity[];\r\n\treadonly opponentBoardHero: BgsPlayerEntity;\r\n\treadonly gameState: FullGameState;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"reborn.js","sourceRoot":"","sources":["../../src/simulation/reborn.ts"],"names":[],"mappings":";;;AAEA,4DAMiC;AACjC,iEAA4D;AAC5D,oFAAmF;AACnF,8EAA+G;AAE/G,oCAA2C;AAC3C,6DAAqD;AAErD,qCAA+C;AAC/C,uDAAqD;AAE9C,MAAM,qBAAqB,GAAG,CACpC,qBAAoC,EACpC,yBAA0C,EAC1C,UAAuB,EACvB,wBAAgC,EAChC,aAA4B,EAC5B,iBAAkC,EAClC,SAAwB,EACjB,EAAE;;IACT,MAAM,eAAe,GAAG,CAAC,CAAC;IAC1B,IAAI,aAAa,GAAgB,IAAI,CAAC;IACtC,IACC,IAAA,sCAAkB,EAAC,UAAU,CAAC,MAAM,CAAC;QACrC,IAAA,uCAAmB,EAAC,UAAU,CAAC;SAC/B,MAAA,UAAU,CAAC,YAAY,0CAAE,IAAI,CAC5B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,wBAAuE,CACtF,CAAA,EACA;QACD,aAAa,GAAG,IAAA,qDAAiC,EAAC,UAAU,CAAC,CAAC;KAC9D;IAED,MAAM,UAAU,GAAG,6BAAY,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACnD,IAAI,IAAA,0CAAyB,EAAC,UAAU,CAAC,EAAE;QAC1C,UAAU,CAAC,sBAAsB,CAAC,UAAU,EAAE;YAC7C,YAAY,EAAE,UAAU;YACxB,qBAAqB;YACrB,yBAAyB;YACzB,aAAa;YACb,iBAAiB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EACd,CAAC,EACD,qBAAqB,EACrB,yBAAyB,EACzB,UAAU,GAAG,CAAC,EACd,UAAU,GAAG,CAAC,EACd,SAAS,CACT,CAAC;QACH,CAAC,CAAC,CAAC;KACJ;AACF,CAAC,CAAC;AA5KW,QAAA,qBAAqB,yBA4KhC","sourcesContent":["import { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport {\r\n\thasAfterReborn,\r\n\thasBeforeRebornSelfEffect,\r\n\thasRebornEffect,\r\n\thasRebornSelfAttributeTransfer,\r\n\thasRebornSelfEffect,\r\n} from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { hasPersistingHorror } from '../cards/impl/enchantments/persisting-horror';\r\nimport { buildSinrunnerBlanchyRebornEntity, isSinrunnerBlanchy } from '../cards/impl/minion/sinrunner-blanchy';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { addStatsToBoard } from '../utils';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { performEntitySpawns } from './spawns';\r\nimport { copyAttribute } from './utils/entity-utils';\r\n\r\nexport const handleRebornForEntity = (\r\n\tboardWithKilledMinion: BoardEntity[],\r\n\tboardWithKilledMinionHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tdeadMinionIndexFromRight: number,\r\n\topponentBoard: BoardEntity[],\r\n\topponentBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst numberOfReborns = 1;\r\n\tlet entityToSpawn: BoardEntity = null;\r\n\tif (\r\n\t\tisSinrunnerBlanchy(deadEntity.cardId) ||\r\n\t\thasPersistingHorror(deadEntity) ||\r\n\t\tdeadEntity.enchantments?.some(\r\n\t\t\t(e) => e.cardId === CardIds.UltraCapacitor_UltraCapacitorEnchantment_BG31_HERO_801ptje,\r\n\t\t)\r\n\t) {\r\n\t\tentityToSpawn = buildSinrunnerBlanchyRebornEntity(deadEntity);\r\n\t}\r\n\r\n\tconst rebornImpl = cardMappings[deadEntity.cardId];\r\n\tif (hasBeforeRebornSelfEffect(rebornImpl)) {\r\n\t\trebornImpl.beforeRebornSelfEffect(deadEntity, {\r\n\t\t\trebornEntity: deadEntity,\r\n\t\t\tboardWithKilledMinion,\r\n\t\t\tboardWithKilledMinionHero,\r\n\t\t\topponentBoard,\r\n\t\t\topponentBoardHero,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t}\r\n\r\n\tconst entitiesFromReborn: readonly BoardEntity[] =\r\n\t\tdeadEntity.reborn && deadMinionIndexFromRight >= 0\r\n\t\t\t? spawnEntities(\r\n\t\t\t\t\tdeadEntity.cardId,\r\n\t\t\t\t\tnumberOfReborns,\r\n\t\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t\tentityToSpawn,\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t )\r\n\t\t\t: [];\r\n\tif (!entitiesFromReborn.length) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (\r\n\t\tdeadEntity.cardId === CardIds.WannabeGargoyle_BG30_109 ||\r\n\t\tdeadEntity.cardId === CardIds.WannabeGargoyle_BG30_109_G\r\n\t) {\r\n\t\tentitiesFromReborn.forEach((e) => {\r\n\t\t\tconst attack = deadEntity.maxAttack;\r\n\t\t\tconst health = deadEntity.cardId === CardIds.WannabeGargoyle_BG30_109_G ? deadEntity.maxHealth : 1;\r\n\t\t\te.attack = attack;\r\n\t\t\te.health = health;\r\n\t\t});\r\n\t}\r\n\r\n\tfor (const entity of entitiesFromReborn) {\r\n\t\tconst rebornImpl = cardMappings[entity.cardId];\r\n\t\tif (hasRebornSelfAttributeTransfer(rebornImpl)) {\r\n\t\t\trebornImpl.rebornSelfAttributeTransfer.forEach((attribute: keyof BoardEntity) => {\r\n\t\t\t\tcopyAttribute(entity, deadEntity, attribute);\r\n\t\t\t});\r\n\t\t}\r\n\t\tif (hasRebornSelfEffect(rebornImpl)) {\r\n\t\t\trebornImpl.rebornSelfEffect(entity, {\r\n\t\t\t\trebornEntity: deadEntity,\r\n\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const entity of boardWithKilledMinion) {\r\n\t\tconst rebornImpl = cardMappings[entity.cardId];\r\n\t\tif (hasRebornEffect(rebornImpl)) {\r\n\t\t\trebornImpl.rebornEffect(entity, {\r\n\t\t\t\trebornEntity: deadEntity,\r\n\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tconst entitiesThatWereReborn = performEntitySpawns(\r\n\t\tentitiesFromReborn,\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\tdeadEntity,\r\n\t\tdeadMinionIndexFromRight,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tgameState,\r\n\t);\r\n\tentitiesThatWereReborn.forEach((e) => (e.rebornFromEntityId = deadEntity.entityId));\r\n\tconst entityRightToSpawns =\r\n\t\tdeadMinionIndexFromRight === 0\r\n\t\t\t? null\r\n\t\t\t: boardWithKilledMinion[boardWithKilledMinion.length - deadMinionIndexFromRight];\r\n\tentitiesThatWereReborn.forEach((entity) => {\r\n\t\tentity.hasAttacked = deadEntity.hasAttacked > 1 ? 1 : entityRightToSpawns?.hasAttacked ?? undefined;\r\n\t});\r\n\r\n\tfor (const rebornEntity of entitiesThatWereReborn) {\r\n\t\tfor (const entity of boardWithKilledMinion) {\r\n\t\t\t// The entity was not there when the minion died, so we don't trigger its effect\r\n\t\t\tif (entitiesThatWereReborn.includes(entity)) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tconst rebornImpl = cardMappings[entity.cardId];\r\n\t\t\tif (hasAfterReborn(rebornImpl)) {\r\n\t\t\t\trebornImpl.afterReborn(entity, {\r\n\t\t\t\t\trebornEntity: rebornEntity,\r\n\t\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t\tfor (const trinket of boardWithKilledMinionHero.trinkets ?? []) {\r\n\t\t\tconst rebornImpl = cardMappings[trinket.cardId];\r\n\t\t\tif (hasAfterReborn(rebornImpl)) {\r\n\t\t\t\trebornImpl.afterReborn(trinket, {\r\n\t\t\t\t\trebornEntity: rebornEntity,\r\n\t\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tconst numberOfTriggersForDeathwhisper = Math.min(entitiesThatWereReborn.length, 1);\r\n\tfor (let i = 0; i < numberOfTriggersForDeathwhisper; i++) {\r\n\t\tboardWithKilledMinion\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId === CardIds.SisterDeathwhisper_BG25_020 ||\r\n\t\t\t\t\te.cardId === CardIds.SisterDeathwhisper_BG25_020_G,\r\n\t\t\t)\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\tconst multiplier = e.cardId === CardIds.SisterDeathwhisper_BG25_020_G ? 2 : 1;\r\n\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\te,\r\n\t\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\t\tmultiplier * 1,\r\n\t\t\t\t\tmultiplier * 3,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t}\r\n};\r\n\r\nexport interface RebornEffectInput {\r\n\treadonly rebornEntity: BoardEntity;\r\n\treadonly boardWithKilledMinion: BoardEntity[];\r\n\treadonly boardWithKilledMinionHero: BgsPlayerEntity;\r\n\treadonly opponentBoard: BoardEntity[];\r\n\treadonly opponentBoardHero: BgsPlayerEntity;\r\n\treadonly gameState: FullGameState;\r\n}\r\n"]}
|
|
@@ -11,6 +11,7 @@ const pending_effects_1 = require("./pending-effects");
|
|
|
11
11
|
const secrets_1 = require("./secrets");
|
|
12
12
|
const start_of_combat_1 = require("./start-of-combat/start-of-combat");
|
|
13
13
|
const summon_when_space_1 = require("./summon-when-space");
|
|
14
|
+
const combat_profile_1 = require("./combat-profile");
|
|
14
15
|
class Simulator {
|
|
15
16
|
constructor(gameState) {
|
|
16
17
|
this.gameState = gameState;
|
|
@@ -18,18 +19,24 @@ class Simulator {
|
|
|
18
19
|
this.hasShowShortCircuitWarning = false;
|
|
19
20
|
}
|
|
20
21
|
simulateSingleBattle(playerState, opponentState) {
|
|
21
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
22
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
22
23
|
let playerBoard = playerState.board;
|
|
23
24
|
let playerEntity = playerState.player;
|
|
24
25
|
let opponentBoard = opponentState.board;
|
|
25
26
|
let opponentEntity = opponentState.player;
|
|
27
|
+
playerEntity.globalInfo = (_a = playerEntity.globalInfo) !== null && _a !== void 0 ? _a : {};
|
|
28
|
+
opponentEntity.globalInfo = (_b = opponentEntity.globalInfo) !== null && _b !== void 0 ? _b : {};
|
|
29
|
+
playerEntity.globalInfo.RallyMinionAttacksThisCombat = 0;
|
|
30
|
+
opponentEntity.globalInfo.RallyMinionAttacksThisCombat = 0;
|
|
31
|
+
playerEntity.globalInfo.FreeRefreshesGainedThisCombat = 0;
|
|
32
|
+
opponentEntity.globalInfo.FreeRefreshesGainedThisCombat = 0;
|
|
26
33
|
let maxEntityId = -Infinity;
|
|
27
34
|
for (const group of [playerBoard, opponentBoard, playerEntity.hand, opponentEntity.hand]) {
|
|
28
35
|
for (const entity of group !== null && group !== void 0 ? group : []) {
|
|
29
36
|
if (entity.entityId > maxEntityId) {
|
|
30
37
|
maxEntityId = entity.entityId;
|
|
31
38
|
}
|
|
32
|
-
for (const enchantment of (
|
|
39
|
+
for (const enchantment of (_c = entity.enchantments) !== null && _c !== void 0 ? _c : []) {
|
|
33
40
|
if (enchantment.originEntityId > maxEntityId) {
|
|
34
41
|
maxEntityId = enchantment.originEntityId;
|
|
35
42
|
}
|
|
@@ -58,18 +65,18 @@ class Simulator {
|
|
|
58
65
|
const isPlayerDefeated = playerState.board.length === 0 || playerState.player.hpLeft <= 0;
|
|
59
66
|
const isOpponentDefeated = opponentState.board.length === 0 || opponentState.player.hpLeft <= 0;
|
|
60
67
|
if (isPlayerDefeated) {
|
|
61
|
-
playerBoard = (
|
|
68
|
+
playerBoard = (_d = playerState.teammate) === null || _d === void 0 ? void 0 : _d.board;
|
|
62
69
|
playerState.board = [];
|
|
63
|
-
playerEntity = (
|
|
70
|
+
playerEntity = (_e = playerState.teammate) === null || _e === void 0 ? void 0 : _e.player;
|
|
64
71
|
}
|
|
65
72
|
else {
|
|
66
73
|
playerBoard = playerState.board;
|
|
67
74
|
playerEntity = playerState.player;
|
|
68
75
|
}
|
|
69
76
|
if (isOpponentDefeated) {
|
|
70
|
-
opponentBoard = (
|
|
77
|
+
opponentBoard = (_f = opponentState.teammate) === null || _f === void 0 ? void 0 : _f.board;
|
|
71
78
|
opponentState.board = [];
|
|
72
|
-
opponentEntity = (
|
|
79
|
+
opponentEntity = (_g = opponentState.teammate) === null || _g === void 0 ? void 0 : _g.player;
|
|
73
80
|
}
|
|
74
81
|
else {
|
|
75
82
|
opponentBoard = opponentState.board;
|
|
@@ -106,49 +113,105 @@ class Simulator {
|
|
|
106
113
|
additionalCards: e.additionalCards ? [...e.additionalCards] : e.additionalCards,
|
|
107
114
|
});
|
|
108
115
|
});
|
|
116
|
+
const snapshotQuests = (hero) => {
|
|
117
|
+
var _a, _b, _c;
|
|
118
|
+
return ({
|
|
119
|
+
questEntities: ((_a = hero === null || hero === void 0 ? void 0 : hero.questEntities) !== null && _a !== void 0 ? _a : []).map((q) => ({ ...q })),
|
|
120
|
+
questRewards: [...((_b = hero === null || hero === void 0 ? void 0 : hero.questRewards) !== null && _b !== void 0 ? _b : [])],
|
|
121
|
+
questRewardEntities: ((_c = hero === null || hero === void 0 ? void 0 : hero.questRewardEntities) !== null && _c !== void 0 ? _c : []).map((r) => ({ ...r })),
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
const withQuestWriteback = (base) => {
|
|
125
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
126
|
+
const t0 = (0, combat_profile_1.combatProfileEnabled)() ? performance.now() : 0;
|
|
127
|
+
const playerQ = snapshotQuests(playerEntity);
|
|
128
|
+
const opponentQ = snapshotQuests(opponentEntity);
|
|
129
|
+
const snapshotHand = (hand) => (hand !== null && hand !== void 0 ? hand : []).map((e) => {
|
|
130
|
+
var _a;
|
|
131
|
+
return ({
|
|
132
|
+
...e,
|
|
133
|
+
enchantments: [...((_a = e.enchantments) !== null && _a !== void 0 ? _a : [])],
|
|
134
|
+
additionalCards: e.additionalCards ? [...e.additionalCards] : e.additionalCards,
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
const snapshotSecrets = (secrets) => (secrets !== null && secrets !== void 0 ? secrets : [])
|
|
138
|
+
.filter((s) => !s.triggered)
|
|
139
|
+
.map((s) => ({ ...s }));
|
|
140
|
+
const snapshotTrinkets = (trinkets) => (trinkets !== null && trinkets !== void 0 ? trinkets : []).map((t) => ({ ...t }));
|
|
141
|
+
const snapshotHeroPowers = (hps) => (hps !== null && hps !== void 0 ? hps : []).map((hp) => ({ ...hp }));
|
|
142
|
+
const packed = {
|
|
143
|
+
...base,
|
|
144
|
+
playerQuestEntities: playerQ.questEntities,
|
|
145
|
+
playerQuestRewards: playerQ.questRewards,
|
|
146
|
+
playerQuestRewardEntities: playerQ.questRewardEntities,
|
|
147
|
+
opponentQuestEntities: opponentQ.questEntities,
|
|
148
|
+
opponentQuestRewards: opponentQ.questRewards,
|
|
149
|
+
opponentQuestRewardEntities: opponentQ.questRewardEntities,
|
|
150
|
+
playerRallyAttacksThisCombat: (_b = (_a = playerEntity === null || playerEntity === void 0 ? void 0 : playerEntity.globalInfo) === null || _a === void 0 ? void 0 : _a.RallyMinionAttacksThisCombat) !== null && _b !== void 0 ? _b : 0,
|
|
151
|
+
opponentRallyAttacksThisCombat: (_d = (_c = opponentEntity === null || opponentEntity === void 0 ? void 0 : opponentEntity.globalInfo) === null || _c === void 0 ? void 0 : _c.RallyMinionAttacksThisCombat) !== null && _d !== void 0 ? _d : 0,
|
|
152
|
+
playerFreeRefreshesGainedThisCombat: (_f = (_e = playerEntity === null || playerEntity === void 0 ? void 0 : playerEntity.globalInfo) === null || _e === void 0 ? void 0 : _e.FreeRefreshesGainedThisCombat) !== null && _f !== void 0 ? _f : 0,
|
|
153
|
+
opponentFreeRefreshesGainedThisCombat: (_h = (_g = opponentEntity === null || opponentEntity === void 0 ? void 0 : opponentEntity.globalInfo) === null || _g === void 0 ? void 0 : _g.FreeRefreshesGainedThisCombat) !== null && _h !== void 0 ? _h : 0,
|
|
154
|
+
playerFodderRefreshes: (_k = (_j = playerEntity === null || playerEntity === void 0 ? void 0 : playerEntity.globalInfo) === null || _j === void 0 ? void 0 : _j.fodderRefreshes) !== null && _k !== void 0 ? _k : 0,
|
|
155
|
+
opponentFodderRefreshes: (_m = (_l = opponentEntity === null || opponentEntity === void 0 ? void 0 : opponentEntity.globalInfo) === null || _l === void 0 ? void 0 : _l.fodderRefreshes) !== null && _m !== void 0 ? _m : 0,
|
|
156
|
+
playerGlobalInfo: { ...((_o = playerEntity === null || playerEntity === void 0 ? void 0 : playerEntity.globalInfo) !== null && _o !== void 0 ? _o : {}) },
|
|
157
|
+
opponentGlobalInfo: { ...((_p = opponentEntity === null || opponentEntity === void 0 ? void 0 : opponentEntity.globalInfo) !== null && _p !== void 0 ? _p : {}) },
|
|
158
|
+
playerHand: snapshotHand(playerEntity === null || playerEntity === void 0 ? void 0 : playerEntity.hand),
|
|
159
|
+
opponentHand: snapshotHand(opponentEntity === null || opponentEntity === void 0 ? void 0 : opponentEntity.hand),
|
|
160
|
+
playerSecrets: snapshotSecrets(playerEntity === null || playerEntity === void 0 ? void 0 : playerEntity.secrets),
|
|
161
|
+
opponentSecrets: snapshotSecrets(opponentEntity === null || opponentEntity === void 0 ? void 0 : opponentEntity.secrets),
|
|
162
|
+
playerTrinkets: snapshotTrinkets(playerEntity === null || playerEntity === void 0 ? void 0 : playerEntity.trinkets),
|
|
163
|
+
opponentTrinkets: snapshotTrinkets(opponentEntity === null || opponentEntity === void 0 ? void 0 : opponentEntity.trinkets),
|
|
164
|
+
playerHeroPowers: snapshotHeroPowers(playerEntity === null || playerEntity === void 0 ? void 0 : playerEntity.heroPowers),
|
|
165
|
+
opponentHeroPowers: snapshotHeroPowers(opponentEntity === null || opponentEntity === void 0 ? void 0 : opponentEntity.heroPowers),
|
|
166
|
+
};
|
|
167
|
+
if (t0) {
|
|
168
|
+
(0, combat_profile_1.combatProfileAdd)('writebackMs', performance.now() - t0);
|
|
169
|
+
}
|
|
170
|
+
return packed;
|
|
171
|
+
};
|
|
109
172
|
if ((!(playerBoard === null || playerBoard === void 0 ? void 0 : playerBoard.length) && !(opponentBoard === null || opponentBoard === void 0 ? void 0 : opponentBoard.length)) ||
|
|
110
173
|
((playerBoard === null || playerBoard === void 0 ? void 0 : playerBoard.length) > 0 && (opponentBoard === null || opponentBoard === void 0 ? void 0 : opponentBoard.length) > 0)) {
|
|
111
|
-
return {
|
|
174
|
+
return withQuestWriteback({
|
|
112
175
|
result: 'tied',
|
|
113
176
|
damageDealt: 0,
|
|
114
177
|
playerBoard: snapshotBoard(playerBoard),
|
|
115
178
|
opponentBoard: snapshotBoard(opponentBoard),
|
|
116
|
-
};
|
|
179
|
+
});
|
|
117
180
|
}
|
|
118
181
|
if (!(playerBoard === null || playerBoard === void 0 ? void 0 : playerBoard.length) || (playerEntity === null || playerEntity === void 0 ? void 0 : playerEntity.hpLeft) <= 0) {
|
|
119
182
|
const winningHero = opponentEntity !== null && opponentEntity !== void 0 ? opponentEntity : opponentState.player;
|
|
120
183
|
const losingHero = playerEntity !== null && playerEntity !== void 0 ? playerEntity : playerState.player;
|
|
121
|
-
let damage = this.capDamage(this.buildBoardTotalDamage(opponentBoard, (
|
|
122
|
-
((
|
|
184
|
+
let damage = this.capDamage(this.buildBoardTotalDamage(opponentBoard, (_j = (_h = this.gameState.gameState.opponent) === null || _h === void 0 ? void 0 : _h.teammate) === null || _j === void 0 ? void 0 : _j.board) +
|
|
185
|
+
((_k = winningHero === null || winningHero === void 0 ? void 0 : winningHero.tavernTier) !== null && _k !== void 0 ? _k : 1));
|
|
123
186
|
if (this.gameState.applyIceBlock &&
|
|
124
187
|
damage > 0 &&
|
|
125
188
|
(0, secrets_1.tryPreventCombatDamageWithIceBlock)(losingHero)) {
|
|
126
189
|
damage = 0;
|
|
127
190
|
}
|
|
128
191
|
this.gameState.spectator.registerOpponentAttack(playerBoard, opponentBoard, damage);
|
|
129
|
-
return {
|
|
192
|
+
return withQuestWriteback({
|
|
130
193
|
result: 'lost',
|
|
131
194
|
damageDealt: damage,
|
|
132
195
|
playerBoard: snapshotBoard(playerBoard),
|
|
133
196
|
opponentBoard: snapshotBoard(opponentBoard),
|
|
134
|
-
};
|
|
197
|
+
});
|
|
135
198
|
}
|
|
136
199
|
const winningHero = playerEntity !== null && playerEntity !== void 0 ? playerEntity : playerState.player;
|
|
137
200
|
const losingHero = opponentEntity !== null && opponentEntity !== void 0 ? opponentEntity : opponentState.player;
|
|
138
|
-
let damage = this.capDamage(this.buildBoardTotalDamage(playerBoard, (
|
|
139
|
-
((
|
|
201
|
+
let damage = this.capDamage(this.buildBoardTotalDamage(playerBoard, (_m = (_l = this.gameState.gameState.player) === null || _l === void 0 ? void 0 : _l.teammate) === null || _m === void 0 ? void 0 : _m.board) +
|
|
202
|
+
((_o = winningHero === null || winningHero === void 0 ? void 0 : winningHero.tavernTier) !== null && _o !== void 0 ? _o : 1));
|
|
140
203
|
if (this.gameState.applyIceBlock &&
|
|
141
204
|
damage > 0 &&
|
|
142
205
|
(0, secrets_1.tryPreventCombatDamageWithIceBlock)(losingHero)) {
|
|
143
206
|
damage = 0;
|
|
144
207
|
}
|
|
145
208
|
this.gameState.spectator.registerPlayerAttack(playerBoard, opponentBoard, damage);
|
|
146
|
-
return {
|
|
209
|
+
return withQuestWriteback({
|
|
147
210
|
result: 'won',
|
|
148
211
|
damageDealt: damage,
|
|
149
212
|
playerBoard: snapshotBoard(playerBoard),
|
|
150
213
|
opponentBoard: snapshotBoard(opponentBoard),
|
|
151
|
-
};
|
|
214
|
+
});
|
|
152
215
|
}
|
|
153
216
|
logRunawayEntityDiagnostics(playerBoard, playerEntity, opponentBoard, opponentEntity) {
|
|
154
217
|
var _a, _b;
|
|
@@ -180,12 +243,16 @@ class Simulator {
|
|
|
180
243
|
: effectiveOpponentBoardLength > effectivePlayerBoardLength
|
|
181
244
|
? 1
|
|
182
245
|
: Math.round(Math.random());
|
|
246
|
+
const profile = (0, combat_profile_1.combatProfileEnabled)();
|
|
247
|
+
const socT0 = profile ? performance.now() : 0;
|
|
183
248
|
const suggestedNewCurrentAttacker = (0, start_of_combat_1.handleStartOfCombat)(playerEntity, playerBoard, opponentEntity, opponentBoard, this.currentAttacker, this.gameState);
|
|
184
249
|
this.currentAttacker = suggestedNewCurrentAttacker;
|
|
250
|
+
const socMs = profile ? performance.now() - socT0 : 0;
|
|
185
251
|
let counter = 0;
|
|
186
252
|
if (debug_state_1.debugState === null || debug_state_1.debugState === void 0 ? void 0 : debug_state_1.debugState.active) {
|
|
187
253
|
this.currentAttacker = (_a = debug_state_1.debugState.forcedCurrentAttacker) !== null && _a !== void 0 ? _a : this.currentAttacker;
|
|
188
254
|
}
|
|
255
|
+
const atkT0 = profile ? performance.now() : 0;
|
|
189
256
|
while (playerBoard.length > 0 &&
|
|
190
257
|
opponentBoard.length > 0 &&
|
|
191
258
|
playerEntity.hpLeft > 0 &&
|
|
@@ -229,15 +296,16 @@ class Simulator {
|
|
|
229
296
|
break;
|
|
230
297
|
}
|
|
231
298
|
}
|
|
299
|
+
if (profile) {
|
|
300
|
+
(0, combat_profile_1.combatProfileAdd)('socMs', socMs);
|
|
301
|
+
(0, combat_profile_1.combatProfileAdd)('atkMs', performance.now() - atkT0);
|
|
302
|
+
}
|
|
232
303
|
}
|
|
233
304
|
capDamage(damage) {
|
|
234
|
-
var _a, _b;
|
|
235
305
|
if (!this.gameState.applyDamageCap) {
|
|
236
306
|
return damage;
|
|
237
307
|
}
|
|
238
|
-
|
|
239
|
-
!!((_b = this.gameState.gameState.opponentInitial) === null || _b === void 0 ? void 0 : _b.teammate);
|
|
240
|
-
return (0, damage_cap_1.applyCombatDamageCap)(damage, this.gameState.currentTurn, this.gameState.numberOfPlayersAlive, isDuos);
|
|
308
|
+
return (0, damage_cap_1.applyCombatDamageCap)(damage, this.gameState.currentTurn, this.gameState.numberOfPlayersAlive, !!this.gameState.isDuos);
|
|
241
309
|
}
|
|
242
310
|
buildBoardTotalDamage(playerBoard, teammateBoard) {
|
|
243
311
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simulator.js","sourceRoot":"","sources":["../../src/simulation/simulator.ts"],"names":[],"mappings":";;;AAAA,iEAAqE;AAGrE,gD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AC,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;AArVD,8BAqVC","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, stringifySimpleCard } from '../utils';\r\nimport { simulateAttack } from './attack';\r\nimport { clearStealthIfNeeded } from './auras';\r\nimport { applyCombatDamageCap } from './damage-cap';\r\nimport { FullGameState, PlayerState } from './internal-game-state';\r\nimport { resolvePendingEffects } from './pending-effects';\r\nimport { tryPreventCombatDamageWithIceBlock } from './secrets';\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\r\n\t\tlet maxEntityId = -Infinity;\r\n\t\tfor (const group of [playerBoard, opponentBoard, playerEntity.hand, opponentEntity.hand]) {\r\n\t\t\tfor (const entity of group ?? []) {\r\n\t\t\t\tif (entity.entityId > maxEntityId) {\r\n\t\t\t\t\tmaxEntityId = entity.entityId;\r\n\t\t\t\t}\r\n\t\t\t\tfor (const enchantment of entity.enchantments ?? []) {\r\n\t\t\t\t\tif (enchantment.originEntityId > maxEntityId) {\r\n\t\t\t\t\t\tmaxEntityId = enchantment.originEntityId;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis.gameState.sharedState.currentEntityId = maxEntityId + 1;\r\n\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\t// Diagnostic only: detect runaway enchantment growth. The full entity id arrays are\r\n\t\t\t// only built in debug mode, since this allocates a lot on every battle pass\r\n\t\t\tif (debugState?.active) {\r\n\t\t\t\tthis.logRunawayEntityDiagnostics(playerBoard, playerEntity, opponentBoard, opponentEntity);\r\n\t\t\t}\r\n\t\t\tthis.simulateSingleBattlePass(playerBoard, playerEntity, opponentBoard, opponentEntity);\r\n\t\t\tif (this.hasShowShortCircuitWarning) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\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\tif (areBothBoards0Attack) {\r\n\t\t\t\tplayerState.board = [];\r\n\t\t\t\topponentState.board = [];\r\n\t\t\t}\r\n\r\n\t\t\tconst isPlayerDefeated = playerState.board.length === 0 || playerState.player.hpLeft <= 0;\r\n\t\t\tconst isOpponentDefeated = opponentState.board.length === 0 || opponentState.player.hpLeft <= 0;\r\n\t\t\tif (isPlayerDefeated) {\r\n\t\t\t\tplayerBoard = playerState.teammate?.board;\r\n\t\t\t\tplayerState.board = [];\r\n\t\t\t\tplayerEntity = playerState.teammate?.player;\r\n\t\t\t} else {\r\n\t\t\t\tplayerBoard = playerState.board;\r\n\t\t\t\tplayerEntity = playerState.player;\r\n\t\t\t}\r\n\t\t\tif (isOpponentDefeated) {\r\n\t\t\t\topponentBoard = opponentState.teammate?.board;\r\n\t\t\t\topponentState.board = [];\r\n\t\t\t\topponentEntity = opponentState.teammate?.player;\r\n\t\t\t} else {\r\n\t\t\t\topponentBoard = opponentState.board;\r\n\t\t\t\topponentEntity = opponentState.player;\r\n\t\t\t}\r\n\t\t\t// So that gameState.player always refers to the active player.\r\n\t\t\t// Only swap when a real Duos teammate takes over — assigning an empty\r\n\t\t\t// teammate shell on solo defeat made isDuos true and used the flat 15\r\n\t\t\t// damage cap instead of the turn-scaled solo cap (35dd5300 t4: 13→10).\r\n\t\t\tif (isPlayerDefeated && playerEntity) {\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 (isOpponentDefeated && opponentEntity) {\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\tconst snapshotBoard = (board: BoardEntity[] | null | undefined): BoardEntity[] =>\r\n\t\t\t(board ?? []).map((e) => ({\r\n\t\t\t\t...e,\r\n\t\t\t\tenchantments: [...(e.enchantments ?? [])],\r\n\t\t\t\tpendingAttackBuffs: [...(e.pendingAttackBuffs ?? [])],\r\n\t\t\t\tadditionalCards: e.additionalCards ? [...e.additionalCards] : e.additionalCards,\r\n\t\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\tdamageDealt: 0,\r\n\t\t\t\tplayerBoard: snapshotBoard(playerBoard),\r\n\t\t\t\topponentBoard: snapshotBoard(opponentBoard),\r\n\t\t\t};\r\n\t\t}\r\n\t\tif (!playerBoard?.length || playerEntity?.hpLeft <= 0) {\r\n\t\t\tconst winningHero = opponentEntity ?? opponentState.player;\r\n\t\t\tconst losingHero = playerEntity ?? playerState.player;\r\n\t\t\tlet damage = this.capDamage(\r\n\t\t\t\tthis.buildBoardTotalDamage(opponentBoard, this.gameState.gameState.opponent?.teammate?.board) +\r\n\t\t\t\t\t(winningHero?.tavernTier ?? 1),\r\n\t\t\t);\r\n\t\t\t// Full-game only: Ice Block prevents face damage (opt-in via applyIceBlock).\r\n\t\t\tif (\r\n\t\t\t\tthis.gameState.applyIceBlock &&\r\n\t\t\t\tdamage > 0 &&\r\n\t\t\t\ttryPreventCombatDamageWithIceBlock(losingHero)\r\n\t\t\t) {\r\n\t\t\t\tdamage = 0;\r\n\t\t\t}\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\tplayerBoard: snapshotBoard(playerBoard),\r\n\t\t\t\topponentBoard: snapshotBoard(opponentBoard),\r\n\t\t\t};\r\n\t\t}\r\n\r\n\t\tconst winningHero = playerEntity ?? playerState.player;\r\n\t\tconst losingHero = opponentEntity ?? opponentState.player;\r\n\t\tlet damage = this.capDamage(\r\n\t\t\tthis.buildBoardTotalDamage(playerBoard, this.gameState.gameState.player?.teammate?.board) +\r\n\t\t\t\t(winningHero?.tavernTier ?? 1),\r\n\t\t);\r\n\t\tif (\r\n\t\t\tthis.gameState.applyIceBlock &&\r\n\t\t\tdamage > 0 &&\r\n\t\t\ttryPreventCombatDamageWithIceBlock(losingHero)\r\n\t\t) {\r\n\t\t\tdamage = 0;\r\n\t\t}\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\tplayerBoard: snapshotBoard(playerBoard),\r\n\t\t\topponentBoard: snapshotBoard(opponentBoard),\r\n\t\t};\r\n\t}\r\n\r\n\tprivate logRunawayEntityDiagnostics(\r\n\t\tplayerBoard: BoardEntity[],\r\n\t\tplayerEntity: BgsPlayerEntity,\r\n\t\topponentBoard: BoardEntity[],\r\n\t\topponentEntity: BgsPlayerEntity,\r\n\t): void {\r\n\t\tconst allEntityIds: number[] = [];\r\n\t\tfor (const group of [playerBoard, opponentBoard, playerEntity.hand, opponentEntity.hand]) {\r\n\t\t\tfor (const entity of group ?? []) {\r\n\t\t\t\tconst result = [entity.entityId, ...(entity.enchantments?.map((e) => e.originEntityId) ?? [])];\r\n\t\t\t\tif (result.length > 200) {\r\n\t\t\t\t\tconsole.log(\r\n\t\t\t\t\t\t'too many entities for entity',\r\n\t\t\t\t\t\tresult.length,\r\n\t\t\t\t\t\tstringifySimpleCard(entity, this.gameState.allCards),\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tallEntityIds.push(...result);\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (allEntityIds.length > 10000) {\r\n\t\t\tconsole.log('allEntityIds2', allEntityIds, new Error().stack);\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\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 (\r\n\t\t\tplayerBoard.length > 0 &&\r\n\t\t\topponentBoard.length > 0 &&\r\n\t\t\tplayerEntity.hpLeft > 0 &&\r\n\t\t\topponentEntity.hpLeft > 0\r\n\t\t) {\r\n\t\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, this.gameState);\r\n\t\t\tclearStealthIfNeeded(playerBoard, playerEntity, opponentBoard, opponentEntity, this.gameState);\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\tresolvePendingEffects(playerBoard, playerEntity, opponentBoard, opponentEntity, this.gameState);\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 capDamage(damage: number): number {\r\n\t\tif (!this.gameState.applyDamageCap) {\r\n\t\t\treturn damage;\r\n\t\t}\r\n\t\tconst isDuos =\r\n\t\t\t!!this.gameState.gameState.playerInitial?.teammate ||\r\n\t\t\t!!this.gameState.gameState.opponentInitial?.teammate;\r\n\t\treturn applyCombatDamageCap(\r\n\t\t\tdamage,\r\n\t\t\tthis.gameState.currentTurn,\r\n\t\t\tthis.gameState.numberOfPlayersAlive,\r\n\t\t\tisDuos,\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,oCAAgE;AAChE,qCAA0C;AAC1C,mCAA+C;AAC/C,6CAAoD;AAEpD,uDAA0D;AAC1D,uCAA+D;AAC/D,uEAAwE;AACxE,2DAA6D;AAC7D,qDAA0E;AAG1E,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;QAE3D,YAAY,CAAC,UAAU,GAAG,MAAA,YAAY,CAAC,UAAU,mCAAI,EAAE,CAAC;QACxD,cAAc,CAAC,UAAU,GAAG,MAAA,cAAc,CAAC,UAAU,mCAAI,EAAE,CAAC;QAC5D,YAAY,CAAC,UAAU,CAAC,4BAA4B,GAAG,CAAC,CAAC;QACzD,cAAc,CAAC,UAAU,CAAC,4BAA4B,GAAG,CAAC,CAAC;QAC3D,YAAY,CAAC,UAAU,CAAC,6BAA6B,GAAG,CAAC,CAAC;QAC1D,cAAc,CAAC,UAAU,CAAC,6BAA6B,GAAG,CAAC,CAAC;QAE5D,IAAI,WAAW,GAAG,CAAC,QAAQ,CAAC;QAC5B,KAAK,MAAM,KAAK,IAAI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E,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;AApbD,8BAobC","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, stringifySimpleCard } from '../utils';\r\nimport { simulateAttack } from './attack';\r\nimport { clearStealthIfNeeded } from './auras';\r\nimport { applyCombatDamageCap } from './damage-cap';\r\nimport { FullGameState, PlayerState } from './internal-game-state';\r\nimport { resolvePendingEffects } from './pending-effects';\r\nimport { tryPreventCombatDamageWithIceBlock } from './secrets';\r\nimport { handleStartOfCombat } from './start-of-combat/start-of-combat';\r\nimport { handleSummonsWhenSpace } from './summon-when-space';\r\nimport { combatProfileAdd, combatProfileEnabled } from './combat-profile';\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\r\n\t\tplayerEntity.globalInfo = playerEntity.globalInfo ?? {};\r\n\t\topponentEntity.globalInfo = opponentEntity.globalInfo ?? {};\r\n\t\tplayerEntity.globalInfo.RallyMinionAttacksThisCombat = 0;\r\n\t\topponentEntity.globalInfo.RallyMinionAttacksThisCombat = 0;\r\n\t\tplayerEntity.globalInfo.FreeRefreshesGainedThisCombat = 0;\r\n\t\topponentEntity.globalInfo.FreeRefreshesGainedThisCombat = 0;\r\n\r\n\t\tlet maxEntityId = -Infinity;\r\n\t\tfor (const group of [playerBoard, opponentBoard, playerEntity.hand, opponentEntity.hand]) {\r\n\t\t\tfor (const entity of group ?? []) {\r\n\t\t\t\tif (entity.entityId > maxEntityId) {\r\n\t\t\t\t\tmaxEntityId = entity.entityId;\r\n\t\t\t\t}\r\n\t\t\t\tfor (const enchantment of entity.enchantments ?? []) {\r\n\t\t\t\t\tif (enchantment.originEntityId > maxEntityId) {\r\n\t\t\t\t\t\tmaxEntityId = enchantment.originEntityId;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis.gameState.sharedState.currentEntityId = maxEntityId + 1;\r\n\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\t// Diagnostic only: detect runaway enchantment growth. The full entity id arrays are\r\n\t\t\t// only built in debug mode, since this allocates a lot on every battle pass\r\n\t\t\tif (debugState?.active) {\r\n\t\t\t\tthis.logRunawayEntityDiagnostics(playerBoard, playerEntity, opponentBoard, opponentEntity);\r\n\t\t\t}\r\n\t\t\tthis.simulateSingleBattlePass(playerBoard, playerEntity, opponentBoard, opponentEntity);\r\n\t\t\tif (this.hasShowShortCircuitWarning) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\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\tif (areBothBoards0Attack) {\r\n\t\t\t\tplayerState.board = [];\r\n\t\t\t\topponentState.board = [];\r\n\t\t\t}\r\n\r\n\t\t\tconst isPlayerDefeated = playerState.board.length === 0 || playerState.player.hpLeft <= 0;\r\n\t\t\tconst isOpponentDefeated = opponentState.board.length === 0 || opponentState.player.hpLeft <= 0;\r\n\t\t\tif (isPlayerDefeated) {\r\n\t\t\t\tplayerBoard = playerState.teammate?.board;\r\n\t\t\t\tplayerState.board = [];\r\n\t\t\t\tplayerEntity = playerState.teammate?.player;\r\n\t\t\t} else {\r\n\t\t\t\tplayerBoard = playerState.board;\r\n\t\t\t\tplayerEntity = playerState.player;\r\n\t\t\t}\r\n\t\t\tif (isOpponentDefeated) {\r\n\t\t\t\topponentBoard = opponentState.teammate?.board;\r\n\t\t\t\topponentState.board = [];\r\n\t\t\t\topponentEntity = opponentState.teammate?.player;\r\n\t\t\t} else {\r\n\t\t\t\topponentBoard = opponentState.board;\r\n\t\t\t\topponentEntity = opponentState.player;\r\n\t\t\t}\r\n\t\t\t// So that gameState.player always refers to the active player.\r\n\t\t\t// Only swap when a real Duos teammate takes over — assigning an empty\r\n\t\t\t// teammate shell on solo defeat made isDuos true and used the flat 15\r\n\t\t\t// damage cap instead of the turn-scaled solo cap (35dd5300 t4: 13→10).\r\n\t\t\tif (isPlayerDefeated && playerEntity) {\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 (isOpponentDefeated && opponentEntity) {\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\tconst snapshotBoard = (board: BoardEntity[] | null | undefined): BoardEntity[] =>\r\n\t\t\t(board ?? []).map((e) => ({\r\n\t\t\t\t...e,\r\n\t\t\t\tenchantments: [...(e.enchantments ?? [])],\r\n\t\t\t\tpendingAttackBuffs: [...(e.pendingAttackBuffs ?? [])],\r\n\t\t\t\tadditionalCards: e.additionalCards ? [...e.additionalCards] : e.additionalCards,\r\n\t\t\t}));\r\n\r\n\t\tconst snapshotQuests = (hero: BgsPlayerEntity | null | undefined) => ({\r\n\t\t\tquestEntities: (hero?.questEntities ?? []).map((q) => ({ ...q })),\r\n\t\t\tquestRewards: [...(hero?.questRewards ?? [])],\r\n\t\t\tquestRewardEntities: (hero?.questRewardEntities ?? []).map((r) => ({ ...r })),\r\n\t\t});\r\n\r\n\t\tconst withQuestWriteback = (\r\n\t\t\tbase: Omit<\r\n\t\t\t\tSingleSimulationResult,\r\n\t\t\t\t| 'playerQuestEntities'\r\n\t\t\t\t| 'playerQuestRewards'\r\n\t\t\t\t| 'playerQuestRewardEntities'\r\n\t\t\t\t| 'opponentQuestEntities'\r\n\t\t\t\t| 'opponentQuestRewards'\r\n\t\t\t\t| 'opponentQuestRewardEntities'\r\n\t\t\t\t| 'playerRallyAttacksThisCombat'\r\n\t\t\t\t| 'opponentRallyAttacksThisCombat'\r\n\t\t\t\t| 'playerFreeRefreshesGainedThisCombat'\r\n\t\t\t\t| 'opponentFreeRefreshesGainedThisCombat'\r\n\t\t\t\t| 'playerFodderRefreshes'\r\n\t\t\t\t| 'opponentFodderRefreshes'\r\n\t\t\t\t| 'playerGlobalInfo'\r\n\t\t\t\t| 'opponentGlobalInfo'\r\n\t\t\t\t| 'playerHand'\r\n\t\t\t\t| 'opponentHand'\r\n\t\t\t\t| 'playerSecrets'\r\n\t\t\t\t| 'opponentSecrets'\r\n\t\t\t\t| 'playerTrinkets'\r\n\t\t\t\t| 'opponentTrinkets'\r\n\t\t\t\t| 'playerHeroPowers'\r\n\t\t\t\t| 'opponentHeroPowers'\r\n\t\t\t>,\r\n\t\t): SingleSimulationResult => {\r\n\t\t\tconst t0 = combatProfileEnabled() ? performance.now() : 0;\r\n\t\t\tconst playerQ = snapshotQuests(playerEntity);\r\n\t\t\tconst opponentQ = snapshotQuests(opponentEntity);\r\n\t\t\tconst snapshotHand = (hand: typeof playerEntity.hand) =>\r\n\t\t\t\t(hand ?? []).map((e) => ({\r\n\t\t\t\t\t...e,\r\n\t\t\t\t\tenchantments: [...(e.enchantments ?? [])],\r\n\t\t\t\t\tadditionalCards: e.additionalCards ? [...e.additionalCards] : e.additionalCards,\r\n\t\t\t\t}));\r\n\t\t\tconst snapshotSecrets = (secrets: typeof playerEntity.secrets) =>\r\n\t\t\t\t(secrets ?? [])\r\n\t\t\t\t\t.filter((s) => !s.triggered)\r\n\t\t\t\t\t.map((s) => ({ ...s }));\r\n\t\t\tconst snapshotTrinkets = (trinkets: typeof playerEntity.trinkets) =>\r\n\t\t\t\t(trinkets ?? []).map((t) => ({ ...t }));\r\n\t\t\tconst snapshotHeroPowers = (hps: typeof playerEntity.heroPowers) =>\r\n\t\t\t\t(hps ?? []).map((hp) => ({ ...hp }));\r\n\t\t\tconst packed: SingleSimulationResult = {\r\n\t\t\t\t...base,\r\n\t\t\t\tplayerQuestEntities: playerQ.questEntities,\r\n\t\t\t\tplayerQuestRewards: playerQ.questRewards,\r\n\t\t\t\tplayerQuestRewardEntities: playerQ.questRewardEntities,\r\n\t\t\t\topponentQuestEntities: opponentQ.questEntities,\r\n\t\t\t\topponentQuestRewards: opponentQ.questRewards,\r\n\t\t\t\topponentQuestRewardEntities: opponentQ.questRewardEntities,\r\n\t\t\t\tplayerRallyAttacksThisCombat: playerEntity?.globalInfo?.RallyMinionAttacksThisCombat ?? 0,\r\n\t\t\t\topponentRallyAttacksThisCombat: opponentEntity?.globalInfo?.RallyMinionAttacksThisCombat ?? 0,\r\n\t\t\t\tplayerFreeRefreshesGainedThisCombat:\r\n\t\t\t\t\tplayerEntity?.globalInfo?.FreeRefreshesGainedThisCombat ?? 0,\r\n\t\t\t\topponentFreeRefreshesGainedThisCombat:\r\n\t\t\t\t\topponentEntity?.globalInfo?.FreeRefreshesGainedThisCombat ?? 0,\r\n\t\t\t\tplayerFodderRefreshes: playerEntity?.globalInfo?.fodderRefreshes ?? 0,\r\n\t\t\t\topponentFodderRefreshes: opponentEntity?.globalInfo?.fodderRefreshes ?? 0,\r\n\t\t\t\tplayerGlobalInfo: { ...(playerEntity?.globalInfo ?? {}) },\r\n\t\t\t\topponentGlobalInfo: { ...(opponentEntity?.globalInfo ?? {}) },\r\n\t\t\t\tplayerHand: snapshotHand(playerEntity?.hand),\r\n\t\t\t\topponentHand: snapshotHand(opponentEntity?.hand),\r\n\t\t\t\tplayerSecrets: snapshotSecrets(playerEntity?.secrets),\r\n\t\t\t\topponentSecrets: snapshotSecrets(opponentEntity?.secrets),\r\n\t\t\t\tplayerTrinkets: snapshotTrinkets(playerEntity?.trinkets),\r\n\t\t\t\topponentTrinkets: snapshotTrinkets(opponentEntity?.trinkets),\r\n\t\t\t\tplayerHeroPowers: snapshotHeroPowers(playerEntity?.heroPowers),\r\n\t\t\t\topponentHeroPowers: snapshotHeroPowers(opponentEntity?.heroPowers),\r\n\t\t\t};\r\n\t\t\tif (t0) {\r\n\t\t\t\tcombatProfileAdd('writebackMs', performance.now() - t0);\r\n\t\t\t}\r\n\t\t\treturn packed;\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 withQuestWriteback({\r\n\t\t\t\tresult: 'tied',\r\n\t\t\t\tdamageDealt: 0,\r\n\t\t\t\tplayerBoard: snapshotBoard(playerBoard),\r\n\t\t\t\topponentBoard: snapshotBoard(opponentBoard),\r\n\t\t\t});\r\n\t\t}\r\n\t\tif (!playerBoard?.length || playerEntity?.hpLeft <= 0) {\r\n\t\t\tconst winningHero = opponentEntity ?? opponentState.player;\r\n\t\t\tconst losingHero = playerEntity ?? playerState.player;\r\n\t\t\tlet damage = this.capDamage(\r\n\t\t\t\tthis.buildBoardTotalDamage(opponentBoard, this.gameState.gameState.opponent?.teammate?.board) +\r\n\t\t\t\t\t(winningHero?.tavernTier ?? 1),\r\n\t\t\t);\r\n\t\t\t// Full-game only: Ice Block prevents face damage (opt-in via applyIceBlock).\r\n\t\t\tif (\r\n\t\t\t\tthis.gameState.applyIceBlock &&\r\n\t\t\t\tdamage > 0 &&\r\n\t\t\t\ttryPreventCombatDamageWithIceBlock(losingHero)\r\n\t\t\t) {\r\n\t\t\t\tdamage = 0;\r\n\t\t\t}\r\n\t\t\tthis.gameState.spectator.registerOpponentAttack(playerBoard, opponentBoard, damage);\r\n\t\t\treturn withQuestWriteback({\r\n\t\t\t\tresult: 'lost',\r\n\t\t\t\tdamageDealt: damage,\r\n\t\t\t\tplayerBoard: snapshotBoard(playerBoard),\r\n\t\t\t\topponentBoard: snapshotBoard(opponentBoard),\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tconst winningHero = playerEntity ?? playerState.player;\r\n\t\tconst losingHero = opponentEntity ?? opponentState.player;\r\n\t\tlet damage = this.capDamage(\r\n\t\t\tthis.buildBoardTotalDamage(playerBoard, this.gameState.gameState.player?.teammate?.board) +\r\n\t\t\t\t(winningHero?.tavernTier ?? 1),\r\n\t\t);\r\n\t\tif (\r\n\t\t\tthis.gameState.applyIceBlock &&\r\n\t\t\tdamage > 0 &&\r\n\t\t\ttryPreventCombatDamageWithIceBlock(losingHero)\r\n\t\t) {\r\n\t\t\tdamage = 0;\r\n\t\t}\r\n\t\tthis.gameState.spectator.registerPlayerAttack(playerBoard, opponentBoard, damage);\r\n\t\treturn withQuestWriteback({\r\n\t\t\tresult: 'won',\r\n\t\t\tdamageDealt: damage,\r\n\t\t\tplayerBoard: snapshotBoard(playerBoard),\r\n\t\t\topponentBoard: snapshotBoard(opponentBoard),\r\n\t\t});\r\n\t}\r\n\r\n\tprivate logRunawayEntityDiagnostics(\r\n\t\tplayerBoard: BoardEntity[],\r\n\t\tplayerEntity: BgsPlayerEntity,\r\n\t\topponentBoard: BoardEntity[],\r\n\t\topponentEntity: BgsPlayerEntity,\r\n\t): void {\r\n\t\tconst allEntityIds: number[] = [];\r\n\t\tfor (const group of [playerBoard, opponentBoard, playerEntity.hand, opponentEntity.hand]) {\r\n\t\t\tfor (const entity of group ?? []) {\r\n\t\t\t\tconst result = [entity.entityId, ...(entity.enchantments?.map((e) => e.originEntityId) ?? [])];\r\n\t\t\t\tif (result.length > 200) {\r\n\t\t\t\t\tconsole.log(\r\n\t\t\t\t\t\t'too many entities for entity',\r\n\t\t\t\t\t\tresult.length,\r\n\t\t\t\t\t\tstringifySimpleCard(entity, this.gameState.allCards),\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tallEntityIds.push(...result);\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (allEntityIds.length > 10000) {\r\n\t\t\tconsole.log('allEntityIds2', allEntityIds, new Error().stack);\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\tconst profile = combatProfileEnabled();\r\n\t\tconst socT0 = profile ? performance.now() : 0;\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\tconst socMs = profile ? performance.now() - socT0 : 0;\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\tconst atkT0 = profile ? performance.now() : 0;\r\n\t\twhile (\r\n\t\t\tplayerBoard.length > 0 &&\r\n\t\t\topponentBoard.length > 0 &&\r\n\t\t\tplayerEntity.hpLeft > 0 &&\r\n\t\t\topponentEntity.hpLeft > 0\r\n\t\t) {\r\n\t\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, this.gameState);\r\n\t\t\tclearStealthIfNeeded(playerBoard, playerEntity, opponentBoard, opponentEntity, this.gameState);\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\tresolvePendingEffects(playerBoard, playerEntity, opponentBoard, opponentEntity, this.gameState);\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\tif (profile) {\r\n\t\t\tcombatProfileAdd('socMs', socMs);\r\n\t\t\tcombatProfileAdd('atkMs', performance.now() - atkT0);\r\n\t\t}\r\n\t}\r\n\r\n\tprivate capDamage(damage: number): number {\r\n\t\tif (!this.gameState.applyDamageCap) {\r\n\t\t\treturn damage;\r\n\t\t}\r\n\t\treturn applyCombatDamageCap(\r\n\t\t\tdamage,\r\n\t\t\tthis.gameState.currentTurn,\r\n\t\t\tthis.gameState.numberOfPlayersAlive,\r\n\t\t\t!!this.gameState.isDuos,\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"]}
|