@firestone-hs/simulate-bgs-battle 1.1.574 → 1.1.576
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/board-secret.d.ts +1 -0
- package/dist/board-secret.js.map +1 -1
- package/dist/cards/impl/hero-power/rapid-reanimation.js +1 -2
- package/dist/cards/impl/hero-power/rapid-reanimation.js.map +1 -1
- package/dist/cards/impl/minion/corrupted-bristler.js +1 -1
- package/dist/cards/impl/minion/corrupted-bristler.js.map +1 -1
- package/dist/cards/impl/minion/fire-forged-evoker.js +2 -1
- package/dist/cards/impl/minion/fire-forged-evoker.js.map +1 -1
- package/dist/cards/impl/minion/flighty-scout.js +1 -1
- package/dist/cards/impl/minion/flighty-scout.js.map +1 -1
- package/dist/cards/impl/spell/fleeting-vigor.js +1 -1
- package/dist/cards/impl/spell/fleeting-vigor.js.map +1 -1
- package/dist/cards/impl/trinket/beetle-band.js +3 -1
- package/dist/cards/impl/trinket/beetle-band.js.map +1 -1
- package/dist/cards/impl/trinket/eclectic-shrine.js +1 -1
- package/dist/cards/impl/trinket/eclectic-shrine.js.map +1 -1
- package/dist/input-sanitation.js +0 -1
- package/dist/input-sanitation.js.map +1 -1
- package/dist/simulation/auras.js +1 -1
- package/dist/simulation/auras.js.map +1 -1
- package/dist/simulation/deathrattle-effects.js +14 -4
- package/dist/simulation/deathrattle-effects.js.map +1 -1
- package/dist/simulation/deathrattle-spawns.js +1 -0
- package/dist/simulation/deathrattle-spawns.js.map +1 -1
- package/dist/simulation/spawns.d.ts +2 -2
- package/dist/simulation/spawns.js.map +1 -1
- package/dist/simulation/spectator/spectator.d.ts +1 -1
- package/dist/simulation/spectator/spectator.js.map +1 -1
- package/dist/simulation/start-of-combat/soc-anomalies.js +11 -6
- package/dist/simulation/start-of-combat/soc-anomalies.js.map +1 -1
- package/dist/simulation/start-of-combat/soc-hero-power.js +11 -5
- package/dist/simulation/start-of-combat/soc-hero-power.js.map +1 -1
- package/dist/simulation/start-of-combat/soc-illidan-hero-power.js +13 -7
- package/dist/simulation/start-of-combat/soc-illidan-hero-power.js.map +1 -1
- package/dist/simulation/start-of-combat/soc-minion.js +10 -3
- package/dist/simulation/start-of-combat/soc-minion.js.map +1 -1
- package/dist/simulation/start-of-combat/soc-pre-combat-hero-power.js +11 -5
- package/dist/simulation/start-of-combat/soc-pre-combat-hero-power.js.map +1 -1
- package/dist/simulation/start-of-combat/soc-quest-reward.js +11 -5
- package/dist/simulation/start-of-combat/soc-quest-reward.js.map +1 -1
- package/dist/simulation/start-of-combat/soc-secret.js +11 -6
- package/dist/simulation/start-of-combat/soc-secret.js.map +1 -1
- package/dist/simulation/start-of-combat/soc-trinket.js +8 -2
- package/dist/simulation/start-of-combat/soc-trinket.js.map +1 -1
- package/dist/simulation/start-of-combat/start-of-combat.js +26 -23
- package/dist/simulation/start-of-combat/start-of-combat.js.map +1 -1
- package/dist/simulation/stats.js +0 -8
- package/dist/simulation/stats.js.map +1 -1
- package/dist/utils.js +5 -3
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawns.js","sourceRoot":"","sources":["../../src/simulation/spawns.ts"],"names":[],"mappings":";;;AAEA,+DAAyD;AACzD,qCAA0C;AAE1C,6CAAqD;AAE9C,MAAM,mBAAmB,GAAG,CAClC,iBAAyC,EACzC,qBAAoC,EACpC,yBAA0C,EAC1C,
|
|
1
|
+
{"version":3,"file":"spawns.js","sourceRoot":"","sources":["../../src/simulation/spawns.ts"],"names":[],"mappings":";;;AAEA,+DAAyD;AACzD,qCAA0C;AAE1C,6CAAqD;AAE9C,MAAM,mBAAmB,GAAG,CAClC,iBAAyC,EACzC,qBAAoC,EACpC,yBAA0C,EAC1C,iBAA+D,EAC/D,+BAAuC,EACvC,aAA4B,EAC5B,iBAAkC,EAClC,SAAwB,EACxB,cAAc,GAAG,IAAI,EACI,EAAE;IAC3B,MAAM,YAAY,GAAG,iBAAiB,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AAS,CAAC,CAAC;SAChC;KACD;IAED,SAAS,CAAC,SAAS,CAAC,oBAAoB,CAAC,iBAAiB,EAAE,qBAAqB,EAAE,eAAe,CAAC,CAAC;IACpG,OAAO,eAAe,CAAC;AACxB,CAAC,CAAC;AA9EW,QAAA,mBAAmB,uBA8E9B","sourcesContent":["import { BgsPlayerEntity, BoardTrinket } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { addMinionToBoard } from './add-minion-to-board';\r\nimport { simulateAttack } from './attack';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { onMinionFailedToSpawn } from './spawn-fail';\r\n\r\nexport const performEntitySpawns = (\r\n\tcandidateEntities: readonly BoardEntity[],\r\n\tboardWithKilledMinion: BoardEntity[],\r\n\tboardWithKilledMinionHero: BgsPlayerEntity,\r\n\tspawnSourceEntity: BoardEntity | BgsPlayerEntity | BoardTrinket,\r\n\tspawnSourceEntityIndexFromRight: number,\r\n\topponentBoard: BoardEntity[],\r\n\topponentBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tapplySelfAuras = true,\r\n): readonly BoardEntity[] => {\r\n\tconst aliveEntites = candidateEntities.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\tconst spawnedEntities = [];\r\n\tfor (let i = 0; i < aliveEntites.length; i++) {\r\n\t\tconst newMinion = aliveEntites[i];\r\n\t\t// All entities have been spawned\r\n\t\tif (boardWithKilledMinion.length >= 7) {\r\n\t\t\tfor (let j = i; j < aliveEntites.length; j++) {\r\n\t\t\t\tonMinionFailedToSpawn(aliveEntites[j], boardWithKilledMinion, boardWithKilledMinionHero, gameState);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t// Avoid minions spawning backwards (we don't have this issue if we add all elements at\r\n\t\t// the same time, but here we want to be able to attack after each spawn, which in turn\r\n\t\t// means that the minion can die before the other one spawns)\r\n\t\t// In boardWithKilledMinion, the dead minion has already been removed\r\n\t\tconst indexToSpawnAt = Math.max(0, boardWithKilledMinion.length - spawnSourceEntityIndexFromRight);\r\n\t\taddMinionToBoard(\r\n\t\t\tboardWithKilledMinion,\r\n\t\t\tboardWithKilledMinionHero,\r\n\t\t\topponentBoard,\r\n\t\t\topponentBoardHero,\r\n\t\t\tindexToSpawnAt,\r\n\t\t\tnewMinion,\r\n\t\t\tgameState,\r\n\t\t\ttrue,\r\n\t\t\tapplySelfAuras,\r\n\t\t);\r\n\t\tif (newMinion.attackImmediately) {\r\n\t\t\t// console.debug(\r\n\t\t\t// \t'\\nattack immediately\\n',\r\n\t\t\t// \tstringifySimple(boardWithKilledMinion, gameState.allCards),\r\n\t\t\t// \t'\\n',\r\n\t\t\t// \tstringifySimple(opponentBoard, gameState.allCards),\r\n\t\t\t// );\r\n\t\t\t// Whenever we are already in a combat phase, we need to first clean up the state\r\n\t\t\tconst actualAttacker = simulateAttack(\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\t// console.debug(\r\n\t\t\t// \t'after attack immediately\\n',\r\n\t\t\t// \tstringifySimple(boardWithKilledMinion, gameState.allCards),\r\n\t\t\t// \t'\\n',\r\n\t\t\t// \tstringifySimple(opponentBoard, gameState.allCards),\r\n\t\t\t// );\r\n\t\t\t// So that, even if the opponent's board is temporarily empty (e.g. no minion, but a token will\r\n\t\t\t// spawn in the enchantments resolution phase), the minion won't attack right away again\r\n\t\t\t// In case of attack immediately + multiple spawns minins, it's possible that the minion for which\r\n\t\t\t// we triggered the attack simulation was not the one who actually attacked\r\n\t\t\tif (actualAttacker) {\r\n\t\t\t\tactualAttacker.attackImmediately = false;\r\n\t\t\t}\r\n\t\t\t// Can happen if the attackImmediately minion spawns first, opponent board is empty, then opponent minino spawns\r\n\t\t\telse {\r\n\t\t\t\tnewMinion.attackImmediately = false;\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (newMinion.health > 0 && !newMinion.definitelyDead) {\r\n\t\t\tspawnedEntities.push(newMinion);\r\n\t\t}\r\n\t}\r\n\r\n\tgameState.spectator.registerMinionsSpawn(spawnSourceEntity, boardWithKilledMinion, spawnedEntities);\r\n\treturn spawnedEntities;\r\n};\r\n"]}
|
|
@@ -24,7 +24,7 @@ export declare class Spectator {
|
|
|
24
24
|
registerOpponentAttack(friendlyBoard: readonly BoardEntity[], opponentBoard: readonly BoardEntity[], damage: number): void;
|
|
25
25
|
registerDamageDealt(damagingEntity: BoardEntity, damagedEntity: BoardEntity, damageTaken: number, damagedEntityBoard: BoardEntity[]): void;
|
|
26
26
|
registerPowerTarget(sourceEntity: BoardEntity | BgsPlayerEntity | BoardSecret | BoardTrinket, targetEntity: BoardEntity | BgsPlayerEntity, targetBoard: BoardEntity[], hero1: BgsPlayerEntity, hero2: BgsPlayerEntity): void;
|
|
27
|
-
registerMinionsSpawn(sourceEntity: BoardEntity | BgsPlayerEntity, boardOnWhichToSpawn: BoardEntity[], spawnedEntities: readonly BoardEntity[]): void;
|
|
27
|
+
registerMinionsSpawn(sourceEntity: BoardEntity | BgsPlayerEntity | BoardTrinket, boardOnWhichToSpawn: BoardEntity[], spawnedEntities: readonly BoardEntity[]): void;
|
|
28
28
|
registerDeadEntities(deadMinionIndexes1: number[], deadEntities1: BoardEntity[], board1: BoardEntity[], deadMinionIndexes2: number[], deadEntities2: BoardEntity[], board2: BoardEntity[]): void;
|
|
29
29
|
private addAction;
|
|
30
30
|
private collapseActions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spectator.js","sourceRoot":"","sources":["../../../src/simulation/spectator/spectator.ts"],"names":[],"mappings":";;;AAIA,+CAA4D;AAG5D,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,MAAa,SAAS;IAMrB,YAA6B,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;QAC5C,IAAI,CAAC,uBAAuB,GAAG,EAAE,CAAC;QACl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zB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,OAAO,EAAE,MAAM,CAAC,OAAO;SACP,CAAA,CAClB,CAAC;IACH,CAAC;IAEO,gBAAgB,CAAC,QAAiC;QACzD,IAAI,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,CAAA,EAAE;YACtB,OAAO,SAAS,CAAC;SACjB;QACD,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAC1B,CAAC,CAAC,EAAE,EAAE,CACL,CAAC;YACA,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,cAAc,EAAE,CAAC,CAAC,cAAc;YAChC,cAAc,EAAE,CAAC,CAAC,cAAc;SACf,CAAA,CACnB,CAAC;QACF,OAAO,MAAM,CAAC;IACf,CAAC;CACD;AAzcD,8BAycC","sourcesContent":["import { BgsGameState } from '../../bgs-battle-info';\r\nimport { BgsPlayerEntity, BoardTrinket } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { BoardSecret } from '../../board-secret';\r\nimport { GameAction, buildGameAction } from './game-action';\r\nimport { GameSample } from './game-sample';\r\n\r\nconst MAX_SAMPLES = 1;\r\n\r\nexport class Spectator {\r\n\tprivate actionsForCurrentBattle: GameAction[];\r\n\tprivate wonBattles: GameSample[];\r\n\tprivate tiedBattles: GameSample[];\r\n\tprivate lostBattles: GameSample[];\r\n\r\n\tconstructor(private readonly enabled: boolean) {\r\n\t\tthis.actionsForCurrentBattle = [];\r\n\t\tthis.wonBattles = [];\r\n\t\tthis.tiedBattles = [];\r\n\t\tthis.lostBattles = [];\r\n\t}\r\n\r\n\tpublic prune(): void {\r\n\t\tthis.wonBattles = this.wonBattles.slice(0, MAX_SAMPLES);\r\n\t\tthis.lostBattles = this.lostBattles.slice(0, MAX_SAMPLES);\r\n\t\tthis.tiedBattles = this.tiedBattles.slice(0, MAX_SAMPLES);\r\n\t}\r\n\r\n\tpublic buildOutcomeSamples(gameState: BgsGameState): {\r\n\t\twon: readonly GameSample[];\r\n\t\tlost: readonly GameSample[];\r\n\t\ttied: readonly GameSample[];\r\n\t} {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn {\r\n\t\t\t\twon: [],\r\n\t\t\t\tlost: [],\r\n\t\t\t\ttied: [],\r\n\t\t\t};\r\n\t\t}\r\n\t\treturn {\r\n\t\t\twon: this.wonBattles?.map((battle) => this.cleanUpActions(battle, gameState)),\r\n\t\t\tlost: this.lostBattles?.map((battle) => this.cleanUpActions(battle, gameState)),\r\n\t\t\ttied: this.tiedBattles?.map((battle) => this.cleanUpActions(battle, gameState)),\r\n\t\t};\r\n\t}\r\n\r\n\tprivate cleanUpActions(battle: GameSample, gameState: BgsGameState): GameSample {\r\n\t\tconst collapsed = this.collapseActions(battle.actions);\r\n\t\tconst result: GameSample = {\r\n\t\t\t...battle,\r\n\t\t\tactions: collapsed,\r\n\t\t\tanomalies: gameState.anomalies,\r\n\t\t};\r\n\t\treturn result;\r\n\t}\r\n\r\n\tpublic commitBattleResult(result: 'won' | 'lost' | 'tied'): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\tthis.actionsForCurrentBattle = [];\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (\r\n\t\t\tthis.wonBattles.length >= MAX_SAMPLES &&\r\n\t\t\tthis.lostBattles.length >= MAX_SAMPLES &&\r\n\t\t\tthis.tiedBattles.length >= MAX_SAMPLES\r\n\t\t) {\r\n\t\t\tthis.actionsForCurrentBattle = [];\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// const actionsForBattle = this.collapseActions(this.actionsForCurrentBattle);\r\n\t\tconst actionsForBattle = this.actionsForCurrentBattle;\r\n\t\tthis.actionsForCurrentBattle = [];\r\n\r\n\t\tconst battle: GameSample = {\r\n\t\t\tactions: actionsForBattle,\r\n\t\t\tanomalies: [],\r\n\t\t};\r\n\t\tswitch (result) {\r\n\t\t\tcase 'won':\r\n\t\t\t\tthis.wonBattles.push(battle);\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'lost':\r\n\t\t\t\tthis.lostBattles.push(battle);\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'tied':\r\n\t\t\t\tthis.tiedBattles.push(battle);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic registerAttack(\r\n\t\tattackingEntity: BoardEntity,\r\n\t\tdefendingEntity: BoardEntity,\r\n\t\tattackingBoard: readonly BoardEntity[],\r\n\t\tdefendingBoard: readonly BoardEntity[],\r\n\t\tattackingBoardHero: BgsPlayerEntity,\r\n\t\tdefendingBoardHero: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// console.debug(\r\n\t\t// \t'\\n register attack',\r\n\t\t// \tstringifySimple(attackingBoard),\r\n\t\t// \t'\\n',\r\n\t\t// \tstringifySimple(defendingBoard),\r\n\t\t// \t'\\n',\r\n\t\t// \tattackingBoard.find((e) => e.entityId === 2441),\r\n\t\t// \t'\\n',\r\n\t\t// \tattackingBoard.find((e) => e.entityId === 2442),\r\n\t\t// );\r\n\t\tconst isAttackerFriendly = attackingBoard.every((entity) => entity.friendly);\r\n\t\tconst playerHero = isAttackerFriendly ? attackingBoardHero : defendingBoardHero;\r\n\t\tconst opponentHero = isAttackerFriendly ? defendingBoardHero : attackingBoardHero;\r\n\t\tconst friendlyBoard = isAttackerFriendly ? attackingBoard : defendingBoard;\r\n\t\tconst opponentBoard = isAttackerFriendly ? defendingBoard : attackingBoard;\r\n\t\tconst action: GameAction = buildGameAction(playerHero, opponentHero, {\r\n\t\t\ttype: 'attack',\r\n\t\t\tsourceEntityId: attackingEntity.entityId,\r\n\t\t\ttargetEntityId: defendingEntity.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\tplayerHand: this.sanitize(playerHero.hand),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\topponentHand: this.sanitize(opponentHero.hand),\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerStartOfCombat(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tfriendlyHero: BgsPlayerEntity,\r\n\t\topponentHero: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(friendlyHero, opponentHero, {\r\n\t\t\ttype: 'start-of-combat',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: this.sanitize(friendlyHero.hand),\r\n\t\t\topponentHand: this.sanitize(opponentHero.hand),\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerPlayerAttack(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tdamage: number,\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'player-attack',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tdamage: damage,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerOpponentAttack(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tdamage: number,\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'opponent-attack',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tdamage: damage,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerDamageDealt(\r\n\t\tdamagingEntity: BoardEntity,\r\n\t\tdamagedEntity: BoardEntity,\r\n\t\tdamageTaken: number,\r\n\t\tdamagedEntityBoard: BoardEntity[],\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!damagingEntity.entityId) {\r\n\t\t\t// console.error('missing damaging entity id', damagingEntity.cardId);\r\n\t\t}\r\n\t\tconst friendlyBoard = damagedEntityBoard.every((entity) => entity.friendly) ? damagedEntityBoard : null;\r\n\t\tconst opponentBoard = damagedEntityBoard.every((entity) => !entity.friendly) ? damagedEntityBoard : null;\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'damage',\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tsourceEntityId: damagingEntity.entityId,\r\n\t\t\t\t\ttargetEntityId: damagedEntity.entityId,\r\n\t\t\t\t\tdamage: damageTaken,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerPowerTarget(\r\n\t\tsourceEntity: BoardEntity | BgsPlayerEntity | BoardSecret | BoardTrinket,\r\n\t\ttargetEntity: BoardEntity | BgsPlayerEntity,\r\n\t\ttargetBoard: BoardEntity[],\r\n\t\thero1: BgsPlayerEntity,\r\n\t\thero2: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!targetEntity) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// console.log('registerPowerTarget', stringifySimpleCard(sourceEntity), stringifySimpleCard(targetEntity), new Error().stack);\r\n\t\tconst friendlyBoard = targetBoard?.every((entity) => entity.friendly) ? targetBoard : null;\r\n\t\tconst opponentBoard = targetBoard?.every((entity) => !entity.friendly) ? targetBoard : null;\r\n\t\tconst friendlyHero = hero1?.friendly ? hero1 : hero2?.friendly ? hero2 : null;\r\n\t\tconst opponentHero = hero1?.friendly ? hero2 : hero2?.friendly ? hero1 : null;\r\n\t\tconst action: GameAction = buildGameAction(friendlyHero, opponentHero, {\r\n\t\t\ttype: 'power-target',\r\n\t\t\tsourceEntityId: sourceEntity.entityId,\r\n\t\t\ttargetEntityId: targetEntity.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: this.sanitize(friendlyHero?.hand),\r\n\t\t\topponentHand: this.sanitize(opponentHero?.hand),\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerMinionsSpawn(\r\n\t\tsourceEntity: BoardEntity | BgsPlayerEntity,\r\n\t\tboardOnWhichToSpawn: BoardEntity[],\r\n\t\tspawnedEntities: readonly BoardEntity[],\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!spawnedEntities || spawnedEntities.length === 0) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (!sourceEntity?.entityId) {\r\n\t\t\t// console.error('missing spawn source entity id', sourceEntity);\r\n\t\t}\r\n\t\tconst friendlyBoard = boardOnWhichToSpawn.every((entity) => entity.friendly) ? boardOnWhichToSpawn : null;\r\n\t\tconst opponentBoard = boardOnWhichToSpawn.every((entity) => !entity.friendly) ? boardOnWhichToSpawn : null;\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'spawn',\r\n\t\t\tspawns: this.sanitize(spawnedEntities),\r\n\t\t\tsourceEntityId: sourceEntity?.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerDeadEntities(\r\n\t\tdeadMinionIndexes1: number[],\r\n\t\tdeadEntities1: BoardEntity[],\r\n\t\tboard1: BoardEntity[],\r\n\t\tdeadMinionIndexes2: number[],\r\n\t\tdeadEntities2: BoardEntity[],\r\n\t\tboard2: BoardEntity[],\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst deaths = [...(deadEntities1 || []), ...(deadEntities2 || [])];\r\n\t\tif (!deaths || deaths.length === 0) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'minion-death',\r\n\t\t\tdeaths: this.sanitize(deaths),\r\n\t\t\tdeadMinionsPositionsOnBoard: [\r\n\t\t\t\t...(deadMinionIndexes1 || []).map((i) => board1.length - i),\r\n\t\t\t\t...(deadMinionIndexes2 || []).map((i) => board2.length - i),\r\n\t\t\t],\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tprivate addAction(action: GameAction) {\r\n\t\tthis.actionsForCurrentBattle.push(action);\r\n\t}\r\n\r\n\tprivate collapseActions(actions: readonly GameAction[]): readonly GameAction[] {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\t\tif (!actions || actions.length === 0) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\t\tconst result: GameAction[] = [];\r\n\t\tfor (let i = 0; i < actions.length; i++) {\r\n\t\t\tconst action: GameAction = {\r\n\t\t\t\t...actions[i],\r\n\t\t\t\tplayerBoard: this.sanitize(actions[i].playerBoard),\r\n\t\t\t\topponentBoard: this.sanitize(actions[i].opponentBoard),\r\n\t\t\t\tplayerHand: this.sanitize(actions[i].playerHand),\r\n\t\t\t\topponentHand: this.sanitize(actions[i].opponentHand),\r\n\t\t\t\t// spawns: this.sanitize(actions[i].spawns),\r\n\t\t\t\tdeaths: this.sanitize(actions[i].deaths),\r\n\t\t\t\tplayerTrinkets: this.sanitizeTrinkets(actions[i].playerTrinkets),\r\n\t\t\t\topponentTrinkets: this.sanitizeTrinkets(actions[i].opponentTrinkets),\r\n\t\t\t};\r\n\t\t\t// action.playerBoard && console.debug('\\naction playerboard', stringifySimple(action.playerBoard));\r\n\t\t\tconst lastAction = result.length > 0 ? result[result.length - 1] : null;\r\n\r\n\t\t\tif (lastAction) {\r\n\t\t\t\taction.playerBoard = action.playerBoard ?? lastAction.playerBoard;\r\n\t\t\t\taction.opponentBoard = action.opponentBoard ?? lastAction.opponentBoard;\r\n\t\t\t\taction.playerHand = action.playerHand ?? lastAction.playerHand;\r\n\t\t\t\taction.opponentHand = action.opponentHand ?? lastAction.opponentHand;\r\n\t\t\t\taction.playerSecrets = action.playerSecrets ?? lastAction.playerSecrets;\r\n\t\t\t\taction.opponentSecrets = action.opponentSecrets ?? lastAction.opponentSecrets;\r\n\t\t\t\taction.playerRewardCardId = action.playerRewardCardId ?? lastAction.playerRewardCardId;\r\n\t\t\t\taction.playerRewardEntityId = action.playerRewardEntityId ?? lastAction.playerRewardEntityId;\r\n\t\t\t\taction.playerRewardData = action.playerRewardData ?? lastAction.playerRewardData;\r\n\t\t\t\taction.opponentRewardCardId = action.opponentRewardCardId ?? lastAction.opponentRewardCardId;\r\n\t\t\t\taction.opponentRewardEntityId = action.opponentRewardEntityId ?? lastAction.opponentRewardEntityId;\r\n\t\t\t\taction.opponentRewardData = action.opponentRewardData ?? lastAction.opponentRewardData;\r\n\t\t\t\taction.playerCardId = action.playerCardId ?? lastAction.playerCardId;\r\n\t\t\t\taction.playerEntityId = action.playerEntityId ?? lastAction.playerEntityId;\r\n\t\t\t\taction.playerHeroPowerCardId = action.playerHeroPowerCardId ?? lastAction.playerHeroPowerCardId;\r\n\t\t\t\taction.playerHeroPowerEntityId = action.playerHeroPowerEntityId ?? lastAction.playerHeroPowerEntityId;\r\n\t\t\t\taction.playerHeroPowerUsed = action.playerHeroPowerUsed ?? lastAction.playerHeroPowerUsed;\r\n\t\t\t\taction.opponentCardId = action.opponentCardId ?? lastAction.opponentCardId;\r\n\t\t\t\taction.opponentEntityId = action.opponentEntityId ?? lastAction.opponentEntityId;\r\n\t\t\t\taction.opponentHeroPowerCardId = action.opponentHeroPowerCardId ?? lastAction.opponentHeroPowerCardId;\r\n\t\t\t\taction.opponentHeroPowerEntityId =\r\n\t\t\t\t\taction.opponentHeroPowerEntityId ?? lastAction.opponentHeroPowerEntityId;\r\n\t\t\t\taction.opponentHeroPowerUsed = action.opponentHeroPowerUsed ?? lastAction.opponentHeroPowerUsed;\r\n\t\t\t\taction.playerTrinkets = action.playerTrinkets ?? lastAction.playerTrinkets;\r\n\t\t\t\taction.opponentTrinkets = action.opponentTrinkets ?? lastAction.opponentTrinkets;\r\n\t\t\t}\r\n\r\n\t\t\tif (lastAction && action.type === 'damage' && lastAction.type === 'attack') {\r\n\t\t\t\tlastAction.damages = lastAction.damages || [];\r\n\t\t\t\tlastAction.damages.push({\r\n\t\t\t\t\tdamage: action.damages[0].damage,\r\n\t\t\t\t\tsourceEntityId: action.damages[0].sourceEntityId,\r\n\t\t\t\t\ttargetEntityId: action.damages[0].targetEntityId,\r\n\t\t\t\t});\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t\tlastAction.playerTrinkets = action.playerTrinkets;\r\n\t\t\t\tlastAction.opponentTrinkets = action.opponentTrinkets;\r\n\t\t\t} else if (lastAction && action.type === 'damage' && lastAction.type === 'damage') {\r\n\t\t\t\tlastAction.damages = lastAction.damages || [];\r\n\t\t\t\tlastAction.damages.push({\r\n\t\t\t\t\tdamage: action.damages[0].damage,\r\n\t\t\t\t\tsourceEntityId: action.damages[0].sourceEntityId,\r\n\t\t\t\t\ttargetEntityId: action.damages[0].targetEntityId,\r\n\t\t\t\t});\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t\tlastAction.playerTrinkets = action.playerTrinkets;\r\n\t\t\t\tlastAction.opponentTrinkets = action.opponentTrinkets;\r\n\t\t\t} else if (\r\n\t\t\t\tlastAction &&\r\n\t\t\t\taction.type === 'power-target' &&\r\n\t\t\t\tlastAction.type === 'power-target' &&\r\n\t\t\t\taction.sourceEntityId === lastAction.sourceEntityId\r\n\t\t\t) {\r\n\t\t\t\tlastAction.targetEntityIds =\r\n\t\t\t\t\tlastAction.targetEntityIds ?? (lastAction.targetEntityId ? [lastAction.targetEntityId] : []);\r\n\t\t\t\taction.targetEntityIds =\r\n\t\t\t\t\taction.targetEntityIds ?? (action.targetEntityId ? [action.targetEntityId] : []);\r\n\t\t\t\tlastAction.targetEntityIds.push(...action.targetEntityIds);\r\n\t\t\t\t// So that when multiple Leapfroggers enchantments target the same minion,\r\n\t\t\t\t// we can count them in the replay viewer's text\r\n\t\t\t\t// lastAction.targetEntityIds = [...new Set(lastAction.targetEntityIds)];\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t\tlastAction.playerTrinkets = action.playerTrinkets;\r\n\t\t\t\tlastAction.opponentTrinkets = action.opponentTrinkets;\r\n\t\t\t} else {\r\n\t\t\t\tresult.push(action);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\t// Calling sanitize every time before we add an action to the list is mandatory, since\r\n\t// the entities and boards are mutable\r\n\tprivate sanitize(board: readonly BoardEntity[]): readonly BoardEntity[] {\r\n\t\tif (!board) {\r\n\t\t\treturn undefined;\r\n\t\t}\r\n\t\treturn board.map(\r\n\t\t\t(entity) =>\r\n\t\t\t\t({\r\n\t\t\t\t\tentityId: entity.entityId,\r\n\t\t\t\t\tcardId: entity.cardId,\r\n\t\t\t\t\tfriendly: entity.friendly,\r\n\t\t\t\t\tattack: entity.attack,\r\n\t\t\t\t\thealth: entity.health,\r\n\t\t\t\t\tmaxHealth: entity.maxHealth,\r\n\t\t\t\t\ttaunt: entity.taunt,\r\n\t\t\t\t\tdivineShield: entity.divineShield,\r\n\t\t\t\t\tpoisonous: entity.poisonous,\r\n\t\t\t\t\tvenomous: entity.venomous,\r\n\t\t\t\t\treborn: entity.reborn,\r\n\t\t\t\t\twindfury: entity.windfury,\r\n\t\t\t\t\tstealth: entity.stealth,\r\n\t\t\t\t} as BoardEntity),\r\n\t\t);\r\n\t}\r\n\r\n\tprivate sanitizeTrinkets(trinkets: readonly BoardTrinket[]): readonly BoardTrinket[] {\r\n\t\tif (!trinkets?.length) {\r\n\t\t\treturn undefined;\r\n\t\t}\r\n\t\tconst result = trinkets.map(\r\n\t\t\t(t) =>\r\n\t\t\t\t({\r\n\t\t\t\t\tcardId: t.cardId,\r\n\t\t\t\t\tentityId: t.entityId,\r\n\t\t\t\t\tscriptDataNum1: t.scriptDataNum1,\r\n\t\t\t\t\tscriptDataNum6: t.scriptDataNum6,\r\n\t\t\t\t} as BoardTrinket),\r\n\t\t);\r\n\t\treturn result;\r\n\t}\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"spectator.js","sourceRoot":"","sources":["../../../src/simulation/spectator/spectator.ts"],"names":[],"mappings":";;;AAIA,+CAA4D;AAG5D,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,MAAa,SAAS;IAMrB,YAA6B,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;QAC5C,IAAI,CAAC,uBAAuB,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACvB,CAAC;IAEM,KAAK;QACX,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;QACxD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;QAC1D,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;IAC3D,CAAC;IAEM,mBAAmB,CAAC,SAAuB;;Q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QAAQ,CAAE,MAAM,CAAA,EAAE;YACtB,OAAO,SAAS,CAAC;SACjB;QACD,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAC1B,CAAC,CAAC,EAAE,EAAE,CACL,CAAC;YACA,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,cAAc,EAAE,CAAC,CAAC,cAAc;YAChC,cAAc,EAAE,CAAC,CAAC,cAAc;SACf,CAAA,CACnB,CAAC;QACF,OAAO,MAAM,CAAC;IACf,CAAC;CACD;AAzcD,8BAycC","sourcesContent":["import { BgsGameState } from '../../bgs-battle-info';\r\nimport { BgsPlayerEntity, BoardTrinket } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { BoardSecret } from '../../board-secret';\r\nimport { GameAction, buildGameAction } from './game-action';\r\nimport { GameSample } from './game-sample';\r\n\r\nconst MAX_SAMPLES = 1;\r\n\r\nexport class Spectator {\r\n\tprivate actionsForCurrentBattle: GameAction[];\r\n\tprivate wonBattles: GameSample[];\r\n\tprivate tiedBattles: GameSample[];\r\n\tprivate lostBattles: GameSample[];\r\n\r\n\tconstructor(private readonly enabled: boolean) {\r\n\t\tthis.actionsForCurrentBattle = [];\r\n\t\tthis.wonBattles = [];\r\n\t\tthis.tiedBattles = [];\r\n\t\tthis.lostBattles = [];\r\n\t}\r\n\r\n\tpublic prune(): void {\r\n\t\tthis.wonBattles = this.wonBattles.slice(0, MAX_SAMPLES);\r\n\t\tthis.lostBattles = this.lostBattles.slice(0, MAX_SAMPLES);\r\n\t\tthis.tiedBattles = this.tiedBattles.slice(0, MAX_SAMPLES);\r\n\t}\r\n\r\n\tpublic buildOutcomeSamples(gameState: BgsGameState): {\r\n\t\twon: readonly GameSample[];\r\n\t\tlost: readonly GameSample[];\r\n\t\ttied: readonly GameSample[];\r\n\t} {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn {\r\n\t\t\t\twon: [],\r\n\t\t\t\tlost: [],\r\n\t\t\t\ttied: [],\r\n\t\t\t};\r\n\t\t}\r\n\t\treturn {\r\n\t\t\twon: this.wonBattles?.map((battle) => this.cleanUpActions(battle, gameState)),\r\n\t\t\tlost: this.lostBattles?.map((battle) => this.cleanUpActions(battle, gameState)),\r\n\t\t\ttied: this.tiedBattles?.map((battle) => this.cleanUpActions(battle, gameState)),\r\n\t\t};\r\n\t}\r\n\r\n\tprivate cleanUpActions(battle: GameSample, gameState: BgsGameState): GameSample {\r\n\t\tconst collapsed = this.collapseActions(battle.actions);\r\n\t\tconst result: GameSample = {\r\n\t\t\t...battle,\r\n\t\t\tactions: collapsed,\r\n\t\t\tanomalies: gameState.anomalies,\r\n\t\t};\r\n\t\treturn result;\r\n\t}\r\n\r\n\tpublic commitBattleResult(result: 'won' | 'lost' | 'tied'): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\tthis.actionsForCurrentBattle = [];\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (\r\n\t\t\tthis.wonBattles.length >= MAX_SAMPLES &&\r\n\t\t\tthis.lostBattles.length >= MAX_SAMPLES &&\r\n\t\t\tthis.tiedBattles.length >= MAX_SAMPLES\r\n\t\t) {\r\n\t\t\tthis.actionsForCurrentBattle = [];\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// const actionsForBattle = this.collapseActions(this.actionsForCurrentBattle);\r\n\t\tconst actionsForBattle = this.actionsForCurrentBattle;\r\n\t\tthis.actionsForCurrentBattle = [];\r\n\r\n\t\tconst battle: GameSample = {\r\n\t\t\tactions: actionsForBattle,\r\n\t\t\tanomalies: [],\r\n\t\t};\r\n\t\tswitch (result) {\r\n\t\t\tcase 'won':\r\n\t\t\t\tthis.wonBattles.push(battle);\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'lost':\r\n\t\t\t\tthis.lostBattles.push(battle);\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'tied':\r\n\t\t\t\tthis.tiedBattles.push(battle);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic registerAttack(\r\n\t\tattackingEntity: BoardEntity,\r\n\t\tdefendingEntity: BoardEntity,\r\n\t\tattackingBoard: readonly BoardEntity[],\r\n\t\tdefendingBoard: readonly BoardEntity[],\r\n\t\tattackingBoardHero: BgsPlayerEntity,\r\n\t\tdefendingBoardHero: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// console.debug(\r\n\t\t// \t'\\n register attack',\r\n\t\t// \tstringifySimple(attackingBoard),\r\n\t\t// \t'\\n',\r\n\t\t// \tstringifySimple(defendingBoard),\r\n\t\t// \t'\\n',\r\n\t\t// \tattackingBoard.find((e) => e.entityId === 2441),\r\n\t\t// \t'\\n',\r\n\t\t// \tattackingBoard.find((e) => e.entityId === 2442),\r\n\t\t// );\r\n\t\tconst isAttackerFriendly = attackingBoard.every((entity) => entity.friendly);\r\n\t\tconst playerHero = isAttackerFriendly ? attackingBoardHero : defendingBoardHero;\r\n\t\tconst opponentHero = isAttackerFriendly ? defendingBoardHero : attackingBoardHero;\r\n\t\tconst friendlyBoard = isAttackerFriendly ? attackingBoard : defendingBoard;\r\n\t\tconst opponentBoard = isAttackerFriendly ? defendingBoard : attackingBoard;\r\n\t\tconst action: GameAction = buildGameAction(playerHero, opponentHero, {\r\n\t\t\ttype: 'attack',\r\n\t\t\tsourceEntityId: attackingEntity.entityId,\r\n\t\t\ttargetEntityId: defendingEntity.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\tplayerHand: this.sanitize(playerHero.hand),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\topponentHand: this.sanitize(opponentHero.hand),\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerStartOfCombat(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tfriendlyHero: BgsPlayerEntity,\r\n\t\topponentHero: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(friendlyHero, opponentHero, {\r\n\t\t\ttype: 'start-of-combat',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: this.sanitize(friendlyHero.hand),\r\n\t\t\topponentHand: this.sanitize(opponentHero.hand),\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerPlayerAttack(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tdamage: number,\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'player-attack',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tdamage: damage,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerOpponentAttack(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tdamage: number,\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'opponent-attack',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tdamage: damage,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerDamageDealt(\r\n\t\tdamagingEntity: BoardEntity,\r\n\t\tdamagedEntity: BoardEntity,\r\n\t\tdamageTaken: number,\r\n\t\tdamagedEntityBoard: BoardEntity[],\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!damagingEntity.entityId) {\r\n\t\t\t// console.error('missing damaging entity id', damagingEntity.cardId);\r\n\t\t}\r\n\t\tconst friendlyBoard = damagedEntityBoard.every((entity) => entity.friendly) ? damagedEntityBoard : null;\r\n\t\tconst opponentBoard = damagedEntityBoard.every((entity) => !entity.friendly) ? damagedEntityBoard : null;\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'damage',\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tsourceEntityId: damagingEntity.entityId,\r\n\t\t\t\t\ttargetEntityId: damagedEntity.entityId,\r\n\t\t\t\t\tdamage: damageTaken,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerPowerTarget(\r\n\t\tsourceEntity: BoardEntity | BgsPlayerEntity | BoardSecret | BoardTrinket,\r\n\t\ttargetEntity: BoardEntity | BgsPlayerEntity,\r\n\t\ttargetBoard: BoardEntity[],\r\n\t\thero1: BgsPlayerEntity,\r\n\t\thero2: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!targetEntity) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// console.log('registerPowerTarget', stringifySimpleCard(sourceEntity), stringifySimpleCard(targetEntity), new Error().stack);\r\n\t\tconst friendlyBoard = targetBoard?.every((entity) => entity.friendly) ? targetBoard : null;\r\n\t\tconst opponentBoard = targetBoard?.every((entity) => !entity.friendly) ? targetBoard : null;\r\n\t\tconst friendlyHero = hero1?.friendly ? hero1 : hero2?.friendly ? hero2 : null;\r\n\t\tconst opponentHero = hero1?.friendly ? hero2 : hero2?.friendly ? hero1 : null;\r\n\t\tconst action: GameAction = buildGameAction(friendlyHero, opponentHero, {\r\n\t\t\ttype: 'power-target',\r\n\t\t\tsourceEntityId: sourceEntity.entityId,\r\n\t\t\ttargetEntityId: targetEntity.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: this.sanitize(friendlyHero?.hand),\r\n\t\t\topponentHand: this.sanitize(opponentHero?.hand),\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerMinionsSpawn(\r\n\t\tsourceEntity: BoardEntity | BgsPlayerEntity | BoardTrinket,\r\n\t\tboardOnWhichToSpawn: BoardEntity[],\r\n\t\tspawnedEntities: readonly BoardEntity[],\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!spawnedEntities || spawnedEntities.length === 0) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (!sourceEntity?.entityId) {\r\n\t\t\t// console.error('missing spawn source entity id', sourceEntity);\r\n\t\t}\r\n\t\tconst friendlyBoard = boardOnWhichToSpawn.every((entity) => entity.friendly) ? boardOnWhichToSpawn : null;\r\n\t\tconst opponentBoard = boardOnWhichToSpawn.every((entity) => !entity.friendly) ? boardOnWhichToSpawn : null;\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'spawn',\r\n\t\t\tspawns: this.sanitize(spawnedEntities),\r\n\t\t\tsourceEntityId: sourceEntity?.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerDeadEntities(\r\n\t\tdeadMinionIndexes1: number[],\r\n\t\tdeadEntities1: BoardEntity[],\r\n\t\tboard1: BoardEntity[],\r\n\t\tdeadMinionIndexes2: number[],\r\n\t\tdeadEntities2: BoardEntity[],\r\n\t\tboard2: BoardEntity[],\r\n\t): void {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst deaths = [...(deadEntities1 || []), ...(deadEntities2 || [])];\r\n\t\tif (!deaths || deaths.length === 0) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = buildGameAction(null, null, {\r\n\t\t\ttype: 'minion-death',\r\n\t\t\tdeaths: this.sanitize(deaths),\r\n\t\t\tdeadMinionsPositionsOnBoard: [\r\n\t\t\t\t...(deadMinionIndexes1 || []).map((i) => board1.length - i),\r\n\t\t\t\t...(deadMinionIndexes2 || []).map((i) => board2.length - i),\r\n\t\t\t],\r\n\t\t});\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tprivate addAction(action: GameAction) {\r\n\t\tthis.actionsForCurrentBattle.push(action);\r\n\t}\r\n\r\n\tprivate collapseActions(actions: readonly GameAction[]): readonly GameAction[] {\r\n\t\tif (!this.enabled) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\t\tif (!actions || actions.length === 0) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\t\tconst result: GameAction[] = [];\r\n\t\tfor (let i = 0; i < actions.length; i++) {\r\n\t\t\tconst action: GameAction = {\r\n\t\t\t\t...actions[i],\r\n\t\t\t\tplayerBoard: this.sanitize(actions[i].playerBoard),\r\n\t\t\t\topponentBoard: this.sanitize(actions[i].opponentBoard),\r\n\t\t\t\tplayerHand: this.sanitize(actions[i].playerHand),\r\n\t\t\t\topponentHand: this.sanitize(actions[i].opponentHand),\r\n\t\t\t\t// spawns: this.sanitize(actions[i].spawns),\r\n\t\t\t\tdeaths: this.sanitize(actions[i].deaths),\r\n\t\t\t\tplayerTrinkets: this.sanitizeTrinkets(actions[i].playerTrinkets),\r\n\t\t\t\topponentTrinkets: this.sanitizeTrinkets(actions[i].opponentTrinkets),\r\n\t\t\t};\r\n\t\t\t// action.playerBoard && console.debug('\\naction playerboard', stringifySimple(action.playerBoard));\r\n\t\t\tconst lastAction = result.length > 0 ? result[result.length - 1] : null;\r\n\r\n\t\t\tif (lastAction) {\r\n\t\t\t\taction.playerBoard = action.playerBoard ?? lastAction.playerBoard;\r\n\t\t\t\taction.opponentBoard = action.opponentBoard ?? lastAction.opponentBoard;\r\n\t\t\t\taction.playerHand = action.playerHand ?? lastAction.playerHand;\r\n\t\t\t\taction.opponentHand = action.opponentHand ?? lastAction.opponentHand;\r\n\t\t\t\taction.playerSecrets = action.playerSecrets ?? lastAction.playerSecrets;\r\n\t\t\t\taction.opponentSecrets = action.opponentSecrets ?? lastAction.opponentSecrets;\r\n\t\t\t\taction.playerRewardCardId = action.playerRewardCardId ?? lastAction.playerRewardCardId;\r\n\t\t\t\taction.playerRewardEntityId = action.playerRewardEntityId ?? lastAction.playerRewardEntityId;\r\n\t\t\t\taction.playerRewardData = action.playerRewardData ?? lastAction.playerRewardData;\r\n\t\t\t\taction.opponentRewardCardId = action.opponentRewardCardId ?? lastAction.opponentRewardCardId;\r\n\t\t\t\taction.opponentRewardEntityId = action.opponentRewardEntityId ?? lastAction.opponentRewardEntityId;\r\n\t\t\t\taction.opponentRewardData = action.opponentRewardData ?? lastAction.opponentRewardData;\r\n\t\t\t\taction.playerCardId = action.playerCardId ?? lastAction.playerCardId;\r\n\t\t\t\taction.playerEntityId = action.playerEntityId ?? lastAction.playerEntityId;\r\n\t\t\t\taction.playerHeroPowerCardId = action.playerHeroPowerCardId ?? lastAction.playerHeroPowerCardId;\r\n\t\t\t\taction.playerHeroPowerEntityId = action.playerHeroPowerEntityId ?? lastAction.playerHeroPowerEntityId;\r\n\t\t\t\taction.playerHeroPowerUsed = action.playerHeroPowerUsed ?? lastAction.playerHeroPowerUsed;\r\n\t\t\t\taction.opponentCardId = action.opponentCardId ?? lastAction.opponentCardId;\r\n\t\t\t\taction.opponentEntityId = action.opponentEntityId ?? lastAction.opponentEntityId;\r\n\t\t\t\taction.opponentHeroPowerCardId = action.opponentHeroPowerCardId ?? lastAction.opponentHeroPowerCardId;\r\n\t\t\t\taction.opponentHeroPowerEntityId =\r\n\t\t\t\t\taction.opponentHeroPowerEntityId ?? lastAction.opponentHeroPowerEntityId;\r\n\t\t\t\taction.opponentHeroPowerUsed = action.opponentHeroPowerUsed ?? lastAction.opponentHeroPowerUsed;\r\n\t\t\t\taction.playerTrinkets = action.playerTrinkets ?? lastAction.playerTrinkets;\r\n\t\t\t\taction.opponentTrinkets = action.opponentTrinkets ?? lastAction.opponentTrinkets;\r\n\t\t\t}\r\n\r\n\t\t\tif (lastAction && action.type === 'damage' && lastAction.type === 'attack') {\r\n\t\t\t\tlastAction.damages = lastAction.damages || [];\r\n\t\t\t\tlastAction.damages.push({\r\n\t\t\t\t\tdamage: action.damages[0].damage,\r\n\t\t\t\t\tsourceEntityId: action.damages[0].sourceEntityId,\r\n\t\t\t\t\ttargetEntityId: action.damages[0].targetEntityId,\r\n\t\t\t\t});\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t\tlastAction.playerTrinkets = action.playerTrinkets;\r\n\t\t\t\tlastAction.opponentTrinkets = action.opponentTrinkets;\r\n\t\t\t} else if (lastAction && action.type === 'damage' && lastAction.type === 'damage') {\r\n\t\t\t\tlastAction.damages = lastAction.damages || [];\r\n\t\t\t\tlastAction.damages.push({\r\n\t\t\t\t\tdamage: action.damages[0].damage,\r\n\t\t\t\t\tsourceEntityId: action.damages[0].sourceEntityId,\r\n\t\t\t\t\ttargetEntityId: action.damages[0].targetEntityId,\r\n\t\t\t\t});\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t\tlastAction.playerTrinkets = action.playerTrinkets;\r\n\t\t\t\tlastAction.opponentTrinkets = action.opponentTrinkets;\r\n\t\t\t} else if (\r\n\t\t\t\tlastAction &&\r\n\t\t\t\taction.type === 'power-target' &&\r\n\t\t\t\tlastAction.type === 'power-target' &&\r\n\t\t\t\taction.sourceEntityId === lastAction.sourceEntityId\r\n\t\t\t) {\r\n\t\t\t\tlastAction.targetEntityIds =\r\n\t\t\t\t\tlastAction.targetEntityIds ?? (lastAction.targetEntityId ? [lastAction.targetEntityId] : []);\r\n\t\t\t\taction.targetEntityIds =\r\n\t\t\t\t\taction.targetEntityIds ?? (action.targetEntityId ? [action.targetEntityId] : []);\r\n\t\t\t\tlastAction.targetEntityIds.push(...action.targetEntityIds);\r\n\t\t\t\t// So that when multiple Leapfroggers enchantments target the same minion,\r\n\t\t\t\t// we can count them in the replay viewer's text\r\n\t\t\t\t// lastAction.targetEntityIds = [...new Set(lastAction.targetEntityIds)];\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t\tlastAction.playerTrinkets = action.playerTrinkets;\r\n\t\t\t\tlastAction.opponentTrinkets = action.opponentTrinkets;\r\n\t\t\t} else {\r\n\t\t\t\tresult.push(action);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\t// Calling sanitize every time before we add an action to the list is mandatory, since\r\n\t// the entities and boards are mutable\r\n\tprivate sanitize(board: readonly BoardEntity[]): readonly BoardEntity[] {\r\n\t\tif (!board) {\r\n\t\t\treturn undefined;\r\n\t\t}\r\n\t\treturn board.map(\r\n\t\t\t(entity) =>\r\n\t\t\t\t({\r\n\t\t\t\t\tentityId: entity.entityId,\r\n\t\t\t\t\tcardId: entity.cardId,\r\n\t\t\t\t\tfriendly: entity.friendly,\r\n\t\t\t\t\tattack: entity.attack,\r\n\t\t\t\t\thealth: entity.health,\r\n\t\t\t\t\tmaxHealth: entity.maxHealth,\r\n\t\t\t\t\ttaunt: entity.taunt,\r\n\t\t\t\t\tdivineShield: entity.divineShield,\r\n\t\t\t\t\tpoisonous: entity.poisonous,\r\n\t\t\t\t\tvenomous: entity.venomous,\r\n\t\t\t\t\treborn: entity.reborn,\r\n\t\t\t\t\twindfury: entity.windfury,\r\n\t\t\t\t\tstealth: entity.stealth,\r\n\t\t\t\t} as BoardEntity),\r\n\t\t);\r\n\t}\r\n\r\n\tprivate sanitizeTrinkets(trinkets: readonly BoardTrinket[]): readonly BoardTrinket[] {\r\n\t\tif (!trinkets?.length) {\r\n\t\t\treturn undefined;\r\n\t\t}\r\n\t\tconst result = trinkets.map(\r\n\t\t\t(t) =>\r\n\t\t\t\t({\r\n\t\t\t\t\tcardId: t.cardId,\r\n\t\t\t\t\tentityId: t.entityId,\r\n\t\t\t\t\tscriptDataNum1: t.scriptDataNum1,\r\n\t\t\t\t\tscriptDataNum6: t.scriptDataNum6,\r\n\t\t\t\t} as BoardTrinket),\r\n\t\t);\r\n\t\treturn result;\r\n\t}\r\n}\r\n"]}
|
|
@@ -27,12 +27,17 @@ const handleStartOfCombatAnomalies = (playerEntity, playerBoard, opponentEntity,
|
|
|
27
27
|
};
|
|
28
28
|
exports.handleStartOfCombatAnomalies = handleStartOfCombatAnomalies;
|
|
29
29
|
const handleStartOfCombatAnomaliesForPlayer = (input) => {
|
|
30
|
-
var _a;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
for (
|
|
35
|
-
(0
|
|
30
|
+
var _a, _b;
|
|
31
|
+
const loops = ((_a = input.playerEntity.trinkets) === null || _a === void 0 ? void 0 : _a.some((t) => t.cardId === "BG32_MagicItem_365"))
|
|
32
|
+
? 2
|
|
33
|
+
: 1;
|
|
34
|
+
for (let i = 0; i < loops; i++) {
|
|
35
|
+
if (!((_b = input.gameState.anomalies) === null || _b === void 0 ? void 0 : _b.length) || input.playerEntity.startOfCombatDone) {
|
|
36
|
+
return input.currentAttacker;
|
|
37
|
+
}
|
|
38
|
+
for (const anomaly of input.gameState.anomalies) {
|
|
39
|
+
(0, soc_action_processor_1.performStartOfCombatAction)(anomaly, input.playerEntity, input, false);
|
|
40
|
+
}
|
|
36
41
|
}
|
|
37
42
|
return input.currentAttacker;
|
|
38
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"soc-anomalies.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-anomalies.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"soc-anomalies.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-anomalies.ts"],"names":[],"mappings":";;;AAIA,4DAA8D;AAC9D,iEAAoE;AAG7D,MAAM,4BAA4B,GAAG,CAC3C,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IACX,eAAe,GAAG,qCAAqC,CAAC;QACvD,YAAY,EAAE,YAAY;QAC1B,WAAW,EAAE,WAAW;QAC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one-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { FullGameState } from '../internal-game-state';\r\nimport { handleSummonsWhenSpace } from '../summon-when-space';\r\nimport { performStartOfCombatAction } from './soc-action-processor';\r\nimport { SoCInput } from './start-of-combat-input';\r\n\r\nexport const handleStartOfCombatAnomalies = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tcurrentAttacker = handleStartOfCombatAnomaliesForPlayer({\r\n\t\tplayerEntity: playerEntity,\r\n\t\tplayerBoard: playerBoard,\r\n\t\topponentEntity: opponentEntity,\r\n\t\topponentBoard: opponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t\tplayerIsFriendly: true,\r\n\t});\r\n\tcurrentAttacker = handleStartOfCombatAnomaliesForPlayer({\r\n\t\tplayerEntity: opponentEntity,\r\n\t\tplayerBoard: opponentBoard,\r\n\t\topponentEntity: playerEntity,\r\n\t\topponentBoard: playerBoard,\r\n\t\tcurrentAttacker,\r\n\t\tgameState,\r\n\t\tplayerIsFriendly: false,\r\n\t});\r\n\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatAnomaliesForPlayer = (input: SoCInput): number => {\r\n\tconst loops = input.playerEntity.trinkets?.some((t) => t.cardId === CardIds.ValdrakkenWindChimes_BG32_MagicItem_365)\r\n\t\t? 2\r\n\t\t: 1;\r\n\tfor (let i = 0; i < loops; i++) {\r\n\t\tif (!input.gameState.anomalies?.length || input.playerEntity.startOfCombatDone) {\r\n\t\t\treturn input.currentAttacker;\r\n\t\t}\r\n\r\n\t\tfor (const anomaly of input.gameState.anomalies) {\r\n\t\t\tperformStartOfCombatAction(anomaly, input.playerEntity, input, false);\r\n\t\t}\r\n\t}\r\n\r\n\treturn input.currentAttacker;\r\n};\r\n"]}
|
|
@@ -49,11 +49,17 @@ const handleStartOfCombatHeroPowers = (playerEntity, playerBoard, opponentEntity
|
|
|
49
49
|
};
|
|
50
50
|
exports.handleStartOfCombatHeroPowers = handleStartOfCombatHeroPowers;
|
|
51
51
|
const handlePlayerStartOfCombatHeroPowers = (input) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
var _a;
|
|
53
|
+
const loops = ((_a = input.playerEntity.trinkets) === null || _a === void 0 ? void 0 : _a.some((t) => t.cardId === "BG32_MagicItem_365"))
|
|
54
|
+
? 2
|
|
55
|
+
: 1;
|
|
56
|
+
for (let i = 0; i < loops; i++) {
|
|
57
|
+
if (input.playerEntity.startOfCombatDone || input.playerEntity.hpLeft <= 0) {
|
|
58
|
+
return input.currentAttacker;
|
|
59
|
+
}
|
|
60
|
+
for (const heroPower of input.playerEntity.heroPowers) {
|
|
61
|
+
(0, soc_action_processor_1.performStartOfCombatAction)(heroPower.cardId, input.playerEntity, input, true, 'start-of-combat');
|
|
62
|
+
}
|
|
57
63
|
}
|
|
58
64
|
return input.currentAttacker;
|
|
59
65
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"soc-hero-power.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-hero-power.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"soc-hero-power.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-hero-power.ts"],"names":[],"mappings":";;;AAIA,4DAA8D;AAC9D,iEAAoE;AAG7D,MAAM,6BAA6B,GAAG,CAC5C,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IAGX,IAAI,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,EAA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ACL,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;QAC/B,IAAI,KAAK,CAAC,YAAY,CAAC,iBAAiB,IAAI,KAAK,CAAC,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE;YAC3E,OAAO,KAAK,CAAC,eAAe,CAAC;SAC7B;QAED,KAAK,MAAM,SAAS,IAAI,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE;YACtD,IAAA,iDAA0B,EAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,iBAAiB,CAAC,CAAC;SACjG;KACD;IACD,OAAO,KAAK,CAAC,eAAe,CAAC;AAC9B,CAAC,CAAC","sourcesContent":["import { CardIds } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { FullGameState } from '../internal-game-state';\r\nimport { handleSummonsWhenSpace } from '../summon-when-space';\r\nimport { performStartOfCombatAction } from './soc-action-processor';\r\nimport { SoCInput } from './start-of-combat-input';\r\n\r\nexport const handleStartOfCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\t// Apparently it's a toin coss about whether to handle Illidan first or Al'Akir first\r\n\t// Auras are only relevant for Illidan, and already applied there\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t} else {\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t}\r\n\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePlayerStartOfCombatHeroPowers = (input: SoCInput): number => {\r\n\tconst loops = input.playerEntity.trinkets?.some((t) => t.cardId === CardIds.ValdrakkenWindChimes_BG32_MagicItem_365)\r\n\t\t? 2\r\n\t\t: 1;\r\n\tfor (let i = 0; i < loops; i++) {\r\n\t\tif (input.playerEntity.startOfCombatDone || input.playerEntity.hpLeft <= 0) {\r\n\t\t\treturn input.currentAttacker;\r\n\t\t}\r\n\r\n\t\tfor (const heroPower of input.playerEntity.heroPowers) {\r\n\t\t\tperformStartOfCombatAction(heroPower.cardId, input.playerEntity, input, true, 'start-of-combat');\r\n\t\t}\r\n\t}\r\n\treturn input.currentAttacker;\r\n};\r\n\r\n// export const getHeroPowerForHero = (heroCardId: string): string => {\r\n// \tswitch (heroCardId) {\r\n// \t\tcase CardIds.IllidanStormrage_TB_BaconShop_HERO_08:\r\n// \t\t\treturn CardIds.Wingmen;\r\n// \t\tcase CardIds.TheLichKing_TB_BaconShop_HERO_22:\r\n// \t\t\treturn CardIds.RebornRites;\r\n// \t\tcase CardIds.ProfessorPutricide_BG25_HERO_100:\r\n// \t\t\treturn CardIds.RagePotion;\r\n// \t\tcase CardIds.Deathwing_TB_BaconShop_HERO_52:\r\n// \t\t\treturn CardIds.AllWillBurn;\r\n// \t\tcase CardIds.TeronGorefiend_BG25_HERO_103:\r\n// \t\t\treturn CardIds.TeronGorefiend_RapidReanimation;\r\n// \t}\r\n// \treturn null;\r\n// };\r\n"]}
|
|
@@ -19,13 +19,19 @@ const handleIllidanHeroPowers = (playerEntity, playerBoard, opponentEntity, oppo
|
|
|
19
19
|
};
|
|
20
20
|
exports.handleIllidanHeroPowers = handleIllidanHeroPowers;
|
|
21
21
|
const handlePlayerIllidanHeroPowers = (playerEntity, playerBoard, opponentEntity, opponentBoard, currentAttacker, friendly, gameState) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
currentAttacker
|
|
22
|
+
var _a;
|
|
23
|
+
const loops = ((_a = playerEntity.trinkets) === null || _a === void 0 ? void 0 : _a.some((t) => t.cardId === "BG32_MagicItem_365"))
|
|
24
|
+
? 2
|
|
25
|
+
: 1;
|
|
26
|
+
for (let i = 0; i < loops; i++) {
|
|
27
|
+
if (playerEntity.hpLeft <= 0) {
|
|
28
|
+
return currentAttacker;
|
|
29
|
+
}
|
|
30
|
+
for (const heroPower of playerEntity.heroPowers) {
|
|
31
|
+
if (heroPower.cardId === "TB_BaconShop_HP_069" && playerBoard.length > 0) {
|
|
32
|
+
handleIllidanForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState, currentAttacker);
|
|
33
|
+
currentAttacker = Math.random() < 0.5 ? 0 : 1;
|
|
34
|
+
}
|
|
29
35
|
}
|
|
30
36
|
}
|
|
31
37
|
return currentAttacker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"soc-illidan-hero-power.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-illidan-hero-power.ts"],"names":[],"mappings":";;;AAGA,sCAA+D;AAE/D,oCAAuC;AACvC,4DAA8D;AAEvD,MAAM,uBAAuB,GAAG,CACtC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IAIX,IAAI,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,EAAE;QACxB,eAAe,GAAG,6BAA6B,CAC9C,YAAY,EACZ,WAAW,EACX,cAAc,EACd,aAAa,EACb,eAAe,EACf,IAAI,EACJ,SAAS,CACT,CAAC;QACF,eAAe,GAAG,6BAA6B,CAC9C,cAAc,EACd,aAAa,EACb,YAAY,EACZ,WAAW,EACX,eAAe,EACf,KAAK,EACL,SAAS,CACT,CAAC;KACF;SAAM;QACN,eAAe,GAAG,6BAA6B,CAC9C,cAAc,EACd,aAAa,EACb,YAAY,EACZ,WAAW,EACX,eAAe,EACf,KAAK,EACL,SAAS,CACT,CAAC;QACF,eAAe,GAAG,6BAA6B,CAC9C,YAAY,EACZ,WAAW,EACX,cAAc,EACd,aAAa,EACb,eAAe,EACf,IAAI,EACJ,SAAS,CACT,CAAC;KACF;IACD,IAAA,2BAAkB,EAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;IACxF,IAAA,0CAAsB,EAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;IAC5F,OAAO,eAAe,CAAC;AACxB,CAAC,CAAC;AArDW,QAAA,uBAAuB,2BAqDlC;AAEF,MAAM,6BAA6B,GAAG,CACrC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,QAAiB,EACjB,SAAwB,EACf,EAAE
|
|
1
|
+
{"version":3,"file":"soc-illidan-hero-power.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-illidan-hero-power.ts"],"names":[],"mappings":";;;AAGA,sCAA+D;AAE/D,oCAAuC;AACvC,4DAA8D;AAEvD,MAAM,uBAAuB,GAAG,CACtC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IAIX,IAAI,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,EAAE;QACxB,eAAe,GAAG,6BAA6B,CAC9C,YAAY,EACZ,WAAW,EACX,cAAc,EACd,aAAa,EACb,eAAe,EACf,IAAI,EACJ,SAAS,CACT,CAAC;QACF,eAAe,GAAG,6BAA6B,CAC9C,cAAc,EACd,aAAa,EACb,YAAY,EACZ,WAAW,EACX,eAAe,EACf,KAAK,EACL,SAAS,CACT,CAAC;KACF;SAAM;QACN,eAAe,GAAG,6BAA6B,CAC9C,cAAc,EACd,aAAa,EACb,YAAY,EACZ,WAAW,EACX,eAAe,EACf,KAAK,EACL,SAAS,CACT,CAAC;QACF,eAAe,GAAG,6BAA6B,CAC9C,YAAY,EACZ,WAAW,EACX,cAAc,EACd,aAAa,EACb,eAAe,EACf,IAAI,EACJ,SAAS,CACT,CAAC;KACF;IACD,IAAA,2BAAkB,EAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;IACxF,IAAA,0CAAsB,EAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;IAC5F,OAAO,eAAe,CAAC;AACxB,CAAC,CAAC;AArDW,QAAA,uBAAuB,2BAqDlC;AAEF,MAAM,6BAA6B,GAAG,CACrC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B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AGvF,IAAA,mBAAW,EAAC,aAAa,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;IACrF,IAAI,CAAC,CAAC,cAAc,IAAI,CAAC,cAAc,CAAC,cAAc,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;QACpF,IAAA,mBAAW,EAAC,cAAc,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;KACtF;IAGD,aAAa,CAAC,iBAAiB,GAAG,IAAI,CAAC;IACvC,IAAA,uBAAc,EAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;IAEpF,aAAa,CAAC,WAAW,GAAG,CAAC,CAAC;IAC9B,IAAI,CAAC,CAAC,cAAc,IAAI,CAAC,cAAc,CAAC,cAAc,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;QACpF,cAAc,CAAC,iBAAiB,GAAG,IAAI,CAAC;QACxC,IAAA,uBAAc,EAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;QACpF,cAAc,CAAC,WAAW,GAAG,CAAC,CAAC;KAC/B;AAOF,CAAC,CAAC","sourcesContent":["import { CardIds } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { processMinionDeath, simulateAttack } from '../attack';\r\nimport { FullGameState } from '../internal-game-state';\r\nimport { modifyStats } from '../stats';\r\nimport { handleSummonsWhenSpace } from '../summon-when-space';\r\n\r\nexport const handleIllidanHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\t// console.log('current attacker before', currentAttacker);\r\n\t// Apparently it's a toin coss about whether to handle Illidan first or Al'Akir first\r\n\t// Auras are only relevant for Illidan, and already applied there\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t} else {\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\tprocessMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePlayerIllidanHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tconst loops = playerEntity.trinkets?.some((t) => t.cardId === CardIds.ValdrakkenWindChimes_BG32_MagicItem_365)\r\n\t\t? 2\r\n\t\t: 1;\r\n\tfor (let i = 0; i < loops; i++) {\r\n\t\tif (playerEntity.hpLeft <= 0) {\r\n\t\t\treturn currentAttacker;\r\n\t\t}\r\n\t\tfor (const heroPower of playerEntity.heroPowers) {\r\n\t\t\tif (heroPower.cardId === CardIds.Wingmen && playerBoard.length > 0) {\r\n\t\t\t\t// After Illidan triggers, it's always the other opponent's turn\r\n\t\t\t\t// https://x.com/LoewenMitchell/status/1752714583360639131?s=20\r\n\t\t\t\thandleIllidanForPlayer(\r\n\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentEntity,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t\tcurrentAttacker,\r\n\t\t\t\t);\r\n\t\t\t\t// This is not true anymore: https://replays.firestoneapp.com/?reviewId=7282387d-66cd-458e-8ee1-e04c662e7bad&turn=5&action=1\r\n\t\t\t\t// currentAttacker = friendly ? 1 : 0;\r\n\t\t\t\t// In fact there is some adjustment going on: https://replays.firestoneapp.com/?reviewId=929f676f-47f6-494b-9619-df04174a0150&turn=11&action=0\r\n\t\t\t\t// So trying another logic\r\n\t\t\t\t// currentAttacker = (currentAttacker + 1) % 2;\r\n\t\t\t\t// This isn't correct. The following game is a case of:\r\n\t\t\t\t// The player with the fewer minions is Illidan, so isn't the \"first attacker\"\r\n\t\t\t\t// Wingmen triggers\r\n\t\t\t\t// The non-Illidan side then attacks first\r\n\t\t\t\t// https://replays.firestoneapp.com/?reviewId=45f40e73-4be9-419f-9093-0c2d91a7bac2&turn=5&action=0\r\n\t\t\t\t// So for now, just randomizing the attacker to try and avoid \"impossible\" scenarios as much as possible\r\n\t\t\t\tcurrentAttacker = Math.random() < 0.5 ? 0 : 1;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\n// TODO: not exactly correct, because of \"attack immediately\", but it's close enough\r\nconst handleIllidanForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tcurrentAttacker: number,\r\n): void => {\r\n\tif (playerEntity.startOfCombatDone) {\r\n\t\treturn;\r\n\t}\r\n\t// Otherwise, if the first minion dies on the attack, and the board has only 2 minions, we\r\n\t// miss the second one\r\n\tconst minionsAtStart = playerBoard.length;\r\n\tconst firstAttacker = playerBoard[0];\r\n\tconst secondAttacker = minionsAtStart > 1 ? playerBoard[playerBoard.length - 1] : null;\r\n\r\n\t// Stats updates\r\n\tmodifyStats(firstAttacker, playerEntity, 2, 1, playerBoard, playerEntity, gameState);\r\n\tif (!!secondAttacker && !secondAttacker.definitelyDead && secondAttacker.health > 0) {\r\n\t\tmodifyStats(secondAttacker, playerEntity, 2, 1, playerBoard, playerEntity, gameState);\r\n\t}\r\n\r\n\t// Attacks\r\n\tfirstAttacker.attackImmediately = true;\r\n\tsimulateAttack(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t// See http://replays.firestoneapp.com/?reviewId=f16b7a49-c2a2-4ac5-a9eb-a75f83246f70&turn=6&action=8\r\n\tfirstAttacker.hasAttacked = 0;\r\n\tif (!!secondAttacker && !secondAttacker.definitelyDead && secondAttacker.health > 0) {\r\n\t\tsecondAttacker.attackImmediately = true;\r\n\t\tsimulateAttack(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\tsecondAttacker.hasAttacked = 0;\r\n\t}\r\n\r\n\t// // See http://replays.firestoneapp.com/?reviewId=7e9ec42c-a8f6-43d2-9f39-cc486dfa2395&turn=6&action=5\r\n\t// if (firstAttacker.definitelyDead || firstAttacker.health <= 0) {\r\n\t// \tcurrentAttacker = (currentAttacker + 1) % 2;\r\n\t// }\r\n\t// return currentAttacker;\r\n};\r\n"]}
|
|
@@ -70,10 +70,17 @@ const handleStartOfCombatMinions = (playerEntity, playerBoard, opponentEntity, o
|
|
|
70
70
|
};
|
|
71
71
|
exports.handleStartOfCombatMinions = handleStartOfCombatMinions;
|
|
72
72
|
const performStartOfCombatMinionsForPlayer = (minion, input) => {
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
var _a;
|
|
74
|
+
const loops = ((_a = input.playerEntity.trinkets) === null || _a === void 0 ? void 0 : _a.some((t) => t.cardId === "BG32_MagicItem_365"))
|
|
75
|
+
? 2
|
|
76
|
+
: 1;
|
|
77
|
+
let hasProcessed = false;
|
|
78
|
+
for (let i = 0; i < loops; i++) {
|
|
79
|
+
if (input.playerEntity.startOfCombatDone) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
hasProcessed = (0, soc_action_processor_1.performStartOfCombatAction)(minion.cardId, minion, input, true) || hasProcessed;
|
|
75
83
|
}
|
|
76
|
-
const hasProcessed = (0, soc_action_processor_1.performStartOfCombatAction)(minion.cardId, minion, input, true);
|
|
77
84
|
return hasProcessed;
|
|
78
85
|
};
|
|
79
86
|
exports.performStartOfCombatMinionsForPlayer = performStartOfCombatMinionsForPlayer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"soc-minion.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-minion.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"soc-minion.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-minion.ts"],"names":[],"mappings":";;;AAGA,+DAAsE;AACtE,oEAA+D;AAE/D,4DAA8D;AAC9D,iEAAoE;AAG7D,MAAM,0BAA0B,GAAG,CACzC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,iBAAgC,EAChC,mBAAkC,EAClC,SAAwB,EACf,EAAE;IACX,IAAI,gBAAgB,GAAG,IAAI,CAA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KAAe,EAAW,EAAE;;IACrG,MAAM,KAAK,GAAG,CAAA,MAAA,KAAK,CAAC,YAAY,CAAC,QAAQ,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,yBAAoD,CAAC;QACnH,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,CAAC,CAAC;IACL,IAAI,YAAY,GAAG,KAAK,CAAC;IACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;QAC/B,IAAI,KAAK,CAAC,YAAY,CAAC,iBAAiB,EAAE;YACzC,OAAO,KAAK,CAAC;SACb;QAED,YAAY,GAAG,IAAA,iDAA0B,EAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,YAAY,CAAC;KAC9F;IACD,OAAO,YAAY,CAAC;AACrB,CAAC,CAAC;AAbW,QAAA,oCAAoC,wCAa/C","sourcesContent":["import { CardIds } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { hasStartOfCombatFromHand } from '../../cards/card.interface';\r\nimport { cardMappings } from '../../cards/impl/_card-mappings';\r\nimport { FullGameState } from '../internal-game-state';\r\nimport { handleSummonsWhenSpace } from '../summon-when-space';\r\nimport { performStartOfCombatAction } from './soc-action-processor';\r\nimport { SoCInput } from './start-of-combat-input';\r\n\r\nexport const handleStartOfCombatMinions = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tplayerBoardBefore: BoardEntity[],\r\n\topponentBoardBefore: BoardEntity[],\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tlet attackerForStart = Math.random() < 0.5 ? 0 : 1;\r\n\tconst playerAttackers = [\r\n\t\t...playerBoard,\r\n\t\t...playerEntity.hand.filter((e) => hasStartOfCombatFromHand(cardMappings[e.cardId])),\r\n\t];\r\n\tconst opponentAttackers = [\r\n\t\t...opponentBoard,\r\n\t\t...opponentEntity.hand.filter((e) => hasStartOfCombatFromHand(cardMappings[e.cardId])),\r\n\t];\r\n\r\n\twhile (playerAttackers.length > 0 || opponentAttackers.length > 0) {\r\n\t\tlet shouldUpdateNextPlayer = false;\r\n\t\tif (attackerForStart === 0 && playerAttackers.length > 0) {\r\n\t\t\tconst attacker = playerAttackers.splice(0, 1)[0];\r\n\t\t\tif (attacker.health <= 0 || attacker.definitelyDead) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tconst input = {\r\n\t\t\t\tplayerBoard: playerBoard,\r\n\t\t\t\tplayerEntity: playerEntity,\r\n\t\t\t\topponentBoard: opponentBoard,\r\n\t\t\t\topponentEntity: opponentEntity,\r\n\t\t\t\tplayerBoardBefore: playerBoardBefore,\r\n\t\t\t\topponentBoardBefore: opponentBoardBefore,\r\n\t\t\t\tplayerIsFriendly: true,\r\n\t\t\t\tcurrentAttacker: currentAttacker,\r\n\t\t\t\tgameState,\r\n\t\t\t};\r\n\t\t\tshouldUpdateNextPlayer = performStartOfCombatMinionsForPlayer(attacker, input);\r\n\t\t\tcurrentAttacker = input.currentAttacker;\r\n\t\t} else if (attackerForStart === 0 && playerAttackers.length === 0) {\r\n\t\t\tshouldUpdateNextPlayer = true;\r\n\t\t} else if (attackerForStart === 1 && opponentAttackers.length > 0) {\r\n\t\t\tconst attacker = opponentAttackers.splice(0, 1)[0];\r\n\t\t\tif (attacker.health <= 0 || attacker.definitelyDead) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tconst input = {\r\n\t\t\t\tplayerBoard: opponentBoard,\r\n\t\t\t\tplayerEntity: opponentEntity,\r\n\t\t\t\topponentBoard: playerBoard,\r\n\t\t\t\topponentEntity: playerEntity,\r\n\t\t\t\tplayerBoardBefore: opponentBoardBefore,\r\n\t\t\t\topponentBoardBefore: playerBoardBefore,\r\n\t\t\t\tplayerIsFriendly: false,\r\n\t\t\t\tcurrentAttacker: currentAttacker,\r\n\t\t\t\tgameState,\r\n\t\t\t};\r\n\t\t\tshouldUpdateNextPlayer = performStartOfCombatMinionsForPlayer(attacker, input);\r\n\t\t\tcurrentAttacker = input.currentAttacker;\r\n\t\t} else if (attackerForStart === 1 && opponentAttackers.length === 0) {\r\n\t\t\tshouldUpdateNextPlayer = true;\r\n\t\t}\r\n\r\n\t\tif (shouldUpdateNextPlayer) {\r\n\t\t\tattackerForStart = (attackerForStart + 1) % 2;\r\n\t\t}\r\n\t}\r\n\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn currentAttacker;\r\n};\r\n\r\n// Apparently, the board composition used for start of combat minion effects (like Red Whelp, and I assume it works the\r\n// same way for others like Prized Promo Drake or Mantid Queen) is the one that is used before Illidan's effect is handled.\r\n// Since this also runs before HP start of combat, we probably also use the state as it was before HP were triggered, like\r\n// Tamsin's Phylactery.\r\nexport const performStartOfCombatMinionsForPlayer = (minion: BoardEntity, input: SoCInput): boolean => {\r\n\tconst loops = input.playerEntity.trinkets?.some((t) => t.cardId === CardIds.ValdrakkenWindChimes_BG32_MagicItem_365)\r\n\t\t? 2\r\n\t\t: 1;\r\n\tlet hasProcessed = false;\r\n\tfor (let i = 0; i < loops; i++) {\r\n\t\tif (input.playerEntity.startOfCombatDone) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\thasProcessed = performStartOfCombatAction(minion.cardId, minion, input, true) || hasProcessed;\r\n\t}\r\n\treturn hasProcessed;\r\n};\r\n"]}
|
|
@@ -67,11 +67,17 @@ const handlePreCombatHeroPowers = (playerEntity, playerBoard, opponentEntity, op
|
|
|
67
67
|
};
|
|
68
68
|
exports.handlePreCombatHeroPowers = handlePreCombatHeroPowers;
|
|
69
69
|
const handlePreCombatHeroPowersForPlayer = (input) => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
var _a;
|
|
71
|
+
const loops = ((_a = input.playerEntity.trinkets) === null || _a === void 0 ? void 0 : _a.some((t) => t.cardId === "BG32_MagicItem_365"))
|
|
72
|
+
? 2
|
|
73
|
+
: 1;
|
|
74
|
+
for (let i = 0; i < loops; i++) {
|
|
75
|
+
if (input.playerEntity.startOfCombatDone || input.playerEntity.hpLeft <= 0) {
|
|
76
|
+
return input.currentAttacker;
|
|
77
|
+
}
|
|
78
|
+
for (const heroPower of input.playerEntity.heroPowers) {
|
|
79
|
+
(0, soc_action_processor_1.performStartOfCombatAction)(heroPower.cardId, input.playerEntity, input, true, 'pre-combat');
|
|
80
|
+
}
|
|
75
81
|
}
|
|
76
82
|
return input.currentAttacker;
|
|
77
83
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"soc-pre-combat-hero-power.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-pre-combat-hero-power.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"soc-pre-combat-hero-power.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-pre-combat-hero-power.ts"],"names":[],"mappings":";;;AAIA,4DAA8D;AAC9D,iEAAoE;AAG7D,MAAM,yBAAyB,GAAG,CACxC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IACX,IAAI,sBAAsB,GAAG,WAAW,CAAC,MAAM,CAAC;IAChD,IAAI,wBAAwB,GAAG,aAAa,CAAC,MAAM,CAAC;IACpD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC7B,IAAI,MAAM,GAAG,GAAG,EAAE;QACjB,eAAe,GAAG,kCAAkC,CAAC;YACpD,YAAY,EAAE,YAAY;YAC1B,WAAW,EAAE,WAAW;YACxB,cAAc,EAAE,cAAc;YAC9B,aA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entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { FullGameState } from '../internal-game-state';\r\nimport { handleSummonsWhenSpace } from '../summon-when-space';\r\nimport { performStartOfCombatAction } from './soc-action-processor';\r\nimport { SoCInput } from './start-of-combat-input';\r\n\r\nexport const handlePreCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tlet initialPlayerBoardSize = playerBoard.length;\r\n\tlet initialOpponentBoardSize = opponentBoard.length;\r\n\tconst random = Math.random();\r\n\tif (random < 0.5) {\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialPlayerBoardSize = playerBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialOpponentBoardSize = opponentBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t} else {\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialOpponentBoardSize = opponentBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialPlayerBoardSize = playerBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t}\r\n\t// Ozumat's Tentaclecan cause the first player to be recomputed\r\n\t// https://replays.firestoneapp.com/?reviewId=f15c90de-8b3c-4017-960d-365fe09eb7ab&turn=5&action=1\r\n\tif (playerBoard.length !== initialPlayerBoardSize || opponentBoard.length !== initialOpponentBoardSize) {\r\n\t\tcurrentAttacker =\r\n\t\t\tplayerBoard.length > opponentBoard.length\r\n\t\t\t\t? 0\r\n\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t? 1\r\n\t\t\t\t: Math.round(Math.random());\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePreCombatHeroPowersForPlayer = (input: SoCInput): number => {\r\n\tconst loops = input.playerEntity.trinkets?.some((t) => t.cardId === CardIds.ValdrakkenWindChimes_BG32_MagicItem_365)\r\n\t\t? 2\r\n\t\t: 1;\r\n\tfor (let i = 0; i < loops; i++) {\r\n\t\tif (input.playerEntity.startOfCombatDone || input.playerEntity.hpLeft <= 0) {\r\n\t\t\treturn input.currentAttacker;\r\n\t\t}\r\n\r\n\t\tfor (const heroPower of input.playerEntity.heroPowers) {\r\n\t\t\tperformStartOfCombatAction(heroPower.cardId, input.playerEntity, input, true, 'pre-combat');\r\n\t\t}\r\n\t}\r\n\r\n\treturn input.currentAttacker;\r\n};\r\n"]}
|
|
@@ -49,11 +49,17 @@ const handleStartOfCombatQuestRewards = (playerEntity, playerBoard, opponentEnti
|
|
|
49
49
|
};
|
|
50
50
|
exports.handleStartOfCombatQuestRewards = handleStartOfCombatQuestRewards;
|
|
51
51
|
const handleStartOfCombatQuestRewardsForPlayer = (input) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
var _a;
|
|
53
|
+
const loops = ((_a = input.playerEntity.trinkets) === null || _a === void 0 ? void 0 : _a.some((t) => t.cardId === "BG32_MagicItem_365"))
|
|
54
|
+
? 2
|
|
55
|
+
: 1;
|
|
56
|
+
for (let i = 0; i < loops; i++) {
|
|
57
|
+
if (input.playerEntity.startOfCombatDone) {
|
|
58
|
+
return input.currentAttacker;
|
|
59
|
+
}
|
|
60
|
+
for (const reward of input.playerEntity.questRewards) {
|
|
61
|
+
(0, soc_action_processor_1.performStartOfCombatAction)(reward, input.playerEntity, input, false);
|
|
62
|
+
}
|
|
57
63
|
}
|
|
58
64
|
return input.currentAttacker;
|
|
59
65
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"soc-quest-reward.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-quest-reward.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"soc-quest-reward.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-quest-reward.ts"],"names":[],"mappings":";;;AAIA,4DAA8D;AAC9D,iEAAoE;AAG7D,MAAM,+BAA+B,GAAG,CAC9C,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IACX,IAAI,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,EAAE;QACxB,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,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;QAC/B,IAAI,KAAK,CAAC,YAAY,CAAC,iBAAiB,EAAE;YACzC,OAAO,KAAK,CAAC,eAAe,CAAC;SAC7B;QAED,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE;YACrD,IAAA,iDAA0B,EAAC,MAAM,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;SACrE;KACD;IAED,OAAO,KAAK,CAAC,eAAe,CAAC;AAC9B,CAAC,CAAC","sourcesContent":["import { CardIds } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { FullGameState } from '../internal-game-state';\r\nimport { handleSummonsWhenSpace } from '../summon-when-space';\r\nimport { performStartOfCombatAction } from './soc-action-processor';\r\nimport { SoCInput } from './start-of-combat-input';\r\n\r\nexport const handleStartOfCombatQuestRewards = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handleStartOfCombatQuestRewardsForPlayer({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t});\r\n\t\tcurrentAttacker = handleStartOfCombatQuestRewardsForPlayer({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t});\r\n\t} else {\r\n\t\tcurrentAttacker = handleStartOfCombatQuestRewardsForPlayer({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t});\r\n\t\tcurrentAttacker = handleStartOfCombatQuestRewardsForPlayer({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t});\r\n\t}\r\n\r\n\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatQuestRewardsForPlayer = (input: SoCInput): number => {\r\n\tconst loops = input.playerEntity.trinkets?.some((t) => t.cardId === CardIds.ValdrakkenWindChimes_BG32_MagicItem_365)\r\n\t\t? 2\r\n\t\t: 1;\r\n\tfor (let i = 0; i < loops; i++) {\r\n\t\tif (input.playerEntity.startOfCombatDone) {\r\n\t\t\treturn input.currentAttacker;\r\n\t\t}\r\n\r\n\t\tfor (const reward of input.playerEntity.questRewards) {\r\n\t\t\tperformStartOfCombatAction(reward, input.playerEntity, input, false);\r\n\t\t}\r\n\t}\r\n\r\n\treturn input.currentAttacker;\r\n};\r\n"]}
|
|
@@ -49,12 +49,17 @@ const handleStartOfCombatSecrets = (playerEntity, playerBoard, opponentEntity, o
|
|
|
49
49
|
};
|
|
50
50
|
exports.handleStartOfCombatSecrets = handleStartOfCombatSecrets;
|
|
51
51
|
const handleStartOfCombatSecretsForPlayer = (input) => {
|
|
52
|
-
var _a;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
for (
|
|
57
|
-
(
|
|
52
|
+
var _a, _b;
|
|
53
|
+
const loops = ((_a = input.playerEntity.trinkets) === null || _a === void 0 ? void 0 : _a.some((t) => t.cardId === "BG32_MagicItem_365"))
|
|
54
|
+
? 2
|
|
55
|
+
: 1;
|
|
56
|
+
for (let i = 0; i < loops; i++) {
|
|
57
|
+
if (input.playerEntity.startOfCombatDone) {
|
|
58
|
+
return input.currentAttacker;
|
|
59
|
+
}
|
|
60
|
+
for (const secret of (_b = input.playerEntity.secrets) !== null && _b !== void 0 ? _b : []) {
|
|
61
|
+
(0, soc_action_processor_1.performStartOfCombatAction)(secret.cardId, secret, input, false);
|
|
62
|
+
}
|
|
58
63
|
}
|
|
59
64
|
return input.currentAttacker;
|
|
60
65
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"soc-secret.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-secret.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"soc-secret.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-secret.ts"],"names":[],"mappings":";;;AAIA,4DAA8D;AAC9D,iEAAoE;AAG7D,MAAM,0BAA0B,GAAG,CACzC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IACX,IAAI,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,EAAE;QACxB,eAAe,GAAG,mCAAmC,CAAC;YACrD,YAAY,EAAE,YAAY;YAC1B,WAAW,EAAE,WAAW;YACxB,cAAc,EAAE,cAAc;YAC9B,aAAa,EAAE,aAAa;YAC5B,eAAe;YACf,SAAS;YACT,gBAAgB,EAAE,IAAI;SACtB,CAAC,CAAC;QACH,eAAe,GAAG,mCAAmC,CAAC;YACrD,YAAY,EAAE,cAAc;YAC5B,WAAW,EAAE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DAA0B,EAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;SAChE;KACD;IACD,OAAO,KAAK,CAAC,eAAe,CAAC;AAC9B,CAAC,CAAC","sourcesContent":["import { CardIds } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { FullGameState } from '../internal-game-state';\r\nimport { handleSummonsWhenSpace } from '../summon-when-space';\r\nimport { performStartOfCombatAction } from './soc-action-processor';\r\nimport { SoCInput } from './start-of-combat-input';\r\n\r\nexport const handleStartOfCombatSecrets = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handleStartOfCombatSecretsForPlayer({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t});\r\n\t\tcurrentAttacker = handleStartOfCombatSecretsForPlayer({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t});\r\n\t} else {\r\n\t\tcurrentAttacker = handleStartOfCombatSecretsForPlayer({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t});\r\n\t\tcurrentAttacker = handleStartOfCombatSecretsForPlayer({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tgameState,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t});\r\n\t}\r\n\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatSecretsForPlayer = (input: SoCInput): number => {\r\n\tconst loops = input.playerEntity.trinkets?.some((t) => t.cardId === CardIds.ValdrakkenWindChimes_BG32_MagicItem_365)\r\n\t\t? 2\r\n\t\t: 1;\r\n\tfor (let i = 0; i < loops; i++) {\r\n\t\tif (input.playerEntity.startOfCombatDone) {\r\n\t\t\treturn input.currentAttacker;\r\n\t\t}\r\n\t\tfor (const secret of input.playerEntity.secrets ?? []) {\r\n\t\t\tperformStartOfCombatAction(secret.cardId, secret, input, false);\r\n\t\t}\r\n\t}\r\n\treturn input.currentAttacker;\r\n};\r\n"]}
|