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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/cards/impl/bg-spell/blood-gem-quilboar-divine-shield.js +2 -2
  2. package/dist/cards/impl/bg-spell/blood-gem-quilboar-divine-shield.js.map +1 -1
  3. package/dist/cards/impl/bg-spell/blood-gem-quilboar-reborn.js +2 -2
  4. package/dist/cards/impl/bg-spell/blood-gem-quilboar-reborn.js.map +1 -1
  5. package/dist/cards/impl/bg-spell/blood-gem-quilboar-taunt.js +2 -2
  6. package/dist/cards/impl/bg-spell/blood-gem-quilboar-taunt.js.map +1 -1
  7. package/dist/cards/impl/bg-spell/conflagration.js +2 -2
  8. package/dist/cards/impl/bg-spell/conflagration.js.map +1 -1
  9. package/dist/cards/impl/bg-spell/deepwater-clan.js +2 -2
  10. package/dist/cards/impl/bg-spell/deepwater-clan.js.map +1 -1
  11. package/dist/cards/impl/bg-spell/queens-command.js +2 -2
  12. package/dist/cards/impl/bg-spell/queens-command.js.map +1 -1
  13. package/dist/cards/impl/bg-spell/shifting-tide.js.map +1 -1
  14. package/dist/cards/impl/minion/abyssal-bruiser.js +2 -4
  15. package/dist/cards/impl/minion/abyssal-bruiser.js.map +1 -1
  16. package/dist/cards/impl/minion/bristleback-bully.js +1 -3
  17. package/dist/cards/impl/minion/bristleback-bully.js.map +1 -1
  18. package/dist/cards/impl/minion/chromadrake-pool.js +5 -5
  19. package/dist/cards/impl/minion/chromadrake-pool.js.map +1 -1
  20. package/dist/cards/impl/minion/clunker-junker.js +4 -2
  21. package/dist/cards/impl/minion/clunker-junker.js.map +1 -1
  22. package/dist/cards/impl/minion/dead-sea-ravager.js +2 -3
  23. package/dist/cards/impl/minion/dead-sea-ravager.js.map +1 -1
  24. package/dist/cards/impl/minion/deepwater-chieftain.js +2 -6
  25. package/dist/cards/impl/minion/deepwater-chieftain.js.map +1 -1
  26. package/dist/cards/impl/minion/firelands-fugitive.js +1 -3
  27. package/dist/cards/impl/minion/firelands-fugitive.js.map +1 -1
  28. package/dist/cards/impl/minion/ingenious-inventor.js +2 -3
  29. package/dist/cards/impl/minion/ingenious-inventor.js.map +1 -1
  30. package/dist/cards/impl/minion/leyline-surfacer.js +2 -6
  31. package/dist/cards/impl/minion/leyline-surfacer.js.map +1 -1
  32. package/dist/cards/impl/minion/mummifier.js +1 -1
  33. package/dist/cards/impl/minion/mummifier.js.map +1 -1
  34. package/dist/cards/impl/minion/redtusk-thornraiser.js +1 -3
  35. package/dist/cards/impl/minion/redtusk-thornraiser.js.map +1 -1
  36. package/dist/cards/impl/minion/tide-raiser.js +1 -1
  37. package/dist/cards/impl/minion/tide-raiser.js.map +1 -1
  38. package/dist/cards/impl/minion/vinespeaker.js +1 -2
  39. package/dist/cards/impl/minion/vinespeaker.js.map +1 -1
  40. package/dist/cards/impl/minion/wrathscale-rogue.js.map +1 -1
  41. package/dist/cards/impl/trinket/deathtouch-apple.js +1 -2
  42. package/dist/cards/impl/trinket/deathtouch-apple.js.map +1 -1
  43. package/dist/cards/impl/trinket/rylak-portrait.js +1 -2
  44. package/dist/cards/impl/trinket/rylak-portrait.js.map +1 -1
  45. package/dist/cards/impl/trinket/sky-golem-portrait-enchantment.js +1 -2
  46. package/dist/cards/impl/trinket/sky-golem-portrait-enchantment.js.map +1 -1
  47. package/dist/cards/impl/trinket/sky-golem-portrait.js +2 -3
  48. package/dist/cards/impl/trinket/sky-golem-portrait.js.map +1 -1
  49. package/dist/cards/impl/trinket/soul-fermenter.js +6 -3
  50. package/dist/cards/impl/trinket/soul-fermenter.js.map +1 -1
  51. package/dist/input-clone.js +1 -1
  52. package/dist/input-clone.js.map +1 -1
  53. package/dist/services/card-ids.d.ts +165 -17
  54. package/dist/services/card-ids.js.map +1 -1
  55. package/dist/simulate-bgs-battle.js +4 -4
  56. package/dist/simulate-bgs-battle.js.map +1 -1
  57. package/dist/simulation/auras.js +4 -2
  58. package/dist/simulation/auras.js.map +1 -1
  59. package/dist/simulation/avenge.js +4 -0
  60. package/dist/simulation/avenge.js.map +1 -1
  61. package/dist/simulation/blood-gems.js +1 -4
  62. package/dist/simulation/blood-gems.js.map +1 -1
  63. package/dist/simulation/reborn.js +25 -23
  64. package/dist/simulation/reborn.js.map +1 -1
  65. package/dist/simulation/start-of-combat/soc-trinket.js +1 -1
  66. package/dist/simulation/start-of-combat/soc-trinket.js.map +1 -1
  67. package/dist/temp-card-ids.d.ts +1 -12
  68. package/dist/temp-card-ids.js +1 -12
  69. package/dist/temp-card-ids.js.map +1 -1
  70. package/package.json +2 -2
@@ -128,10 +128,6 @@ const simulateBattle = function* (battleInput, cards, cardsData) {
128
128
  };
129
129
  const simulator = new simulator_1.Simulator(gameState);
130
130
  const battleResult = simulator.simulateSingleBattle(gameState.gameState.player, gameState.gameState.opponent);
131
- if (Date.now() - start > maxAcceptableDuration && !hideMaxSimulationDurationWarning) {
132
- console.warn('Stopping simulation after', i, 'iterations and ', Date.now() - start, 'ms');
133
- break;
134
- }
135
131
  if (!battleResult) {
136
132
  continue;
137
133
  }
@@ -157,6 +153,10 @@ const simulateBattle = function* (battleInput, cards, cardsData) {
157
153
  simulationResult.tied++;
158
154
  }
159
155
  spectator.commitBattleResult(battleResult.result);
