@firestone-hs/simulate-bgs-battle 1.1.433 → 1.1.434

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.
@@ -6,6 +6,7 @@ export interface BgsPlayerEntity {
6
6
  readonly hpLeft: number;
7
7
  readonly tavernTier: number;
8
8
  readonly heroPowerId?: string | undefined | null;
9
+ readonly heroPowerEntityId?: number;
9
10
  readonly heroPowerUsed: boolean;
10
11
  readonly heroPowerInfo?: number | string;
11
12
  readonly heroPowerInfo2?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"bgs-player-entity.js","sourceRoot":"","sources":["../src/bgs-player-entity.ts"],"names":[],"mappings":"","sourcesContent":["import { BoardEntity } from './board-entity';\r\nimport { BoardSecret } from './board-secret';\r\n\r\nexport interface BgsPlayerEntity {\r\n\treadonly cardId: string;\r\n\treadonly nonGhostCardId?: string;\r\n\treadonly hpLeft: number;\r\n\treadonly tavernTier: number;\r\n\treadonly heroPowerId?: string | undefined | null;\r\n\treadonly heroPowerUsed: boolean;\r\n\treadonly heroPowerInfo?: number | string;\r\n\treadonly heroPowerInfo2?: number;\r\n\tfriendly?: boolean;\r\n\tentityId?: number;\r\n\tquestEntities: BgsQuestEntity[];\r\n\tquestRewards?: string[];\r\n\tquestRewardEntities?: {\r\n\t\tcardId: string;\r\n\t\tentityId: number;\r\n\t\tavengeDefault?: number;\r\n\t\tavengeCurrent?: number;\r\n\t\tscriptDataNum1: number;\r\n\t}[];\r\n\thand?: BoardEntity[];\r\n\tsecrets?: BoardSecret[];\r\n\tavengeCurrent?: number;\r\n\tavengeDefault?: number;\r\n\tglobalInfo?: BgsPlayerGlobalInfo;\r\n\tstartOfCombatDone?: boolean;\r\n\r\n\tdeadEyeDamageDone?: number;\r\n\trapidReanimationMinion?: BoardEntity;\r\n\trapidReanimationIndexFromLeft?: number;\r\n}\r\n\r\nexport interface BgsPlayerGlobalInfo {\r\n\tEternalKnightsDeadThisGame?: number;\r\n\tUndeadAttackBonus?: number;\r\n\tChoralAttackBuff?: number;\r\n\tChoralHealthBuff?: number;\r\n\tFrostlingBonus?: number;\r\n\tBloodGemAttackBonus?: number;\r\n\tBloodGemHealthBonus?: number;\r\n\tGoldrinnBuffAtk?: number;\r\n\tGoldrinnBuffHealth?: number;\r\n\tTavernSpellsCastThisGame?: number;\r\n}\r\n\r\nexport interface BgsQuestEntity {\r\n\tCardId: string;\r\n\tRewardDbfId: number;\r\n\tProgressCurrent: number;\r\n\tProgressTotal: number;\r\n}\r\n"]}
1
+ {"version":3,"file":"bgs-player-entity.js","sourceRoot":"","sources":["../src/bgs-player-entity.ts"],"names":[],"mappings":"","sourcesContent":["import { BoardEntity } from './board-entity';\r\nimport { BoardSecret } from './board-secret';\r\n\r\nexport interface BgsPlayerEntity {\r\n\treadonly cardId: string;\r\n\treadonly nonGhostCardId?: string;\r\n\treadonly hpLeft: number;\r\n\treadonly tavernTier: number;\r\n\treadonly heroPowerId?: string | undefined | null;\r\n\treadonly heroPowerEntityId?: number;\r\n\treadonly heroPowerUsed: boolean;\r\n\treadonly heroPowerInfo?: number | string;\r\n\treadonly heroPowerInfo2?: number;\r\n\tfriendly?: boolean;\r\n\tentityId?: number;\r\n\tquestEntities: BgsQuestEntity[];\r\n\tquestRewards?: string[];\r\n\tquestRewardEntities?: {\r\n\t\tcardId: string;\r\n\t\tentityId: number;\r\n\t\tavengeDefault?: number;\r\n\t\tavengeCurrent?: number;\r\n\t\tscriptDataNum1: number;\r\n\t}[];\r\n\thand?: BoardEntity[];\r\n\tsecrets?: BoardSecret[];\r\n\tavengeCurrent?: number;\r\n\tavengeDefault?: number;\r\n\tglobalInfo?: BgsPlayerGlobalInfo;\r\n\tstartOfCombatDone?: boolean;\r\n\r\n\tdeadEyeDamageDone?: number;\r\n\trapidReanimationMinion?: BoardEntity;\r\n\trapidReanimationIndexFromLeft?: number;\r\n}\r\n\r\nexport interface BgsPlayerGlobalInfo {\r\n\tEternalKnightsDeadThisGame?: number;\r\n\tUndeadAttackBonus?: number;\r\n\tChoralAttackBuff?: number;\r\n\tChoralHealthBuff?: number;\r\n\tFrostlingBonus?: number;\r\n\tBloodGemAttackBonus?: number;\r\n\tBloodGemHealthBonus?: number;\r\n\tGoldrinnBuffAtk?: number;\r\n\tGoldrinnBuffHealth?: number;\r\n\tTavernSpellsCastThisGame?: number;\r\n}\r\n\r\nexport interface BgsQuestEntity {\r\n\tCardId: string;\r\n\tRewardDbfId: number;\r\n\tProgressCurrent: number;\r\n\tProgressTotal: number;\r\n}\r\n"]}
@@ -53,11 +53,12 @@ const simulateBattle = (battleInput, cards, cardsData) => {
53
53
  averageDamageWon: undefined,
54
54
  averageDamageLost: undefined,
55
55
  };
56
- const spectator = new spectator_1.Spectator(battleInput);
56
+ const spectator = new spectator_1.Spectator();
57
57
  const inputReady = (0, input_sanitation_1.buildFinalInput)(battleInput, cards, cardsData);
58
58
  !((_c = battleInput.options) === null || _c === void 0 ? void 0 : _c.skipInfoLogs) && console.time('simulation');
59
59
  const outcomes = {};
