@firestone-hs/simulate-bgs-battle 1.1.129 → 1.1.133
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/cards/cards-data.js +1 -2
- package/dist/cards/cards-data.js.map +1 -1
- package/dist/simulation/attack.js +2 -2
- package/dist/simulation/attack.js.map +1 -1
- package/dist/simulation/deathrattle-effects.js +8 -2
- package/dist/simulation/deathrattle-effects.js.map +1 -1
- package/dist/simulation/frenzy.js.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +2 -2
package/dist/cards/cards-data.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cards-data.js","sourceRoot":"","sources":["../../src/cards/cards-data.ts"],"names":[],"mappings":";;;AAAA,iEAAkH;AAClH,6CAAgE;AAChE,oCAAoD;AAEpD,MAAa,SAAS;IAgBrB,YAA6B,QAAyB,EAAE,IAAI,GAAG,IAAI;QAAtC,aAAQ,GAAR,QAAQ,CAAiB;QACrD,IAAI,IAAI,EAAE;YACT,IAAI,CAAC,YAAY,EAAE,CAAC;SACpB;IACF,CAAC;IAEM,YAAY,CAAC,WAA6B;QAChD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ;aACxB,QAAQ,EAAE;aACV,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,oCAAmB,CAAC,IAAI,CAAC,CAAC;aAC3C,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;aAClC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC;QAC3C,IAAI,CAAC,cAAc,GAAG,uBAAe,CAAC,CAAC,IAAmB,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,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AAkB;QAIrD,OAAO,kBAAU,CAAC,IAAI,CAAC,cAAc,CAAC,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5D,CAAC;IAEO,QAAQ,CAAC,IAAmB;QACnC,OAAO,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC;IACxC,CAAC;IAEO,YAAY,CAAC,WAA4B,EAAE,IAAY;QAC9D,MAAM,QAAQ,GAAS,mBAAW,CAAC,IAAI,CAAC,CAAC;QACzC,OAAO,QAAQ,KAAK,qBAAI,CAAC,GAAG,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,IAAI,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC5G,CAAC;CACD;AA3HD,8BA2HC","sourcesContent":["import { AllCardsService, CardIds, isBattlegroundsCard, Race, ReferenceCard } from '@firestone-hs/reference-data';\r\nimport { groupByFunction, pickRandom } from '../services/utils';\r\nimport { getRaceEnum, hasMechanic } from '../utils';\r\n\r\nexport class CardsData {\r\n\t// public shredderSpawns: readonly string[];\r\n\tpublic ghastcoilerSpawns: readonly string[];\r\n\tpublic validDeathrattles: readonly string[];\r\n\tpublic impMamaSpawns: readonly string[];\r\n\tpublic gentleDjinniSpawns: readonly string[];\r\n\t// public sneedsSpawns: readonly string[];\r\n\t// public treasureChestSpawns: readonly string[];\r\n\tpublic pirateSpawns: readonly string[];\r\n\r\n\tpublic auraEnchantments: readonly string[][];\r\n\tpublic auraOrigins: readonly string[];\r\n\tpublic startOfCombats: readonly string[];\r\n\r\n\tprivate minionsForTier: { [key: string]: readonly ReferenceCard[] };\r\n\r\n\tconstructor(private readonly allCards: AllCardsService, init = true) {\r\n\t\tif (init) {\r\n\t\t\tthis.inititialize();\r\n\t\t}\r\n\t}\r\n\r\n\tpublic inititialize(validTribes?: readonly Race[]): void {\r\n\t\tconst pool = this.allCards\r\n\t\t\t.getCards()\r\n\t\t\t.filter((card) => isBattlegroundsCard(card))\r\n\t\t\t.filter((card) => !!card.techLevel)\r\n\t\t\t.filter((card) => card.set !== 'Vanilla');\r\n\t\tthis.minionsForTier = groupByFunction((card: ReferenceCard) => card.techLevel)(pool.filter((card) => !this.isGolden(card)));\r\n\t\tthis.ghastcoilerSpawns = pool\r\n\t\t\t.filter((card) => !this.isGolden(card))\r\n\t\t\t.filter((card) => card.id !== 'BGS_008')\r\n\t\t\t.filter((card) => hasMechanic(card, 'DEATHRATTLE'))\r\n\t\t\t// .filter((card) => REMOVED_CARD_IDS.indexOf(card.id) === -1)\r\n\t\t\t.filter((card) => this.isValidTribe(validTribes, card.race))\r\n\t\t\t.map((card) => card.id);\r\n\t\tthis.validDeathrattles = pool\r\n\t\t\t// .filter((card) => !card.id.startsWith('TB_BaconUps')) // Ignore golden\r\n\t\t\t.filter((card) => hasMechanic(card, 'DEATHRATTLE'))\r\n\t\t\t// .filter((card) => REMOVED_CARD_IDS.indexOf(card.id) === -1)\r\n\t\t\t.filter((card) => this.isValidTribe(validTribes, card.race))\r\n\t\t\t.map((card) => card.id);\r\n\t\tthis.impMamaSpawns = pool\r\n\t\t\t.filter((card) => !this.isGolden(card))\r\n\t\t\t.filter((card) => card.race === 'DEMON')\r\n\t\t\t.filter((card) => card.id !== CardIds.ImpMama)\r\n\t\t\t// .filter((card) => REMOVED_CARD_IDS.indexOf(card.id) === -1)\r\n\t\t\t.map((card) => card.id);\r\n\t\tthis.gentleDjinniSpawns = pool\r\n\t\t\t.filter((card) => !this.isGolden(card))\r\n\t\t\t.filter((card) => card.race === 'ELEMENTAL')\r\n\t\t\t.filter((card) => card.id !== CardIds.GentleDjinni)\r\n\t\t\t// .filter((card) => REMOVED_CARD_IDS.indexOf(card.id) === -1)\r\n\t\t\t.map((card) => card.id);\r\n\t\tthis.pirateSpawns = pool\r\n\t\t\t.filter((card) => !this.isGolden(card))\r\n\t\t\t.filter((card) => card.race === 'PIRATE')\r\n\t\t\t// .filter((card) => REMOVED_CARD_IDS.indexOf(card.id) === -1)\r\n\t\t\t.map((card) => card.id);\r\n\t\t// Auras are effects that are permanent (unlike deathrattles or \"whenever\" effects)\r\n\t\t// and that stop once the origin entity leaves play (so it doesn't include buffs)\r\n\t\tthis.auraEnchantments = [\r\n\t\t\t[CardIds.Kathranatir2, CardIds.Kathranatir_GraspOfKathranatirEnchantment1],\r\n\t\t\t[CardIds.KathranatirBattlegrounds, CardIds.Kathranatir_GraspOfKathranatirEnchantment2],\r\n\t\t\t[CardIds.MurlocWarleaderLegacy, CardIds.MurlocWarleader_MrgglaarglLegacyEnchantment],\r\n\t\t\t[CardIds.MurlocWarleaderBattlegrounds, CardIds.MurlocWarleader_MrgglaarglEnchantmentBattlegrounds],\r\n\t\t\t[CardIds.SouthseaCaptainLegacy, CardIds.SouthseaCaptain_YarrrLegacyEnchantment],\r\n\t\t\t[CardIds.SouthseaCaptainBattlegrounds, CardIds.SouthseaCaptain_YarrrEnchantmentBattlegrounds],\r\n\t\t];\r\n\t\tthis.auraOrigins = this.auraEnchantments.map((pair) => pair[0]);\r\n\t\tthis.startOfCombats = [\r\n\t\t\tCardIds.RedWhelp,\r\n\t\t\tCardIds.RedWhelpBattlegrounds,\r\n\t\t\tCardIds.PrizedPromoDrake,\r\n\t\t\tCardIds.PrizedPromoDrakeBattlegrounds,\r\n\t\t];\r\n\t}\r\n\r\n\tpublic avengeValue(cardId: string): number {\r\n\t\tswitch (cardId) {\r\n\t\t\tcase CardIds.BirdBuddy:\r\n\t\t\tcase CardIds.BirdBuddyBattlegrounds:\r\n\t\t\t\treturn 1;\r\n\t\t\tcase CardIds.PalescaleCrocolisk:\r\n\t\t\tcase CardIds.PalescaleCrocoliskBattlegrounds:\r\n\t\t\tcase CardIds.MechanoTank:\r\n\t\t\tcase CardIds.MechanoTankBattlegrounds:\r\n\t\t\t\treturn 2;\r\n\t\t\tcase CardIds.Sisefin:\r\n\t\t\tcase CardIds.SisefinBattlegrounds:\r\n\t\t\tcase CardIds.BuddingGreenthumb:\r\n\t\t\tcase CardIds.BuddingGreenthumbBattlegrounds:\r\n\t\t\t\treturn 3;\r\n\t\t\tcase CardIds.ImpatientDoomsayer:\r\n\t\t\tcase CardIds.ImpatientDoomsayerBattlegrounds:\r\n\t\t\tcase CardIds.WitchwingNestmatron:\r\n\t\t\tcase CardIds.WitchwingNestmatronBattlegrounds:\r\n\t\t\tcase CardIds.TonyTwoTusk:\r\n\t\t\tcase CardIds.TonyTwoTuskBattlegrounds:\r\n\t\t\t\treturn 4;\r\n\t\t}\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tpublic getTavernLevel(cardId: string): number {\r\n\t\treturn this.allCards.getCard(cardId).techLevel;\r\n\t}\r\n\r\n\tpublic getRandomMinionForTavernTier(tavernTier: number): string {\r\n\t\t// Tzvern tier can be undefined for hero-power specific tokens, like the Amalgam, or when\r\n\t\t// for some reason tokens end up in the shop. For now, defaulting to 1 for tavern\r\n\t\t// level seems to work in all cases\r\n\t\treturn pickRandom(this.minionsForTier[tavernTier ?? 1]).id;\r\n\t}\r\n\r\n\tprivate isGolden(card: ReferenceCard): boolean {\r\n\t\treturn !!card.battlegroundsNormalDbfId;\r\n\t}\r\n\r\n\tprivate isValidTribe(validTribes: readonly Race[], race: string): boolean {\r\n\t\tconst raceEnum: Race = getRaceEnum(race);\r\n\t\treturn raceEnum === Race.ALL || !validTribes || validTribes.length === 0 || validTribes.includes(raceEnum);\r\n\t}\r\n}\r\n"]}
|
|
@@ -255,12 +255,12 @@ const bumpEntities = (entity, bumpInto, entityBoard, entityBoardHero, otherBoard
|
|
|
255
255
|
const greaseBots = entityBoard.filter((entity) => entity.cardId === "BG21_024");
|
|
256
256
|
const greaseBotBattlegrounds = entityBoard.filter((entity) => entity.cardId === "BG21_024_G");
|
|
257
257
|
greaseBots.forEach((bot) => {
|
|
258
|
-
utils_2.modifyAttack(entity,
|
|
258
|
+
utils_2.modifyAttack(entity, 1, entityBoard, allCards);
|
|
259
259
|
utils_2.modifyHealth(entity, 1);
|
|
260
260
|
spectator.registerPowerTarget(bot, entity, entityBoard);
|
|
261
261
|
});
|
|
262
262
|
greaseBotBattlegrounds.forEach((bot) => {
|
|
263
|
-
utils_2.modifyAttack(entity,
|
|
263
|
+
utils_2.modifyAttack(entity, 2, entityBoard, allCards);
|
|
264
264
|
utils_2.modifyHealth(entity, 2);
|
|
265
265
|
spectator.registerPowerTarget(bot, entity, entityBoard);
|
|
266
266
|
});
|
|
@@ -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,oCAAsH;AACtH,mCAAkD;AAClD,+DAA+H;AAC/H,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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACrE,kBAAU,CAAC,cAAc,EAAE,yBAA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} 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 { afterStatsUpdate, hasCorrectTribe, hasMechanic, isCorrectTribe, modifyAttack, modifyHealth } from '../utils';\r\nimport { applyAuras, removeAuras } from './auras';\r\nimport { addCardsInHand, applyMinionDeathEffect, 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\tapplyAuras(attackingBoard, numberOfDeathwingPresents, spawns, allCards);\r\n\tapplyAuras(defendingBoard, numberOfDeathwingPresents, spawns, allCards);\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// 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}\r\n\t\tattackingEntity.attacking = false;\r\n\t}\r\n\tremoveAuras(attackingBoard, spawns);\r\n\tremoveAuras(defendingBoard, spawns);\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);\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\tspawns: 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\tspawns,\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// For Prestor\r\n\tconst defenderAliveBeforeAttack = defendingEntity.health > 0 && !defendingEntity.definitelyDead;\r\n\tif (defenderAliveBeforeAttack) {\r\n\t\tbumpEntities(\r\n\t\t\tattackingEntity,\r\n\t\t\tdefendingEntity,\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\tspawns,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\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\tspawns,\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\tspawns,\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\tspawns,\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\tspawns,\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, spawns, sharedState, spectator);\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};\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\tif (lastAttackerIndex != null) {\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): void => {\r\n\t// console.log('dealing damage to', damage, stringifySimpleCard(defendingEntity, allCards));\r\n\tif (!defendingEntity) {\r\n\t\treturn;\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\tbumpEntities(\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\t// processMinionDeath(\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};\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): void => {\r\n\t// No attack has no impact\r\n\tif (bumpInto.attack === 0) {\r\n\t\treturn;\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);\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);\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);\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.GemsplitterBattlegrounds) {\r\n\t\t\t\taddCardsInHand(entityBoardHero, 2, entityBoard, allCards, spectator);\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, 2, entityBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 1);\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, 4, entityBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 2);\r\n\t\t\tspectator.registerPowerTarget(bot, entity, entityBoard);\r\n\t\t});\r\n\t\treturn;\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;\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\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\tsharedState.deaths.push(...deadEntities1);\r\n\tsharedState.deaths.push(...deadEntities2);\r\n\r\n\tif (Math.random() > 0.5) {\r\n\t\t// Now proceed to trigger all deathrattle effects on baord1\r\n\t\thandleDeathsForFirstBoard(\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\thandleDeathsForFirstBoard(\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\thandleDeathsForFirstBoard(\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\thandleDeathsForFirstBoard(\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\r\nconst handleDeathsForFirstBoard = (\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\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);\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);\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);\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);\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);\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);\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);\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);\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\nconst 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);\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);\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// console.log('buildBoardAfterDeathrattleSpawns', deadMinionIndex, stringifySimple(boardWithKilledMinion, allCards));\r\n\t// TODO: don't apply this for FishOfNZoth\r\n\tif (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// 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\t1,\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\nconst performEntitySpawns = (\r\n\tcandidateEntities: readonly BoardEntity[],\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 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 - deadMinionIndex;\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(deadEntity, boardWithKilledMinion, spawnedEntities);\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"attack.js","sourceRoot":"","sources":["../../src/simulation/attack.ts"],"names":[],"mappings":";;;AACA,iEAA8E;AAI9E,6CAA+C;AAC/C,gEAA2D;AAC3D,oCAAsH;AACtH,mCAAkD;AAClD,+DAA+H;AAC/H,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,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AAM,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,UAAU,EAAE,qBAAqB,EAAE,eAAe,CAAC,CAAC;AACpF,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 '../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 { afterStatsUpdate, hasCorrectTribe, hasMechanic, isCorrectTribe, modifyAttack, modifyHealth } from '../utils';\r\nimport { applyAuras, removeAuras } from './auras';\r\nimport { addCardsInHand, applyMinionDeathEffect, 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\tapplyAuras(attackingBoard, numberOfDeathwingPresents, spawns, allCards);\r\n\tapplyAuras(defendingBoard, numberOfDeathwingPresents, spawns, allCards);\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// 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}\r\n\t\tattackingEntity.attacking = false;\r\n\t}\r\n\tremoveAuras(attackingBoard, spawns);\r\n\tremoveAuras(defendingBoard, spawns);\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);\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\tspawns: 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\tspawns,\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// For Prestor\r\n\tconst defenderAliveBeforeAttack = defendingEntity.health > 0 && !defendingEntity.definitelyDead;\r\n\tif (defenderAliveBeforeAttack) {\r\n\t\tbumpEntities(\r\n\t\t\tattackingEntity,\r\n\t\t\tdefendingEntity,\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\tspawns,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\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\tspawns,\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\tspawns,\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\tspawns,\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\tspawns,\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, spawns, sharedState, spectator);\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};\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\tif (lastAttackerIndex != null) {\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): void => {\r\n\t// console.log('dealing damage to', damage, stringifySimpleCard(defendingEntity, allCards));\r\n\tif (!defendingEntity) {\r\n\t\treturn;\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\tbumpEntities(\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\t// processMinionDeath(\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};\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): void => {\r\n\t// No attack has no impact\r\n\tif (bumpInto.attack === 0) {\r\n\t\treturn;\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);\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);\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);\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.GemsplitterBattlegrounds) {\r\n\t\t\t\taddCardsInHand(entityBoardHero, 2, entityBoard, allCards, spectator);\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);\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);\r\n\t\t\tspectator.registerPowerTarget(bot, entity, entityBoard);\r\n\t\t});\r\n\t\treturn;\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;\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\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\tsharedState.deaths.push(...deadEntities1);\r\n\tsharedState.deaths.push(...deadEntities2);\r\n\r\n\tif (Math.random() > 0.5) {\r\n\t\t// Now proceed to trigger all deathrattle effects on baord1\r\n\t\thandleDeathsForFirstBoard(\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\thandleDeathsForFirstBoard(\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\thandleDeathsForFirstBoard(\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\thandleDeathsForFirstBoard(\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\r\nconst handleDeathsForFirstBoard = (\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\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);\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);\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);\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);\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);\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);\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);\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);\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\nconst 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);\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);\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// console.log('buildBoardAfterDeathrattleSpawns', deadMinionIndex, stringifySimple(boardWithKilledMinion, allCards));\r\n\t// TODO: don't apply this for FishOfNZoth\r\n\tif (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// 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\t1,\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\nconst performEntitySpawns = (\r\n\tcandidateEntities: readonly BoardEntity[],\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 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 - deadMinionIndex;\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(deadEntity, boardWithKilledMinion, spawnedEntities);\r\n};\r\n"]}
|
|
@@ -331,6 +331,12 @@ const handleAvenge = (boardWithDeadEntity, boardWithDeadEntityHero, avenger, oth
|
|
|
331
331
|
case "BG21_038_G":
|
|
332
332
|
exports.addCardsInHand(boardWithDeadEntityHero, 2, boardWithDeadEntity, allCards, spectator);
|
|
333
333
|
break;
|
|
334
|
+
case "BG20_105":
|
|
335
|
+
exports.addCardsInHand(boardWithDeadEntityHero, 1, boardWithDeadEntity, allCards, spectator);
|
|
336
|
+
break;
|
|
337
|
+
case "BG20_105_G":
|
|
338
|
+
exports.addCardsInHand(boardWithDeadEntityHero, 2, boardWithDeadEntity, allCards, spectator);
|
|
339
|
+
break;
|
|
334
340
|
case "BG21_009":
|
|
335
341
|
const murloc = getRandomMinion(boardWithDeadEntity, reference_data_1.Race.MURLOC, allCards);
|
|
336
342
|
if (murloc) {
|
|
@@ -350,13 +356,13 @@ const handleAvenge = (boardWithDeadEntity, boardWithDeadEntityHero, avenger, oth
|
|
|
350
356
|
case "BG21_023":
|
|
351
357
|
const target = getRandomMinionWithHighestHealth(otherBoard);
|
|
352
358
|
spectator.registerPowerTarget(avenger, target, otherBoard);
|
|
353
|
-
attack_1.dealDamageToEnemy(target, otherBoard, otherBoardHero, avenger,
|
|
359
|
+
attack_1.dealDamageToEnemy(target, otherBoard, otherBoardHero, avenger, 5, boardWithDeadEntity, boardWithDeadEntityHero, allCards, cardsData, sharedState, spectator);
|
|
354
360
|
break;
|
|
355
361
|
case "BG21_023_G":
|
|
356
362
|
for (let i = 0; i < 2; i++) {
|
|
357
363
|
const target = getRandomMinionWithHighestHealth(otherBoard);
|
|
358
364
|
spectator.registerPowerTarget(avenger, target, otherBoard);
|
|
359
|
-
attack_1.dealDamageToEnemy(target, otherBoard, otherBoardHero, avenger,
|
|
365
|
+
attack_1.dealDamageToEnemy(target, otherBoard, otherBoardHero, avenger, 5, boardWithDeadEntity, boardWithDeadEntityHero, allCards, cardsData, sharedState, spectator);
|
|
360
366
|
}
|
|
361
367
|
break;
|
|
362
368
|
case "BG21_031":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deathrattle-effects.js","sourceRoot":"","sources":["../../src/simulation/deathrattle-effects.ts"],"names":[],"mappings":";;;AACA,iEAA8E;AAI9E,6CAAoD;AACpD,oCAAsH;AACtH,qCAAmG;AACnG,mCAA0D;AAC1D,6DAAqD;AAI9C,MAAM,wBAAwB,GAA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AAE,GAAG,CAAC,IAAI,CAAC,sBAAsB,IAAI,EAAE,CAAC,CAAC,CAAC;KAC3F;AAEF,CAAC,CAAC;AA5BW,QAAA,oBAAoB,wBA4B/B;AAEF,MAAM,sBAAsB,GAAG,CAAC,mBAAkC,EAAE,QAAyB,EAAE,EAAE;IAChG,MAAM,QAAQ,GAAG,mBAAmB,CAAC,MAAM,CAC1C,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,cAA6B,IAAI,MAAM,CAAC,MAAM,kBAA8B,CACrG,CAAC;IACF,MAAM,cAAc,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,sBAAoC,CAAC,CAAC;IACjH,QAAQ,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QAC3B,oBAAY,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC;QACxD,wBAAgB,CAAC,MAAM,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IACH,cAAc,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QACjC,oBAAY,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC;QACxD,wBAAgB,CAAC,MAAM,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACJ,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 '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardsData } from '../cards/cards-data';\r\nimport { groupByFunction } from '../services/utils';\r\nimport { afterStatsUpdate, getRaceEnum, hasCorrectTribe, isCorrectTribe, modifyAttack, modifyHealth } from '../utils';\r\nimport { bumpEntities, dealDamageToEnemy, dealDamageToRandomEnemy, getNeighbours } from './attack';\r\nimport { removeAurasAfterAuraSourceDeath } from './auras';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { SharedState } from './shared-state';\r\nimport { Spectator } from './spectator/spectator';\r\n\r\nexport const handleDeathrattleEffects = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\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 rivendare = boardWithDeadEntity.find((entity) => entity.cardId === CardIds.BaronRivendare2);\r\n\tconst goldenRivendare = boardWithDeadEntity.find((entity) => entity.cardId === CardIds.BaronRivendareBattlegrounds);\r\n\tconst multiplier = goldenRivendare ? 3 : rivendare ? 2 : 1;\r\n\t// We do it on a case by case basis so that we deal all the damage in one go for instance\r\n\t// and avoid proccing deathrattle spawns between the times the damage triggers\r\n\tswitch (deadEntity.cardId) {\r\n\t\tcase CardIds.SelflessHero:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tgrantRandomDivineShield(deadEntity, boardWithDeadEntity, spectator);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.SelflessHeroBattlegrounds:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tgrantRandomDivineShield(deadEntity, boardWithDeadEntity, spectator);\r\n\t\t\t\tgrantRandomDivineShield(deadEntity, boardWithDeadEntity, spectator);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.NadinaTheRed:\r\n\t\tcase CardIds.NadinaTheRedBattlegrounds:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tgrantAllDivineShield(boardWithDeadEntity, 'DRAGON', allCards);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.SpawnOfNzoth:\r\n\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, multiplier * 1, multiplier * 1, allCards, spectator);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.SpawnOfNzothBattlegrounds:\r\n\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, multiplier * 2, multiplier * 2, allCards, spectator);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.GoldrinnTheGreatWolf:\r\n\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, multiplier * 5, multiplier * 5, allCards, spectator, 'BEAST');\r\n\t\t\tbreak;\r\n\t\tcase CardIds.GoldrinnTheGreatWolfBattlegrounds:\r\n\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, multiplier * 10, multiplier * 10, allCards, spectator, 'BEAST');\r\n\t\t\tbreak;\r\n\t\tcase CardIds.KingBagurgle:\r\n\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, multiplier * 2, multiplier * 2, allCards, spectator, 'MURLOC');\r\n\t\t\tbreak;\r\n\t\tcase CardIds.KingBagurgleBattlegrounds:\r\n\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, multiplier * 4, multiplier * 4, allCards, spectator, 'MURLOC');\r\n\t\t\tbreak;\r\n\t\tcase CardIds.FiendishServant:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tgrantRandomAttack(deadEntity, boardWithDeadEntity, deadEntity.attack, allCards, spectator);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.FiendishServantBattlegrounds:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tgrantRandomAttack(deadEntity, boardWithDeadEntity, deadEntity.attack, allCards, spectator);\r\n\t\t\t\tgrantRandomAttack(deadEntity, boardWithDeadEntity, deadEntity.attack, allCards, spectator);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ImpulsiveTrickster:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tgrantRandomHealth(deadEntity, boardWithDeadEntity, deadEntity.maxHealth, allCards, spectator, true);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ImpulsiveTricksterBattlegrounds:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tgrantRandomHealth(deadEntity, boardWithDeadEntity, deadEntity.maxHealth, allCards, spectator, true);\r\n\t\t\t\tgrantRandomHealth(deadEntity, boardWithDeadEntity, deadEntity.maxHealth, allCards, spectator, true);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Leapfrogger:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, deadEntity, false, allCards, spectator);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.LeapfroggerBattlegrounds:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, deadEntity, true, allCards, spectator);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PalescaleCrocolisk:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tconst target = grantRandomStats(deadEntity, boardWithDeadEntity, 6, 6, Race.BEAST, allCards, spectator);\r\n\t\t\t\tif (!!target) {\r\n\t\t\t\t\tspectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PalescaleCrocoliskBattlegrounds:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tconst target = grantRandomStats(deadEntity, boardWithDeadEntity, 12, 12, Race.BEAST, allCards, spectator);\r\n\t\t\t\tif (!!target) {\r\n\t\t\t\t\tspectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.LeapfroggerBattlegrounds:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, deadEntity, true, allCards, spectator);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.KaboomBot:\r\n\t\t\t// FIXME: I don't think this way of doing things is really accurate (as some deathrattles\r\n\t\t\t// could be spawned between the shots firing), but let's say it's good enough for now\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tdealDamageToRandomEnemy(\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t4,\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.KaboomBotBattlegrounds:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tdealDamageToRandomEnemy(\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t4,\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\tdealDamageToRandomEnemy(\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t4,\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}\r\n\r\n\t// It's important to first copy the enchantments, otherwise you could end up\r\n\t// in an infinite loop - since new enchants are added after each step\r\n\tlet enchantments: { cardId: string; originEntityId?: number; repeats?: number }[] = [...(deadEntity.enchantments ?? [])];\r\n\tconst threshold = 20;\r\n\tif (enchantments.length > threshold || enchantments.some((e) => e.repeats && e.repeats > 1)) {\r\n\t\t// console.warn(\r\n\t\t// \t'too many enchtments, truncating',\r\n\t\t// \tstringifySimpleCard(deadEntity),\r\n\t\t// \tdeadEntity.enchantments.length,\r\n\t\t// \tdeadEntity.enchantments,\r\n\t\t// );\r\n\t\t// In some cases it's possible that there are way too many enchantments because of the frog\r\n\t\t// In that case, we make a trade-off and don't trigger the \"on stats change\" trigger as\r\n\t\t// often as we should, so that we can have the stats themselves correct\r\n\t\tconst enchantmentGroups = groupByFunction((enchantment: any) => enchantment.cardId)(enchantments);\r\n\t\tenchantments = Object.keys(enchantmentGroups).map((cardId) => ({\r\n\t\t\tcardId: cardId,\r\n\t\t\trepeats: enchantmentGroups[cardId].length,\r\n\t\t}));\r\n\t}\r\n\tfor (const enchantment of enchantments) {\r\n\t\tswitch (enchantment.cardId) {\r\n\t\t\tcase CardIds.Leapfrogger_LeapfrogginEnchantment1:\r\n\t\t\t\tif (!!enchantment.repeats && enchantment.repeats > 1) {\r\n\t\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, deadEntity, false, allCards, spectator, multiplier * enchantment.repeats);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, deadEntity, false, allCards, spectator);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Leapfrogger_LeapfrogginEnchantment2:\r\n\t\t\t\tif (!!enchantment.repeats && enchantment.repeats > 1) {\r\n\t\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, deadEntity, true, allCards, spectator, multiplier * enchantment.repeats);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, deadEntity, true, allCards, spectator);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyLeapFroggerEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tmultiplier = 1,\r\n): void => {\r\n\tmultiplier = multiplier || 1;\r\n\tconst buffed = grantRandomStats(\r\n\t\tdeadEntity,\r\n\t\tboardWithDeadEntity,\r\n\t\tmultiplier * (isPremium ? 2 : 1),\r\n\t\tmultiplier * (isPremium ? 2 : 1),\r\n\t\tRace.BEAST,\r\n\t\tallCards,\r\n\t\tspectator,\r\n\t);\r\n\tif (buffed) {\r\n\t\tbuffed.enchantments = buffed.enchantments ?? [];\r\n\t\tbuffed.enchantments.push({\r\n\t\t\tcardId: isPremium ? CardIds.Leapfrogger_LeapfrogginEnchantment2 : CardIds.Leapfrogger_LeapfrogginEnchantment1,\r\n\t\t\toriginEntityId: deadEntity.entityId,\r\n\t\t\trepeats: multiplier > 1 ? multiplier : undefined,\r\n\t\t});\r\n\t\t// Don't register power effect here, since it's already done in the random stats\r\n\t\t// spectator.registerPowerTarget(deadEntity, buffed, boardWithDeadEntity);\r\n\t\t// console.log('applyLeapFroggerEffect', stringifySimpleCard(deadEntity), stringifySimpleCard(buffed));\r\n\t}\r\n};\r\n\r\nconst 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\nconst 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,\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);\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 applyMinionDeathEffect = (\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\t// console.log('applying minion death effect', stringifySimpleCard(deadEntity, allCards));\r\n\tif (isCorrectTribe(allCards.getCard(deadEntity.cardId).race, Race.BEAST)) {\r\n\t\tapplyScavengingHyenaEffect(boardWithDeadEntity, allCards, spectator);\r\n\t}\r\n\tif (isCorrectTribe(allCards.getCard(deadEntity.cardId).race, Race.DEMON)) {\r\n\t\tapplySoulJugglerEffect(\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\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\tif (isCorrectTribe(allCards.getCard(deadEntity.cardId).race, Race.MECH)) {\r\n\t\tapplyJunkbotEffect(boardWithDeadEntity, allCards, spectator);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, Race.MURLOC, allCards)) {\r\n\t\tremoveOldMurkEyeAttack(boardWithDeadEntity, allCards);\r\n\t\tremoveOldMurkEyeAttack(otherBoard, allCards);\r\n\t}\r\n\r\n\tif (cardsData.auraOrigins.includes(deadEntity.cardId)) {\r\n\t\tremoveAurasAfterAuraSourceDeath(boardWithDeadEntity, deadEntity, cardsData);\r\n\t}\r\n\r\n\tif (deadEntity.taunt) {\r\n\t\t// applyQirajiHarbringerEffect(boardWithDeadEntity, deadEntityIndex, allCards);\r\n\t}\r\n\t// Overkill\r\n\tif (deadEntity.health < 0 && deadEntity.lastAffectedByEntity?.attacking) {\r\n\t\tif (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlame2) {\r\n\t\t\tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t\tif (targets.length > 0) {\r\n\t\t\t\tconst target = targets[0];\r\n\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t\t\t3,\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);\r\n\t\t\t}\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlameBattlegrounds) {\r\n\t\t\tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t\tif (targets.length > 0) {\r\n\t\t\t\tconst target = targets[0];\r\n\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t\t\t6,\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);\r\n\t\t\t}\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental) {\r\n\t\t\t// console.log('applying WildfireElemental effect', stringifySimple(boardWithDeadEntity, allCards));\r\n\t\t\tconst excessDamage = -deadEntity.health;\r\n\t\t\tconst neighbours = getNeighbours(boardWithDeadEntity, null, deadEntityIndex);\r\n\t\t\t// console.log('neighbours', stringifySimple(neighbours, allCards));\r\n\t\t\tif (neighbours.length > 0) {\r\n\t\t\t\tconst randomTarget = neighbours[Math.floor(Math.random() * neighbours.length)];\r\n\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\trandomTarget,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t\texcessDamage,\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);\r\n\t\t\t}\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElementalBattlegrounds) {\r\n\t\t\tconst excessDamage = -deadEntity.health;\r\n\t\t\tconst neighbours = getNeighbours(boardWithDeadEntity, null, deadEntityIndex);\r\n\t\t\tneighbours.forEach((neighbour) =>\r\n\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\tneighbour,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t\texcessDamage,\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),\r\n\t\t\t);\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn) {\r\n\t\t\tconst newEntities = spawnEntities(\r\n\t\t\t\tCardIds.IronhideDirehorn_IronhideRuntToken,\r\n\t\t\t\t1,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\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\t!deadEntity.friendly,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t\totherBoard.splice(deadEntityIndex, 0, ...newEntities);\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehornBattlegrounds) {\r\n\t\t\tconst newEntities = spawnEntities(\r\n\t\t\t\tCardIds.IronhideDirehorn_IronhideRuntTokenBattlegrounds,\r\n\t\t\t\t1,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\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\t!deadEntity.friendly,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t\totherBoard.splice(deadEntityIndex, 0, ...newEntities);\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath2) {\r\n\t\t\tconst otherPirates = otherBoard\r\n\t\t\t\t.filter((entity) => isCorrectTribe(allCards.getCard(entity.cardId).race, Race.PIRATE))\r\n\t\t\t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\totherPirates.forEach((pirate) => {\r\n\t\t\t\tmodifyAttack(pirate, 2, boardWithDeadEntity, allCards);\r\n\t\t\t\tmodifyHealth(pirate, 2);\r\n\t\t\t\tafterStatsUpdate(pirate, boardWithDeadEntity, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(deadEntity.lastAffectedByEntity, pirate, otherBoard);\r\n\t\t\t});\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliathBattlegrounds) {\r\n\t\t\tconst otherPirates = otherBoard\r\n\t\t\t\t.filter((entity) => isCorrectTribe(allCards.getCard(entity.cardId).race, Race.PIRATE))\r\n\t\t\t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\totherPirates.forEach((pirate) => {\r\n\t\t\t\tmodifyAttack(pirate, 4, boardWithDeadEntity, allCards);\r\n\t\t\t\tmodifyHealth(pirate, 4);\r\n\t\t\t\tafterStatsUpdate(pirate, boardWithDeadEntity, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(deadEntity.lastAffectedByEntity, pirate, otherBoard);\r\n\t\t\t});\r\n\t\t}\r\n\t\t// else if (deadEntity.lastAffectedByEntity.cardId === CardIds.NatPagleExtremeAngler) {\r\n\t\t// }\r\n\t}\r\n\r\n\tconst rivendare = boardWithDeadEntity.find((entity) => entity.cardId === CardIds.BaronRivendare2);\r\n\tconst goldenRivendare = boardWithDeadEntity.find((entity) => entity.cardId === CardIds.BaronRivendareBattlegrounds);\r\n\tconst multiplier = goldenRivendare ? 3 : rivendare ? 2 : 1;\r\n\tif (deadEntity.cardId === CardIds.UnstableGhoul) {\r\n\t\tdealDamageToAllMinions(\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tdeadEntity,\r\n\t\t\tmultiplier * 1,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else if (deadEntity.cardId === CardIds.UnstableGhoulBattlegrounds) {\r\n\t\tdealDamageToAllMinions(\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tdeadEntity,\r\n\t\t\tmultiplier * 2,\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// Avenge\r\n\tupdateAvengeCounters(boardWithDeadEntity);\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};\r\n\r\nconst updateAvengeCounters = (board: readonly BoardEntity[]) => {\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};\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);\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.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.Sisefin:\r\n\t\t\tconst murloc = getRandomMinion(boardWithDeadEntity, 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 murloc2 = getRandomMinion(boardWithDeadEntity, 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\t6,\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\t6,\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\tconst refCard = allCards.getCard(pirate.cardId);\r\n\t\t\t\tconst goldenCard = allCards.getCardFromDbfId(refCard.battlegroundsPremiumDbfId);\r\n\t\t\t\tpirate.cardId = goldenCard.id;\r\n\t\t\t\tmodifyAttack(pirate, refCard.attack, boardWithDeadEntity, allCards);\r\n\t\t\t\tmodifyHealth(pirate, refCard.health);\r\n\t\t\t\tafterStatsUpdate(pirate, boardWithDeadEntity, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(avenger, pirate, boardWithDeadEntity);\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\tconst refCard = allCards.getCard(pirate.cardId);\r\n\t\t\t\t\tpirate.cardId = refCard.id;\r\n\t\t\t\t\tmodifyAttack(pirate, refCard.attack, boardWithDeadEntity, allCards);\r\n\t\t\t\t\tmodifyHealth(pirate, refCard.health);\r\n\t\t\t\t\tafterStatsUpdate(pirate, boardWithDeadEntity, allCards);\r\n\t\t\t\t\tspectator.registerPowerTarget(avenger, pirate, boardWithDeadEntity);\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\nexport const dealDamageToAllMinions = (\r\n\tboard1: BoardEntity[],\r\n\tboard1Hero: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tboard2Hero: BgsPlayerEntity,\r\n\tdamageSource: BoardEntity,\r\n\tdamageDealt: number,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (board1.length === 0 && board2.length === 0) {\r\n\t\treturn;\r\n\t\t// return [board1, board2];\r\n\t}\r\n\t// let updatedBoard1 = [...board1];\r\n\t// let updatedBoard2 = [...board2];\r\n\tconst fakeAttacker = {\r\n\t\t...(damageSource || {}),\r\n\t\tentityId: -1,\r\n\t\tattack: damageDealt,\r\n\t\tattacking: true,\r\n\t} as BoardEntity;\r\n\tfor (let i = 0; i < board1.length; i++) {\r\n\t\tbumpEntities(board1[i], fakeAttacker, board1, board1Hero, board2, board2Hero, allCards, cardsData, sharedState, spectator);\r\n\t\t// board1[i] = entity;\r\n\t}\r\n\tfor (let i = 0; i < board2.length; i++) {\r\n\t\tbumpEntities(board2[i], fakeAttacker, board2, board2Hero, board1, board1Hero, allCards, cardsData, sharedState, spectator);\r\n\t\t// updatedBoard2 = [...boardResult];\r\n\t\t// updatedBoard2[i] = entity;\r\n\t}\r\n\t// processMinionDeath(board1, board1Hero, board2, board2Hero, allCards, cardsData, sharedState, spectator);\r\n};\r\n\r\nconst applySoulJugglerEffect = (\r\n\tboardWithJugglers: BoardEntity[],\r\n\tboardWithJugglersHero: BgsPlayerEntity,\r\n\tboardToAttack: BoardEntity[],\r\n\tboardToAttackHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (boardWithJugglers.length === 0 && boardToAttack.length === 0) {\r\n\t\treturn;\r\n\t\t// return [boardWithJugglers, boardToAttack];\r\n\t}\r\n\tconst jugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler);\r\n\tfor (const juggler of jugglers) {\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t3,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\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 goldenJugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJugglerBattlegrounds);\r\n\tfor (const juggler of goldenJugglers) {\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t3,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t3,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\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// processMinionDeath(\r\n\t// \tboardWithJugglers,\r\n\t// \tboardWithJugglersHero,\r\n\t// \tboardToAttack,\r\n\t// \tboardToAttackHero,\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 applyScavengingHyenaEffect = (board: BoardEntity[], allCards: AllCardsService, spectator: Spectator): void => {\r\n\t// const copy = [...board];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.ScavengingHyenaLegacy) {\r\n\t\t\tmodifyAttack(board[i], 2, board, allCards);\r\n\t\t\tmodifyHealth(board[i], 1);\r\n\t\t\tafterStatsUpdate(board[i], board, allCards);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t} else if (board[i].cardId === CardIds.ScavengingHyenaBattlegrounds) {\r\n\t\t\tmodifyAttack(board[i], 4, board, allCards);\r\n\t\t\tmodifyHealth(board[i], 2);\r\n\t\t\tafterStatsUpdate(board[i], board, allCards);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyJunkbotEffect = (board: BoardEntity[], allCards: AllCardsService, spectator: Spectator): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.Junkbot) {\r\n\t\t\tmodifyAttack(board[i], 2, board, allCards);\r\n\t\t\tmodifyHealth(board[i], 2);\r\n\t\t\tafterStatsUpdate(board[i], board, allCards);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t} else if (board[i].cardId === CardIds.JunkbotBattlegrounds) {\r\n\t\t\tmodifyAttack(board[i], 4, board, allCards);\r\n\t\t\tmodifyHealth(board[i], 4);\r\n\t\t\tafterStatsUpdate(board[i], board, allCards);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t}\r\n\t}\r\n};\r\n\r\n// const applyQirajiHarbringerEffect = (board: BoardEntity[], deadEntityIndex: number, allCards: AllCardsService): void => {\r\n// \tconst qiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger);\r\n// \tconst goldenQiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbingerBattlegrounds);\r\n// \tconst neighbours = getNeighbours(board, null, deadEntityIndex);\r\n\r\n// \t// TODO: if reactivated, properly apply buffs one by one, instead of all together\r\n\r\n// \tneighbours.forEach((entity) => {\r\n// \t\tmodifyAttack(entity, 2 * qiraji.length + 4 * goldenQiraji.length, board, allCards);\r\n// \t\tmodifyHealth(entity, 2 * qiraji.length + 4 * goldenQiraji.length);\r\n// \t\tafterStatsUpdate(entity, board, allCards);\r\n// \t});\r\n// };\r\n\r\nconst 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\nconst 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);\r\n\t\tafterStatsUpdate(target, board, allCards);\r\n\t\tspectator.registerPowerTarget(source, target, board);\r\n\t}\r\n};\r\n\r\nconst 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);\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): void => {\r\n\tplayerEntity.cardsInHand = Math.min(10, (playerEntity.cardsInHand ?? 0) + 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);\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\nconst 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\nconst 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 rememberDeathrattles = (fish: BoardEntity, deadEntities: readonly BoardEntity[], cardsData: CardsData): void => {\r\n\tconst validDeathrattles = deadEntities\r\n\t\t.filter((entity) => cardsData.validDeathrattles.includes(entity.cardId))\r\n\t\t.map((entity) => entity.cardId);\r\n\tconst validEnchantments = deadEntities\r\n\t\t.filter((entity) => entity.enchantments?.length)\r\n\t\t.map((entity) => entity.enchantments)\r\n\t\t.reduce((a, b) => a.concat(b), [])\r\n\t\t.map((enchantment) => enchantment.cardId)\r\n\t\t.filter((enchantmentId) =>\r\n\t\t\t[\r\n\t\t\t\tCardIds.ReplicatingMenace_ReplicatingMenaceEnchantment,\r\n\t\t\t\tCardIds.ReplicatingMenace_ReplicatingMenaceEnchantmentBattlegrounds,\r\n\t\t\t\tCardIds.LivingSpores_LivingSporesEnchantment,\r\n\t\t\t\tCardIds.SneedsReplicator_ReplicateEnchantment,\r\n\t\t\t].includes(enchantmentId as CardIds),\r\n\t\t);\r\n\t// console.debug('remembering deathrattles', fish.cardId, stringifySimple(deadEntities), validDeathrattles, validEnchantments);\r\n\tconst newDeathrattles = [...validDeathrattles, ...validEnchantments];\r\n\t// Order is important\r\n\tif (fish.cardId === CardIds.FishOfNzothBattlegrounds) {\r\n\t\t// https://stackoverflow.com/questions/33305152/how-to-duplicate-elements-in-a-js-array\r\n\t\tconst doubleDr = [...validDeathrattles, ...validEnchantments].reduce((res, current) => res.concat([current, current]), []);\r\n\t\tfish.rememberedDeathrattles = [...doubleDr, ...(fish.rememberedDeathrattles || [])];\r\n\t} else {\r\n\t\tfish.rememberedDeathrattles = [...newDeathrattles, ...(fish.rememberedDeathrattles || [])];\r\n\t}\r\n\t// console.debug('remembered dr', fish.rememberedDeathrattles);\r\n};\r\n\r\nconst removeOldMurkEyeAttack = (boardWithDeadEntity: BoardEntity[], allCards: AllCardsService) => {\r\n\tconst murkeyes = boardWithDeadEntity.filter(\r\n\t\t(entity) => entity.cardId === CardIds.OldMurkEyeLegacy || entity.cardId === CardIds.OldMurkEyeVanilla,\r\n\t);\r\n\tconst goldenMurkeyes = boardWithDeadEntity.filter((entity) => entity.cardId === CardIds.OldMurkEyeBattlegrounds);\r\n\tmurkeyes.forEach((entity) => {\r\n\t\tmodifyAttack(entity, -1, boardWithDeadEntity, allCards);\r\n\t\tafterStatsUpdate(entity, boardWithDeadEntity, allCards);\r\n\t});\r\n\tgoldenMurkeyes.forEach((entity) => {\r\n\t\tmodifyAttack(entity, -2, boardWithDeadEntity, allCards);\r\n\t\tafterStatsUpdate(entity, boardWithDeadEntity, allCards);\r\n\t});\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"deathrattle-effects.js","sourceRoot":"","sources":["../../src/simulation/deathrattle-effects.ts"],"names":[],"mappings":";;;AACA,iEAA8E;AAI9E,6CAAoD;AACpD,oCAAsH;AACtH,qCAAmG;AACnG,mCAA0D;AAC1D,6DAAqD;AAI9C,MAAM,wBAAwB,GAAG,CACvC,mBAAkC,EAClC,uBAAwC,EACxC,UAAuB,EACvB,UAAyB,EACzB,cAA+B,EAC/B,QAAyB,EACzB,SAAoB,EACpB,WAAwB,EACxB,SAAoB,EACb,EAAE;;IACT,MAAM,SAAS,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,cAA4B,CAAC,CAAC;IAClG,MAAM,eAAe,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,sBAAwC,CAAC,CAAC;IACpH,MAAM,UAAU,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAG3D,QAAQ,UAAU,CAAC,MAAM,EAAE;QAC1B;YACC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,EAAE;gBACpC,uBAAuB,CAAC,UAAU,EAAE,mBAAmB,EAAE,SAAS,CAAC,CAAC;aACpE;YACD,MAAM;QACP;YACC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,EAAE;gBACpC,uBAAuB,CAAC,UAAU,EAAE,mBAAmB,EAAE,SAAS,CAAC,CAAC;gBACpE,uBAAuB,CAAC,UAAU,EAAE,mBAAmB,EAAE,SAAS,CAAC,CAAC;aACpE;YACD,MAAM;QACP,eAA0B;QAC1B;YACC,KAAK,IAAI,CAAC,GAA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,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC;QACxD,wBAAgB,CAAC,MAAM,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACJ,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 '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardsData } from '../cards/cards-data';\r\nimport { groupByFunction } from '../services/utils';\r\nimport { afterStatsUpdate, getRaceEnum, hasCorrectTribe, isCorrectTribe, modifyAttack, modifyHealth } from '../utils';\r\nimport { bumpEntities, dealDamageToEnemy, dealDamageToRandomEnemy, getNeighbours } from './attack';\r\nimport { removeAurasAfterAuraSourceDeath } from './auras';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { SharedState } from './shared-state';\r\nimport { Spectator } from './spectator/spectator';\r\n\r\nexport const handleDeathrattleEffects = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\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 rivendare = boardWithDeadEntity.find((entity) => entity.cardId === CardIds.BaronRivendare2);\r\n\tconst goldenRivendare = boardWithDeadEntity.find((entity) => entity.cardId === CardIds.BaronRivendareBattlegrounds);\r\n\tconst multiplier = goldenRivendare ? 3 : rivendare ? 2 : 1;\r\n\t// We do it on a case by case basis so that we deal all the damage in one go for instance\r\n\t// and avoid proccing deathrattle spawns between the times the damage triggers\r\n\tswitch (deadEntity.cardId) {\r\n\t\tcase CardIds.SelflessHero:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tgrantRandomDivineShield(deadEntity, boardWithDeadEntity, spectator);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.SelflessHeroBattlegrounds:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tgrantRandomDivineShield(deadEntity, boardWithDeadEntity, spectator);\r\n\t\t\t\tgrantRandomDivineShield(deadEntity, boardWithDeadEntity, spectator);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.NadinaTheRed:\r\n\t\tcase CardIds.NadinaTheRedBattlegrounds:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tgrantAllDivineShield(boardWithDeadEntity, 'DRAGON', allCards);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.SpawnOfNzoth:\r\n\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, multiplier * 1, multiplier * 1, allCards, spectator);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.SpawnOfNzothBattlegrounds:\r\n\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, multiplier * 2, multiplier * 2, allCards, spectator);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.GoldrinnTheGreatWolf:\r\n\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, multiplier * 5, multiplier * 5, allCards, spectator, 'BEAST');\r\n\t\t\tbreak;\r\n\t\tcase CardIds.GoldrinnTheGreatWolfBattlegrounds:\r\n\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, multiplier * 10, multiplier * 10, allCards, spectator, 'BEAST');\r\n\t\t\tbreak;\r\n\t\tcase CardIds.KingBagurgle:\r\n\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, multiplier * 2, multiplier * 2, allCards, spectator, 'MURLOC');\r\n\t\t\tbreak;\r\n\t\tcase CardIds.KingBagurgleBattlegrounds:\r\n\t\t\taddStatsToBoard(deadEntity, boardWithDeadEntity, multiplier * 4, multiplier * 4, allCards, spectator, 'MURLOC');\r\n\t\t\tbreak;\r\n\t\tcase CardIds.FiendishServant:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tgrantRandomAttack(deadEntity, boardWithDeadEntity, deadEntity.attack, allCards, spectator);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.FiendishServantBattlegrounds:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tgrantRandomAttack(deadEntity, boardWithDeadEntity, deadEntity.attack, allCards, spectator);\r\n\t\t\t\tgrantRandomAttack(deadEntity, boardWithDeadEntity, deadEntity.attack, allCards, spectator);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ImpulsiveTrickster:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tgrantRandomHealth(deadEntity, boardWithDeadEntity, deadEntity.maxHealth, allCards, spectator, true);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ImpulsiveTricksterBattlegrounds:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tgrantRandomHealth(deadEntity, boardWithDeadEntity, deadEntity.maxHealth, allCards, spectator, true);\r\n\t\t\t\tgrantRandomHealth(deadEntity, boardWithDeadEntity, deadEntity.maxHealth, allCards, spectator, true);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Leapfrogger:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, deadEntity, false, allCards, spectator);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.LeapfroggerBattlegrounds:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, deadEntity, true, allCards, spectator);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PalescaleCrocolisk:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tconst target = grantRandomStats(deadEntity, boardWithDeadEntity, 6, 6, Race.BEAST, allCards, spectator);\r\n\t\t\t\tif (!!target) {\r\n\t\t\t\t\tspectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PalescaleCrocoliskBattlegrounds:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tconst target = grantRandomStats(deadEntity, boardWithDeadEntity, 12, 12, Race.BEAST, allCards, spectator);\r\n\t\t\t\tif (!!target) {\r\n\t\t\t\t\tspectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.LeapfroggerBattlegrounds:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, deadEntity, true, allCards, spectator);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.KaboomBot:\r\n\t\t\t// FIXME: I don't think this way of doing things is really accurate (as some deathrattles\r\n\t\t\t// could be spawned between the shots firing), but let's say it's good enough for now\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tdealDamageToRandomEnemy(\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t4,\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.KaboomBotBattlegrounds:\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tdealDamageToRandomEnemy(\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t4,\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\tdealDamageToRandomEnemy(\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\t4,\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}\r\n\r\n\t// It's important to first copy the enchantments, otherwise you could end up\r\n\t// in an infinite loop - since new enchants are added after each step\r\n\tlet enchantments: { cardId: string; originEntityId?: number; repeats?: number }[] = [...(deadEntity.enchantments ?? [])];\r\n\tconst threshold = 20;\r\n\tif (enchantments.length > threshold || enchantments.some((e) => e.repeats && e.repeats > 1)) {\r\n\t\t// console.warn(\r\n\t\t// \t'too many enchtments, truncating',\r\n\t\t// \tstringifySimpleCard(deadEntity),\r\n\t\t// \tdeadEntity.enchantments.length,\r\n\t\t// \tdeadEntity.enchantments,\r\n\t\t// );\r\n\t\t// In some cases it's possible that there are way too many enchantments because of the frog\r\n\t\t// In that case, we make a trade-off and don't trigger the \"on stats change\" trigger as\r\n\t\t// often as we should, so that we can have the stats themselves correct\r\n\t\tconst enchantmentGroups = groupByFunction((enchantment: any) => enchantment.cardId)(enchantments);\r\n\t\tenchantments = Object.keys(enchantmentGroups).map((cardId) => ({\r\n\t\t\tcardId: cardId,\r\n\t\t\trepeats: enchantmentGroups[cardId].length,\r\n\t\t}));\r\n\t}\r\n\tfor (const enchantment of enchantments) {\r\n\t\tswitch (enchantment.cardId) {\r\n\t\t\tcase CardIds.Leapfrogger_LeapfrogginEnchantment1:\r\n\t\t\t\tif (!!enchantment.repeats && enchantment.repeats > 1) {\r\n\t\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, deadEntity, false, allCards, spectator, multiplier * enchantment.repeats);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, deadEntity, false, allCards, spectator);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Leapfrogger_LeapfrogginEnchantment2:\r\n\t\t\t\tif (!!enchantment.repeats && enchantment.repeats > 1) {\r\n\t\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, deadEntity, true, allCards, spectator, multiplier * enchantment.repeats);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\t\t\tapplyLeapFroggerEffect(boardWithDeadEntity, deadEntity, true, allCards, spectator);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyLeapFroggerEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tmultiplier = 1,\r\n): void => {\r\n\tmultiplier = multiplier || 1;\r\n\tconst buffed = grantRandomStats(\r\n\t\tdeadEntity,\r\n\t\tboardWithDeadEntity,\r\n\t\tmultiplier * (isPremium ? 2 : 1),\r\n\t\tmultiplier * (isPremium ? 2 : 1),\r\n\t\tRace.BEAST,\r\n\t\tallCards,\r\n\t\tspectator,\r\n\t);\r\n\tif (buffed) {\r\n\t\tbuffed.enchantments = buffed.enchantments ?? [];\r\n\t\tbuffed.enchantments.push({\r\n\t\t\tcardId: isPremium ? CardIds.Leapfrogger_LeapfrogginEnchantment2 : CardIds.Leapfrogger_LeapfrogginEnchantment1,\r\n\t\t\toriginEntityId: deadEntity.entityId,\r\n\t\t\trepeats: multiplier > 1 ? multiplier : undefined,\r\n\t\t});\r\n\t\t// Don't register power effect here, since it's already done in the random stats\r\n\t\t// spectator.registerPowerTarget(deadEntity, buffed, boardWithDeadEntity);\r\n\t\t// console.log('applyLeapFroggerEffect', stringifySimpleCard(deadEntity), stringifySimpleCard(buffed));\r\n\t}\r\n};\r\n\r\nconst 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\nconst 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,\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);\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 applyMinionDeathEffect = (\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\t// console.log('applying minion death effect', stringifySimpleCard(deadEntity, allCards));\r\n\tif (isCorrectTribe(allCards.getCard(deadEntity.cardId).race, Race.BEAST)) {\r\n\t\tapplyScavengingHyenaEffect(boardWithDeadEntity, allCards, spectator);\r\n\t}\r\n\tif (isCorrectTribe(allCards.getCard(deadEntity.cardId).race, Race.DEMON)) {\r\n\t\tapplySoulJugglerEffect(\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\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\tif (isCorrectTribe(allCards.getCard(deadEntity.cardId).race, Race.MECH)) {\r\n\t\tapplyJunkbotEffect(boardWithDeadEntity, allCards, spectator);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, Race.MURLOC, allCards)) {\r\n\t\tremoveOldMurkEyeAttack(boardWithDeadEntity, allCards);\r\n\t\tremoveOldMurkEyeAttack(otherBoard, allCards);\r\n\t}\r\n\r\n\tif (cardsData.auraOrigins.includes(deadEntity.cardId)) {\r\n\t\tremoveAurasAfterAuraSourceDeath(boardWithDeadEntity, deadEntity, cardsData);\r\n\t}\r\n\r\n\tif (deadEntity.taunt) {\r\n\t\t// applyQirajiHarbringerEffect(boardWithDeadEntity, deadEntityIndex, allCards);\r\n\t}\r\n\t// Overkill\r\n\tif (deadEntity.health < 0 && deadEntity.lastAffectedByEntity?.attacking) {\r\n\t\tif (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlame2) {\r\n\t\t\tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t\tif (targets.length > 0) {\r\n\t\t\t\tconst target = targets[0];\r\n\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t\t\t3,\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);\r\n\t\t\t}\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlameBattlegrounds) {\r\n\t\t\tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t\tif (targets.length > 0) {\r\n\t\t\t\tconst target = targets[0];\r\n\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t\t\t6,\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);\r\n\t\t\t}\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental) {\r\n\t\t\t// console.log('applying WildfireElemental effect', stringifySimple(boardWithDeadEntity, allCards));\r\n\t\t\tconst excessDamage = -deadEntity.health;\r\n\t\t\tconst neighbours = getNeighbours(boardWithDeadEntity, null, deadEntityIndex);\r\n\t\t\t// console.log('neighbours', stringifySimple(neighbours, allCards));\r\n\t\t\tif (neighbours.length > 0) {\r\n\t\t\t\tconst randomTarget = neighbours[Math.floor(Math.random() * neighbours.length)];\r\n\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\trandomTarget,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t\texcessDamage,\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);\r\n\t\t\t}\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElementalBattlegrounds) {\r\n\t\t\tconst excessDamage = -deadEntity.health;\r\n\t\t\tconst neighbours = getNeighbours(boardWithDeadEntity, null, deadEntityIndex);\r\n\t\t\tneighbours.forEach((neighbour) =>\r\n\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\tneighbour,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tnull,\r\n\t\t\t\t\texcessDamage,\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),\r\n\t\t\t);\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn) {\r\n\t\t\tconst newEntities = spawnEntities(\r\n\t\t\t\tCardIds.IronhideDirehorn_IronhideRuntToken,\r\n\t\t\t\t1,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\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\t!deadEntity.friendly,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t\totherBoard.splice(deadEntityIndex, 0, ...newEntities);\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehornBattlegrounds) {\r\n\t\t\tconst newEntities = spawnEntities(\r\n\t\t\t\tCardIds.IronhideDirehorn_IronhideRuntTokenBattlegrounds,\r\n\t\t\t\t1,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\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\t!deadEntity.friendly,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t\totherBoard.splice(deadEntityIndex, 0, ...newEntities);\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath2) {\r\n\t\t\tconst otherPirates = otherBoard\r\n\t\t\t\t.filter((entity) => isCorrectTribe(allCards.getCard(entity.cardId).race, Race.PIRATE))\r\n\t\t\t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\totherPirates.forEach((pirate) => {\r\n\t\t\t\tmodifyAttack(pirate, 2, boardWithDeadEntity, allCards);\r\n\t\t\t\tmodifyHealth(pirate, 2);\r\n\t\t\t\tafterStatsUpdate(pirate, boardWithDeadEntity, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(deadEntity.lastAffectedByEntity, pirate, otherBoard);\r\n\t\t\t});\r\n\t\t} else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliathBattlegrounds) {\r\n\t\t\tconst otherPirates = otherBoard\r\n\t\t\t\t.filter((entity) => isCorrectTribe(allCards.getCard(entity.cardId).race, Race.PIRATE))\r\n\t\t\t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\totherPirates.forEach((pirate) => {\r\n\t\t\t\tmodifyAttack(pirate, 4, boardWithDeadEntity, allCards);\r\n\t\t\t\tmodifyHealth(pirate, 4);\r\n\t\t\t\tafterStatsUpdate(pirate, boardWithDeadEntity, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(deadEntity.lastAffectedByEntity, pirate, otherBoard);\r\n\t\t\t});\r\n\t\t}\r\n\t\t// else if (deadEntity.lastAffectedByEntity.cardId === CardIds.NatPagleExtremeAngler) {\r\n\t\t// }\r\n\t}\r\n\r\n\tconst rivendare = boardWithDeadEntity.find((entity) => entity.cardId === CardIds.BaronRivendare2);\r\n\tconst goldenRivendare = boardWithDeadEntity.find((entity) => entity.cardId === CardIds.BaronRivendareBattlegrounds);\r\n\tconst multiplier = goldenRivendare ? 3 : rivendare ? 2 : 1;\r\n\tif (deadEntity.cardId === CardIds.UnstableGhoul) {\r\n\t\tdealDamageToAllMinions(\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tdeadEntity,\r\n\t\t\tmultiplier * 1,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else if (deadEntity.cardId === CardIds.UnstableGhoulBattlegrounds) {\r\n\t\tdealDamageToAllMinions(\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tdeadEntity,\r\n\t\t\tmultiplier * 2,\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// Avenge\r\n\tupdateAvengeCounters(boardWithDeadEntity);\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};\r\n\r\nconst updateAvengeCounters = (board: readonly BoardEntity[]) => {\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};\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);\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.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);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Sisefin:\r\n\t\t\tconst murloc = getRandomMinion(boardWithDeadEntity, 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 murloc2 = getRandomMinion(boardWithDeadEntity, 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\tconst refCard = allCards.getCard(pirate.cardId);\r\n\t\t\t\tconst goldenCard = allCards.getCardFromDbfId(refCard.battlegroundsPremiumDbfId);\r\n\t\t\t\tpirate.cardId = goldenCard.id;\r\n\t\t\t\tmodifyAttack(pirate, refCard.attack, boardWithDeadEntity, allCards);\r\n\t\t\t\tmodifyHealth(pirate, refCard.health);\r\n\t\t\t\tafterStatsUpdate(pirate, boardWithDeadEntity, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(avenger, pirate, boardWithDeadEntity);\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\tconst refCard = allCards.getCard(pirate.cardId);\r\n\t\t\t\t\tpirate.cardId = refCard.id;\r\n\t\t\t\t\tmodifyAttack(pirate, refCard.attack, boardWithDeadEntity, allCards);\r\n\t\t\t\t\tmodifyHealth(pirate, refCard.health);\r\n\t\t\t\t\tafterStatsUpdate(pirate, boardWithDeadEntity, allCards);\r\n\t\t\t\t\tspectator.registerPowerTarget(avenger, pirate, boardWithDeadEntity);\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\nexport const dealDamageToAllMinions = (\r\n\tboard1: BoardEntity[],\r\n\tboard1Hero: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tboard2Hero: BgsPlayerEntity,\r\n\tdamageSource: BoardEntity,\r\n\tdamageDealt: number,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (board1.length === 0 && board2.length === 0) {\r\n\t\treturn;\r\n\t\t// return [board1, board2];\r\n\t}\r\n\t// let updatedBoard1 = [...board1];\r\n\t// let updatedBoard2 = [...board2];\r\n\tconst fakeAttacker = {\r\n\t\t...(damageSource || {}),\r\n\t\tentityId: -1,\r\n\t\tattack: damageDealt,\r\n\t\tattacking: true,\r\n\t} as BoardEntity;\r\n\tfor (let i = 0; i < board1.length; i++) {\r\n\t\tbumpEntities(board1[i], fakeAttacker, board1, board1Hero, board2, board2Hero, allCards, cardsData, sharedState, spectator);\r\n\t\t// board1[i] = entity;\r\n\t}\r\n\tfor (let i = 0; i < board2.length; i++) {\r\n\t\tbumpEntities(board2[i], fakeAttacker, board2, board2Hero, board1, board1Hero, allCards, cardsData, sharedState, spectator);\r\n\t\t// updatedBoard2 = [...boardResult];\r\n\t\t// updatedBoard2[i] = entity;\r\n\t}\r\n\t// processMinionDeath(board1, board1Hero, board2, board2Hero, allCards, cardsData, sharedState, spectator);\r\n};\r\n\r\nconst applySoulJugglerEffect = (\r\n\tboardWithJugglers: BoardEntity[],\r\n\tboardWithJugglersHero: BgsPlayerEntity,\r\n\tboardToAttack: BoardEntity[],\r\n\tboardToAttackHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (boardWithJugglers.length === 0 && boardToAttack.length === 0) {\r\n\t\treturn;\r\n\t\t// return [boardWithJugglers, boardToAttack];\r\n\t}\r\n\tconst jugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler);\r\n\tfor (const juggler of jugglers) {\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t3,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\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 goldenJugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJugglerBattlegrounds);\r\n\tfor (const juggler of goldenJugglers) {\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t3,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t3,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\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// processMinionDeath(\r\n\t// \tboardWithJugglers,\r\n\t// \tboardWithJugglersHero,\r\n\t// \tboardToAttack,\r\n\t// \tboardToAttackHero,\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 applyScavengingHyenaEffect = (board: BoardEntity[], allCards: AllCardsService, spectator: Spectator): void => {\r\n\t// const copy = [...board];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.ScavengingHyenaLegacy) {\r\n\t\t\tmodifyAttack(board[i], 2, board, allCards);\r\n\t\t\tmodifyHealth(board[i], 1);\r\n\t\t\tafterStatsUpdate(board[i], board, allCards);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t} else if (board[i].cardId === CardIds.ScavengingHyenaBattlegrounds) {\r\n\t\t\tmodifyAttack(board[i], 4, board, allCards);\r\n\t\t\tmodifyHealth(board[i], 2);\r\n\t\t\tafterStatsUpdate(board[i], board, allCards);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyJunkbotEffect = (board: BoardEntity[], allCards: AllCardsService, spectator: Spectator): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.Junkbot) {\r\n\t\t\tmodifyAttack(board[i], 2, board, allCards);\r\n\t\t\tmodifyHealth(board[i], 2);\r\n\t\t\tafterStatsUpdate(board[i], board, allCards);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t} else if (board[i].cardId === CardIds.JunkbotBattlegrounds) {\r\n\t\t\tmodifyAttack(board[i], 4, board, allCards);\r\n\t\t\tmodifyHealth(board[i], 4);\r\n\t\t\tafterStatsUpdate(board[i], board, allCards);\r\n\t\t\tspectator.registerPowerTarget(board[i], board[i], board);\r\n\t\t}\r\n\t}\r\n};\r\n\r\n// const applyQirajiHarbringerEffect = (board: BoardEntity[], deadEntityIndex: number, allCards: AllCardsService): void => {\r\n// \tconst qiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger);\r\n// \tconst goldenQiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbingerBattlegrounds);\r\n// \tconst neighbours = getNeighbours(board, null, deadEntityIndex);\r\n\r\n// \t// TODO: if reactivated, properly apply buffs one by one, instead of all together\r\n\r\n// \tneighbours.forEach((entity) => {\r\n// \t\tmodifyAttack(entity, 2 * qiraji.length + 4 * goldenQiraji.length, board, allCards);\r\n// \t\tmodifyHealth(entity, 2 * qiraji.length + 4 * goldenQiraji.length);\r\n// \t\tafterStatsUpdate(entity, board, allCards);\r\n// \t});\r\n// };\r\n\r\nconst 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\nconst 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);\r\n\t\tafterStatsUpdate(target, board, allCards);\r\n\t\tspectator.registerPowerTarget(source, target, board);\r\n\t}\r\n};\r\n\r\nconst 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);\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): void => {\r\n\tplayerEntity.cardsInHand = Math.min(10, (playerEntity.cardsInHand ?? 0) + 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);\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\nconst 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\nconst 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 rememberDeathrattles = (fish: BoardEntity, deadEntities: readonly BoardEntity[], cardsData: CardsData): void => {\r\n\tconst validDeathrattles = deadEntities\r\n\t\t.filter((entity) => cardsData.validDeathrattles.includes(entity.cardId))\r\n\t\t.map((entity) => entity.cardId);\r\n\tconst validEnchantments = deadEntities\r\n\t\t.filter((entity) => entity.enchantments?.length)\r\n\t\t.map((entity) => entity.enchantments)\r\n\t\t.reduce((a, b) => a.concat(b), [])\r\n\t\t.map((enchantment) => enchantment.cardId)\r\n\t\t.filter((enchantmentId) =>\r\n\t\t\t[\r\n\t\t\t\tCardIds.ReplicatingMenace_ReplicatingMenaceEnchantment,\r\n\t\t\t\tCardIds.ReplicatingMenace_ReplicatingMenaceEnchantmentBattlegrounds,\r\n\t\t\t\tCardIds.LivingSpores_LivingSporesEnchantment,\r\n\t\t\t\tCardIds.SneedsReplicator_ReplicateEnchantment,\r\n\t\t\t].includes(enchantmentId as CardIds),\r\n\t\t);\r\n\t// console.debug('remembering deathrattles', fish.cardId, stringifySimple(deadEntities), validDeathrattles, validEnchantments);\r\n\tconst newDeathrattles = [...validDeathrattles, ...validEnchantments];\r\n\t// Order is important\r\n\tif (fish.cardId === CardIds.FishOfNzothBattlegrounds) {\r\n\t\t// https://stackoverflow.com/questions/33305152/how-to-duplicate-elements-in-a-js-array\r\n\t\tconst doubleDr = [...validDeathrattles, ...validEnchantments].reduce((res, current) => res.concat([current, current]), []);\r\n\t\tfish.rememberedDeathrattles = [...doubleDr, ...(fish.rememberedDeathrattles || [])];\r\n\t} else {\r\n\t\tfish.rememberedDeathrattles = [...newDeathrattles, ...(fish.rememberedDeathrattles || [])];\r\n\t}\r\n\t// console.debug('remembered dr', fish.rememberedDeathrattles);\r\n};\r\n\r\nconst removeOldMurkEyeAttack = (boardWithDeadEntity: BoardEntity[], allCards: AllCardsService) => {\r\n\tconst murkeyes = boardWithDeadEntity.filter(\r\n\t\t(entity) => entity.cardId === CardIds.OldMurkEyeLegacy || entity.cardId === CardIds.OldMurkEyeVanilla,\r\n\t);\r\n\tconst goldenMurkeyes = boardWithDeadEntity.filter((entity) => entity.cardId === CardIds.OldMurkEyeBattlegrounds);\r\n\tmurkeyes.forEach((entity) => {\r\n\t\tmodifyAttack(entity, -1, boardWithDeadEntity, allCards);\r\n\t\tafterStatsUpdate(entity, boardWithDeadEntity, allCards);\r\n\t});\r\n\tgoldenMurkeyes.forEach((entity) => {\r\n\t\tmodifyAttack(entity, -2, boardWithDeadEntity, allCards);\r\n\t\tafterStatsUpdate(entity, boardWithDeadEntity, allCards);\r\n\t});\r\n};\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frenzy.js","sourceRoot":"","sources":["../../src/simulation/frenzy.ts"],"names":[],"mappings":";;;AAKA,+DAAuD;AAIhD,MAAM,WAAW,GAAG,CAC1B,gBAA6B,EAC7B,qBAAoC,EACpC,yBAA0C,EAC1C,QAAyB,EACzB,SAAoB,EACpB,WAAwB,EACxB,SAAoB,EACb,EAAE;IACT,IAAI,gBAAgB,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"frenzy.js","sourceRoot":"","sources":["../../src/simulation/frenzy.ts"],"names":[],"mappings":";;;AAKA,+DAAuD;AAIhD,MAAM,WAAW,GAAG,CAC1B,gBAA6B,EAC7B,qBAAoC,EACpC,yBAA0C,EAC1C,QAAyB,EACzB,SAAoB,EACpB,WAAwB,EACxB,SAAoB,EACb,EAAE;IACT,IAAI,gBAAgB,CAAC,MAAM,eAA+B,IAAI,gBAAgB,CAAC,MAAM,iBAA+B,EAAE;QACrH,gBAAgB,CAAC,YAAY,GAAG,IAAI,CAAC;KACrC;SAAM,IAAI,gBAAgB,CAAC,MAAM,eAAqB,IAAI,gBAAgB,CAAC,MAAM,iBAAkC,EAAE;QACrH,oCAAc,CACb,yBAAyB,EACzB,gBAAgB,CAAC,MAAM,iBAAkC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACjE,qBAAqB,EACrB,QAAQ,EACR,SAAS,CACT,CAAC;KACF;AACF,CAAC,CAAC;AApBW,QAAA,WAAW,eAoBtB","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds } 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 { addCardsInHand } from './deathrattle-effects';\r\nimport { SharedState } from './shared-state';\r\nimport { Spectator } from './spectator/spectator';\r\n\r\nexport const applyFrenzy = (\r\n\tentityWithFrenzy: BoardEntity,\r\n\tentityWithFrenzyBoard: BoardEntity[],\r\n\tentityWithFrenzyBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (entityWithFrenzy.cardId === CardIds.BristlebackKnight1 || entityWithFrenzy.cardId === CardIds.BristlebackKnight2) {\r\n\t\tentityWithFrenzy.divineShield = true;\r\n\t} else if (entityWithFrenzy.cardId === CardIds.Roadboar || entityWithFrenzy.cardId === CardIds.RoadboarBattlegrounds) {\r\n\t\taddCardsInHand(\r\n\t\t\tentityWithFrenzyBoardHero,\r\n\t\t\tentityWithFrenzy.cardId === CardIds.RoadboarBattlegrounds ? 2 : 1,\r\n\t\t\tentityWithFrenzyBoard,\r\n\t\t\tallCards,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n};\r\n"]}
|
package/dist/utils.js
CHANGED
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;;;;;;;;;;;;;;;;;;;;;CAqBjB,CAAC;AACF,MAAM,sBAAsB,GAAG,gCAAiF,CAAC;AACpG,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,CAAC,EACZ,WAAW,GAAG,KAAK,EACnB,SAAoB,EACpB,SAAoB,EACN,EAAE;;IAChB,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,YAAY,GAAG,yBAAiB,CAAC,OAAO,CAAC,MAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;IACzE,MAAM,iBAAiB,GAAG,sBAAsB,CAAC,OAAO,CAAC,MAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;IACnF,MAAM,MAAM,GAAG,2BAAmB,CAAC;QAClC,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,gBAAgB,EAAE,CAAC;QACnB,MAAM,EAAE,MAAM;QACd,YAAY,EAAE,mBAAW,CAAC,IAAI,EAAE,eAAe,CAAC;QAChD,QAAQ,EAAE,QAAQ;QAClB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,SAAS,EAAE,IAAI,CAAC,MAAM;QACtB,KAAK,EAAE,mBAAW,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAiB,CAAC;QAC1E,MAAM,EAAE,mBA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AAE,MAAM,mCAAI,CAC/B,EAAE;QACJ,CAAC,CAAC,IAAI,CAAC;AACT,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B;AAEK,MAAM,MAAM,GAAG,CAAC,KAAa,EAAU,EAAE;IAE/C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC;AACf,CAAC,CAAC;AALW,QAAA,MAAM,UAKjB;AAEK,MAAM,MAAM,GAAG,CAAC,MAAc,EAAU,EAAE;IAChD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACnC,OAAO,GAAG,CAAC;AACZ,CAAC,CAAC;AAJW,QAAA,MAAM,UAIjB","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];\r\nconst ATTACK_IMMEDIATELY_IDS = [CardIds.Scallywag_SkyPirateToken, CardIds.Scallywag_SkyPirateTokenBattlegrounds];\r\nexport const MEGA_WINDFURY_IDS = [\r\n\tCardIds.ZappSlywickBattlegrounds,\r\n\tCardIds.CracklingCycloneBattlegrounds,\r\n\tCardIds.BristlebackKnight,\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 result = 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\tresult.health = 1;\r\n\t\tresult.reborn = false;\r\n\t}\r\n\r\n\tif (controllerHero?.heroPowerId === CardIds.SproutItOutBattlegrounds) {\r\n\t\tresult.taunt = true;\r\n\t\tmodifyAttack(result, 1, friendlyBoard, allCards);\r\n\t\tmodifyHealth(result, 2);\r\n\t\tafterStatsUpdate(result, 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(result, 2, friendlyBoard, allCards);\r\n\t\tmodifyHealth(result, 2);\r\n\t\tafterStatsUpdate(result, friendlyBoard, allCards);\r\n\t\t// spectator && spectator.registerPowerTarget(result, result, friendlyBoard);\r\n\t}\r\n\r\n\treturn result;\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);\r\n\t\t});\r\n\t\twhelpSmugglersBattlegrounds.forEach((smuggler) => {\r\n\t\t\tmodifyHealth(entity, 2);\r\n\t\t});\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(entity, master.cardId === CardIds.MasterOfRealitiesBattlegrounds ? 2 : 1, friendlyBoard, allCards);\r\n\t\t\tmodifyHealth(entity, master.cardId === CardIds.MasterOfRealitiesBattlegrounds ? 2 : 1);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const modifyHealth = (entity: BoardEntity, amount: number): void => {\r\n\tentity.health += amount;\r\n\tif (amount > 0) {\r\n\t\tentity.maxHealth += amount;\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): 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.enchantments?.length ?? 0\r\n\t\t }`\r\n\t\t: null;\r\n};\r\n\r\nexport const encode = (input: string): string => {\r\n\t// return compressToEncodedURIComponent(input);\r\n\tconst buff = Buffer.from(input, 'utf-8');\r\n\tconst base64 = buff.toString('base64');\r\n\treturn base64;\r\n};\r\n\r\nexport const decode = (base64: string): string => {\r\n\tconst buff = Buffer.from(base64, 'base64');\r\n\tconst str = buff.toString('utf-8');\r\n\treturn str;\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;;;;;;;;;;;;;;;;;;;;;CAqBjB,CAAC;AACF,MAAM,sBAAsB,GAAG,gCAAiF,CAAC;AACpG,QAAA,iBAAiB,GAAG;;;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,MAAM,UAKjB;AAEK,MAAM,MAAM,GAAG,CAAC,MAAc,EAAU,EAAE;IAChD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACnC,OAAO,GAAG,CAAC;AACZ,CAAC,CAAC;AAJW,QAAA,MAAM,UAIjB","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];\r\nconst ATTACK_IMMEDIATELY_IDS = [CardIds.Scallywag_SkyPirateToken, CardIds.Scallywag_SkyPirateTokenBattlegrounds];\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 result = 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\tresult.health = 1;\r\n\t\tresult.reborn = false;\r\n\t}\r\n\r\n\tif (controllerHero?.heroPowerId === CardIds.SproutItOutBattlegrounds) {\r\n\t\tresult.taunt = true;\r\n\t\tmodifyAttack(result, 1, friendlyBoard, allCards);\r\n\t\tmodifyHealth(result, 2);\r\n\t\tafterStatsUpdate(result, 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(result, 2, friendlyBoard, allCards);\r\n\t\tmodifyHealth(result, 2);\r\n\t\tafterStatsUpdate(result, friendlyBoard, allCards);\r\n\t\t// spectator && spectator.registerPowerTarget(result, result, friendlyBoard);\r\n\t}\r\n\r\n\treturn result;\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);\r\n\t\t});\r\n\t\twhelpSmugglersBattlegrounds.forEach((smuggler) => {\r\n\t\t\tmodifyHealth(entity, 2);\r\n\t\t});\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(entity, master.cardId === CardIds.MasterOfRealitiesBattlegrounds ? 2 : 1, friendlyBoard, allCards);\r\n\t\t\tmodifyHealth(entity, master.cardId === CardIds.MasterOfRealitiesBattlegrounds ? 2 : 1);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const modifyHealth = (entity: BoardEntity, amount: number): void => {\r\n\tentity.health += amount;\r\n\tif (amount > 0) {\r\n\t\tentity.maxHealth += amount;\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): 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.enchantments?.length ?? 0\r\n\t\t }`\r\n\t\t: null;\r\n};\r\n\r\nexport const encode = (input: string): string => {\r\n\t// return compressToEncodedURIComponent(input);\r\n\tconst buff = Buffer.from(input, 'utf-8');\r\n\tconst base64 = buff.toString('base64');\r\n\treturn base64;\r\n};\r\n\r\nexport const decode = (base64: string): string => {\r\n\tconst buff = Buffer.from(base64, 'base64');\r\n\tconst str = buff.toString('utf-8');\r\n\treturn str;\r\n};\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firestone-hs/simulate-bgs-battle",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.133",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint": "eslint --color --fix --ext .ts .",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@firestone-hs/hs-replay-xml-parser": "0.0.46",
|
|
31
|
-
"@firestone-hs/reference-data": "^0.1.
|
|
31
|
+
"@firestone-hs/reference-data": "^0.1.179",
|
|
32
32
|
"cross-fetch": "^3.0.6",
|
|
33
33
|
"lodash.clonedeep": "^4.5.0",
|
|
34
34
|
"node-fetch": "^2.6.1"
|