156
+ if (Date.now() - start > maxAcceptableDuration && !hideMaxSimulationDurationWarning) {
157
+ console.warn('Stopping simulation after', i, 'iterations and ', Date.now() - start, 'ms');
158
+ break;
159
+ }
160
160
  if (!!intermediateSteps && i > 0 && i % intermediateSteps === 0) {
161
161
  updateSimulationResult(simulationResult, inputReady, damageConfidence);
162
162
  yield simulationResult;
@@ -1 +1 @@
1
- {"version":3,"file":"simulate-bgs-battle.js","sourceRoot":"","sources":["../src/simulate-bgs-battle.ts"],"names":[],"mappings":";;;AACA,iEAA+D;AAE/D,2DAAwE;AACxE,mDAA+C;AAC/C,gEAA2D;AAC3D,+CAA2C;AAC3C,+CAA4C;AAC5C,yDAAqD;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AAM,uCAAuC,GAAG,EAAE,CAAC;AAC5C,MAAM,6BAA6B,GAAG,CAAC,MAAc,EAAW,EAAE;IACxE,IAAI,8BAA8B,CAAC,QAAQ,CAAC,MAAiB,CAAC,EAAE;QAC/D,OAAO,IAAI,CAAC;KACZ;IACD,IAAI,uCAAuC,CAAC,MAAM,KAAK,CAAC,EAAE;QACzD,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,6BAAY,CAAC,EAAE;YAEnD,IAAI,IAAA,+CAA8B,EAAC,QAAQ,CAAC,EAAE;gBAC7C,uCAAuC,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;aAClE;SACD;KACD;IACD,OAAO,uCAAuC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACjE,CAAC,CAAC;AAbW,QAAA,6BAA6B,iCAaxC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport { AllCardsService } from '@firestone-hs/reference-data';\nimport { BgsBattleInfo } from './bgs-battle-info';\nimport { hasDeathrattleSpawnEnchantment } from './cards/card.interface';\nimport { CardsData } from './cards/cards-data';\nimport { cardMappings } from './cards/impl/_card-mappings';\nimport { debugState } from './debug-state';\nimport { cloneInput3 } from './input-clone';\nimport { buildFinalInput } from './input-sanitation';\nimport { CardIds } from './services/card-ids';\nimport { SimulationResult } from './simulation-result';\nimport { FullGameState } from './simulation/internal-game-state';\nimport { SharedState } from './simulation/shared-state';\nimport { Simulator } from './simulation/simulator';\nimport { Spectator } from './simulation/spectator/spectator';\n\nlet globalCards = new AllCardsService();\n\nexport const assignCards = (cards: AllCardsService) => {\n\tglobalCards = cards;\n};\n\n// This example demonstrates a NodeJS 8.10 async handler[1], however of course you could use\n// the more traditional callback-style handler.\n// [1]: https://aws.amazon.com/blogs/compute/node-js-8-10-runtime-now-available-in-aws-lambda/\nexport default async (event): Promise<any> => {\n\tif (!event.body?.length) {\n\t\tconsole.warn('missing event body', event);\n\t\treturn;\n\t}\n\n\tconst battleInput: BgsBattleInfo = JSON.parse(event.body);\n\tconst cards = globalCards;\n\tawait cards.initializeCardsDb();\n\tconst cardsData = new CardsData(cards, false);\n\tcardsData.inititialize(\n\t\tbattleInput.gameState?.validTribes ?? battleInput.options?.validTribes,\n\t\tbattleInput.gameState?.anomalies ?? [],\n\t);\n\tconst battleIterator = simulateBattle(battleInput, cards, cardsData);\n\n\t// Iterate through all intermediate results to reach the final result\n\tlet result = battleIterator.next();\n\twhile (!result.done) {\n\t\tresult = battleIterator.next();\n\t}\n\n\tconst simulationResult = result.value;\n\t// console.debug('simulationResult', simulationResult);\n\n\tconst response = {\n\t\tstatusCode: 200,\n\t\tisBase64Encoded: false,\n\t\tbody: JSON.stringify(simulationResult),\n\t};\n\treturn response;\n};\n\nexport const simulateBattle = function* (\n\tbattleInput: BgsBattleInfo,\n\tcards: AllCardsService,\n\tcardsData: CardsData,\n): Generator<SimulationResult, SimulationResult, void> {\n\tif (!cards?.getCards()?.length) {\n\t\tconsole.error('[simulate-bgs-battle] reference cards are empty, cannot simulate battle', cards);\n\t\treturn null;\n\t}\n\t// !battleInput.options?.skipInfoLogs && console.time('full-sim');\n\tconst start = Date.now();\n\tconst maxAcceptableDuration = battleInput.options?.maxAcceptableDuration || 8000;\n\tconst hideMaxSimulationDurationWarning = battleInput.options?.hideMaxSimulationDurationWarning ?? false;\n\tconst numberOfSimulations = battleInput.options?.numberOfSimulations || 8000;\n\tconst intermediateSteps = battleInput.options?.intermediateResults ?? 200;\n\tconst damageConfidence = battleInput.options?.damageConfidence ?? 0.9;\n\tconst includeOutcomeSamples = battleInput.options?.includeOutcomeSamples ?? true;\n\tconst simulationResult: SimulationResult = {\n\t\twonLethal: 0,\n\t\twon: 0,\n\t\ttied: 0,\n\t\tlost: 0,\n\t\tlostLethal: 0,\n\t\tdamageWons: [],\n\t\tdamageWon: 0,\n\t\tdamageWonRange: null,\n\t\tdamageLosts: [],\n\t\tdamageLost: 0,\n\t\tdamageLostRange: null,\n\t\twonLethalPercent: undefined,\n\t\twonPercent: undefined,\n\t\ttiedPercent: undefined,\n\t\tlostPercent: undefined,\n\t\tlostLethalPercent: undefined,\n\t\taverageDamageWon: undefined,\n\t\taverageDamageLost: undefined,\n\t};\n\n\tconst spectator = new Spectator(includeOutcomeSamples);\n\tconst inputReady = buildFinalInput(battleInput, cards, cardsData);\n\n\t// Apply debug state from input when present (e.g. from bug report)\n\tif (battleInput.debugState) {\n\t\tdebugState.active = true;\n\t\tdebugState.forcedCurrentAttacker = battleInput.debugState.forcedCurrentAttacker;\n\t\tdebugState.forcedFaceOffBase = battleInput.debugState.forcedFaceOffBase.map((f) => ({\n\t\t\tattacker: { ...f.attacker },\n\t\t\tdefender: { ...f.defender },\n\t\t}));\n\t\tconst rawPicks = battleInput.debugState.forcedRandomPicks ?? [];\n\t\tdebugState.forcedRandomPicksBase = rawPicks.map((p) => ({\n\t\t\tsource: { ...p.source },\n\t\t\ttarget: { ...p.target },\n\t\t\t...(p.chosenCardId && { chosenCardId: p.chosenCardId }),\n\t\t}));\n\t}\n\n\ttry {\n\t\t!battleInput.options?.skipInfoLogs && console.time('simulation');\n\t\tconst outcomes = {};\n\t\tfor (let i = 0; i < numberOfSimulations; i++) {\n\t\t\tconst input: BgsBattleInfo = cloneInput3(inputReady);\n\t\t\tconst inputClone: BgsBattleInfo = cloneInput3(inputReady);\n\t\t\tconst gameState: FullGameState = {\n\t\t\t\tallCards: cards,\n\t\t\t\tcardsData: cardsData,\n\t\t\t\tspectator: spectator,\n\t\t\t\tsharedState: new SharedState(),\n\t\t\t\tcurrentTurn: input.gameState.currentTurn,\n\t\t\t\tvalidTribes: input.gameState.validTribes,\n\t\t\t\tanomalies: input.gameState.anomalies,\n\t\t\t\tgameState: {\n\t\t\t\t\tplayer: {\n\t\t\t\t\t\tplayer: input.playerBoard.player,\n\t\t\t\t\t\tboard: input.playerBoard.board,\n\t\t\t\t\t\tteammate: input.playerTeammateBoard,\n\t\t\t\t\t},\n\t\t\t\t\topponent: {\n\t\t\t\t\t\tplayer: input.opponentBoard.player,\n\t\t\t\t\t\tboard: input.opponentBoard.board,\n\t\t\t\t\t\tteammate: input.opponentTeammateBoard,\n\t\t\t\t\t},\n\t\t\t\t\tplayerInitial: {\n\t\t\t\t\t\tplayer: inputClone.playerBoard.player,\n\t\t\t\t\t\tboard: inputClone.playerBoard.board,\n\t\t\t\t\t\tteammate: inputClone.playerTeammateBoard,\n\t\t\t\t\t},\n\t\t\t\t\topponentInitial: {\n\t\t\t\t\t\tplayer: inputClone.opponentBoard.player,\n\t\t\t\t\t\tboard: inputClone.opponentBoard.board,\n\t\t\t\t\t\tteammate: inputClone.opponentTeammateBoard,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t\tconst simulator = new Simulator(gameState);\n\t\t\tconst battleResult = simulator.simulateSingleBattle(\n\t\t\t\tgameState.gameState.player,\n\t\t\t\tgameState.gameState.opponent,\n\t\t\t);\n\t\t\tif (Date.now() - start > maxAcceptableDuration && !hideMaxSimulationDurationWarning) {\n\t\t\t\t// Can happen in case of inifinite boards, or a bug. Don't hog the user's computer in that case\n\t\t\t\tconsole.warn('Stopping simulation after', i, 'iterations and ', Date.now() - start, 'ms');\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (!battleResult) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (battleResult.result === 'won') {\n\t\t\t\tsimulationResult.won++;\n\t\t\t\tsimulationResult.damageWon += battleResult.damageDealt;\n\t\t\t\tsimulationResult.damageWons.push(battleResult.damageDealt);\n\t\t\t\tif (battleResult.damageDealt >= battleInput.opponentBoard.player.hpLeft) {\n\t\t\t\t\tsimulationResult.wonLethal++;\n\t\t\t\t}\n\t\t\t} else if (battleResult.result === 'lost') {\n\t\t\t\tsimulationResult.lost++;\n\t\t\t\tsimulationResult.damageLost += battleResult.damageDealt;\n\t\t\t\tsimulationResult.damageLosts.push(battleResult.damageDealt);\n\t\t\t\toutcomes[battleResult.damageDealt] = (outcomes[battleResult.damageDealt] ?? 0) + 1;\n\t\t\t\tif (\n\t\t\t\t\tbattleInput.playerBoard.player.hpLeft &&\n\t\t\t\t\tbattleResult.damageDealt >= battleInput.playerBoard.player.hpLeft\n\t\t\t\t) {\n\t\t\t\t\tsimulationResult.lostLethal++;\n\t\t\t\t}\n\t\t\t} else if (battleResult.result === 'tied') {\n\t\t\t\tsimulationResult.tied++;\n\t\t\t}\n\t\t\tspectator.commitBattleResult(battleResult.result);\n\n\t\t\t// Yield intermediate result every 200 iterations\n\t\t\tif (!!intermediateSteps && i > 0 && i % intermediateSteps === 0) {\n\t\t\t\tupdateSimulationResult(simulationResult, inputReady, damageConfidence);\n\t\t\t\tyield simulationResult;\n\t\t\t}\n\t\t}\n\t\tupdateSimulationResult(simulationResult, inputReady, damageConfidence);\n\t\t!battleInput.options?.skipInfoLogs && console.timeEnd('simulation');\n\t\tspectator.prune();\n\t\tsimulationResult.outcomeSamples = spectator.buildOutcomeSamples(battleInput.gameState);\n\t\t// Avoid sending this verbose data\n\n\t\tsimulationResult.damageWons = [];\n\t\tsimulationResult.damageLosts = [];\n\t\t// !battleInput.options?.skipInfoLogs && console.timeEnd('full-sim');\n\t\treturn simulationResult;\n\t} finally {\n\t\tif (battleInput.debugState) {\n\t\t\tdebugState.active = false;\n\t\t}\n\t}\n};\n\nconst updateSimulationResult = (simulationResult: SimulationResult, input: BgsBattleInfo, damageConfidence: number) => {\n\tconst totalMatches = simulationResult.won + simulationResult.tied + simulationResult.lost;\n\tsimulationResult.wonPercent = checkRounding(\n\t\tMath.round((10 * (100 * simulationResult.won)) / totalMatches) / 10,\n\t\tsimulationResult.won,\n\t\ttotalMatches,\n\t);\n\tsimulationResult.wonLethalPercent = checkRounding(\n\t\tMath.round((10 * (100 * simulationResult.wonLethal)) / totalMatches) / 10,\n\t\tsimulationResult.wonLethal,\n\t\ttotalMatches,\n\t);\n\tsimulationResult.lostPercent = checkRounding(\n\t\tMath.round((10 * (100 * simulationResult.lost)) / totalMatches) / 10,\n\t\tsimulationResult.lost,\n\t\ttotalMatches,\n\t);\n\tsimulationResult.lostLethalPercent = checkRounding(\n\t\tMath.round((10 * (100 * simulationResult.lostLethal)) / totalMatches) / 10,\n\t\tsimulationResult.lostLethal,\n\t\ttotalMatches,\n\t);\n\tsimulationResult.tiedPercent = checkRounding(\n\t\tMath.max(0, 100 - simulationResult.lostPercent - simulationResult.wonPercent),\n\t\tsimulationResult.tied,\n\t\ttotalMatches,\n\t);\n\n\t// simulationResult.wonLethalPercent = Math.round((10 * (100 * simulationResult.wonLethal)) / totalMatches) / 10;\n\t// simulationResult.lostLethalPercent = Math.round((10 * (100 * simulationResult.lostLethal)) / totalMatches) / 10;\n\tconst totalDamageWon = simulationResult.damageWons.reduce((a, b) => a + b, 0);\n\tconst totalDamageLost = simulationResult.damageLosts.reduce((a, b) => a + b, 0);\n\tconst damageWonRange = calculateDamageRange(simulationResult.damageWons, damageConfidence);\n\tconst damageLostRange = calculateDamageRange(simulationResult.damageLosts, damageConfidence);\n\tsimulationResult.averageDamageWon = simulationResult.won ? totalDamageWon / simulationResult.won : 0;\n\tsimulationResult.averageDamageLost = simulationResult.lost ? totalDamageLost / simulationResult.lost : 0;\n\tsimulationResult.damageWonRange = simulationResult.won ? damageWonRange : null;\n\tsimulationResult.damageLostRange = simulationResult.lost ? damageLostRange : null;\n\n\tif (\n\t\tsimulationResult.averageDamageWon > 0 &&\n\t\tsimulationResult.averageDamageWon < input.playerBoard.player.tavernTier\n\t) {\n\t\tconsole.warn('average damage won issue');\n\t}\n\tif (\n\t\tsimulationResult.averageDamageLost > 0 &&\n\t\tsimulationResult.averageDamageLost < input.opponentBoard.player.tavernTier\n\t) {\n\t\tconsole.warn('average damage lost issue');\n\t}\n};\n\nconst calculateDamageRange = (damageArray: number[], damageConfidence: number): { min: number; max: number } => {\n\tif (damageArray.length === 0) {\n\t\treturn { min: 0, max: 0 };\n\t}\n\n\t// Sort the array\n\tconst sortedDamage = [...damageArray].sort((a, b) => a - b);\n\n\t// Calculate the 10th and 90th percentiles\n\tconst percentile = (arr: number[], p: number) => {\n\t\tconst index = Math.floor(p * arr.length);\n\t\treturn arr[index];\n\t};\n\n\tconst minDamage = percentile(sortedDamage, 1 - damageConfidence);\n\tconst maxDamage = percentile(sortedDamage, damageConfidence);\n\n\treturn { min: minDamage, max: maxDamage };\n};\n\nconst checkRounding = (roundedValue: number, initialValue: number, totalValue: number): number => {\n\tif (roundedValue === 0 && initialValue !== 0) {\n\t\treturn 0.01;\n\t}\n\tif (roundedValue === 100 && initialValue !== totalValue) {\n\t\treturn 99.9;\n\t}\n\treturn roundedValue;\n};\n\n// Used when triggering random deathrattles\nconst VALID_DEATHRATTLE_ENCHANTMENTS = [\n\tCardIds.ReplicatingMenace_ReplicatingMenaceEnchantment_BG_BOT_312e,\n\tCardIds.ReplicatingMenace_ReplicatingMenaceEnchantment_TB_BaconUps_032e,\n\tCardIds.LivingSpores_LivingSporesEnchantment,\n\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e,\n\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge,\n\tCardIds.Sneed_SneedsReplicator,\n\tCardIds.SneedsReplicator_ReplicateEnchantment,\n\tCardIds.EarthRecollectionEnchantment, // Spirit Raptor\n\tCardIds.FireRecollectionEnchantment,\n\tCardIds.LightningRecollectionEnchantment,\n\tCardIds.WaterRecollectionEnchantment,\n\tCardIds.EarthInvocation_ElementEarthEnchantment, // Summon a 1/1\n\tCardIds.LightningInvocation, // Deal 1 damage to 5 enemy minions\n\t// CardIds.SurfNSurf_CrabRidingEnchantment_BG27_004e,\n\t// CardIds.SurfNSurf_CrabRidingEnchantment_BG27_004_Ge,\n\t// CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055e,\n\t// CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055_Ge,\n\tCardIds.BoonOfBeetles_BeetleSwarmEnchantment_BG28_603e,\n\tCardIds.RustyTrident_TridentsTreasureEnchantment_BG30_MagicItem_917e,\n\tCardIds.HoggyBank_GemInTheBankEnchantment_BG30_MagicItem_411e,\n\tCardIds.JarredFrostling_FrostyGlobeEnchantment_BG30_MagicItem_952e,\n\tCardIds.CaduceusReactor_CaduceusReactorEnchantment_BG31_HERO_801ptee,\n\tCardIds.AutoAssembler_AutoAssemblerEnchantment_BG32_172e,\n\tCardIds.AutoAssembler_AutoAssemblerEnchantment_BG32_172_Ge,\n\tCardIds.TamsinRoame_ImpendingSacrificeEnchantment_BG20_HERO_282e2,\n];\nconst validDeathrattleEnchantmentsFromMapping = [];\nexport const isValidDeathrattleEnchantment = (cardId: string): boolean => {\n\tif (VALID_DEATHRATTLE_ENCHANTMENTS.includes(cardId as CardIds)) {\n\t\treturn true;\n\t}\n\tif (validDeathrattleEnchantmentsFromMapping.length === 0) {\n\t\tfor (const cardImpl of Object.values(cardMappings)) {\n\t\t\t// Also includes non-enchantments, but since we only match this against the enchants list, it's fine\n\t\t\tif (hasDeathrattleSpawnEnchantment(cardImpl)) {\n\t\t\t\tvalidDeathrattleEnchantmentsFromMapping.push(...cardImpl.cardIds);\n\t\t\t}\n\t\t}\n\t}\n\treturn validDeathrattleEnchantmentsFromMapping.includes(cardId);\n};\n\n// const cleanEnchantmentsForEntity = (\n// \tenchantments: { cardId: string; originEntityId?: number; timing: number }[],\n// \tentityIds: readonly number[],\n// ): { cardId: string; originEntityId?: number; timing: number }[] => {\n// \treturn enchantments.filter(\n// \t\t(enchant) =>\n// \t\t\tentityIds.indexOf(enchant.originEntityId) !== -1 ||\n// \t\t\tvalidEnchantments.indexOf(enchant.cardId as CardIds) !== -1,\n// \t);\n// };\n"]}
1
+ {"version":3,"file":"simulate-bgs-battle.js","sourceRoot":"","sources":["../src/simulate-bgs-battle.ts"],"names":[],"mappings":";;;AACA,iEAA+D;AAE/D,2DAAwE;AACxE,mDAA+C;AAC/C,gEAA2D;AAC3D,+CAA2C;AAC3C,+CAA4C;AAC5C,yDAAqD;AAIrD,4DAAwD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AAG,EAAE,CAAC;AAC5C,MAAM,6BAA6B,GAAG,CAAC,MAAc,EAAW,EAAE;IACxE,IAAI,8BAA8B,CAAC,QAAQ,CAAC,MAAiB,CAAC,EAAE;QAC/D,OAAO,IAAI,CAAC;KACZ;IACD,IAAI,uCAAuC,CAAC,MAAM,KAAK,CAAC,EAAE;QACzD,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,6BAAY,CAAC,EAAE;YAEnD,IAAI,IAAA,+CAA8B,EAAC,QAAQ,CAAC,EAAE;gBAC7C,uCAAuC,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;aAClE;SACD;KACD;IACD,OAAO,uCAAuC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACjE,CAAC,CAAC;AAbW,QAAA,6BAA6B,iCAaxC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport { AllCardsService } from '@firestone-hs/reference-data';\nimport { BgsBattleInfo } from './bgs-battle-info';\nimport { hasDeathrattleSpawnEnchantment } from './cards/card.interface';\nimport { CardsData } from './cards/cards-data';\nimport { cardMappings } from './cards/impl/_card-mappings';\nimport { debugState } from './debug-state';\nimport { cloneInput3 } from './input-clone';\nimport { buildFinalInput } from './input-sanitation';\nimport { CardIds } from './services/card-ids';\nimport { SimulationResult } from './simulation-result';\nimport { FullGameState } from './simulation/internal-game-state';\nimport { SharedState } from './simulation/shared-state';\nimport { Simulator } from './simulation/simulator';\nimport { Spectator } from './simulation/spectator/spectator';\n\nlet globalCards = new AllCardsService();\n\nexport const assignCards = (cards: AllCardsService) => {\n\tglobalCards = cards;\n};\n\n// This example demonstrates a NodeJS 8.10 async handler[1], however of course you could use\n// the more traditional callback-style handler.\n// [1]: https://aws.amazon.com/blogs/compute/node-js-8-10-runtime-now-available-in-aws-lambda/\nexport default async (event): Promise<any> => {\n\tif (!event.body?.length) {\n\t\tconsole.warn('missing event body', event);\n\t\treturn;\n\t}\n\n\tconst battleInput: BgsBattleInfo = JSON.parse(event.body);\n\tconst cards = globalCards;\n\tawait cards.initializeCardsDb();\n\tconst cardsData = new CardsData(cards, false);\n\tcardsData.inititialize(\n\t\tbattleInput.gameState?.validTribes ?? battleInput.options?.validTribes,\n\t\tbattleInput.gameState?.anomalies ?? [],\n\t);\n\tconst battleIterator = simulateBattle(battleInput, cards, cardsData);\n\n\t// Iterate through all intermediate results to reach the final result\n\tlet result = battleIterator.next();\n\twhile (!result.done) {\n\t\tresult = battleIterator.next();\n\t}\n\n\tconst simulationResult = result.value;\n\t// console.debug('simulationResult', simulationResult);\n\n\tconst response = {\n\t\tstatusCode: 200,\n\t\tisBase64Encoded: false,\n\t\tbody: JSON.stringify(simulationResult),\n\t};\n\treturn response;\n};\n\nexport const simulateBattle = function* (\n\tbattleInput: BgsBattleInfo,\n\tcards: AllCardsService,\n\tcardsData: CardsData,\n): Generator<SimulationResult, SimulationResult, void> {\n\tif (!cards?.getCards()?.length) {\n\t\tconsole.error('[simulate-bgs-battle] reference cards are empty, cannot simulate battle', cards);\n\t\treturn null;\n\t}\n\t// !battleInput.options?.skipInfoLogs && console.time('full-sim');\n\tconst start = Date.now();\n\tconst maxAcceptableDuration = battleInput.options?.maxAcceptableDuration || 8000;\n\tconst hideMaxSimulationDurationWarning = battleInput.options?.hideMaxSimulationDurationWarning ?? false;\n\tconst numberOfSimulations = battleInput.options?.numberOfSimulations || 8000;\n\tconst intermediateSteps = battleInput.options?.intermediateResults ?? 200;\n\tconst damageConfidence = battleInput.options?.damageConfidence ?? 0.9;\n\tconst includeOutcomeSamples = battleInput.options?.includeOutcomeSamples ?? true;\n\tconst simulationResult: SimulationResult = {\n\t\twonLethal: 0,\n\t\twon: 0,\n\t\ttied: 0,\n\t\tlost: 0,\n\t\tlostLethal: 0,\n\t\tdamageWons: [],\n\t\tdamageWon: 0,\n\t\tdamageWonRange: null,\n\t\tdamageLosts: [],\n\t\tdamageLost: 0,\n\t\tdamageLostRange: null,\n\t\twonLethalPercent: undefined,\n\t\twonPercent: undefined,\n\t\ttiedPercent: undefined,\n\t\tlostPercent: undefined,\n\t\tlostLethalPercent: undefined,\n\t\taverageDamageWon: undefined,\n\t\taverageDamageLost: undefined,\n\t};\n\n\tconst spectator = new Spectator(includeOutcomeSamples);\n\tconst inputReady = buildFinalInput(battleInput, cards, cardsData);\n\n\t// Apply debug state from input when present (e.g. from bug report)\n\tif (battleInput.debugState) {\n\t\tdebugState.active = true;\n\t\tdebugState.forcedCurrentAttacker = battleInput.debugState.forcedCurrentAttacker;\n\t\tdebugState.forcedFaceOffBase = battleInput.debugState.forcedFaceOffBase.map((f) => ({\n\t\t\tattacker: { ...f.attacker },\n\t\t\tdefender: { ...f.defender },\n\t\t}));\n\t\tconst rawPicks = battleInput.debugState.forcedRandomPicks ?? [];\n\t\tdebugState.forcedRandomPicksBase = rawPicks.map((p) => ({\n\t\t\tsource: { ...p.source },\n\t\t\ttarget: { ...p.target },\n\t\t\t...(p.chosenCardId && { chosenCardId: p.chosenCardId }),\n\t\t}));\n\t}\n\n\ttry {\n\t\t!battleInput.options?.skipInfoLogs && console.time('simulation');\n\t\tconst outcomes = {};\n\t\tfor (let i = 0; i < numberOfSimulations; i++) {\n\t\t\tconst input: BgsBattleInfo = cloneInput3(inputReady);\n\t\t\tconst inputClone: BgsBattleInfo = cloneInput3(inputReady);\n\t\t\tconst gameState: FullGameState = {\n\t\t\t\tallCards: cards,\n\t\t\t\tcardsData: cardsData,\n\t\t\t\tspectator: spectator,\n\t\t\t\tsharedState: new SharedState(),\n\t\t\t\tcurrentTurn: input.gameState.currentTurn,\n\t\t\t\tvalidTribes: input.gameState.validTribes,\n\t\t\t\tanomalies: input.gameState.anomalies,\n\t\t\t\tgameState: {\n\t\t\t\t\tplayer: {\n\t\t\t\t\t\tplayer: input.playerBoard.player,\n\t\t\t\t\t\tboard: input.playerBoard.board,\n\t\t\t\t\t\tteammate: input.playerTeammateBoard,\n\t\t\t\t\t},\n\t\t\t\t\topponent: {\n\t\t\t\t\t\tplayer: input.opponentBoard.player,\n\t\t\t\t\t\tboard: input.opponentBoard.board,\n\t\t\t\t\t\tteammate: input.opponentTeammateBoard,\n\t\t\t\t\t},\n\t\t\t\t\tplayerInitial: {\n\t\t\t\t\t\tplayer: inputClone.playerBoard.player,\n\t\t\t\t\t\tboard: inputClone.playerBoard.board,\n\t\t\t\t\t\tteammate: inputClone.playerTeammateBoard,\n\t\t\t\t\t},\n\t\t\t\t\topponentInitial: {\n\t\t\t\t\t\tplayer: inputClone.opponentBoard.player,\n\t\t\t\t\t\tboard: inputClone.opponentBoard.board,\n\t\t\t\t\t\tteammate: inputClone.opponentTeammateBoard,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t\tconst simulator = new Simulator(gameState);\n\t\t\tconst battleResult = simulator.simulateSingleBattle(\n\t\t\t\tgameState.gameState.player,\n\t\t\t\tgameState.gameState.opponent,\n\t\t\t);\n\t\t\tif (!battleResult) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (battleResult.result === 'won') {\n\t\t\t\tsimulationResult.won++;\n\t\t\t\tsimulationResult.damageWon += battleResult.damageDealt;\n\t\t\t\tsimulationResult.damageWons.push(battleResult.damageDealt);\n\t\t\t\tif (battleResult.damageDealt >= battleInput.opponentBoard.player.hpLeft) {\n\t\t\t\t\tsimulationResult.wonLethal++;\n\t\t\t\t}\n\t\t\t} else if (battleResult.result === 'lost') {\n\t\t\t\tsimulationResult.lost++;\n\t\t\t\tsimulationResult.damageLost += battleResult.damageDealt;\n\t\t\t\tsimulationResult.damageLosts.push(battleResult.damageDealt);\n\t\t\t\toutcomes[battleResult.damageDealt] = (outcomes[battleResult.damageDealt] ?? 0) + 1;\n\t\t\t\tif (\n\t\t\t\t\tbattleInput.playerBoard.player.hpLeft &&\n\t\t\t\t\tbattleResult.damageDealt >= battleInput.playerBoard.player.hpLeft\n\t\t\t\t) {\n\t\t\t\t\tsimulationResult.lostLethal++;\n\t\t\t\t}\n\t\t\t} else if (battleResult.result === 'tied') {\n\t\t\t\tsimulationResult.tied++;\n\t\t\t}\n\t\t\tspectator.commitBattleResult(battleResult.result);\n\n\t\t\tif (Date.now() - start > maxAcceptableDuration && !hideMaxSimulationDurationWarning) {\n\t\t\t\t// Can happen in case of inifinite boards, or a bug. Don't hog the user's computer in that case\n\t\t\t\tconsole.warn('Stopping simulation after', i, 'iterations and ', Date.now() - start, 'ms');\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Yield intermediate result every 200 iterations\n\t\t\tif (!!intermediateSteps && i > 0 && i % intermediateSteps === 0) {\n\t\t\t\tupdateSimulationResult(simulationResult, inputReady, damageConfidence);\n\t\t\t\tyield simulationResult;\n\t\t\t}\n\t\t}\n\t\tupdateSimulationResult(simulationResult, inputReady, damageConfidence);\n\t\t!battleInput.options?.skipInfoLogs && console.timeEnd('simulation');\n\t\tspectator.prune();\n\t\tsimulationResult.outcomeSamples = spectator.buildOutcomeSamples(battleInput.gameState);\n\t\t// Avoid sending this verbose data\n\n\t\tsimulationResult.damageWons = [];\n\t\tsimulationResult.damageLosts = [];\n\t\t// !battleInput.options?.skipInfoLogs && console.timeEnd('full-sim');\n\t\treturn simulationResult;\n\t} finally {\n\t\tif (battleInput.debugState) {\n\t\t\tdebugState.active = false;\n\t\t}\n\t}\n};\n\nconst updateSimulationResult = (simulationResult: SimulationResult, input: BgsBattleInfo, damageConfidence: number) => {\n\tconst totalMatches = simulationResult.won + simulationResult.tied + simulationResult.lost;\n\tsimulationResult.wonPercent = checkRounding(\n\t\tMath.round((10 * (100 * simulationResult.won)) / totalMatches) / 10,\n\t\tsimulationResult.won,\n\t\ttotalMatches,\n\t);\n\tsimulationResult.wonLethalPercent = checkRounding(\n\t\tMath.round((10 * (100 * simulationResult.wonLethal)) / totalMatches) / 10,\n\t\tsimulationResult.wonLethal,\n\t\ttotalMatches,\n\t);\n\tsimulationResult.lostPercent = checkRounding(\n\t\tMath.round((10 * (100 * simulationResult.lost)) / totalMatches) / 10,\n\t\tsimulationResult.lost,\n\t\ttotalMatches,\n\t);\n\tsimulationResult.lostLethalPercent = checkRounding(\n\t\tMath.round((10 * (100 * simulationResult.lostLethal)) / totalMatches) / 10,\n\t\tsimulationResult.lostLethal,\n\t\ttotalMatches,\n\t);\n\tsimulationResult.tiedPercent = checkRounding(\n\t\tMath.max(0, 100 - simulationResult.lostPercent - simulationResult.wonPercent),\n\t\tsimulationResult.tied,\n\t\ttotalMatches,\n\t);\n\n\t// simulationResult.wonLethalPercent = Math.round((10 * (100 * simulationResult.wonLethal)) / totalMatches) / 10;\n\t// simulationResult.lostLethalPercent = Math.round((10 * (100 * simulationResult.lostLethal)) / totalMatches) / 10;\n\tconst totalDamageWon = simulationResult.damageWons.reduce((a, b) => a + b, 0);\n\tconst totalDamageLost = simulationResult.damageLosts.reduce((a, b) => a + b, 0);\n\tconst damageWonRange = calculateDamageRange(simulationResult.damageWons, damageConfidence);\n\tconst damageLostRange = calculateDamageRange(simulationResult.damageLosts, damageConfidence);\n\tsimulationResult.averageDamageWon = simulationResult.won ? totalDamageWon / simulationResult.won : 0;\n\tsimulationResult.averageDamageLost = simulationResult.lost ? totalDamageLost / simulationResult.lost : 0;\n\tsimulationResult.damageWonRange = simulationResult.won ? damageWonRange : null;\n\tsimulationResult.damageLostRange = simulationResult.lost ? damageLostRange : null;\n\n\tif (\n\t\tsimulationResult.averageDamageWon > 0 &&\n\t\tsimulationResult.averageDamageWon < input.playerBoard.player.tavernTier\n\t) {\n\t\tconsole.warn('average damage won issue');\n\t}\n\tif (\n\t\tsimulationResult.averageDamageLost > 0 &&\n\t\tsimulationResult.averageDamageLost < input.opponentBoard.player.tavernTier\n\t) {\n\t\tconsole.warn('average damage lost issue');\n\t}\n};\n\nconst calculateDamageRange = (damageArray: number[], damageConfidence: number): { min: number; max: number } => {\n\tif (damageArray.length === 0) {\n\t\treturn { min: 0, max: 0 };\n\t}\n\n\t// Sort the array\n\tconst sortedDamage = [...damageArray].sort((a, b) => a - b);\n\n\t// Calculate the 10th and 90th percentiles\n\tconst percentile = (arr: number[], p: number) => {\n\t\tconst index = Math.floor(p * arr.length);\n\t\treturn arr[index];\n\t};\n\n\tconst minDamage = percentile(sortedDamage, 1 - damageConfidence);\n\tconst maxDamage = percentile(sortedDamage, damageConfidence);\n\n\treturn { min: minDamage, max: maxDamage };\n};\n\nconst checkRounding = (roundedValue: number, initialValue: number, totalValue: number): number => {\n\tif (roundedValue === 0 && initialValue !== 0) {\n\t\treturn 0.01;\n\t}\n\tif (roundedValue === 100 && initialValue !== totalValue) {\n\t\treturn 99.9;\n\t}\n\treturn roundedValue;\n};\n\n// Used when triggering random deathrattles\nconst VALID_DEATHRATTLE_ENCHANTMENTS = [\n\tCardIds.ReplicatingMenace_ReplicatingMenaceEnchantment_BG_BOT_312e,\n\tCardIds.ReplicatingMenace_ReplicatingMenaceEnchantment_TB_BaconUps_032e,\n\tCardIds.LivingSpores_LivingSporesEnchantment,\n\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e,\n\tCardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge,\n\tCardIds.Sneed_SneedsReplicator,\n\tCardIds.SneedsReplicator_ReplicateEnchantment,\n\tCardIds.EarthRecollectionEnchantment, // Spirit Raptor\n\tCardIds.FireRecollectionEnchantment,\n\tCardIds.LightningRecollectionEnchantment,\n\tCardIds.WaterRecollectionEnchantment,\n\tCardIds.EarthInvocation_ElementEarthEnchantment, // Summon a 1/1\n\tCardIds.LightningInvocation, // Deal 1 damage to 5 enemy minions\n\t// CardIds.SurfNSurf_CrabRidingEnchantment_BG27_004e,\n\t// CardIds.SurfNSurf_CrabRidingEnchantment_BG27_004_Ge,\n\t// CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055e,\n\t// CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055_Ge,\n\tCardIds.BoonOfBeetles_BeetleSwarmEnchantment_BG28_603e,\n\tCardIds.RustyTrident_TridentsTreasureEnchantment_BG30_MagicItem_917e,\n\tCardIds.HoggyBank_GemInTheBankEnchantment_BG30_MagicItem_411e,\n\tCardIds.JarredFrostling_FrostyGlobeEnchantment_BG30_MagicItem_952e,\n\tCardIds.CaduceusReactor_CaduceusReactorEnchantment_BG31_HERO_801ptee,\n\tCardIds.AutoAssembler_AutoAssemblerEnchantment_BG32_172e,\n\tCardIds.AutoAssembler_AutoAssemblerEnchantment_BG32_172_Ge,\n\tCardIds.TamsinRoame_ImpendingSacrificeEnchantment_BG20_HERO_282e2,\n];\nconst validDeathrattleEnchantmentsFromMapping = [];\nexport const isValidDeathrattleEnchantment = (cardId: string): boolean => {\n\tif (VALID_DEATHRATTLE_ENCHANTMENTS.includes(cardId as CardIds)) {\n\t\treturn true;\n\t}\n\tif (validDeathrattleEnchantmentsFromMapping.length === 0) {\n\t\tfor (const cardImpl of Object.values(cardMappings)) {\n\t\t\t// Also includes non-enchantments, but since we only match this against the enchants list, it's fine\n\t\t\tif (hasDeathrattleSpawnEnchantment(cardImpl)) {\n\t\t\t\tvalidDeathrattleEnchantmentsFromMapping.push(...cardImpl.cardIds);\n\t\t\t}\n\t\t}\n\t}\n\treturn validDeathrattleEnchantmentsFromMapping.includes(cardId);\n};\n\n// const cleanEnchantmentsForEntity = (\n// \tenchantments: { cardId: string; originEntityId?: number; timing: number }[],\n// \tentityIds: readonly number[],\n// ): { cardId: string; originEntityId?: number; timing: number }[] => {\n// \treturn enchantments.filter(\n// \t\t(enchant) =>\n// \t\t\tentityIds.indexOf(enchant.originEntityId) !== -1 ||\n// \t\t\tvalidEnchantments.indexOf(enchant.cardId as CardIds) !== -1,\n// \t);\n// };\n"]}
@@ -96,12 +96,14 @@ const setImplicitDataHero = (hero, cardsData, isPlayer, entityIdContainer) => {
96
96
  avengeDefault: cardsData.avengeValue(reward),
97
97
  scriptDataNum1: cardsData.defaultScriptDataNum(reward),
98
98
  }));