60
60
  for (let i = 0; i < numberOfSimulations; i++) {
61
+ spectator.setProtagonists(battleInput);
61
62
  const input = (0, input_clone_1.cloneInput3)(inputReady);
62
63
  const inputClone = (0, input_clone_1.cloneInput3)(inputReady);
63
64
  const gameState = {
@@ -1 +1 @@
1
- {"version":3,"file":"simulate-bgs-battle.js","sourceRoot":"","sources":["../src/simulate-bgs-battle.ts"],"names":[],"mappings":";;;AACA,iEAAwE;AAExE,mDAA+C;AAC/C,+CAA4C;AAC5C,yDAAqD;AAGrD,4DAAwD;AACxD,sDAAmD;AACnD,gEAA6D;AAE7D,IAAI,WAAW,GAAG,IAAI,gCAAe,EAAE,CAAC;AAEjC,MAAM,WAAW,GAAG,CAAC,KAAsB,EAAE,EAAE;IACrD,WAAW,GAAG,KAAK,CAAC;AACrB,CAAC,CAAC;AAFW,QAAA,WAAW,eAEtB;AAKF,kBAAe,KAAK,EAAE,KAAK,EAAgB,EAAE;;IAC5C,IAAI,CAAC,C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E,GAAG,CAAC,GAAG,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC,GAAG,YAAY,CAAC,GAAG,EAAE,CAAC;IAChH,gBAAgB,CAAC,gBAAgB,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,gBAAgB,CAAC,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACjH,gBAAgB,CAAC,iBAAiB,GAAG,gBAAgB,CAAC,IAAI;QACzD,CAAC,CAAC,gBAAgB,CAAC,UAAU,GAAG,gBAAgB,CAAC,IAAI;QACrD,CAAC,CAAC,CAAC,CAAC;IACL,IACC,gBAAgB,CAAC,gBAAgB,GAAG,CAAC;QACrC,gBAAgB,CAAC,gBAAgB,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,EACtE;QACD,OAAO,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;KACzC;IACD,IACC,gBAAgB,CAAC,iBAAiB,GAAG,CAAC;QACtC,gBAAgB,CAAC,iBAAiB,GAAG,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,EACzE;QACD,OAAO,CAAC,IAAI,CAAC,2BAA2B,EAAE,gBAAgB,CAAC,CAAC;KAC5D;AACF,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,YAAoB,EAAE,YAAoB,EAAE,UAAkB,EAAU,EAAE;IAChG,IAAI,YAAY,KAAK,CAAC,IAAI,YAAY,KAAK,CAAC,EAAE;QAC7C,OAAO,IAAI,CAAC;KACZ;IACD,IAAI,YAAY,KAAK,GAAG,IAAI,YAAY,KAAK,UAAU,EAAE;QACxD,OAAO,IAAI,CAAC;KACZ;IACD,OAAO,YAAY,CAAC;AACrB,CAAC,CAAC;AAGW,QAAA,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;CAqBjC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds } from '@firestone-hs/reference-data';\r\nimport { BgsBattleInfo } from './bgs-battle-info';\r\nimport { CardsData } from './cards/cards-data';\r\nimport { cloneInput3 } from './input-clone';\r\nimport { buildFinalInput } from './input-sanitation';\r\nimport { SimulationResult } from './simulation-result';\r\nimport { FullGameState } from './simulation/internal-game-state';\r\nimport { SharedState } from './simulation/shared-state';\r\nimport { Simulator } from './simulation/simulator';\r\nimport { Spectator } from './simulation/spectator/spectator';\r\n\r\nlet globalCards = new AllCardsService();\r\n\r\nexport const assignCards = (cards: AllCardsService) => {\r\n\tglobalCards = cards;\r\n};\r\n\r\n// This example demonstrates a NodeJS 8.10 async handler[1], however of course you could use\r\n// the more traditional callback-style handler.\r\n// [1]: https://aws.amazon.com/blogs/compute/node-js-8-10-runtime-now-available-in-aws-lambda/\r\nexport default async (event): Promise<any> => {\r\n\tif (!event.body?.length) {\r\n\t\tconsole.warn('missing event body', event);\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst battleInput: BgsBattleInfo = JSON.parse(event.body);\r\n\tconst cards = globalCards;\r\n\tawait cards.initializeCardsDb();\r\n\tconst cardsData = new CardsData(cards, false);\r\n\tcardsData.inititialize(\r\n\t\tbattleInput.gameState?.validTribes ?? battleInput.options?.validTribes,\r\n\t\tbattleInput.gameState?.anomalies ?? [],\r\n\t);\r\n\tconst simulationResult = simulateBattle(battleInput, cards, cardsData);\r\n\r\n\tconst response = {\r\n\t\tstatusCode: 200,\r\n\t\tisBase64Encoded: false,\r\n\t\tbody: JSON.stringify(simulationResult),\r\n\t};\r\n\treturn response;\r\n};\r\n\r\nexport const simulateBattle = (\r\n\tbattleInput: BgsBattleInfo,\r\n\tcards: AllCardsService,\r\n\tcardsData: CardsData,\r\n): SimulationResult => {\r\n\t// !battleInput.options?.skipInfoLogs && console.time('full-sim');\r\n\tconst start = Date.now();\r\n\tconst maxAcceptableDuration = battleInput.options?.maxAcceptableDuration || 8000;\r\n\tconst numberOfSimulations = battleInput.options?.numberOfSimulations || 8000;\r\n\tconst simulationResult: SimulationResult = {\r\n\t\twonLethal: 0,\r\n\t\twon: 0,\r\n\t\ttied: 0,\r\n\t\tlost: 0,\r\n\t\tlostLethal: 0,\r\n\t\tdamageWon: 0,\r\n\t\tdamageLost: 0,\r\n\t\twonLethalPercent: undefined,\r\n\t\twonPercent: undefined,\r\n\t\ttiedPercent: undefined,\r\n\t\tlostPercent: undefined,\r\n\t\tlostLethalPercent: undefined,\r\n\t\taverageDamageWon: undefined,\r\n\t\taverageDamageLost: undefined,\r\n\t};\r\n\r\n\tconst spectator = new Spectator(battleInput);\r\n\tconst inputReady = buildFinalInput(battleInput, cards, cardsData);\r\n\t!battleInput.options?.skipInfoLogs && console.time('simulation');\r\n\tconst outcomes = {};\r\n\tfor (let i = 0; i < numberOfSimulations; i++) {\r\n\t\tconst input: BgsBattleInfo = cloneInput3(inputReady);\r\n\t\tconst inputClone: BgsBattleInfo = cloneInput3(inputReady);\r\n\t\tconst gameState: FullGameState = {\r\n\t\t\tallCards: cards,\r\n\t\t\tcardsData: cardsData,\r\n\t\t\tspectator: spectator,\r\n\t\t\tsharedState: new SharedState(),\r\n\t\t\tcurrentTurn: input.gameState.currentTurn,\r\n\t\t\tvalidTribes: input.gameState.validTribes,\r\n\t\t\tanomalies: input.gameState.anomalies,\r\n\t\t\tgameState: {\r\n\t\t\t\tplayer: {\r\n\t\t\t\t\tplayer: input.playerBoard.player,\r\n\t\t\t\t\tboard: input.playerBoard.board,\r\n\t\t\t\t\tteammate: input.playerTeammateBoard,\r\n\t\t\t\t},\r\n\t\t\t\topponent: {\r\n\t\t\t\t\tplayer: input.opponentBoard.player,\r\n\t\t\t\t\tboard: input.opponentBoard.board,\r\n\t\t\t\t\tteammate: input.opponentTeammateBoard,\r\n\t\t\t\t},\r\n\t\t\t\tplayerInitial: {\r\n\t\t\t\t\tplayer: inputClone.playerBoard.player,\r\n\t\t\t\t\tboard: inputClone.playerBoard.board,\r\n\t\t\t\t\tteammate: inputClone.playerTeammateBoard,\r\n\t\t\t\t},\r\n\t\t\t\topponentInitial: {\r\n\t\t\t\t\tplayer: inputClone.opponentBoard.player,\r\n\t\t\t\t\tboard: inputClone.opponentBoard.board,\r\n\t\t\t\t\tteammate: inputClone.opponentTeammateBoard,\r\n\t\t\t\t},\r\n\t\t\t},\r\n\t\t};\r\n\t\tconst simulator = new Simulator(gameState);\r\n\t\tconst battleResult = simulator.simulateSingleBattle(gameState.gameState.player, gameState.gameState.opponent);\r\n\t\tif (Date.now() - start > maxAcceptableDuration) {\r\n\t\t\t// Can happen in case of inifinite boards, or a bug. Don't hog the user's computer in that case\r\n\t\t\tconsole.warn('Stopping simulation after', i, 'iterations and ', Date.now() - start, 'ms', battleResult);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tif (!battleResult) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\t\tif (battleResult.result === 'won') {\r\n\t\t\tsimulationResult.won++;\r\n\t\t\tsimulationResult.damageWon += battleResult.damageDealt;\r\n\t\t\tif (battleResult.damageDealt >= battleInput.opponentBoard.player.hpLeft) {\r\n\t\t\t\tsimulationResult.wonLethal++;\r\n\t\t\t}\r\n\t\t} else if (battleResult.result === 'lost') {\r\n\t\t\tsimulationResult.lost++;\r\n\t\t\tsimulationResult.damageLost += battleResult.damageDealt;\r\n\t\t\toutcomes[battleResult.damageDealt] = (outcomes[battleResult.damageDealt] ?? 0) + 1;\r\n\t\t\tif (\r\n\t\t\t\tbattleInput.playerBoard.player.hpLeft &&\r\n\t\t\t\tbattleResult.damageDealt >= battleInput.playerBoard.player.hpLeft\r\n\t\t\t) {\r\n\t\t\t\tsimulationResult.lostLethal++;\r\n\t\t\t}\r\n\t\t} else if (battleResult.result === 'tied') {\r\n\t\t\tsimulationResult.tied++;\r\n\t\t}\r\n\t\tspectator.commitBattleResult(battleResult.result);\r\n\t}\r\n\tupdateSimulationResult(simulationResult, inputReady);\r\n\t!battleInput.options?.skipInfoLogs && console.timeEnd('simulation');\r\n\tspectator.prune();\r\n\tsimulationResult.outcomeSamples = spectator.buildOutcomeSamples();\r\n\t// !battleInput.options?.skipInfoLogs && console.timeEnd('full-sim');\r\n\treturn simulationResult;\r\n};\r\n\r\nconst updateSimulationResult = (simulationResult: SimulationResult, input: BgsBattleInfo) => {\r\n\tconst totalMatches = simulationResult.won + simulationResult.tied + simulationResult.lost;\r\n\tsimulationResult.wonPercent = checkRounding(\r\n\t\tMath.round((10 * (100 * simulationResult.won)) / totalMatches) / 10,\r\n\t\tsimulationResult.won,\r\n\t\ttotalMatches,\r\n\t);\r\n\tsimulationResult.wonLethalPercent = checkRounding(\r\n\t\tMath.round((10 * (100 * simulationResult.wonLethal)) / totalMatches) / 10,\r\n\t\tsimulationResult.wonLethal,\r\n\t\ttotalMatches,\r\n\t);\r\n\tsimulationResult.lostPercent = checkRounding(\r\n\t\tMath.round((10 * (100 * simulationResult.lost)) / totalMatches) / 10,\r\n\t\tsimulationResult.lost,\r\n\t\ttotalMatches,\r\n\t);\r\n\tsimulationResult.lostLethalPercent = checkRounding(\r\n\t\tMath.round((10 * (100 * simulationResult.lostLethal)) / totalMatches) / 10,\r\n\t\tsimulationResult.lostLethal,\r\n\t\ttotalMatches,\r\n\t);\r\n\t// simulationResult.tiedPercent = checkRounding(Math.round((10 * (100 * simulationResult.tied)) / totalMatches) / 10, simulationResult.tied, totalMatches);\r\n\tsimulationResult.tiedPercent = checkRounding(\r\n\t\t100 - simulationResult.lostPercent - simulationResult.wonPercent,\r\n\t\tsimulationResult.tied,\r\n\t\ttotalMatches,\r\n\t);\r\n\r\n\tsimulationResult.wonLethalPercent = Math.round((10 * (100 * simulationResult.wonLethal)) / totalMatches) / 10;\r\n\tsimulationResult.lostLethalPercent = Math.round((10 * (100 * simulationResult.lostLethal)) / totalMatches) / 10;\r\n\tsimulationResult.averageDamageWon = simulationResult.won ? simulationResult.damageWon / simulationResult.won : 0;\r\n\tsimulationResult.averageDamageLost = simulationResult.lost\r\n\t\t? simulationResult.damageLost / simulationResult.lost\r\n\t\t: 0;\r\n\tif (\r\n\t\tsimulationResult.averageDamageWon > 0 &&\r\n\t\tsimulationResult.averageDamageWon < input.playerBoard.player.tavernTier\r\n\t) {\r\n\t\tconsole.warn('average damage won issue');\r\n\t}\r\n\tif (\r\n\t\tsimulationResult.averageDamageLost > 0 &&\r\n\t\tsimulationResult.averageDamageLost < input.opponentBoard.player.tavernTier\r\n\t) {\r\n\t\tconsole.warn('average damage lost issue', simulationResult);\r\n\t}\r\n};\r\n\r\nconst checkRounding = (roundedValue: number, initialValue: number, totalValue: number): number => {\r\n\tif (roundedValue === 0 && initialValue !== 0) {\r\n\t\treturn 0.01;\r\n\t}\r\n\tif (roundedValue === 100 && initialValue !== totalValue) {\r\n\t\treturn 99.9;\r\n\t}\r\n\treturn roundedValue;\r\n};\r\n\r\n// Used when triggering random deathrattles\r\nexport const VALID_ENCHANTMENTS = [\r\n\tCardIds.ReplicatingMenace_ReplicatingMenaceEnchantment_BG_BOT_312e,\r\n\tCardIds.ReplicatingMenace_ReplicatingMenaceEnchantment_TB_BaconUps_032e,\r\n\tCardIds.LivingSpores_LivingSporesEnchantment,\r\n\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e,\r\n\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge,\r\n\tCardIds.Sneed_SneedsReplicator,\r\n\tCardIds.SneedsReplicator_ReplicateEnchantment,\r\n\tCardIds.EarthRecollectionEnchantment, // Spirit Raptor\r\n\tCardIds.FireRecollectionEnchantment,\r\n\tCardIds.LightningRecollectionEnchantment,\r\n\tCardIds.WaterRecollectionEnchantment,\r\n\tCardIds.EarthInvocation_ElementEarthEnchantment, // Summon a 1/1\r\n\t// CardIds.FireInvocation_ElementFireEnchantment, // Attack is doubled, probably no use to keep it\r\n\t// CardIds.WaterInvocation_ElementWaterEnchantment, // +3 health and taunt, same\r\n\tCardIds.LightningInvocation, // Deal 1 damage to 5 enemy minions\r\n\tCardIds.SurfNSurf_CrabRidingEnchantment_BG27_004e,\r\n\tCardIds.SurfNSurf_CrabRidingEnchantment_BG27_004_Ge,\r\n\tCardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055e,\r\n\tCardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055_Ge,\r\n\tCardIds.BoonOfBeetles_BeetleSwarmEnchantment_BG28_603e,\r\n];\r\n\r\n// const cleanEnchantmentsForEntity = (\r\n// \tenchantments: { cardId: string; originEntityId?: number; timing: number }[],\r\n// \tentityIds: readonly number[],\r\n// ): { cardId: string; originEntityId?: number; timing: number }[] => {\r\n// \treturn enchantments.filter(\r\n// \t\t(enchant) =>\r\n// \t\t\tentityIds.indexOf(enchant.originEntityId) !== -1 ||\r\n// \t\t\tvalidEnchantments.indexOf(enchant.cardId as CardIds) !== -1,\r\n// \t);\r\n// };\r\n"]}
1
+ {"version":3,"file":"simulate-bgs-battle.js","sourceRoot":"","sources":["../src/simulate-bgs-battle.ts"],"names":[],"mappings":";;;AACA,iEAAwE;AAExE,mDAA+C;AAC/C,+CAA4C;AAC5C,yDAAqD;AAGrD,4DAAwD;AACxD,sDAAmD;AACnD,gEAA6D;AAE7D,IAAI,WAAW,GAAG,IAAI,gCAAe,EAAE,CAAC;AAEjC,MAAM,WAAW,GAAG,CAAC,KAAsB,EAAE,EAAE;IACrD,WAAW,GAAG,KAAK,CAAC;AACrB,CAAC,CAAC;AAFW,QAAA,WAAW,eAEtB;AAKF,kBAAe,KAAK,EAAE,KAAK,EAAgB,EAAE;;IAC5C,IAAI,CAAC,CAAA,MAAA,KAAK,CAAC,IAAI,0CAAE,MAAM,CAAA,EAAE;QACxB,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;QAC1C,OAAO;KACP;IAED,MAAM,WAAW,GAAkB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1D,MAAM,KAAK,GAAG,WAAW,CAAC;IAC1B,MAAM,KAAK,CAAC,iBAAiB,EAAE,CAAC;IAChC,MAAM,SAAS,GA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gBAAgB,CAAC,IAAI;QACzD,CAAC,CAAC,gBAAgB,CAAC,UAAU,GAAG,gBAAgB,CAAC,IAAI;QACrD,CAAC,CAAC,CAAC,CAAC;IACL,IACC,gBAAgB,CAAC,gBAAgB,GAAG,CAAC;QACrC,gBAAgB,CAAC,gBAAgB,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,EACtE;QACD,OAAO,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;KACzC;IACD,IACC,gBAAgB,CAAC,iBAAiB,GAAG,CAAC;QACtC,gBAAgB,CAAC,iBAAiB,GAAG,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,EACzE;QACD,OAAO,CAAC,IAAI,CAAC,2BAA2B,EAAE,gBAAgB,CAAC,CAAC;KAC5D;AACF,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,YAAoB,EAAE,YAAoB,EAAE,UAAkB,EAAU,EAAE;IAChG,IAAI,YAAY,KAAK,CAAC,IAAI,YAAY,KAAK,CAAC,EAAE;QAC7C,OAAO,IAAI,CAAC;KACZ;IACD,IAAI,YAAY,KAAK,GAAG,IAAI,YAAY,KAAK,UAAU,EAAE;QACxD,OAAO,IAAI,CAAC;KACZ;IACD,OAAO,YAAY,CAAC;AACrB,CAAC,CAAC;AAGW,QAAA,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;CAqBjC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds } from '@firestone-hs/reference-data';\r\nimport { BgsBattleInfo } from './bgs-battle-info';\r\nimport { CardsData } from './cards/cards-data';\r\nimport { cloneInput3 } from './input-clone';\r\nimport { buildFinalInput } from './input-sanitation';\r\nimport { SimulationResult } from './simulation-result';\r\nimport { FullGameState } from './simulation/internal-game-state';\r\nimport { SharedState } from './simulation/shared-state';\r\nimport { Simulator } from './simulation/simulator';\r\nimport { Spectator } from './simulation/spectator/spectator';\r\n\r\nlet globalCards = new AllCardsService();\r\n\r\nexport const assignCards = (cards: AllCardsService) => {\r\n\tglobalCards = cards;\r\n};\r\n\r\n// This example demonstrates a NodeJS 8.10 async handler[1], however of course you could use\r\n// the more traditional callback-style handler.\r\n// [1]: https://aws.amazon.com/blogs/compute/node-js-8-10-runtime-now-available-in-aws-lambda/\r\nexport default async (event): Promise<any> => {\r\n\tif (!event.body?.length) {\r\n\t\tconsole.warn('missing event body', event);\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst battleInput: BgsBattleInfo = JSON.parse(event.body);\r\n\tconst cards = globalCards;\r\n\tawait cards.initializeCardsDb();\r\n\tconst cardsData = new CardsData(cards, false);\r\n\tcardsData.inititialize(\r\n\t\tbattleInput.gameState?.validTribes ?? battleInput.options?.validTribes,\r\n\t\tbattleInput.gameState?.anomalies ?? [],\r\n\t);\r\n\tconst simulationResult = simulateBattle(battleInput, cards, cardsData);\r\n\r\n\tconst response = {\r\n\t\tstatusCode: 200,\r\n\t\tisBase64Encoded: false,\r\n\t\tbody: JSON.stringify(simulationResult),\r\n\t};\r\n\treturn response;\r\n};\r\n\r\nexport const simulateBattle = (\r\n\tbattleInput: BgsBattleInfo,\r\n\tcards: AllCardsService,\r\n\tcardsData: CardsData,\r\n): SimulationResult => {\r\n\t// !battleInput.options?.skipInfoLogs && console.time('full-sim');\r\n\tconst start = Date.now();\r\n\tconst maxAcceptableDuration = battleInput.options?.maxAcceptableDuration || 8000;\r\n\tconst numberOfSimulations = battleInput.options?.numberOfSimulations || 8000;\r\n\tconst simulationResult: SimulationResult = {\r\n\t\twonLethal: 0,\r\n\t\twon: 0,\r\n\t\ttied: 0,\r\n\t\tlost: 0,\r\n\t\tlostLethal: 0,\r\n\t\tdamageWon: 0,\r\n\t\tdamageLost: 0,\r\n\t\twonLethalPercent: undefined,\r\n\t\twonPercent: undefined,\r\n\t\ttiedPercent: undefined,\r\n\t\tlostPercent: undefined,\r\n\t\tlostLethalPercent: undefined,\r\n\t\taverageDamageWon: undefined,\r\n\t\taverageDamageLost: undefined,\r\n\t};\r\n\r\n\tconst spectator = new Spectator();\r\n\tconst inputReady = buildFinalInput(battleInput, cards, cardsData);\r\n\t!battleInput.options?.skipInfoLogs && console.time('simulation');\r\n\tconst outcomes = {};\r\n\tfor (let i = 0; i < numberOfSimulations; i++) {\r\n\t\tspectator.setProtagonists(battleInput);\r\n\t\tconst input: BgsBattleInfo = cloneInput3(inputReady);\r\n\t\tconst inputClone: BgsBattleInfo = cloneInput3(inputReady);\r\n\t\tconst gameState: FullGameState = {\r\n\t\t\tallCards: cards,\r\n\t\t\tcardsData: cardsData,\r\n\t\t\tspectator: spectator,\r\n\t\t\tsharedState: new SharedState(),\r\n\t\t\tcurrentTurn: input.gameState.currentTurn,\r\n\t\t\tvalidTribes: input.gameState.validTribes,\r\n\t\t\tanomalies: input.gameState.anomalies,\r\n\t\t\tgameState: {\r\n\t\t\t\tplayer: {\r\n\t\t\t\t\tplayer: input.playerBoard.player,\r\n\t\t\t\t\tboard: input.playerBoard.board,\r\n\t\t\t\t\tteammate: input.playerTeammateBoard,\r\n\t\t\t\t},\r\n\t\t\t\topponent: {\r\n\t\t\t\t\tplayer: input.opponentBoard.player,\r\n\t\t\t\t\tboard: input.opponentBoard.board,\r\n\t\t\t\t\tteammate: input.opponentTeammateBoard,\r\n\t\t\t\t},\r\n\t\t\t\tplayerInitial: {\r\n\t\t\t\t\tplayer: inputClone.playerBoard.player,\r\n\t\t\t\t\tboard: inputClone.playerBoard.board,\r\n\t\t\t\t\tteammate: inputClone.playerTeammateBoard,\r\n\t\t\t\t},\r\n\t\t\t\topponentInitial: {\r\n\t\t\t\t\tplayer: inputClone.opponentBoard.player,\r\n\t\t\t\t\tboard: inputClone.opponentBoard.board,\r\n\t\t\t\t\tteammate: inputClone.opponentTeammateBoard,\r\n\t\t\t\t},\r\n\t\t\t},\r\n\t\t};\r\n\t\tconst simulator = new Simulator(gameState);\r\n\t\tconst battleResult = simulator.simulateSingleBattle(gameState.gameState.player, gameState.gameState.opponent);\r\n\t\tif (Date.now() - start > maxAcceptableDuration) {\r\n\t\t\t// Can happen in case of inifinite boards, or a bug. Don't hog the user's computer in that case\r\n\t\t\tconsole.warn('Stopping simulation after', i, 'iterations and ', Date.now() - start, 'ms', battleResult);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tif (!battleResult) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\t\tif (battleResult.result === 'won') {\r\n\t\t\tsimulationResult.won++;\r\n\t\t\tsimulationResult.damageWon += battleResult.damageDealt;\r\n\t\t\tif (battleResult.damageDealt >= battleInput.opponentBoard.player.hpLeft) {\r\n\t\t\t\tsimulationResult.wonLethal++;\r\n\t\t\t}\r\n\t\t} else if (battleResult.result === 'lost') {\r\n\t\t\tsimulationResult.lost++;\r\n\t\t\tsimulationResult.damageLost += battleResult.damageDealt;\r\n\t\t\toutcomes[battleResult.damageDealt] = (outcomes[battleResult.damageDealt] ?? 0) + 1;\r\n\t\t\tif (\r\n\t\t\t\tbattleInput.playerBoard.player.hpLeft &&\r\n\t\t\t\tbattleResult.damageDealt >= battleInput.playerBoard.player.hpLeft\r\n\t\t\t) {\r\n\t\t\t\tsimulationResult.lostLethal++;\r\n\t\t\t}\r\n\t\t} else if (battleResult.result === 'tied') {\r\n\t\t\tsimulationResult.tied++;\r\n\t\t}\r\n\t\tspectator.commitBattleResult(battleResult.result);\r\n\t}\r\n\tupdateSimulationResult(simulationResult, inputReady);\r\n\t!battleInput.options?.skipInfoLogs && console.timeEnd('simulation');\r\n\tspectator.prune();\r\n\tsimulationResult.outcomeSamples = spectator.buildOutcomeSamples();\r\n\t// !battleInput.options?.skipInfoLogs && console.timeEnd('full-sim');\r\n\treturn simulationResult;\r\n};\r\n\r\nconst updateSimulationResult = (simulationResult: SimulationResult, input: BgsBattleInfo) => {\r\n\tconst totalMatches = simulationResult.won + simulationResult.tied + simulationResult.lost;\r\n\tsimulationResult.wonPercent = checkRounding(\r\n\t\tMath.round((10 * (100 * simulationResult.won)) / totalMatches) / 10,\r\n\t\tsimulationResult.won,\r\n\t\ttotalMatches,\r\n\t);\r\n\tsimulationResult.wonLethalPercent = checkRounding(\r\n\t\tMath.round((10 * (100 * simulationResult.wonLethal)) / totalMatches) / 10,\r\n\t\tsimulationResult.wonLethal,\r\n\t\ttotalMatches,\r\n\t);\r\n\tsimulationResult.lostPercent = checkRounding(\r\n\t\tMath.round((10 * (100 * simulationResult.lost)) / totalMatches) / 10,\r\n\t\tsimulationResult.lost,\r\n\t\ttotalMatches,\r\n\t);\r\n\tsimulationResult.lostLethalPercent = checkRounding(\r\n\t\tMath.round((10 * (100 * simulationResult.lostLethal)) / totalMatches) / 10,\r\n\t\tsimulationResult.lostLethal,\r\n\t\ttotalMatches,\r\n\t);\r\n\t// simulationResult.tiedPercent = checkRounding(Math.round((10 * (100 * simulationResult.tied)) / totalMatches) / 10, simulationResult.tied, totalMatches);\r\n\tsimulationResult.tiedPercent = checkRounding(\r\n\t\t100 - simulationResult.lostPercent - simulationResult.wonPercent,\r\n\t\tsimulationResult.tied,\r\n\t\ttotalMatches,\r\n\t);\r\n\r\n\tsimulationResult.wonLethalPercent = Math.round((10 * (100 * simulationResult.wonLethal)) / totalMatches) / 10;\r\n\tsimulationResult.lostLethalPercent = Math.round((10 * (100 * simulationResult.lostLethal)) / totalMatches) / 10;\r\n\tsimulationResult.averageDamageWon = simulationResult.won ? simulationResult.damageWon / simulationResult.won : 0;\r\n\tsimulationResult.averageDamageLost = simulationResult.lost\r\n\t\t? simulationResult.damageLost / simulationResult.lost\r\n\t\t: 0;\r\n\tif (\r\n\t\tsimulationResult.averageDamageWon > 0 &&\r\n\t\tsimulationResult.averageDamageWon < input.playerBoard.player.tavernTier\r\n\t) {\r\n\t\tconsole.warn('average damage won issue');\r\n\t}\r\n\tif (\r\n\t\tsimulationResult.averageDamageLost > 0 &&\r\n\t\tsimulationResult.averageDamageLost < input.opponentBoard.player.tavernTier\r\n\t) {\r\n\t\tconsole.warn('average damage lost issue', simulationResult);\r\n\t}\r\n};\r\n\r\nconst checkRounding = (roundedValue: number, initialValue: number, totalValue: number): number => {\r\n\tif (roundedValue === 0 && initialValue !== 0) {\r\n\t\treturn 0.01;\r\n\t}\r\n\tif (roundedValue === 100 && initialValue !== totalValue) {\r\n\t\treturn 99.9;\r\n\t}\r\n\treturn roundedValue;\r\n};\r\n\r\n// Used when triggering random deathrattles\r\nexport const VALID_ENCHANTMENTS = [\r\n\tCardIds.ReplicatingMenace_ReplicatingMenaceEnchantment_BG_BOT_312e,\r\n\tCardIds.ReplicatingMenace_ReplicatingMenaceEnchantment_TB_BaconUps_032e,\r\n\tCardIds.LivingSpores_LivingSporesEnchantment,\r\n\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e,\r\n\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge,\r\n\tCardIds.Sneed_SneedsReplicator,\r\n\tCardIds.SneedsReplicator_ReplicateEnchantment,\r\n\tCardIds.EarthRecollectionEnchantment, // Spirit Raptor\r\n\tCardIds.FireRecollectionEnchantment,\r\n\tCardIds.LightningRecollectionEnchantment,\r\n\tCardIds.WaterRecollectionEnchantment,\r\n\tCardIds.EarthInvocation_ElementEarthEnchantment, // Summon a 1/1\r\n\t// CardIds.FireInvocation_ElementFireEnchantment, // Attack is doubled, probably no use to keep it\r\n\t// CardIds.WaterInvocation_ElementWaterEnchantment, // +3 health and taunt, same\r\n\tCardIds.LightningInvocation, // Deal 1 damage to 5 enemy minions\r\n\tCardIds.SurfNSurf_CrabRidingEnchantment_BG27_004e,\r\n\tCardIds.SurfNSurf_CrabRidingEnchantment_BG27_004_Ge,\r\n\tCardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055e,\r\n\tCardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055_Ge,\r\n\tCardIds.BoonOfBeetles_BeetleSwarmEnchantment_BG28_603e,\r\n];\r\n\r\n// const cleanEnchantmentsForEntity = (\r\n// \tenchantments: { cardId: string; originEntityId?: number; timing: number }[],\r\n// \tentityIds: readonly number[],\r\n// ): { cardId: string; originEntityId?: number; timing: number }[] => {\r\n// \treturn enchantments.filter(\r\n// \t\t(enchant) =>\r\n// \t\t\tentityIds.indexOf(enchant.originEntityId) !== -1 ||\r\n// \t\t\tvalidEnchantments.indexOf(enchant.cardId as CardIds) !== -1,\r\n// \t);\r\n// };\r\n"]}
@@ -10,8 +10,10 @@ const applyOnBeingAttackedBuffs = (attackerEntity, attackerBoard, attackerHero,
10
10
  for (const secret of ((_a = defendingPlayerEntity.secrets) !== null && _a !== void 0 ? _a : []).filter((s) => !s.triggered)) {
11
11
  switch (secret.cardId) {
12
12
  case "TB_Bacon_Secrets_07":
13
- secret.triggered = true;
14
- (0, utils_1.updateDivineShield)(defendingEntity, defendingBoard, true, gameState.allCards);
13
+ if (!defendingEntity.divineShield) {
14
+ secret.triggered = true;
15
+ (0, utils_1.updateDivineShield)(defendingEntity, defendingBoard, true, gameState.allCards);
16
+ }
15
17
  break;
16
18
  case "TB_Bacon_Secrets_04":
17
19
  if (defendingBoard.length < 7) {
@@ -1 +1 @@
1
- {"version":3,"file":"on-being-attacked.js","sourceRoot":"","sources":["../../src/simulation/on-being-attacked.ts"],"names":[],"mappings":";;;AAGA,oCAA8C;AAC9C,qCAAyC;AAEzC,uCAA4G;AAC5G,mCAAqE;AAE9D,MAAM,yBAAyB,GAAG,CACxC,cAA2B,EAC3B,aAA4B,EAC5B,YAA6B,EAC7B,eAA4B,EAC5B,cAA6B,EAC7B,qBAAsC,EACtC,SAAwB,EACjB,EAAE;;IAET,KAAK,MAAM,MAAM,IAAI,CAAC,MAAA,qBAAqB,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE;QACvF,QAAQ,MAAM,CAAC,MAAM,EAAE;YACtB;gBACC,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC;gBACxB,IAAA,0BAAkB,E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AG,IAAI,CAAC;KAChC;IAGD,IACC,cAAc,CAAC,MAAM,eAA0C;QAC/D,cAAc,CAAC,MAAM,iBAA4C,EAChE;QACD,eAAe,CAAC,KAAK,GAAG,KAAK,CAAC;QAC9B,eAAe,CAAC,MAAM,GAAG,KAAK,CAAC;KAC/B;SAAM,IACN,0BAAoF,CAAC,QAAQ,CAC5F,cAAc,CAAC,MAAiB,CAChC;QACD,cAAc,CAAC,iBAAiB,GAAG,CAAC,EACnC;QAED,IAAA,sBAAc,EAAC,eAAe,EAAE,CAAC,EAAE,CAAC,EAAE,cAAc,EAAE,qBAAqB,EAAE,SAAS,CAAC,CAAC;QACxF,cAAc,CAAC,iBAAiB,EAAE,CAAC;KACnC;AACF,CAAC,CAAC;AAxNW,QAAA,yBAAyB,6BAwNpC","sourcesContent":["import { CardIds } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { updateDivineShield } from '../utils';\r\nimport { getNeighbours } from './attack';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { handlePackTactics, handleSnakeTrap, handleSplittingImage, handleVenomstrikeTrap } from './secrets';\r\nimport { modifyAttack, modifyHealth, setEntityStats } from './stats';\r\n\r\nexport const applyOnBeingAttackedBuffs = (\r\n\tattackerEntity: BoardEntity,\r\n\tattackerBoard: BoardEntity[],\r\n\tattackerHero: BgsPlayerEntity,\r\n\tdefendingEntity: BoardEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingPlayerEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// We need to respect the order of the secrets\r\n\tfor (const secret of (defendingPlayerEntity.secrets ?? []).filter((s) => !s.triggered)) {\r\n\t\tswitch (secret.cardId) {\r\n\t\t\tcase CardIds.AutodefenseMatrix_TB_Bacon_Secrets_07:\r\n\t\t\t\tsecret.triggered = true;\r\n\t\t\t\tupdateDivineShield(defendingEntity, defendingBoard, true, gameState.allCards);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SplittingImage_TB_Bacon_Secrets_04:\r\n\t\t\t\tif (defendingBoard.length < 7) {\r\n\t\t\t\t\tsecret.triggered = true;\r\n\t\t\t\t\thandleSplittingImage(\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t\t\t\tattackerBoard,\r\n\t\t\t\t\t\tattackerHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.PackTactics_TB_Bacon_Secrets_15:\r\n\t\t\t\tif (defendingBoard.length < 7) {\r\n\t\t\t\t\tsecret.triggered = true;\r\n\t\t\t\t\thandlePackTactics(\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t\t\t\tattackerBoard,\r\n\t\t\t\t\t\tattackerHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SnakeTrap_TB_Bacon_Secrets_02:\r\n\t\t\t\tif (defendingBoard.length < 7) {\r\n\t\t\t\t\tsecret.triggered = true;\r\n\t\t\t\t\thandleSnakeTrap(\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t\t\t\tattackerBoard,\r\n\t\t\t\t\t\tattackerHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.VenomstrikeTrap_TB_Bacon_Secrets_01:\r\n\t\t\t\tif (defendingBoard.length < 7) {\r\n\t\t\t\t\tsecret.triggered = true;\r\n\t\t\t\t\thandleVenomstrikeTrap(\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t\t\t\tattackerBoard,\r\n\t\t\t\t\t\tattackerHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tif (defendingEntity.taunt) {\r\n\t\tconst champions = defendingBoard.filter((entity) => entity.cardId === CardIds.ChampionOfYshaarj_BGS_111);\r\n\t\tconst goldenChampions = defendingBoard.filter(\r\n\t\t\t(entity) => entity.cardId === CardIds.ChampionOfYshaarj_TB_BaconUps_301,\r\n\t\t);\r\n\t\tchampions.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 1, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t\tmodifyHealth(entity, 2, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tentity,\r\n\t\t\t\tentity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tattackerHero,\r\n\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t);\r\n\t\t});\r\n\t\tgoldenChampions.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 2, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t\tmodifyHealth(entity, 4, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tentity,\r\n\t\t\t\tentity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tattackerHero,\r\n\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t);\r\n\t\t});\r\n\r\n\t\tconst arms = defendingBoard.filter((entity) => entity.cardId === CardIds.ArmOfTheEmpire_BGS_110);\r\n\t\tconst goldenArms = defendingBoard.filter((entity) => entity.cardId === CardIds.ArmOfTheEmpire_TB_BaconUps_302);\r\n\t\tarms.forEach((arm) => {\r\n\t\t\tmodifyAttack(defendingEntity, 2, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tarm,\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tattackerHero,\r\n\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t);\r\n\t\t});\r\n\t\tgoldenArms.forEach((arm) => {\r\n\t\t\tmodifyAttack(defendingEntity, 4, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tarm,\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tattackerHero,\r\n\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\r\n\t// Based on defending entity\r\n\tif (defendingEntity.cardId === CardIds.TormentedRitualist_BGS_201) {\r\n\t\tconst neighbours = getNeighbours(defendingBoard, defendingEntity);\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 1, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t\tmodifyHealth(entity, 1, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tentity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tattackerHero,\r\n\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t);\r\n\t\t});\r\n\t} else if (defendingEntity.cardId === CardIds.TormentedRitualist_TB_BaconUps_257) {\r\n\t\tconst neighbours = getNeighbours(defendingBoard, defendingEntity);\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 2, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t\tmodifyHealth(entity, 2, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tentity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tattackerHero,\r\n\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t);\r\n\t\t});\r\n\t} else if (\r\n\t\tdefendingEntity.cardId === CardIds.DozyWhelp_BG24_300 ||\r\n\t\tdefendingEntity.cardId === CardIds.DozyWhelp_BG24_300_G\r\n\t) {\r\n\t\tmodifyAttack(\r\n\t\t\tdefendingEntity,\r\n\t\t\tdefendingEntity.cardId === CardIds.DozyWhelp_BG24_300_G ? 2 : 1,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingPlayerEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tdefendingEntity,\r\n\t\t\tdefendingEntity,\r\n\t\t\tdefendingBoard,\r\n\t\t\tattackerHero,\r\n\t\t\tdefendingPlayerEntity,\r\n\t\t);\r\n\t} else if (\r\n\t\t[CardIds.AdaptableBarricade_BG27_022, CardIds.AdaptableBarricade_BG27_022_G].includes(\r\n\t\t\tdefendingEntity.cardId as CardIds,\r\n\t\t)\r\n\t) {\r\n\t\t// https://twitter.com/LoewenMitchell/status/1692225556559901031?s=20\r\n\t\tconst totalStats = defendingEntity.attack + defendingEntity.health;\r\n\t\tconst attackerAttack = attackerEntity.attack;\r\n\t\tif (defendingEntity.divineShield) {\r\n\t\t\tdefendingEntity.health = 1;\r\n\t\t\tdefendingEntity.attack = totalStats - defendingEntity.health;\r\n\t\t} else if (attackerEntity.venomous || attackerEntity.poisonous) {\r\n\t\t\t// Do nothing\r\n\t\t} else if (attackerAttack < totalStats) {\r\n\t\t\tdefendingEntity.health = attackerAttack + 1;\r\n\t\t\tdefendingEntity.attack = totalStats - defendingEntity.health;\r\n\t\t}\r\n\t} else if (\r\n\t\t[CardIds.GraniteGuardian_BG24_001, CardIds.GraniteGuardian_BG24_001_G].includes(\r\n\t\t\tdefendingEntity.cardId as CardIds,\r\n\t\t)\r\n\t) {\r\n\t\tattackerEntity.health = 1;\r\n\t} else if (\r\n\t\t[CardIds.WaywardGrimscale_BG28_406, CardIds.WaywardGrimscale_BG28_406_G].includes(\r\n\t\t\tdefendingEntity.cardId as CardIds,\r\n\t\t)\r\n\t) {\r\n\t\tdefendingEntity.venomous = true;\r\n\t}\r\n\r\n\t// Based on attacking entity\r\n\tif (\r\n\t\tattackerEntity.cardId === CardIds.SindoreiStraightShot_BG25_016 ||\r\n\t\tattackerEntity.cardId === CardIds.SindoreiStraightShot_BG25_016_G\r\n\t) {\r\n\t\tdefendingEntity.taunt = false;\r\n\t\tdefendingEntity.reborn = false;\r\n\t} else if (\r\n\t\t[CardIds.TransmutedBramblewitch_BG27_013, CardIds.TransmutedBramblewitch_BG27_013_G].includes(\r\n\t\t\tattackerEntity.cardId as CardIds,\r\n\t\t) &&\r\n\t\tattackerEntity.abiityChargesLeft > 0\r\n\t) {\r\n\t\t// TODO: also modify all code that directly sets the stats of an entity\r\n\t\tsetEntityStats(defendingEntity, 3, 3, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\tattackerEntity.abiityChargesLeft--;\r\n\t}\r\n};\r\n"]}
1
+ {"version":3,"file":"on-being-attacked.js","sourceRoot":"","sources":["../../src/simulation/on-being-attacked.ts"],"names":[],"mappings":";;;AAGA,oCAA8C;AAC9C,qCAAyC;AAEzC,uCAA4G;AAC5G,mCAAqE;AAE9D,MAAM,yBAAyB,GAAG,CACxC,cAA2B,EAC3B,aAA4B,EAC5B,YAA6B,EAC7B,eAA4B,EAC5B,cAA6B,EAC7B,qBAAsC,EACtC,SAAwB,EACjB,EAAE;;IAET,KAAK,MAAM,MAAM,IAAI,CAAC,MAAA,qBAAqB,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE;QACvF,QAAQ,MAAM,CAAC,MAAM,EAAE;YACtB;gBACC,IAAI,CAAC,eAAe,CAAC,YA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AAwE,CAAC,QAAQ,CAChF,eAAe,CAAC,MAAiB,CACjC,EACA;QACD,eAAe,CAAC,QAAQ,GAAG,IAAI,CAAC;KAChC;IAGD,IACC,cAAc,CAAC,MAAM,eAA0C;QAC/D,cAAc,CAAC,MAAM,iBAA4C,EAChE;QACD,eAAe,CAAC,KAAK,GAAG,KAAK,CAAC;QAC9B,eAAe,CAAC,MAAM,GAAG,KAAK,CAAC;KAC/B;SAAM,IACN,0BAAoF,CAAC,QAAQ,CAC5F,cAAc,CAAC,MAAiB,CAChC;QACD,cAAc,CAAC,iBAAiB,GAAG,CAAC,EACnC;QAED,IAAA,sBAAc,EAAC,eAAe,EAAE,CAAC,EAAE,CAAC,EAAE,cAAc,EAAE,qBAAqB,EAAE,SAAS,CAAC,CAAC;QACxF,cAAc,CAAC,iBAAiB,EAAE,CAAC;KACnC;AACF,CAAC,CAAC;AA1NW,QAAA,yBAAyB,6BA0NpC","sourcesContent":["import { CardIds } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { updateDivineShield } from '../utils';\r\nimport { getNeighbours } from './attack';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { handlePackTactics, handleSnakeTrap, handleSplittingImage, handleVenomstrikeTrap } from './secrets';\r\nimport { modifyAttack, modifyHealth, setEntityStats } from './stats';\r\n\r\nexport const applyOnBeingAttackedBuffs = (\r\n\tattackerEntity: BoardEntity,\r\n\tattackerBoard: BoardEntity[],\r\n\tattackerHero: BgsPlayerEntity,\r\n\tdefendingEntity: BoardEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingPlayerEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// We need to respect the order of the secrets\r\n\tfor (const secret of (defendingPlayerEntity.secrets ?? []).filter((s) => !s.triggered)) {\r\n\t\tswitch (secret.cardId) {\r\n\t\t\tcase CardIds.AutodefenseMatrix_TB_Bacon_Secrets_07:\r\n\t\t\t\tif (!defendingEntity.divineShield) {\r\n\t\t\t\t\tsecret.triggered = true;\r\n\t\t\t\t\tupdateDivineShield(defendingEntity, defendingBoard, true, gameState.allCards);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SplittingImage_TB_Bacon_Secrets_04:\r\n\t\t\t\tif (defendingBoard.length < 7) {\r\n\t\t\t\t\tsecret.triggered = true;\r\n\t\t\t\t\thandleSplittingImage(\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t\t\t\tattackerBoard,\r\n\t\t\t\t\t\tattackerHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.PackTactics_TB_Bacon_Secrets_15:\r\n\t\t\t\tif (defendingBoard.length < 7) {\r\n\t\t\t\t\tsecret.triggered = true;\r\n\t\t\t\t\thandlePackTactics(\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t\t\t\tattackerBoard,\r\n\t\t\t\t\t\tattackerHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SnakeTrap_TB_Bacon_Secrets_02:\r\n\t\t\t\tif (defendingBoard.length < 7) {\r\n\t\t\t\t\tsecret.triggered = true;\r\n\t\t\t\t\thandleSnakeTrap(\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t\t\t\tattackerBoard,\r\n\t\t\t\t\t\tattackerHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.VenomstrikeTrap_TB_Bacon_Secrets_01:\r\n\t\t\t\tif (defendingBoard.length < 7) {\r\n\t\t\t\t\tsecret.triggered = true;\r\n\t\t\t\t\thandleVenomstrikeTrap(\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t\t\t\tattackerBoard,\r\n\t\t\t\t\t\tattackerHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tif (defendingEntity.taunt) {\r\n\t\tconst champions = defendingBoard.filter((entity) => entity.cardId === CardIds.ChampionOfYshaarj_BGS_111);\r\n\t\tconst goldenChampions = defendingBoard.filter(\r\n\t\t\t(entity) => entity.cardId === CardIds.ChampionOfYshaarj_TB_BaconUps_301,\r\n\t\t);\r\n\t\tchampions.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 1, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t\tmodifyHealth(entity, 2, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tentity,\r\n\t\t\t\tentity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tattackerHero,\r\n\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t);\r\n\t\t});\r\n\t\tgoldenChampions.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 2, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t\tmodifyHealth(entity, 4, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tentity,\r\n\t\t\t\tentity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tattackerHero,\r\n\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t);\r\n\t\t});\r\n\r\n\t\tconst arms = defendingBoard.filter((entity) => entity.cardId === CardIds.ArmOfTheEmpire_BGS_110);\r\n\t\tconst goldenArms = defendingBoard.filter((entity) => entity.cardId === CardIds.ArmOfTheEmpire_TB_BaconUps_302);\r\n\t\tarms.forEach((arm) => {\r\n\t\t\tmodifyAttack(defendingEntity, 2, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tarm,\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tattackerHero,\r\n\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t);\r\n\t\t});\r\n\t\tgoldenArms.forEach((arm) => {\r\n\t\t\tmodifyAttack(defendingEntity, 4, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tarm,\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tattackerHero,\r\n\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\r\n\t// Based on defending entity\r\n\tif (defendingEntity.cardId === CardIds.TormentedRitualist_BGS_201) {\r\n\t\tconst neighbours = getNeighbours(defendingBoard, defendingEntity);\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 1, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t\tmodifyHealth(entity, 1, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tentity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tattackerHero,\r\n\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t);\r\n\t\t});\r\n\t} else if (defendingEntity.cardId === CardIds.TormentedRitualist_TB_BaconUps_257) {\r\n\t\tconst neighbours = getNeighbours(defendingBoard, defendingEntity);\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 2, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t\tmodifyHealth(entity, 2, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tentity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tattackerHero,\r\n\t\t\t\tdefendingPlayerEntity,\r\n\t\t\t);\r\n\t\t});\r\n\t} else if (\r\n\t\tdefendingEntity.cardId === CardIds.DozyWhelp_BG24_300 ||\r\n\t\tdefendingEntity.cardId === CardIds.DozyWhelp_BG24_300_G\r\n\t) {\r\n\t\tmodifyAttack(\r\n\t\t\tdefendingEntity,\r\n\t\t\tdefendingEntity.cardId === CardIds.DozyWhelp_BG24_300_G ? 2 : 1,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingPlayerEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tdefendingEntity,\r\n\t\t\tdefendingEntity,\r\n\t\t\tdefendingBoard,\r\n\t\t\tattackerHero,\r\n\t\t\tdefendingPlayerEntity,\r\n\t\t);\r\n\t} else if (\r\n\t\t[CardIds.AdaptableBarricade_BG27_022, CardIds.AdaptableBarricade_BG27_022_G].includes(\r\n\t\t\tdefendingEntity.cardId as CardIds,\r\n\t\t)\r\n\t) {\r\n\t\t// https://twitter.com/LoewenMitchell/status/1692225556559901031?s=20\r\n\t\tconst totalStats = defendingEntity.attack + defendingEntity.health;\r\n\t\tconst attackerAttack = attackerEntity.attack;\r\n\t\tif (defendingEntity.divineShield) {\r\n\t\t\tdefendingEntity.health = 1;\r\n\t\t\tdefendingEntity.attack = totalStats - defendingEntity.health;\r\n\t\t} else if (attackerEntity.venomous || attackerEntity.poisonous) {\r\n\t\t\t// Do nothing\r\n\t\t} else if (attackerAttack < totalStats) {\r\n\t\t\tdefendingEntity.health = attackerAttack + 1;\r\n\t\t\tdefendingEntity.attack = totalStats - defendingEntity.health;\r\n\t\t}\r\n\t} else if (\r\n\t\t[CardIds.GraniteGuardian_BG24_001, CardIds.GraniteGuardian_BG24_001_G].includes(\r\n\t\t\tdefendingEntity.cardId as CardIds,\r\n\t\t)\r\n\t) {\r\n\t\tattackerEntity.health = 1;\r\n\t} else if (\r\n\t\t[CardIds.WaywardGrimscale_BG28_406, CardIds.WaywardGrimscale_BG28_406_G].includes(\r\n\t\t\tdefendingEntity.cardId as CardIds,\r\n\t\t)\r\n\t) {\r\n\t\tdefendingEntity.venomous = true;\r\n\t}\r\n\r\n\t// Based on attacking entity\r\n\tif (\r\n\t\tattackerEntity.cardId === CardIds.SindoreiStraightShot_BG25_016 ||\r\n\t\tattackerEntity.cardId === CardIds.SindoreiStraightShot_BG25_016_G\r\n\t) {\r\n\t\tdefendingEntity.taunt = false;\r\n\t\tdefendingEntity.reborn = false;\r\n\t} else if (\r\n\t\t[CardIds.TransmutedBramblewitch_BG27_013, CardIds.TransmutedBramblewitch_BG27_013_G].includes(\r\n\t\t\tattackerEntity.cardId as CardIds,\r\n\t\t) &&\r\n\t\tattackerEntity.abiityChargesLeft > 0\r\n\t) {\r\n\t\t// TODO: also modify all code that directly sets the stats of an entity\r\n\t\tsetEntityStats(defendingEntity, 3, 3, defendingBoard, defendingPlayerEntity, gameState);\r\n\t\tattackerEntity.abiityChargesLeft--;\r\n\t}\r\n};\r\n"]}
@@ -1,3 +1,4 @@
1
+ import { BgsPlayerEntity } from '../../bgs-player-entity';
1
2
  import { BoardEntity } from '../../board-entity';
2
3
  import { BoardSecret } from '../../board-secret';
3
4
  export interface GameAction {
@@ -8,6 +9,16 @@ export interface GameAction {
8
9
  opponentBoard: readonly BoardEntity[];
9
10
  opponentHand: readonly BoardEntity[];
10
11
  opponentSecrets: readonly BoardSecret[];
12
+ playerCardId: string;
13
+ playerEntityId: number;
14
+ playerHeroPowerCardId: string;
15
+ playerHeroPowerEntityId: number;
16
+ playerHeroPowerUsed: boolean;
17
+ opponentCardId: string;
18
+ opponentEntityId: number;
19
+ opponentHeroPowerCardId: string;
20
+ opponentHeroPowerEntityId: number;
21
+ opponentHeroPowerUsed: boolean;
11
22
  playerRewardCardId: string;
12
23
  playerRewardEntityId: number;
13
24
  playerRewardData: number;
@@ -27,3 +38,4 @@ export interface Damage {
27
38
  readonly targetEntityId?: number;
28
39
  readonly damage?: number;
29
40
  }
41
+ export declare const buildGameAction: (playerHero: BgsPlayerEntity, opponentHero: BgsPlayerEntity, action: Partial<GameAction>) => GameAction;
@@ -1,3 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildGameAction = void 0;
4
+ const buildGameAction = (playerHero, opponentHero, action) => {
5
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
6
+ const result = {
7
+ ...action,
8
+ playerSecrets: ((_a = playerHero === null || playerHero === void 0 ? void 0 : playerHero.secrets) !== null && _a !== void 0 ? _a : []).filter((s) => !s.triggered),
9
+ playerCardId: playerHero === null || playerHero === void 0 ? void 0 : playerHero.cardId,
10
+ playerEntityId: playerHero === null || playerHero === void 0 ? void 0 : playerHero.entityId,
11
+ playerHeroPowerCardId: playerHero === null || playerHero === void 0 ? void 0 : playerHero.heroPowerId,
12
+ playerHeroPowerEntityId: playerHero === null || playerHero === void 0 ? void 0 : playerHero.heroPowerEntityId,
13
+ playerHeroPowerUsed: playerHero === null || playerHero === void 0 ? void 0 : playerHero.heroPowerUsed,
14
+ playerRewardCardId: (_d = (_c = (_b = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewardEntities) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.cardId) !== null && _d !== void 0 ? _d : (_e = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewards) === null || _e === void 0 ? void 0 : _e[0],
15
+ playerRewardEntityId: (_g = (_f = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewardEntities) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.entityId,
16
+ playerRewardData: (_j = (_h = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewardEntities) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.scriptDataNum1,
17
+ opponentSecrets: ((_k = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.secrets) !== null && _k !== void 0 ? _k : []).filter((s) => !s.triggered),
18
+ opponentCardId: opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.cardId,
19
+ opponentEntityId: opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.entityId,
20
+ opponentHeroPowerCardId: opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.heroPowerId,
21
+ opponentHeroPowerEntityId: opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.heroPowerEntityId,
22
+ opponentHeroPowerUsed: opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.heroPowerUsed,
23
+ opponentRewardCardId: (_o = (_m = (_l = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewardEntities) === null || _l === void 0 ? void 0 : _l[0]) === null || _m === void 0 ? void 0 : _m.cardId) !== null && _o !== void 0 ? _o : (_p = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewards) === null || _p === void 0 ? void 0 : _p[0],
24
+ opponentRewardEntityId: (_r = (_q = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewardEntities) === null || _q === void 0 ? void 0 : _q[0]) === null || _r === void 0 ? void 0 : _r.entityId,
25
+ opponentRewardData: (_t = (_s = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewardEntities) === null || _s === void 0 ? void 0 : _s[0]) === null || _t === void 0 ? void 0 : _t.scriptDataNum1,
26
+ };
27
+ return result;
28
+ };
29
+ exports.buildGameAction = buildGameAction;
3
30
  //# sourceMappingURL=game-action.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"game-action.js","sourceRoot":"","sources":["../../../src/simulation/spectator/game-action.ts"],"names":[],"mappings":"","sourcesContent":["import { BoardEntity } from '../../board-entity';\r\nimport { BoardSecret } from '../../board-secret';\r\n\r\nexport interface GameAction {\r\n\ttype:\r\n\t\t| 'damage'\r\n\t\t| 'attack'\r\n\t\t| 'spawn'\r\n\t\t| 'minion-death'\r\n\t\t| 'power-target'\r\n\t\t| 'start-of-combat'\r\n\t\t| 'player-attack'\r\n\t\t| 'opponent-attack';\r\n\tplayerBoard: readonly BoardEntity[];\r\n\tplayerHand: readonly BoardEntity[];\r\n\tplayerSecrets: readonly BoardSecret[];\r\n\topponentBoard: readonly BoardEntity[];\r\n\topponentHand: readonly BoardEntity[];\r\n\topponentSecrets: readonly BoardSecret[];\r\n\tplayerRewardCardId: string;\r\n\tplayerRewardEntityId: number;\r\n\tplayerRewardData: number;\r\n\topponentRewardCardId: string;\r\n\topponentRewardEntityId: number;\r\n\topponentRewardData: number;\r\n\tsourceEntityId?: number;\r\n\t/** @deprecated */\r\n\ttargetEntityId?: number;\r\n\ttargetEntityIds?: number[];\r\n\r\n\tdamages?: Damage[];\r\n\tspawns?: readonly BoardEntity[];\r\n\tdeaths?: readonly BoardEntity[];\r\n\tdeadMinionsPositionsOnBoard?: readonly number[];\r\n}\r\n\r\nexport interface Damage {\r\n\treadonly sourceEntityId?: number;\r\n\treadonly targetEntityId?: number;\r\n\treadonly damage?: number;\r\n}\r\n"]}
1
+ {"version":3,"file":"game-action.js","sourceRoot":"","sources":["../../../src/simulation/spectator/game-action.ts"],"names":[],"mappings":";;;AAqDO,MAAM,eAAe,GAAG,CAC9B,UAA2B,EAC3B,YAA6B,EAC7B,MAA2B,EACd,EAAE;;IACf,MAAM,MAAM,GAAe;QAC1B,GAAG,MAAM;QAET,aAAa,EAAE,CAAC,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,OAAO,mCAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC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AE,aAAa;QAClD,oBAAoB,EAAE,MAAA,MAAA,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,mBAAmB,0CAAG,CAAC,CAAC,0CAAE,MAAM,mCAAI,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,YAAY,0CAAG,CAAC,CAAC;QACvG,sBAAsB,EAAE,MAAA,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,mBAAmB,0CAAG,CAAC,CAAC,0CAAE,QAAQ;QACxE,kBAAkB,EAAE,MAAA,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,mBAAmB,0CAAG,CAAC,CAAC,0CAAE,cAAc;KAC5D,CAAC;IAChB,OAAO,MAAM,CAAC;AACf,CAAC,CAAC;AA7BW,QAAA,eAAe,mBA6B1B","sourcesContent":["import { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { BoardSecret } from '../../board-secret';\r\n\r\nexport interface GameAction {\r\n\ttype:\r\n\t\t| 'damage'\r\n\t\t| 'attack'\r\n\t\t| 'spawn'\r\n\t\t| 'minion-death'\r\n\t\t| 'power-target'\r\n\t\t| 'start-of-combat'\r\n\t\t| 'player-attack'\r\n\t\t| 'opponent-attack';\r\n\tplayerBoard: readonly BoardEntity[];\r\n\tplayerHand: readonly BoardEntity[];\r\n\tplayerSecrets: readonly BoardSecret[];\r\n\topponentBoard: readonly BoardEntity[];\r\n\topponentHand: readonly BoardEntity[];\r\n\topponentSecrets: readonly BoardSecret[];\r\n\tplayerCardId: string;\r\n\tplayerEntityId: number;\r\n\tplayerHeroPowerCardId: string;\r\n\tplayerHeroPowerEntityId: number;\r\n\tplayerHeroPowerUsed: boolean;\r\n\topponentCardId: string;\r\n\topponentEntityId: number;\r\n\topponentHeroPowerCardId: string;\r\n\topponentHeroPowerEntityId: number;\r\n\topponentHeroPowerUsed: boolean;\r\n\tplayerRewardCardId: string;\r\n\tplayerRewardEntityId: number;\r\n\tplayerRewardData: number;\r\n\topponentRewardCardId: string;\r\n\topponentRewardEntityId: number;\r\n\topponentRewardData: number;\r\n\tsourceEntityId?: number;\r\n\t/** @deprecated */\r\n\ttargetEntityId?: number;\r\n\ttargetEntityIds?: number[];\r\n\r\n\tdamages?: Damage[];\r\n\tspawns?: readonly BoardEntity[];\r\n\tdeaths?: readonly BoardEntity[];\r\n\tdeadMinionsPositionsOnBoard?: readonly number[];\r\n}\r\n\r\nexport interface Damage {\r\n\treadonly sourceEntityId?: number;\r\n\treadonly targetEntityId?: number;\r\n\treadonly damage?: number;\r\n}\r\n\r\nexport const buildGameAction = (\r\n\tplayerHero: BgsPlayerEntity,\r\n\topponentHero: BgsPlayerEntity,\r\n\taction: Partial<GameAction>,\r\n): GameAction => {\r\n\tconst result: GameAction = {\r\n\t\t...action,\r\n\r\n\t\tplayerSecrets: (playerHero?.secrets ?? []).filter((s) => !s.triggered),\r\n\t\tplayerCardId: playerHero?.cardId,\r\n\t\tplayerEntityId: playerHero?.entityId,\r\n\t\tplayerHeroPowerCardId: playerHero?.heroPowerId,\r\n\t\tplayerHeroPowerEntityId: playerHero?.heroPowerEntityId,\r\n\t\tplayerHeroPowerUsed: playerHero?.heroPowerUsed,\r\n\t\tplayerRewardCardId: playerHero?.questRewardEntities?.[0]?.cardId ?? playerHero?.questRewards?.[0],\r\n\t\tplayerRewardEntityId: playerHero?.questRewardEntities?.[0]?.entityId,\r\n\t\tplayerRewardData: playerHero?.questRewardEntities?.[0]?.scriptDataNum1,\r\n\r\n\t\topponentSecrets: (opponentHero?.secrets ?? []).filter((s) => !s.triggered),\r\n\t\topponentCardId: opponentHero?.cardId,\r\n\t\topponentEntityId: opponentHero?.entityId,\r\n\t\topponentHeroPowerCardId: opponentHero?.heroPowerId,\r\n\t\topponentHeroPowerEntityId: opponentHero?.heroPowerEntityId,\r\n\t\topponentHeroPowerUsed: opponentHero?.heroPowerUsed,\r\n\t\topponentRewardCardId: opponentHero?.questRewardEntities?.[0]?.cardId ?? opponentHero?.questRewards?.[0],\r\n\t\topponentRewardEntityId: opponentHero?.questRewardEntities?.[0]?.entityId,\r\n\t\topponentRewardData: opponentHero?.questRewardEntities?.[0]?.scriptDataNum1,\r\n\t} as GameAction;\r\n\treturn result;\r\n};\r\n"]}
@@ -1,10 +1,4 @@
1
1
  import { GameAction } from './game-action';
2
2
  export interface GameSample {
3
3
  readonly actions: readonly GameAction[];
4
- readonly playerCardId: string;
5
- readonly playerHeroPowerCardId: string;
6
- readonly playerHeroPowerUsed: boolean;
7
- readonly opponentCardId: string;
8
- readonly opponentHeroPowerCardId: string;
9
- readonly opponentHeroPowerUsed: boolean;
10
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"game-sample.js","sourceRoot":"","sources":["../../../src/simulation/spectator/game-sample.ts"],"names":[],"mappings":"","sourcesContent":["import { GameAction } from './game-action';\r\n\r\nexport interface GameSample {\r\n\treadonly actions: readonly GameAction[];\r\n\treadonly playerCardId: string;\r\n\treadonly playerHeroPowerCardId: string;\r\n\treadonly playerHeroPowerUsed: boolean;\r\n\treadonly opponentCardId: string;\r\n\treadonly opponentHeroPowerCardId: string;\r\n\treadonly opponentHeroPowerUsed: boolean;\r\n}\r\n"]}
1
+ {"version":3,"file":"game-sample.js","sourceRoot":"","sources":["../../../src/simulation/spectator/game-sample.ts"],"names":[],"mappings":"","sourcesContent":["import { GameAction } from './game-action';\r\n\r\nexport interface GameSample {\r\n\treadonly actions: readonly GameAction[];\r\n\t/*\r\n\treadonly playerCardId: string;\r\n\treadonly playerEntityId: number;\r\n\treadonly playerHeroPowerCardId: string;\r\n\treadonly playerHeroPowerUsed: boolean;\r\n\treadonly opponentCardId: string;\r\n\treadonly opponentEntityId: number;\r\n\treadonly opponentHeroPowerCardId: string;\r\n\treadonly opponentHeroPowerUsed: boolean;\r\n\t*/\r\n}\r\n"]}
@@ -8,13 +8,16 @@ export declare class Spectator {
8
8
  private wonBattles;
9
9
  private tiedBattles;
10
10
  private lostBattles;
11
- private readonly playerCardId?;
12
- private readonly playerHeroPowerCardId;
13
- private readonly playerHeroPowerUsed;
14
- private readonly opponentCardId;
15
- private readonly opponentHeroPowerCardId;
16
- private readonly opponentHeroPowerUsed;
17
- constructor(battleInput: BgsBattleInfo);
11
+ private playerCardId;
12
+ private playerEntityId;
13
+ private playerHeroPowerCardId;
14
+ private playerHeroPowerUsed;
15
+ private opponentCardId;
16
+ private opponentEntityId;
17
+ private opponentHeroPowerCardId;
18
+ private opponentHeroPowerUsed;
19
+ constructor();
20
+ setProtagonists(battleInput: BgsBattleInfo): void;
18
21
  prune(): void;
19
22
  buildOutcomeSamples(): {
20
23
  won: readonly GameSample[];