@firestone-hs/simulate-bgs-battle 1.1.184 → 1.1.185
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.
|
@@ -121,7 +121,7 @@ const handleTamsinForPlayer = (playerBoard, playerEntity, opponentBoard, opponen
|
|
|
121
121
|
const entitiesWithLowestHealth = playerBoard.filter((e) => e.health === lowestHealth);
|
|
122
122
|
const chosenEntity = utils_1.pickRandom(entitiesWithLowestHealth);
|
|
123
123
|
const newBoard = playerBoard.filter((e) => e.entityId !== chosenEntity.entityId);
|
|
124
|
-
const buffedEntities = utils_1.pickMultipleRandomDifferent(newBoard,
|
|
124
|
+
const buffedEntities = utils_1.pickMultipleRandomDifferent(newBoard, 5);
|
|
125
125
|
chosenEntity.definitelyDead = true;
|
|
126
126
|
buffedEntities.forEach((e) => {
|
|
127
127
|
utils_2.modifyAttack(e, chosenEntity.attack, newBoard, allCards);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-of-combat.js","sourceRoot":"","sources":["../../src/simulation/start-of-combat.ts"],"names":[],"mappings":";;;AACA,iEAA8E;AAI9E,oDAA0E;AAC1E,6CAA4E;AAC5E,oCAAwF;AACxF,qCAAyH;AACzH,mCAAkD;AAClD,+DAK+B;AAIxB,MAAM,mBAAmB,GAAG,CAClC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,QAAyB,EACzB,MAAiB,EACjB,WAAwB,EACxB,SAAuB,EACvB,SAAoB,EACX,EAAE;IAKX,eAAe,GAAG,yBAAyB,CAC1C,YAAY,EACZ,WAAW,EACX,cAAc,EACd,aAAa,EACb,eAAe,EACf,QAAQ,EACR,MAAM,EACN,WAAW,EACX,SAAS,EACT,SAAS,CACT,CAAC;IAEF,MAAM,iBAAiB,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAM,CAAC,EAAG,CAAC,CAAC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,CAAC,MAAM,CAAC,YAAY,EAAE;QACzB,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;KACpC;IACD,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;QACrB,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;KAC/B;IACD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;QAClB,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KAC5B;IACD,OAAO,kBAAU,CAAC,aAAa,CAAC,CAAC;AAClC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsGameState } from '../bgs-battle-info';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardsData, START_OF_COMBAT_CARD_IDS } from '../cards/cards-data';\r\nimport { pickMultipleRandomDifferent, pickRandom } from '../services/utils';\r\nimport { afterStatsUpdate, isCorrectTribe, modifyAttack, modifyHealth } from '../utils';\r\nimport { dealDamageToEnemy, dealDamageToRandomEnemy, getNeighbours, processMinionDeath, simulateAttack } from './attack';\r\nimport { applyAuras, removeAuras } from './auras';\r\nimport {\r\n\tapplyEarthInvocationEnchantment,\r\n\tapplyFireInvocationEnchantment,\r\n\tapplyLightningInvocationEnchantment,\r\n\tapplyWaterInvocationEnchantment,\r\n} from './deathrattle-effects';\r\nimport { SharedState } from './shared-state';\r\nimport { Spectator } from './spectator/spectator';\r\n\r\nexport const handleStartOfCombat = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// https://twitter.com/DCalkosz/status/1488361384320528388?s=20&t=1ECxRZFdjqwEa2fRsXk32Q\r\n\t// There’s a certain order for Start of Combat hero powers, rather than “coin flips” where\r\n\t// an unlucky trigger order could mess up some positioning you had planned for your own hero\r\n\t// power. “Precombat” (Al’Akir, Y’Shaarj), then Illidan, then others.\r\n\tcurrentAttacker = handlePreCombatHeroPowers(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\t// Because start of combat powers like Red Whelp's use the board composition before Illidan's strike to know the amount of damage\r\n\tconst playerBoardBefore = playerBoard.map((e) => ({ ...e }));\r\n\tconst opponentBoardBefore = opponentBoard.map((e) => ({ ...e }));\r\n\tcurrentAttacker = handleIllidanHeroPowers(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\tcurrentAttacker = handleStartOfCombatHeroPowers(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\tcurrentAttacker = handleStartOfCombatMinions(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tplayerBoardBefore,\r\n\t\topponentBoardBefore,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePreCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// Some are part of the incoming board: Y'Shaarj, Lich King\r\n\t// Since the order is not important here, we just always do the player first\r\n\tconst playerHeroPowerId = playerEntity.heroPowerId || getHeroPowerForHero(playerEntity.cardId);\r\n\tif (playerHeroPowerId === CardIds.SwattingInsectsBattlegrounds && playerBoard.length > 0) {\r\n\t\t// Should be sent by the app, but it is an idempotent operation, so we can just reapply it here\r\n\t\thandleAlakirForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, spawns, sharedState, spectator);\r\n\t}\r\n\r\n\tconst opponentHeroPowerId = opponentEntity.heroPowerId || getHeroPowerForHero(opponentEntity.cardId);\r\n\tif (opponentHeroPowerId === CardIds.SwattingInsectsBattlegrounds && opponentBoard.length > 0) {\r\n\t\thandleAlakirForPlayer(opponentBoard, opponentEntity, playerBoard, playerEntity, allCards, spawns, sharedState, spectator);\r\n\t}\r\n\r\n\treturn currentAttacker;\r\n};\r\n\r\nexport const handleIllidanHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// console.log('current attacker before', currentAttacker);\r\n\t// Apparently it's a toin coss about whether to handle Illidan first or Al'Akir first\r\n\t// Auras are only relevant for Illidan, and already applied there\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else {\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\tprocessMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t// console.log('current attacker after', currentAttacker);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatMinions = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tplayerBoardBefore: BoardEntity[],\r\n\topponentBoardBefore: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\tlet attackerForStart = currentAttacker;\r\n\tconst playerAttackers = playerBoard.filter((entity) => START_OF_COMBAT_CARD_IDS.indexOf(entity.cardId as CardIds) !== -1);\r\n\tconst opponentAttackers = opponentBoard.filter((entity) => START_OF_COMBAT_CARD_IDS.indexOf(entity.cardId as CardIds) !== -1);\r\n\twhile (playerAttackers.length > 0 || opponentAttackers.length > 0) {\r\n\t\tif (attackerForStart === 0 && playerAttackers.length > 0) {\r\n\t\t\tconst attacker = playerAttackers.splice(0, 1)[0];\r\n\t\t\tperformStartOfCombatMinionsForPlayer(\r\n\t\t\t\tattacker,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tplayerBoardBefore,\r\n\t\t\t\topponentBoardBefore,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspawns,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tgameState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t} else if (attackerForStart === 1 && opponentAttackers.length > 0) {\r\n\t\t\tconst attacker = opponentAttackers.splice(0, 1)[0];\r\n\t\t\tperformStartOfCombatMinionsForPlayer(\r\n\t\t\t\tattacker,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoardBefore,\r\n\t\t\t\tplayerBoardBefore,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspawns,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tgameState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t\tattackerForStart = (attackerForStart + 1) % 2;\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\nexport const handleStartOfCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\tconst attackingHeroPowerId = playerEntity.heroPowerId || getHeroPowerForHero(playerEntity.cardId);\r\n\tconst defendingHeroPowerId = opponentEntity.heroPowerId || getHeroPowerForHero(opponentEntity.cardId);\r\n\tconst numberOfDeathwingPresents =\r\n\t\t(attackingHeroPowerId === CardIds.AllWillBurnBattlegrounds ? 1 : 0) +\r\n\t\t(defendingHeroPowerId === CardIds.AllWillBurnBattlegrounds ? 1 : 0);\r\n\tapplyAuras(playerBoard, numberOfDeathwingPresents, cardsData, allCards);\r\n\tapplyAuras(opponentBoard, numberOfDeathwingPresents, cardsData, allCards);\r\n\r\n\t// Apparently it's a toin coss about whether to handle Illidan first or Al'Akir first\r\n\t// Auras are only relevant for Illidan, and already applied there\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else {\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\tremoveAuras(playerBoard, cardsData);\r\n\tremoveAuras(opponentBoard, cardsData);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePlayerIllidanHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tfriendly: boolean,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\tconst playerHeroPowerId = playerEntity.heroPowerId || getHeroPowerForHero(playerEntity.cardId);\r\n\tif (playerHeroPowerId === CardIds.WingmenBattlegrounds && playerBoard.length > 0) {\r\n\t\thandleIllidanForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, spawns, sharedState, spectator);\r\n\t\tcurrentAttacker = (currentAttacker + 1) % 2;\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\n// TODO: not exactly correct, because of \"attack immediately\", but it's close enough\r\nconst handleIllidanForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// Otherwise, if the first minion dies on the attack, and the board has only 2 minions, we\r\n\t// miss the second one\r\n\tconst minionsAtStart = playerBoard.length;\r\n\tconst firstAttacker = playerBoard[0];\r\n\tconst secondAttacker = minionsAtStart > 1 ? playerBoard[playerBoard.length - 1] : null;\r\n\r\n\tmodifyAttack(firstAttacker, 2, playerBoard, allCards);\r\n\tafterStatsUpdate(firstAttacker, playerBoard, allCards);\r\n\tspectator.registerPowerTarget(firstAttacker, firstAttacker, playerBoard);\r\n\tif (\r\n\t\tplayerBoard.map((e) => e.cardId).includes(CardIds.EclipsionIllidariBattlegrounds2) ||\r\n\t\tplayerBoard.map((e) => e.cardId).includes(CardIds.EclipsionIllidariBattlegrounds1)\r\n\t) {\r\n\t\tfirstAttacker.immuneWhenAttackCharges = 1;\r\n\t}\r\n\tsimulateAttack(playerBoard, playerEntity, opponentBoard, opponentEntity, undefined, allCards, spawns, sharedState, spectator, 0);\r\n\r\n\tif (!!secondAttacker && !secondAttacker.definitelyDead && secondAttacker.health > 0) {\r\n\t\tmodifyAttack(secondAttacker, 2, playerBoard, allCards);\r\n\t\tafterStatsUpdate(secondAttacker, playerBoard, allCards);\r\n\t\tspectator.registerPowerTarget(secondAttacker, secondAttacker, playerBoard);\r\n\t\tif (playerBoard.map((e) => e.cardId).includes(CardIds.EclipsionIllidariBattlegrounds2)) {\r\n\t\t\tsecondAttacker.immuneWhenAttackCharges = 1;\r\n\t\t}\r\n\t\tsimulateAttack(\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tundefined,\r\n\t\t\tallCards,\r\n\t\t\tspawns,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tplayerBoard.length - 1,\r\n\t\t);\r\n\t}\r\n};\r\n\r\nconst handleAlakirForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst firstEntity = playerBoard[0];\r\n\tfirstEntity.windfury = true;\r\n\tfirstEntity.divineShield = true;\r\n\tfirstEntity.taunt = true;\r\n\tspectator.registerPowerTarget(firstEntity, firstEntity, playerBoard);\r\n};\r\n\r\nconst handleTamsinForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst lowestHealth = Math.min(...playerBoard.map((e) => e.health));\r\n\tconst entitiesWithLowestHealth = playerBoard.filter((e) => e.health === lowestHealth);\r\n\tconst chosenEntity = pickRandom(entitiesWithLowestHealth);\r\n\tconst newBoard = playerBoard.filter((e) => e.entityId !== chosenEntity.entityId);\r\n\tconst buffedEntities = pickMultipleRandomDifferent(newBoard, 4);\r\n\t// How to mark the minion as dead\r\n\tchosenEntity.definitelyDead = true;\r\n\tbuffedEntities.forEach((e) => {\r\n\t\tmodifyAttack(e, chosenEntity.attack, newBoard, allCards);\r\n\t\tmodifyHealth(e, chosenEntity.health, newBoard, allCards);\r\n\t\tafterStatsUpdate(e, newBoard, allCards);\r\n\t\tspectator.registerPowerTarget(chosenEntity, e, newBoard);\r\n\t});\r\n};\r\n\r\nconst handlePlayerStartOfCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tfriendly: boolean,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\tconst playerHeroPowerId = playerEntity.heroPowerId || getHeroPowerForHero(playerEntity.cardId);\r\n\tif (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.TamsinRoame_FragrantPhylactery) {\r\n\t\thandleTamsinForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimLeftToken) {\r\n\t\tconst target = opponentBoard[0];\r\n\t\tconst damageDone = dealDamageToEnemy(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimRightToken) {\r\n\t\tconst target = opponentBoard[opponentBoard.length - 1];\r\n\t\tconst damageDone = dealDamageToEnemy(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimLowToken) {\r\n\t\tconst smallestHealthMinion = [...opponentBoard].sort((a, b) => a.health - b.health)[0];\r\n\t\tconst target = pickRandom(opponentBoard.filter((e) => e.health === smallestHealthMinion.health));\r\n\t\tconst damageDone = dealDamageToEnemy(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimHighToken) {\r\n\t\tconst highestHealthMinion = [...opponentBoard].sort((a, b) => b.health - a.health)[0];\r\n\t\tconst target = pickRandom(opponentBoard.filter((e) => e.health === highestHealthMinion.health));\r\n\t\tconst damageDone = dealDamageToEnemy(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.EarthInvocationToken) {\r\n\t\tapplyEarthInvocationEnchantment(playerBoard, null, allCards, spectator);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.WaterInvocationToken) {\r\n\t\tapplyWaterInvocationEnchantment(playerBoard, null, allCards, spectator);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.FireInvocationToken) {\r\n\t\tapplyFireInvocationEnchantment(playerBoard, null, allCards, spectator);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.LightningInvocationToken) {\r\n\t\tapplyLightningInvocationEnchantment(\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tnull,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\tprocessMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\treturn currentAttacker;\r\n};\r\n\r\nexport const getHeroPowerForHero = (heroCardId: string): string => {\r\n\tswitch (heroCardId) {\r\n\t\tcase CardIds.IllidanStormrageBattlegrounds:\r\n\t\t\treturn CardIds.WingmenBattlegrounds;\r\n\t\tcase CardIds.TheLichKingBattlegrounds:\r\n\t\t\treturn CardIds.RebornRitesBattlegrounds;\r\n\t\tcase CardIds.ProfessorPutricideBattlegrounds:\r\n\t\t\treturn CardIds.RagePotionBattlegrounds;\r\n\t\tcase CardIds.DeathwingBattlegrounds:\r\n\t\t\treturn CardIds.AllWillBurnBattlegrounds;\r\n\t}\r\n\treturn null;\r\n};\r\n\r\nexport const performStartOfCombatMinionsForPlayer = (\r\n\tattacker: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\t// Apparently, the board composition used for start of combat minion effects (like Red Whelp, and I assume it works the\r\n\t// same way for others like Prized Promo Drake or Mantid Queen) is the one that is used before Illidan's effect is handled.\r\n\t// Since this also runs before HP start of combat, we probably also use the state as it was before HP were triggered, like\r\n\t// Tamsin's Phylactery.\r\n\tattackingBoardBefore: BoardEntity[],\r\n\tdefendingBoardBefore: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst attackingHeroPowerId = attackingBoardHero.heroPowerId || getHeroPowerForHero(attackingBoardHero.cardId);\r\n\tconst defendingHeroPowerId = defendingBoardHero.heroPowerId || getHeroPowerForHero(defendingBoardHero.cardId);\r\n\tconst numberOfDeathwingPresents =\r\n\t\t(attackingHeroPowerId === CardIds.AllWillBurnBattlegrounds ? 1 : 0) +\r\n\t\t(defendingHeroPowerId === CardIds.AllWillBurnBattlegrounds ? 1 : 0);\r\n\tapplyAuras(attackingBoard, numberOfDeathwingPresents, cardsData, allCards);\r\n\tapplyAuras(defendingBoard, numberOfDeathwingPresents, cardsData, allCards);\r\n\r\n\t// For now we're only dealing with the red whelp\r\n\tif (attacker.cardId === CardIds.RedWhelp) {\r\n\t\tconst damage = attackingBoardBefore\r\n\t\t\t.map((entity) => allCards.getCard(entity.cardId).race)\r\n\t\t\t.filter((race) => isCorrectTribe(race, Race.DRAGON)).length;\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tattacker,\r\n\t\t\tdamage,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tprocessMinionDeath(\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else if (attacker.cardId === CardIds.RedWhelpBattlegrounds) {\r\n\t\tconst damage = attackingBoardBefore\r\n\t\t\t.map((entity) => allCards.getCard(entity.cardId).race)\r\n\t\t\t.filter((race) => isCorrectTribe(race, Race.DRAGON)).length;\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tattacker,\r\n\t\t\tdamage,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tattacker,\r\n\t\t\tdamage,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tprocessMinionDeath(\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else if (attacker.cardId === CardIds.PrizedPromoDrake) {\r\n\t\tconst numberOfDragons = attackingBoardBefore\r\n\t\t\t.map((entity) => allCards.getCard(entity.cardId).race)\r\n\t\t\t.filter((race) => isCorrectTribe(race, Race.DRAGON)).length;\r\n\t\tconst neighbours = getNeighbours(attackingBoard, attacker);\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, numberOfDragons, attackingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, numberOfDragons, attackingBoard, allCards);\r\n\t\t\tafterStatsUpdate(entity, attackingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(attacker, entity, attackingBoard);\r\n\t\t});\r\n\t} else if (attacker.cardId === CardIds.PrizedPromoDrakeBattlegrounds) {\r\n\t\tconst dragons = attackingBoardBefore\r\n\t\t\t.map((entity) => allCards.getCard(entity.cardId).race)\r\n\t\t\t.filter((race) => isCorrectTribe(race, Race.DRAGON)).length;\r\n\t\tconst neighbours = getNeighbours(attackingBoard, attacker);\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 2 * dragons, attackingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 2 * dragons, attackingBoard, allCards);\r\n\t\t\tafterStatsUpdate(entity, attackingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(attacker, entity, attackingBoard);\r\n\t\t});\r\n\t} else if (attacker.cardId === CardIds.Crabby1 || attacker.cardId === CardIds.CrabbyBattlegrounds) {\r\n\t\tconst neighbours = getNeighbours(attackingBoard, attacker);\r\n\t\tconst multiplier = attacker.cardId === CardIds.CrabbyBattlegrounds ? 2 : 1;\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, multiplier * (attackingBoardHero.deadEyeDamageDone ?? 0), attackingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, multiplier * (attackingBoardHero.deadEyeDamageDone ?? 0), attackingBoard, allCards);\r\n\t\t\tafterStatsUpdate(entity, attackingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(attacker, entity, attackingBoard);\r\n\t\t});\r\n\t} else if (attacker.cardId === CardIds.CorruptedMyrmidon || attacker.cardId === CardIds.CorruptedMyrmidonBattlegrounds) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.CorruptedMyrmidonBattlegrounds ? 2 : 1;\r\n\t\tmodifyAttack(attacker, multiplier * attacker.attack, attackingBoard, allCards);\r\n\t\tmodifyHealth(attacker, multiplier * attacker.health, attackingBoard, allCards);\r\n\t\tafterStatsUpdate(attacker, attackingBoard, allCards);\r\n\t\tspectator.registerPowerTarget(attacker, attacker, attackingBoard);\r\n\t} else if (attacker.cardId === CardIds.MantidQueen || attacker.cardId === CardIds.MantidQueenBattlegrounds) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.MantidQueenBattlegrounds ? 2 : 1;\r\n\t\tconst allRaces = attackingBoardBefore\r\n\t\t\t.map((entity) => entity.cardId)\r\n\t\t\t.map((cardId) => allCards.getCard(cardId).race)\r\n\t\t\t.filter((race) => !!race && race !== Race[Race.BLANK]);\r\n\t\tconst totalRaces =\r\n\t\t\t[...new Set(allRaces.filter((race) => race !== Race[Race.ALL]))].length +\r\n\t\t\tallRaces.filter((race) => race === Race[Race.ALL]).length;\r\n\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\tfor (let j = 0; j < totalRaces; j++) {\r\n\t\t\t\tconst buffType = getRandomMantidQueenBuffType(attacker);\r\n\t\t\t\tswitch (buffType) {\r\n\t\t\t\t\tcase 'stats':\r\n\t\t\t\t\t\tmodifyAttack(attacker, 5, attackingBoard, allCards);\r\n\t\t\t\t\t\tmodifyHealth(attacker, 5, attackingBoard, allCards);\r\n\t\t\t\t\t\tafterStatsUpdate(attacker, attackingBoard, allCards);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'divine-shield':\r\n\t\t\t\t\t\tattacker.divineShield = true;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'taunt':\r\n\t\t\t\t\t\tattacker.taunt = true;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'windfury':\r\n\t\t\t\t\t\tattacker.windfury = true;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tspectator.registerPowerTarget(attacker, attacker, attackingBoard);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tremoveAuras(attackingBoard, cardsData);\r\n\tremoveAuras(defendingBoard, cardsData);\r\n};\r\n\r\nconst getRandomMantidQueenBuffType = (entity: BoardEntity): 'stats' | 'divine-shield' | 'windfury' | 'taunt' => {\r\n\tconst possibilities: ('stats' | 'divine-shield' | 'windfury' | 'taunt')[] = ['stats'];\r\n\tif (!entity.divineShield) {\r\n\t\tpossibilities.push('divine-shield');\r\n\t}\r\n\tif (!entity.windfury) {\r\n\t\tpossibilities.push('windfury');\r\n\t}\r\n\tif (!entity.taunt) {\r\n\t\tpossibilities.push('taunt');\r\n\t}\r\n\treturn pickRandom(possibilities);\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"start-of-combat.js","sourceRoot":"","sources":["../../src/simulation/start-of-combat.ts"],"names":[],"mappings":";;;AACA,iEAA8E;AAI9E,oDAA0E;AAC1E,6CAA4E;AAC5E,oCAAwF;AACxF,qCAAyH;AACzH,mCAAkD;AAClD,+DAK+B;AAIxB,MAAM,mBAAmB,GAAG,CAClC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,QAAyB,EACzB,MAAiB,EACjB,WAAwB,EACxB,SAAuB,EACvB,SAAoB,EACX,EAAE;IAKX,eAAe,GAAG,yBAAyB,CAC1C,YAAY,EACZ,WAAW,EACX,cAAc,EACd,aAAa,EACb,eAAe,EACf,QAAQ,EACR,MAAM,EACN,WAAW,EACX,SAAS,EACT,SAAS,CACT,CAAC;IAEF,MAAM,iBAAiB,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAM,CAAC,EAAG,CAAC,CAAC;IAC7D,MAAM,mBAAmB,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAM,CAAC,EAAG,CAAC,CAAC;IACjE,eAAe,GAAG,+BAAuB,CACxC,YAAY,EACZ,WAAW,EACX,cAAc,EACd,aAAa,EACb,eAAe,EACf,QAAQ,EACR,MAAM,EACN,WAAW,EACX,SAAS,EACT,SAAS,CACT,CAAC;IACF,e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C;KAC5B;IACD,OAAO,kBAAU,CAAC,aAAa,CAAC,CAAC;AAClC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsGameState } from '../bgs-battle-info';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardsData, START_OF_COMBAT_CARD_IDS } from '../cards/cards-data';\r\nimport { pickMultipleRandomDifferent, pickRandom } from '../services/utils';\r\nimport { afterStatsUpdate, isCorrectTribe, modifyAttack, modifyHealth } from '../utils';\r\nimport { dealDamageToEnemy, dealDamageToRandomEnemy, getNeighbours, processMinionDeath, simulateAttack } from './attack';\r\nimport { applyAuras, removeAuras } from './auras';\r\nimport {\r\n\tapplyEarthInvocationEnchantment,\r\n\tapplyFireInvocationEnchantment,\r\n\tapplyLightningInvocationEnchantment,\r\n\tapplyWaterInvocationEnchantment,\r\n} from './deathrattle-effects';\r\nimport { SharedState } from './shared-state';\r\nimport { Spectator } from './spectator/spectator';\r\n\r\nexport const handleStartOfCombat = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// https://twitter.com/DCalkosz/status/1488361384320528388?s=20&t=1ECxRZFdjqwEa2fRsXk32Q\r\n\t// There’s a certain order for Start of Combat hero powers, rather than “coin flips” where\r\n\t// an unlucky trigger order could mess up some positioning you had planned for your own hero\r\n\t// power. “Precombat” (Al’Akir, Y’Shaarj), then Illidan, then others.\r\n\tcurrentAttacker = handlePreCombatHeroPowers(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\t// Because start of combat powers like Red Whelp's use the board composition before Illidan's strike to know the amount of damage\r\n\tconst playerBoardBefore = playerBoard.map((e) => ({ ...e }));\r\n\tconst opponentBoardBefore = opponentBoard.map((e) => ({ ...e }));\r\n\tcurrentAttacker = handleIllidanHeroPowers(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\tcurrentAttacker = handleStartOfCombatHeroPowers(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\tcurrentAttacker = handleStartOfCombatMinions(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tplayerBoardBefore,\r\n\t\topponentBoardBefore,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePreCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// Some are part of the incoming board: Y'Shaarj, Lich King, Ozumat\r\n\t// Since the order is not important here, we just always do the player first\r\n\tconst playerHeroPowerId = playerEntity.heroPowerId || getHeroPowerForHero(playerEntity.cardId);\r\n\tif (playerHeroPowerId === CardIds.SwattingInsectsBattlegrounds && playerBoard.length > 0) {\r\n\t\t// Should be sent by the app, but it is an idempotent operation, so we can just reapply it here\r\n\t\thandleAlakirForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, spawns, sharedState, spectator);\r\n\t}\r\n\r\n\tconst opponentHeroPowerId = opponentEntity.heroPowerId || getHeroPowerForHero(opponentEntity.cardId);\r\n\tif (opponentHeroPowerId === CardIds.SwattingInsectsBattlegrounds && opponentBoard.length > 0) {\r\n\t\thandleAlakirForPlayer(opponentBoard, opponentEntity, playerBoard, playerEntity, allCards, spawns, sharedState, spectator);\r\n\t}\r\n\r\n\treturn currentAttacker;\r\n};\r\n\r\nexport const handleIllidanHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// console.log('current attacker before', currentAttacker);\r\n\t// Apparently it's a toin coss about whether to handle Illidan first or Al'Akir first\r\n\t// Auras are only relevant for Illidan, and already applied there\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else {\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\tprocessMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t// console.log('current attacker after', currentAttacker);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatMinions = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tplayerBoardBefore: BoardEntity[],\r\n\topponentBoardBefore: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\tlet attackerForStart = currentAttacker;\r\n\tconst playerAttackers = playerBoard.filter((entity) => START_OF_COMBAT_CARD_IDS.indexOf(entity.cardId as CardIds) !== -1);\r\n\tconst opponentAttackers = opponentBoard.filter((entity) => START_OF_COMBAT_CARD_IDS.indexOf(entity.cardId as CardIds) !== -1);\r\n\twhile (playerAttackers.length > 0 || opponentAttackers.length > 0) {\r\n\t\tif (attackerForStart === 0 && playerAttackers.length > 0) {\r\n\t\t\tconst attacker = playerAttackers.splice(0, 1)[0];\r\n\t\t\tperformStartOfCombatMinionsForPlayer(\r\n\t\t\t\tattacker,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tplayerBoardBefore,\r\n\t\t\t\topponentBoardBefore,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspawns,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tgameState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t} else if (attackerForStart === 1 && opponentAttackers.length > 0) {\r\n\t\t\tconst attacker = opponentAttackers.splice(0, 1)[0];\r\n\t\t\tperformStartOfCombatMinionsForPlayer(\r\n\t\t\t\tattacker,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoardBefore,\r\n\t\t\t\tplayerBoardBefore,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspawns,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tgameState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t\tattackerForStart = (attackerForStart + 1) % 2;\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\nexport const handleStartOfCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\tconst attackingHeroPowerId = playerEntity.heroPowerId || getHeroPowerForHero(playerEntity.cardId);\r\n\tconst defendingHeroPowerId = opponentEntity.heroPowerId || getHeroPowerForHero(opponentEntity.cardId);\r\n\tconst numberOfDeathwingPresents =\r\n\t\t(attackingHeroPowerId === CardIds.AllWillBurnBattlegrounds ? 1 : 0) +\r\n\t\t(defendingHeroPowerId === CardIds.AllWillBurnBattlegrounds ? 1 : 0);\r\n\tapplyAuras(playerBoard, numberOfDeathwingPresents, cardsData, allCards);\r\n\tapplyAuras(opponentBoard, numberOfDeathwingPresents, cardsData, allCards);\r\n\r\n\t// Apparently it's a toin coss about whether to handle Illidan first or Al'Akir first\r\n\t// Auras are only relevant for Illidan, and already applied there\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else {\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\tremoveAuras(playerBoard, cardsData);\r\n\tremoveAuras(opponentBoard, cardsData);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePlayerIllidanHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tfriendly: boolean,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\tconst playerHeroPowerId = playerEntity.heroPowerId || getHeroPowerForHero(playerEntity.cardId);\r\n\tif (playerHeroPowerId === CardIds.WingmenBattlegrounds && playerBoard.length > 0) {\r\n\t\thandleIllidanForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, spawns, sharedState, spectator);\r\n\t\tcurrentAttacker = (currentAttacker + 1) % 2;\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\n// TODO: not exactly correct, because of \"attack immediately\", but it's close enough\r\nconst handleIllidanForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// Otherwise, if the first minion dies on the attack, and the board has only 2 minions, we\r\n\t// miss the second one\r\n\tconst minionsAtStart = playerBoard.length;\r\n\tconst firstAttacker = playerBoard[0];\r\n\tconst secondAttacker = minionsAtStart > 1 ? playerBoard[playerBoard.length - 1] : null;\r\n\r\n\tmodifyAttack(firstAttacker, 2, playerBoard, allCards);\r\n\tafterStatsUpdate(firstAttacker, playerBoard, allCards);\r\n\tspectator.registerPowerTarget(firstAttacker, firstAttacker, playerBoard);\r\n\tif (\r\n\t\tplayerBoard.map((e) => e.cardId).includes(CardIds.EclipsionIllidariBattlegrounds2) ||\r\n\t\tplayerBoard.map((e) => e.cardId).includes(CardIds.EclipsionIllidariBattlegrounds1)\r\n\t) {\r\n\t\tfirstAttacker.immuneWhenAttackCharges = 1;\r\n\t}\r\n\tsimulateAttack(playerBoard, playerEntity, opponentBoard, opponentEntity, undefined, allCards, spawns, sharedState, spectator, 0);\r\n\r\n\tif (!!secondAttacker && !secondAttacker.definitelyDead && secondAttacker.health > 0) {\r\n\t\tmodifyAttack(secondAttacker, 2, playerBoard, allCards);\r\n\t\tafterStatsUpdate(secondAttacker, playerBoard, allCards);\r\n\t\tspectator.registerPowerTarget(secondAttacker, secondAttacker, playerBoard);\r\n\t\tif (playerBoard.map((e) => e.cardId).includes(CardIds.EclipsionIllidariBattlegrounds2)) {\r\n\t\t\tsecondAttacker.immuneWhenAttackCharges = 1;\r\n\t\t}\r\n\t\tsimulateAttack(\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tundefined,\r\n\t\t\tallCards,\r\n\t\t\tspawns,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tplayerBoard.length - 1,\r\n\t\t);\r\n\t}\r\n};\r\n\r\nconst handleAlakirForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst firstEntity = playerBoard[0];\r\n\tfirstEntity.windfury = true;\r\n\tfirstEntity.divineShield = true;\r\n\tfirstEntity.taunt = true;\r\n\tspectator.registerPowerTarget(firstEntity, firstEntity, playerBoard);\r\n};\r\n\r\nconst handleTamsinForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst lowestHealth = Math.min(...playerBoard.map((e) => e.health));\r\n\tconst entitiesWithLowestHealth = playerBoard.filter((e) => e.health === lowestHealth);\r\n\tconst chosenEntity = pickRandom(entitiesWithLowestHealth);\r\n\tconst newBoard = playerBoard.filter((e) => e.entityId !== chosenEntity.entityId);\r\n\tconst buffedEntities = pickMultipleRandomDifferent(newBoard, 5);\r\n\t// How to mark the minion as dead\r\n\tchosenEntity.definitelyDead = true;\r\n\tbuffedEntities.forEach((e) => {\r\n\t\tmodifyAttack(e, chosenEntity.attack, newBoard, allCards);\r\n\t\tmodifyHealth(e, chosenEntity.health, newBoard, allCards);\r\n\t\tafterStatsUpdate(e, newBoard, allCards);\r\n\t\tspectator.registerPowerTarget(chosenEntity, e, newBoard);\r\n\t});\r\n};\r\n\r\nconst handlePlayerStartOfCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tfriendly: boolean,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\tconst playerHeroPowerId = playerEntity.heroPowerId || getHeroPowerForHero(playerEntity.cardId);\r\n\tif (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.TamsinRoame_FragrantPhylactery) {\r\n\t\thandleTamsinForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimLeftToken) {\r\n\t\tconst target = opponentBoard[0];\r\n\t\tconst damageDone = dealDamageToEnemy(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimRightToken) {\r\n\t\tconst target = opponentBoard[opponentBoard.length - 1];\r\n\t\tconst damageDone = dealDamageToEnemy(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimLowToken) {\r\n\t\tconst smallestHealthMinion = [...opponentBoard].sort((a, b) => a.health - b.health)[0];\r\n\t\tconst target = pickRandom(opponentBoard.filter((e) => e.health === smallestHealthMinion.health));\r\n\t\tconst damageDone = dealDamageToEnemy(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimHighToken) {\r\n\t\tconst highestHealthMinion = [...opponentBoard].sort((a, b) => b.health - a.health)[0];\r\n\t\tconst target = pickRandom(opponentBoard.filter((e) => e.health === highestHealthMinion.health));\r\n\t\tconst damageDone = dealDamageToEnemy(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.EarthInvocationToken) {\r\n\t\tapplyEarthInvocationEnchantment(playerBoard, null, allCards, spectator);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.WaterInvocationToken) {\r\n\t\tapplyWaterInvocationEnchantment(playerBoard, null, allCards, spectator);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.FireInvocationToken) {\r\n\t\tapplyFireInvocationEnchantment(playerBoard, null, allCards, spectator);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.LightningInvocationToken) {\r\n\t\tapplyLightningInvocationEnchantment(\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tnull,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\tprocessMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\treturn currentAttacker;\r\n};\r\n\r\nexport const getHeroPowerForHero = (heroCardId: string): string => {\r\n\tswitch (heroCardId) {\r\n\t\tcase CardIds.IllidanStormrageBattlegrounds:\r\n\t\t\treturn CardIds.WingmenBattlegrounds;\r\n\t\tcase CardIds.TheLichKingBattlegrounds:\r\n\t\t\treturn CardIds.RebornRitesBattlegrounds;\r\n\t\tcase CardIds.ProfessorPutricideBattlegrounds:\r\n\t\t\treturn CardIds.RagePotionBattlegrounds;\r\n\t\tcase CardIds.DeathwingBattlegrounds:\r\n\t\t\treturn CardIds.AllWillBurnBattlegrounds;\r\n\t}\r\n\treturn null;\r\n};\r\n\r\nexport const performStartOfCombatMinionsForPlayer = (\r\n\tattacker: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\t// Apparently, the board composition used for start of combat minion effects (like Red Whelp, and I assume it works the\r\n\t// same way for others like Prized Promo Drake or Mantid Queen) is the one that is used before Illidan's effect is handled.\r\n\t// Since this also runs before HP start of combat, we probably also use the state as it was before HP were triggered, like\r\n\t// Tamsin's Phylactery.\r\n\tattackingBoardBefore: BoardEntity[],\r\n\tdefendingBoardBefore: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst attackingHeroPowerId = attackingBoardHero.heroPowerId || getHeroPowerForHero(attackingBoardHero.cardId);\r\n\tconst defendingHeroPowerId = defendingBoardHero.heroPowerId || getHeroPowerForHero(defendingBoardHero.cardId);\r\n\tconst numberOfDeathwingPresents =\r\n\t\t(attackingHeroPowerId === CardIds.AllWillBurnBattlegrounds ? 1 : 0) +\r\n\t\t(defendingHeroPowerId === CardIds.AllWillBurnBattlegrounds ? 1 : 0);\r\n\tapplyAuras(attackingBoard, numberOfDeathwingPresents, cardsData, allCards);\r\n\tapplyAuras(defendingBoard, numberOfDeathwingPresents, cardsData, allCards);\r\n\r\n\t// For now we're only dealing with the red whelp\r\n\tif (attacker.cardId === CardIds.RedWhelp) {\r\n\t\tconst damage = attackingBoardBefore\r\n\t\t\t.map((entity) => allCards.getCard(entity.cardId).race)\r\n\t\t\t.filter((race) => isCorrectTribe(race, Race.DRAGON)).length;\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tattacker,\r\n\t\t\tdamage,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tprocessMinionDeath(\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else if (attacker.cardId === CardIds.RedWhelpBattlegrounds) {\r\n\t\tconst damage = attackingBoardBefore\r\n\t\t\t.map((entity) => allCards.getCard(entity.cardId).race)\r\n\t\t\t.filter((race) => isCorrectTribe(race, Race.DRAGON)).length;\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tattacker,\r\n\t\t\tdamage,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tattacker,\r\n\t\t\tdamage,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tprocessMinionDeath(\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else if (attacker.cardId === CardIds.PrizedPromoDrake) {\r\n\t\tconst numberOfDragons = attackingBoardBefore\r\n\t\t\t.map((entity) => allCards.getCard(entity.cardId).race)\r\n\t\t\t.filter((race) => isCorrectTribe(race, Race.DRAGON)).length;\r\n\t\tconst neighbours = getNeighbours(attackingBoard, attacker);\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, numberOfDragons, attackingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, numberOfDragons, attackingBoard, allCards);\r\n\t\t\tafterStatsUpdate(entity, attackingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(attacker, entity, attackingBoard);\r\n\t\t});\r\n\t} else if (attacker.cardId === CardIds.PrizedPromoDrakeBattlegrounds) {\r\n\t\tconst dragons = attackingBoardBefore\r\n\t\t\t.map((entity) => allCards.getCard(entity.cardId).race)\r\n\t\t\t.filter((race) => isCorrectTribe(race, Race.DRAGON)).length;\r\n\t\tconst neighbours = getNeighbours(attackingBoard, attacker);\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 2 * dragons, attackingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 2 * dragons, attackingBoard, allCards);\r\n\t\t\tafterStatsUpdate(entity, attackingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(attacker, entity, attackingBoard);\r\n\t\t});\r\n\t} else if (attacker.cardId === CardIds.Crabby1 || attacker.cardId === CardIds.CrabbyBattlegrounds) {\r\n\t\tconst neighbours = getNeighbours(attackingBoard, attacker);\r\n\t\tconst multiplier = attacker.cardId === CardIds.CrabbyBattlegrounds ? 2 : 1;\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, multiplier * (attackingBoardHero.deadEyeDamageDone ?? 0), attackingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, multiplier * (attackingBoardHero.deadEyeDamageDone ?? 0), attackingBoard, allCards);\r\n\t\t\tafterStatsUpdate(entity, attackingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(attacker, entity, attackingBoard);\r\n\t\t});\r\n\t} else if (attacker.cardId === CardIds.CorruptedMyrmidon || attacker.cardId === CardIds.CorruptedMyrmidonBattlegrounds) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.CorruptedMyrmidonBattlegrounds ? 2 : 1;\r\n\t\tmodifyAttack(attacker, multiplier * attacker.attack, attackingBoard, allCards);\r\n\t\tmodifyHealth(attacker, multiplier * attacker.health, attackingBoard, allCards);\r\n\t\tafterStatsUpdate(attacker, attackingBoard, allCards);\r\n\t\tspectator.registerPowerTarget(attacker, attacker, attackingBoard);\r\n\t} else if (attacker.cardId === CardIds.MantidQueen || attacker.cardId === CardIds.MantidQueenBattlegrounds) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.MantidQueenBattlegrounds ? 2 : 1;\r\n\t\tconst allRaces = attackingBoardBefore\r\n\t\t\t.map((entity) => entity.cardId)\r\n\t\t\t.map((cardId) => allCards.getCard(cardId).race)\r\n\t\t\t.filter((race) => !!race && race !== Race[Race.BLANK]);\r\n\t\tconst totalRaces =\r\n\t\t\t[...new Set(allRaces.filter((race) => race !== Race[Race.ALL]))].length +\r\n\t\t\tallRaces.filter((race) => race === Race[Race.ALL]).length;\r\n\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\tfor (let j = 0; j < totalRaces; j++) {\r\n\t\t\t\tconst buffType = getRandomMantidQueenBuffType(attacker);\r\n\t\t\t\tswitch (buffType) {\r\n\t\t\t\t\tcase 'stats':\r\n\t\t\t\t\t\tmodifyAttack(attacker, 5, attackingBoard, allCards);\r\n\t\t\t\t\t\tmodifyHealth(attacker, 5, attackingBoard, allCards);\r\n\t\t\t\t\t\tafterStatsUpdate(attacker, attackingBoard, allCards);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'divine-shield':\r\n\t\t\t\t\t\tattacker.divineShield = true;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'taunt':\r\n\t\t\t\t\t\tattacker.taunt = true;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'windfury':\r\n\t\t\t\t\t\tattacker.windfury = true;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tspectator.registerPowerTarget(attacker, attacker, attackingBoard);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tremoveAuras(attackingBoard, cardsData);\r\n\tremoveAuras(defendingBoard, cardsData);\r\n};\r\n\r\nconst getRandomMantidQueenBuffType = (entity: BoardEntity): 'stats' | 'divine-shield' | 'windfury' | 'taunt' => {\r\n\tconst possibilities: ('stats' | 'divine-shield' | 'windfury' | 'taunt')[] = ['stats'];\r\n\tif (!entity.divineShield) {\r\n\t\tpossibilities.push('divine-shield');\r\n\t}\r\n\tif (!entity.windfury) {\r\n\t\tpossibilities.push('windfury');\r\n\t}\r\n\tif (!entity.taunt) {\r\n\t\tpossibilities.push('taunt');\r\n\t}\r\n\treturn pickRandom(possibilities);\r\n};\r\n"]}
|