99
- hero.trinkets = ((_e = hero.trinkets) !== null && _e !== void 0 ? _e : []).map((trinket) => ({
99
+ hero.trinkets = ((_e = hero.trinkets) !== null && _e !== void 0 ? _e : [])
100
+ .map((trinket) => ({
100
101
  ...trinket,
101
102
  avengeDefault: cardsData.avengeValue(trinket.cardId),
102
103
  avengeCurrent: cardsData.avengeValue(trinket.cardId),
103
104
  scriptDataNum1: trinket.scriptDataNum1 || cardsData.defaultScriptDataNum(trinket.cardId),
104
- }));
105
+ }))
106
+ .sort((a, b) => a.entityId - b.entityId);
105
107
  hero.entityId = hero.entityId || entityIdContainer.entityId--;
106
108
  hero.hand = (_f = hero.hand) !== null && _f !== void 0 ? _f : [];
107
109
  hero.enchantments = (_g = hero.enchantments) !== null && _g !== void 0 ? _g : [];
@@ -1 +1 @@
1
- {"version":3,"file":"auras.js","sourceRoot":"","sources":["../../src/simulation/auras.ts"],"names":[],"mappings":";;;AACA,iEAAqE;AAIrE,iDAAoD;AAEpD,oCAAgE;AAGzD,MAAM,eAAe,GAAG,CAC9B,KAAoB,EACpB,SAA0B,EAC1B,SAA4B,EAC5B,QAAyB,EAClB,EAAE;IACT,qBAAqB,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC7D,IAAA,+BAAuB,EAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC1C,IAAA,6BAAqB,EAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AACzC,CAAC,CAAC;AATW,QAAA,eAAe,mBAS1B;AAEK,MAAM,qBAAqB,GAAG,CAAC,KAAoB,EAAE,SAA0B,EAAQ,EAAE;;IAC/F,KAAK,MAAM,OAAO,IAAI,MAAA,SAAS,CAAC,QAAQ,mCAAI,EAAE,EAAE;KAoB/C;AACF,CAAC,CAAC;AAtBW,QAAA,qBAAqB,yBAsBhC;AAEK,MAAM,uBAAuB,GAAG,CAAC,KAAoB,EAAE,SAA0B,EAAQ,EAAE;IACjG,KAAK,MAAM,SAAS,IAAI,SAAS,CAAC,UAAU,EAAE;QAC7C,IAAI,SAAS,CAAC,MAAM,sBAA0B,EAA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IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE;QACxE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,uBAAa,EAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;QACjF,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,uBAAa,EAAC,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;KAC3F;AACF,CAAC,CAAC;AAlBW,QAAA,oBAAoB,wBAkB/B","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardsData } from '../cards/cards-data';\r\nimport { updateStealth } from '../keywords/stealth';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { addImpliedMechanics, hasCorrectTribe } from '../utils';\r\nimport { FullGameState } from './internal-game-state';\r\n\r\nexport const setMissingAuras = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tanomalies: readonly string[],\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\tsetMissingMinionsAura(board, boardHero, anomalies, allCards);\r\n\tsetMissingHeroPowerAura(board, boardHero);\r\n\tsetMissingTrinketAura(board, boardHero);\r\n};\r\n\r\nexport const setMissingTrinketAura = (board: BoardEntity[], boardHero: BgsPlayerEntity): void => {\r\n\tfor (const trinket of boardHero.trinkets ?? []) {\r\n\t\t// switch (trinket.cardId) {\r\n\t\t// \tcase CardIds.WindrunnerNecklace_BG30_MagicItem_997:\r\n\t\t// \tcase CardIds.WindrunnerNecklace_WindrunnerNecklaceToken_BG30_MagicItem_997t:\r\n\t\t// \t\tconst enchantment =\r\n\t\t// \t\t\ttrinket.cardId === CardIds.WindrunnerNecklace_BG30_MagicItem_997\r\n\t\t// \t\t\t\t? CardIds.WindrunnerNecklace_RunningLikeTheWindEnchantment_BG30_MagicItem_997e\r\n\t\t// \t\t\t\t: CardIds.WindrunnerNecklace_RunningLikeTheWindEnchantment_BG30_MagicItem_997e2;\r\n\t\t// \t\tconst buff = trinket.cardId === CardIds.WindrunnerNecklace_BG30_MagicItem_997 ? 8 : 20;\r\n\t\t// \t\tconst target = board[0];\r\n\t\t// \t\tif (!!target && !target.enchantments?.find((e) => e.cardId === enchantment)) {\r\n\t\t// \t\t\ttarget.attack += buff;\r\n\t\t// \t\t\ttarget.enchantments.push({\r\n\t\t// \t\t\t\tcardId: enchantment,\r\n\t\t// \t\t\t\toriginEntityId: trinket.entityId,\r\n\t\t// \t\t\t\ttiming: 0,\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\r\nexport const setMissingHeroPowerAura = (board: BoardEntity[], boardHero: BgsPlayerEntity): void => {\r\n\tfor (const heroPower of boardHero.heroPowers) {\r\n\t\tif (heroPower.cardId === CardIds.TheSmokingGun) {\r\n\t\t\tboard\r\n\t\t\t\t.filter(\r\n\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\t!e.enchantments.find(\r\n\t\t\t\t\t\t\t(ench) => ench.cardId === CardIds.TheSmokingGun_ArmedAndStillSmokingEnchantment,\r\n\t\t\t\t\t\t),\r\n\t\t\t\t)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += 4;\r\n\t\t\t\t});\r\n\t\t}\r\n\t\tif (heroPower.cardId === CardIds.VolatileVenom) {\r\n\t\t\tboard\r\n\t\t\t\t.filter(\r\n\t\t\t\t\t(e) => !e.enchantments.find((ench) => ench.cardId === CardIds.VolatileVenom_VolatileEnchantment),\r\n\t\t\t\t)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += 7;\r\n\t\t\t\t\te.health += 7;\r\n\t\t\t\t\te.enchantments.push({\r\n\t\t\t\t\t\tcardId: CardIds.VolatileVenom_VolatileEnchantment,\r\n\t\t\t\t\t\toriginEntityId: undefined,\r\n\t\t\t\t\t\ttiming: 0,\r\n\t\t\t\t\t});\r\n\t\t\t\t});\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst setMissingMinionsAura = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tanomalies: readonly string[],\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, boardHero, Race.PIRATE, anomalies, allCards)),\r\n\t\tCardIds.SouthseaCaptainLegacy_BG_NEW1_027,\r\n\t\tCardIds.SouthseaCaptain_YarrrVanillaEnchantment,\r\n\t\t1,\r\n\t\t1,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, boardHero, Race.PIRATE, anomalies, allCards)),\r\n\t\tCardIds.SouthseaCaptainLegacy_TB_BaconUps_136,\r\n\t\tCardIds.SouthseaCaptain_YarrrEnchantment,\r\n\t\t2,\r\n\t\t2,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, boardHero, Race.MURLOC, anomalies, allCards)),\r\n\t\tCardIds.MurlocWarleaderLegacy_BG_EX1_507,\r\n\t\tCardIds.MurlocWarleader_MrgglaarglLegacyEnchantment,\r\n\t\t2,\r\n\t\t0,\r\n\t);\r\n\t// setMissingAura(\r\n\t// \tboard.filter((e) => hasCorrectTribe(e, boardHero, Race.MURLOC, anomalies, allCards)),\r\n\t// \tCardIds.MurlocWarleaderLegacy_BG_EX1_507,\r\n\t// \tCardIds.MurlocWarleader_MrgglaarglEnchantment,\r\n\t// \t4,\r\n\t// \t0,\r\n\t// );\r\n\t// setMissingAura(\r\n\t// \tboard.filter((e) => hasCorrectTribe(e, boardHero, Race.DEMON, anomalies, allCards)),\r\n\t// \tCardIds.Kathranatir_BG21_039,\r\n\t// \tCardIds.Kathranatir_GraspOfKathranatirEnchantment_BG21_039e,\r\n\t// \t2,\r\n\t// \t0,\r\n\t// );\r\n\t// setMissingAura(\r\n\t// \tboard.filter((e) => hasCorrectTribe(e, boardHero, Race.DEMON, anomalies, allCards)),\r\n\t// \tCardIds.Kathranatir_BG21_039_G,\r\n\t// \tCardIds.Kathranatir_GraspOfKathranatirEnchantment_BG21_039_Ge,\r\n\t// \t4,\r\n\t// \t0,\r\n\t// );\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => e.divineShield),\r\n\t\tCardIds.CyborgDrake_BG25_043,\r\n\t\tCardIds.CyborgDrake_CyborgEnhancementEnchantment_BG25_043e,\r\n\t\t6,\r\n\t\t0,\r\n\t\tfalse,\r\n\t);\r\n\t// setMissingAura(\r\n\t// \tboard.filter((e) => e.divineShield),\r\n\t// \tCardIds.CyborgDrake_BG25_043_G,\r\n\t// \tCardIds.CyborgDrake_CyborgEnhancementEnchantment_BG25_043_Ge,\r\n\t// \t12,\r\n\t// \t0,\r\n\t// \tfalse,\r\n\t// );\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, boardHero, Race.UNDEAD, anomalies, allCards)),\r\n\t\tCardIds.SoreLoser_BG27_030,\r\n\t\tCardIds.SoreLoser_NoImWinningEnchantment_BG27_030e,\r\n\t\tboardHero.tavernTier,\r\n\t\t0,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, boardHero, Race.UNDEAD, anomalies, allCards)),\r\n\t\tCardIds.SoreLoser_BG27_030_G,\r\n\t\tCardIds.SoreLoser_NoImWinningEnchantment_BG27_030e,\r\n\t\t2 * boardHero.tavernTier,\r\n\t\t0,\r\n\t);\r\n};\r\n\r\nconst setMissingAura = (\r\n\tboard: BoardEntity[],\r\n\tminionCardId: string,\r\n\tenchantmentCardId: string,\r\n\tattack: number,\r\n\thealth: number,\r\n\tignoreSelf = true,\r\n\tallCards: AllCardsService = null,\r\n): void => {\r\n\tconst buffers = board.filter((e) => e.cardId === minionCardId);\r\n\tfor (const buffer of buffers) {\r\n\t\tboard\r\n\t\t\t.filter((e) => !e.enchantments.find((ench) => ench.cardId === enchantmentCardId))\r\n\t\t\t.filter((e) => (ignoreSelf ? e.entityId !== buffer.entityId : true))\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\te.attack += attack;\r\n\t\t\t\te.health += health;\r\n\t\t\t});\r\n\t}\r\n};\r\n\r\nexport const setImplicitDataHero = (\r\n\thero: BgsPlayerEntity,\r\n\tcardsData: CardsData,\r\n\tisPlayer: boolean,\r\n\tentityIdContainer: { entityId: number },\r\n): void => {\r\n\tfor (const heroPower of hero.heroPowers) {\r\n\t\tconst avengeValue = cardsData.avengeValue(heroPower.cardId);\r\n\t\tif (avengeValue > 0) {\r\n\t\t\theroPower.avengeCurrent = avengeValue - (heroPower.scoreValue2 ?? 0);\r\n\t\t\theroPower.avengeDefault = avengeValue;\r\n\t\t}\r\n\t\tif ((heroPower.info as BoardEntity)?.health) {\r\n\t\t\taddImpliedMechanics(heroPower.info as BoardEntity, cardsData);\r\n\t\t}\r\n\t}\r\n\t// Backward compatibility\r\n\tif (!!hero.questRewards?.length && !Array.isArray(hero.questRewards)) {\r\n\t\thero.questRewards = [hero.questRewards as any];\r\n\t}\r\n\r\n\t// Because Denathrius can send a quest reward as its hero power (I think)\r\n\t// For now deactivating this, until I have a scenario where this matters. It feels like\r\n\t// this should be a display issue only, as quest rewards are also handled in the code\r\n\tconst heroPowerAsReward = null; // hero.cardId === CardIds.SireDenathrius_BG24_HERO_100 ? hero.heroPowers[0]?.cardId : null;\r\n\thero.questRewards = [...(hero.questRewards ?? []), heroPowerAsReward].filter((e) => !!e);\r\n\thero.questRewardEntities = hero.questRewardEntities\r\n\t\t? hero.questRewardEntities.map((reward: any) => ({\r\n\t\t\t\tcardId: reward.CardId,\r\n\t\t\t\tscriptDataNum1: reward.ScriptDataNum1 ?? 0,\r\n\t\t\t\tentityId: entityIdContainer.entityId--,\r\n\t\t\t\tavengeDefault: cardsData.avengeValue(reward.CardId),\r\n\t\t\t\tavengeCurrent: cardsData.avengeValue(reward.CardId),\r\n\t\t }))\r\n\t\t: hero.questRewards.map((reward) => ({\r\n\t\t\t\tcardId: reward,\r\n\t\t\t\tentityId: entityIdContainer.entityId--,\r\n\t\t\t\tavengeCurrent: cardsData.avengeValue(reward),\r\n\t\t\t\tavengeDefault: cardsData.avengeValue(reward),\r\n\t\t\t\tscriptDataNum1: cardsData.defaultScriptDataNum(reward),\r\n\t\t }));\r\n\thero.trinkets = (hero.trinkets ?? []).map((trinket) => ({\r\n\t\t...trinket,\r\n\t\tavengeDefault: cardsData.avengeValue(trinket.cardId),\r\n\t\tavengeCurrent: cardsData.avengeValue(trinket.cardId),\r\n\t\t// Use scriptDataNum1 to keep the info from the input\r\n\t\tscriptDataNum1: trinket.scriptDataNum1 || cardsData.defaultScriptDataNum(trinket.cardId),\r\n\t}));\r\n\t// 0 is not a valid entityId\r\n\thero.entityId = hero.entityId || entityIdContainer.entityId--;\r\n\thero.hand = hero.hand ?? [];\r\n\thero.enchantments = hero.enchantments ?? [];\r\n\tif (!hero.globalInfo) {\r\n\t\thero.globalInfo = {};\r\n\t}\r\n\r\n\thero.globalInfo.EternalKnightsDeadThisGame = hero.globalInfo.EternalKnightsDeadThisGame ?? 0;\r\n\thero.globalInfo.SanlaynScribesDeadThisGame = hero.globalInfo.SanlaynScribesDeadThisGame ?? 0;\r\n\thero.globalInfo.BeastsSummonedThisGame = hero.globalInfo.BeastsSummonedThisGame ?? 0;\r\n\thero.globalInfo.BeastsSummonedThisCombat = hero.globalInfo.BeastsSummonedThisCombat ?? 0;\r\n\thero.globalInfo.MagnetizedThisGame = hero.globalInfo.MagnetizedThisGame ?? 0;\r\n\thero.globalInfo.PiratesSummonedThisGame = hero.globalInfo.PiratesSummonedThisGame ?? 0;\r\n\thero.globalInfo.BattlecriesTriggeredThisGame = hero.globalInfo.BattlecriesTriggeredThisGame ?? 0;\r\n\thero.globalInfo.DeathrattlesTriggeredThisGame = hero.globalInfo.DeathrattlesTriggeredThisGame ?? 0;\r\n\thero.globalInfo.BeetleAttackBuff = hero.globalInfo.BeetleAttackBuff ?? 0;\r\n\thero.globalInfo.BeetleHealthBuff = hero.globalInfo.BeetleHealthBuff ?? 0;\r\n\thero.globalInfo.ElementalAttackBuff = hero.globalInfo.ElementalAttackBuff ?? 0;\r\n\thero.globalInfo.ElementalHealthBuff = hero.globalInfo.ElementalHealthBuff ?? 0;\r\n\thero.globalInfo.PirateAttackBuff = hero.globalInfo.PirateAttackBuff ?? 0;\r\n\thero.globalInfo.PirateHealthBuff = hero.globalInfo.PirateHealthBuff ?? 0;\r\n\thero.globalInfo.TavernSpellAttackBuff = hero.globalInfo.TavernSpellAttackBuff ?? 0;\r\n\thero.globalInfo.TavernSpellHealthBuff = hero.globalInfo.TavernSpellHealthBuff ?? 0;\r\n\thero.globalInfo.MutatedLasherAttackBuff = hero.globalInfo.MutatedLasherAttackBuff ?? 0;\r\n\thero.globalInfo.MutatedLasherHealthBuff = hero.globalInfo.MutatedLasherHealthBuff ?? 0;\r\n\thero.globalInfo.TavernSpellsCastThisGame = hero.globalInfo.TavernSpellsCastThisGame ?? 0;\r\n\thero.globalInfo.TavernSpellsCastThisTurn = hero.globalInfo.TavernSpellsCastThisTurn ?? 0;\r\n\thero.globalInfo.CardsPlayedThisTurn = hero.globalInfo.CardsPlayedThisTurn ?? 0;\r\n\thero.globalInfo.MrrgltonsPlayedThisGame = hero.globalInfo.MrrgltonsPlayedThisGame ?? 0;\r\n\thero.globalInfo.AdditionalAttack = hero.globalInfo.AdditionalAttack ?? 0;\r\n\thero.globalInfo.SpellsCastThisGame = hero.globalInfo.SpellsCastThisGame ?? 0;\r\n\thero.globalInfo.UndeadAttackBonus = hero.globalInfo.UndeadAttackBonus ?? 0;\r\n\thero.globalInfo.UndeadHealthBonus = hero.globalInfo.UndeadHealthBonus ?? 0;\r\n\thero.globalInfo.HauntedCarapaceAttackBonus = hero.globalInfo.HauntedCarapaceAttackBonus ?? 0;\r\n\thero.globalInfo.HauntedCarapaceHealthBonus = hero.globalInfo.HauntedCarapaceHealthBonus ?? 0;\r\n\thero.globalInfo.FrostlingBonus = hero.globalInfo.FrostlingBonus ?? 0;\r\n\thero.globalInfo.BloodGemAttackBonus =\r\n\t\t(hero.globalInfo.BloodGemAttackBonus ?? 0) +\r\n\t\t// Not sure why, but this isn't reflected in the player enchant\r\n\t\t(hero.questRewardEntities?.filter((e) => e.cardId === CardIds.EndlessBloodMoon).length ?? 0);\r\n\thero.globalInfo.BloodGemHealthBonus =\r\n\t\t(hero.globalInfo.BloodGemHealthBonus ?? 0) +\r\n\t\t(hero.questRewardEntities?.filter((e) => e.cardId === CardIds.EndlessBloodMoon).length ?? 0);\r\n\thero.globalInfo.GoldrinnBuffAtk = hero.globalInfo.GoldrinnBuffAtk ?? 0;\r\n\thero.globalInfo.GoldrinnBuffHealth = hero.globalInfo.GoldrinnBuffHealth ?? 0;\r\n\thero.globalInfo.WhelpAttackBuff = hero.globalInfo.WhelpAttackBuff ?? 0;\r\n\thero.globalInfo.WhelpHealthBuff = hero.globalInfo.WhelpHealthBuff ?? 0;\r\n\thero.globalInfo.GoldSpentThisGame = hero.globalInfo.GoldSpentThisGame ?? 0;\r\n\thero.globalInfo.VolumizerAttackBuff = hero.globalInfo.VolumizerAttackBuff ?? 0;\r\n\thero.globalInfo.VolumizerHealthBuff = hero.globalInfo.VolumizerHealthBuff ?? 0;\r\n\thero.globalInfo.DeepBluesPlayed = hero.globalInfo.DeepBluesPlayed ?? 0;\r\n\thero.globalInfo.DeathrattlesTriggeredThisGame = hero.globalInfo.DeathrattlesTriggeredThisGame ?? 0;\r\n\thero.globalInfo.BackToBackCastThisGame = hero.globalInfo.BackToBackCastThisGame ?? 0;\r\n\thero.globalInfo.TavernSpellsCastThisTurn = hero.globalInfo.TavernSpellsCastThisTurn ?? 0;\r\n\thero.globalInfo.CardsPlayedThisTurn = hero.globalInfo.CardsPlayedThisTurn ?? 0;\r\n\thero.globalInfo.MrrgltonsPlayedThisGame = hero.globalInfo.MrrgltonsPlayedThisGame ?? 0;\r\n};\r\n\r\nexport const clearStealthIfNeeded = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// https://twitter.com/DCalkosz/status/1562194944688660481?s=20&t=100I8IVZmBKgYQWkdK8nIA\r\n\tif (board.every((entity) => entity.stealth && !entity.attack)) {\r\n\t\tboard.forEach((e) => updateStealth(e, false, board, hero, otherHero, gameState));\r\n\t}\r\n\tif (otherBoard.every((entity) => entity.stealth && !entity.attack)) {\r\n\t\totherBoard.forEach((e) => updateStealth(e, false, otherBoard, otherHero, hero, gameState));\r\n\t}\r\n\tif (board.every((e) => e.stealth) && otherBoard.every((e) => e.stealth)) {\r\n\t\tboard.forEach((e) => updateStealth(e, false, board, hero, otherHero, gameState));\r\n\t\totherBoard.forEach((e) => updateStealth(e, false, otherBoard, otherHero, hero, gameState));\r\n\t}\r\n};\r\n"]}
1
+ {"version":3,"file":"auras.js","sourceRoot":"","sources":["../../src/simulation/auras.ts"],"names":[],"mappings":";;;AACA,iEAAqE;AAIrE,iDAAoD;AAEpD,oCAAgE;AAGzD,MAAM,eAAe,GAAG,CAC9B,KAAoB,EACpB,SAA0B,EAC1B,SAA4B,EAC5B,QAAyB,EAClB,EAAE;IACT,qBAAqB,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC7D,IAAA,+BAAuB,EAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC1C,IAAA,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AAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;QAC9D,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,uBAAa,EAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;KACjF;IACD,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;QACnE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,uBAAa,EAAC,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;KAC3F;IACD,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE;QACxE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,uBAAa,EAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;QACjF,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,uBAAa,EAAC,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;KAC3F;AACF,CAAC,CAAC;AAlBW,QAAA,oBAAoB,wBAkB/B","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardsData } from '../cards/cards-data';\r\nimport { updateStealth } from '../keywords/stealth';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { addImpliedMechanics, hasCorrectTribe } from '../utils';\r\nimport { FullGameState } from './internal-game-state';\r\n\r\nexport const setMissingAuras = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tanomalies: readonly string[],\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\tsetMissingMinionsAura(board, boardHero, anomalies, allCards);\r\n\tsetMissingHeroPowerAura(board, boardHero);\r\n\tsetMissingTrinketAura(board, boardHero);\r\n};\r\n\r\nexport const setMissingTrinketAura = (board: BoardEntity[], boardHero: BgsPlayerEntity): void => {\r\n\tfor (const trinket of boardHero.trinkets ?? []) {\r\n\t\t// switch (trinket.cardId) {\r\n\t\t// \tcase CardIds.WindrunnerNecklace_BG30_MagicItem_997:\r\n\t\t// \tcase CardIds.WindrunnerNecklace_WindrunnerNecklaceToken_BG30_MagicItem_997t:\r\n\t\t// \t\tconst enchantment =\r\n\t\t// \t\t\ttrinket.cardId === CardIds.WindrunnerNecklace_BG30_MagicItem_997\r\n\t\t// \t\t\t\t? CardIds.WindrunnerNecklace_RunningLikeTheWindEnchantment_BG30_MagicItem_997e\r\n\t\t// \t\t\t\t: CardIds.WindrunnerNecklace_RunningLikeTheWindEnchantment_BG30_MagicItem_997e2;\r\n\t\t// \t\tconst buff = trinket.cardId === CardIds.WindrunnerNecklace_BG30_MagicItem_997 ? 8 : 20;\r\n\t\t// \t\tconst target = board[0];\r\n\t\t// \t\tif (!!target && !target.enchantments?.find((e) => e.cardId === enchantment)) {\r\n\t\t// \t\t\ttarget.attack += buff;\r\n\t\t// \t\t\ttarget.enchantments.push({\r\n\t\t// \t\t\t\tcardId: enchantment,\r\n\t\t// \t\t\t\toriginEntityId: trinket.entityId,\r\n\t\t// \t\t\t\ttiming: 0,\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\r\nexport const setMissingHeroPowerAura = (board: BoardEntity[], boardHero: BgsPlayerEntity): void => {\r\n\tfor (const heroPower of boardHero.heroPowers) {\r\n\t\tif (heroPower.cardId === CardIds.TheSmokingGun) {\r\n\t\t\tboard\r\n\t\t\t\t.filter(\r\n\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\t!e.enchantments.find(\r\n\t\t\t\t\t\t\t(ench) => ench.cardId === CardIds.TheSmokingGun_ArmedAndStillSmokingEnchantment,\r\n\t\t\t\t\t\t),\r\n\t\t\t\t)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += 4;\r\n\t\t\t\t});\r\n\t\t}\r\n\t\tif (heroPower.cardId === CardIds.VolatileVenom) {\r\n\t\t\tboard\r\n\t\t\t\t.filter(\r\n\t\t\t\t\t(e) => !e.enchantments.find((ench) => ench.cardId === CardIds.VolatileVenom_VolatileEnchantment),\r\n\t\t\t\t)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += 7;\r\n\t\t\t\t\te.health += 7;\r\n\t\t\t\t\te.enchantments.push({\r\n\t\t\t\t\t\tcardId: CardIds.VolatileVenom_VolatileEnchantment,\r\n\t\t\t\t\t\toriginEntityId: undefined,\r\n\t\t\t\t\t\ttiming: 0,\r\n\t\t\t\t\t});\r\n\t\t\t\t});\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst setMissingMinionsAura = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tanomalies: readonly string[],\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, boardHero, Race.PIRATE, anomalies, allCards)),\r\n\t\tCardIds.SouthseaCaptainLegacy_BG_NEW1_027,\r\n\t\tCardIds.SouthseaCaptain_YarrrVanillaEnchantment,\r\n\t\t1,\r\n\t\t1,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, boardHero, Race.PIRATE, anomalies, allCards)),\r\n\t\tCardIds.SouthseaCaptainLegacy_TB_BaconUps_136,\r\n\t\tCardIds.SouthseaCaptain_YarrrEnchantment,\r\n\t\t2,\r\n\t\t2,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, boardHero, Race.MURLOC, anomalies, allCards)),\r\n\t\tCardIds.MurlocWarleaderLegacy_BG_EX1_507,\r\n\t\tCardIds.MurlocWarleader_MrgglaarglLegacyEnchantment,\r\n\t\t2,\r\n\t\t0,\r\n\t);\r\n\t// setMissingAura(\r\n\t// \tboard.filter((e) => hasCorrectTribe(e, boardHero, Race.MURLOC, anomalies, allCards)),\r\n\t// \tCardIds.MurlocWarleaderLegacy_BG_EX1_507,\r\n\t// \tCardIds.MurlocWarleader_MrgglaarglEnchantment,\r\n\t// \t4,\r\n\t// \t0,\r\n\t// );\r\n\t// setMissingAura(\r\n\t// \tboard.filter((e) => hasCorrectTribe(e, boardHero, Race.DEMON, anomalies, allCards)),\r\n\t// \tCardIds.Kathranatir_BG21_039,\r\n\t// \tCardIds.Kathranatir_GraspOfKathranatirEnchantment_BG21_039e,\r\n\t// \t2,\r\n\t// \t0,\r\n\t// );\r\n\t// setMissingAura(\r\n\t// \tboard.filter((e) => hasCorrectTribe(e, boardHero, Race.DEMON, anomalies, allCards)),\r\n\t// \tCardIds.Kathranatir_BG21_039_G,\r\n\t// \tCardIds.Kathranatir_GraspOfKathranatirEnchantment_BG21_039_Ge,\r\n\t// \t4,\r\n\t// \t0,\r\n\t// );\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => e.divineShield),\r\n\t\tCardIds.CyborgDrake_BG25_043,\r\n\t\tCardIds.CyborgDrake_CyborgEnhancementEnchantment_BG25_043e,\r\n\t\t6,\r\n\t\t0,\r\n\t\tfalse,\r\n\t);\r\n\t// setMissingAura(\r\n\t// \tboard.filter((e) => e.divineShield),\r\n\t// \tCardIds.CyborgDrake_BG25_043_G,\r\n\t// \tCardIds.CyborgDrake_CyborgEnhancementEnchantment_BG25_043_Ge,\r\n\t// \t12,\r\n\t// \t0,\r\n\t// \tfalse,\r\n\t// );\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, boardHero, Race.UNDEAD, anomalies, allCards)),\r\n\t\tCardIds.SoreLoser_BG27_030,\r\n\t\tCardIds.SoreLoser_NoImWinningEnchantment_BG27_030e,\r\n\t\tboardHero.tavernTier,\r\n\t\t0,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, boardHero, Race.UNDEAD, anomalies, allCards)),\r\n\t\tCardIds.SoreLoser_BG27_030_G,\r\n\t\tCardIds.SoreLoser_NoImWinningEnchantment_BG27_030e,\r\n\t\t2 * boardHero.tavernTier,\r\n\t\t0,\r\n\t);\r\n};\r\n\r\nconst setMissingAura = (\r\n\tboard: BoardEntity[],\r\n\tminionCardId: string,\r\n\tenchantmentCardId: string,\r\n\tattack: number,\r\n\thealth: number,\r\n\tignoreSelf = true,\r\n\tallCards: AllCardsService = null,\r\n): void => {\r\n\tconst buffers = board.filter((e) => e.cardId === minionCardId);\r\n\tfor (const buffer of buffers) {\r\n\t\tboard\r\n\t\t\t.filter((e) => !e.enchantments.find((ench) => ench.cardId === enchantmentCardId))\r\n\t\t\t.filter((e) => (ignoreSelf ? e.entityId !== buffer.entityId : true))\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\te.attack += attack;\r\n\t\t\t\te.health += health;\r\n\t\t\t});\r\n\t}\r\n};\r\n\r\nexport const setImplicitDataHero = (\r\n\thero: BgsPlayerEntity,\r\n\tcardsData: CardsData,\r\n\tisPlayer: boolean,\r\n\tentityIdContainer: { entityId: number },\r\n): void => {\r\n\tfor (const heroPower of hero.heroPowers) {\r\n\t\tconst avengeValue = cardsData.avengeValue(heroPower.cardId);\r\n\t\tif (avengeValue > 0) {\r\n\t\t\theroPower.avengeCurrent = avengeValue - (heroPower.scoreValue2 ?? 0);\r\n\t\t\theroPower.avengeDefault = avengeValue;\r\n\t\t}\r\n\t\tif ((heroPower.info as BoardEntity)?.health) {\r\n\t\t\taddImpliedMechanics(heroPower.info as BoardEntity, cardsData);\r\n\t\t}\r\n\t}\r\n\t// Backward compatibility\r\n\tif (!!hero.questRewards?.length && !Array.isArray(hero.questRewards)) {\r\n\t\thero.questRewards = [hero.questRewards as any];\r\n\t}\r\n\r\n\t// Because Denathrius can send a quest reward as its hero power (I think)\r\n\t// For now deactivating this, until I have a scenario where this matters. It feels like\r\n\t// this should be a display issue only, as quest rewards are also handled in the code\r\n\tconst heroPowerAsReward = null; // hero.cardId === CardIds.SireDenathrius_BG24_HERO_100 ? hero.heroPowers[0]?.cardId : null;\r\n\thero.questRewards = [...(hero.questRewards ?? []), heroPowerAsReward].filter((e) => !!e);\r\n\thero.questRewardEntities = hero.questRewardEntities\r\n\t\t? hero.questRewardEntities.map((reward: any) => ({\r\n\t\t\t\tcardId: reward.CardId,\r\n\t\t\t\tscriptDataNum1: reward.ScriptDataNum1 ?? 0,\r\n\t\t\t\tentityId: entityIdContainer.entityId--,\r\n\t\t\t\tavengeDefault: cardsData.avengeValue(reward.CardId),\r\n\t\t\t\tavengeCurrent: cardsData.avengeValue(reward.CardId),\r\n\t\t }))\r\n\t\t: hero.questRewards.map((reward) => ({\r\n\t\t\t\tcardId: reward,\r\n\t\t\t\tentityId: entityIdContainer.entityId--,\r\n\t\t\t\tavengeCurrent: cardsData.avengeValue(reward),\r\n\t\t\t\tavengeDefault: cardsData.avengeValue(reward),\r\n\t\t\t\tscriptDataNum1: cardsData.defaultScriptDataNum(reward),\r\n\t\t }));\r\n\thero.trinkets = (hero.trinkets ?? [])\r\n\t\t.map((trinket) => ({\r\n\t\t\t...trinket,\r\n\t\t\tavengeDefault: cardsData.avengeValue(trinket.cardId),\r\n\t\t\tavengeCurrent: cardsData.avengeValue(trinket.cardId),\r\n\t\t\t// Use scriptDataNum1 to keep the info from the input\r\n\t\t\tscriptDataNum1: trinket.scriptDataNum1 || cardsData.defaultScriptDataNum(trinket.cardId),\r\n\t\t}))\r\n\t\t.sort((a, b) => a.entityId - b.entityId);\r\n\t// 0 is not a valid entityId\r\n\thero.entityId = hero.entityId || entityIdContainer.entityId--;\r\n\thero.hand = hero.hand ?? [];\r\n\thero.enchantments = hero.enchantments ?? [];\r\n\tif (!hero.globalInfo) {\r\n\t\thero.globalInfo = {};\r\n\t}\r\n\r\n\thero.globalInfo.EternalKnightsDeadThisGame = hero.globalInfo.EternalKnightsDeadThisGame ?? 0;\r\n\thero.globalInfo.SanlaynScribesDeadThisGame = hero.globalInfo.SanlaynScribesDeadThisGame ?? 0;\r\n\thero.globalInfo.BeastsSummonedThisGame = hero.globalInfo.BeastsSummonedThisGame ?? 0;\r\n\thero.globalInfo.BeastsSummonedThisCombat = hero.globalInfo.BeastsSummonedThisCombat ?? 0;\r\n\thero.globalInfo.MagnetizedThisGame = hero.globalInfo.MagnetizedThisGame ?? 0;\r\n\thero.globalInfo.PiratesSummonedThisGame = hero.globalInfo.PiratesSummonedThisGame ?? 0;\r\n\thero.globalInfo.BattlecriesTriggeredThisGame = hero.globalInfo.BattlecriesTriggeredThisGame ?? 0;\r\n\thero.globalInfo.DeathrattlesTriggeredThisGame = hero.globalInfo.DeathrattlesTriggeredThisGame ?? 0;\r\n\thero.globalInfo.BeetleAttackBuff = hero.globalInfo.BeetleAttackBuff ?? 0;\r\n\thero.globalInfo.BeetleHealthBuff = hero.globalInfo.BeetleHealthBuff ?? 0;\r\n\thero.globalInfo.ElementalAttackBuff = hero.globalInfo.ElementalAttackBuff ?? 0;\r\n\thero.globalInfo.ElementalHealthBuff = hero.globalInfo.ElementalHealthBuff ?? 0;\r\n\thero.globalInfo.PirateAttackBuff = hero.globalInfo.PirateAttackBuff ?? 0;\r\n\thero.globalInfo.PirateHealthBuff = hero.globalInfo.PirateHealthBuff ?? 0;\r\n\thero.globalInfo.TavernSpellAttackBuff = hero.globalInfo.TavernSpellAttackBuff ?? 0;\r\n\thero.globalInfo.TavernSpellHealthBuff = hero.globalInfo.TavernSpellHealthBuff ?? 0;\r\n\thero.globalInfo.MutatedLasherAttackBuff = hero.globalInfo.MutatedLasherAttackBuff ?? 0;\r\n\thero.globalInfo.MutatedLasherHealthBuff = hero.globalInfo.MutatedLasherHealthBuff ?? 0;\r\n\thero.globalInfo.TavernSpellsCastThisGame = hero.globalInfo.TavernSpellsCastThisGame ?? 0;\r\n\thero.globalInfo.TavernSpellsCastThisTurn = hero.globalInfo.TavernSpellsCastThisTurn ?? 0;\r\n\thero.globalInfo.CardsPlayedThisTurn = hero.globalInfo.CardsPlayedThisTurn ?? 0;\r\n\thero.globalInfo.MrrgltonsPlayedThisGame = hero.globalInfo.MrrgltonsPlayedThisGame ?? 0;\r\n\thero.globalInfo.AdditionalAttack = hero.globalInfo.AdditionalAttack ?? 0;\r\n\thero.globalInfo.SpellsCastThisGame = hero.globalInfo.SpellsCastThisGame ?? 0;\r\n\thero.globalInfo.UndeadAttackBonus = hero.globalInfo.UndeadAttackBonus ?? 0;\r\n\thero.globalInfo.UndeadHealthBonus = hero.globalInfo.UndeadHealthBonus ?? 0;\r\n\thero.globalInfo.HauntedCarapaceAttackBonus = hero.globalInfo.HauntedCarapaceAttackBonus ?? 0;\r\n\thero.globalInfo.HauntedCarapaceHealthBonus = hero.globalInfo.HauntedCarapaceHealthBonus ?? 0;\r\n\thero.globalInfo.FrostlingBonus = hero.globalInfo.FrostlingBonus ?? 0;\r\n\thero.globalInfo.BloodGemAttackBonus =\r\n\t\t(hero.globalInfo.BloodGemAttackBonus ?? 0) +\r\n\t\t// Not sure why, but this isn't reflected in the player enchant\r\n\t\t(hero.questRewardEntities?.filter((e) => e.cardId === CardIds.EndlessBloodMoon).length ?? 0);\r\n\thero.globalInfo.BloodGemHealthBonus =\r\n\t\t(hero.globalInfo.BloodGemHealthBonus ?? 0) +\r\n\t\t(hero.questRewardEntities?.filter((e) => e.cardId === CardIds.EndlessBloodMoon).length ?? 0);\r\n\thero.globalInfo.GoldrinnBuffAtk = hero.globalInfo.GoldrinnBuffAtk ?? 0;\r\n\thero.globalInfo.GoldrinnBuffHealth = hero.globalInfo.GoldrinnBuffHealth ?? 0;\r\n\thero.globalInfo.WhelpAttackBuff = hero.globalInfo.WhelpAttackBuff ?? 0;\r\n\thero.globalInfo.WhelpHealthBuff = hero.globalInfo.WhelpHealthBuff ?? 0;\r\n\thero.globalInfo.GoldSpentThisGame = hero.globalInfo.GoldSpentThisGame ?? 0;\r\n\thero.globalInfo.VolumizerAttackBuff = hero.globalInfo.VolumizerAttackBuff ?? 0;\r\n\thero.globalInfo.VolumizerHealthBuff = hero.globalInfo.VolumizerHealthBuff ?? 0;\r\n\thero.globalInfo.DeepBluesPlayed = hero.globalInfo.DeepBluesPlayed ?? 0;\r\n\thero.globalInfo.DeathrattlesTriggeredThisGame = hero.globalInfo.DeathrattlesTriggeredThisGame ?? 0;\r\n\thero.globalInfo.BackToBackCastThisGame = hero.globalInfo.BackToBackCastThisGame ?? 0;\r\n\thero.globalInfo.TavernSpellsCastThisTurn = hero.globalInfo.TavernSpellsCastThisTurn ?? 0;\r\n\thero.globalInfo.CardsPlayedThisTurn = hero.globalInfo.CardsPlayedThisTurn ?? 0;\r\n\thero.globalInfo.MrrgltonsPlayedThisGame = hero.globalInfo.MrrgltonsPlayedThisGame ?? 0;\r\n};\r\n\r\nexport const clearStealthIfNeeded = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// https://twitter.com/DCalkosz/status/1562194944688660481?s=20&t=100I8IVZmBKgYQWkdK8nIA\r\n\tif (board.every((entity) => entity.stealth && !entity.attack)) {\r\n\t\tboard.forEach((e) => updateStealth(e, false, board, hero, otherHero, gameState));\r\n\t}\r\n\tif (otherBoard.every((entity) => entity.stealth && !entity.attack)) {\r\n\t\totherBoard.forEach((e) => updateStealth(e, false, otherBoard, otherHero, hero, gameState));\r\n\t}\r\n\tif (board.every((e) => e.stealth) && otherBoard.every((e) => e.stealth)) {\r\n\t\tboard.forEach((e) => updateStealth(e, false, board, hero, otherHero, gameState));\r\n\t\totherBoard.forEach((e) => updateStealth(e, false, otherBoard, otherHero, hero, gameState));\r\n\t}\r\n};\r\n"]}
@@ -89,6 +89,10 @@ const handleAvenge = (boardWithDeadEntity, boardWithDeadEntityHero, deadEntity,
89
89
  gameState,
90
90
  });
