@firestone-hs/simulate-bgs-battle 1.1.170 → 1.1.171
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/simulation/attack.js +4 -4
- package/dist/simulation/attack.js.map +1 -1
- package/dist/simulation/auras.d.ts +1 -1
- package/dist/simulation/auras.js +10 -10
- package/dist/simulation/auras.js.map +1 -1
- package/dist/simulation/avenge.js +11 -1
- package/dist/simulation/avenge.js.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -28,11 +28,11 @@ const simulateAttack = (attackingBoard, attackingBoardHero, defendingBoard, defe
|
|
|
28
28
|
attackingEntity.attacking = true;
|
|
29
29
|
const numberOfAttacks = attackingEntity.megaWindfury ? 4 : attackingEntity.windfury ? 2 : 1;
|
|
30
30
|
for (let i = 0; i < numberOfAttacks; i++) {
|
|
31
|
-
auras_1.applyAuras(attackingBoard, numberOfDeathwingPresents, spawns, allCards);
|
|
32
|
-
auras_1.applyAuras(defendingBoard, numberOfDeathwingPresents, spawns, allCards);
|
|
33
31
|
if (attackingBoard.length === 0 || defendingBoard.length === 0) {
|
|
34
32
|
return;
|
|
35
33
|
}
|
|
34
|
+
auras_1.applyAuras(attackingBoard, numberOfDeathwingPresents, spawns, allCards);
|
|
35
|
+
auras_1.applyAuras(defendingBoard, numberOfDeathwingPresents, spawns, allCards);
|
|
36
36
|
if (attackingBoard.find((entity) => entity.entityId === attackingEntity.entityId)) {
|
|
37
37
|
exports.applyOnAttackBuffs(attackingEntity, attackingBoard, allCards, spectator);
|
|
38
38
|
const defendingEntity = exports.getDefendingEntity(defendingBoard, attackingEntity);
|
|
@@ -566,8 +566,8 @@ const performEntitySpawns = (candidateEntities, boardWithKilledMinion, boardWith
|
|
|
566
566
|
}
|
|
567
567
|
boardWithKilledMinion.splice(boardWithKilledMinion.length - indexFromRight, 0, newMinion);
|
|
568
568
|
if (newMinion.attackImmediately) {
|
|
569
|
-
auras_1.removeAuras(boardWithKilledMinion, cardsData);
|
|
570
|
-
auras_1.removeAuras(opponentBoard, cardsData);
|
|
569
|
+
auras_1.removeAuras(boardWithKilledMinion, cardsData, true);
|
|
570
|
+
auras_1.removeAuras(opponentBoard, cardsData, true);
|
|
571
571
|
exports.simulateAttack(boardWithKilledMinion, boardWithKilledMinionHero, opponentBoard, opponentBoardHero, null, allCards, cardsData, sharedState, spectator);
|
|
572
572
|
}
|
|
573
573
|
if (newMinion.health > 0 && !newMinion.definitelyDead) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attack.js","sourceRoot":"","sources":["../../src/simulation/attack.ts"],"names":[],"mappings":";;;AACA,iEAA8E;AAI9E,6CAA+C;AAC/C,gEAA2D;AAC3D,oCAAsI;AACtI,mCAAkD;AAClD,qCAA8C;AAC9C,+DAAiI;AACjI,6DAAkH;AAClH,qCAAuC;AAEvC,iDAAoD;AAEpD,uDAAwD;AAGjD,MAAM,cAAc,GAAG,CAC7B,cAA6B,EAC7B,kBAAmC,EACnC,cAA6B,EAC7B,kBAAmC,EACnC,oBAA4B,EAC5B,QAAyB,EACzB,MAAiB,EACjB,WAAwB,EACxB,SAAoB,EACpB,yBAAkC,EACzB,EAAE;IACX,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;QAC/D,OAAO;KACP;IACD,MAAM,oBAAoB,GAAG,kBAAkB,CAAC,WAAW,IAAI,qCAAmB,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC9G,MAAM,oBAAoB,GAAG,kBAAkB,CAAC,WAAW,IAAI,qCAAmB,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC9G,MAAM,yBAAyB,GAC9B,CAAC,oBAAoB,0BAAqC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnE,CAAC,oBAAoB,0BAAqC,CAAC,CAAC,CAAC,C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AAI,qBAAqB,CAAC,MAAM,IAAI,CAAC,EAAE;YACtC,MAAM;SACN;QAKD,qBAAqB,CAAC,MAAM,CAAC,qBAAqB,CAAC,MAAM,GAAG,cAAc,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;QAC1F,IAAI,SAAS,CAAC,iBAAiB,EAAE;YAEhC,mBAAW,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;YAC9C,mBAAW,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;YACtC,sBAAc,CACb,qBAAqB,EACrB,yBAAyB,EACzB,aAAa,EACb,iBAAiB,EACjB,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,WAAW,EACX,SAAS,CACT,CAAC;SACF;QACD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE;YACtD,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAChC;KACD;IAGD,iCAAkB,CAAC,qBAAqB,EAAE,eAAe,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAChF,SAAS,CAAC,oBAAoB,CAAC,iBAAiB,EAAE,qBAAqB,EAAE,eAAe,CAAC,CAAC;IAC1F,OAAO,eAAe,CAAC;AACxB,CAAC,CAAC;AAvDW,QAAA,mBAAmB,uBAuD9B","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds, 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 { pickRandom } from '../services/utils';\r\nimport { validEnchantments } from '../simulate-bgs-battle';\r\nimport { addCardsInHand, afterStatsUpdate, hasCorrectTribe, hasMechanic, isCorrectTribe, modifyAttack, modifyHealth } from '../utils';\r\nimport { applyAuras, removeAuras } from './auras';\r\nimport { applyAvengeEffects } from './avenge';\r\nimport { applyMinionDeathEffect, applyMonstrosity, handleDeathrattleEffects, rememberDeathrattles } from './deathrattle-effects';\r\nimport { spawnEntities, spawnEntitiesFromDeathrattle, spawnEntitiesFromEnchantments } from './deathrattle-spawns';\r\nimport { applyFrenzy } from './frenzy';\r\nimport { SharedState } from './shared-state';\r\nimport { handleSpawnEffects } from './spawn-effect';\r\nimport { Spectator } from './spectator/spectator';\r\nimport { getHeroPowerForHero } from './start-of-combat';\r\n\r\n// Only use it to simulate actual attack. To simulate damage, or something similar, use bumpInto\r\nexport const simulateAttack = (\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tlastAttackerEntityId: number,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n\tforceAttackingEntityIndex?: number,\r\n): number => {\r\n\tif (attackingBoard.length === 0 || defendingBoard.length === 0) {\r\n\t\treturn;\r\n\t}\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\r\n\tconst attackingEntity =\r\n\t\tforceAttackingEntityIndex != null\r\n\t\t\t? attackingBoard[forceAttackingEntityIndex]\r\n\t\t\t: getAttackingEntity(attackingBoard, lastAttackerEntityId);\r\n\tconst attackingEntityIndex = attackingBoard.map((e) => e.entityId).indexOf(attackingEntity?.entityId);\r\n\tif (attackingEntity) {\r\n\t\tattackingEntity.attacking = true;\r\n\t\t// console.log('attack by', stringifySimpleCard(attackingEntity, allCards), attackingEntity.attacking);\r\n\t\tconst numberOfAttacks = attackingEntity.megaWindfury ? 4 : attackingEntity.windfury ? 2 : 1;\r\n\t\tfor (let i = 0; i < numberOfAttacks; i++) {\r\n\t\t\t// The auras need to be handled on a per-attack basis, as otherwise minions that spawn\r\n\t\t\t// in-between attacks don't get aura buffs\r\n\t\t\tapplyAuras(attackingBoard, numberOfDeathwingPresents, spawns, allCards);\r\n\t\t\tapplyAuras(defendingBoard, numberOfDeathwingPresents, spawns, allCards);\r\n\t\t\t// We refresh the entity in case of windfury\r\n\t\t\tif (attackingBoard.length === 0 || defendingBoard.length === 0) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\t// Check that didn't die\r\n\t\t\tif (attackingBoard.find((entity) => entity.entityId === attackingEntity.entityId)) {\r\n\t\t\t\tapplyOnAttackBuffs(attackingEntity, attackingBoard, allCards, spectator);\r\n\t\t\t\tconst defendingEntity: BoardEntity = getDefendingEntity(defendingBoard, attackingEntity);\r\n\t\t\t\tspectator.registerAttack(attackingEntity, defendingEntity, attackingBoard, defendingBoard);\r\n\t\t\t\tapplyOnBeingAttackedBuffs(defendingEntity, defendingBoard, allCards, spectator);\r\n\t\t\t\tperformAttack(\r\n\t\t\t\t\tattackingEntity,\r\n\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tspawns,\r\n\t\t\t\t\tsharedState,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t);\r\n\t\t\t\tapplyAfterAttackEffects(attackingEntity, attackingBoard, attackingBoardHero, allCards, spectator);\r\n\t\t\t\t// FIXME: I don't know the behavior with Windfury. Should the attack be done right away, before\r\n\t\t\t\t// the windfury triggers again? The current behavior attacks after the windfury is over\r\n\t\t\t\tif (\r\n\t\t\t\t\tdefendingEntity.health > 0 &&\r\n\t\t\t\t\t!defendingEntity.definitelyDead &&\r\n\t\t\t\t\t(defendingEntity.cardId === CardIds.YoHoOgre || defendingEntity.cardId === CardIds.YoHoOgreBattlegrounds)\r\n\t\t\t\t) {\r\n\t\t\t\t\tdefendingEntity.attackImmediately = true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tremoveAuras(attackingBoard, spawns);\r\n\t\t\tremoveAuras(defendingBoard, spawns);\r\n\t\t}\r\n\t\tattackingEntity.attacking = false;\r\n\t}\r\n\t// If entities that were before the attacker died, we need to update the attacker index\r\n\treturn attackingEntityIndex;\r\n};\r\n\r\nconst applyAfterAttackEffects = (\r\n\tattackingEntity: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (attackingEntity.cardId === CardIds.Bonker || attackingEntity.cardId === CardIds.BonkerBattlegrounds) {\r\n\t\taddCardsInHand(attackingBoardHero, 1, attackingBoard, allCards, spectator, CardIds.BloodGem);\r\n\t}\r\n};\r\n\r\nconst performAttack = (\r\n\tattackingEntity: BoardEntity,\r\n\tdefendingEntity: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (hasCorrectTribe(attackingEntity, Race.DRAGON, allCards)) {\r\n\t\tconst prestors = attackingBoard\r\n\t\t\t.filter((e) => e.entityId !== attackingEntity.entityId)\r\n\t\t\t.filter((e) => e.cardId === CardIds.PrestorsPyrospawn || e.cardId === CardIds.PrestorsPyrospawnBattlegrounds);\r\n\t\tprestors.forEach((prestor) => {\r\n\t\t\tspectator.registerPowerTarget(prestor, defendingEntity, defendingBoard);\r\n\t\t\tdealDamageToEnemy(\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tprestor,\r\n\t\t\t\tprestor.cardId === CardIds.PrestorsPyrospawnBattlegrounds ? 6 : 3,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\r\n\tif ([CardIds.BabyKrush, CardIds.BabyKrushBattlegrounds].includes(attackingEntity.cardId as CardIds)) {\r\n\t\tconst spawns = spawnEntities(\r\n\t\t\tattackingEntity.cardId === CardIds.BabyKrushBattlegrounds ? CardIds.DevilsaurBattlegrounds : CardIds.BabyKrush_DevilsaurToken,\r\n\t\t\t1,\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\ttrue,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t\tif (spawns.length > 0) {\r\n\t\t\tconst sourceIndex = attackingBoard.indexOf(attackingEntity);\r\n\t\t\tconst actualSpawns = performEntitySpawns(\r\n\t\t\t\tspawns,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tsourceIndex,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\tfor (const actualSpawn of actualSpawns) {\r\n\t\t\t\tif (defendingEntity.health > 0 && !defendingEntity.definitelyDead) {\r\n\t\t\t\t\tperformAttack(\r\n\t\t\t\t\t\tactualSpawn,\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// For Prestor\r\n\tconst defenderAliveBeforeAttack = defendingEntity.health > 0 && !defendingEntity.definitelyDead;\r\n\tif (defenderAliveBeforeAttack) {\r\n\t\tif (!attackingEntity.immuneWhenAttackCharges || attackingEntity.immuneWhenAttackCharges <= 0) {\r\n\t\t\tbumpEntities(\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t} else {\r\n\t\t\t// console.log('immune when attack', attackingEntity);\r\n\t\t}\r\n\t\tbumpEntities(\r\n\t\t\tdefendingEntity,\r\n\t\t\tattackingEntity,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\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}\r\n\t// Cleave\r\n\tif (attackingEntity.cleave) {\r\n\t\tconst defenderNeighbours: readonly BoardEntity[] = getNeighbours(defendingBoard, defendingEntity);\r\n\t\tfor (const neighbour of defenderNeighbours) {\r\n\t\t\tbumpEntities(\r\n\t\t\t\tneighbour,\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\t// After attack hooks\r\n\t// Arcane Cannon\r\n\t// Monstrous Macaw\r\n\tif (attackingEntity.cardId === CardIds.MonstrousMacaw) {\r\n\t\ttriggerRandomDeathrattle(\r\n\t\t\tattackingEntity,\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\ttrue,\r\n\t\t);\r\n\t} else if (attackingEntity.cardId === CardIds.MonstrousMacawBattlegrounds) {\r\n\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\ttriggerRandomDeathrattle(\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\tattackingEntity.attackImmediately = false;\r\n\tprocessMinionDeath(attackingBoard, attackingBoardHero, defendingBoard, defendingBoardHero, allCards, cardsData, sharedState, spectator);\r\n\tattackingEntity.immuneWhenAttackCharges = Math.max(0, attackingEntity.immuneWhenAttackCharges - 1);\r\n};\r\n\r\nconst triggerRandomDeathrattle = (\r\n\tsourceEntity: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n\texcludeSource = false,\r\n): void => {\r\n\tconst validDeathrattles = attackingBoard\r\n\t\t.filter((entity) => !excludeSource || entity.entityId !== sourceEntity.entityId)\r\n\t\t.filter((entity) => {\r\n\t\t\tif (hasMechanic(allCards.getCard(entity.cardId), 'DEATHRATTLE')) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\tif (entity.rememberedDeathrattles?.length) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\tif (\r\n\t\t\t\tentity.enchantments &&\r\n\t\t\t\tentity.enchantments\r\n\t\t\t\t\t.map((enchantment) => enchantment.cardId)\r\n\t\t\t\t\t.some((enchantmentId) => validEnchantments.includes(enchantmentId as CardIds))\r\n\t\t\t) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\treturn false;\r\n\t\t});\r\n\tif (validDeathrattles.length === 0) {\r\n\t\treturn;\r\n\t}\r\n\tconst targetEntity = validDeathrattles[Math.floor(Math.random() * validDeathrattles.length)];\r\n\tspectator.registerPowerTarget(sourceEntity, targetEntity, attackingBoard);\r\n\tbuildBoardAfterDeathrattleSpawns(\r\n\t\tattackingBoard,\r\n\t\tattackingBoardHero,\r\n\t\ttargetEntity,\r\n\t\t-1,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\tbuildBoardAfterRebornSpawns(\r\n\t\tattackingBoard,\r\n\t\tattackingBoardHero,\r\n\t\ttargetEntity,\r\n\t\t-1,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n};\r\n\r\nconst getAttackingEntity = (attackingBoard: BoardEntity[], lastAttackerIndex: number): BoardEntity => {\r\n\tlet validAttackers = attackingBoard.filter((entity) => entity.attack > 0).filter((entity) => !entity.cantAttack);\r\n\tif (validAttackers.length === 0) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tif (validAttackers.some((entity) => entity.attackImmediately)) {\r\n\t\tvalidAttackers = validAttackers.filter((entity) => entity.attackImmediately);\r\n\t}\r\n\r\n\t// Once an entity has attacked, no entity to the left of it can attack until all entities\r\n\t// on the board have attacked\r\n\t// Once the last attacker index is the last entity on the board, we cycle back to the start\r\n\tif (lastAttackerIndex != null && lastAttackerIndex < validAttackers.length - 1) {\r\n\t\t// This doesn't work if any entity that appears before the attacked index died in-between\r\n\t\tconst candidates = validAttackers.slice(lastAttackerIndex);\r\n\t\tif (candidates.length > 0) {\r\n\t\t\tvalidAttackers = candidates;\r\n\t\t}\r\n\t}\r\n\r\n\tlet attackingEntity = validAttackers[0];\r\n\tlet minNumberOfAttacks: number = attackingEntity.attacksPerformed || 0;\r\n\tfor (const entity of validAttackers) {\r\n\t\tif ((entity.attacksPerformed || 0) < minNumberOfAttacks) {\r\n\t\t\tattackingEntity = entity;\r\n\t\t\tminNumberOfAttacks = entity.attacksPerformed;\r\n\t\t}\r\n\t}\r\n\r\n\tif (!attackingEntity.attackImmediately) {\r\n\t\tattackingEntity.attacksPerformed = (attackingEntity.attacksPerformed || 0) + 1;\r\n\t}\r\n\treturn attackingEntity;\r\n};\r\n\r\nexport const getNeighbours = (board: BoardEntity[], entity: BoardEntity, deadEntityIndex?: number): readonly BoardEntity[] => {\r\n\tconst neighbours = [];\r\n\tif (deadEntityIndex != null) {\r\n\t\tif (deadEntityIndex < board.length - 1) {\r\n\t\t\tneighbours.push(board[deadEntityIndex]);\r\n\t\t}\r\n\t\t// Could happen if a cleave kills several entities at the same time\r\n\t\tif (deadEntityIndex > 0 && deadEntityIndex <= board.length) {\r\n\t\t\tneighbours.push(board[deadEntityIndex - 1]);\r\n\t\t}\r\n\t} else {\r\n\t\tconst index = board.map((e) => e.entityId).indexOf(entity.entityId);\r\n\t\tif (index - 1 >= 0) {\r\n\t\t\tneighbours.push(board[index - 1]);\r\n\t\t}\r\n\t\t// neighbours.push(entity);\r\n\t\tif (index + 1 < board.length) {\r\n\t\t\tneighbours.push(board[index + 1]);\r\n\t\t}\r\n\t}\r\n\treturn neighbours;\r\n};\r\n\r\nexport const dealDamageToRandomEnemy = (\r\n\tboardToBeDamaged: BoardEntity[],\r\n\tboardToBeDamagedHero: BgsPlayerEntity,\r\n\tdamageSource: BoardEntity,\r\n\tdamage: number,\r\n\tboardWithAttackOrigin: BoardEntity[],\r\n\tboardWithAttackOriginHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (boardToBeDamaged.length === 0) {\r\n\t\treturn;\r\n\t}\r\n\tconst validTargets = boardToBeDamaged.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tconst defendingEntity: BoardEntity = pickRandom(validTargets);\r\n\tif (defendingEntity) {\r\n\t\tspectator.registerPowerTarget(damageSource, defendingEntity, boardToBeDamaged);\r\n\t\tdealDamageToEnemy(\r\n\t\t\tdefendingEntity,\r\n\t\t\tboardToBeDamaged,\r\n\t\t\tboardToBeDamagedHero,\r\n\t\t\tdamageSource,\r\n\t\t\tdamage,\r\n\t\t\tboardWithAttackOrigin,\r\n\t\t\tboardWithAttackOriginHero,\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};\r\n\r\nexport const dealDamageToEnemy = (\r\n\tdefendingEntity: BoardEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tdamageSource: BoardEntity,\r\n\tdamage: number,\r\n\tboardWithAttackOrigin: BoardEntity[],\r\n\tboardWithAttackOriginHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// console.log('dealing damage to', damage, stringifySimpleCard(defendingEntity, allCards));\r\n\tif (!defendingEntity) {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tconst fakeAttacker = {\r\n\t\t...(damageSource || {}),\r\n\t\tentityId: -1,\r\n\t\tattack: damage,\r\n\t\tattacking: true,\r\n\t} as BoardEntity;\r\n\tconst actualDamageDone = bumpEntities(\r\n\t\tdefendingEntity,\r\n\t\tfakeAttacker,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\tboardWithAttackOrigin,\r\n\t\tboardWithAttackOriginHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\tconst defendingEntityIndex = defendingBoard.map((entity) => entity.entityId).indexOf(defendingEntity.entityId);\r\n\tdefendingBoard[defendingEntityIndex] = defendingEntity;\r\n\treturn actualDamageDone;\r\n};\r\n\r\nexport const getDefendingEntity = (defendingBoard: BoardEntity[], attackingEntity: BoardEntity, ignoreTaunts = false): BoardEntity => {\r\n\tlet possibleDefenders: readonly BoardEntity[];\r\n\tif (attackingEntity.cardId === CardIds.ZappSlywick || attackingEntity.cardId === CardIds.ZappSlywickBattlegrounds) {\r\n\t\tconst minAttack = Math.min(...defendingBoard.map((entity) => entity.attack));\r\n\t\tpossibleDefenders = defendingBoard.filter((entity) => entity.attack === minAttack);\r\n\t} else if (!ignoreTaunts) {\r\n\t\tconst taunts = defendingBoard.filter((entity) => entity.taunt);\r\n\t\tpossibleDefenders = taunts.length > 0 ? taunts : defendingBoard;\r\n\t} else {\r\n\t\tpossibleDefenders = defendingBoard;\r\n\t}\r\n\tlet chosenDefender = possibleDefenders[Math.floor(Math.random() * possibleDefenders.length)];\r\n\tif (chosenDefender.taunt) {\r\n\t\tconst elistras = defendingBoard.filter(\r\n\t\t\t(entity) => entity.cardId === CardIds.ElistraTheImmortal2 || entity.cardId === CardIds.ElistraTheImmortalBattlegrounds,\r\n\t\t);\r\n\t\tif (elistras.length > 0) {\r\n\t\t\tchosenDefender = elistras[Math.floor(Math.random() * elistras.length)];\r\n\t\t}\r\n\t}\r\n\treturn chosenDefender;\r\n};\r\nexport const bumpEntities = (\r\n\tentity: BoardEntity,\r\n\tbumpInto: BoardEntity,\r\n\tentityBoard: BoardEntity[],\r\n\tentityBoardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// No attack has no impact\r\n\tif (bumpInto.attack === 0) {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tif (entity.divineShield) {\r\n\t\t// Handle all the divine shield loss effects here\r\n\t\tfor (let i = 0; i < entityBoard.length; i++) {\r\n\t\t\tif (entityBoard[i].cardId === CardIds.BolvarFireblood) {\r\n\t\t\t\tmodifyAttack(entityBoard[i], 2, entityBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(entityBoard[i], entityBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(entityBoard[i], entityBoard[i], entityBoard);\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.BolvarFirebloodBattlegrounds) {\r\n\t\t\t\tmodifyAttack(entityBoard[i], 4, entityBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(entityBoard[i], entityBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(entityBoard[i], entityBoard[i], entityBoard);\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.DrakonidEnforcer) {\r\n\t\t\t\tmodifyAttack(entityBoard[i], 2, entityBoard, allCards);\r\n\t\t\t\tmodifyHealth(entityBoard[i], 2, entityBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(entityBoard[i], entityBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(entityBoard[i], entityBoard[i], entityBoard);\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.DrakonidEnforcerBattlegrounds) {\r\n\t\t\t\tmodifyAttack(entityBoard[i], 4, entityBoard, allCards);\r\n\t\t\t\tmodifyHealth(entityBoard[i], 4, entityBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(entityBoard[i], entityBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(entityBoard[i], entityBoard[i], entityBoard);\r\n\t\t\t} else if (\r\n\t\t\t\tentityBoard[i].entityId !== entity.entityId &&\r\n\t\t\t\t(entityBoard[i].cardId === CardIds.HolyMecherel || entityBoard[i].cardId === CardIds.HolyMecherelBattlegrounds)\r\n\t\t\t) {\r\n\t\t\t\tentityBoard[i].divineShield = true;\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.Gemsplitter) {\r\n\t\t\t\taddCardsInHand(entityBoardHero, 1, entityBoard, allCards, spectator, CardIds.BloodGem);\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.GemsplitterBattlegrounds) {\r\n\t\t\t\taddCardsInHand(entityBoardHero, 2, entityBoard, allCards, spectator, CardIds.BloodGem);\r\n\t\t\t}\r\n\r\n\t\t\t// So that self-buffs from Bolvar are taken into account\r\n\t\t\tif (entityBoard[i].entityId === entity.entityId) {\r\n\t\t\t\tentity.divineShield = false;\r\n\t\t\t}\r\n\t\t}\r\n\t\tconst greaseBots = entityBoard.filter((entity) => entity.cardId === CardIds.GreaseBot);\r\n\t\tconst greaseBotBattlegrounds = entityBoard.filter((entity) => entity.cardId === CardIds.GreaseBotBattlegrounds);\r\n\t\tgreaseBots.forEach((bot) => {\r\n\t\t\tmodifyAttack(entity, 1, entityBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 1, entityBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(bot, entity, entityBoard);\r\n\t\t});\r\n\t\tgreaseBotBattlegrounds.forEach((bot) => {\r\n\t\t\tmodifyAttack(entity, 2, entityBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 2, entityBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(bot, entity, entityBoard);\r\n\t\t});\r\n\t\tspectator.registerDamageDealt(bumpInto, entity, 0, entityBoard);\r\n\t\treturn 0;\r\n\t\t// return entity;\r\n\t}\r\n\tentity.health = entity.health - bumpInto.attack;\r\n\t// Do it last, so that other effects are still processed\r\n\tif (bumpInto.poisonous) {\r\n\t\t// So that further buffs don't revive it\r\n\t\t// And we don't just set the health to avoid applying overkill effects\r\n\t\tentity.definitelyDead = true;\r\n\t\t// return entity;\r\n\t}\r\n\t// FIXME: This will likely be incorrect in terms of timings, e.g. if the entity ends up\r\n\t// surviving following a buff like Spawn.\r\n\tspectator.registerDamageDealt(bumpInto, entity, bumpInto.attack, entityBoard);\r\n\tentity.lastAffectedByEntity = bumpInto;\r\n\tif (!entity.frenzyApplied && entity.health > 0 && !entity.definitelyDead) {\r\n\t\tapplyFrenzy(entity, entityBoard, entityBoardHero, allCards, cardsData, sharedState, spectator);\r\n\t\tentity.frenzyApplied = true;\r\n\t}\r\n\r\n\t// We spawn them here, because it says \"whenever\", and so happens right away\r\n\t// FIXME: there could be a bug here, if a Cleave attacks several IGB at the same time. The current\r\n\t// implementation could spawn minions above the max board size. Fringe case though, so leaving it\r\n\t// like this for now\r\n\tconst entitySpawns = getWheneverEntitySpawns(\r\n\t\tentity,\r\n\t\tentityBoard,\r\n\t\tentityBoardHero,\r\n\t\totherBoard,\r\n\t\totherHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\tif (!!entitySpawns?.length) {\r\n\t\tconst index = entityBoard.map((e) => e.entityId).indexOf(entity.entityId);\r\n\t\tentityBoard.splice(index + 1, 0, ...entitySpawns);\r\n\t\tspectator.registerMinionsSpawn(entity, entityBoard, entitySpawns);\r\n\t\thandleSpawnEffects(entityBoard, entitySpawns, allCards, spectator);\r\n\t}\r\n\treturn bumpInto.attack;\r\n};\r\n\r\nconst getWheneverEntitySpawns = (\r\n\tentity: BoardEntity,\r\n\tentityBoard: BoardEntity[],\r\n\tentityBoardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): readonly BoardEntity[] => {\r\n\tif (entityBoard.length === 7) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tif (entity.cardId === CardIds.ImpGangBoss) {\r\n\t\treturn spawnEntities(\r\n\t\t\tCardIds.ImpGangBoss_ImpToken,\r\n\t\t\t1,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t} else if (entity.cardId === CardIds.ImpGangBossBattlegrounds) {\r\n\t\treturn spawnEntities(\r\n\t\t\tCardIds.ImpGangBoss_ImpTokenBattlegrounds,\r\n\t\t\t1,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t} else if (entity.cardId === CardIds.ImpMama) {\r\n\t\treturn spawnEntities(\r\n\t\t\tcardsData.impMamaSpawns[Math.floor(Math.random() * cardsData.impMamaSpawns.length)],\r\n\t\t\t1,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t).map((entity) => ({ ...entity, taunt: true }));\r\n\t} else if (entity.cardId === CardIds.ImpMamaBattlegrounds) {\r\n\t\treturn spawnEntities(\r\n\t\t\tcardsData.impMamaSpawns[Math.floor(Math.random() * cardsData.impMamaSpawns.length)],\r\n\t\t\t2,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t).map((entity) => ({ ...entity, taunt: true }));\r\n\t} else if (entity.cardId === CardIds.SecurityRover) {\r\n\t\treturn spawnEntities(\r\n\t\t\tCardIds.SecurityRover_GuardBotToken,\r\n\t\t\t1,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t} else if (entity.cardId === CardIds.SecurityRoverBattlegrounds) {\r\n\t\treturn spawnEntities(\r\n\t\t\tCardIds.SecurityRover_GuardBotTokenBattlegrounds,\r\n\t\t\t1,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t}\r\n\treturn null;\r\n};\r\n\r\nexport const processMinionDeath = (\r\n\tboard1: BoardEntity[],\r\n\tboard1Hero: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tboard2Hero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst [deadMinionIndexes1, deadEntities1] = makeMinionsDie(board1, allCards);\r\n\tconst [deadMinionIndexes2, deadEntities2] = makeMinionsDie(board2, allCards);\r\n\tspectator.registerDeadEntities(deadMinionIndexes1, deadEntities1, deadMinionIndexes2, deadEntities2);\r\n\t// No death to process, we can return\r\n\tif (deadEntities1.length === 0 && deadEntities2.length === 0) {\r\n\t\treturn;\r\n\t\t// return [board1, board2];\r\n\t}\r\n\r\n\tsharedState.deaths.push(...deadEntities1);\r\n\tsharedState.deaths.push(...deadEntities2);\r\n\r\n\t// First process all DRs, then process the reborn\r\n\tif (Math.random() > 0.5) {\r\n\t\t// Now proceed to trigger all deathrattle effects on baord1\r\n\t\thandleDeathrattlesForFirstBoard(\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdeadMinionIndexes1,\r\n\t\t\tdeadEntities1,\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// Now handle the other board's deathrattles\r\n\t\thandleDeathrattlesForFirstBoard(\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdeadMinionIndexes2,\r\n\t\t\tdeadEntities2,\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\thandleDeathrattlesForFirstBoard(\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdeadMinionIndexes2,\r\n\t\t\tdeadEntities2,\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\thandleDeathrattlesForFirstBoard(\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdeadMinionIndexes1,\r\n\t\t\tdeadEntities1,\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\r\n\t// Now the reborn\r\n\tif (Math.random() > 0.5) {\r\n\t\t// Now proceed to trigger all deathrattle effects on baord1\r\n\t\thandleRebornForFirstBoard(\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdeadMinionIndexes1,\r\n\t\t\tdeadEntities1,\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// Now handle the other board's deathrattles\r\n\t\thandleRebornForFirstBoard(\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdeadMinionIndexes2,\r\n\t\t\tdeadEntities2,\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\thandleRebornForFirstBoard(\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdeadMinionIndexes2,\r\n\t\t\tdeadEntities2,\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\thandleRebornForFirstBoard(\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdeadMinionIndexes1,\r\n\t\t\tdeadEntities1,\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\t// Make sure we only return when there are no more deaths to process\r\n\t// FIXME: this will propagate the killer between rounds, which is incorrect. For instance,\r\n\t// if a dragon kills a Ghoul, then the Ghoul's deathrattle kills a Kaboom, the killer should\r\n\t// now be the ghoul. Then if the Kaboom kills someone, the killer should again change. You could\r\n\t// also have multiple killers, which is not taken into account here.\r\n\t// The current assumption is that it's a suffienctly fringe case to not matter too much\r\n\tprocessMinionDeath(board1, board1Hero, board2, board2Hero, allCards, cardsData, sharedState, spectator);\r\n\r\n\t// If the fish dies (from Scallywag for instance), it doesn't remember the deathrattle\r\n\tboard1\r\n\t\t.filter(\r\n\t\t\t(entity) =>\r\n\t\t\t\tentity.cardId === CardIds.AvatarOfNzoth_FishOfNzothTokenBattlegrounds || entity.cardId === CardIds.FishOfNzothBattlegrounds,\r\n\t\t)\r\n\t\t.forEach((entity) => rememberDeathrattles(entity, deadEntities1, cardsData));\r\n\tboard2\r\n\t\t.filter(\r\n\t\t\t(entity) =>\r\n\t\t\t\tentity.cardId === CardIds.AvatarOfNzoth_FishOfNzothTokenBattlegrounds || entity.cardId === CardIds.FishOfNzothBattlegrounds,\r\n\t\t)\r\n\t\t.forEach((entity) => rememberDeathrattles(entity, deadEntities2, cardsData));\r\n\r\n\tboard1\r\n\t\t.filter((entity) => entity.cardId === CardIds.Monstrosity || entity.cardId === CardIds.MonstrosityBattlegrounds)\r\n\t\t.forEach((entity) => applyMonstrosity(entity, deadEntities1, board1, allCards));\r\n\tboard2\r\n\t\t.filter((entity) => entity.cardId === CardIds.Monstrosity || entity.cardId === CardIds.MonstrosityBattlegrounds)\r\n\t\t.forEach((entity) => applyMonstrosity(entity, deadEntities2, board2, allCards));\r\n\r\n\t// Apply \"after minion death\" effects\r\n\thandleAfterMinionsDeaths(\r\n\t\tboard1,\r\n\t\tdeadEntities1,\r\n\t\tboard1Hero,\r\n\t\tboard2,\r\n\t\tdeadEntities2,\r\n\t\tboard2Hero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n};\r\n\r\nconst handleAfterMinionsDeaths = (\r\n\tboard1: BoardEntity[],\r\n\tdeadEntities1: BoardEntity[],\r\n\theroEntity1: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tdeadEntities2: BoardEntity[],\r\n\theroEntity2: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n) => {\r\n\tconst random = Math.random() > 0.5;\r\n\thandleAfterMinionsDeathsForBoard(\r\n\t\trandom ? board1 : board2,\r\n\t\trandom ? deadEntities1 : deadEntities2,\r\n\t\trandom ? heroEntity1 : heroEntity2,\r\n\t\trandom ? board2 : board1,\r\n\t\trandom ? deadEntities2 : deadEntities1,\r\n\t\trandom ? heroEntity2 : heroEntity1,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\thandleAfterMinionsDeathsForBoard(\r\n\t\t!random ? board1 : board2,\r\n\t\t!random ? deadEntities1 : deadEntities2,\r\n\t\t!random ? heroEntity1 : heroEntity2,\r\n\t\t!random ? board2 : board1,\r\n\t\t!random ? deadEntities2 : deadEntities1,\r\n\t\t!random ? heroEntity2 : heroEntity1,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n};\r\n\r\nconst handleAfterMinionsDeathsForBoard = (\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyDeadEntities: BoardEntity[],\r\n\tfriendlyHeroEntity: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherDeadEntities: BoardEntity[],\r\n\totherHeroEntity: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n) => {\r\n\tfor (const deadEntity of friendlyDeadEntities) {\r\n\t\tconst killer = deadEntity.lastAffectedByEntity;\r\n\t\tif (!killer) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\t\t// Killed an enemy minion\r\n\t\tif (killer.friendly !== deadEntity.friendly) {\r\n\t\t\tif (otherHeroEntity.heroPowerId === CardIds.Rokara_GloryOfCombat) {\r\n\t\t\t\tmodifyAttack(killer, 1, otherBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(killer, otherBoard, allCards);\r\n\t\t\t\t// Icesnarl the Mighty\r\n\t\t\t\totherBoard\r\n\t\t\t\t\t.filter((e) => e.cardId === CardIds.IcesnarlTheMighty || e.cardId === CardIds.IcesnarlTheMightyBattlegrounds)\r\n\t\t\t\t\t.forEach((icesnarl) => {\r\n\t\t\t\t\t\tmodifyHealth(icesnarl, icesnarl.cardId === CardIds.IcesnarlTheMightyBattlegrounds ? 2 : 1, friendlyBoard, allCards);\r\n\t\t\t\t\t\tafterStatsUpdate(icesnarl, friendlyBoard, allCards);\r\n\t\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleDeathrattlesForFirstBoard = (\r\n\tfirstBoard: BoardEntity[],\r\n\tfirstBoardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tdeadMinionIndexes: readonly number[],\r\n\tdeadEntities: readonly BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tfor (let i = 0; i < deadMinionIndexes.length; i++) {\r\n\t\tconst entity = deadEntities[i];\r\n\t\tconst index = deadMinionIndexes[i];\r\n\t\tif (entity.health <= 0 || entity.definitelyDead) {\r\n\t\t\tbuildBoardAfterDeathrattleSpawns(\r\n\t\t\t\tfirstBoard,\r\n\t\t\t\tfirstBoardHero,\r\n\t\t\t\tentity,\r\n\t\t\t\tindex,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t} else if (firstBoard.length > 0) {\r\n\t\t\t// const newBoardD = [...firstBoard];\r\n\t\t\tfirstBoard.splice(index, 1, entity);\r\n\t\t\t// firstBoard = newBoardD;\r\n\t\t}\r\n\t}\r\n\t// return [firstBoard, otherBoard];\r\n};\r\n\r\nconst handleRebornForFirstBoard = (\r\n\tfirstBoard: BoardEntity[],\r\n\tfirstBoardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tdeadMinionIndexes: readonly number[],\r\n\tdeadEntities: readonly BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tfor (let i = 0; i < deadMinionIndexes.length; i++) {\r\n\t\tconst entity = deadEntities[i];\r\n\t\tconst index = deadMinionIndexes[i];\r\n\t\tif (entity.health <= 0 || entity.definitelyDead) {\r\n\t\t\tbuildBoardAfterRebornSpawns(\r\n\t\t\t\tfirstBoard,\r\n\t\t\t\tfirstBoardHero,\r\n\t\t\t\tentity,\r\n\t\t\t\tindex,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t} else if (firstBoard.length > 0) {\r\n\t\t\t// const newBoardD = [...firstBoard];\r\n\t\t\tfirstBoard.splice(index, 1, entity);\r\n\t\t\t// firstBoard = newBoardD;\r\n\t\t}\r\n\t}\r\n\t// return [firstBoard, otherBoard];\r\n};\r\n\r\nexport const applyOnAttackBuffs = (\r\n\tattacker: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (attacker.cardId === CardIds.GlyphGuardian2) {\r\n\t\t// For now the utility method only works additively, so we hack around it\r\n\t\tmodifyAttack(attacker, 2 * attacker.attack - attacker.attack, attackingBoard, allCards);\r\n\t}\r\n\tif (attacker.cardId === CardIds.GlyphGuardianBattlegrounds) {\r\n\t\tmodifyAttack(attacker, 3 * attacker.attack - attacker.attack, attackingBoard, allCards);\r\n\t}\r\n\r\n\t// Ripsnarl Captain\r\n\tif (isCorrectTribe(allCards.getCard(attacker.cardId).race, Race.PIRATE)) {\r\n\t\tconst ripsnarls = attackingBoard\r\n\t\t\t.filter((e) => e.cardId === CardIds.RipsnarlCaptain)\r\n\t\t\t.filter((e) => e.entityId !== attacker.entityId);\r\n\t\tconst ripsnarlsTB = attackingBoard\r\n\t\t\t.filter((entity) => entity.cardId === CardIds.RipsnarlCaptainBattlegrounds)\r\n\t\t\t.filter((e) => e.entityId !== attacker.entityId);\r\n\t\tripsnarls.forEach((captain) => {\r\n\t\t\tmodifyAttack(attacker, 2, attackingBoard, allCards);\r\n\t\t\tmodifyHealth(attacker, 2, attackingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(captain, attacker, attackingBoard);\r\n\t\t});\r\n\t\tripsnarlsTB.forEach((captain) => {\r\n\t\t\tmodifyAttack(attacker, 4, attackingBoard, allCards);\r\n\t\t\tmodifyHealth(attacker, 4, attackingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(captain, attacker, attackingBoard);\r\n\t\t});\r\n\t}\r\n\r\n\t// Dread Admiral Eliza\r\n\tif (isCorrectTribe(allCards.getCard(attacker.cardId).race, Race.PIRATE)) {\r\n\t\tconst elizas = attackingBoard.filter((e) => e.cardId === CardIds.DreadAdmiralEliza);\r\n\t\tconst elizasTB = attackingBoard.filter((e) => e.cardId === CardIds.DreadAdmiralElizaBattlegrounds);\r\n\r\n\t\telizas.forEach((eliza) => {\r\n\t\t\tattackingBoard.forEach((entity) => {\r\n\t\t\t\tmodifyAttack(entity, 2, attackingBoard, allCards);\r\n\t\t\t\tmodifyHealth(entity, 1, attackingBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(eliza, entity, attackingBoard);\r\n\t\t\t});\r\n\t\t});\r\n\t\telizasTB.forEach((eliza) => {\r\n\t\t\tattackingBoard.forEach((entity) => {\r\n\t\t\t\tmodifyAttack(entity, 4, attackingBoard, allCards);\r\n\t\t\t\tmodifyHealth(entity, 2, attackingBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(eliza, entity, attackingBoard);\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const applyOnBeingAttackedBuffs = (\r\n\tattackedEntity: BoardEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (attackedEntity.taunt) {\r\n\t\tconst champions = defendingBoard.filter((entity) => entity.cardId === CardIds.ChampionOfYshaarj);\r\n\t\tconst goldenChampions = defendingBoard.filter((entity) => entity.cardId === CardIds.ChampionOfYshaarjBattlegrounds);\r\n\t\tchampions.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 1, defendingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 1, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(entity, entity, defendingBoard);\r\n\t\t});\r\n\t\tgoldenChampions.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 2, defendingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 2, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(entity, entity, defendingBoard);\r\n\t\t});\r\n\r\n\t\tconst arms = defendingBoard.filter((entity) => entity.cardId === CardIds.ArmOfTheEmpire);\r\n\t\tconst goldenArms = defendingBoard.filter((entity) => entity.cardId === CardIds.ArmOfTheEmpireBattlegrounds);\r\n\t\tarms.forEach((arm) => {\r\n\t\t\tmodifyAttack(attackedEntity, 2, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(arm, attackedEntity, defendingBoard);\r\n\t\t});\r\n\t\tgoldenArms.forEach((arm) => {\r\n\t\t\tmodifyAttack(attackedEntity, 4, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(arm, attackedEntity, defendingBoard);\r\n\t\t});\r\n\t}\r\n\tif (attackedEntity.cardId === CardIds.TormentedRitualist) {\r\n\t\tconst neighbours = getNeighbours(defendingBoard, attackedEntity);\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 1, defendingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 1, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(attackedEntity, entity, defendingBoard);\r\n\t\t});\r\n\t}\r\n\tif (attackedEntity.cardId === CardIds.TormentedRitualistBattlegrounds) {\r\n\t\tconst neighbours = getNeighbours(defendingBoard, attackedEntity);\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 2, defendingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 2, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(attackedEntity, entity, defendingBoard);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nconst makeMinionsDie = (board: BoardEntity[], allCards: AllCardsService): [number[], BoardEntity[]] => {\r\n\tconst deadMinionIndexes: number[] = [];\r\n\tconst deadEntities: BoardEntity[] = [];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tconst index = board.map((entity) => entity.entityId).indexOf(board[i].entityId);\r\n\t\tif (board[i].health <= 0 || board[i].definitelyDead) {\r\n\t\t\tdeadMinionIndexes.push(i);\r\n\t\t\tdeadEntities.push(board[i]);\r\n\t\t\tboard.splice(index, 1);\r\n\t\t\t// We modify the original array, so we need to update teh current index accordingly\r\n\t\t\ti--;\r\n\t\t}\r\n\t}\r\n\treturn [deadMinionIndexes, deadEntities];\r\n};\r\n\r\n// const handleKillEffects = (\r\n// \tboardWithKilledMinion: BoardEntity[],\r\n// \tkillerBoard: BoardEntity[],\r\n// \tdeadEntity: BoardEntity,\r\n// \tallCards: AllCardsService,\r\n// \tspectator: Spectator,\r\n// ): void => {\r\n// \tif (\r\n// \t\tdeadEntity.lastAffectedByEntity?.cardId &&\r\n// \t\tisCorrectTribe(allCards.getCard(deadEntity.lastAffectedByEntity.cardId).race, Race.DRAGON)\r\n// \t) {\r\n// \t\tfor (const entity of killerBoard) {\r\n// \t\t\tif (entity.cardId === CardIds.WaxriderTogwaggle2) {\r\n// \t\t\t\tmodifyAttack(entity, 2, killerBoard, allCards);\r\n// \t\t\t\tmodifyHealth(entity, 2, killerBoard, allCards);\r\n// \t\t\t\tafterStatsUpdate(entity, killerBoard, allCards);\r\n// \t\t\t\tspectator.registerPowerTarget(entity, entity, killerBoard);\r\n// \t\t\t} else if (entity.cardId === CardIds.WaxriderTogwaggleBattlegrounds) {\r\n// \t\t\t\tmodifyAttack(entity, 4, killerBoard, allCards);\r\n// \t\t\t\tmodifyHealth(entity, 4, killerBoard, allCards);\r\n// \t\t\t\tafterStatsUpdate(entity, killerBoard, allCards);\r\n// \t\t\t\tspectator.registerPowerTarget(entity, entity, killerBoard);\r\n// \t\t\t}\r\n// \t\t}\r\n// \t}\r\n// };\r\n\r\nconst buildBoardAfterDeathrattleSpawns = (\r\n\tboardWithKilledMinion: BoardEntity[],\r\n\tboardWithKilledMinionHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tdeadMinionIndex: number,\r\n\topponentBoard: BoardEntity[],\r\n\topponentBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// TODO: don't apply this for FishOfNZoth\r\n\t// if (deadMinionIndex >= 0) {\r\n\t// \thandleKillEffects(boardWithKilledMinion, opponentBoard, deadEntity, allCards, spectator);\r\n\t// }\r\n\r\n\t// But Wildfire Element is applied first, before the DR spawns\r\n\tif (deadMinionIndex >= 0) {\r\n\t\tapplyMinionDeathEffect(\r\n\t\t\tdeadEntity,\r\n\t\t\tdeadMinionIndex,\r\n\t\t\tboardWithKilledMinion,\r\n\t\t\tboardWithKilledMinionHero,\r\n\t\t\topponentBoard,\r\n\t\t\topponentBoardHero,\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\tconst entitiesFromNativeDeathrattle: readonly BoardEntity[] = spawnEntitiesFromDeathrattle(\r\n\t\tdeadEntity,\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\r\n\tconst entitiesFromEnchantments: readonly BoardEntity[] = spawnEntitiesFromEnchantments(\r\n\t\tdeadEntity,\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\r\n\tconst candidateEntities: readonly BoardEntity[] = [...entitiesFromNativeDeathrattle, ...entitiesFromEnchantments];\r\n\tperformEntitySpawns(\r\n\t\tcandidateEntities,\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\tdeadEntity,\r\n\t\tdeadMinionIndex,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\r\n\t// In case of leapfrogger, we want to first spawn the minions, then apply the frog effect\r\n\thandleDeathrattleEffects(\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\tdeadEntity,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\r\n\t// eslint-disable-next-line prettier/prettier\r\n\tif (deadEntity.rememberedDeathrattles?.length) {\r\n\t\tfor (const deathrattle of deadEntity.rememberedDeathrattles) {\r\n\t\t\tconst entityToProcess: BoardEntity = {\r\n\t\t\t\t...deadEntity,\r\n\t\t\t\trememberedDeathrattles: undefined,\r\n\t\t\t\tcardId: deathrattle,\r\n\t\t\t\tenchantments: [\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcardId: deathrattle,\r\n\t\t\t\t\t\toriginEntityId: deadEntity.entityId,\r\n\t\t\t\t\t},\r\n\t\t\t\t],\r\n\t\t\t};\r\n\t\t\tbuildBoardAfterDeathrattleSpawns(\r\n\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\tentityToProcess,\r\n\t\t\t\tdeadMinionIndex,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\t// TODO: check if Avenge effects should proc after deathrattles instead\r\n\t// They most certainly do, since the rat pack + avenge beast buffer works\r\n\tapplyAvengeEffects(\r\n\t\tdeadEntity,\r\n\t\tdeadMinionIndex,\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n};\r\n\r\nconst buildBoardAfterRebornSpawns = (\r\n\tboardWithKilledMinion: BoardEntity[],\r\n\tboardWithKilledMinionHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tdeadMinionIndex: number,\r\n\topponentBoard: BoardEntity[],\r\n\topponentBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst otherEntityCardIds = boardWithKilledMinion.filter((e) => e.entityId !== deadEntity.entityId).map((e) => e.cardId);\r\n\tconst numberOfReborns =\r\n\t\t1 +\r\n\t\t1 * otherEntityCardIds.filter((cardId) => cardId === CardIds.ArfusBattlegrounds1).length +\r\n\t\t2 * otherEntityCardIds.filter((cardId) => cardId === CardIds.ArfusBattlegrounds2).length;\r\n\t// Reborn happens after deathrattles\r\n\tconst entitiesFromReborn: readonly BoardEntity[] =\r\n\t\tdeadEntity.reborn && deadMinionIndex >= 0\r\n\t\t\t? spawnEntities(\r\n\t\t\t\t\tdeadEntity.cardId,\r\n\t\t\t\t\tnumberOfReborns,\r\n\t\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentBoardHero,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tcardsData,\r\n\t\t\t\t\tsharedState,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\ttrue,\r\n\t\t\t )\r\n\t\t\t: [];\r\n\tperformEntitySpawns(\r\n\t\tentitiesFromReborn,\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\tdeadEntity,\r\n\t\tdeadMinionIndex,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n};\r\n\r\nexport const performEntitySpawns = (\r\n\tcandidateEntities: readonly BoardEntity[],\r\n\tboardWithKilledMinion: BoardEntity[],\r\n\tboardWithKilledMinionHero: BgsPlayerEntity,\r\n\tspawnSourceEntity: BoardEntity,\r\n\tspawnSourceEntityIndex: number,\r\n\topponentBoard: BoardEntity[],\r\n\topponentBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): readonly BoardEntity[] => {\r\n\tconst aliveEntites = candidateEntities.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\r\n\t// const roomToSpawn: number = 7 - boardWithKilledMinion.length;\r\n\t// const spawnedEntities: readonly BoardEntity[] = aliveEntites.slice(0, roomToSpawn);\r\n\r\n\tconst indexFromRight = boardWithKilledMinion.length - spawnSourceEntityIndex;\r\n\tconst spawnedEntities = [];\r\n\tfor (const newMinion of aliveEntites) {\r\n\t\t// All entities have been spawned\r\n\t\tif (boardWithKilledMinion.length >= 7) {\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t// Avoid minions spawning backwards (we don't have this issue if we add all elements at\r\n\t\t// the same time, but here we want to be able to attack after each spawn, which in turn\r\n\t\t// means that the minion can die before the other one spawns)\r\n\t\t// In boardWithKilledMinion, the dead minion has already been removed\r\n\t\tboardWithKilledMinion.splice(boardWithKilledMinion.length - indexFromRight, 0, newMinion);\r\n\t\tif (newMinion.attackImmediately) {\r\n\t\t\t// Whenever we are already in a combat phase, we need to first clean up the state\r\n\t\t\tremoveAuras(boardWithKilledMinion, cardsData);\r\n\t\t\tremoveAuras(opponentBoard, cardsData);\r\n\t\t\tsimulateAttack(\r\n\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentBoardHero,\r\n\t\t\t\tnull,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t\tif (newMinion.health > 0 && !newMinion.definitelyDead) {\r\n\t\t\tspawnedEntities.push(newMinion);\r\n\t\t}\r\n\t}\r\n\r\n\t// Minion has already been removed from the board in the previous step\r\n\thandleSpawnEffects(boardWithKilledMinion, spawnedEntities, allCards, spectator);\r\n\tspectator.registerMinionsSpawn(spawnSourceEntity, boardWithKilledMinion, spaw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IAAI,CAAC,CAAC;YAC5C,sBAAc,CACb,qBAAqB,EACrB,yBAAyB,EACzB,aAAa,EACb,iBAAiB,EACjB,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,WAAW,EACX,SAAS,CACT,CAAC;SACF;QACD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE;YACtD,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAChC;KACD;IAGD,iCAAkB,CAAC,qBAAqB,EAAE,eAAe,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAChF,SAAS,CAAC,oBAAoB,CAAC,iBAAiB,EAAE,qBAAqB,EAAE,eAAe,CAAC,CAAC;IAC1F,OAAO,eAAe,CAAC;AACxB,CAAC,CAAC;AAvDW,QAAA,mBAAmB,uBAuD9B","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds, 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 { pickRandom } from '../services/utils';\r\nimport { validEnchantments } from '../simulate-bgs-battle';\r\nimport { addCardsInHand, afterStatsUpdate, hasCorrectTribe, hasMechanic, isCorrectTribe, modifyAttack, modifyHealth } from '../utils';\r\nimport { applyAuras, removeAuras } from './auras';\r\nimport { applyAvengeEffects } from './avenge';\r\nimport { applyMinionDeathEffect, applyMonstrosity, handleDeathrattleEffects, rememberDeathrattles } from './deathrattle-effects';\r\nimport { spawnEntities, spawnEntitiesFromDeathrattle, spawnEntitiesFromEnchantments } from './deathrattle-spawns';\r\nimport { applyFrenzy } from './frenzy';\r\nimport { SharedState } from './shared-state';\r\nimport { handleSpawnEffects } from './spawn-effect';\r\nimport { Spectator } from './spectator/spectator';\r\nimport { getHeroPowerForHero } from './start-of-combat';\r\n\r\n// Only use it to simulate actual attack. To simulate damage, or something similar, use bumpInto\r\nexport const simulateAttack = (\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tlastAttackerEntityId: number,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n\tforceAttackingEntityIndex?: number,\r\n): number => {\r\n\tif (attackingBoard.length === 0 || defendingBoard.length === 0) {\r\n\t\treturn;\r\n\t}\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\r\n\tconst attackingEntity =\r\n\t\tforceAttackingEntityIndex != null\r\n\t\t\t? attackingBoard[forceAttackingEntityIndex]\r\n\t\t\t: getAttackingEntity(attackingBoard, lastAttackerEntityId);\r\n\tconst attackingEntityIndex = attackingBoard.map((e) => e.entityId).indexOf(attackingEntity?.entityId);\r\n\tif (attackingEntity) {\r\n\t\tattackingEntity.attacking = true;\r\n\t\t// console.log('attack by', stringifySimpleCard(attackingEntity, allCards), attackingEntity.attacking, new Error().stack);\r\n\t\tconst numberOfAttacks = attackingEntity.megaWindfury ? 4 : attackingEntity.windfury ? 2 : 1;\r\n\t\tfor (let i = 0; i < numberOfAttacks; i++) {\r\n\t\t\t// We refresh the entity in case of windfury\r\n\t\t\tif (attackingBoard.length === 0 || defendingBoard.length === 0) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\t// The auras need to be handled on a per-attack basis, as otherwise minions that spawn\r\n\t\t\t// in-between attacks don't get aura buffs\r\n\t\t\tapplyAuras(attackingBoard, numberOfDeathwingPresents, spawns, allCards);\r\n\t\t\tapplyAuras(defendingBoard, numberOfDeathwingPresents, spawns, allCards);\r\n\t\t\t// Check that didn't die\r\n\t\t\tif (attackingBoard.find((entity) => entity.entityId === attackingEntity.entityId)) {\r\n\t\t\t\tapplyOnAttackBuffs(attackingEntity, attackingBoard, allCards, spectator);\r\n\t\t\t\tconst defendingEntity: BoardEntity = getDefendingEntity(defendingBoard, attackingEntity);\r\n\t\t\t\tspectator.registerAttack(attackingEntity, defendingEntity, attackingBoard, defendingBoard);\r\n\t\t\t\tapplyOnBeingAttackedBuffs(defendingEntity, defendingBoard, allCards, spectator);\r\n\t\t\t\tperformAttack(\r\n\t\t\t\t\tattackingEntity,\r\n\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tspawns,\r\n\t\t\t\t\tsharedState,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t);\r\n\t\t\t\tapplyAfterAttackEffects(attackingEntity, attackingBoard, attackingBoardHero, allCards, spectator);\r\n\t\t\t\t// FIXME: I don't know the behavior with Windfury. Should the attack be done right away, before\r\n\t\t\t\t// the windfury triggers again? The current behavior attacks after the windfury is over\r\n\t\t\t\tif (\r\n\t\t\t\t\tdefendingEntity.health > 0 &&\r\n\t\t\t\t\t!defendingEntity.definitelyDead &&\r\n\t\t\t\t\t(defendingEntity.cardId === CardIds.YoHoOgre || defendingEntity.cardId === CardIds.YoHoOgreBattlegrounds)\r\n\t\t\t\t) {\r\n\t\t\t\t\tdefendingEntity.attackImmediately = true;\r\n\t\t\t\t}\r\n\t\t\t\t// console.log(\r\n\t\t\t\t// \t'after attack by',\r\n\t\t\t\t// \tstringifySimpleCard(attackingEntity, allCards),\r\n\t\t\t\t// \tstringifySimpleCard(defendingEntity, allCards),\r\n\t\t\t\t// );\r\n\t\t\t}\r\n\t\t\tremoveAuras(attackingBoard, spawns);\r\n\t\t\tremoveAuras(defendingBoard, spawns);\r\n\t\t}\r\n\t\tattackingEntity.attacking = false;\r\n\t}\r\n\t// If entities that were before the attacker died, we need to update the attacker index\r\n\treturn attackingEntityIndex;\r\n};\r\n\r\nconst applyAfterAttackEffects = (\r\n\tattackingEntity: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (attackingEntity.cardId === CardIds.Bonker || attackingEntity.cardId === CardIds.BonkerBattlegrounds) {\r\n\t\taddCardsInHand(attackingBoardHero, 1, attackingBoard, allCards, spectator, CardIds.BloodGem);\r\n\t}\r\n};\r\n\r\nconst performAttack = (\r\n\tattackingEntity: BoardEntity,\r\n\tdefendingEntity: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (hasCorrectTribe(attackingEntity, Race.DRAGON, allCards)) {\r\n\t\tconst prestors = attackingBoard\r\n\t\t\t.filter((e) => e.entityId !== attackingEntity.entityId)\r\n\t\t\t.filter((e) => e.cardId === CardIds.PrestorsPyrospawn || e.cardId === CardIds.PrestorsPyrospawnBattlegrounds);\r\n\t\tprestors.forEach((prestor) => {\r\n\t\t\tspectator.registerPowerTarget(prestor, defendingEntity, defendingBoard);\r\n\t\t\tdealDamageToEnemy(\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tprestor,\r\n\t\t\t\tprestor.cardId === CardIds.PrestorsPyrospawnBattlegrounds ? 6 : 3,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\r\n\tif ([CardIds.BabyKrush, CardIds.BabyKrushBattlegrounds].includes(attackingEntity.cardId as CardIds)) {\r\n\t\tconst spawns = spawnEntities(\r\n\t\t\tattackingEntity.cardId === CardIds.BabyKrushBattlegrounds ? CardIds.DevilsaurBattlegrounds : CardIds.BabyKrush_DevilsaurToken,\r\n\t\t\t1,\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\ttrue,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t\tif (spawns.length > 0) {\r\n\t\t\tconst sourceIndex = attackingBoard.indexOf(attackingEntity);\r\n\t\t\tconst actualSpawns = performEntitySpawns(\r\n\t\t\t\tspawns,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tsourceIndex,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\tfor (const actualSpawn of actualSpawns) {\r\n\t\t\t\tif (defendingEntity.health > 0 && !defendingEntity.definitelyDead) {\r\n\t\t\t\t\tperformAttack(\r\n\t\t\t\t\t\tactualSpawn,\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// For Prestor\r\n\tconst defenderAliveBeforeAttack = defendingEntity.health > 0 && !defendingEntity.definitelyDead;\r\n\tif (defenderAliveBeforeAttack) {\r\n\t\tif (!attackingEntity.immuneWhenAttackCharges || attackingEntity.immuneWhenAttackCharges <= 0) {\r\n\t\t\tbumpEntities(\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t} else {\r\n\t\t\t// console.log('immune when attack', attackingEntity);\r\n\t\t}\r\n\t\tbumpEntities(\r\n\t\t\tdefendingEntity,\r\n\t\t\tattackingEntity,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\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}\r\n\t// Cleave\r\n\tif (attackingEntity.cleave) {\r\n\t\tconst defenderNeighbours: readonly BoardEntity[] = getNeighbours(defendingBoard, defendingEntity);\r\n\t\tfor (const neighbour of defenderNeighbours) {\r\n\t\t\tbumpEntities(\r\n\t\t\t\tneighbour,\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\t// After attack hooks\r\n\t// Arcane Cannon\r\n\t// Monstrous Macaw\r\n\tif (attackingEntity.cardId === CardIds.MonstrousMacaw) {\r\n\t\ttriggerRandomDeathrattle(\r\n\t\t\tattackingEntity,\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\ttrue,\r\n\t\t);\r\n\t} else if (attackingEntity.cardId === CardIds.MonstrousMacawBattlegrounds) {\r\n\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\ttriggerRandomDeathrattle(\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\tattackingEntity.attackImmediately = false;\r\n\tprocessMinionDeath(attackingBoard, attackingBoardHero, defendingBoard, defendingBoardHero, allCards, cardsData, sharedState, spectator);\r\n\tattackingEntity.immuneWhenAttackCharges = Math.max(0, attackingEntity.immuneWhenAttackCharges - 1);\r\n};\r\n\r\nconst triggerRandomDeathrattle = (\r\n\tsourceEntity: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n\texcludeSource = false,\r\n): void => {\r\n\tconst validDeathrattles = attackingBoard\r\n\t\t.filter((entity) => !excludeSource || entity.entityId !== sourceEntity.entityId)\r\n\t\t.filter((entity) => {\r\n\t\t\tif (hasMechanic(allCards.getCard(entity.cardId), 'DEATHRATTLE')) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\tif (entity.rememberedDeathrattles?.length) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\tif (\r\n\t\t\t\tentity.enchantments &&\r\n\t\t\t\tentity.enchantments\r\n\t\t\t\t\t.map((enchantment) => enchantment.cardId)\r\n\t\t\t\t\t.some((enchantmentId) => validEnchantments.includes(enchantmentId as CardIds))\r\n\t\t\t) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\treturn false;\r\n\t\t});\r\n\tif (validDeathrattles.length === 0) {\r\n\t\treturn;\r\n\t}\r\n\tconst targetEntity = validDeathrattles[Math.floor(Math.random() * validDeathrattles.length)];\r\n\tspectator.registerPowerTarget(sourceEntity, targetEntity, attackingBoard);\r\n\tbuildBoardAfterDeathrattleSpawns(\r\n\t\tattackingBoard,\r\n\t\tattackingBoardHero,\r\n\t\ttargetEntity,\r\n\t\t-1,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\tbuildBoardAfterRebornSpawns(\r\n\t\tattackingBoard,\r\n\t\tattackingBoardHero,\r\n\t\ttargetEntity,\r\n\t\t-1,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n};\r\n\r\nconst getAttackingEntity = (attackingBoard: BoardEntity[], lastAttackerIndex: number): BoardEntity => {\r\n\tlet validAttackers = attackingBoard.filter((entity) => entity.attack > 0).filter((entity) => !entity.cantAttack);\r\n\tif (validAttackers.length === 0) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tif (validAttackers.some((entity) => entity.attackImmediately)) {\r\n\t\tvalidAttackers = validAttackers.filter((entity) => entity.attackImmediately);\r\n\t}\r\n\r\n\t// Once an entity has attacked, no entity to the left of it can attack until all entities\r\n\t// on the board have attacked\r\n\t// Once the last attacker index is the last entity on the board, we cycle back to the start\r\n\tif (lastAttackerIndex != null && lastAttackerIndex < validAttackers.length - 1) {\r\n\t\t// This doesn't work if any entity that appears before the attacked index died in-between\r\n\t\tconst candidates = validAttackers.slice(lastAttackerIndex);\r\n\t\tif (candidates.length > 0) {\r\n\t\t\tvalidAttackers = candidates;\r\n\t\t}\r\n\t}\r\n\r\n\tlet attackingEntity = validAttackers[0];\r\n\tlet minNumberOfAttacks: number = attackingEntity.attacksPerformed || 0;\r\n\tfor (const entity of validAttackers) {\r\n\t\tif ((entity.attacksPerformed || 0) < minNumberOfAttacks) {\r\n\t\t\tattackingEntity = entity;\r\n\t\t\tminNumberOfAttacks = entity.attacksPerformed;\r\n\t\t}\r\n\t}\r\n\r\n\tif (!attackingEntity.attackImmediately) {\r\n\t\tattackingEntity.attacksPerformed = (attackingEntity.attacksPerformed || 0) + 1;\r\n\t}\r\n\treturn attackingEntity;\r\n};\r\n\r\nexport const getNeighbours = (board: BoardEntity[], entity: BoardEntity, deadEntityIndex?: number): readonly BoardEntity[] => {\r\n\tconst neighbours = [];\r\n\tif (deadEntityIndex != null) {\r\n\t\tif (deadEntityIndex < board.length - 1) {\r\n\t\t\tneighbours.push(board[deadEntityIndex]);\r\n\t\t}\r\n\t\t// Could happen if a cleave kills several entities at the same time\r\n\t\tif (deadEntityIndex > 0 && deadEntityIndex <= board.length) {\r\n\t\t\tneighbours.push(board[deadEntityIndex - 1]);\r\n\t\t}\r\n\t} else {\r\n\t\tconst index = board.map((e) => e.entityId).indexOf(entity.entityId);\r\n\t\tif (index - 1 >= 0) {\r\n\t\t\tneighbours.push(board[index - 1]);\r\n\t\t}\r\n\t\t// neighbours.push(entity);\r\n\t\tif (index + 1 < board.length) {\r\n\t\t\tneighbours.push(board[index + 1]);\r\n\t\t}\r\n\t}\r\n\treturn neighbours;\r\n};\r\n\r\nexport const dealDamageToRandomEnemy = (\r\n\tboardToBeDamaged: BoardEntity[],\r\n\tboardToBeDamagedHero: BgsPlayerEntity,\r\n\tdamageSource: BoardEntity,\r\n\tdamage: number,\r\n\tboardWithAttackOrigin: BoardEntity[],\r\n\tboardWithAttackOriginHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (boardToBeDamaged.length === 0) {\r\n\t\treturn;\r\n\t}\r\n\tconst validTargets = boardToBeDamaged.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tconst defendingEntity: BoardEntity = pickRandom(validTargets);\r\n\tif (defendingEntity) {\r\n\t\tspectator.registerPowerTarget(damageSource, defendingEntity, boardToBeDamaged);\r\n\t\tdealDamageToEnemy(\r\n\t\t\tdefendingEntity,\r\n\t\t\tboardToBeDamaged,\r\n\t\t\tboardToBeDamagedHero,\r\n\t\t\tdamageSource,\r\n\t\t\tdamage,\r\n\t\t\tboardWithAttackOrigin,\r\n\t\t\tboardWithAttackOriginHero,\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};\r\n\r\nexport const dealDamageToEnemy = (\r\n\tdefendingEntity: BoardEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tdamageSource: BoardEntity,\r\n\tdamage: number,\r\n\tboardWithAttackOrigin: BoardEntity[],\r\n\tboardWithAttackOriginHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// console.log('dealing damage to', damage, stringifySimpleCard(defendingEntity, allCards));\r\n\tif (!defendingEntity) {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tconst fakeAttacker = {\r\n\t\t...(damageSource || {}),\r\n\t\tentityId: -1,\r\n\t\tattack: damage,\r\n\t\tattacking: true,\r\n\t} as BoardEntity;\r\n\tconst actualDamageDone = bumpEntities(\r\n\t\tdefendingEntity,\r\n\t\tfakeAttacker,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\tboardWithAttackOrigin,\r\n\t\tboardWithAttackOriginHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\tconst defendingEntityIndex = defendingBoard.map((entity) => entity.entityId).indexOf(defendingEntity.entityId);\r\n\tdefendingBoard[defendingEntityIndex] = defendingEntity;\r\n\treturn actualDamageDone;\r\n};\r\n\r\nexport const getDefendingEntity = (defendingBoard: BoardEntity[], attackingEntity: BoardEntity, ignoreTaunts = false): BoardEntity => {\r\n\tlet possibleDefenders: readonly BoardEntity[];\r\n\tif (attackingEntity.cardId === CardIds.ZappSlywick || attackingEntity.cardId === CardIds.ZappSlywickBattlegrounds) {\r\n\t\tconst minAttack = Math.min(...defendingBoard.map((entity) => entity.attack));\r\n\t\tpossibleDefenders = defendingBoard.filter((entity) => entity.attack === minAttack);\r\n\t} else if (!ignoreTaunts) {\r\n\t\tconst taunts = defendingBoard.filter((entity) => entity.taunt);\r\n\t\tpossibleDefenders = taunts.length > 0 ? taunts : defendingBoard;\r\n\t} else {\r\n\t\tpossibleDefenders = defendingBoard;\r\n\t}\r\n\tlet chosenDefender = possibleDefenders[Math.floor(Math.random() * possibleDefenders.length)];\r\n\tif (chosenDefender.taunt) {\r\n\t\tconst elistras = defendingBoard.filter(\r\n\t\t\t(entity) => entity.cardId === CardIds.ElistraTheImmortal2 || entity.cardId === CardIds.ElistraTheImmortalBattlegrounds,\r\n\t\t);\r\n\t\tif (elistras.length > 0) {\r\n\t\t\tchosenDefender = elistras[Math.floor(Math.random() * elistras.length)];\r\n\t\t}\r\n\t}\r\n\treturn chosenDefender;\r\n};\r\nexport const bumpEntities = (\r\n\tentity: BoardEntity,\r\n\tbumpInto: BoardEntity,\r\n\tentityBoard: BoardEntity[],\r\n\tentityBoardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// No attack has no impact\r\n\tif (bumpInto.attack === 0) {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tif (entity.divineShield) {\r\n\t\t// Handle all the divine shield loss effects here\r\n\t\tfor (let i = 0; i < entityBoard.length; i++) {\r\n\t\t\tif (entityBoard[i].cardId === CardIds.BolvarFireblood) {\r\n\t\t\t\tmodifyAttack(entityBoard[i], 2, entityBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(entityBoard[i], entityBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(entityBoard[i], entityBoard[i], entityBoard);\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.BolvarFirebloodBattlegrounds) {\r\n\t\t\t\tmodifyAttack(entityBoard[i], 4, entityBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(entityBoard[i], entityBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(entityBoard[i], entityBoard[i], entityBoard);\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.DrakonidEnforcer) {\r\n\t\t\t\tmodifyAttack(entityBoard[i], 2, entityBoard, allCards);\r\n\t\t\t\tmodifyHealth(entityBoard[i], 2, entityBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(entityBoard[i], entityBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(entityBoard[i], entityBoard[i], entityBoard);\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.DrakonidEnforcerBattlegrounds) {\r\n\t\t\t\tmodifyAttack(entityBoard[i], 4, entityBoard, allCards);\r\n\t\t\t\tmodifyHealth(entityBoard[i], 4, entityBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(entityBoard[i], entityBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(entityBoard[i], entityBoard[i], entityBoard);\r\n\t\t\t} else if (\r\n\t\t\t\tentityBoard[i].entityId !== entity.entityId &&\r\n\t\t\t\t(entityBoard[i].cardId === CardIds.HolyMecherel || entityBoard[i].cardId === CardIds.HolyMecherelBattlegrounds)\r\n\t\t\t) {\r\n\t\t\t\tentityBoard[i].divineShield = true;\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.Gemsplitter) {\r\n\t\t\t\taddCardsInHand(entityBoardHero, 1, entityBoard, allCards, spectator, CardIds.BloodGem);\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.GemsplitterBattlegrounds) {\r\n\t\t\t\taddCardsInHand(entityBoardHero, 2, entityBoard, allCards, spectator, CardIds.BloodGem);\r\n\t\t\t}\r\n\r\n\t\t\t// So that self-buffs from Bolvar are taken into account\r\n\t\t\tif (entityBoard[i].entityId === entity.entityId) {\r\n\t\t\t\tentity.divineShield = false;\r\n\t\t\t}\r\n\t\t}\r\n\t\tconst greaseBots = entityBoard.filter((entity) => entity.cardId === CardIds.GreaseBot);\r\n\t\tconst greaseBotBattlegrounds = entityBoard.filter((entity) => entity.cardId === CardIds.GreaseBotBattlegrounds);\r\n\t\tgreaseBots.forEach((bot) => {\r\n\t\t\tmodifyAttack(entity, 1, entityBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 1, entityBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(bot, entity, entityBoard);\r\n\t\t});\r\n\t\tgreaseBotBattlegrounds.forEach((bot) => {\r\n\t\t\tmodifyAttack(entity, 2, entityBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 2, entityBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(bot, entity, entityBoard);\r\n\t\t});\r\n\t\tspectator.registerDamageDealt(bumpInto, entity, 0, entityBoard);\r\n\t\treturn 0;\r\n\t\t// return entity;\r\n\t}\r\n\tentity.health = entity.health - bumpInto.attack;\r\n\t// Do it last, so that other effects are still processed\r\n\tif (bumpInto.poisonous) {\r\n\t\t// So that further buffs don't revive it\r\n\t\t// And we don't just set the health to avoid applying overkill effects\r\n\t\tentity.definitelyDead = true;\r\n\t\t// return entity;\r\n\t}\r\n\t// FIXME: This will likely be incorrect in terms of timings, e.g. if the entity ends up\r\n\t// surviving following a buff like Spawn.\r\n\tspectator.registerDamageDealt(bumpInto, entity, bumpInto.attack, entityBoard);\r\n\tentity.lastAffectedByEntity = bumpInto;\r\n\tif (!entity.frenzyApplied && entity.health > 0 && !entity.definitelyDead) {\r\n\t\tapplyFrenzy(entity, entityBoard, entityBoardHero, allCards, cardsData, sharedState, spectator);\r\n\t\tentity.frenzyApplied = true;\r\n\t}\r\n\r\n\t// We spawn them here, because it says \"whenever\", and so happens right away\r\n\t// FIXME: there could be a bug here, if a Cleave attacks several IGB at the same time. The current\r\n\t// implementation could spawn minions above the max board size. Fringe case though, so leaving it\r\n\t// like this for now\r\n\tconst entitySpawns = getWheneverEntitySpawns(\r\n\t\tentity,\r\n\t\tentityBoard,\r\n\t\tentityBoardHero,\r\n\t\totherBoard,\r\n\t\totherHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\tif (!!entitySpawns?.length) {\r\n\t\tconst index = entityBoard.map((e) => e.entityId).indexOf(entity.entityId);\r\n\t\tentityBoard.splice(index + 1, 0, ...entitySpawns);\r\n\t\tspectator.registerMinionsSpawn(entity, entityBoard, entitySpawns);\r\n\t\thandleSpawnEffects(entityBoard, entitySpawns, allCards, spectator);\r\n\t}\r\n\treturn bumpInto.attack;\r\n};\r\n\r\nconst getWheneverEntitySpawns = (\r\n\tentity: BoardEntity,\r\n\tentityBoard: BoardEntity[],\r\n\tentityBoardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): readonly BoardEntity[] => {\r\n\tif (entityBoard.length === 7) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tif (entity.cardId === CardIds.ImpGangBoss) {\r\n\t\treturn spawnEntities(\r\n\t\t\tCardIds.ImpGangBoss_ImpToken,\r\n\t\t\t1,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t} else if (entity.cardId === CardIds.ImpGangBossBattlegrounds) {\r\n\t\treturn spawnEntities(\r\n\t\t\tCardIds.ImpGangBoss_ImpTokenBattlegrounds,\r\n\t\t\t1,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t} else if (entity.cardId === CardIds.ImpMama) {\r\n\t\treturn spawnEntities(\r\n\t\t\tcardsData.impMamaSpawns[Math.floor(Math.random() * cardsData.impMamaSpawns.length)],\r\n\t\t\t1,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t).map((entity) => ({ ...entity, taunt: true }));\r\n\t} else if (entity.cardId === CardIds.ImpMamaBattlegrounds) {\r\n\t\treturn spawnEntities(\r\n\t\t\tcardsData.impMamaSpawns[Math.floor(Math.random() * cardsData.impMamaSpawns.length)],\r\n\t\t\t2,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t).map((entity) => ({ ...entity, taunt: true }));\r\n\t} else if (entity.cardId === CardIds.SecurityRover) {\r\n\t\treturn spawnEntities(\r\n\t\t\tCardIds.SecurityRover_GuardBotToken,\r\n\t\t\t1,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t} else if (entity.cardId === CardIds.SecurityRoverBattlegrounds) {\r\n\t\treturn spawnEntities(\r\n\t\t\tCardIds.SecurityRover_GuardBotTokenBattlegrounds,\r\n\t\t\t1,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t}\r\n\treturn null;\r\n};\r\n\r\nexport const processMinionDeath = (\r\n\tboard1: BoardEntity[],\r\n\tboard1Hero: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tboard2Hero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst [deadMinionIndexes1, deadEntities1] = makeMinionsDie(board1, allCards);\r\n\tconst [deadMinionIndexes2, deadEntities2] = makeMinionsDie(board2, allCards);\r\n\tspectator.registerDeadEntities(deadMinionIndexes1, deadEntities1, deadMinionIndexes2, deadEntities2);\r\n\t// No death to process, we can return\r\n\tif (deadEntities1.length === 0 && deadEntities2.length === 0) {\r\n\t\treturn;\r\n\t\t// return [board1, board2];\r\n\t}\r\n\r\n\tsharedState.deaths.push(...deadEntities1);\r\n\tsharedState.deaths.push(...deadEntities2);\r\n\r\n\t// First process all DRs, then process the reborn\r\n\tif (Math.random() > 0.5) {\r\n\t\t// Now proceed to trigger all deathrattle effects on baord1\r\n\t\thandleDeathrattlesForFirstBoard(\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdeadMinionIndexes1,\r\n\t\t\tdeadEntities1,\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// Now handle the other board's deathrattles\r\n\t\thandleDeathrattlesForFirstBoard(\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdeadMinionIndexes2,\r\n\t\t\tdeadEntities2,\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\thandleDeathrattlesForFirstBoard(\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdeadMinionIndexes2,\r\n\t\t\tdeadEntities2,\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\thandleDeathrattlesForFirstBoard(\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdeadMinionIndexes1,\r\n\t\t\tdeadEntities1,\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\r\n\t// Now the reborn\r\n\tif (Math.random() > 0.5) {\r\n\t\t// Now proceed to trigger all deathrattle effects on baord1\r\n\t\thandleRebornForFirstBoard(\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdeadMinionIndexes1,\r\n\t\t\tdeadEntities1,\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// Now handle the other board's deathrattles\r\n\t\thandleRebornForFirstBoard(\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdeadMinionIndexes2,\r\n\t\t\tdeadEntities2,\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\thandleRebornForFirstBoard(\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdeadMinionIndexes2,\r\n\t\t\tdeadEntities2,\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\thandleRebornForFirstBoard(\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdeadMinionIndexes1,\r\n\t\t\tdeadEntities1,\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\t// Make sure we only return when there are no more deaths to process\r\n\t// FIXME: this will propagate the killer between rounds, which is incorrect. For instance,\r\n\t// if a dragon kills a Ghoul, then the Ghoul's deathrattle kills a Kaboom, the killer should\r\n\t// now be the ghoul. Then if the Kaboom kills someone, the killer should again change. You could\r\n\t// also have multiple killers, which is not taken into account here.\r\n\t// The current assumption is that it's a suffienctly fringe case to not matter too much\r\n\tprocessMinionDeath(board1, board1Hero, board2, board2Hero, allCards, cardsData, sharedState, spectator);\r\n\r\n\t// If the fish dies (from Scallywag for instance), it doesn't remember the deathrattle\r\n\tboard1\r\n\t\t.filter(\r\n\t\t\t(entity) =>\r\n\t\t\t\tentity.cardId === CardIds.AvatarOfNzoth_FishOfNzothTokenBattlegrounds || entity.cardId === CardIds.FishOfNzothBattlegrounds,\r\n\t\t)\r\n\t\t.forEach((entity) => rememberDeathrattles(entity, deadEntities1, cardsData));\r\n\tboard2\r\n\t\t.filter(\r\n\t\t\t(entity) =>\r\n\t\t\t\tentity.cardId === CardIds.AvatarOfNzoth_FishOfNzothTokenBattlegrounds || entity.cardId === CardIds.FishOfNzothBattlegrounds,\r\n\t\t)\r\n\t\t.forEach((entity) => rememberDeathrattles(entity, deadEntities2, cardsData));\r\n\r\n\tboard1\r\n\t\t.filter((entity) => entity.cardId === CardIds.Monstrosity || entity.cardId === CardIds.MonstrosityBattlegrounds)\r\n\t\t.forEach((entity) => applyMonstrosity(entity, deadEntities1, board1, allCards));\r\n\tboard2\r\n\t\t.filter((entity) => entity.cardId === CardIds.Monstrosity || entity.cardId === CardIds.MonstrosityBattlegrounds)\r\n\t\t.forEach((entity) => applyMonstrosity(entity, deadEntities2, board2, allCards));\r\n\r\n\t// Apply \"after minion death\" effects\r\n\thandleAfterMinionsDeaths(\r\n\t\tboard1,\r\n\t\tdeadEntities1,\r\n\t\tboard1Hero,\r\n\t\tboard2,\r\n\t\tdeadEntities2,\r\n\t\tboard2Hero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n};\r\n\r\nconst handleAfterMinionsDeaths = (\r\n\tboard1: BoardEntity[],\r\n\tdeadEntities1: BoardEntity[],\r\n\theroEntity1: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tdeadEntities2: BoardEntity[],\r\n\theroEntity2: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n) => {\r\n\tconst random = Math.random() > 0.5;\r\n\thandleAfterMinionsDeathsForBoard(\r\n\t\trandom ? board1 : board2,\r\n\t\trandom ? deadEntities1 : deadEntities2,\r\n\t\trandom ? heroEntity1 : heroEntity2,\r\n\t\trandom ? board2 : board1,\r\n\t\trandom ? deadEntities2 : deadEntities1,\r\n\t\trandom ? heroEntity2 : heroEntity1,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\thandleAfterMinionsDeathsForBoard(\r\n\t\t!random ? board1 : board2,\r\n\t\t!random ? deadEntities1 : deadEntities2,\r\n\t\t!random ? heroEntity1 : heroEntity2,\r\n\t\t!random ? board2 : board1,\r\n\t\t!random ? deadEntities2 : deadEntities1,\r\n\t\t!random ? heroEntity2 : heroEntity1,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n};\r\n\r\nconst handleAfterMinionsDeathsForBoard = (\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyDeadEntities: BoardEntity[],\r\n\tfriendlyHeroEntity: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherDeadEntities: BoardEntity[],\r\n\totherHeroEntity: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n) => {\r\n\tfor (const deadEntity of friendlyDeadEntities) {\r\n\t\tconst killer = deadEntity.lastAffectedByEntity;\r\n\t\tif (!killer) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\t\t// Killed an enemy minion\r\n\t\tif (killer.friendly !== deadEntity.friendly) {\r\n\t\t\tif (otherHeroEntity.heroPowerId === CardIds.Rokara_GloryOfCombat) {\r\n\t\t\t\tmodifyAttack(killer, 1, otherBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(killer, otherBoard, allCards);\r\n\t\t\t\t// Icesnarl the Mighty\r\n\t\t\t\totherBoard\r\n\t\t\t\t\t.filter((e) => e.cardId === CardIds.IcesnarlTheMighty || e.cardId === CardIds.IcesnarlTheMightyBattlegrounds)\r\n\t\t\t\t\t.forEach((icesnarl) => {\r\n\t\t\t\t\t\tmodifyHealth(icesnarl, icesnarl.cardId === CardIds.IcesnarlTheMightyBattlegrounds ? 2 : 1, friendlyBoard, allCards);\r\n\t\t\t\t\t\tafterStatsUpdate(icesnarl, friendlyBoard, allCards);\r\n\t\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleDeathrattlesForFirstBoard = (\r\n\tfirstBoard: BoardEntity[],\r\n\tfirstBoardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tdeadMinionIndexes: readonly number[],\r\n\tdeadEntities: readonly BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tfor (let i = 0; i < deadMinionIndexes.length; i++) {\r\n\t\tconst entity = deadEntities[i];\r\n\t\tconst index = deadMinionIndexes[i];\r\n\t\tif (entity.health <= 0 || entity.definitelyDead) {\r\n\t\t\tbuildBoardAfterDeathrattleSpawns(\r\n\t\t\t\tfirstBoard,\r\n\t\t\t\tfirstBoardHero,\r\n\t\t\t\tentity,\r\n\t\t\t\tindex,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t} else if (firstBoard.length > 0) {\r\n\t\t\t// const newBoardD = [...firstBoard];\r\n\t\t\tfirstBoard.splice(index, 1, entity);\r\n\t\t\t// firstBoard = newBoardD;\r\n\t\t}\r\n\t}\r\n\t// return [firstBoard, otherBoard];\r\n};\r\n\r\nconst handleRebornForFirstBoard = (\r\n\tfirstBoard: BoardEntity[],\r\n\tfirstBoardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tdeadMinionIndexes: readonly number[],\r\n\tdeadEntities: readonly BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tfor (let i = 0; i < deadMinionIndexes.length; i++) {\r\n\t\tconst entity = deadEntities[i];\r\n\t\tconst index = deadMinionIndexes[i];\r\n\t\tif (entity.health <= 0 || entity.definitelyDead) {\r\n\t\t\tbuildBoardAfterRebornSpawns(\r\n\t\t\t\tfirstBoard,\r\n\t\t\t\tfirstBoardHero,\r\n\t\t\t\tentity,\r\n\t\t\t\tindex,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t} else if (firstBoard.length > 0) {\r\n\t\t\t// const newBoardD = [...firstBoard];\r\n\t\t\tfirstBoard.splice(index, 1, entity);\r\n\t\t\t// firstBoard = newBoardD;\r\n\t\t}\r\n\t}\r\n\t// return [firstBoard, otherBoard];\r\n};\r\n\r\nexport const applyOnAttackBuffs = (\r\n\tattacker: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (attacker.cardId === CardIds.GlyphGuardian2) {\r\n\t\t// For now the utility method only works additively, so we hack around it\r\n\t\tmodifyAttack(attacker, 2 * attacker.attack - attacker.attack, attackingBoard, allCards);\r\n\t}\r\n\tif (attacker.cardId === CardIds.GlyphGuardianBattlegrounds) {\r\n\t\tmodifyAttack(attacker, 3 * attacker.attack - attacker.attack, attackingBoard, allCards);\r\n\t}\r\n\r\n\t// Ripsnarl Captain\r\n\tif (isCorrectTribe(allCards.getCard(attacker.cardId).race, Race.PIRATE)) {\r\n\t\tconst ripsnarls = attackingBoard\r\n\t\t\t.filter((e) => e.cardId === CardIds.RipsnarlCaptain)\r\n\t\t\t.filter((e) => e.entityId !== attacker.entityId);\r\n\t\tconst ripsnarlsTB = attackingBoard\r\n\t\t\t.filter((entity) => entity.cardId === CardIds.RipsnarlCaptainBattlegrounds)\r\n\t\t\t.filter((e) => e.entityId !== attacker.entityId);\r\n\t\tripsnarls.forEach((captain) => {\r\n\t\t\tmodifyAttack(attacker, 2, attackingBoard, allCards);\r\n\t\t\tmodifyHealth(attacker, 2, attackingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(captain, attacker, attackingBoard);\r\n\t\t});\r\n\t\tripsnarlsTB.forEach((captain) => {\r\n\t\t\tmodifyAttack(attacker, 4, attackingBoard, allCards);\r\n\t\t\tmodifyHealth(attacker, 4, attackingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(captain, attacker, attackingBoard);\r\n\t\t});\r\n\t}\r\n\r\n\t// Dread Admiral Eliza\r\n\tif (isCorrectTribe(allCards.getCard(attacker.cardId).race, Race.PIRATE)) {\r\n\t\tconst elizas = attackingBoard.filter((e) => e.cardId === CardIds.DreadAdmiralEliza);\r\n\t\tconst elizasTB = attackingBoard.filter((e) => e.cardId === CardIds.DreadAdmiralElizaBattlegrounds);\r\n\r\n\t\telizas.forEach((eliza) => {\r\n\t\t\tattackingBoard.forEach((entity) => {\r\n\t\t\t\tmodifyAttack(entity, 2, attackingBoard, allCards);\r\n\t\t\t\tmodifyHealth(entity, 1, attackingBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(eliza, entity, attackingBoard);\r\n\t\t\t});\r\n\t\t});\r\n\t\telizasTB.forEach((eliza) => {\r\n\t\t\tattackingBoard.forEach((entity) => {\r\n\t\t\t\tmodifyAttack(entity, 4, attackingBoard, allCards);\r\n\t\t\t\tmodifyHealth(entity, 2, attackingBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(eliza, entity, attackingBoard);\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const applyOnBeingAttackedBuffs = (\r\n\tattackedEntity: BoardEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (attackedEntity.taunt) {\r\n\t\tconst champions = defendingBoard.filter((entity) => entity.cardId === CardIds.ChampionOfYshaarj);\r\n\t\tconst goldenChampions = defendingBoard.filter((entity) => entity.cardId === CardIds.ChampionOfYshaarjBattlegrounds);\r\n\t\tchampions.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 1, defendingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 1, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(entity, entity, defendingBoard);\r\n\t\t});\r\n\t\tgoldenChampions.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 2, defendingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 2, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(entity, entity, defendingBoard);\r\n\t\t});\r\n\r\n\t\tconst arms = defendingBoard.filter((entity) => entity.cardId === CardIds.ArmOfTheEmpire);\r\n\t\tconst goldenArms = defendingBoard.filter((entity) => entity.cardId === CardIds.ArmOfTheEmpireBattlegrounds);\r\n\t\tarms.forEach((arm) => {\r\n\t\t\tmodifyAttack(attackedEntity, 2, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(arm, attackedEntity, defendingBoard);\r\n\t\t});\r\n\t\tgoldenArms.forEach((arm) => {\r\n\t\t\tmodifyAttack(attackedEntity, 4, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(arm, attackedEntity, defendingBoard);\r\n\t\t});\r\n\t}\r\n\tif (attackedEntity.cardId === CardIds.TormentedRitualist) {\r\n\t\tconst neighbours = getNeighbours(defendingBoard, attackedEntity);\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 1, defendingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 1, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(attackedEntity, entity, defendingBoard);\r\n\t\t});\r\n\t}\r\n\tif (attackedEntity.cardId === CardIds.TormentedRitualistBattlegrounds) {\r\n\t\tconst neighbours = getNeighbours(defendingBoard, attackedEntity);\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 2, defendingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 2, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(attackedEntity, entity, defendingBoard);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nconst makeMinionsDie = (board: BoardEntity[], allCards: AllCardsService): [number[], BoardEntity[]] => {\r\n\tconst deadMinionIndexes: number[] = [];\r\n\tconst deadEntities: BoardEntity[] = [];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tconst index = board.map((entity) => entity.entityId).indexOf(board[i].entityId);\r\n\t\tif (board[i].health <= 0 || board[i].definitelyDead) {\r\n\t\t\tdeadMinionIndexes.push(i);\r\n\t\t\tdeadEntities.push(board[i]);\r\n\t\t\tboard.splice(index, 1);\r\n\t\t\t// We modify the original array, so we need to update teh current index accordingly\r\n\t\t\ti--;\r\n\t\t}\r\n\t}\r\n\treturn [deadMinionIndexes, deadEntities];\r\n};\r\n\r\n// const handleKillEffects = (\r\n// \tboardWithKilledMinion: BoardEntity[],\r\n// \tkillerBoard: BoardEntity[],\r\n// \tdeadEntity: BoardEntity,\r\n// \tallCards: AllCardsService,\r\n// \tspectator: Spectator,\r\n// ): void => {\r\n// \tif (\r\n// \t\tdeadEntity.lastAffectedByEntity?.cardId &&\r\n// \t\tisCorrectTribe(allCards.getCard(deadEntity.lastAffectedByEntity.cardId).race, Race.DRAGON)\r\n// \t) {\r\n// \t\tfor (const entity of killerBoard) {\r\n// \t\t\tif (entity.cardId === CardIds.WaxriderTogwaggle2) {\r\n// \t\t\t\tmodifyAttack(entity, 2, killerBoard, allCards);\r\n// \t\t\t\tmodifyHealth(entity, 2, killerBoard, allCards);\r\n// \t\t\t\tafterStatsUpdate(entity, killerBoard, allCards);\r\n// \t\t\t\tspectator.registerPowerTarget(entity, entity, killerBoard);\r\n// \t\t\t} else if (entity.cardId === CardIds.WaxriderTogwaggleBattlegrounds) {\r\n// \t\t\t\tmodifyAttack(entity, 4, killerBoard, allCards);\r\n// \t\t\t\tmodifyHealth(entity, 4, killerBoard, allCards);\r\n// \t\t\t\tafterStatsUpdate(entity, killerBoard, allCards);\r\n// \t\t\t\tspectator.registerPowerTarget(entity, entity, killerBoard);\r\n// \t\t\t}\r\n// \t\t}\r\n// \t}\r\n// };\r\n\r\nconst buildBoardAfterDeathrattleSpawns = (\r\n\tboardWithKilledMinion: BoardEntity[],\r\n\tboardWithKilledMinionHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tdeadMinionIndex: number,\r\n\topponentBoard: BoardEntity[],\r\n\topponentBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// TODO: don't apply this for FishOfNZoth\r\n\t// if (deadMinionIndex >= 0) {\r\n\t// \thandleKillEffects(boardWithKilledMinion, opponentBoard, deadEntity, allCards, spectator);\r\n\t// }\r\n\r\n\t// But Wildfire Element is applied first, before the DR spawns\r\n\tif (deadMinionIndex >= 0) {\r\n\t\tapplyMinionDeathEffect(\r\n\t\t\tdeadEntity,\r\n\t\t\tdeadMinionIndex,\r\n\t\t\tboardWithKilledMinion,\r\n\t\t\tboardWithKilledMinionHero,\r\n\t\t\topponentBoard,\r\n\t\t\topponentBoardHero,\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\tconst entitiesFromNativeDeathrattle: readonly BoardEntity[] = spawnEntitiesFromDeathrattle(\r\n\t\tdeadEntity,\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\r\n\tconst entitiesFromEnchantments: readonly BoardEntity[] = spawnEntitiesFromEnchantments(\r\n\t\tdeadEntity,\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\r\n\tconst candidateEntities: readonly BoardEntity[] = [...entitiesFromNativeDeathrattle, ...entitiesFromEnchantments];\r\n\tperformEntitySpawns(\r\n\t\tcandidateEntities,\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\tdeadEntity,\r\n\t\tdeadMinionIndex,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\r\n\t// In case of leapfrogger, we want to first spawn the minions, then apply the frog effect\r\n\thandleDeathrattleEffects(\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\tdeadEntity,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\r\n\t// eslint-disable-next-line prettier/prettier\r\n\tif (deadEntity.rememberedDeathrattles?.length) {\r\n\t\tfor (const deathrattle of deadEntity.rememberedDeathrattles) {\r\n\t\t\tconst entityToProcess: BoardEntity = {\r\n\t\t\t\t...deadEntity,\r\n\t\t\t\trememberedDeathrattles: undefined,\r\n\t\t\t\tcardId: deathrattle,\r\n\t\t\t\tenchantments: [\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcardId: deathrattle,\r\n\t\t\t\t\t\toriginEntityId: deadEntity.entityId,\r\n\t\t\t\t\t},\r\n\t\t\t\t],\r\n\t\t\t};\r\n\t\t\tbuildBoardAfterDeathrattleSpawns(\r\n\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\tentityToProcess,\r\n\t\t\t\tdeadMinionIndex,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\t// TODO: check if Avenge effects should proc after deathrattles instead\r\n\t// They most certainly do, since the rat pack + avenge beast buffer works\r\n\tapplyAvengeEffects(\r\n\t\tdeadEntity,\r\n\t\tdeadMinionIndex,\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n};\r\n\r\nconst buildBoardAfterRebornSpawns = (\r\n\tboardWithKilledMinion: BoardEntity[],\r\n\tboardWithKilledMinionHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tdeadMinionIndex: number,\r\n\topponentBoard: BoardEntity[],\r\n\topponentBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst otherEntityCardIds = boardWithKilledMinion.filter((e) => e.entityId !== deadEntity.entityId).map((e) => e.cardId);\r\n\tconst numberOfReborns =\r\n\t\t1 +\r\n\t\t1 * otherEntityCardIds.filter((cardId) => cardId === CardIds.ArfusBattlegrounds1).length +\r\n\t\t2 * otherEntityCardIds.filter((cardId) => cardId === CardIds.ArfusBattlegrounds2).length;\r\n\t// Reborn happens after deathrattles\r\n\tconst entitiesFromReborn: readonly BoardEntity[] =\r\n\t\tdeadEntity.reborn && deadMinionIndex >= 0\r\n\t\t\t? spawnEntities(\r\n\t\t\t\t\tdeadEntity.cardId,\r\n\t\t\t\t\tnumberOfReborns,\r\n\t\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentBoardHero,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tcardsData,\r\n\t\t\t\t\tsharedState,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\ttrue,\r\n\t\t\t )\r\n\t\t\t: [];\r\n\tperformEntitySpawns(\r\n\t\tentitiesFromReborn,\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\tdeadEntity,\r\n\t\tdeadMinionIndex,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n};\r\n\r\nexport const performEntitySpawns = (\r\n\tcandidateEntities: readonly BoardEntity[],\r\n\tboardWithKilledMinion: BoardEntity[],\r\n\tboardWithKilledMinionHero: BgsPlayerEntity,\r\n\tspawnSourceEntity: BoardEntity,\r\n\tspawnSourceEntityIndex: number,\r\n\topponentBoard: BoardEntity[],\r\n\topponentBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): readonly BoardEntity[] => {\r\n\tconst aliveEntites = candidateEntities.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\r\n\t// const roomToSpawn: number = 7 - boardWithKilledMinion.length;\r\n\t// const spawnedEntities: readonly BoardEntity[] = aliveEntites.slice(0, roomToSpawn);\r\n\r\n\tconst indexFromRight = boardWithKilledMinion.length - spawnSourceEntityIndex;\r\n\tconst spawnedEntities = [];\r\n\tfor (const newMinion of aliveEntites) {\r\n\t\t// All entities have been spawned\r\n\t\tif (boardWithKilledMinion.length >= 7) {\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t// Avoid minions spawning backwards (we don't have this issue if we add all elements at\r\n\t\t// the same time, but here we want to be able to attack after each spawn, which in turn\r\n\t\t// means that the minion can die before the other one spawns)\r\n\t\t// In boardWithKilledMinion, the dead minion has already been removed\r\n\t\tboardWithKilledMinion.splice(boardWithKilledMinion.length - indexFromRight, 0, newMinion);\r\n\t\tif (newMinion.attackImmediately) {\r\n\t\t\t// Whenever we are already in a combat phase, we need to first clean up the state\r\n\t\t\tremoveAuras(boardWithKilledMinion, cardsData, true);\r\n\t\t\tremoveAuras(opponentBoard, cardsData, true);\r\n\t\t\tsimulateAttack(\r\n\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentBoardHero,\r\n\t\t\t\tnull,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t\tif (newMinion.health > 0 && !newMinion.definitelyDead) {\r\n\t\t\tspawnedEntities.push(newMinion);\r\n\t\t}\r\n\t}\r\n\r\n\t// Minion has already been removed from the board in the previous step\r\n\thandleSpawnEffects(boardWithKilledMinion, spawnedEntities, allCards, spectator);\r\n\tspectator.registerMinionsSpawn(spawnSourceEntity, boardWithKilledMinion, spawnedEntities);\r\n\treturn spawnedEntities;\r\n};\r\n"]}
|
|
@@ -5,5 +5,5 @@ import { CardsData } from '../cards/cards-data';
|
|
|
5
5
|
export declare const applyAuras: (board: BoardEntity[], numberOfDeathwingPresents: number, data: CardsData, cards: AllCardsService) => void;
|
|
6
6
|
export declare const setImplicitData: (board: BoardEntity[], cardsData: CardsData) => void;
|
|
7
7
|
export declare const setImplicitDataHero: (hero: BgsPlayerEntity, cardsData: CardsData) => void;
|
|
8
|
-
export declare const removeAuras: (board: BoardEntity[], data: CardsData) => void;
|
|
8
|
+
export declare const removeAuras: (board: BoardEntity[], data: CardsData, allowNegativeHealth?: boolean) => void;
|
|
9
9
|
export declare const removeAurasAfterAuraSourceDeath: (board: BoardEntity[], auraSource: BoardEntity, data: CardsData) => void;
|
package/dist/simulation/auras.js
CHANGED
|
@@ -36,9 +36,9 @@ const setImplicitDataHero = (hero, cardsData) => {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
exports.setImplicitDataHero = setImplicitDataHero;
|
|
39
|
-
const removeAuras = (board, data) => {
|
|
39
|
+
const removeAuras = (board, data, allowNegativeHealth = false) => {
|
|
40
40
|
for (const entity of board) {
|
|
41
|
-
removeAurasFrom(entity, board, data);
|
|
41
|
+
removeAurasFrom(entity, board, data, allowNegativeHealth);
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
exports.removeAuras = removeAuras;
|
|
@@ -49,13 +49,13 @@ const removeAurasAfterAuraSourceDeath = (board, auraSource, data) => {
|
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
for (const entity of board) {
|
|
52
|
-
removeAura(entity, auraEnchantmentId, board, auraSource);
|
|
52
|
+
removeAura(entity, auraEnchantmentId, board, false, auraSource);
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
exports.removeAurasAfterAuraSourceDeath = removeAurasAfterAuraSourceDeath;
|
|
56
|
-
const removeAurasFrom = (entity, board, data) => {
|
|
56
|
+
const removeAurasFrom = (entity, board, data, allowNegativeHealth) => {
|
|
57
57
|
for (const enchantment of entity.enchantments) {
|
|
58
|
-
removeAura(entity, enchantment.cardId, board);
|
|
58
|
+
removeAura(entity, enchantment.cardId, board, allowNegativeHealth);
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
61
|
const applyAura = (board, i, enchantmentId, cards) => {
|
|
@@ -81,7 +81,7 @@ const applyAura = (board, i, enchantmentId, cards) => {
|
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
|
-
const removeAura = (entity, enchantmentId, board, deadAuraSource = null) => {
|
|
84
|
+
const removeAura = (entity, enchantmentId, board, allowNegativeHealth, deadAuraSource = null) => {
|
|
85
85
|
switch (enchantmentId) {
|
|
86
86
|
case "BG21_039e":
|
|
87
87
|
case "BG21_039_Ge":
|
|
@@ -95,7 +95,7 @@ const removeAura = (entity, enchantmentId, board, deadAuraSource = null) => {
|
|
|
95
95
|
case "NEW1_027e":
|
|
96
96
|
case "VAN_NEW1_027e":
|
|
97
97
|
case "TB_BaconUps_136e":
|
|
98
|
-
removeSouthseaCaptainAura(entity, enchantmentId, board, deadAuraSource);
|
|
98
|
+
removeSouthseaCaptainAura(entity, enchantmentId, board, allowNegativeHealth, deadAuraSource);
|
|
99
99
|
return;
|
|
100
100
|
case "TB_BaconShop_HERO_52_Buddy_e":
|
|
101
101
|
case "TB_BaconShop_HERO_52_Buddy_G_e":
|
|
@@ -178,12 +178,12 @@ const applyLadySinestraAura = (board, index, enchantmentId) => {
|
|
|
178
178
|
entity.enchantments.push({ cardId: enchantmentId, originEntityId: originEntity.entityId });
|
|
179
179
|
}
|
|
180
180
|
};
|
|
181
|
-
const removeSouthseaCaptainAura = (entity, enchantmentId, board, deadAuraSource = null) => {
|
|
181
|
+
const removeSouthseaCaptainAura = (entity, enchantmentId, board, allowNegativeHealth, deadAuraSource = null) => {
|
|
182
182
|
if (!deadAuraSource) {
|
|
183
183
|
const buffs = entity.enchantments.filter((e) => e.cardId === enchantmentId && e.originEntityId !== entity.entityId);
|
|
184
184
|
const numberOfBuffs = buffs.length;
|
|
185
185
|
entity.attack = Math.max(0, entity.attack - numberOfBuffs * (enchantmentId === "TB_BaconUps_136e" ? 2 : 1));
|
|
186
|
-
entity.health = Math.max(1, entity.health - numberOfBuffs * (enchantmentId === "TB_BaconUps_136e" ? 2 : 1));
|
|
186
|
+
entity.health = Math.max(allowNegativeHealth ? -999 : 1, entity.health - numberOfBuffs * (enchantmentId === "TB_BaconUps_136e" ? 2 : 1));
|
|
187
187
|
entity.enchantments = entity.enchantments.filter((aura) => aura.cardId !== enchantmentId);
|
|
188
188
|
}
|
|
189
189
|
else {
|
|
@@ -192,7 +192,7 @@ const removeSouthseaCaptainAura = (entity, enchantmentId, board, deadAuraSource
|
|
|
192
192
|
entity.attack = Math.max(0, entity.attack - numberOfBuffs * (enchantmentId === "TB_BaconUps_136e" ? 2 : 1));
|
|
193
193
|
entity.health = entity.maxHealth
|
|
194
194
|
? Math.min(entity.health, entity.maxHealth)
|
|
195
|
-
: Math.max(1, entity.health - numberOfBuffs * (enchantmentId === "TB_BaconUps_136e" ? 2 : 1));
|
|
195
|
+
: Math.max(allowNegativeHealth ? -999 : 1, entity.health - numberOfBuffs * (enchantmentId === "TB_BaconUps_136e" ? 2 : 1));
|
|
196
196
|
entity.enchantments = entity.enchantments.filter((aura) => aura.cardId !== enchantmentId);
|
|
197
197
|
}
|
|
198
198
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auras.js","sourceRoot":"","sources":["../../src/simulation/auras.ts"],"names":[],"mappings":";;;AACA,iEAA8E;AAG9E,oDAAiF;AACjF,oCAA0C;AAGnC,MAAM,UAAU,GAAG,CAAC,KAAoB,EAAE,yBAAiC,EAAE,IAAe,EAAE,KAAsB,EAAQ,EAAE;IACpI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,IAAI,yBAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE;YACjD,MAAM,aAAa,GAAG,8BAAiB,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AAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,aAAa,CAAC,CAAC;AAC3F,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from 'src/bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { AURA_ENCHANTMENTS, AURA_ORIGINS, CardsData } from '../cards/cards-data';\r\nimport { isCorrectTribe } from '../utils';\r\n\r\n// Check if aura is already applied, and if not re-apply it\r\nexport const applyAuras = (board: BoardEntity[], numberOfDeathwingPresents: number, data: CardsData, cards: AllCardsService): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (AURA_ORIGINS.indexOf(board[i].cardId) !== -1) {\r\n\t\t\tconst enchantmentId = AURA_ENCHANTMENTS.find((aura) => aura[0] === board[i].cardId)[1];\r\n\t\t\tapplyAura(board, i, enchantmentId, cards);\r\n\t\t}\r\n\t}\r\n\r\n\tfor (let i = 0; i < numberOfDeathwingPresents; i++) {\r\n\t\tapplyDeathwingAura(board, CardIds.AllWillBurn_AllWillBurnEnchantmentBattlegrounds);\r\n\t}\r\n\t// return board;\r\n};\r\n\r\nexport const setImplicitData = (board: BoardEntity[], cardsData: CardsData): void => {\r\n\tfor (const entity of board) {\r\n\t\tentity.maxHealth = entity.health;\r\n\t\tconst avengeValue = cardsData.avengeValue(entity.cardId);\r\n\t\tif (avengeValue > 0) {\r\n\t\t\tentity.avengeCurrent = avengeValue;\r\n\t\t\tentity.avengeDefault = avengeValue;\r\n\t\t}\r\n\t\tentity.immuneWhenAttackCharges = 0;\r\n\t}\r\n};\r\n\r\nexport const setImplicitDataHero = (hero: BgsPlayerEntity, cardsData: CardsData): void => {\r\n\tconst avengeValue = cardsData.avengeValue(hero.heroPowerId);\r\n\tif (avengeValue > 0) {\r\n\t\thero.avengeCurrent = avengeValue;\r\n\t\thero.avengeDefault = avengeValue;\r\n\t}\r\n};\r\n\r\nexport const removeAuras = (board: BoardEntity[], data: CardsData): void => {\r\n\tfor (const entity of board) {\r\n\t\tremoveAurasFrom(entity, board, data);\r\n\t}\r\n};\r\n\r\nexport const removeAurasAfterAuraSourceDeath = (board: BoardEntity[], auraSource: BoardEntity, data: CardsData): void => {\r\n\tconst auraPair = AURA_ENCHANTMENTS.find((pair) => pair[0] === auraSource.cardId);\r\n\tconst auraEnchantmentId = !!auraPair ? auraPair[1] : null;\r\n\tif (!auraEnchantmentId) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tfor (const entity of board) {\r\n\t\tremoveAura(entity, auraEnchantmentId, board, auraSource);\r\n\t}\r\n};\r\n\r\nconst removeAurasFrom = (entity: BoardEntity, board: BoardEntity[], data: CardsData): void => {\r\n\t// let newEntity = entity;\r\n\tfor (const enchantment of entity.enchantments) {\r\n\t\tremoveAura(entity, enchantment.cardId, board);\r\n\t}\r\n\t// return newEntity;\r\n};\r\n\r\nconst applyAura = (board: BoardEntity[], i: number, enchantmentId: string, cards: AllCardsService): void => {\r\n\tswitch (board[i].cardId) {\r\n\t\t// case CardIds.SiegebreakerLegacy:\r\n\t\t// case CardIds.SiegebreakerBattlegrounds:\r\n\t\t// \tapplySiegebreakerAura(board, i, enchantmentId, cards);\r\n\t\t// \treturn;\r\n\t\t// case CardIds.Malganis1:\r\n\t\t// case CardIds.MalganisBattlegrounds:\r\n\t\t// \tapplyMalGanisAura(board, i, enchantmentId, cards);\r\n\t\t// \treturn;\r\n\t\tcase CardIds.Kathranatir2:\r\n\t\tcase CardIds.KathranatirBattlegrounds:\r\n\t\t\tapplyKathranatirAura(board, i, enchantmentId, cards);\r\n\t\t\treturn;\r\n\t\tcase CardIds.MurlocWarleaderLegacy:\r\n\t\tcase CardIds.MurlocWarleaderVanilla:\r\n\t\tcase CardIds.MurlocWarleaderBattlegrounds:\r\n\t\t\tapplyMurlocWarleaderAura(board, i, enchantmentId, cards);\r\n\t\t\treturn;\r\n\t\tcase CardIds.SouthseaCaptainLegacy:\r\n\t\tcase CardIds.SouthseaCaptainCore:\r\n\t\tcase CardIds.SouthseaCaptainVanilla:\r\n\t\tcase CardIds.SouthseaCaptainBattlegrounds:\r\n\t\t\tapplySouthseaCaptainAura(board, i, enchantmentId, cards);\r\n\t\t\treturn;\r\n\t\tcase CardIds.LadySinestraBattlegrounds1:\r\n\t\tcase CardIds.LadySinestraBattlegrounds2:\r\n\t\t\tapplyLadySinestraAura(board, i, enchantmentId);\r\n\t\t\treturn;\r\n\t}\r\n};\r\n\r\nconst removeAura = (entity: BoardEntity, enchantmentId: string, board: BoardEntity[], deadAuraSource: BoardEntity = null): void => {\r\n\tswitch (enchantmentId) {\r\n\t\t// case CardIds.Siegebreaker_SiegebreakingLegacyEnchantment:\r\n\t\t// case CardIds.Siegebreaker_SiegebreakingEnchantmentBattlegrounds:\r\n\t\t// \tremoveSiegebreakerAura(entity, enchantmentId);\r\n\t\t// \treturn;\r\n\t\t// case CardIds.Malganis_GraspOfMalganisEnchantment:\r\n\t\t// case CardIds.Malganis_GraspOfMalganisEnchantmentBattlegrounds:\r\n\t\t// \tremoveMalGanisAura(entity, enchantmentId);\r\n\t\t// \treturn;\r\n\t\tcase CardIds.Kathranatir_GraspOfKathranatirEnchantment1:\r\n\t\tcase CardIds.Kathranatir_GraspOfKathranatirEnchantment2:\r\n\t\t\tremoveKathranatirAura(entity, enchantmentId);\r\n\t\t\treturn;\r\n\t\tcase CardIds.MurlocWarleader_MrgglaarglLegacyEnchantment:\r\n\t\tcase CardIds.MurlocWarleader_MrgglaarglVanillaEnchantment:\r\n\t\tcase CardIds.MurlocWarleader_MrgglaarglEnchantmentBattlegrounds:\r\n\t\t\tremoveMurlocWarleaderAura(entity, enchantmentId);\r\n\t\t\treturn;\r\n\t\tcase CardIds.SouthseaCaptain_YarrrLegacyEnchantment:\r\n\t\tcase CardIds.SouthseaCaptain_YarrrVanillaEnchantment:\r\n\t\tcase CardIds.SouthseaCaptain_YarrrEnchantmentBattlegrounds:\r\n\t\t\tremoveSouthseaCaptainAura(entity, enchantmentId, board, deadAuraSource);\r\n\t\t\treturn;\r\n\t\t// TODO find proper enchantment\r\n\t\tcase CardIds.DraconicBlessingEnchantmentBattlegrounds1:\r\n\t\tcase CardIds.DraconicBlessingEnchantmentBattlegrounds2:\r\n\t\t\tremoveLadySinestraAura(entity, enchantmentId);\r\n\t\t\treturn;\r\n\t\tcase CardIds.AllWillBurn_AllWillBurnEnchantmentBattlegrounds:\r\n\t\t\tremoveDeathwingAura(entity, enchantmentId);\r\n\t\t\treturn;\r\n\t\t// case CardIds.WhirlwindTempest_WhirlingEnchantment:\r\n\t\t// \tremoveWhirlwindTempestAura(entity, enchantmentId);\r\n\t\t// \treturn;\r\n\t}\r\n};\r\n\r\nconst applyDeathwingAura = (board: BoardEntity[], enchantmentId: string): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tconst entity = board[i];\r\n\t\tif (!entity.enchantments.some((aura) => aura.cardId === enchantmentId)) {\r\n\t\t\tentity.attack += 2;\r\n\t\t\tentity.enchantments.push({ cardId: enchantmentId, originEntityId: undefined });\r\n\t\t}\r\n\t}\r\n};\r\n\r\n// const applySiegebreakerAura = (board: BoardEntity[], index: number, enchantmentId: string, cards: AllCardsService): void => {\r\n// \tconst originEntity = board[index];\r\n// \t// const newBoard = [];\r\n// \tfor (let i = 0; i < board.length; i++) {\r\n// \t\tconst entity = board[i];\r\n// \t\tif (i === index || !isCorrectTribe(cards.getCard(entity.cardId).race, Race.DEMON)) {\r\n// \t\t\t// newBoard.push(entity);\r\n// \t\t\tcontinue;\r\n// \t\t}\r\n\r\n// \t\tif (!entity.enchantments.some((aura) => aura.cardId === enchantmentId && aura.originEntityId === originEntity.entityId)) {\r\n// \t\t\tentity.attack += enchantmentId === CardIds.Siegebreaker_SiegebreakingEnchantmentBattlegrounds ? 2 : 1;\r\n// \t\t\tentity.enchantments.push({ cardId: enchantmentId, originEntityId: originEntity.entityId });\r\n// \t\t}\r\n// \t}\r\n// };\r\n\r\n// const applyMalGanisAura = (board: BoardEntity[], index: number, enchantmentId: string, cards: AllCardsService): void => {\r\n// \tconst originEntity = board[index];\r\n// \t// const newBoard = [];\r\n// \tfor (let i = 0; i < board.length; i++) {\r\n// \t\tconst entity = board[i];\r\n// \t\tif (i === index || !isCorrectTribe(cards.getCard(entity.cardId).race, Race.DEMON)) {\r\n// \t\t\t// newBoard.push(entity);\r\n// \t\t\tcontinue;\r\n// \t\t}\r\n\r\n// \t\tif (!entity.enchantments.some((aura) => aura.cardId === enchantmentId && aura.originEntityId === originEntity.entityId)) {\r\n// \t\t\tentity.attack += enchantmentId === CardIds.Malganis_GraspOfMalganisEnchantmentBattlegrounds ? 4 : 2;\r\n// \t\t\tentity.health += enchantmentId === CardIds.Malganis_GraspOfMalganisEnchantmentBattlegrounds ? 4 : 2;\r\n// \t\t\tentity.enchantments.push({ cardId: enchantmentId, originEntityId: originEntity.entityId });\r\n// \t\t}\r\n// \t}\r\n// \t// return newBoard;\r\n// };\r\n\r\nconst applyKathranatirAura = (board: BoardEntity[], index: number, enchantmentId: string, cards: AllCardsService): void => {\r\n\tconst originEntity = board[index];\r\n\t// const newBoard = [];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tconst entity = board[i];\r\n\t\tif (i === index || !isCorrectTribe(cards.getCard(entity.cardId).race, Race.DEMON)) {\r\n\t\t\t// newBoard.push(entity);\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tif (!entity.enchantments.some((aura) => aura.cardId === enchantmentId && aura.originEntityId === originEntity.entityId)) {\r\n\t\t\tentity.attack += enchantmentId === CardIds.Kathranatir_GraspOfKathranatirEnchantment2 ? 4 : 2;\r\n\t\t\tentity.enchantments.push({ cardId: enchantmentId, originEntityId: originEntity.entityId });\r\n\t\t}\r\n\t}\r\n\t// return newBoard;\r\n};\r\n\r\nconst removeDeathwingAura = (entity: BoardEntity, enchantmentId: string): void => {\r\n\tconst numberOfBuffs = entity.enchantments.filter((e) => e.cardId === enchantmentId).length;\r\n\tentity.attack = Math.max(0, entity.attack - numberOfBuffs * 2);\r\n\tentity.enchantments = entity.enchantments.filter((aura) => aura.cardId !== enchantmentId);\r\n};\r\n\r\n// const removeSiegebreakerAura = (entity: BoardEntity, enchantmentId: string): void => {\r\n// \tconst numberOfBuffs = entity.enchantments.filter((e) => e.cardId === enchantmentId).length;\r\n// \tentity.attack = Math.max(\r\n// \t\t0,\r\n// \t\tentity.attack - numberOfBuffs * (enchantmentId === CardIds.Siegebreaker_SiegebreakingEnchantmentBattlegrounds ? 2 : 1),\r\n// \t);\r\n// \tentity.enchantments = entity.enchantments.filter((aura) => aura.cardId !== enchantmentId);\r\n// };\r\n\r\n// const removeMalGanisAura = (entity: BoardEntity, enchantmentId: string): void => {\r\n// \tconst numberOfBuffs = entity.enchantments.filter((e) => e.cardId === enchantmentId).length;\r\n// \tentity.attack = Math.max(\r\n// \t\t0,\r\n// \t\tentity.attack - numberOfBuffs * (enchantmentId === CardIds.Malganis_GraspOfMalganisEnchantmentBattlegrounds ? 4 : 2),\r\n// \t);\r\n// \tentity.health = Math.max(\r\n// \t\t1,\r\n// \t\tentity.health - numberOfBuffs * (enchantmentId === CardIds.Malganis_GraspOfMalganisEnchantmentBattlegrounds ? 4 : 2),\r\n// \t);\r\n// \tentity.enchantments = entity.enchantments.filter((aura) => aura.cardId !== enchantmentId);\r\n// };\r\n\r\nconst removeKathranatirAura = (entity: BoardEntity, enchantmentId: string): void => {\r\n\tconst numberOfBuffs = entity.enchantments.filter((e) => e.cardId === enchantmentId).length;\r\n\tentity.attack = Math.max(\r\n\t\t0,\r\n\t\tentity.attack - numberOfBuffs * (enchantmentId === CardIds.Kathranatir_GraspOfKathranatirEnchantment2 ? 4 : 2),\r\n\t);\r\n\tentity.enchantments = entity.enchantments.filter((aura) => aura.cardId !== enchantmentId);\r\n};\r\n\r\nconst applyMurlocWarleaderAura = (board: BoardEntity[], index: number, enchantmentId: string, cards: AllCardsService): void => {\r\n\tconst originEntity = board[index];\r\n\t// const newBoard = [];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tconst entity = board[i];\r\n\t\tif (i === index || !isCorrectTribe(cards.getCard(entity.cardId).race, Race.MURLOC)) {\r\n\t\t\t// newBoard.push(entity);\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tif (!entity.enchantments.some((aura) => aura.cardId === enchantmentId && aura.originEntityId === originEntity.entityId)) {\r\n\t\t\tentity.attack += enchantmentId === CardIds.MurlocWarleader_MrgglaarglEnchantmentBattlegrounds ? 4 : 2;\r\n\t\t\tentity.enchantments.push({ cardId: enchantmentId, originEntityId: originEntity.entityId });\r\n\t\t}\r\n\t}\r\n\t// return newBoard;\r\n};\r\n\r\nconst removeMurlocWarleaderAura = (entity: BoardEntity, enchantmentId: string): void => {\r\n\tconst numberOfBuffs = entity.enchantments.filter((e) => e.cardId === enchantmentId && e.originEntityId !== entity.entityId).length;\r\n\tentity.attack = Math.max(\r\n\t\t0,\r\n\t\tentity.attack - numberOfBuffs * (enchantmentId === CardIds.MurlocWarleader_MrgglaarglEnchantmentBattlegrounds ? 4 : 2),\r\n\t);\r\n\tentity.enchantments = entity.enchantments.filter((aura) => aura.cardId !== enchantmentId);\r\n};\r\n\r\nconst applySouthseaCaptainAura = (board: BoardEntity[], index: number, enchantmentId: string, cards: AllCardsService): void => {\r\n\tconst originEntity = board[index];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tconst entity = board[i];\r\n\t\tif (i === index || !isCorrectTribe(cards.getCard(entity.cardId).race, Race.PIRATE)) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tif (!entity.enchantments.some((aura) => aura.cardId === enchantmentId && aura.originEntityId === originEntity.entityId)) {\r\n\t\t\tentity.attack += enchantmentId === CardIds.SouthseaCaptain_YarrrEnchantmentBattlegrounds ? 2 : 1;\r\n\t\t\tentity.health += enchantmentId === CardIds.SouthseaCaptain_YarrrEnchantmentBattlegrounds ? 2 : 1;\r\n\t\t\t// entity.maxHealth += enchantmentId === CardIds.SouthseaCaptain_YarrrEnchantmentBattlegrounds ? 2 : 1;\r\n\t\t\tentity.enchantments.push({ cardId: enchantmentId, originEntityId: originEntity.entityId });\r\n\t\t}\r\n\t}\r\n\t// return newBoard;\r\n};\r\n\r\nconst applyLadySinestraAura = (board: BoardEntity[], index: number, enchantmentId: string): void => {\r\n\tconst originEntity = board[index];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tconst entity = board[i];\r\n\t\t// TODO find proper enchantment\r\n\t\tentity.attack += enchantmentId === CardIds.DraconicBlessingEnchantmentBattlegrounds2 ? 6 : 3;\r\n\t\tentity.enchantments.push({ cardId: enchantmentId, originEntityId: originEntity.entityId });\r\n\t}\r\n};\r\n\r\nconst removeSouthseaCaptainAura = (\r\n\tentity: BoardEntity,\r\n\tenchantmentId: string,\r\n\tboard: BoardEntity[],\r\n\tdeadAuraSource: BoardEntity = null,\r\n): void => {\r\n\tif (!deadAuraSource) {\r\n\t\t// console.log('removing aura', stringifySimpleCard(entity), entity.maxHealth);\r\n\t\tconst buffs = entity.enchantments.filter((e) => e.cardId === enchantmentId && e.originEntityId !== entity.entityId);\r\n\t\tconst numberOfBuffs = buffs.length;\r\n\r\n\t\tentity.attack = Math.max(\r\n\t\t\t0,\r\n\t\t\tentity.attack - numberOfBuffs * (enchantmentId === CardIds.SouthseaCaptain_YarrrEnchantmentBattlegrounds ? 2 : 1),\r\n\t\t);\r\n\r\n\t\t// entity.health = entity.maxHealth\r\n\t\t// \t? Math.min(entity.health, entity.maxHealth)\r\n\t\t// \t: Math.max(1, entity.health - numberOfBuffs * (enchantmentId === CardIds.SouthseaCaptain_YarrrEnchantmentBattlegrounds ? 2 : 1));\r\n\t\tentity.health = Math.max(\r\n\t\t\t1,\r\n\t\t\tentity.health - numberOfBuffs * (enchantmentId === CardIds.SouthseaCaptain_YarrrEnchantmentBattlegrounds ? 2 : 1),\r\n\t\t);\r\n\t\tentity.enchantments = entity.enchantments.filter((aura) => aura.cardId !== enchantmentId);\r\n\t\t// console.log('removed aura', stringifySimpleCard(entity), entity.maxHealth);\r\n\t}\r\n\t// Special case where the source dies, health is treated differently\r\n\telse {\r\n\t\t// console.log('removing aura after source death', stringifySimpleCard(entity), entity.maxHealth);\r\n\t\tconst buffs = entity.enchantments.filter((e) => e.cardId === enchantmentId && e.originEntityId === deadAuraSource.entityId);\r\n\t\tconst numberOfBuffs = buffs.length;\r\n\r\n\t\tentity.attack = Math.max(\r\n\t\t\t0,\r\n\t\t\tentity.attack - numberOfBuffs * (enchantmentId === CardIds.SouthseaCaptain_YarrrEnchantmentBattlegrounds ? 2 : 1),\r\n\t\t);\r\n\t\tentity.health = entity.maxHealth\r\n\t\t\t? Math.min(entity.health, entity.maxHealth)\r\n\t\t\t: Math.max(\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tentity.health - numberOfBuffs * (enchantmentId === CardIds.SouthseaCaptain_YarrrEnchantmentBattlegrounds ? 2 : 1),\r\n\t\t\t );\r\n\t\tentity.enchantments = entity.enchantments.filter((aura) => aura.cardId !== enchantmentId);\r\n\t\t// console.log('removed aura after source death', stringifySimpleCard(entity), entity.maxHealth);\r\n\t}\r\n};\r\n\r\nconst removeLadySinestraAura = (entity: BoardEntity, enchantmentId: string): void => {\r\n\tconst numberOfBuffs = entity.enchantments.filter((e) => e.cardId === enchantmentId).length;\r\n\t// TODO: find proper enchantment\r\n\tentity.attack = Math.max(\r\n\t\t0,\r\n\t\tentity.attack - numberOfBuffs * (enchantmentId === CardIds.DraconicBlessingEnchantmentBattlegrounds2 ? 6 : 3),\r\n\t);\r\n\tentity.enchantments = entity.enchantments.filter((aura) => aura.cardId !== enchantmentId);\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"auras.js","sourceRoot":"","sources":["../../src/simulation/auras.ts"],"names":[],"mappings":";;;AACA,iEAA8E;AAG9E,oDAAiF;AACjF,oCAA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AY,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,aAAa,CAAC,CAAC;KAE1F;AACF,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,MAAmB,EAAE,aAAqB,EAAQ,EAAE;IACnF,MAAM,aAAa,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,aAAa,CAAC,CAAC,MAAM,CAAC;IAE3F,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CACvB,CAAC,EACD,MAAM,CAAC,MAAM,GAAG,aAAa,GAAG,CAAC,aAAa,qCAAsD,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC7G,CAAC;IACF,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,aAAa,CAAC,CAAC;AAC3F,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from 'src/bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { AURA_ENCHANTMENTS, AURA_ORIGINS, CardsData } from '../cards/cards-data';\r\nimport { isCorrectTribe } from '../utils';\r\n\r\n// Check if aura is already applied, and if not re-apply it\r\nexport const applyAuras = (board: BoardEntity[], numberOfDeathwingPresents: number, data: CardsData, cards: AllCardsService): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (AURA_ORIGINS.indexOf(board[i].cardId) !== -1) {\r\n\t\t\tconst enchantmentId = AURA_ENCHANTMENTS.find((aura) => aura[0] === board[i].cardId)[1];\r\n\t\t\tapplyAura(board, i, enchantmentId, cards);\r\n\t\t}\r\n\t}\r\n\r\n\tfor (let i = 0; i < numberOfDeathwingPresents; i++) {\r\n\t\tapplyDeathwingAura(board, CardIds.AllWillBurn_AllWillBurnEnchantmentBattlegrounds);\r\n\t}\r\n\t// return board;\r\n};\r\n\r\nexport const setImplicitData = (board: BoardEntity[], cardsData: CardsData): void => {\r\n\tfor (const entity of board) {\r\n\t\tentity.maxHealth = entity.health;\r\n\t\tconst avengeValue = cardsData.avengeValue(entity.cardId);\r\n\t\tif (avengeValue > 0) {\r\n\t\t\tentity.avengeCurrent = avengeValue;\r\n\t\t\tentity.avengeDefault = avengeValue;\r\n\t\t}\r\n\t\tentity.immuneWhenAttackCharges = 0;\r\n\t}\r\n};\r\n\r\nexport const setImplicitDataHero = (hero: BgsPlayerEntity, cardsData: CardsData): void => {\r\n\tconst avengeValue = cardsData.avengeValue(hero.heroPowerId);\r\n\tif (avengeValue > 0) {\r\n\t\thero.avengeCurrent = avengeValue;\r\n\t\thero.avengeDefault = avengeValue;\r\n\t}\r\n};\r\n\r\n// When removing and applying auras without any action in-between (like for attackImmediately minions),\r\n// we use this hack to avoid granting additional health to minions that would end at 0 HP\r\n// once the aura is removed (eg two Southsea Captains)\r\nexport const removeAuras = (board: BoardEntity[], data: CardsData, allowNegativeHealth = false): void => {\r\n\tfor (const entity of board) {\r\n\t\tremoveAurasFrom(entity, board, data, allowNegativeHealth);\r\n\t}\r\n};\r\n\r\nexport const removeAurasAfterAuraSourceDeath = (board: BoardEntity[], auraSource: BoardEntity, data: CardsData): void => {\r\n\tconst auraPair = AURA_ENCHANTMENTS.find((pair) => pair[0] === auraSource.cardId);\r\n\tconst auraEnchantmentId = !!auraPair ? auraPair[1] : null;\r\n\tif (!auraEnchantmentId) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tfor (const entity of board) {\r\n\t\tremoveAura(entity, auraEnchantmentId, board, false, auraSource);\r\n\t}\r\n};\r\n\r\nconst removeAurasFrom = (entity: BoardEntity, board: BoardEntity[], data: CardsData, allowNegativeHealth: boolean): void => {\r\n\t// let newEntity = entity;\r\n\tfor (const enchantment of entity.enchantments) {\r\n\t\tremoveAura(entity, enchantment.cardId, board, allowNegativeHealth);\r\n\t}\r\n\t// return newEntity;\r\n};\r\n\r\nconst applyAura = (board: BoardEntity[], i: number, enchantmentId: string, cards: AllCardsService): void => {\r\n\tswitch (board[i].cardId) {\r\n\t\t// case CardIds.SiegebreakerLegacy:\r\n\t\t// case CardIds.SiegebreakerBattlegrounds:\r\n\t\t// \tapplySiegebreakerAura(board, i, enchantmentId, cards);\r\n\t\t// \treturn;\r\n\t\t// case CardIds.Malganis1:\r\n\t\t// case CardIds.MalganisBattlegrounds:\r\n\t\t// \tapplyMalGanisAura(board, i, enchantmentId, cards);\r\n\t\t// \treturn;\r\n\t\tcase CardIds.Kathranatir2:\r\n\t\tcase CardIds.KathranatirBattlegrounds:\r\n\t\t\tapplyKathranatirAura(board, i, enchantmentId, cards);\r\n\t\t\treturn;\r\n\t\tcase CardIds.MurlocWarleaderLegacy:\r\n\t\tcase CardIds.MurlocWarleaderVanilla:\r\n\t\tcase CardIds.MurlocWarleaderBattlegrounds:\r\n\t\t\tapplyMurlocWarleaderAura(board, i, enchantmentId, cards);\r\n\t\t\treturn;\r\n\t\tcase CardIds.SouthseaCaptainLegacy:\r\n\t\tcase CardIds.SouthseaCaptainCore:\r\n\t\tcase CardIds.SouthseaCaptainVanilla:\r\n\t\tcase CardIds.SouthseaCaptainBattlegrounds:\r\n\t\t\tapplySouthseaCaptainAura(board, i, enchantmentId, cards);\r\n\t\t\treturn;\r\n\t\tcase CardIds.LadySinestraBattlegrounds1:\r\n\t\tcase CardIds.LadySinestraBattlegrounds2:\r\n\t\t\tapplyLadySinestraAura(board, i, enchantmentId);\r\n\t\t\treturn;\r\n\t}\r\n};\r\n\r\nconst removeAura = (\r\n\tentity: BoardEntity,\r\n\tenchantmentId: string,\r\n\tboard: BoardEntity[],\r\n\tallowNegativeHealth: boolean,\r\n\tdeadAuraSource: BoardEntity = null,\r\n): void => {\r\n\tswitch (enchantmentId) {\r\n\t\t// case CardIds.Siegebreaker_SiegebreakingLegacyEnchantment:\r\n\t\t// case CardIds.Siegebreaker_SiegebreakingEnchantmentBattlegrounds:\r\n\t\t// \tremoveSiegebreakerAura(entity, enchantmentId);\r\n\t\t// \treturn;\r\n\t\t// case CardIds.Malganis_GraspOfMalganisEnchantment:\r\n\t\t// case CardIds.Malganis_GraspOfMalganisEnchantmentBattlegrounds:\r\n\t\t// \tremoveMalGanisAura(entity, enchantmentId);\r\n\t\t// \treturn;\r\n\t\tcase CardIds.Kathranatir_GraspOfKathranatirEnchantment1:\r\n\t\tcase CardIds.Kathranatir_GraspOfKathranatirEnchantment2:\r\n\t\t\tremoveKathranatirAura(entity, enchantmentId);\r\n\t\t\treturn;\r\n\t\tcase CardIds.MurlocWarleader_MrgglaarglLegacyEnchantment:\r\n\t\tcase CardIds.MurlocWarleader_MrgglaarglVanillaEnchantment:\r\n\t\tcase CardIds.MurlocWarleader_MrgglaarglEnchantmentBattlegrounds:\r\n\t\t\tremoveMurlocWarleaderAura(entity, enchantmentId);\r\n\t\t\treturn;\r\n\t\tcase CardIds.SouthseaCaptain_YarrrLegacyEnchantment:\r\n\t\tcase CardIds.SouthseaCaptain_YarrrVanillaEnchantment:\r\n\t\tcase CardIds.SouthseaCaptain_YarrrEnchantmentBattlegrounds:\r\n\t\t\tremoveSouthseaCaptainAura(entity, enchantmentId, board, allowNegativeHealth, deadAuraSource);\r\n\t\t\treturn;\r\n\t\t// TODO find proper enchantment\r\n\t\tcase CardIds.DraconicBlessingEnchantmentBattlegrounds1:\r\n\t\tcase CardIds.DraconicBlessingEnchantmentBattlegrounds2:\r\n\t\t\tremoveLadySinestraAura(entity, enchantmentId);\r\n\t\t\treturn;\r\n\t\tcase CardIds.AllWillBurn_AllWillBurnEnchantmentBattlegrounds:\r\n\t\t\tremoveDeathwingAura(entity, enchantmentId);\r\n\t\t\treturn;\r\n\t\t// case CardIds.WhirlwindTempest_WhirlingEnchantment:\r\n\t\t// \tremoveWhirlwindTempestAura(entity, enchantmentId);\r\n\t\t// \treturn;\r\n\t}\r\n};\r\n\r\nconst applyDeathwingAura = (board: BoardEntity[], enchantmentId: string): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tconst entity = board[i];\r\n\t\tif (!entity.enchantments.some((aura) => aura.cardId === enchantmentId)) {\r\n\t\t\tentity.attack += 2;\r\n\t\t\tentity.enchantments.push({ cardId: enchantmentId, originEntityId: undefined });\r\n\t\t}\r\n\t}\r\n};\r\n\r\n// const applySiegebreakerAura = (board: BoardEntity[], index: number, enchantmentId: string, cards: AllCardsService): void => {\r\n// \tconst originEntity = board[index];\r\n// \t// const newBoard = [];\r\n// \tfor (let i = 0; i < board.length; i++) {\r\n// \t\tconst entity = board[i];\r\n// \t\tif (i === index || !isCorrectTribe(cards.getCard(entity.cardId).race, Race.DEMON)) {\r\n// \t\t\t// newBoard.push(entity);\r\n// \t\t\tcontinue;\r\n// \t\t}\r\n\r\n// \t\tif (!entity.enchantments.some((aura) => aura.cardId === enchantmentId && aura.originEntityId === originEntity.entityId)) {\r\n// \t\t\tentity.attack += enchantmentId === CardIds.Siegebreaker_SiegebreakingEnchantmentBattlegrounds ? 2 : 1;\r\n// \t\t\tentity.enchantments.push({ cardId: enchantmentId, originEntityId: originEntity.entityId });\r\n// \t\t}\r\n// \t}\r\n// };\r\n\r\n// const applyMalGanisAura = (board: BoardEntity[], index: number, enchantmentId: string, cards: AllCardsService): void => {\r\n// \tconst originEntity = board[index];\r\n// \t// const newBoard = [];\r\n// \tfor (let i = 0; i < board.length; i++) {\r\n// \t\tconst entity = board[i];\r\n// \t\tif (i === index || !isCorrectTribe(cards.getCard(entity.cardId).race, Race.DEMON)) {\r\n// \t\t\t// newBoard.push(entity);\r\n// \t\t\tcontinue;\r\n// \t\t}\r\n\r\n// \t\tif (!entity.enchantments.some((aura) => aura.cardId === enchantmentId && aura.originEntityId === originEntity.entityId)) {\r\n// \t\t\tentity.attack += enchantmentId === CardIds.Malganis_GraspOfMalganisEnchantmentBattlegrounds ? 4 : 2;\r\n// \t\t\tentity.health += enchantmentId === CardIds.Malganis_GraspOfMalganisEnchantmentBattlegrounds ? 4 : 2;\r\n// \t\t\tentity.enchantments.push({ cardId: enchantmentId, originEntityId: originEntity.entityId });\r\n// \t\t}\r\n// \t}\r\n// \t// return newBoard;\r\n// };\r\n\r\nconst applyKathranatirAura = (board: BoardEntity[], index: number, enchantmentId: string, cards: AllCardsService): void => {\r\n\tconst originEntity = board[index];\r\n\t// const newBoard = [];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tconst entity = board[i];\r\n\t\tif (i === index || !isCorrectTribe(cards.getCard(entity.cardId).race, Race.DEMON)) {\r\n\t\t\t// newBoard.push(entity);\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tif (!entity.enchantments.some((aura) => aura.cardId === enchantmentId && aura.originEntityId === originEntity.entityId)) {\r\n\t\t\tentity.attack += enchantmentId === CardIds.Kathranatir_GraspOfKathranatirEnchantment2 ? 4 : 2;\r\n\t\t\tentity.enchantments.push({ cardId: enchantmentId, originEntityId: originEntity.entityId });\r\n\t\t}\r\n\t}\r\n\t// return newBoard;\r\n};\r\n\r\nconst removeDeathwingAura = (entity: BoardEntity, enchantmentId: string): void => {\r\n\tconst numberOfBuffs = entity.enchantments.filter((e) => e.cardId === enchantmentId).length;\r\n\tentity.attack = Math.max(0, entity.attack - numberOfBuffs * 2);\r\n\tentity.enchantments = entity.enchantments.filter((aura) => aura.cardId !== enchantmentId);\r\n};\r\n\r\n// const removeSiegebreakerAura = (entity: BoardEntity, enchantmentId: string): void => {\r\n// \tconst numberOfBuffs = entity.enchantments.filter((e) => e.cardId === enchantmentId).length;\r\n// \tentity.attack = Math.max(\r\n// \t\t0,\r\n// \t\tentity.attack - numberOfBuffs * (enchantmentId === CardIds.Siegebreaker_SiegebreakingEnchantmentBattlegrounds ? 2 : 1),\r\n// \t);\r\n// \tentity.enchantments = entity.enchantments.filter((aura) => aura.cardId !== enchantmentId);\r\n// };\r\n\r\n// const removeMalGanisAura = (entity: BoardEntity, enchantmentId: string): void => {\r\n// \tconst numberOfBuffs = entity.enchantments.filter((e) => e.cardId === enchantmentId).length;\r\n// \tentity.attack = Math.max(\r\n// \t\t0,\r\n// \t\tentity.attack - numberOfBuffs * (enchantmentId === CardIds.Malganis_GraspOfMalganisEnchantmentBattlegrounds ? 4 : 2),\r\n// \t);\r\n// \tentity.health = Math.max(\r\n// \t\t1,\r\n// \t\tentity.health - numberOfBuffs * (enchantmentId === CardIds.Malganis_GraspOfMalganisEnchantmentBattlegrounds ? 4 : 2),\r\n// \t);\r\n// \tentity.enchantments = entity.enchantments.filter((aura) => aura.cardId !== enchantmentId);\r\n// };\r\n\r\nconst removeKathranatirAura = (entity: BoardEntity, enchantmentId: string): void => {\r\n\tconst numberOfBuffs = entity.enchantments.filter((e) => e.cardId === enchantmentId).length;\r\n\tentity.attack = Math.max(\r\n\t\t0,\r\n\t\tentity.attack - numberOfBuffs * (enchantmentId === CardIds.Kathranatir_GraspOfKathranatirEnchantment2 ? 4 : 2),\r\n\t);\r\n\tentity.enchantments = entity.enchantments.filter((aura) => aura.cardId !== enchantmentId);\r\n};\r\n\r\nconst applyMurlocWarleaderAura = (board: BoardEntity[], index: number, enchantmentId: string, cards: AllCardsService): void => {\r\n\tconst originEntity = board[index];\r\n\t// const newBoard = [];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tconst entity = board[i];\r\n\t\tif (i === index || !isCorrectTribe(cards.getCard(entity.cardId).race, Race.MURLOC)) {\r\n\t\t\t// newBoard.push(entity);\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tif (!entity.enchantments.some((aura) => aura.cardId === enchantmentId && aura.originEntityId === originEntity.entityId)) {\r\n\t\t\tentity.attack += enchantmentId === CardIds.MurlocWarleader_MrgglaarglEnchantmentBattlegrounds ? 4 : 2;\r\n\t\t\tentity.enchantments.push({ cardId: enchantmentId, originEntityId: originEntity.entityId });\r\n\t\t}\r\n\t}\r\n\t// return newBoard;\r\n};\r\n\r\nconst removeMurlocWarleaderAura = (entity: BoardEntity, enchantmentId: string): void => {\r\n\tconst numberOfBuffs = entity.enchantments.filter((e) => e.cardId === enchantmentId && e.originEntityId !== entity.entityId).length;\r\n\tentity.attack = Math.max(\r\n\t\t0,\r\n\t\tentity.attack - numberOfBuffs * (enchantmentId === CardIds.MurlocWarleader_MrgglaarglEnchantmentBattlegrounds ? 4 : 2),\r\n\t);\r\n\tentity.enchantments = entity.enchantments.filter((aura) => aura.cardId !== enchantmentId);\r\n};\r\n\r\nconst applySouthseaCaptainAura = (board: BoardEntity[], index: number, enchantmentId: string, cards: AllCardsService): void => {\r\n\tconst originEntity = board[index];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tconst entity = board[i];\r\n\t\tif (i === index || !isCorrectTribe(cards.getCard(entity.cardId).race, Race.PIRATE)) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\t// console.log('applying aura', stringifySimpleCard(entity), entity.maxHealth);\r\n\t\tif (!entity.enchantments.some((aura) => aura.cardId === enchantmentId && aura.originEntityId === originEntity.entityId)) {\r\n\t\t\tentity.attack += enchantmentId === CardIds.SouthseaCaptain_YarrrEnchantmentBattlegrounds ? 2 : 1;\r\n\t\t\tentity.health += enchantmentId === CardIds.SouthseaCaptain_YarrrEnchantmentBattlegrounds ? 2 : 1;\r\n\t\t\t// entity.maxHealth += enchantmentId === CardIds.SouthseaCaptain_YarrrEnchantmentBattlegrounds ? 2 : 1;\r\n\t\t\tentity.enchantments.push({ cardId: enchantmentId, originEntityId: originEntity.entityId });\r\n\t\t}\r\n\t}\r\n\t// return newBoard;\r\n};\r\n\r\nconst applyLadySinestraAura = (board: BoardEntity[], index: number, enchantmentId: string): void => {\r\n\tconst originEntity = board[index];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tconst entity = board[i];\r\n\t\t// TODO find proper enchantment\r\n\t\tentity.attack += enchantmentId === CardIds.DraconicBlessingEnchantmentBattlegrounds2 ? 6 : 3;\r\n\t\tentity.enchantments.push({ cardId: enchantmentId, originEntityId: originEntity.entityId });\r\n\t}\r\n};\r\n\r\nconst removeSouthseaCaptainAura = (\r\n\tentity: BoardEntity,\r\n\tenchantmentId: string,\r\n\tboard: BoardEntity[],\r\n\tallowNegativeHealth: boolean,\r\n\tdeadAuraSource: BoardEntity = null,\r\n): void => {\r\n\tif (!deadAuraSource) {\r\n\t\t// console.log('removing aura', stringifySimpleCard(entity), entity.maxHealth);\r\n\t\tconst buffs = entity.enchantments.filter((e) => e.cardId === enchantmentId && e.originEntityId !== entity.entityId);\r\n\t\tconst numberOfBuffs = buffs.length;\r\n\r\n\t\tentity.attack = Math.max(\r\n\t\t\t0,\r\n\t\t\tentity.attack - numberOfBuffs * (enchantmentId === CardIds.SouthseaCaptain_YarrrEnchantmentBattlegrounds ? 2 : 1),\r\n\t\t);\r\n\r\n\t\tentity.health = Math.max(\r\n\t\t\tallowNegativeHealth ? -999 : 1,\r\n\t\t\tentity.health - numberOfBuffs * (enchantmentId === CardIds.SouthseaCaptain_YarrrEnchantmentBattlegrounds ? 2 : 1),\r\n\t\t);\r\n\t\tentity.enchantments = entity.enchantments.filter((aura) => aura.cardId !== enchantmentId);\r\n\t\t// console.log('removed aura', stringifySimpleCard(entity), entity.maxHealth);\r\n\t}\r\n\t// Special case where the source dies, health is treated differently\r\n\telse {\r\n\t\t// console.log('removing aura after source death', stringifySimpleCard(entity), stringifySimpleCard(deadAuraSource), entity.maxHealth);\r\n\t\tconst buffs = entity.enchantments.filter((e) => e.cardId === enchantmentId && e.originEntityId === deadAuraSource.entityId);\r\n\t\tconst numberOfBuffs = buffs.length;\r\n\r\n\t\tentity.attack = Math.max(\r\n\t\t\t0,\r\n\t\t\tentity.attack - numberOfBuffs * (enchantmentId === CardIds.SouthseaCaptain_YarrrEnchantmentBattlegrounds ? 2 : 1),\r\n\t\t);\r\n\t\tentity.health = entity.maxHealth\r\n\t\t\t? Math.min(entity.health, entity.maxHealth)\r\n\t\t\t: Math.max(\r\n\t\t\t\t\tallowNegativeHealth ? -999 : 1,\r\n\t\t\t\t\tentity.health - numberOfBuffs * (enchantmentId === CardIds.SouthseaCaptain_YarrrEnchantmentBattlegrounds ? 2 : 1),\r\n\t\t\t );\r\n\t\tentity.enchantments = entity.enchantments.filter((aura) => aura.cardId !== enchantmentId);\r\n\t\t// console.log('removed aura after source death', stringifySimpleCard(entity), entity.maxHealth);\r\n\t}\r\n};\r\n\r\nconst removeLadySinestraAura = (entity: BoardEntity, enchantmentId: string): void => {\r\n\tconst numberOfBuffs = entity.enchantments.filter((e) => e.cardId === enchantmentId).length;\r\n\t// TODO: find proper enchantment\r\n\tentity.attack = Math.max(\r\n\t\t0,\r\n\t\tentity.attack - numberOfBuffs * (enchantmentId === CardIds.DraconicBlessingEnchantmentBattlegrounds2 ? 6 : 3),\r\n\t);\r\n\tentity.enchantments = entity.enchantments.filter((aura) => aura.cardId !== enchantmentId);\r\n};\r\n"]}
|
|
@@ -8,7 +8,17 @@ const deathrattle_spawns_1 = require("./deathrattle-spawns");
|
|
|
8
8
|
const applyAvengeEffects = (deadEntity, deadEntityIndex, boardWithDeadEntity, boardWithDeadEntityHero, otherBoard, otherBoardHero, allCards, cardsData, sharedState, spectator) => {
|
|
9
9
|
const candidatesEntitiesSpawnedFromAvenge = [];
|
|
10
10
|
updateAvengeCounters(boardWithDeadEntity, boardWithDeadEntityHero);
|
|
11
|
-
const avengers = boardWithDeadEntity
|
|
11
|
+
const avengers = boardWithDeadEntity
|
|
12
|
+
.filter((e) => !!e.avengeDefault && e.avengeCurrent === 0)
|
|
13
|
+
.sort((a, b) => {
|
|
14
|
+
if (a.cardId === "BG21_031" || a.cardId === "BG21_031_G") {
|
|
15
|
+
return -1;
|
|
16
|
+
}
|
|
17
|
+
if (b.cardId === "BG21_031" || b.cardId === "BG21_031_G") {
|
|
18
|
+
return 1;
|
|
19
|
+
}
|
|
20
|
+
return 0;
|
|
21
|
+
});
|
|
12
22
|
for (const avenger of avengers) {
|
|
13
23
|
handleAvenge(boardWithDeadEntity, boardWithDeadEntityHero, avenger, otherBoard, otherBoardHero, cardsData, sharedState, spectator, allCards);
|
|
14
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avenge.js","sourceRoot":"","sources":["../../src/simulation/avenge.ts"],"names":[],"mappings":";;;AAAA,iEAA8E;AAI9E,oCAUkB;AAClB,qCAAiF;AACjF,6DAAqD;AAI9C,MAAM,kBAAkB,GAAG,CACjC,UAAuB,EACvB,eAAuB,EACvB,mBAAkC,EAClC,uBAAwC,EACxC,UAAyB,EACzB,cAA+B,EAC/B,QAAyB,EACzB,SAAoB,EACpB,WAAwB,EACxB,SAAoB,EACb,EAAE;IACT,MAAM,mCAAmC,GAAkB,EAAE,CAAC;IAC9D,oBAAoB,CAAC,mBAAmB,EAAE,uBAAuB,CAAC,CAAC;IACnE,MAAM,QAAQ,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,IAAI,CAAC,CAAC,aAAa,KAAK,CAAC,CAAC,CAAC;IAC/F,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;QAC/B,YAAY,CACX,mBAAmB,EACnB,uBAAuB,EACvB,OAAO,EACP,UAAU,EACV,cAAc,EACd,SAAS,EACT,WAAW,EACX,SAAS,EACT,QAAQ,CACR,CAAC;KACF;IAED,MAAM,WAAW,GAAG,CAAC,CAAC,uBAAuB,CAAC,aAAa,IAAI,uBAAuB,CAAC,aAAa,KAAK,CAAC,CAAC;IAC3G,IAAI,WAAW,EAAE;QAOhB,gBAAgB,CACf,UAAU,EACV,mBAAmB,EACnB,uBAAuB,EACvB,UAAU,EACV,cAAc,EACd,mCAAmC,EACnC,SAAS,EACT,WAAW,EACX,SAAS,EACT,QAAQ,CACR,CAAC;KACF;IAED,4BAAm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EACxB,SAAoB,EACpB,QAAyB,EACxB,EAAE;IAGH,QAAQ,uBAAuB,aAAvB,uBAAuB,uBAAvB,uBAAuB,CAAE,WAAW,EAAE;QAC7C;YACC,mCAAmC,CAAC,IAAI,CACvC,GAAG,kCAAa,mBAEf,CAAC,EACD,mBAAmB,EACnB,uBAAuB,EACvB,UAAU,EACV,cAAc,EACd,QAAQ,EACR,SAAS,EACT,WAAW,EACX,SAAS,EACT,UAAU,CAAC,QAAQ,EACnB,KAAK,EACL,KAAK,EACL,KAAK,CACL,CACD,CAAC;YACF,MAAM;KACP;IACD,uBAAuB,CAAC,aAAa,GAAG,uBAAuB,CAAC,aAAa,CAAC;AAC/E,CAAC,CAAC","sourcesContent":["import { AllCardsService, CardIds, 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 {\r\n\taddCardsInHand,\r\n\taddStatsToBoard,\r\n\tafterStatsUpdate,\r\n\tgetRandomMinion,\r\n\tgetRandomMinionWithHighestHealth,\r\n\tgrantRandomStats,\r\n\tmakeMinionGolden,\r\n\tmodifyAttack,\r\n\tmodifyHealth,\r\n} from '../utils';\r\nimport { dealDamageToEnemy, getNeighbours, performEntitySpawns } from './attack';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { SharedState } from './shared-state';\r\nimport { Spectator } from './spectator/spectator';\r\n\r\nexport const applyAvengeEffects = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndex: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst candidatesEntitiesSpawnedFromAvenge: BoardEntity[] = [];\r\n\tupdateAvengeCounters(boardWithDeadEntity, boardWithDeadEntityHero);\r\n\tconst avengers = boardWithDeadEntity.filter((e) => !!e.avengeDefault && e.avengeCurrent === 0);\r\n\tfor (const avenger of avengers) {\r\n\t\thandleAvenge(\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\tavenger,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t}\r\n\t// console.log('updating dead entity avenge counter', boardWithDeadEntityHero.avengeCurrent, stringifySimpleCard(deadEntity, allCards));\r\n\tconst heroAvenger = !!boardWithDeadEntityHero.avengeDefault && boardWithDeadEntityHero.avengeCurrent === 0;\r\n\tif (heroAvenger) {\r\n\t\t// console.log(\r\n\t\t// \t'Hero is an avenger',\r\n\t\t// \tboardWithDeadEntityHero.avengeCurrent,\r\n\t\t// \tboardWithDeadEntityHero.avengeDefault,\r\n\t\t// \tboardWithDeadEntityHero.heroPowerId,\r\n\t\t// );\r\n\t\thandleHeroAvenge(\r\n\t\t\tdeadEntity,\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tcandidatesEntitiesSpawnedFromAvenge,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t}\r\n\r\n\tperformEntitySpawns(\r\n\t\tcandidatesEntitiesSpawnedFromAvenge,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tdeadEntity,\r\n\t\tdeadEntityIndex,\r\n\t\totherBoard,\r\n\t\totherBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n};\r\n\r\nconst updateAvengeCounters = (board: readonly BoardEntity[], boardWithDeadEntityHero: BgsPlayerEntity) => {\r\n\tfor (const entity of board) {\r\n\t\tif (!!entity.avengeDefault) {\r\n\t\t\tentity.avengeCurrent -= 1;\r\n\t\t}\r\n\t}\r\n\tif (!!boardWithDeadEntityHero.avengeDefault) {\r\n\t\tboardWithDeadEntityHero.avengeCurrent -= 1;\r\n\t}\r\n};\r\n\r\nconst handleAvenge = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tavenger: BoardEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n\tallCards: AllCardsService,\r\n) => {\r\n\t// Don't forget to update the avenge data in cards-data\r\n\tswitch (avenger.cardId) {\r\n\t\tcase CardIds.BirdBuddy:\r\n\t\t\taddStatsToBoard(avenger, boardWithDeadEntity, 1, 1, allCards, spectator, 'BEAST');\r\n\t\t\tbreak;\r\n\t\tcase CardIds.BirdBuddyBattlegrounds:\r\n\t\t\taddStatsToBoard(avenger, boardWithDeadEntity, 2, 2, allCards, spectator, 'BEAST');\r\n\t\t\tbreak;\r\n\t\tcase CardIds.BuddingGreenthumb:\r\n\t\tcase CardIds.BuddingGreenthumbBattlegrounds:\r\n\t\t\tconst neighbours = getNeighbours(boardWithDeadEntity, avenger);\r\n\t\t\tneighbours.forEach((entity) => {\r\n\t\t\t\tmodifyAttack(entity, avenger.cardId === CardIds.BuddingGreenthumbBattlegrounds ? 4 : 2, boardWithDeadEntity, allCards);\r\n\t\t\t\tmodifyHealth(entity, avenger.cardId === CardIds.BuddingGreenthumbBattlegrounds ? 2 : 1, boardWithDeadEntity, allCards);\r\n\t\t\t\tafterStatsUpdate(entity, boardWithDeadEntity, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(avenger, entity, boardWithDeadEntity);\r\n\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.FrostwolfLieutenant:\r\n\t\tcase CardIds.FrostwolfLieutenantBattlegrounds:\r\n\t\t\taddStatsToBoard(\r\n\t\t\t\tavenger,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tavenger.cardId === CardIds.FrostwolfLieutenantBattlegrounds ? 2 : 1,\r\n\t\t\t\t0,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.StormpikeLieutenant:\r\n\t\tcase CardIds.StormpikeLieutenantBattlegrounds:\r\n\t\t\taddStatsToBoard(\r\n\t\t\t\tavenger,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t0,\r\n\t\t\t\tavenger.cardId === CardIds.StormpikeLieutenantBattlegrounds ? 2 : 1,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PalescaleCrocolisk:\r\n\t\t\tconst target1 = grantRandomStats(avenger, boardWithDeadEntity, 6, 6, Race.BEAST, allCards, spectator);\r\n\t\t\tif (!!target1) {\r\n\t\t\t\tspectator.registerPowerTarget(avenger, target1, boardWithDeadEntity);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PalescaleCrocoliskBattlegrounds:\r\n\t\t\tconst target2 = grantRandomStats(avenger, boardWithDeadEntity, 12, 12, Race.BEAST, allCards, spectator);\r\n\t\t\tif (!!target2) {\r\n\t\t\t\tspectator.registerPowerTarget(avenger, target2, boardWithDeadEntity);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ImpatientDoomsayer:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, 1, boardWithDeadEntity, allCards, spectator);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ImpatientDoomsayerBattlegrounds:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, 2, boardWithDeadEntity, allCards, spectator);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.WitchwingNestmatron:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, 1, boardWithDeadEntity, allCards, spectator);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.WitchwingNestmatronBattlegrounds:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, 2, boardWithDeadEntity, allCards, spectator);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Thorncaller:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, 1, boardWithDeadEntity, allCards, spectator);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ThorncallerBattlegrounds:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, 2, boardWithDeadEntity, allCards, spectator, CardIds.BloodGem);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Sisefin:\r\n\t\t\tconst validTargets = boardWithDeadEntity.filter((e) => !e.poisonous);\r\n\t\t\tconst murloc = getRandomMinion(validTargets, Race.MURLOC, allCards);\r\n\t\t\tif (murloc) {\r\n\t\t\t\tmurloc.poisonous = true;\r\n\t\t\t\tspectator.registerPowerTarget(avenger, murloc, boardWithDeadEntity);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.SisefinBattlegrounds:\r\n\t\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\t\tconst validTargets = boardWithDeadEntity.filter((e) => !e.poisonous);\r\n\t\t\t\tconst murloc2 = getRandomMinion(validTargets, Race.MURLOC, allCards);\r\n\t\t\t\tif (murloc2) {\r\n\t\t\t\t\tmurloc2.poisonous = true;\r\n\t\t\t\t\tspectator.registerPowerTarget(avenger, murloc2, boardWithDeadEntity);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.MechanoTank:\r\n\t\t\t// This can be null if the avenge triggers when the last enemy minion dies as well\r\n\t\t\tconst target = getRandomMinionWithHighestHealth(otherBoard);\r\n\t\t\tspectator.registerPowerTarget(avenger, target, otherBoard);\r\n\t\t\tdealDamageToEnemy(\r\n\t\t\t\ttarget,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tavenger,\r\n\t\t\t\t5,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.MechanoTankBattlegrounds:\r\n\t\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\t\tconst target = getRandomMinionWithHighestHealth(otherBoard);\r\n\t\t\t\tspectator.registerPowerTarget(avenger, target, otherBoard);\r\n\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tavenger,\r\n\t\t\t\t\t5,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tcardsData,\r\n\t\t\t\t\tsharedState,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.TonyTwoTusk:\r\n\t\t\tconst nonGoldenMinions = boardWithDeadEntity\r\n\t\t\t\t.filter((e) => e.entityId !== avenger.entityId)\r\n\t\t\t\t.filter((e) => {\r\n\t\t\t\t\tconst ref = allCards.getCard(e.cardId);\r\n\t\t\t\t\treturn !!ref.battlegroundsPremiumDbfId && !!allCards.getCardFromDbfId(ref.battlegroundsPremiumDbfId).id;\r\n\t\t\t\t});\r\n\t\t\tconst pirate = getRandomMinion(nonGoldenMinions, Race.PIRATE, allCards);\r\n\t\t\tif (pirate) {\r\n\t\t\t\tmakeMinionGolden(pirate, avenger, boardWithDeadEntity, allCards, spectator);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.TonyTwoTuskBattlegrounds:\r\n\t\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\t\tconst nonGoldenMinions = boardWithDeadEntity.filter((e) => {\r\n\t\t\t\t\tconst ref = allCards.getCard(e.cardId);\r\n\t\t\t\t\treturn !!ref.battlegroundsPremiumDbfId;\r\n\t\t\t\t});\r\n\t\t\t\tconst pirate = getRandomMinion(nonGoldenMinions, Race.PIRATE, allCards);\r\n\t\t\t\tif (pirate) {\r\n\t\t\t\t\tmakeMinionGolden(pirate, avenger, boardWithDeadEntity, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t}\r\n\tavenger.avengeCurrent = avenger.avengeDefault;\r\n};\r\n\r\nconst handleHeroAvenge = (\r\n\tdeadEntity: BoardEntity,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tcandidatesEntitiesSpawnedFromAvenge: BoardEntity[],\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n\tallCards: AllCardsService,\r\n) => {\r\n\t// https://twitter.com/LoewenMitchell/status/1491879869457879040\r\n\t// Not affected by Khadgar\r\n\tswitch (boardWithDeadEntityHero?.heroPowerId) {\r\n\t\tcase CardIds.Onyxia_Broodmother:\r\n\t\t\tcandidatesEntitiesSpawnedFromAvenge.push(\r\n\t\t\t\t...spawnEntities(\r\n\t\t\t\t\tCardIds.Onyxia_OnyxianWhelpToken,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tcardsData,\r\n\t\t\t\t\tsharedState,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t),\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t}\r\n\tboardWithDeadEntityHero.avengeCurrent = boardWithDeadEntityHero.avengeDefault;\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"avenge.js","sourceRoot":"","sources":["../../src/simulation/avenge.ts"],"names":[],"mappings":";;;AAAA,iEAA8E;AAI9E,oCAUkB;AAClB,qCAAiF;AACjF,6DAAqD;AAI9C,MAAM,kBAAkB,GAAG,CACjC,UAAuB,EACvB,eAAuB,EACvB,mBAAkC,EAClC,uBAAwC,EACxC,UAAyB,EACzB,cAA+B,EAC/B,QAAyB,EACzB,SAAoB,EACpB,WAAwB,EACxB,SAAoB,EACb,EAAE;IACT,MAAM,mCAAmC,GAAkB,EAAE,CAAC;IAC9D,oBAAoB,CAAC,mBAAmB,EAAE,uBAAuB,CAAC,CAAC;IACnE,MAAM,QAAQ,GAAG,mBAAmB;SAClC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,IAAI,CAAC,CAAC,aAAa,KAAK,CAAC,CAAC;SAGzD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACd,IAAI,CAAC,CAAC,MAAM,eAAwB,IAAI,CAAC,CAAC,MAAM,iBAAqC,EAAE;YACtF,OAAO,CAAC,CAAC,CAAC;SACV;QACD,IAAI,CAAC,CAAC,MAAM,eAAwB,IAAI,CAAC,CAAC,MAAM,iBAAqC,EAAE;YACtF,OAAO,CAAC,CAAC;SACT;QACD,OAAO,CAAC,CAAC;IACV,CAAC,CAAC,CAAC;IACJ,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;QAC/B,YAAY,CACX,mBAAmB,EACnB,uBAAuB,EACvB,OAAO,EACP,UAAU,EACV,cAAc,EACd,SAAS,EACT,WAAW,EACX,SAAS,EACT,QAAQ,CACR,CAAC;KACF;IAED,MAA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mB,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;iBAC5E;aACD;YACD,MAAM;KACP;IACD,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;AAC/C,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CACxB,UAAuB,EACvB,mBAAkC,EAClC,uBAAwC,EACxC,UAAyB,EACzB,cAA+B,EAC/B,mCAAkD,EAClD,SAAoB,EACpB,WAAwB,EACxB,SAAoB,EACpB,QAAyB,EACxB,EAAE;IAGH,QAAQ,uBAAuB,aAAvB,uBAAuB,uBAAvB,uBAAuB,CAAE,WAAW,EAAE;QAC7C;YACC,mCAAmC,CAAC,IAAI,CACvC,GAAG,kCAAa,mBAEf,CAAC,EACD,mBAAmB,EACnB,uBAAuB,EACvB,UAAU,EACV,cAAc,EACd,QAAQ,EACR,SAAS,EACT,WAAW,EACX,SAAS,EACT,UAAU,CAAC,QAAQ,EACnB,KAAK,EACL,KAAK,EACL,KAAK,CACL,CACD,CAAC;YACF,MAAM;KACP;IACD,uBAAuB,CAAC,aAAa,GAAG,uBAAuB,CAAC,aAAa,CAAC;AAC/E,CAAC,CAAC","sourcesContent":["import { AllCardsService, CardIds, 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 {\r\n\taddCardsInHand,\r\n\taddStatsToBoard,\r\n\tafterStatsUpdate,\r\n\tgetRandomMinion,\r\n\tgetRandomMinionWithHighestHealth,\r\n\tgrantRandomStats,\r\n\tmakeMinionGolden,\r\n\tmodifyAttack,\r\n\tmodifyHealth,\r\n} from '../utils';\r\nimport { dealDamageToEnemy, getNeighbours, performEntitySpawns } from './attack';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { SharedState } from './shared-state';\r\nimport { Spectator } from './spectator/spectator';\r\n\r\nexport const applyAvengeEffects = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndex: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst candidatesEntitiesSpawnedFromAvenge: BoardEntity[] = [];\r\n\tupdateAvengeCounters(boardWithDeadEntity, boardWithDeadEntityHero);\r\n\tconst avengers = boardWithDeadEntity\r\n\t\t.filter((e) => !!e.avengeDefault && e.avengeCurrent === 0)\r\n\t\t// Get Tony to be processed first, because of the \"when turned golden, the minion ignores the death for the avenge counter\"\r\n\t\t// behavior\r\n\t\t.sort((a, b) => {\r\n\t\t\tif (a.cardId === CardIds.TonyTwoTusk || a.cardId === CardIds.TonyTwoTuskBattlegrounds) {\r\n\t\t\t\treturn -1;\r\n\t\t\t}\r\n\t\t\tif (b.cardId === CardIds.TonyTwoTusk || b.cardId === CardIds.TonyTwoTuskBattlegrounds) {\r\n\t\t\t\treturn 1;\r\n\t\t\t}\r\n\t\t\treturn 0;\r\n\t\t});\r\n\tfor (const avenger of avengers) {\r\n\t\thandleAvenge(\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\tavenger,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t}\r\n\t// console.log('updating dead entity avenge counter', boardWithDeadEntityHero.avengeCurrent, stringifySimpleCard(deadEntity, allCards));\r\n\tconst heroAvenger = !!boardWithDeadEntityHero.avengeDefault && boardWithDeadEntityHero.avengeCurrent === 0;\r\n\tif (heroAvenger) {\r\n\t\t// console.log(\r\n\t\t// \t'Hero is an avenger',\r\n\t\t// \tboardWithDeadEntityHero.avengeCurrent,\r\n\t\t// \tboardWithDeadEntityHero.avengeDefault,\r\n\t\t// \tboardWithDeadEntityHero.heroPowerId,\r\n\t\t// );\r\n\t\thandleHeroAvenge(\r\n\t\t\tdeadEntity,\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tcandidatesEntitiesSpawnedFromAvenge,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t}\r\n\r\n\tperformEntitySpawns(\r\n\t\tcandidatesEntitiesSpawnedFromAvenge,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tdeadEntity,\r\n\t\tdeadEntityIndex,\r\n\t\totherBoard,\r\n\t\totherBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n};\r\n\r\nconst updateAvengeCounters = (board: readonly BoardEntity[], boardWithDeadEntityHero: BgsPlayerEntity) => {\r\n\tfor (const entity of board) {\r\n\t\tif (!!entity.avengeDefault) {\r\n\t\t\tentity.avengeCurrent -= 1;\r\n\t\t}\r\n\t}\r\n\tif (!!boardWithDeadEntityHero.avengeDefault) {\r\n\t\tboardWithDeadEntityHero.avengeCurrent -= 1;\r\n\t}\r\n};\r\n\r\nconst handleAvenge = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tavenger: BoardEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n\tallCards: AllCardsService,\r\n) => {\r\n\t// Don't forget to update the avenge data in cards-data\r\n\tswitch (avenger.cardId) {\r\n\t\tcase CardIds.BirdBuddy:\r\n\t\t\taddStatsToBoard(avenger, boardWithDeadEntity, 1, 1, allCards, spectator, 'BEAST');\r\n\t\t\tbreak;\r\n\t\tcase CardIds.BirdBuddyBattlegrounds:\r\n\t\t\taddStatsToBoard(avenger, boardWithDeadEntity, 2, 2, allCards, spectator, 'BEAST');\r\n\t\t\tbreak;\r\n\t\tcase CardIds.BuddingGreenthumb:\r\n\t\tcase CardIds.BuddingGreenthumbBattlegrounds:\r\n\t\t\tconst neighbours = getNeighbours(boardWithDeadEntity, avenger);\r\n\t\t\tneighbours.forEach((entity) => {\r\n\t\t\t\tmodifyAttack(entity, avenger.cardId === CardIds.BuddingGreenthumbBattlegrounds ? 4 : 2, boardWithDeadEntity, allCards);\r\n\t\t\t\tmodifyHealth(entity, avenger.cardId === CardIds.BuddingGreenthumbBattlegrounds ? 2 : 1, boardWithDeadEntity, allCards);\r\n\t\t\t\tafterStatsUpdate(entity, boardWithDeadEntity, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(avenger, entity, boardWithDeadEntity);\r\n\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.FrostwolfLieutenant:\r\n\t\tcase CardIds.FrostwolfLieutenantBattlegrounds:\r\n\t\t\taddStatsToBoard(\r\n\t\t\t\tavenger,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tavenger.cardId === CardIds.FrostwolfLieutenantBattlegrounds ? 2 : 1,\r\n\t\t\t\t0,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.StormpikeLieutenant:\r\n\t\tcase CardIds.StormpikeLieutenantBattlegrounds:\r\n\t\t\taddStatsToBoard(\r\n\t\t\t\tavenger,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t0,\r\n\t\t\t\tavenger.cardId === CardIds.StormpikeLieutenantBattlegrounds ? 2 : 1,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PalescaleCrocolisk:\r\n\t\t\tconst target1 = grantRandomStats(avenger, boardWithDeadEntity, 6, 6, Race.BEAST, allCards, spectator);\r\n\t\t\tif (!!target1) {\r\n\t\t\t\tspectator.registerPowerTarget(avenger, target1, boardWithDeadEntity);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PalescaleCrocoliskBattlegrounds:\r\n\t\t\tconst target2 = grantRandomStats(avenger, boardWithDeadEntity, 12, 12, Race.BEAST, allCards, spectator);\r\n\t\t\tif (!!target2) {\r\n\t\t\t\tspectator.registerPowerTarget(avenger, target2, boardWithDeadEntity);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ImpatientDoomsayer:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, 1, boardWithDeadEntity, allCards, spectator);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ImpatientDoomsayerBattlegrounds:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, 2, boardWithDeadEntity, allCards, spectator);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.WitchwingNestmatron:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, 1, boardWithDeadEntity, allCards, spectator);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.WitchwingNestmatronBattlegrounds:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, 2, boardWithDeadEntity, allCards, spectator);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Thorncaller:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, 1, boardWithDeadEntity, allCards, spectator);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ThorncallerBattlegrounds:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, 2, boardWithDeadEntity, allCards, spectator, CardIds.BloodGem);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Sisefin:\r\n\t\t\tconst validTargets = boardWithDeadEntity.filter((e) => !e.poisonous);\r\n\t\t\tconst murloc = getRandomMinion(validTargets, Race.MURLOC, allCards);\r\n\t\t\tif (murloc) {\r\n\t\t\t\tmurloc.poisonous = true;\r\n\t\t\t\tspectator.registerPowerTarget(avenger, murloc, boardWithDeadEntity);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.SisefinBattlegrounds:\r\n\t\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\t\tconst validTargets = boardWithDeadEntity.filter((e) => !e.poisonous);\r\n\t\t\t\tconst murloc2 = getRandomMinion(validTargets, Race.MURLOC, allCards);\r\n\t\t\t\tif (murloc2) {\r\n\t\t\t\t\tmurloc2.poisonous = true;\r\n\t\t\t\t\tspectator.registerPowerTarget(avenger, murloc2, boardWithDeadEntity);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.MechanoTank:\r\n\t\t\t// This can be null if the avenge triggers when the last enemy minion dies as well\r\n\t\t\tconst target = getRandomMinionWithHighestHealth(otherBoard);\r\n\t\t\tspectator.registerPowerTarget(avenger, target, otherBoard);\r\n\t\t\tdealDamageToEnemy(\r\n\t\t\t\ttarget,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tavenger,\r\n\t\t\t\t5,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.MechanoTankBattlegrounds:\r\n\t\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\t\tconst target = getRandomMinionWithHighestHealth(otherBoard);\r\n\t\t\t\tspectator.registerPowerTarget(avenger, target, otherBoard);\r\n\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tavenger,\r\n\t\t\t\t\t5,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tcardsData,\r\n\t\t\t\t\tsharedState,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.TonyTwoTusk:\r\n\t\t\tconst nonGoldenMinions = boardWithDeadEntity\r\n\t\t\t\t.filter((e) => e.entityId !== avenger.entityId)\r\n\t\t\t\t.filter((e) => {\r\n\t\t\t\t\tconst ref = allCards.getCard(e.cardId);\r\n\t\t\t\t\treturn !!ref.battlegroundsPremiumDbfId && !!allCards.getCardFromDbfId(ref.battlegroundsPremiumDbfId).id;\r\n\t\t\t\t});\r\n\t\t\tconst pirate = getRandomMinion(nonGoldenMinions, Race.PIRATE, allCards);\r\n\t\t\tif (pirate) {\r\n\t\t\t\tmakeMinionGolden(pirate, avenger, boardWithDeadEntity, allCards, spectator);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.TonyTwoTuskBattlegrounds:\r\n\t\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\t\tconst nonGoldenMinions = boardWithDeadEntity.filter((e) => {\r\n\t\t\t\t\tconst ref = allCards.getCard(e.cardId);\r\n\t\t\t\t\treturn !!ref.battlegroundsPremiumDbfId;\r\n\t\t\t\t});\r\n\t\t\t\tconst pirate = getRandomMinion(nonGoldenMinions, Race.PIRATE, allCards);\r\n\t\t\t\tif (pirate) {\r\n\t\t\t\t\tmakeMinionGolden(pirate, avenger, boardWithDeadEntity, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t}\r\n\tavenger.avengeCurrent = avenger.avengeDefault;\r\n};\r\n\r\nconst handleHeroAvenge = (\r\n\tdeadEntity: BoardEntity,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tcandidatesEntitiesSpawnedFromAvenge: BoardEntity[],\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n\tallCards: AllCardsService,\r\n) => {\r\n\t// https://twitter.com/LoewenMitchell/status/1491879869457879040\r\n\t// Not affected by Khadgar\r\n\tswitch (boardWithDeadEntityHero?.heroPowerId) {\r\n\t\tcase CardIds.Onyxia_Broodmother:\r\n\t\t\tcandidatesEntitiesSpawnedFromAvenge.push(\r\n\t\t\t\t...spawnEntities(\r\n\t\t\t\t\tCardIds.Onyxia_OnyxianWhelpToken,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tcardsData,\r\n\t\t\t\t\tsharedState,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t),\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t}\r\n\tboardWithDeadEntityHero.avengeCurrent = boardWithDeadEntityHero.avengeDefault;\r\n};\r\n"]}
|
package/dist/utils.js
CHANGED
|
@@ -158,7 +158,7 @@ const makeMinionGolden = (target, source, sourceBoard, allCards, spectator) => {
|
|
|
158
158
|
const refCard = allCards.getCard(target.cardId);
|
|
159
159
|
const goldenCard = allCards.getCardFromDbfId(refCard.battlegroundsPremiumDbfId);
|
|
160
160
|
target.cardId = goldenCard.id;
|
|
161
|
-
target.avengeCurrent = 0;
|
|
161
|
+
target.avengeCurrent = Math.max(0, target.avengeCurrent - 1);
|
|
162
162
|
exports.modifyAttack(target, refCard.attack, sourceBoard, allCards);
|
|
163
163
|
exports.modifyHealth(target, refCard.health, sourceBoard, allCards);
|
|
164
164
|
exports.afterStatsUpdate(target, sourceBoard, allCards);
|
package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,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;AAC5F,CAAC,CAAC;AAFW,QAAA,eAAe,mBAE1B;AAEK,MAAM,mBAAmB,GAAG,CAAC,MAAmB,EAAE,WAA4B,IAAI,EAAU,EAAE;;IACpG,OAAO,MAAM;QACZ,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,IAAI,YAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,CAAC,MAAM,CAAC,MAAM,2CAAG,IAAI,mCAAI,EAAE,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,IACrH,MAAM,CAAC,YACP,IAAI,MAAM,CAAC,KAAK,IAAI,YAAA,MAAM,CAAC,YAAY,0CAAE,MAAM,mCAAI,CAAC,EAAE;QACxD,CAAC,CAAC,IAAI,CAAC;AACT,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds, Race, ReferenceCard } 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 { Spectator } from './simulation/spectator/spectator';\r\n\r\nconst CLEAVE_IDS = [CardIds.CaveHydra, CardIds.CaveHydraBattlegrounds, CardIds.FoeReaper4000, CardIds.FoeReaper4000Battlegrounds];\r\n// Because for some reason, the Taunt keyword is only a referenced tag,\r\n// so we have to know when a taunt minion is spawned (the taunt tag\r\n// is passed in input properly, so it's not an issue there)\r\nconst TAUNT_IDS = [\r\n\tCardIds.YoHoOgre,\r\n\tCardIds.YoHoOgreBattlegrounds,\r\n\tCardIds.SecurityRover_GuardBotToken,\r\n\tCardIds.SecurityRover_GuardBotTokenBattlegrounds,\r\n\tCardIds.MoltenRock,\r\n\tCardIds.MoltenRockBattlegrounds,\r\n\tCardIds.LieutenantGarr,\r\n\tCardIds.LieutenantGarrBattlegrounds,\r\n\tCardIds.GentleDjinni,\r\n\tCardIds.GentleDjinniBattlegrounds,\r\n\tCardIds.AcolyteOfCthun,\r\n\tCardIds.AcolyteOfCthunBattlegrounds,\r\n\tCardIds.RingMatron,\r\n\tCardIds.RingMatronBattlegrounds,\r\n\tCardIds.DynamicDuo,\r\n\tCardIds.DynamicDuoBattlegrounds,\r\n\tCardIds.InsatiableUrzul,\r\n\tCardIds.InsatiableUrzulBattlegrounds,\r\n\tCardIds.MasterOfRealities2,\r\n\tCardIds.MasterOfRealitiesBattlegrounds,\r\n\tCardIds.BrannsEpicEggBattlegrounds1,\r\n\tCardIds.BrannsEpicEggBattlegrounds2,\r\n\tCardIds.KilrekBattlegrounds1,\r\n\tCardIds.KilrekBattlegrounds2,\r\n];\r\nconst ATTACK_IMMEDIATELY_IDS = [\r\n\tCardIds.Scallywag_SkyPirateToken,\r\n\tCardIds.Scallywag_SkyPirateTokenBattlegrounds,\r\n\tCardIds.Onyxia_OnyxianWhelpToken,\r\n];\r\nexport const MEGA_WINDFURY_IDS = [\r\n\tCardIds.ZappSlywickBattlegrounds,\r\n\tCardIds.CracklingCycloneBattlegrounds,\r\n\tCardIds.BristlebackKnight2,\r\n\tCardIds.BonkerBattlegrounds,\r\n];\r\nconst CANT_ATTACK_IDS = [CardIds.ArcaneCannonBattlegrounds];\r\n\r\nexport const buildSingleBoardEntity = (\r\n\tcardId: string,\r\n\tcontrollerHero: BgsPlayerEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tfriendly: boolean,\r\n\tentityId = 1,\r\n\tspawnReborn = false,\r\n\tcardsData: CardsData,\r\n\tspectator: Spectator,\r\n): BoardEntity => {\r\n\tconst card = allCards.getCard(cardId);\r\n\tconst megaWindfury = MEGA_WINDFURY_IDS.indexOf(cardId as CardIds) !== -1;\r\n\tconst attackImmediately = ATTACK_IMMEDIATELY_IDS.indexOf(cardId as CardIds) !== -1;\r\n\tconst newEntity = addImpliedMechanics({\r\n\t\tattack: card.attack,\r\n\t\tattacksPerformed: 0,\r\n\t\tcardId: cardId,\r\n\t\tdivineShield: hasMechanic(card, 'DIVINE_SHIELD'),\r\n\t\tentityId: entityId,\r\n\t\thealth: card.health,\r\n\t\tmaxHealth: card.health,\r\n\t\ttaunt: hasMechanic(card, 'TAUNT') || TAUNT_IDS.includes(cardId as CardIds),\r\n\t\treborn: hasMechanic(card, 'REBORN'),\r\n\t\tpoisonous: hasMechanic(card, 'POISONOUS'),\r\n\t\twindfury: !megaWindfury && (hasMechanic(card, 'WINDFURY') || card.referencedTags?.includes('WINDFURY')),\r\n\t\tmegaWindfury: megaWindfury,\r\n\t\tenchantments: [],\r\n\t\tfriendly: friendly,\r\n\t\tattackImmediately: attackImmediately,\r\n\t\tavengeCurrent: cardsData.avengeValue(cardId),\r\n\t\tavengeDefault: cardsData.avengeValue(cardId),\r\n\t} as BoardEntity);\r\n\r\n\tif (spawnReborn) {\r\n\t\tnewEntity.health = 1;\r\n\t\tnewEntity.reborn = false;\r\n\t}\r\n\r\n\tif (controllerHero?.heroPowerId === CardIds.SproutItOutBattlegrounds) {\r\n\t\tnewEntity.taunt = true;\r\n\t\tmodifyAttack(newEntity, 1, friendlyBoard, allCards);\r\n\t\tmodifyHealth(newEntity, 2, friendlyBoard, allCards);\r\n\t\tafterStatsUpdate(newEntity, friendlyBoard, allCards);\r\n\t\t// spectator && spectator.registerPowerTarget(result, result, friendlyBoard);\r\n\t} else if (controllerHero?.heroPowerId === CardIds.KurtrusAshfallen_CloseThePortal) {\r\n\t\tmodifyAttack(newEntity, 2, friendlyBoard, allCards);\r\n\t\tmodifyHealth(newEntity, 2, friendlyBoard, allCards);\r\n\t\tafterStatsUpdate(newEntity, friendlyBoard, allCards);\r\n\t\t// spectator && spectator.registerPowerTarget(result, result, friendlyBoard);\r\n\t}\r\n\r\n\tif (allCards.getCard(cardId).techLevel === controllerHero.tavernTier) {\r\n\t\tconst statsBonus =\r\n\t\t\t4 * friendlyBoard.filter((e) => e.cardId === CardIds.BabyYshaarjBattlegrounds1).length +\r\n\t\t\t8 * friendlyBoard.filter((e) => e.cardId === CardIds.BabyYshaarjBattlegrounds2).length;\r\n\t\tmodifyAttack(newEntity, statsBonus, friendlyBoard, allCards);\r\n\t\tmodifyHealth(newEntity, statsBonus, friendlyBoard, allCards);\r\n\t\tafterStatsUpdate(newEntity, friendlyBoard, allCards);\r\n\t}\r\n\r\n\tif (newEntity.taunt) {\r\n\t\tconst statsBonus =\r\n\t\t\t2 * friendlyBoard.filter((e) => e.cardId === CardIds.WanderingTreantBattlegrounds1).length +\r\n\t\t\t4 * friendlyBoard.filter((e) => e.cardId === CardIds.WanderingTreantBattlegrounds2).length;\r\n\t\tmodifyAttack(newEntity, statsBonus, friendlyBoard, allCards);\r\n\t\tmodifyHealth(newEntity, statsBonus, friendlyBoard, allCards);\r\n\t\tafterStatsUpdate(newEntity, friendlyBoard, allCards);\r\n\t}\r\n\r\n\treturn newEntity;\r\n};\r\n\r\nexport const modifyAttack = (entity: BoardEntity, amount: number, friendlyBoard: BoardEntity[], allCards: AllCardsService): void => {\r\n\t// console.log('modifying attack', amount, stringifySimpleCard(entity, allCards), entity.attack);\r\n\tentity.attack = Math.max(0, entity.attack + amount);\r\n\t// console.log('modified attack', amount, stringifySimpleCard(entity, allCards), entity.attack);\r\n\tentity.previousAttack = entity.attack;\r\n\tif (isCorrectTribe(allCards.getCard(entity.cardId).race, Race.DRAGON)) {\r\n\t\tconst whelpSmugglers = friendlyBoard.filter((e) => e.cardId === CardIds.WhelpSmuggler);\r\n\t\tconst whelpSmugglersBattlegrounds = friendlyBoard.filter((e) => e.cardId === CardIds.WhelpSmugglerBattlegrounds);\r\n\t\twhelpSmugglers.forEach((smuggler) => {\r\n\t\t\tmodifyHealth(entity, 1, friendlyBoard, allCards);\r\n\t\t});\r\n\t\twhelpSmugglersBattlegrounds.forEach((smuggler) => {\r\n\t\t\tmodifyHealth(entity, 2, friendlyBoard, allCards);\r\n\t\t});\r\n\t}\r\n\tif (entity.cardId === CardIds.Menagerist_AmalgamTokenBattlegrounds || entity.cardId === CardIds.CuddlgamBattlegrounds) {\r\n\t\tconst mishmashes = friendlyBoard.filter(\r\n\t\t\t(e) => e.cardId === CardIds.MishmashBattlegrounds1 || e.cardId === CardIds.MishmashBattlegrounds2,\r\n\t\t);\r\n\t\tmishmashes.forEach((mishmash) => {\r\n\t\t\tmodifyAttack(mishmash, (mishmash.cardId === CardIds.MishmashBattlegrounds2 ? 2 : 1) * amount, friendlyBoard, allCards);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const modifyHealth = (entity: BoardEntity, amount: number, friendlyBoard: BoardEntity[], allCards: AllCardsService): void => {\r\n\tentity.health += amount;\r\n\tif (amount > 0) {\r\n\t\tentity.maxHealth += amount;\r\n\t}\r\n\tif (entity.cardId === CardIds.Menagerist_AmalgamTokenBattlegrounds || entity.cardId === CardIds.CuddlgamBattlegrounds) {\r\n\t\tconst mishmashes = friendlyBoard.filter(\r\n\t\t\t(e) => e.cardId === CardIds.MishmashBattlegrounds1 || e.cardId === CardIds.MishmashBattlegrounds2,\r\n\t\t);\r\n\t\tmishmashes.forEach((mishmash) => {\r\n\t\t\tmodifyHealth(mishmash, (mishmash.cardId === CardIds.MishmashBattlegrounds2 ? 2 : 1) * amount, friendlyBoard, allCards);\r\n\t\t});\r\n\t}\r\n\r\n\tconst titanicGuardians = friendlyBoard\r\n\t\t.filter((e) => e.entityId !== entity.entityId)\r\n\t\t.filter((e) => e.cardId === CardIds.TitanicGuardianBattlegrounds1 || e.cardId === CardIds.TitanicGuardianBattlegrounds2);\r\n\ttitanicGuardians.forEach((guardian) => {\r\n\t\tmodifyHealth(guardian, (guardian.cardId === CardIds.TitanicGuardianBattlegrounds2 ? 2 : 1) * amount, friendlyBoard, allCards);\r\n\t});\r\n};\r\n\r\nexport const afterStatsUpdate = (entity: BoardEntity, friendlyBoard: BoardEntity[], allCards: AllCardsService): void => {\r\n\tif (hasCorrectTribe(entity, Race.ELEMENTAL, allCards)) {\r\n\t\tconst masterOfRealities = friendlyBoard.filter(\r\n\t\t\t(e) => e.cardId === CardIds.MasterOfRealities2 || e.cardId === CardIds.MasterOfRealitiesBattlegrounds,\r\n\t\t);\r\n\t\tmasterOfRealities.forEach((master) => {\r\n\t\t\tmodifyAttack(master, master.cardId === CardIds.MasterOfRealitiesBattlegrounds ? 2 : 1, friendlyBoard, allCards);\r\n\t\t\tmodifyHealth(master, master.cardId === CardIds.MasterOfRealitiesBattlegrounds ? 2 : 1, friendlyBoard, allCards);\r\n\t\t});\r\n\t}\r\n\tconst tentaclesOfCthun = friendlyBoard\r\n\t\t.filter((e) => e.entityId !== entity.entityId)\r\n\t\t.filter((e) => e.cardId === CardIds.TentacleOfCthunBattlegrounds1 || e.cardId === CardIds.TentacleOfCthunBattlegrounds2);\r\n\ttentaclesOfCthun.forEach((tentacle) => {\r\n\t\tmodifyAttack(tentacle, tentacle.cardId === CardIds.TentacleOfCthunBattlegrounds2 ? 2 : 1, friendlyBoard, allCards);\r\n\t\tmodifyHealth(tentacle, tentacle.cardId === CardIds.TentacleOfCthunBattlegrounds2 ? 2 : 1, friendlyBoard, allCards);\r\n\t});\r\n};\r\n\r\nexport const makeMinionGolden = (\r\n\ttarget: BoardEntity,\r\n\tsource: BoardEntity,\r\n\tsourceBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst refCard = allCards.getCard(target.cardId);\r\n\tconst goldenCard = allCards.getCardFromDbfId(refCard.battlegroundsPremiumDbfId);\r\n\ttarget.cardId = goldenCard.id;\r\n\ttarget.avengeCurrent = 0;\r\n\tmodifyAttack(target, refCard.attack, sourceBoard, allCards);\r\n\tmodifyHealth(target, refCard.health, sourceBoard, allCards);\r\n\tafterStatsUpdate(target, sourceBoard, allCards);\r\n\tspectator.registerPowerTarget(source, target, sourceBoard);\r\n};\r\n\r\nexport const grantRandomAttack = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tadditionalAttack: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (board.length > 0) {\r\n\t\tconst target = board[Math.floor(Math.random() * board.length)];\r\n\t\tmodifyAttack(target, additionalAttack, board, allCards);\r\n\t\tafterStatsUpdate(target, board, allCards);\r\n\t\tspectator.registerPowerTarget(source, target, board);\r\n\t}\r\n};\r\n\r\nexport const grantRandomHealth = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thealth: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\texcludeSource = false,\r\n): void => {\r\n\tconst candidateBoard = board.filter((e) => !excludeSource || e.entityId !== source.entityId);\r\n\tif (candidateBoard.length > 0) {\r\n\t\tconst target = candidateBoard[Math.floor(Math.random() * candidateBoard.length)];\r\n\t\tmodifyHealth(target, health, board, allCards);\r\n\t\tafterStatsUpdate(target, board, allCards);\r\n\t\tspectator.registerPowerTarget(source, target, board);\r\n\t}\r\n};\r\n\r\nexport const grantRandomStats = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tattack: number,\r\n\thealth: number,\r\n\trace: Race,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): BoardEntity => {\r\n\tif (board.length > 0) {\r\n\t\tconst validBeast: BoardEntity = getRandomMinion(board, race, allCards);\r\n\t\tif (validBeast) {\r\n\t\t\tmodifyAttack(validBeast, attack, board, allCards);\r\n\t\t\tmodifyHealth(validBeast, health, board, allCards);\r\n\t\t\tafterStatsUpdate(validBeast, board, allCards);\r\n\t\t\tspectator.registerPowerTarget(source, validBeast, board);\r\n\t\t\treturn validBeast;\r\n\t\t}\r\n\t}\r\n\treturn null;\r\n};\r\n\r\nexport const addCardsInHand = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tcards: number,\r\n\tboard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tcardAdded: CardIds = null,\r\n): void => {\r\n\tconst sages = board.filter((e) => e.cardId === CardIds.DeathsHeadSage);\r\n\tconst sagesGolden = board.filter((e) => e.cardId === CardIds.DeathsHeadSageBattlegrounds);\r\n\tconst multiplier = 1 + (cardAdded === CardIds.BloodGem ? sages.length + 2 * sagesGolden.length : 0);\r\n\tplayerEntity.cardsInHand = Math.min(10, (playerEntity.cardsInHand ?? 0) + multiplier * cards);\r\n\r\n\tconst peggys = board.filter((e) => e.cardId === CardIds.PeggyBrittlebone || e.cardId === CardIds.PeggyBrittleboneBattlegrounds);\r\n\tpeggys.forEach((peggy) => {\r\n\t\tconst pirate = getRandomMinion(\r\n\t\t\tboard.filter((e) => e.entityId !== peggy.entityId),\r\n\t\t\tRace.PIRATE,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t\tif (pirate) {\r\n\t\t\tmodifyAttack(pirate, peggy.cardId === CardIds.PeggyBrittleboneBattlegrounds ? 2 : 1, board, allCards);\r\n\t\t\tmodifyHealth(pirate, peggy.cardId === CardIds.PeggyBrittleboneBattlegrounds ? 2 : 1, board, allCards);\r\n\t\t\tafterStatsUpdate(pirate, board, allCards);\r\n\t\t\tspectator.registerPowerTarget(peggy, pirate, board);\r\n\t\t}\r\n\t});\r\n};\r\n\r\nexport const grantRandomDivineShield = (source: BoardEntity, board: BoardEntity[], spectator: Spectator): void => {\r\n\tconst elligibleEntities = board.filter((entity) => !entity.divineShield);\r\n\tif (elligibleEntities.length > 0) {\r\n\t\tconst chosen = elligibleEntities[Math.floor(Math.random() * elligibleEntities.length)];\r\n\t\tchosen.divineShield = true;\r\n\t\tspectator.registerPowerTarget(source, chosen, board);\r\n\t}\r\n\t// return board;\r\n};\r\n\r\nexport const grantAllDivineShield = (board: BoardEntity[], tribe: string, cards: AllCardsService): void => {\r\n\tconst elligibleEntities = board\r\n\t\t.filter((entity) => !entity.divineShield)\r\n\t\t.filter((entity) => isCorrectTribe(cards.getCard(entity.cardId).race, getRaceEnum(tribe)));\r\n\tfor (const entity of elligibleEntities) {\r\n\t\tentity.divineShield = true;\r\n\t}\r\n\t// return board;\r\n};\r\n\r\nexport const getRandomMinion = (board: BoardEntity[], race: Race, allCards: AllCardsService): BoardEntity => {\r\n\tconst validTribes = board.filter((e) => !race || isCorrectTribe(allCards.getCard(e.cardId).race, race));\r\n\tif (!validTribes.length) {\r\n\t\treturn null;\r\n\t}\r\n\treturn validTribes[Math.floor(Math.random() * validTribes.length)];\r\n};\r\n\r\nexport const getRandomMinionWithHighestHealth = (board: BoardEntity[]): BoardEntity => {\r\n\tif (!board.length) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tconst highestHealth = Math.max(...board.map((e) => e.health));\r\n\tconst validMinions = board.filter((e) => e.health === highestHealth);\r\n\treturn validMinions[Math.floor(Math.random() * validMinions.length)];\r\n};\r\n\r\nexport const addStatsToBoard = (\r\n\tsourceEntity: BoardEntity | BgsPlayerEntity,\r\n\tboard: BoardEntity[],\r\n\tattack: number,\r\n\thealth: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\ttribe?: string,\r\n): void => {\r\n\tfor (const entity of board) {\r\n\t\tif (!tribe || isCorrectTribe(allCards.getCard(entity.cardId).race, Race[tribe])) {\r\n\t\t\tmodifyAttack(entity, attack, board, allCards);\r\n\t\t\tmodifyHealth(entity, health, board, allCards);\r\n\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\tspectator.registerPowerTarget(sourceEntity, entity, board);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const hasMechanic = (card: ReferenceCard, mechanic: string): boolean => {\r\n\treturn card.mechanics?.includes(mechanic);\r\n};\r\n\r\nexport const hasCorrectTribe = (entity: BoardEntity, targetTribe: Race, allCards: AllCardsService): boolean => {\r\n\treturn isCorrectTribe(allCards.getCard(entity.cardId).race, targetTribe);\r\n};\r\n\r\nexport const isCorrectTribe = (cardRace: string, targetTribe: Race): boolean => {\r\n\treturn getRaceEnum(cardRace) === Race.ALL || getRaceEnum(cardRace) === targetTribe;\r\n};\r\n\r\nexport const getRaceEnum = (race: string): Race => {\r\n\treturn Race[race];\r\n};\r\n\r\nexport const addImpliedMechanics = (entity: BoardEntity): BoardEntity => {\r\n\tconst cleave = CLEAVE_IDS.indexOf(entity.cardId as CardIds) !== -1;\r\n\tconst cantAttack = CANT_ATTACK_IDS.indexOf(entity.cardId as CardIds) !== -1;\r\n\t// Avoid creating a new object if not necessary\r\n\tif (!cleave && !cantAttack) {\r\n\t\treturn entity;\r\n\t}\r\n\treturn {\r\n\t\t...entity,\r\n\t\tcleave: cleave,\r\n\t\tcantAttack: cantAttack,\r\n\t} as BoardEntity;\r\n};\r\n\r\nexport const stringifySimple = (board: readonly BoardEntity[], allCards: AllCardsService = null): string => {\r\n\treturn '[' + board.map((entity) => stringifySimpleCard(entity, allCards)).join(', ') + ']';\r\n};\r\n\r\nexport const stringifySimpleCard = (entity: BoardEntity, allCards: AllCardsService = null): string => {\r\n\treturn entity\r\n\t\t? `${entity.cardId}/${allCards?.getCard(entity.cardId)?.name ?? ''}/${entity.attack}/${entity.health}/${entity.entityId}/${\r\n\t\t\t\tentity.divineShield\r\n\t\t }/${entity.taunt}/${entity.enchantments?.length ?? 0}`\r\n\t\t: null;\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AACA,iEAA6F;AAM7F,MAAM,UAAU,GAAG,6DAA8G,CAAC;AAIlI,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;CAyBjB,CAAC;AACF,MAAM,sBAAsB,GAAG;;;;CAI9B,CAAC;AACW,QAAA,iBAAiB,GAAG;;;;;CAKhC,CAAC;AACF,MAAM,eAAe,GAAG,mBAAmC,CAAC;AAErD,MAAM,sBAAsB,GAAG,CACrC,MAAc,EACd,cAA+B,EAC/B,aAA4B,EAC5B,QAAyB,EACzB,QAAiB,EACjB,QAAQ,GAAG,CA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I,MAAM,CAAC,QAAQ,IACrH,MAAM,CAAC,YACP,IAAI,MAAM,CAAC,KAAK,IAAI,YAAA,MAAM,CAAC,YAAY,0CAAE,MAAM,mCAAI,CAAC,EAAE;QACxD,CAAC,CAAC,IAAI,CAAC;AACT,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds, Race, ReferenceCard } 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 { Spectator } from './simulation/spectator/spectator';\r\n\r\nconst CLEAVE_IDS = [CardIds.CaveHydra, CardIds.CaveHydraBattlegrounds, CardIds.FoeReaper4000, CardIds.FoeReaper4000Battlegrounds];\r\n// Because for some reason, the Taunt keyword is only a referenced tag,\r\n// so we have to know when a taunt minion is spawned (the taunt tag\r\n// is passed in input properly, so it's not an issue there)\r\nconst TAUNT_IDS = [\r\n\tCardIds.YoHoOgre,\r\n\tCardIds.YoHoOgreBattlegrounds,\r\n\tCardIds.SecurityRover_GuardBotToken,\r\n\tCardIds.SecurityRover_GuardBotTokenBattlegrounds,\r\n\tCardIds.MoltenRock,\r\n\tCardIds.MoltenRockBattlegrounds,\r\n\tCardIds.LieutenantGarr,\r\n\tCardIds.LieutenantGarrBattlegrounds,\r\n\tCardIds.GentleDjinni,\r\n\tCardIds.GentleDjinniBattlegrounds,\r\n\tCardIds.AcolyteOfCthun,\r\n\tCardIds.AcolyteOfCthunBattlegrounds,\r\n\tCardIds.RingMatron,\r\n\tCardIds.RingMatronBattlegrounds,\r\n\tCardIds.DynamicDuo,\r\n\tCardIds.DynamicDuoBattlegrounds,\r\n\tCardIds.InsatiableUrzul,\r\n\tCardIds.InsatiableUrzulBattlegrounds,\r\n\tCardIds.MasterOfRealities2,\r\n\tCardIds.MasterOfRealitiesBattlegrounds,\r\n\tCardIds.BrannsEpicEggBattlegrounds1,\r\n\tCardIds.BrannsEpicEggBattlegrounds2,\r\n\tCardIds.KilrekBattlegrounds1,\r\n\tCardIds.KilrekBattlegrounds2,\r\n];\r\nconst ATTACK_IMMEDIATELY_IDS = [\r\n\tCardIds.Scallywag_SkyPirateToken,\r\n\tCardIds.Scallywag_SkyPirateTokenBattlegrounds,\r\n\tCardIds.Onyxia_OnyxianWhelpToken,\r\n];\r\nexport const MEGA_WINDFURY_IDS = [\r\n\tCardIds.ZappSlywickBattlegrounds,\r\n\tCardIds.CracklingCycloneBattlegrounds,\r\n\tCardIds.BristlebackKnight2,\r\n\tCardIds.BonkerBattlegrounds,\r\n];\r\nconst CANT_ATTACK_IDS = [CardIds.ArcaneCannonBattlegrounds];\r\n\r\nexport const buildSingleBoardEntity = (\r\n\tcardId: string,\r\n\tcontrollerHero: BgsPlayerEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tfriendly: boolean,\r\n\tentityId = 1,\r\n\tspawnReborn = false,\r\n\tcardsData: CardsData,\r\n\tspectator: Spectator,\r\n): BoardEntity => {\r\n\tconst card = allCards.getCard(cardId);\r\n\tconst megaWindfury = MEGA_WINDFURY_IDS.indexOf(cardId as CardIds) !== -1;\r\n\tconst attackImmediately = ATTACK_IMMEDIATELY_IDS.indexOf(cardId as CardIds) !== -1;\r\n\tconst newEntity = addImpliedMechanics({\r\n\t\tattack: card.attack,\r\n\t\tattacksPerformed: 0,\r\n\t\tcardId: cardId,\r\n\t\tdivineShield: hasMechanic(card, 'DIVINE_SHIELD'),\r\n\t\tentityId: entityId,\r\n\t\thealth: card.health,\r\n\t\tmaxHealth: card.health,\r\n\t\ttaunt: hasMechanic(card, 'TAUNT') || TAUNT_IDS.includes(cardId as CardIds),\r\n\t\treborn: hasMechanic(card, 'REBORN'),\r\n\t\tpoisonous: hasMechanic(card, 'POISONOUS'),\r\n\t\twindfury: !megaWindfury && (hasMechanic(card, 'WINDFURY') || card.referencedTags?.includes('WINDFURY')),\r\n\t\tmegaWindfury: megaWindfury,\r\n\t\tenchantments: [],\r\n\t\tfriendly: friendly,\r\n\t\tattackImmediately: attackImmediately,\r\n\t\tavengeCurrent: cardsData.avengeValue(cardId),\r\n\t\tavengeDefault: cardsData.avengeValue(cardId),\r\n\t} as BoardEntity);\r\n\r\n\tif (spawnReborn) {\r\n\t\tnewEntity.health = 1;\r\n\t\tnewEntity.reborn = false;\r\n\t}\r\n\r\n\tif (controllerHero?.heroPowerId === CardIds.SproutItOutBattlegrounds) {\r\n\t\tnewEntity.taunt = true;\r\n\t\tmodifyAttack(newEntity, 1, friendlyBoard, allCards);\r\n\t\tmodifyHealth(newEntity, 2, friendlyBoard, allCards);\r\n\t\tafterStatsUpdate(newEntity, friendlyBoard, allCards);\r\n\t\t// spectator && spectator.registerPowerTarget(result, result, friendlyBoard);\r\n\t} else if (controllerHero?.heroPowerId === CardIds.KurtrusAshfallen_CloseThePortal) {\r\n\t\tmodifyAttack(newEntity, 2, friendlyBoard, allCards);\r\n\t\tmodifyHealth(newEntity, 2, friendlyBoard, allCards);\r\n\t\tafterStatsUpdate(newEntity, friendlyBoard, allCards);\r\n\t\t// spectator && spectator.registerPowerTarget(result, result, friendlyBoard);\r\n\t}\r\n\r\n\tif (allCards.getCard(cardId).techLevel === controllerHero.tavernTier) {\r\n\t\tconst statsBonus =\r\n\t\t\t4 * friendlyBoard.filter((e) => e.cardId === CardIds.BabyYshaarjBattlegrounds1).length +\r\n\t\t\t8 * friendlyBoard.filter((e) => e.cardId === CardIds.BabyYshaarjBattlegrounds2).length;\r\n\t\tmodifyAttack(newEntity, statsBonus, friendlyBoard, allCards);\r\n\t\tmodifyHealth(newEntity, statsBonus, friendlyBoard, allCards);\r\n\t\tafterStatsUpdate(newEntity, friendlyBoard, allCards);\r\n\t}\r\n\r\n\tif (newEntity.taunt) {\r\n\t\tconst statsBonus =\r\n\t\t\t2 * friendlyBoard.filter((e) => e.cardId === CardIds.WanderingTreantBattlegrounds1).length +\r\n\t\t\t4 * friendlyBoard.filter((e) => e.cardId === CardIds.WanderingTreantBattlegrounds2).length;\r\n\t\tmodifyAttack(newEntity, statsBonus, friendlyBoard, allCards);\r\n\t\tmodifyHealth(newEntity, statsBonus, friendlyBoard, allCards);\r\n\t\tafterStatsUpdate(newEntity, friendlyBoard, allCards);\r\n\t}\r\n\r\n\treturn newEntity;\r\n};\r\n\r\nexport const modifyAttack = (entity: BoardEntity, amount: number, friendlyBoard: BoardEntity[], allCards: AllCardsService): void => {\r\n\t// console.log('modifying attack', amount, stringifySimpleCard(entity, allCards), entity.attack);\r\n\tentity.attack = Math.max(0, entity.attack + amount);\r\n\t// console.log('modified attack', amount, stringifySimpleCard(entity, allCards), entity.attack);\r\n\tentity.previousAttack = entity.attack;\r\n\tif (isCorrectTribe(allCards.getCard(entity.cardId).race, Race.DRAGON)) {\r\n\t\tconst whelpSmugglers = friendlyBoard.filter((e) => e.cardId === CardIds.WhelpSmuggler);\r\n\t\tconst whelpSmugglersBattlegrounds = friendlyBoard.filter((e) => e.cardId === CardIds.WhelpSmugglerBattlegrounds);\r\n\t\twhelpSmugglers.forEach((smuggler) => {\r\n\t\t\tmodifyHealth(entity, 1, friendlyBoard, allCards);\r\n\t\t});\r\n\t\twhelpSmugglersBattlegrounds.forEach((smuggler) => {\r\n\t\t\tmodifyHealth(entity, 2, friendlyBoard, allCards);\r\n\t\t});\r\n\t}\r\n\tif (entity.cardId === CardIds.Menagerist_AmalgamTokenBattlegrounds || entity.cardId === CardIds.CuddlgamBattlegrounds) {\r\n\t\tconst mishmashes = friendlyBoard.filter(\r\n\t\t\t(e) => e.cardId === CardIds.MishmashBattlegrounds1 || e.cardId === CardIds.MishmashBattlegrounds2,\r\n\t\t);\r\n\t\tmishmashes.forEach((mishmash) => {\r\n\t\t\tmodifyAttack(mishmash, (mishmash.cardId === CardIds.MishmashBattlegrounds2 ? 2 : 1) * amount, friendlyBoard, allCards);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const modifyHealth = (entity: BoardEntity, amount: number, friendlyBoard: BoardEntity[], allCards: AllCardsService): void => {\r\n\tentity.health += amount;\r\n\tif (amount > 0) {\r\n\t\tentity.maxHealth += amount;\r\n\t}\r\n\tif (entity.cardId === CardIds.Menagerist_AmalgamTokenBattlegrounds || entity.cardId === CardIds.CuddlgamBattlegrounds) {\r\n\t\tconst mishmashes = friendlyBoard.filter(\r\n\t\t\t(e) => e.cardId === CardIds.MishmashBattlegrounds1 || e.cardId === CardIds.MishmashBattlegrounds2,\r\n\t\t);\r\n\t\tmishmashes.forEach((mishmash) => {\r\n\t\t\tmodifyHealth(mishmash, (mishmash.cardId === CardIds.MishmashBattlegrounds2 ? 2 : 1) * amount, friendlyBoard, allCards);\r\n\t\t});\r\n\t}\r\n\r\n\tconst titanicGuardians = friendlyBoard\r\n\t\t.filter((e) => e.entityId !== entity.entityId)\r\n\t\t.filter((e) => e.cardId === CardIds.TitanicGuardianBattlegrounds1 || e.cardId === CardIds.TitanicGuardianBattlegrounds2);\r\n\ttitanicGuardians.forEach((guardian) => {\r\n\t\tmodifyHealth(guardian, (guardian.cardId === CardIds.TitanicGuardianBattlegrounds2 ? 2 : 1) * amount, friendlyBoard, allCards);\r\n\t});\r\n};\r\n\r\nexport const afterStatsUpdate = (entity: BoardEntity, friendlyBoard: BoardEntity[], allCards: AllCardsService): void => {\r\n\tif (hasCorrectTribe(entity, Race.ELEMENTAL, allCards)) {\r\n\t\tconst masterOfRealities = friendlyBoard.filter(\r\n\t\t\t(e) => e.cardId === CardIds.MasterOfRealities2 || e.cardId === CardIds.MasterOfRealitiesBattlegrounds,\r\n\t\t);\r\n\t\tmasterOfRealities.forEach((master) => {\r\n\t\t\tmodifyAttack(master, master.cardId === CardIds.MasterOfRealitiesBattlegrounds ? 2 : 1, friendlyBoard, allCards);\r\n\t\t\tmodifyHealth(master, master.cardId === CardIds.MasterOfRealitiesBattlegrounds ? 2 : 1, friendlyBoard, allCards);\r\n\t\t});\r\n\t}\r\n\tconst tentaclesOfCthun = friendlyBoard\r\n\t\t.filter((e) => e.entityId !== entity.entityId)\r\n\t\t.filter((e) => e.cardId === CardIds.TentacleOfCthunBattlegrounds1 || e.cardId === CardIds.TentacleOfCthunBattlegrounds2);\r\n\ttentaclesOfCthun.forEach((tentacle) => {\r\n\t\tmodifyAttack(tentacle, tentacle.cardId === CardIds.TentacleOfCthunBattlegrounds2 ? 2 : 1, friendlyBoard, allCards);\r\n\t\tmodifyHealth(tentacle, tentacle.cardId === CardIds.TentacleOfCthunBattlegrounds2 ? 2 : 1, friendlyBoard, allCards);\r\n\t});\r\n};\r\n\r\nexport const makeMinionGolden = (\r\n\ttarget: BoardEntity,\r\n\tsource: BoardEntity,\r\n\tsourceBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst refCard = allCards.getCard(target.cardId);\r\n\tconst goldenCard = allCards.getCardFromDbfId(refCard.battlegroundsPremiumDbfId);\r\n\ttarget.cardId = goldenCard.id;\r\n\t// A minion becoming golden ignore the current death.\r\n\t// This way of handling it is not ideal, since it will still trigger if both avenges trigger at the same time, but\r\n\t// should solve the other cases\r\n\ttarget.avengeCurrent = Math.max(0, target.avengeCurrent - 1);\r\n\tmodifyAttack(target, refCard.attack, sourceBoard, allCards);\r\n\tmodifyHealth(target, refCard.health, sourceBoard, allCards);\r\n\tafterStatsUpdate(target, sourceBoard, allCards);\r\n\tspectator.registerPowerTarget(source, target, sourceBoard);\r\n};\r\n\r\nexport const grantRandomAttack = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tadditionalAttack: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (board.length > 0) {\r\n\t\tconst target = board[Math.floor(Math.random() * board.length)];\r\n\t\tmodifyAttack(target, additionalAttack, board, allCards);\r\n\t\tafterStatsUpdate(target, board, allCards);\r\n\t\tspectator.registerPowerTarget(source, target, board);\r\n\t}\r\n};\r\n\r\nexport const grantRandomHealth = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thealth: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\texcludeSource = false,\r\n): void => {\r\n\tconst candidateBoard = board.filter((e) => !excludeSource || e.entityId !== source.entityId);\r\n\tif (candidateBoard.length > 0) {\r\n\t\tconst target = candidateBoard[Math.floor(Math.random() * candidateBoard.length)];\r\n\t\tmodifyHealth(target, health, board, allCards);\r\n\t\tafterStatsUpdate(target, board, allCards);\r\n\t\tspectator.registerPowerTarget(source, target, board);\r\n\t}\r\n};\r\n\r\nexport const grantRandomStats = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tattack: number,\r\n\thealth: number,\r\n\trace: Race,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): BoardEntity => {\r\n\tif (board.length > 0) {\r\n\t\tconst validBeast: BoardEntity = getRandomMinion(board, race, allCards);\r\n\t\tif (validBeast) {\r\n\t\t\tmodifyAttack(validBeast, attack, board, allCards);\r\n\t\t\tmodifyHealth(validBeast, health, board, allCards);\r\n\t\t\tafterStatsUpdate(validBeast, board, allCards);\r\n\t\t\tspectator.registerPowerTarget(source, validBeast, board);\r\n\t\t\treturn validBeast;\r\n\t\t}\r\n\t}\r\n\treturn null;\r\n};\r\n\r\nexport const addCardsInHand = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tcards: number,\r\n\tboard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tcardAdded: CardIds = null,\r\n): void => {\r\n\tconst sages = board.filter((e) => e.cardId === CardIds.DeathsHeadSage);\r\n\tconst sagesGolden = board.filter((e) => e.cardId === CardIds.DeathsHeadSageBattlegrounds);\r\n\tconst multiplier = 1 + (cardAdded === CardIds.BloodGem ? sages.length + 2 * sagesGolden.length : 0);\r\n\tplayerEntity.cardsInHand = Math.min(10, (playerEntity.cardsInHand ?? 0) + multiplier * cards);\r\n\r\n\tconst peggys = board.filter((e) => e.cardId === CardIds.PeggyBrittlebone || e.cardId === CardIds.PeggyBrittleboneBattlegrounds);\r\n\tpeggys.forEach((peggy) => {\r\n\t\tconst pirate = getRandomMinion(\r\n\t\t\tboard.filter((e) => e.entityId !== peggy.entityId),\r\n\t\t\tRace.PIRATE,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t\tif (pirate) {\r\n\t\t\tmodifyAttack(pirate, peggy.cardId === CardIds.PeggyBrittleboneBattlegrounds ? 2 : 1, board, allCards);\r\n\t\t\tmodifyHealth(pirate, peggy.cardId === CardIds.PeggyBrittleboneBattlegrounds ? 2 : 1, board, allCards);\r\n\t\t\tafterStatsUpdate(pirate, board, allCards);\r\n\t\t\tspectator.registerPowerTarget(peggy, pirate, board);\r\n\t\t}\r\n\t});\r\n};\r\n\r\nexport const grantRandomDivineShield = (source: BoardEntity, board: BoardEntity[], spectator: Spectator): void => {\r\n\tconst elligibleEntities = board.filter((entity) => !entity.divineShield);\r\n\tif (elligibleEntities.length > 0) {\r\n\t\tconst chosen = elligibleEntities[Math.floor(Math.random() * elligibleEntities.length)];\r\n\t\tchosen.divineShield = true;\r\n\t\tspectator.registerPowerTarget(source, chosen, board);\r\n\t}\r\n\t// return board;\r\n};\r\n\r\nexport const grantAllDivineShield = (board: BoardEntity[], tribe: string, cards: AllCardsService): void => {\r\n\tconst elligibleEntities = board\r\n\t\t.filter((entity) => !entity.divineShield)\r\n\t\t.filter((entity) => isCorrectTribe(cards.getCard(entity.cardId).race, getRaceEnum(tribe)));\r\n\tfor (const entity of elligibleEntities) {\r\n\t\tentity.divineShield = true;\r\n\t}\r\n\t// return board;\r\n};\r\n\r\nexport const getRandomMinion = (board: BoardEntity[], race: Race, allCards: AllCardsService): BoardEntity => {\r\n\tconst validTribes = board.filter((e) => !race || isCorrectTribe(allCards.getCard(e.cardId).race, race));\r\n\tif (!validTribes.length) {\r\n\t\treturn null;\r\n\t}\r\n\treturn validTribes[Math.floor(Math.random() * validTribes.length)];\r\n};\r\n\r\nexport const getRandomMinionWithHighestHealth = (board: BoardEntity[]): BoardEntity => {\r\n\tif (!board.length) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tconst highestHealth = Math.max(...board.map((e) => e.health));\r\n\tconst validMinions = board.filter((e) => e.health === highestHealth);\r\n\treturn validMinions[Math.floor(Math.random() * validMinions.length)];\r\n};\r\n\r\nexport const addStatsToBoard = (\r\n\tsourceEntity: BoardEntity | BgsPlayerEntity,\r\n\tboard: BoardEntity[],\r\n\tattack: number,\r\n\thealth: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\ttribe?: string,\r\n): void => {\r\n\tfor (const entity of board) {\r\n\t\tif (!tribe || isCorrectTribe(allCards.getCard(entity.cardId).race, Race[tribe])) {\r\n\t\t\tmodifyAttack(entity, attack, board, allCards);\r\n\t\t\tmodifyHealth(entity, health, board, allCards);\r\n\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\tspectator.registerPowerTarget(sourceEntity, entity, board);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const hasMechanic = (card: ReferenceCard, mechanic: string): boolean => {\r\n\treturn card.mechanics?.includes(mechanic);\r\n};\r\n\r\nexport const hasCorrectTribe = (entity: BoardEntity, targetTribe: Race, allCards: AllCardsService): boolean => {\r\n\treturn isCorrectTribe(allCards.getCard(entity.cardId).race, targetTribe);\r\n};\r\n\r\nexport const isCorrectTribe = (cardRace: string, targetTribe: Race): boolean => {\r\n\treturn getRaceEnum(cardRace) === Race.ALL || getRaceEnum(cardRace) === targetTribe;\r\n};\r\n\r\nexport const getRaceEnum = (race: string): Race => {\r\n\treturn Race[race];\r\n};\r\n\r\nexport const addImpliedMechanics = (entity: BoardEntity): BoardEntity => {\r\n\tconst cleave = CLEAVE_IDS.indexOf(entity.cardId as CardIds) !== -1;\r\n\tconst cantAttack = CANT_ATTACK_IDS.indexOf(entity.cardId as CardIds) !== -1;\r\n\t// Avoid creating a new object if not necessary\r\n\tif (!cleave && !cantAttack) {\r\n\t\treturn entity;\r\n\t}\r\n\treturn {\r\n\t\t...entity,\r\n\t\tcleave: cleave,\r\n\t\tcantAttack: cantAttack,\r\n\t} as BoardEntity;\r\n};\r\n\r\nexport const stringifySimple = (board: readonly BoardEntity[], allCards: AllCardsService = null): string => {\r\n\treturn '[' + board.map((entity) => stringifySimpleCard(entity, allCards)).join(', ') + ']';\r\n};\r\n\r\nexport const stringifySimpleCard = (entity: BoardEntity, allCards: AllCardsService = null): string => {\r\n\treturn entity\r\n\t\t? `${entity.cardId}/${allCards?.getCard(entity.cardId)?.name ?? ''}/${entity.attack}/${entity.health}/${entity.entityId}/${\r\n\t\t\t\tentity.divineShield\r\n\t\t }/${entity.taunt}/${entity.enchantments?.length ?? 0}`\r\n\t\t: null;\r\n};\r\n"]}
|