91
91
  if (Array.isArray(newSpawns) && (newSpawns === null || newSpawns === void 0 ? void 0 : newSpawns.length)) {
92
+ const avengeMinionIndexFromRight = boardWithDeadEntity.length - (boardWithDeadEntity.indexOf(avenger) + 1);
93
+ newSpawns.forEach((e) => {
94
+ e.spawnIndexFromRight = avengeMinionIndexFromRight;
95
+ });
92
96
  candidatesEntitiesSpawnedFromAvenge.push(...newSpawns);
93
97
  }
94
98
  }
@@ -1 +1 @@
1
- {"version":3,"file":"avenge.js","sourceRoot":"","sources":["../../src/simulation/avenge.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAG7D,4DAAoD;AACpD,iEAA4D;AAC5D,6DAAoE;AACpE,+CAAkD;AAClD,6CAAgD;AAEhD,6CAA+C;AAC/C,gEAAuE;AACvE,oCAMkB;AAClB,qCAA8C;AAC9C,mDAAiD;AACjD,6DAAqD;AAErD,qCAA+C;AAC/C,mCAAsC;AAE/B,MAAM,kBAAkB,GAAG,CACjC,UAAuB,EACvB,wBAAgC,EAChC,mBAAkC,EAClC,uBAAwC,EACxC,UAAyB,EACzB,cAA+B,EAC/B,SAAwB,EACxB,8BAA6C,EAC7B,EAAE;IAClB,MAAM,mCAAmC,GAAkB,EAAE,CAAC;IAE9D,MAAM,QAAQ,GAAG,mBAAmB;SAClC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,IAAI,CA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AAO,CAAC,aAAa,CAAC;AAChD,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CACxB,UAAuB,EACvB,SAAuB,EACvB,mBAAkC,EAClC,uBAAwC,EACxC,UAAyB,EACzB,cAA+B,EAC/B,mCAAkD,EAClD,SAAwB,EACvB,EAAE;IAGH,QAAQ,SAAS,CAAC,MAAM,EAAE;QACzB;YACC,MAAM,iBAAiB,GAAG,IAAA,kCAAa,oBAEtC,CAAC,EACD,mBAAmB,EACnB,uBAAuB,EACvB,UAAU,EACV,cAAc,EACd,SAAS,EACT,UAAU,CAAC,QAAQ,EACnB,KAAK,EACL,KAAK,EACL,KAAK,CACL,CAAC;YACF,iBAAiB,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;gBACnC,KAAK,CAAC,MAAM,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC;gBAC/B,KAAK,CAAC,MAAM,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC;gBAC/B,KAAK,CAAC,SAAS,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC;gBAClC,KAAK,CAAC,SAAS,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC;YACnC,CAAC,CAAC,CAAC;YACH,SAAS,CAAC,IAAI,GAAG,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC;YACrC,mCAAmC,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC;YAC/D,MAAM;KACP;IACD,SAAS,CAAC,aAAa,IAAI,SAAS,CAAC,aAAa,CAAC;AACpD,CAAC,CAAC","sourcesContent":["import { GameTag, Race } from '@firestone-hs/reference-data';\nimport { BgsHeroPower, BgsPlayerEntity } from '../bgs-player-entity';\nimport { BoardEntity } from '../board-entity';\nimport { hasAvenge } from '../cards/card.interface';\nimport { cardMappings } from '../cards/impl/_card-mappings';\nimport { grantRandomDivineShield } from '../keywords/divine-shield';\nimport { updateReborn } from '../keywords/reborn';\nimport { updateTaunt } from '../keywords/taunt';\nimport { CardIds } from '../services/card-ids';\nimport { pickRandom } from '../services/utils';\nimport { isValidDeathrattleEnchantment } from '../simulate-bgs-battle';\nimport {\n\taddStatsToBoard,\n\tgetRandomMinionWithHighestHealth,\n\tgrantRandomStats,\n\thasCorrectTribe,\n\thasEntityMechanic,\n} from '../utils';\nimport { dealDamageToMinion } from './attack';\nimport { addCardsInHand } from './cards-in-hand';\nimport { spawnEntities } from './deathrattle-spawns';\nimport { FullGameState } from './internal-game-state';\nimport { performEntitySpawns } from './spawns';\nimport { modifyStats } from './stats';\n\nexport const applyAvengeEffects = (\n\tdeadEntity: BoardEntity,\n\tdeadEntityIndexFromRight: number,\n\tboardWithDeadEntity: BoardEntity[],\n\tboardWithDeadEntityHero: BgsPlayerEntity,\n\totherBoard: BoardEntity[],\n\totherBoardHero: BgsPlayerEntity,\n\tgameState: FullGameState,\n\tentitiesSpawnedFromMinionDeath: BoardEntity[],\n): BoardEntity[] => {\n\tconst candidatesEntitiesSpawnedFromAvenge: BoardEntity[] = [];\n\t// updateAvengeCounters(boardWithDeadEntity, boardWithDeadEntityHero);\n\tconst avengers = boardWithDeadEntity\n\t\t.filter((e) => !!e.avengeDefault && e.avengeCurrent <= 0)\n\t\t// Get Tony to be processed first, because of the \"when turned golden, the minion ignores the death for the avenge counter\"\n\t\t// behavior\n\t\t.sort((a, b) => {\n\t\t\t// if (a.cardId === CardIds.TonyTwoTusk_BG21_031 || a.cardId === CardIds.TonyTwoTusk_BG21_031_G) {\n\t\t\t// \treturn -1;\n\t\t\t// }\n\t\t\t// if (b.cardId === CardIds.TonyTwoTusk_BG21_031 || b.cardId === CardIds.TonyTwoTusk_BG21_031_G) {\n\t\t\t// \treturn 1;\n\t\t\t// }\n\t\t\treturn 0;\n\t\t});\n\tfor (const avenger of avengers) {\n\t\thandleAvenge(\n\t\t\tboardWithDeadEntity,\n\t\t\tboardWithDeadEntityHero,\n\t\t\tdeadEntity,\n\t\t\tdeadEntityIndexFromRight,\n\t\t\tavenger,\n\t\t\tcandidatesEntitiesSpawnedFromAvenge,\n\t\t\totherBoard,\n\t\t\totherBoardHero,\n\t\t\tgameState,\n\t\t);\n\t}\n\t// console.log('updating dead entity avenge counter', boardWithDeadEntityHero.avengeCurrent, stringifySimpleCard(deadEntity, allCards));\n\tfor (const heroPower of boardWithDeadEntityHero.heroPowers) {\n\t\tconst heroAvenger = !!heroPower.avengeDefault && heroPower.avengeCurrent <= 0;\n\t\tif (heroAvenger) {\n\t\t\thandleHeroAvenge(\n\t\t\t\tdeadEntity,\n\t\t\t\theroPower,\n\t\t\t\tboardWithDeadEntity,\n\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\totherBoard,\n\t\t\t\totherBoardHero,\n\t\t\t\tcandidatesEntitiesSpawnedFromAvenge,\n\t\t\t\tgameState,\n\t\t\t);\n\t\t}\n\t}\n\n\tconst questRewardAvengers = boardWithDeadEntityHero.questRewardEntities.filter(\n\t\t(e) => !!e.avengeDefault && e.avengeCurrent <= 0,\n\t);\n\tfor (const avenger of questRewardAvengers) {\n\t\thandleAvenge(\n\t\t\tboardWithDeadEntity,\n\t\t\tboardWithDeadEntityHero,\n\t\t\tdeadEntity,\n\t\t\tdeadEntityIndexFromRight,\n\t\t\tavenger as BoardEntity,\n\t\t\tcandidatesEntitiesSpawnedFromAvenge,\n\t\t\totherBoard,\n\t\t\totherBoardHero,\n\t\t\tgameState,\n\t\t);\n\t}\n\n\tconst trinketAvengers = boardWithDeadEntityHero.trinkets.filter((e) => !!e.avengeDefault && e.avengeCurrent <= 0);\n\tfor (const avenger of trinketAvengers) {\n\t\thandleAvenge(\n\t\t\tboardWithDeadEntity,\n\t\t\tboardWithDeadEntityHero,\n\t\t\tdeadEntity,\n\t\t\tdeadEntityIndexFromRight,\n\t\t\tavenger as BoardEntity,\n\t\t\tcandidatesEntitiesSpawnedFromAvenge,\n\t\t\totherBoard,\n\t\t\totherBoardHero,\n\t\t\tgameState,\n\t\t);\n\t}\n\n\tperformEntitySpawns(\n\t\tcandidatesEntitiesSpawnedFromAvenge,\n\t\tboardWithDeadEntity,\n\t\tboardWithDeadEntityHero,\n\t\tdeadEntity,\n\t\tdeadEntityIndexFromRight,\n\t\totherBoard,\n\t\totherBoardHero,\n\t\tgameState,\n\t);\n\n\t// Not an avenge, but with Avenge timing\n\tconst hasDeathrattle =\n\t\thasEntityMechanic(deadEntity, GameTag.DEATHRATTLE, gameState.allCards) ||\n\t\tdeadEntity.enchantments.some((e) => isValidDeathrattleEnchantment(e.cardId));\n\tif (hasDeathrattle) {\n\t\t// These are apparently processed after Reborn is triggered\n\t\t// http://replays.firestoneapp.com/?reviewId=5db9a191-ae9b-43a5-a072-0d460631d7a9&turn=23&action=12\n\t\t// UPDATE 2024-06-24: Multiple counterexamples of this, so I'm not sure exactly what is the right approach\n\t\t// I'm implementing the one that makes more sense to me; triggering after reborn is just too different\n\t\t// from what happens usually\n\t\t// However, we want to trigger it after all the spawns have been processed, so more or less an \"avenge\" timing?\n\t\t// Maybe even after that?\n\t\t// Update 2024-06-27 29.6.2: timing should stay the same\n\t\tboardWithDeadEntity\n\t\t\t.filter((e) => e.cardId === CardIds.GhoulAcabra_BG29_863 || e.cardId === CardIds.GhoulAcabra_BG29_863_G)\n\t\t\t.forEach((ghoul) => {\n\t\t\t\tconst buff = ghoul.cardId === CardIds.GhoulAcabra_BG29_863_G ? 2 : 1;\n\t\t\t\taddStatsToBoard(ghoul, boardWithDeadEntity, boardWithDeadEntityHero, 2 * buff, 2 * buff, gameState);\n\t\t\t});\n\t}\n\n\treturn candidatesEntitiesSpawnedFromAvenge;\n};\n\nexport const updateAvengeCounters = (board: readonly BoardEntity[], boardWithDeadEntityHero: BgsPlayerEntity) => {\n\tfor (const entity of board) {\n\t\tif (!!entity.avengeDefault) {\n\t\t\tentity.avengeCurrent -= 1;\n\t\t}\n\t}\n\tfor (const heroPower of boardWithDeadEntityHero.heroPowers) {\n\t\tif (!!heroPower.avengeDefault) {\n\t\t\theroPower.avengeCurrent -= 1;\n\t\t}\n\t}\n\n\tfor (const reward of boardWithDeadEntityHero.questRewardEntities) {\n\t\tif (!!reward.avengeDefault) {\n\t\t\treward.avengeCurrent -= 1;\n\t\t}\n\t}\n\n\tfor (const trinket of boardWithDeadEntityHero.trinkets) {\n\t\tif (!!trinket.avengeDefault) {\n\t\t\ttrinket.avengeCurrent -= 1;\n\t\t}\n\t}\n};\n\nconst handleAvenge = (\n\tboardWithDeadEntity: BoardEntity[],\n\tboardWithDeadEntityHero: BgsPlayerEntity,\n\tdeadEntity: BoardEntity,\n\tdeadEntityIndexFromRight: number,\n\tavenger: BoardEntity,\n\tcandidatesEntitiesSpawnedFromAvenge: BoardEntity[],\n\totherBoard: BoardEntity[],\n\totherBoardHero: BgsPlayerEntity,\n\tgameState: FullGameState,\n) => {\n\tconst avengeImpl = cardMappings[avenger.cardId];\n\tif (hasAvenge(avengeImpl)) {\n\t\tconst newSpawns = avengeImpl.avenge(avenger, {\n\t\t\tboard: boardWithDeadEntity,\n\t\t\thero: boardWithDeadEntityHero,\n\t\t\totherBoard: otherBoard,\n\t\t\totherHero: otherBoardHero,\n\t\t\tdeadEntity: deadEntity,\n\t\t\tgameState,\n\t\t});\n\t\tif (Array.isArray(newSpawns) && newSpawns?.length) {\n\t\t\tcandidatesEntitiesSpawnedFromAvenge.push(...newSpawns);\n\t\t}\n\t} else {\n\t\t// Don't forget to update the avenge data in cards-data\n\t\tswitch (avenger.cardId) {\n\t\t\tcase CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy:\n\t\t\tcase CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy_G:\n\t\t\t\t// Only for Tavern\n\t\t\t\t// addStatsToBoard(\n\t\t\t\t// \tavenger,\n\t\t\t\t// \tboardWithDeadEntity,\n\t\t\t\t// \t0,\n\t\t\t\t// \tavenger.cardId === CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy_G ? 2 : 1,\n\t\t\t\t// \tgameState.allCards,\n\t\t\t\t// \tgameState.spectator,\n\t\t\t\t// );\n\t\t\t\tbreak;\n\t\t\tcase CardIds.PalescaleCrocolisk_BG21_001:\n\t\t\t\tconst target1 = grantRandomStats(\n\t\t\t\t\tavenger,\n\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\t6,\n\t\t\t\t\t6,\n\t\t\t\t\tRace.BEAST,\n\t\t\t\t\ttrue,\n\t\t\t\t\tgameState,\n\t\t\t\t);\n\t\t\t\tif (!!target1) {\n\t\t\t\t\tgameState.spectator.registerPowerTarget(\n\t\t\t\t\t\tavenger,\n\t\t\t\t\t\ttarget1,\n\t\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\t\totherBoardHero,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CardIds.PalescaleCrocolisk_BG21_001_G:\n\t\t\t\tconst target2 = grantRandomStats(\n\t\t\t\t\tavenger,\n\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\t12,\n\t\t\t\t\t12,\n\t\t\t\t\tRace.BEAST,\n\t\t\t\t\ttrue,\n\t\t\t\t\tgameState,\n\t\t\t\t);\n\t\t\t\tif (!!target2) {\n\t\t\t\t\tgameState.spectator.registerPowerTarget(\n\t\t\t\t\t\tavenger,\n\t\t\t\t\t\ttarget2,\n\t\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\t\totherBoardHero,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CardIds.ImpatientDoomsayer_BG21_007:\n\t\t\tcase CardIds.ImpatientDoomsayer_BG21_007_G:\n\t\t\t\tconst doomsayerCardsToAddQuantity = avenger.cardId === CardIds.ImpatientDoomsayer_BG21_007_G ? 2 : 1;\n\t\t\t\tconst doomsayerCardsToAdd = [];\n\t\t\t\tfor (let i = 0; i < doomsayerCardsToAddQuantity; i++) {\n\t\t\t\t\tdoomsayerCardsToAdd.push(pickRandom(gameState.cardsData.demonSpawns));\n\t\t\t\t}\n\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, doomsayerCardsToAdd, gameState);\n\t\t\t\tbreak;\n\t\t\tcase CardIds.PashmarTheVengeful_BG23_014:\n\t\t\tcase CardIds.PashmarTheVengeful_BG23_014_G:\n\t\t\t\tbreak;\n\t\t\tcase CardIds.TremblingTrolley_BG28_967:\n\t\t\tcase CardIds.TremblingTrolley_BG28_967_G:\n\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, [null], gameState);\n\t\t\t\tbreak;\n\t\t\tcase CardIds.Thorncaller_BG20_105:\n\t\t\tcase CardIds.Thorncaller_BG20_105_G:\n\t\t\t\tconst thorncallerToAddQuantity = avenger.cardId === CardIds.Thorncaller_BG20_105_G ? 2 : 1;\n\t\t\t\tconst thorncallerCardsToAdd = Array(thorncallerToAddQuantity).fill(CardIds.BloodGem);\n\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, thorncallerCardsToAdd, gameState);\n\t\t\t\tbreak;\n\t\t\t// case CardIds.Sisefin_BG21_009:\n\t\t\t// case CardIds.Sisefin_BG21_009_G:\n\t\t\t// \tconst poisonousIterations = avenger.cardId === CardIds.Sisefin_BG21_009_G ? 2 : 1;\n\t\t\t// \tfor (let i = 0; i < poisonousIterations; i++) {\n\t\t\t// \t\tconst validTargets = boardWithDeadEntity.filter((e) => !e.poisonous && !e.venomous);\n\t\t\t// \t\tconst murloc = getRandomAliveMinion(validTargets, boardWithDeadEntityHero, Race.MURLOC, gameState);\n\t\t\t// \t\tif (murloc) {\n\t\t\t// \t\t\tupdateVenomous(\n\t\t\t// \t\t\t\tmurloc,\n\t\t\t// \t\t\t\ttrue,\n\t\t\t// \t\t\t\tboardWithDeadEntity,\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\n\t\t\t// \t\t\t\totherBoardHero,\n\t\t\t// \t\t\t\tgameState,\n\t\t\t// \t\t\t);\n\t\t\t// \t\t\tgameState.spectator.registerPowerTarget(\n\t\t\t// \t\t\t\tavenger,\n\t\t\t// \t\t\t\tmurloc,\n\t\t\t// \t\t\t\tboardWithDeadEntity,\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\n\t\t\t// \t\t\t\totherBoardHero,\n\t\t\t// \t\t\t);\n\t\t\t// \t\t}\n\t\t\t// \t}\n\t\t\t// \tbreak;\n\t\t\tcase CardIds.MechanoTank_BG21_023:\n\t\t\t\t// This can be null if the avenge triggers when the last enemy minion dies as well\n\t\t\t\tconst target = getRandomMinionWithHighestHealth(otherBoard);\n\t\t\t\tgameState.spectator.registerPowerTarget(\n\t\t\t\t\tavenger,\n\t\t\t\t\ttarget,\n\t\t\t\t\totherBoard,\n\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\totherBoardHero,\n\t\t\t\t);\n\t\t\t\tdealDamageToMinion(\n\t\t\t\t\ttarget,\n\t\t\t\t\totherBoard,\n\t\t\t\t\totherBoardHero,\n\t\t\t\t\tavenger,\n\t\t\t\t\t5,\n\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\tgameState,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase CardIds.MechanoTank_BG21_023_G:\n\t\t\t\tfor (let i = 0; i < 2; i++) {\n\t\t\t\t\tconst target = getRandomMinionWithHighestHealth(otherBoard);\n\t\t\t\t\tgameState.spectator.registerPowerTarget(\n\t\t\t\t\t\tavenger,\n\t\t\t\t\t\ttarget,\n\t\t\t\t\t\totherBoard,\n\t\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\t\totherBoardHero,\n\t\t\t\t\t);\n\t\t\t\t\tdealDamageToMinion(\n\t\t\t\t\t\ttarget,\n\t\t\t\t\t\totherBoard,\n\t\t\t\t\t\totherBoardHero,\n\t\t\t\t\t\tavenger,\n\t\t\t\t\t\t5,\n\t\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\t\tgameState,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t// case CardIds.TonyTwoTusk_BG21_031:\n\t\t\t// \tconst nonGoldenMinions = boardWithDeadEntity\n\t\t\t// \t\t.filter((e) => e.entityId !== avenger.entityId)\n\t\t\t// \t\t.filter((e) => {\n\t\t\t// \t\t\tconst ref = gameState.allCards.getCard(e.cardId);\n\t\t\t// \t\t\treturn (\n\t\t\t// \t\t\t\t!!ref.battlegroundsPremiumDbfId &&\n\t\t\t// \t\t\t\t!!gameState.allCards.getCardFromDbfId(ref.battlegroundsPremiumDbfId).id\n\t\t\t// \t\t\t);\n\t\t\t// \t\t});\n\t\t\t// \tconst pirate = getRandomAliveMinion(nonGoldenMinions, boardWithDeadEntityHero, Race.PIRATE, gameState);\n\t\t\t// \tif (pirate) {\n\t\t\t// \t\tmakeMinionGolden(\n\t\t\t// \t\t\tpirate,\n\t\t\t// \t\t\tavenger,\n\t\t\t// \t\t\tboardWithDeadEntity,\n\t\t\t// \t\t\tboardWithDeadEntityHero,\n\t\t\t// \t\t\totherBoard,\n\t\t\t// \t\t\totherBoardHero,\n\t\t\t// \t\t\tgameState,\n\t\t\t// \t\t);\n\t\t\t// \t}\n\t\t\t// \tbreak;\n\t\t\t// case CardIds.TonyTwoTusk_BG21_031_G:\n\t\t\t// \tfor (let i = 0; i < 2; i++) {\n\t\t\t// \t\tconst nonGoldenMinions = boardWithDeadEntity.filter((e) => !isMinionGolden(e, gameState.allCards));\n\t\t\t// \t\tconst pirate = getRandomAliveMinion(\n\t\t\t// \t\t\tnonGoldenMinions,\n\t\t\t// \t\t\tboardWithDeadEntityHero,\n\t\t\t// \t\t\tRace.PIRATE,\n\t\t\t// \t\t\tgameState,\n\t\t\t// \t\t);\n\t\t\t// \t\tif (pirate) {\n\t\t\t// \t\t\tmakeMinionGolden(\n\t\t\t// \t\t\t\tpirate,\n\t\t\t// \t\t\t\tavenger,\n\t\t\t// \t\t\t\tboardWithDeadEntity,\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\n\t\t\t// \t\t\t\totherBoard,\n\t\t\t// \t\t\t\totherBoardHero,\n\t\t\t// \t\t\t\tgameState,\n\t\t\t// \t\t\t);\n\t\t\t// \t\t}\n\t\t\t// \t}\n\t\t\t// \tbreak;\n\t\t\tcase CardIds.HungeringAbomination_BG25_014:\n\t\t\tcase CardIds.HungeringAbomination_BG25_014_G:\n\t\t\t\tconst abominationMultiplier = avenger.cardId === CardIds.HungeringAbomination_BG25_014_G ? 2 : 1;\n\t\t\t\tmodifyStats(\n\t\t\t\t\tavenger,\n\t\t\t\t\tavenger,\n\t\t\t\t\tabominationMultiplier * 1,\n\t\t\t\t\tabominationMultiplier * 2,\n\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\tgameState,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t// case CardIds.IceSickle:\n\t\t\t// \tgrantRandomStats(\n\t\t\t// \t\tavenger,\n\t\t\t// \t\tboardWithDeadEntityHero.hand.filter(\n\t\t\t// \t\t\t(e) => gameState.allCards.getCard(e.cardId).type?.toUpperCase() === CardType[CardType.MINION],\n\t\t\t// \t\t),\n\t\t\t// \t\tboardWithDeadEntityHero,\n\t\t\t// \t\t4,\n\t\t\t// \t\t0,\n\t\t\t// \t\tnull,\n\t\t\t// \t\ttrue,\n\t\t\t// \t\tgameState,\n\t\t\t// \t);\n\t\t\t// \tbreak;\n\t\t\tcase CardIds.BoomSquad_BG27_Reward_502:\n\t\t\t\tconst highestHealthMinion = [...otherBoard].sort((a, b) => b.health - a.health)[0];\n\t\t\t\tdealDamageToMinion(\n\t\t\t\t\thighestHealthMinion,\n\t\t\t\t\totherBoard,\n\t\t\t\t\totherBoardHero,\n\t\t\t\t\tavenger,\n\t\t\t\t\t10,\n\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\tgameState,\n\t\t\t\t);\n\t\t\t\tgameState.spectator.registerPowerTarget(\n\t\t\t\t\tavenger,\n\t\t\t\t\thighestHealthMinion,\n\t\t\t\t\totherBoard,\n\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\totherBoardHero,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase CardIds.RelentlessSentry_BG25_003:\n\t\t\tcase CardIds.RelentlessSentry_BG25_003_G:\n\t\t\t\tupdateReborn(avenger, true, boardWithDeadEntity, boardWithDeadEntityHero, otherBoardHero, gameState);\n\t\t\t\tupdateTaunt(avenger, true, boardWithDeadEntity, boardWithDeadEntityHero, otherBoardHero, gameState);\n\t\t\t\tbreak;\n\t\t\tcase CardIds.RelentlessMurghoul_BG27_010:\n\t\t\tcase CardIds.RelentlessMurghoul_BG27_010_G:\n\t\t\t\tupdateReborn(avenger, true, boardWithDeadEntity, boardWithDeadEntityHero, otherBoardHero, gameState);\n\t\t\t\tupdateTaunt(avenger, true, boardWithDeadEntity, boardWithDeadEntityHero, otherBoardHero, gameState);\n\t\t\t\tbreak;\n\t\t\tcase CardIds.PhaerixWrathOfTheSun_BG28_403:\n\t\t\tcase CardIds.PhaerixWrathOfTheSun_BG28_403_G:\n\t\t\t\tconst phaerixLoops = avenger.cardId === CardIds.PhaerixWrathOfTheSun_BG28_403_G ? 2 : 1;\n\t\t\t\tfor (let i = 0; i < phaerixLoops; i++) {\n\t\t\t\t\tgrantRandomDivineShield(\n\t\t\t\t\t\tavenger,\n\t\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\t\totherBoardHero,\n\t\t\t\t\t\tgameState,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CardIds.AugmentedLaborer_BG28_740:\n\t\t\tcase CardIds.AugmentedLaborer_BG28_740_G:\n\t\t\t\tconst AugmentedLaborerLoops = avenger.cardId === CardIds.AugmentedLaborer_BG28_740_G ? 2 : 1;\n\t\t\t\tfor (let i = 0; i < AugmentedLaborerLoops; i++) {\n\t\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, [null], gameState);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CardIds.TumblingDisaster_BG28_Reward_505:\n\t\t\t\tconst tumblingDisasterEntity = boardWithDeadEntityHero.questRewardEntities?.find(\n\t\t\t\t\t(e) => e.cardId === CardIds.TumblingDisaster_BG28_Reward_505,\n\t\t\t\t);\n\t\t\t\tif (tumblingDisasterEntity) {\n\t\t\t\t\ttumblingDisasterEntity.scriptDataNum1 = (tumblingDisasterEntity.scriptDataNum1 ?? 0) + 1;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CardIds.CycleOfEnergy_BG28_Reward_504:\n\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, [null], gameState);\n\t\t\t\tbreak;\n\t\t\tcase CardIds.StableAmalgamation_BG28_Reward_518:\n\t\t\t\tavenger.scriptDataNum1 = (avenger.scriptDataNum1 ?? 0) + 1;\n\t\t\t\tbreak;\n\t\t\tcase CardIds.MurglMkIi_BG29_991:\n\t\t\tcase CardIds.MurglMkIi_BG29_991_G:\n\t\t\t\tconst murglMkStats = avenger.cardId === CardIds.MurglMkIi_BG29_991_G ? 2 : 1;\n\t\t\t\taddStatsToBoard(\n\t\t\t\t\tavenger,\n\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\tmurglMkStats,\n\t\t\t\t\tmurglMkStats,\n\t\t\t\t\tgameState,\n\t\t\t\t);\n\t\t\t\t// Don't use utility methods, as we don't want triggers to proc\n\t\t\t\tfor (const e of boardWithDeadEntityHero.hand ?? []) {\n\t\t\t\t\te.attack += murglMkStats;\n\t\t\t\t\te.health += murglMkStats;\n\t\t\t\t\te.maxHealth += murglMkStats;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CardIds.StaffOfTheScourge_BG30_MagicItem_437:\n\t\t\t\tif (boardWithDeadEntity.length > 0) {\n\t\t\t\t\tconst candidates = boardWithDeadEntity.filter(\n\t\t\t\t\t\t(e) =>\n\t\t\t\t\t\t\t!e.reborn &&\n\t\t\t\t\t\t\thasCorrectTribe(\n\t\t\t\t\t\t\t\te,\n\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\t\t\t\tRace.UNDEAD,\n\t\t\t\t\t\t\t\tgameState.anomalies,\n\t\t\t\t\t\t\t\tgameState.allCards,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tconst target = pickRandom(candidates);\n\t\t\t\t\tif (!!target) {\n\t\t\t\t\t\tupdateReborn(\n\t\t\t\t\t\t\ttarget,\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\t\t\totherBoardHero,\n\t\t\t\t\t\t\tgameState,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\n\t\t\t\t\t\t\tavenger,\n\t\t\t\t\t\t\ttarget,\n\t\t\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\t\t\totherBoardHero,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CardIds.BleedingHeart_BG30_MagicItem_713:\n\t\t\t\tconst randomUndead = gameState.cardsData.getRandomMinionForTribe(\n\t\t\t\t\tRace.UNDEAD,\n\t\t\t\t\tboardWithDeadEntityHero.tavernTier,\n\t\t\t\t);\n\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, [randomUndead], gameState);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\tavenger.avengeCurrent += avenger.avengeDefault;\n};\n\nconst handleHeroAvenge = (\n\tdeadEntity: BoardEntity,\n\theroPower: BgsHeroPower,\n\tboardWithDeadEntity: BoardEntity[],\n\tboardWithDeadEntityHero: BgsPlayerEntity,\n\totherBoard: BoardEntity[],\n\totherBoardHero: BgsPlayerEntity,\n\tcandidatesEntitiesSpawnedFromAvenge: BoardEntity[],\n\tgameState: FullGameState,\n) => {\n\t// https://twitter.com/LoewenMitchell/status/1491879869457879040\n\t// Not affected by Khadgar\n\tswitch (heroPower.cardId) {\n\t\tcase CardIds.Onyxia_Broodmother:\n\t\t\tconst broodmotherTokens = spawnEntities(\n\t\t\t\tCardIds.Onyxia_OnyxianWhelpToken,\n\t\t\t\t1,\n\t\t\t\tboardWithDeadEntity,\n\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\totherBoard,\n\t\t\t\totherBoardHero,\n\t\t\t\tgameState,\n\t\t\t\tdeadEntity.friendly,\n\t\t\t\tfalse,\n\t\t\t\tfalse,\n\t\t\t\tfalse,\n\t\t\t);\n\t\t\tbroodmotherTokens.forEach((token) => {\n\t\t\t\ttoken.attack = +heroPower.info;\n\t\t\t\ttoken.health = +heroPower.info;\n\t\t\t\ttoken.maxAttack = +heroPower.info;\n\t\t\t\ttoken.maxHealth = +heroPower.info;\n\t\t\t});\n\t\t\theroPower.info = +heroPower.info + 1;\n\t\t\tcandidatesEntitiesSpawnedFromAvenge.push(...broodmotherTokens);\n\t\t\tbreak;\n\t}\n\theroPower.avengeCurrent += heroPower.avengeDefault;\n};\n\nexport interface AvengeInput {\n\treadonly board: BoardEntity[];\n\treadonly deadEntity: BoardEntity;\n\treadonly hero: BgsPlayerEntity;\n\treadonly otherBoard: BoardEntity[];\n\treadonly otherHero: BgsPlayerEntity;\n\treadonly gameState: FullGameState;\n}\n"]}
1
+ {"version":3,"file":"avenge.js","sourceRoot":"","sources":["../../src/simulation/avenge.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAG7D,4DAAoD;AACpD,iEAA4D;AAC5D,6DAAoE;AACpE,+CAAkD;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AC/B,KAAK,CAAC,MAAM,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC;gBAC/B,KAAK,CAAC,SAAS,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC;gBAClC,KAAK,CAAC,SAAS,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC;YACnC,CAAC,CAAC,CAAC;YACH,SAAS,CAAC,IAAI,GAAG,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC;YACrC,mCAAmC,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC;YAC/D,MAAM;KACP;IACD,SAAS,CAAC,aAAa,IAAI,SAAS,CAAC,aAAa,CAAC;AACpD,CAAC,CAAC","sourcesContent":["import { GameTag, Race } from '@firestone-hs/reference-data';\nimport { BgsHeroPower, BgsPlayerEntity } from '../bgs-player-entity';\nimport { BoardEntity } from '../board-entity';\nimport { hasAvenge } from '../cards/card.interface';\nimport { cardMappings } from '../cards/impl/_card-mappings';\nimport { grantRandomDivineShield } from '../keywords/divine-shield';\nimport { updateReborn } from '../keywords/reborn';\nimport { updateTaunt } from '../keywords/taunt';\nimport { CardIds } from '../services/card-ids';\nimport { pickRandom } from '../services/utils';\nimport { isValidDeathrattleEnchantment } from '../simulate-bgs-battle';\nimport {\n\taddStatsToBoard,\n\tgetRandomMinionWithHighestHealth,\n\tgrantRandomStats,\n\thasCorrectTribe,\n\thasEntityMechanic,\n} from '../utils';\nimport { dealDamageToMinion } from './attack';\nimport { addCardsInHand } from './cards-in-hand';\nimport { spawnEntities } from './deathrattle-spawns';\nimport { FullGameState } from './internal-game-state';\nimport { performEntitySpawns } from './spawns';\nimport { modifyStats } from './stats';\n\nexport const applyAvengeEffects = (\n\tdeadEntity: BoardEntity,\n\tdeadEntityIndexFromRight: number,\n\tboardWithDeadEntity: BoardEntity[],\n\tboardWithDeadEntityHero: BgsPlayerEntity,\n\totherBoard: BoardEntity[],\n\totherBoardHero: BgsPlayerEntity,\n\tgameState: FullGameState,\n\tentitiesSpawnedFromMinionDeath: BoardEntity[],\n): BoardEntity[] => {\n\tconst candidatesEntitiesSpawnedFromAvenge: BoardEntity[] = [];\n\t// updateAvengeCounters(boardWithDeadEntity, boardWithDeadEntityHero);\n\tconst avengers = boardWithDeadEntity\n\t\t.filter((e) => !!e.avengeDefault && e.avengeCurrent <= 0)\n\t\t// Get Tony to be processed first, because of the \"when turned golden, the minion ignores the death for the avenge counter\"\n\t\t// behavior\n\t\t.sort((a, b) => {\n\t\t\t// if (a.cardId === CardIds.TonyTwoTusk_BG21_031 || a.cardId === CardIds.TonyTwoTusk_BG21_031_G) {\n\t\t\t// \treturn -1;\n\t\t\t// }\n\t\t\t// if (b.cardId === CardIds.TonyTwoTusk_BG21_031 || b.cardId === CardIds.TonyTwoTusk_BG21_031_G) {\n\t\t\t// \treturn 1;\n\t\t\t// }\n\t\t\treturn 0;\n\t\t});\n\tfor (const avenger of avengers) {\n\t\thandleAvenge(\n\t\t\tboardWithDeadEntity,\n\t\t\tboardWithDeadEntityHero,\n\t\t\tdeadEntity,\n\t\t\tdeadEntityIndexFromRight,\n\t\t\tavenger,\n\t\t\tcandidatesEntitiesSpawnedFromAvenge,\n\t\t\totherBoard,\n\t\t\totherBoardHero,\n\t\t\tgameState,\n\t\t);\n\t}\n\t// console.log('updating dead entity avenge counter', boardWithDeadEntityHero.avengeCurrent, stringifySimpleCard(deadEntity, allCards));\n\tfor (const heroPower of boardWithDeadEntityHero.heroPowers) {\n\t\tconst heroAvenger = !!heroPower.avengeDefault && heroPower.avengeCurrent <= 0;\n\t\tif (heroAvenger) {\n\t\t\thandleHeroAvenge(\n\t\t\t\tdeadEntity,\n\t\t\t\theroPower,\n\t\t\t\tboardWithDeadEntity,\n\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\totherBoard,\n\t\t\t\totherBoardHero,\n\t\t\t\tcandidatesEntitiesSpawnedFromAvenge,\n\t\t\t\tgameState,\n\t\t\t);\n\t\t}\n\t}\n\n\tconst questRewardAvengers = boardWithDeadEntityHero.questRewardEntities.filter(\n\t\t(e) => !!e.avengeDefault && e.avengeCurrent <= 0,\n\t);\n\tfor (const avenger of questRewardAvengers) {\n\t\thandleAvenge(\n\t\t\tboardWithDeadEntity,\n\t\t\tboardWithDeadEntityHero,\n\t\t\tdeadEntity,\n\t\t\tdeadEntityIndexFromRight,\n\t\t\tavenger as BoardEntity,\n\t\t\tcandidatesEntitiesSpawnedFromAvenge,\n\t\t\totherBoard,\n\t\t\totherBoardHero,\n\t\t\tgameState,\n\t\t);\n\t}\n\n\tconst trinketAvengers = boardWithDeadEntityHero.trinkets.filter((e) => !!e.avengeDefault && e.avengeCurrent <= 0);\n\tfor (const avenger of trinketAvengers) {\n\t\thandleAvenge(\n\t\t\tboardWithDeadEntity,\n\t\t\tboardWithDeadEntityHero,\n\t\t\tdeadEntity,\n\t\t\tdeadEntityIndexFromRight,\n\t\t\tavenger as BoardEntity,\n\t\t\tcandidatesEntitiesSpawnedFromAvenge,\n\t\t\totherBoard,\n\t\t\totherBoardHero,\n\t\t\tgameState,\n\t\t);\n\t}\n\n\tperformEntitySpawns(\n\t\tcandidatesEntitiesSpawnedFromAvenge,\n\t\tboardWithDeadEntity,\n\t\tboardWithDeadEntityHero,\n\t\tdeadEntity,\n\t\tdeadEntityIndexFromRight,\n\t\totherBoard,\n\t\totherBoardHero,\n\t\tgameState,\n\t);\n\n\t// Not an avenge, but with Avenge timing\n\tconst hasDeathrattle =\n\t\thasEntityMechanic(deadEntity, GameTag.DEATHRATTLE, gameState.allCards) ||\n\t\tdeadEntity.enchantments.some((e) => isValidDeathrattleEnchantment(e.cardId));\n\tif (hasDeathrattle) {\n\t\t// These are apparently processed after Reborn is triggered\n\t\t// http://replays.firestoneapp.com/?reviewId=5db9a191-ae9b-43a5-a072-0d460631d7a9&turn=23&action=12\n\t\t// UPDATE 2024-06-24: Multiple counterexamples of this, so I'm not sure exactly what is the right approach\n\t\t// I'm implementing the one that makes more sense to me; triggering after reborn is just too different\n\t\t// from what happens usually\n\t\t// However, we want to trigger it after all the spawns have been processed, so more or less an \"avenge\" timing?\n\t\t// Maybe even after that?\n\t\t// Update 2024-06-27 29.6.2: timing should stay the same\n\t\tboardWithDeadEntity\n\t\t\t.filter((e) => e.cardId === CardIds.GhoulAcabra_BG29_863 || e.cardId === CardIds.GhoulAcabra_BG29_863_G)\n\t\t\t.forEach((ghoul) => {\n\t\t\t\tconst buff = ghoul.cardId === CardIds.GhoulAcabra_BG29_863_G ? 2 : 1;\n\t\t\t\taddStatsToBoard(ghoul, boardWithDeadEntity, boardWithDeadEntityHero, 2 * buff, 2 * buff, gameState);\n\t\t\t});\n\t}\n\n\treturn candidatesEntitiesSpawnedFromAvenge;\n};\n\nexport const updateAvengeCounters = (board: readonly BoardEntity[], boardWithDeadEntityHero: BgsPlayerEntity) => {\n\tfor (const entity of board) {\n\t\tif (!!entity.avengeDefault) {\n\t\t\tentity.avengeCurrent -= 1;\n\t\t}\n\t}\n\tfor (const heroPower of boardWithDeadEntityHero.heroPowers) {\n\t\tif (!!heroPower.avengeDefault) {\n\t\t\theroPower.avengeCurrent -= 1;\n\t\t}\n\t}\n\n\tfor (const reward of boardWithDeadEntityHero.questRewardEntities) {\n\t\tif (!!reward.avengeDefault) {\n\t\t\treward.avengeCurrent -= 1;\n\t\t}\n\t}\n\n\tfor (const trinket of boardWithDeadEntityHero.trinkets) {\n\t\tif (!!trinket.avengeDefault) {\n\t\t\ttrinket.avengeCurrent -= 1;\n\t\t}\n\t}\n};\n\nconst handleAvenge = (\n\tboardWithDeadEntity: BoardEntity[],\n\tboardWithDeadEntityHero: BgsPlayerEntity,\n\tdeadEntity: BoardEntity,\n\tdeadEntityIndexFromRight: number,\n\tavenger: BoardEntity,\n\tcandidatesEntitiesSpawnedFromAvenge: BoardEntity[],\n\totherBoard: BoardEntity[],\n\totherBoardHero: BgsPlayerEntity,\n\tgameState: FullGameState,\n) => {\n\tconst avengeImpl = cardMappings[avenger.cardId];\n\tif (hasAvenge(avengeImpl)) {\n\t\tconst newSpawns = avengeImpl.avenge(avenger, {\n\t\t\tboard: boardWithDeadEntity,\n\t\t\thero: boardWithDeadEntityHero,\n\t\t\totherBoard: otherBoard,\n\t\t\totherHero: otherBoardHero,\n\t\t\tdeadEntity: deadEntity,\n\t\t\tgameState,\n\t\t});\n\t\tif (Array.isArray(newSpawns) && newSpawns?.length) {\n\t\t\tconst avengeMinionIndexFromRight = boardWithDeadEntity.length - (boardWithDeadEntity.indexOf(avenger) + 1);\n\t\t\tnewSpawns.forEach((e: BoardEntity) => {\n\t\t\t\te.spawnIndexFromRight = avengeMinionIndexFromRight;\n\t\t\t});\n\t\t\tcandidatesEntitiesSpawnedFromAvenge.push(...newSpawns);\n\t\t}\n\t} else {\n\t\t// Don't forget to update the avenge data in cards-data\n\t\tswitch (avenger.cardId) {\n\t\t\tcase CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy:\n\t\t\tcase CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy_G:\n\t\t\t\t// Only for Tavern\n\t\t\t\t// addStatsToBoard(\n\t\t\t\t// \tavenger,\n\t\t\t\t// \tboardWithDeadEntity,\n\t\t\t\t// \t0,\n\t\t\t\t// \tavenger.cardId === CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy_G ? 2 : 1,\n\t\t\t\t// \tgameState.allCards,\n\t\t\t\t// \tgameState.spectator,\n\t\t\t\t// );\n\t\t\t\tbreak;\n\t\t\tcase CardIds.PalescaleCrocolisk_BG21_001:\n\t\t\t\tconst target1 = grantRandomStats(\n\t\t\t\t\tavenger,\n\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\t6,\n\t\t\t\t\t6,\n\t\t\t\t\tRace.BEAST,\n\t\t\t\t\ttrue,\n\t\t\t\t\tgameState,\n\t\t\t\t);\n\t\t\t\tif (!!target1) {\n\t\t\t\t\tgameState.spectator.registerPowerTarget(\n\t\t\t\t\t\tavenger,\n\t\t\t\t\t\ttarget1,\n\t\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\t\totherBoardHero,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CardIds.PalescaleCrocolisk_BG21_001_G:\n\t\t\t\tconst target2 = grantRandomStats(\n\t\t\t\t\tavenger,\n\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\t12,\n\t\t\t\t\t12,\n\t\t\t\t\tRace.BEAST,\n\t\t\t\t\ttrue,\n\t\t\t\t\tgameState,\n\t\t\t\t);\n\t\t\t\tif (!!target2) {\n\t\t\t\t\tgameState.spectator.registerPowerTarget(\n\t\t\t\t\t\tavenger,\n\t\t\t\t\t\ttarget2,\n\t\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\t\totherBoardHero,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CardIds.ImpatientDoomsayer_BG21_007:\n\t\t\tcase CardIds.ImpatientDoomsayer_BG21_007_G:\n\t\t\t\tconst doomsayerCardsToAddQuantity = avenger.cardId === CardIds.ImpatientDoomsayer_BG21_007_G ? 2 : 1;\n\t\t\t\tconst doomsayerCardsToAdd = [];\n\t\t\t\tfor (let i = 0; i < doomsayerCardsToAddQuantity; i++) {\n\t\t\t\t\tdoomsayerCardsToAdd.push(pickRandom(gameState.cardsData.demonSpawns));\n\t\t\t\t}\n\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, doomsayerCardsToAdd, gameState);\n\t\t\t\tbreak;\n\t\t\tcase CardIds.PashmarTheVengeful_BG23_014:\n\t\t\tcase CardIds.PashmarTheVengeful_BG23_014_G:\n\t\t\t\tbreak;\n\t\t\tcase CardIds.TremblingTrolley_BG28_967:\n\t\t\tcase CardIds.TremblingTrolley_BG28_967_G:\n\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, [null], gameState);\n\t\t\t\tbreak;\n\t\t\tcase CardIds.Thorncaller_BG20_105:\n\t\t\tcase CardIds.Thorncaller_BG20_105_G:\n\t\t\t\tconst thorncallerToAddQuantity = avenger.cardId === CardIds.Thorncaller_BG20_105_G ? 2 : 1;\n\t\t\t\tconst thorncallerCardsToAdd = Array(thorncallerToAddQuantity).fill(CardIds.BloodGem);\n\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, thorncallerCardsToAdd, gameState);\n\t\t\t\tbreak;\n\t\t\t// case CardIds.Sisefin_BG21_009:\n\t\t\t// case CardIds.Sisefin_BG21_009_G:\n\t\t\t// \tconst poisonousIterations = avenger.cardId === CardIds.Sisefin_BG21_009_G ? 2 : 1;\n\t\t\t// \tfor (let i = 0; i < poisonousIterations; i++) {\n\t\t\t// \t\tconst validTargets = boardWithDeadEntity.filter((e) => !e.poisonous && !e.venomous);\n\t\t\t// \t\tconst murloc = getRandomAliveMinion(validTargets, boardWithDeadEntityHero, Race.MURLOC, gameState);\n\t\t\t// \t\tif (murloc) {\n\t\t\t// \t\t\tupdateVenomous(\n\t\t\t// \t\t\t\tmurloc,\n\t\t\t// \t\t\t\ttrue,\n\t\t\t// \t\t\t\tboardWithDeadEntity,\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\n\t\t\t// \t\t\t\totherBoardHero,\n\t\t\t// \t\t\t\tgameState,\n\t\t\t// \t\t\t);\n\t\t\t// \t\t\tgameState.spectator.registerPowerTarget(\n\t\t\t// \t\t\t\tavenger,\n\t\t\t// \t\t\t\tmurloc,\n\t\t\t// \t\t\t\tboardWithDeadEntity,\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\n\t\t\t// \t\t\t\totherBoardHero,\n\t\t\t// \t\t\t);\n\t\t\t// \t\t}\n\t\t\t// \t}\n\t\t\t// \tbreak;\n\t\t\tcase CardIds.MechanoTank_BG21_023:\n\t\t\t\t// This can be null if the avenge triggers when the last enemy minion dies as well\n\t\t\t\tconst target = getRandomMinionWithHighestHealth(otherBoard);\n\t\t\t\tgameState.spectator.registerPowerTarget(\n\t\t\t\t\tavenger,\n\t\t\t\t\ttarget,\n\t\t\t\t\totherBoard,\n\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\totherBoardHero,\n\t\t\t\t);\n\t\t\t\tdealDamageToMinion(\n\t\t\t\t\ttarget,\n\t\t\t\t\totherBoard,\n\t\t\t\t\totherBoardHero,\n\t\t\t\t\tavenger,\n\t\t\t\t\t5,\n\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\tgameState,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase CardIds.MechanoTank_BG21_023_G:\n\t\t\t\tfor (let i = 0; i < 2; i++) {\n\t\t\t\t\tconst target = getRandomMinionWithHighestHealth(otherBoard);\n\t\t\t\t\tgameState.spectator.registerPowerTarget(\n\t\t\t\t\t\tavenger,\n\t\t\t\t\t\ttarget,\n\t\t\t\t\t\totherBoard,\n\t\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\t\totherBoardHero,\n\t\t\t\t\t);\n\t\t\t\t\tdealDamageToMinion(\n\t\t\t\t\t\ttarget,\n\t\t\t\t\t\totherBoard,\n\t\t\t\t\t\totherBoardHero,\n\t\t\t\t\t\tavenger,\n\t\t\t\t\t\t5,\n\t\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\t\tgameState,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t// case CardIds.TonyTwoTusk_BG21_031:\n\t\t\t// \tconst nonGoldenMinions = boardWithDeadEntity\n\t\t\t// \t\t.filter((e) => e.entityId !== avenger.entityId)\n\t\t\t// \t\t.filter((e) => {\n\t\t\t// \t\t\tconst ref = gameState.allCards.getCard(e.cardId);\n\t\t\t// \t\t\treturn (\n\t\t\t// \t\t\t\t!!ref.battlegroundsPremiumDbfId &&\n\t\t\t// \t\t\t\t!!gameState.allCards.getCardFromDbfId(ref.battlegroundsPremiumDbfId).id\n\t\t\t// \t\t\t);\n\t\t\t// \t\t});\n\t\t\t// \tconst pirate = getRandomAliveMinion(nonGoldenMinions, boardWithDeadEntityHero, Race.PIRATE, gameState);\n\t\t\t// \tif (pirate) {\n\t\t\t// \t\tmakeMinionGolden(\n\t\t\t// \t\t\tpirate,\n\t\t\t// \t\t\tavenger,\n\t\t\t// \t\t\tboardWithDeadEntity,\n\t\t\t// \t\t\tboardWithDeadEntityHero,\n\t\t\t// \t\t\totherBoard,\n\t\t\t// \t\t\totherBoardHero,\n\t\t\t// \t\t\tgameState,\n\t\t\t// \t\t);\n\t\t\t// \t}\n\t\t\t// \tbreak;\n\t\t\t// case CardIds.TonyTwoTusk_BG21_031_G:\n\t\t\t// \tfor (let i = 0; i < 2; i++) {\n\t\t\t// \t\tconst nonGoldenMinions = boardWithDeadEntity.filter((e) => !isMinionGolden(e, gameState.allCards));\n\t\t\t// \t\tconst pirate = getRandomAliveMinion(\n\t\t\t// \t\t\tnonGoldenMinions,\n\t\t\t// \t\t\tboardWithDeadEntityHero,\n\t\t\t// \t\t\tRace.PIRATE,\n\t\t\t// \t\t\tgameState,\n\t\t\t// \t\t);\n\t\t\t// \t\tif (pirate) {\n\t\t\t// \t\t\tmakeMinionGolden(\n\t\t\t// \t\t\t\tpirate,\n\t\t\t// \t\t\t\tavenger,\n\t\t\t// \t\t\t\tboardWithDeadEntity,\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\n\t\t\t// \t\t\t\totherBoard,\n\t\t\t// \t\t\t\totherBoardHero,\n\t\t\t// \t\t\t\tgameState,\n\t\t\t// \t\t\t);\n\t\t\t// \t\t}\n\t\t\t// \t}\n\t\t\t// \tbreak;\n\t\t\tcase CardIds.HungeringAbomination_BG25_014:\n\t\t\tcase CardIds.HungeringAbomination_BG25_014_G:\n\t\t\t\tconst abominationMultiplier = avenger.cardId === CardIds.HungeringAbomination_BG25_014_G ? 2 : 1;\n\t\t\t\tmodifyStats(\n\t\t\t\t\tavenger,\n\t\t\t\t\tavenger,\n\t\t\t\t\tabominationMultiplier * 1,\n\t\t\t\t\tabominationMultiplier * 2,\n\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\tgameState,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t// case CardIds.IceSickle:\n\t\t\t// \tgrantRandomStats(\n\t\t\t// \t\tavenger,\n\t\t\t// \t\tboardWithDeadEntityHero.hand.filter(\n\t\t\t// \t\t\t(e) => gameState.allCards.getCard(e.cardId).type?.toUpperCase() === CardType[CardType.MINION],\n\t\t\t// \t\t),\n\t\t\t// \t\tboardWithDeadEntityHero,\n\t\t\t// \t\t4,\n\t\t\t// \t\t0,\n\t\t\t// \t\tnull,\n\t\t\t// \t\ttrue,\n\t\t\t// \t\tgameState,\n\t\t\t// \t);\n\t\t\t// \tbreak;\n\t\t\tcase CardIds.BoomSquad_BG27_Reward_502:\n\t\t\t\tconst highestHealthMinion = [...otherBoard].sort((a, b) => b.health - a.health)[0];\n\t\t\t\tdealDamageToMinion(\n\t\t\t\t\thighestHealthMinion,\n\t\t\t\t\totherBoard,\n\t\t\t\t\totherBoardHero,\n\t\t\t\t\tavenger,\n\t\t\t\t\t10,\n\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\tgameState,\n\t\t\t\t);\n\t\t\t\tgameState.spectator.registerPowerTarget(\n\t\t\t\t\tavenger,\n\t\t\t\t\thighestHealthMinion,\n\t\t\t\t\totherBoard,\n\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\totherBoardHero,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase CardIds.RelentlessSentry_BG25_003:\n\t\t\tcase CardIds.RelentlessSentry_BG25_003_G:\n\t\t\t\tupdateReborn(avenger, true, boardWithDeadEntity, boardWithDeadEntityHero, otherBoardHero, gameState);\n\t\t\t\tupdateTaunt(avenger, true, boardWithDeadEntity, boardWithDeadEntityHero, otherBoardHero, gameState);\n\t\t\t\tbreak;\n\t\t\tcase CardIds.RelentlessMurghoul_BG27_010:\n\t\t\tcase CardIds.RelentlessMurghoul_BG27_010_G:\n\t\t\t\tupdateReborn(avenger, true, boardWithDeadEntity, boardWithDeadEntityHero, otherBoardHero, gameState);\n\t\t\t\tupdateTaunt(avenger, true, boardWithDeadEntity, boardWithDeadEntityHero, otherBoardHero, gameState);\n\t\t\t\tbreak;\n\t\t\tcase CardIds.PhaerixWrathOfTheSun_BG28_403:\n\t\t\tcase CardIds.PhaerixWrathOfTheSun_BG28_403_G:\n\t\t\t\tconst phaerixLoops = avenger.cardId === CardIds.PhaerixWrathOfTheSun_BG28_403_G ? 2 : 1;\n\t\t\t\tfor (let i = 0; i < phaerixLoops; i++) {\n\t\t\t\t\tgrantRandomDivineShield(\n\t\t\t\t\t\tavenger,\n\t\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\t\totherBoardHero,\n\t\t\t\t\t\tgameState,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CardIds.AugmentedLaborer_BG28_740:\n\t\t\tcase CardIds.AugmentedLaborer_BG28_740_G:\n\t\t\t\tconst AugmentedLaborerLoops = avenger.cardId === CardIds.AugmentedLaborer_BG28_740_G ? 2 : 1;\n\t\t\t\tfor (let i = 0; i < AugmentedLaborerLoops; i++) {\n\t\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, [null], gameState);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CardIds.TumblingDisaster_BG28_Reward_505:\n\t\t\t\tconst tumblingDisasterEntity = boardWithDeadEntityHero.questRewardEntities?.find(\n\t\t\t\t\t(e) => e.cardId === CardIds.TumblingDisaster_BG28_Reward_505,\n\t\t\t\t);\n\t\t\t\tif (tumblingDisasterEntity) {\n\t\t\t\t\ttumblingDisasterEntity.scriptDataNum1 = (tumblingDisasterEntity.scriptDataNum1 ?? 0) + 1;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CardIds.CycleOfEnergy_BG28_Reward_504:\n\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, [null], gameState);\n\t\t\t\tbreak;\n\t\t\tcase CardIds.StableAmalgamation_BG28_Reward_518:\n\t\t\t\tavenger.scriptDataNum1 = (avenger.scriptDataNum1 ?? 0) + 1;\n\t\t\t\tbreak;\n\t\t\tcase CardIds.MurglMkIi_BG29_991:\n\t\t\tcase CardIds.MurglMkIi_BG29_991_G:\n\t\t\t\tconst murglMkStats = avenger.cardId === CardIds.MurglMkIi_BG29_991_G ? 2 : 1;\n\t\t\t\taddStatsToBoard(\n\t\t\t\t\tavenger,\n\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\tmurglMkStats,\n\t\t\t\t\tmurglMkStats,\n\t\t\t\t\tgameState,\n\t\t\t\t);\n\t\t\t\t// Don't use utility methods, as we don't want triggers to proc\n\t\t\t\tfor (const e of boardWithDeadEntityHero.hand ?? []) {\n\t\t\t\t\te.attack += murglMkStats;\n\t\t\t\t\te.health += murglMkStats;\n\t\t\t\t\te.maxHealth += murglMkStats;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CardIds.StaffOfTheScourge_BG30_MagicItem_437:\n\t\t\t\tif (boardWithDeadEntity.length > 0) {\n\t\t\t\t\tconst candidates = boardWithDeadEntity.filter(\n\t\t\t\t\t\t(e) =>\n\t\t\t\t\t\t\t!e.reborn &&\n\t\t\t\t\t\t\thasCorrectTribe(\n\t\t\t\t\t\t\t\te,\n\t\t\t\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\t\t\t\tRace.UNDEAD,\n\t\t\t\t\t\t\t\tgameState.anomalies,\n\t\t\t\t\t\t\t\tgameState.allCards,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tconst target = pickRandom(candidates);\n\t\t\t\t\tif (!!target) {\n\t\t\t\t\t\tupdateReborn(\n\t\t\t\t\t\t\ttarget,\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\t\t\totherBoardHero,\n\t\t\t\t\t\t\tgameState,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\n\t\t\t\t\t\t\tavenger,\n\t\t\t\t\t\t\ttarget,\n\t\t\t\t\t\t\tboardWithDeadEntity,\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\t\t\t\totherBoardHero,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CardIds.BleedingHeart_BG30_MagicItem_713:\n\t\t\t\tconst randomUndead = gameState.cardsData.getRandomMinionForTribe(\n\t\t\t\t\tRace.UNDEAD,\n\t\t\t\t\tboardWithDeadEntityHero.tavernTier,\n\t\t\t\t);\n\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, [randomUndead], gameState);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\tavenger.avengeCurrent += avenger.avengeDefault;\n};\n\nconst handleHeroAvenge = (\n\tdeadEntity: BoardEntity,\n\theroPower: BgsHeroPower,\n\tboardWithDeadEntity: BoardEntity[],\n\tboardWithDeadEntityHero: BgsPlayerEntity,\n\totherBoard: BoardEntity[],\n\totherBoardHero: BgsPlayerEntity,\n\tcandidatesEntitiesSpawnedFromAvenge: BoardEntity[],\n\tgameState: FullGameState,\n) => {\n\t// https://twitter.com/LoewenMitchell/status/1491879869457879040\n\t// Not affected by Khadgar\n\tswitch (heroPower.cardId) {\n\t\tcase CardIds.Onyxia_Broodmother:\n\t\t\tconst broodmotherTokens = spawnEntities(\n\t\t\t\tCardIds.Onyxia_OnyxianWhelpToken,\n\t\t\t\t1,\n\t\t\t\tboardWithDeadEntity,\n\t\t\t\tboardWithDeadEntityHero,\n\t\t\t\totherBoard,\n\t\t\t\totherBoardHero,\n\t\t\t\tgameState,\n\t\t\t\tdeadEntity.friendly,\n\t\t\t\tfalse,\n\t\t\t\tfalse,\n\t\t\t\tfalse,\n\t\t\t);\n\t\t\tbroodmotherTokens.forEach((token) => {\n\t\t\t\ttoken.attack = +heroPower.info;\n\t\t\t\ttoken.health = +heroPower.info;\n\t\t\t\ttoken.maxAttack = +heroPower.info;\n\t\t\t\ttoken.maxHealth = +heroPower.info;\n\t\t\t});\n\t\t\theroPower.info = +heroPower.info + 1;\n\t\t\tcandidatesEntitiesSpawnedFromAvenge.push(...broodmotherTokens);\n\t\t\tbreak;\n\t}\n\theroPower.avengeCurrent += heroPower.avengeDefault;\n};\n\nexport interface AvengeInput {\n\treadonly board: BoardEntity[];\n\treadonly deadEntity: BoardEntity;\n\treadonly hero: BgsPlayerEntity;\n\treadonly otherBoard: BoardEntity[];\n\treadonly otherHero: BgsPlayerEntity;\n\treadonly gameState: FullGameState;\n}\n"]}
@@ -109,11 +109,8 @@ exports.applyBloodGemEnchantment = applyBloodGemEnchantment;
109
109
  const isBloodGem = (cardId) => {
110
110
  return (cardId === "BG20_GEM" ||
111
111
  cardId === "BG20_GEM_Reborn" ||
112
- cardId === "BG20_GEM_Reborn_G" ||
113
112
  cardId === "BG20_GEM_Taunt" ||
114
- cardId === "BG20_GEM_Taunt_G" ||
115
- cardId === "BG20_GEM_DivineShield" ||
116
- cardId === "BG20_GEM_DivineShield_G");
113
+ cardId === "BG20_GEM_DivineShield");
117
114
  };
118
115
  exports.isBloodGem = isBloodGem;
119
116
  //# sourceMappingURL=blood-gems.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"blood-gems.js","sourceRoot":"","sources":["../../src/simulation/blood-gems.ts"],"names":[],"mappings":";;;AAEA,4DAA0F;AAC1F,iEAA4D;AAC5D,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AAC,CAAC;AAvBW,QAAA,wBAAwB,4BAuBnC;AAEK,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,EAAE;IAC5C,OAAO,CACN,MAAM,eAAqB;QAC3B,MAAM,sBAAqC;QAC3C,MAAM,wBAAuC;QAC7C,MAAM,qBAAyC;QAC/C,MAAM,uBAA2C;QACjD,MAAM,4BAA2C;QACjD,MAAM,8BAA6C,CACnD,CAAC;AACH,CAAC,CAAC;AAVW,QAAA,UAAU,cAUrB","sourcesContent":["import { BgsPlayerEntity, BoardTrinket } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { hasPlayedBloodGemsOnAny, hasPlayedBloodGemsOnMe } from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { updateDivineShield } from '../keywords/divine-shield';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { findLast, pickRandom } from '../services/utils';\r\nimport { getMinionsOfDifferentTypes } from '../utils';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { modifyStats } from './stats';\r\n\r\nexport const playBloodGemsOn = (\r\n\tsource: BoardEntity | BoardTrinket | BgsPlayerEntity,\r\n\ttarget: BoardEntity,\r\n\tquantity: number,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tregisterTarget = true,\r\n) => {\r\n\tif (registerTarget) {\r\n\t\tgameState.spectator.registerPowerTarget(source, target, board, null, null);\r\n\t}\r\n\r\n\tconst bloodGemBaseAttack =\r\n\t\t1 +\r\n\t\t(hero.globalInfo?.BloodGemAttackBonus ?? 0) +\r\n\t\thero.trinkets.filter((t) => t.cardId === CardIds.GreatBoarSticker_BG30_MagicItem_988).length * 2 +\r\n\t\thero.trinkets.filter((t) => t.cardId === CardIds.GreatBoarSticker_GreatBoarStickerToken_BG30_MagicItem_988t)\r\n\t\t\t.length *\r\n\t\t\t3;\r\n\tconst bloodGemBaseHealth =\r\n\t\t1 +\r\n\t\t(hero.globalInfo?.BloodGemHealthBonus ?? 0) +\r\n\t\thero.trinkets.filter((t) => t.cardId === CardIds.GreatBoarSticker_BG30_MagicItem_988).length * 1 +\r\n\t\thero.trinkets.filter((t) => t.cardId === CardIds.GreatBoarSticker_GreatBoarStickerToken_BG30_MagicItem_988t)\r\n\t\t\t.length *\r\n\t\t\t3;\r\n\r\n\tconst crones = board.filter((e) => e.cardId === CardIds.NeedlingCrone_BG32_432).length;\r\n\tconst goldenCrones = board.filter((e) => e.cardId === CardIds.NeedlingCrone_BG32_432_G).length;\r\n\tconst cronesMult = goldenCrones > 0 ? 3 : crones > 0 ? 2 : 1;\r\n\tconst bloodGemAttack = bloodGemBaseAttack * cronesMult;\r\n\tconst bloodGemHealth = bloodGemBaseHealth * cronesMult;\r\n\r\n\tapplyBloodGemEnchantment(\r\n\t\tCardIds.BloodGem_BloodGemEnchantment,\r\n\t\ttarget,\r\n\t\tsource,\r\n\t\tquantity,\r\n\t\tbloodGemAttack,\r\n\t\tbloodGemHealth,\r\n\t);\r\n\tapplyBloodGemEnchantment(\r\n\t\tCardIds.BloodGem_BloodGemsEnchantment,\r\n\t\ttarget,\r\n\t\tsource,\r\n\t\tquantity,\r\n\t\tbloodGemAttack,\r\n\t\tbloodGemHealth,\r\n\t);\r\n\r\n\t// This seems to be a single \"modifyStats\" call\r\n\t// 33.6 https://replays.firestoneapp.com/?reviewId=51f93537-182d-4fb8-bf41-1b4429341e01&turn=19&action=3\r\n\tmodifyStats(target, null, quantity * bloodGemAttack, quantity * bloodGemHealth, board, hero, gameState, false);\r\n\t// for (let i = 0; i < quantity; i++) {\r\n\t// }\r\n\r\n\tfor (let i = 0; i < quantity; i++) {\r\n\t\tswitch (target.cardId) {\r\n\t\t\tcase CardIds.ToughTusk_BG20_102:\r\n\t\t\tcase CardIds.ToughTusk_BG20_102_G:\r\n\t\t\t\tif (!target.divineShield) {\r\n\t\t\t\t\tupdateDivineShield(target, board, hero, null, true, gameState);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(target, target, board, null, null);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.GeomagusRoogug_BG28_583:\r\n\t\t\tcase CardIds.GeomagusRoogug_BG28_583_G:\r\n\t\t\t\tconst roogugTargets = board.filter(\r\n\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\te.cardId !== CardIds.GeomagusRoogug_BG28_583 && e.cardId !== CardIds.GeomagusRoogug_BG28_583_G,\r\n\t\t\t\t);\r\n\t\t\t\tconst roogugTarget = pickRandom(roogugTargets);\r\n\t\t\t\tif (roogugTarget) {\r\n\t\t\t\t\tconst roogugBuff = target.cardId === CardIds.GeomagusRoogug_BG28_583_G ? 2 : 1;\r\n\t\t\t\t\tplayBloodGemsOn(\r\n\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\troogugTarget,\r\n\t\t\t\t\t\troogugBuff,\r\n\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\thero,\r\n\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\totherHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\tfalse,\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.AggemThorncurse_BG20_302:\r\n\t\t\tcase CardIds.AggemThorncurse_BG20_302_G:\r\n\t\t\t\t// console.debug('playing blood gem on Aggem Thorncurse', target.cardId);\r\n\t\t\t\tconst aggemGemsToPlay = target.cardId === CardIds.AggemThorncurse_BG20_302_G ? 2 : 1;\r\n\t\t\t\tconst candidates = getMinionsOfDifferentTypes(\r\n\t\t\t\t\tboard.filter(\r\n\t\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\t\te.cardId !== CardIds.AggemThorncurse_BG20_302 &&\r\n\t\t\t\t\t\t\te.cardId !== CardIds.AggemThorncurse_BG20_302_G,\r\n\t\t\t\t\t),\r\n\t\t\t\t\thero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t\tfor (const candidate of candidates) {\r\n\t\t\t\t\tplayBloodGemsOn(\r\n\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\tcandidate,\r\n\t\t\t\t\t\taggemGemsToPlay,\r\n\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\thero,\r\n\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\totherHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tconst playedBloodGemsOnMeImpl = cardMappings[target.cardId];\r\n\t\t\t\tif (hasPlayedBloodGemsOnMe(playedBloodGemsOnMeImpl)) {\r\n\t\t\t\t\tplayedBloodGemsOnMeImpl.playedBloodGemsOnMe(target, {\r\n\t\t\t\t\t\tboard: board,\r\n\t\t\t\t\t\thero: hero,\r\n\t\t\t\t\t\totherBoard: otherBoard,\r\n\t\t\t\t\t\totherHero: otherHero,\r\n\t\t\t\t\t\tgameState: gameState,\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t}\r\n\r\n\t\tfor (const boardEntity of board) {\r\n\t\t\tconst playedBloodGemsOnAnyImpl = cardMappings[boardEntity.cardId];\r\n\t\t\tif (hasPlayedBloodGemsOnAny(playedBloodGemsOnAnyImpl)) {\r\n\t\t\t\tplayedBloodGemsOnAnyImpl.playedBloodGemsOnAny(boardEntity, {\r\n\t\t\t\t\tsource: source,\r\n\t\t\t\t\ttarget: target,\r\n\t\t\t\t\tboard: board,\r\n\t\t\t\t\thero: hero,\r\n\t\t\t\t\totherBoard: otherBoard,\r\n\t\t\t\t\totherHero: otherHero,\r\n\t\t\t\t\tgameState: gameState,\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyBloodGemEnchantment = (\r\n\tenchantmentCardId: string,\r\n\ttarget: BoardEntity,\r\n\tsource: BoardEntity | BoardTrinket | BgsPlayerEntity,\r\n\tquantity: number,\r\n\tbloodGemAttack: number,\r\n\tbloodGemHealth: number,\r\n) => {\r\n\tlet enchantment = findLast(target.enchantments, (e) => e.cardId === enchantmentCardId);\r\n\tif (!enchantment) {\r\n\t\tenchantment = {\r\n\t\t\tcardId: enchantmentCardId,\r\n\t\t\toriginEntityId: source.entityId,\r\n\t\t\ttiming: 0,\r\n\t\t\ttagScriptDataNum1: 0,\r\n\t\t\ttagScriptDataNum2: 0,\r\n\t\t};\r\n\t\ttarget.enchantments.push(enchantment);\r\n\t}\r\n\tfor (let i = 0; i < quantity; i++) {\r\n\t\tenchantment.tagScriptDataNum1 += bloodGemAttack;\r\n\t\tenchantment.tagScriptDataNum2 += bloodGemHealth;\r\n\t}\r\n};\r\n\r\nexport const isBloodGem = (cardId: string) => {\r\n\treturn (\r\n\t\tcardId === CardIds.BloodGem ||\r\n\t\tcardId === CardIds.BloodGem_BG20_GEM_Reborn ||\r\n\t\tcardId === CardIds.BloodGem_BG20_GEM_Reborn_G ||\r\n\t\tcardId === CardIds.BloodGemToken_BG20_GEM_Taunt ||\r\n\t\tcardId === CardIds.BloodGemToken_BG20_GEM_Taunt_G ||\r\n\t\tcardId === CardIds.BloodGem_BG20_GEM_DivineShield ||\r\n\t\tcardId === CardIds.BloodGem_BG20_GEM_DivineShield_G\r\n\t);\r\n};\r\n\r\nexport interface PlayedBloodGemsOnMeInput {\r\n\tboard: BoardEntity[];\r\n\thero: BgsPlayerEntity;\r\n\totherBoard: BoardEntity[];\r\n\totherHero: BgsPlayerEntity;\r\n\tgameState: FullGameState;\r\n}\r\n\r\nexport interface PlayedBloodGemsOnAnyInput {\r\n\tsource: BoardEntity | BoardTrinket | BgsPlayerEntity;\r\n\ttarget: BoardEntity;\r\n\tboard: BoardEntity[];\r\n\thero: BgsPlayerEntity;\r\n\totherBoard: BoardEntity[];\r\n\totherHero: BgsPlayerEntity;\r\n\tgameState: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,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE;QAClC,WAAW,CAAC,iBAAiB,IAAI,cAAc,CAAC;QAChD,WAAW,CAAC,iBAAiB,IAAI,cAAc,CAAC;KAChD;AACF,CAAC,CAAC;AAvBW,QAAA,wBAAwB,4BAuBnC;AAEK,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,EAAE;IAC5C,OAAO,CACN,MAAM,eAAqB;QAC3B,MAAM,sBAAqC;QAC3C,MAAM,qBAAyC;QAC/C,MAAM,4BAA2C,CACjD,CAAC;AACH,CAAC,CAAC;AAPW,QAAA,UAAU,cAOrB","sourcesContent":["import { BgsPlayerEntity, BoardTrinket } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { hasPlayedBloodGemsOnAny, hasPlayedBloodGemsOnMe } from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { updateDivineShield } from '../keywords/divine-shield';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { findLast, pickRandom } from '../services/utils';\r\nimport { getMinionsOfDifferentTypes } from '../utils';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { modifyStats } from './stats';\r\n\r\nexport const playBloodGemsOn = (\r\n\tsource: BoardEntity | BoardTrinket | BgsPlayerEntity,\r\n\ttarget: BoardEntity,\r\n\tquantity: number,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tregisterTarget = true,\r\n) => {\r\n\tif (registerTarget) {\r\n\t\tgameState.spectator.registerPowerTarget(source, target, board, null, null);\r\n\t}\r\n\r\n\tconst bloodGemBaseAttack =\r\n\t\t1 +\r\n\t\t(hero.globalInfo?.BloodGemAttackBonus ?? 0) +\r\n\t\thero.trinkets.filter((t) => t.cardId === CardIds.GreatBoarSticker_BG30_MagicItem_988).length * 2 +\r\n\t\thero.trinkets.filter((t) => t.cardId === CardIds.GreatBoarSticker_GreatBoarStickerToken_BG30_MagicItem_988t)\r\n\t\t\t.length *\r\n\t\t\t3;\r\n\tconst bloodGemBaseHealth =\r\n\t\t1 +\r\n\t\t(hero.globalInfo?.BloodGemHealthBonus ?? 0) +\r\n\t\thero.trinkets.filter((t) => t.cardId === CardIds.GreatBoarSticker_BG30_MagicItem_988).length * 1 +\r\n\t\thero.trinkets.filter((t) => t.cardId === CardIds.GreatBoarSticker_GreatBoarStickerToken_BG30_MagicItem_988t)\r\n\t\t\t.length *\r\n\t\t\t3;\r\n\r\n\tconst crones = board.filter((e) => e.cardId === CardIds.NeedlingCrone_BG32_432).length;\r\n\tconst goldenCrones = board.filter((e) => e.cardId === CardIds.NeedlingCrone_BG32_432_G).length;\r\n\tconst cronesMult = goldenCrones > 0 ? 3 : crones > 0 ? 2 : 1;\r\n\tconst bloodGemAttack = bloodGemBaseAttack * cronesMult;\r\n\tconst bloodGemHealth = bloodGemBaseHealth * cronesMult;\r\n\r\n\tapplyBloodGemEnchantment(\r\n\t\tCardIds.BloodGem_BloodGemEnchantment,\r\n\t\ttarget,\r\n\t\tsource,\r\n\t\tquantity,\r\n\t\tbloodGemAttack,\r\n\t\tbloodGemHealth,\r\n\t);\r\n\tapplyBloodGemEnchantment(\r\n\t\tCardIds.BloodGem_BloodGemsEnchantment,\r\n\t\ttarget,\r\n\t\tsource,\r\n\t\tquantity,\r\n\t\tbloodGemAttack,\r\n\t\tbloodGemHealth,\r\n\t);\r\n\r\n\t// This seems to be a single \"modifyStats\" call\r\n\t// 33.6 https://replays.firestoneapp.com/?reviewId=51f93537-182d-4fb8-bf41-1b4429341e01&turn=19&action=3\r\n\tmodifyStats(target, null, quantity * bloodGemAttack, quantity * bloodGemHealth, board, hero, gameState, false);\r\n\t// for (let i = 0; i < quantity; i++) {\r\n\t// }\r\n\r\n\tfor (let i = 0; i < quantity; i++) {\r\n\t\tswitch (target.cardId) {\r\n\t\t\tcase CardIds.ToughTusk_BG20_102:\r\n\t\t\tcase CardIds.ToughTusk_BG20_102_G:\r\n\t\t\t\tif (!target.divineShield) {\r\n\t\t\t\t\tupdateDivineShield(target, board, hero, null, true, gameState);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(target, target, board, null, null);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.GeomagusRoogug_BG28_583:\r\n\t\t\tcase CardIds.GeomagusRoogug_BG28_583_G:\r\n\t\t\t\tconst roogugTargets = board.filter(\r\n\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\te.cardId !== CardIds.GeomagusRoogug_BG28_583 && e.cardId !== CardIds.GeomagusRoogug_BG28_583_G,\r\n\t\t\t\t);\r\n\t\t\t\tconst roogugTarget = pickRandom(roogugTargets);\r\n\t\t\t\tif (roogugTarget) {\r\n\t\t\t\t\tconst roogugBuff = target.cardId === CardIds.GeomagusRoogug_BG28_583_G ? 2 : 1;\r\n\t\t\t\t\tplayBloodGemsOn(\r\n\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\troogugTarget,\r\n\t\t\t\t\t\troogugBuff,\r\n\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\thero,\r\n\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\totherHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\tfalse,\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.AggemThorncurse_BG20_302:\r\n\t\t\tcase CardIds.AggemThorncurse_BG20_302_G:\r\n\t\t\t\t// console.debug('playing blood gem on Aggem Thorncurse', target.cardId);\r\n\t\t\t\tconst aggemGemsToPlay = target.cardId === CardIds.AggemThorncurse_BG20_302_G ? 2 : 1;\r\n\t\t\t\tconst candidates = getMinionsOfDifferentTypes(\r\n\t\t\t\t\tboard.filter(\r\n\t\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\t\te.cardId !== CardIds.AggemThorncurse_BG20_302 &&\r\n\t\t\t\t\t\t\te.cardId !== CardIds.AggemThorncurse_BG20_302_G,\r\n\t\t\t\t\t),\r\n\t\t\t\t\thero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t\tfor (const candidate of candidates) {\r\n\t\t\t\t\tplayBloodGemsOn(\r\n\t\t\t\t\t\ttarget,\r\n\t\t\t\t\t\tcandidate,\r\n\t\t\t\t\t\taggemGemsToPlay,\r\n\t\t\t\t\t\tboard,\r\n\t\t\t\t\t\thero,\r\n\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\totherHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tconst playedBloodGemsOnMeImpl = cardMappings[target.cardId];\r\n\t\t\t\tif (hasPlayedBloodGemsOnMe(playedBloodGemsOnMeImpl)) {\r\n\t\t\t\t\tplayedBloodGemsOnMeImpl.playedBloodGemsOnMe(target, {\r\n\t\t\t\t\t\tboard: board,\r\n\t\t\t\t\t\thero: hero,\r\n\t\t\t\t\t\totherBoard: otherBoard,\r\n\t\t\t\t\t\totherHero: otherHero,\r\n\t\t\t\t\t\tgameState: gameState,\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t}\r\n\r\n\t\tfor (const boardEntity of board) {\r\n\t\t\tconst playedBloodGemsOnAnyImpl = cardMappings[boardEntity.cardId];\r\n\t\t\tif (hasPlayedBloodGemsOnAny(playedBloodGemsOnAnyImpl)) {\r\n\t\t\t\tplayedBloodGemsOnAnyImpl.playedBloodGemsOnAny(boardEntity, {\r\n\t\t\t\t\tsource: source,\r\n\t\t\t\t\ttarget: target,\r\n\t\t\t\t\tboard: board,\r\n\t\t\t\t\thero: hero,\r\n\t\t\t\t\totherBoard: otherBoard,\r\n\t\t\t\t\totherHero: otherHero,\r\n\t\t\t\t\tgameState: gameState,\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyBloodGemEnchantment = (\r\n\tenchantmentCardId: string,\r\n\ttarget: BoardEntity,\r\n\tsource: BoardEntity | BoardTrinket | BgsPlayerEntity,\r\n\tquantity: number,\r\n\tbloodGemAttack: number,\r\n\tbloodGemHealth: number,\r\n) => {\r\n\tlet enchantment = findLast(target.enchantments, (e) => e.cardId === enchantmentCardId);\r\n\tif (!enchantment) {\r\n\t\tenchantment = {\r\n\t\t\tcardId: enchantmentCardId,\r\n\t\t\toriginEntityId: source.entityId,\r\n\t\t\ttiming: 0,\r\n\t\t\ttagScriptDataNum1: 0,\r\n\t\t\ttagScriptDataNum2: 0,\r\n\t\t};\r\n\t\ttarget.enchantments.push(enchantment);\r\n\t}\r\n\tfor (let i = 0; i < quantity; i++) {\r\n\t\tenchantment.tagScriptDataNum1 += bloodGemAttack;\r\n\t\tenchantment.tagScriptDataNum2 += bloodGemHealth;\r\n\t}\r\n};\r\n\r\nexport const isBloodGem = (cardId: string) => {\r\n\treturn (\r\n\t\tcardId === CardIds.BloodGem ||\r\n\t\tcardId === CardIds.BloodGem_BG20_GEM_Reborn ||\r\n\t\tcardId === CardIds.BloodGemToken_BG20_GEM_Taunt ||\r\n\t\tcardId === CardIds.BloodGem_BG20_GEM_DivineShield\r\n\t);\r\n};\r\n\r\nexport interface PlayedBloodGemsOnMeInput {\r\n\tboard: BoardEntity[];\r\n\thero: BgsPlayerEntity;\r\n\totherBoard: BoardEntity[];\r\n\totherHero: BgsPlayerEntity;\r\n\tgameState: FullGameState;\r\n}\r\n\r\nexport interface PlayedBloodGemsOnAnyInput {\r\n\tsource: BoardEntity | BoardTrinket | BgsPlayerEntity;\r\n\ttarget: BoardEntity;\r\n\tboard: BoardEntity[];\r\n\thero: BgsPlayerEntity;\r\n\totherBoard: BoardEntity[];\r\n\totherHero: BgsPlayerEntity;\r\n\tgameState: FullGameState;\r\n}\r\n"]}
@@ -66,30 +66,32 @@ const handleRebornForEntity = (boardWithKilledMinion, boardWithKilledMinionHero,
66
66
  var _a;
67
67
  entity.hasAttacked = deadEntity.hasAttacked > 1 ? 1 : (_a = entityRightToSpawns === null || entityRightToSpawns === void 0 ? void 0 : entityRightToSpawns.hasAttacked) !== null && _a !== void 0 ? _a : undefined;
68
68
  });
69
- for (const entity of boardWithKilledMinion) {
70
- const rebornImpl = _card_mappings_1.cardMappings[entity.cardId];
71
- if ((0, card_interface_1.hasAfterReborn)(rebornImpl)) {
72
- rebornImpl.afterReborn(entity, {
73
- rebornEntity: deadEntity,
74
- boardWithKilledMinion,
75
- boardWithKilledMinionHero,
76
- opponentBoard,
77
- opponentBoardHero,
78
- gameState,
79
- });
69
+ for (const rebornEntity of entitiesThatWereReborn) {
70
+ for (const entity of boardWithKilledMinion) {
71
+ const rebornImpl = _card_mappings_1.cardMappings[entity.cardId];
72
+ if ((0, card_interface_1.hasAfterReborn)(rebornImpl)) {
73
+ rebornImpl.afterReborn(entity, {
74
+ rebornEntity: rebornEntity,
75
+ boardWithKilledMinion,
76
+ boardWithKilledMinionHero,
77
+ opponentBoard,
78
+ opponentBoardHero,
79
+ gameState,
80
+ });
81
+ }
80
82
  }
81
- }
82
- for (const trinket of (_b = boardWithKilledMinionHero.trinkets) !== null && _b !== void 0 ? _b : []) {
83
- const rebornImpl = _card_mappings_1.cardMappings[trinket.cardId];
84
- if ((0, card_interface_1.hasAfterReborn)(rebornImpl)) {
85
- rebornImpl.afterReborn(trinket, {
86
- rebornEntity: deadEntity,
87
- boardWithKilledMinion,
88
- boardWithKilledMinionHero,
89
- opponentBoard,
90
- opponentBoardHero,
91
- gameState,
92
- });
83
+ for (const trinket of (_b = boardWithKilledMinionHero.trinkets) !== null && _b !== void 0 ? _b : []) {
84
+ const rebornImpl = _card_mappings_1.cardMappings[trinket.cardId];
85
+ if ((0, card_interface_1.hasAfterReborn)(rebornImpl)) {
86
+ rebornImpl.afterReborn(trinket, {
87
+ rebornEntity: rebornEntity,
88
+ boardWithKilledMinion,
89
+ boardWithKilledMinionHero,
90
+ opponentBoard,
91
+ opponentBoardHero,
92
+ gameState,
93
+ });
94
+ }
93
95
  }
94
96
  }
95
97
  boardWithKilledMinion