@firestone-hs/simulate-bgs-battle 1.1.556 → 1.1.557
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/impl/_card-mappings.js +2 -0
- package/dist/cards/impl/_card-mappings.js.map +1 -1
- package/dist/cards/impl/minion/fireworks-fanatic.d.ts +2 -0
- package/dist/cards/impl/minion/fireworks-fanatic.js +25 -0
- package/dist/cards/impl/minion/fireworks-fanatic.js.map +1 -0
- package/dist/cards/impl/minion/sanlayn-scribe.js +20 -0
- package/dist/cards/impl/minion/sanlayn-scribe.js.map +1 -1
- package/dist/cards/impl/minion/sky-pirate-flagbearer.js +1 -0
- package/dist/cards/impl/minion/sky-pirate-flagbearer.js.map +1 -1
- package/dist/simulation/add-minion-to-board.js +8 -4
- package/dist/simulation/add-minion-to-board.js.map +1 -1
- package/dist/simulation/attack.d.ts +1 -1
- package/dist/simulation/attack.js.map +1 -1
- package/dist/simulation/utils/golden.js +1 -2
- package/dist/simulation/utils/golden.js.map +1 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +8 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attack.js","sourceRoot":"","sources":["../../src/simulation/attack.ts"],"names":[],"mappings":";;;AACA,iEAA8E;AAG9E,4DAAqD;AACrD,iEAA4D;AAC5D,gDAA4C;AAC5C,6DAA+D;AAC/D,mDAAsD;AACtD,6CAAgE;AAChE,oCAAwE;AACxE,iDAAyD;AACzD,qDAAmD;AACnD,+DAA+E;AAC/E,2EAA4E;AAC5E,6DAAqD;AAErD,iDAAgD;AAChD,+CAA6C;AAC7C,2CAAmD;AACnD,2DAAgE;AAChE,qCAA+C;AAC/C,mCAAgD;AAChD,2DAA6D;AAC7D,uDAAiD;AAG1C,MAAM,cAAc,GAAG,CAC7B,cAA6B,EAC7B,kBAAmC,EACnC,cAA6B,EAC7B,kBAAmC,EACnC,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AC3B,IACC,CAAC,eAAe,GAAG,MAAA,kBAAkB,CAAC,OAAO,0CAAE,IAAI,CAClD,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,IAAI,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,0BAAgC,CAC/E,CAAC,IAAI,IAAI,EACT;QACD,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;YAC/B,eAAe,CAAC,SAAS,GAAG,IAAI,CAAC;YACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;gBAC3B,MAAM,QAAQ,GAAG,IAAA,kBAAU,EAAC,SAAS,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;gBAC7D,iBAAiB,CAAC,IAAI,CACrB,GAAG,IAAA,kCAAa,EACf,QAAQ,EACR,CAAC,EACD,aAAa,EACb,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,SAAS,EACT,kBAAkB,CAAC,QAAQ,EAC3B,KAAK,CACL,CACD,CAAC;aACF;SACD;KACD;IACD,IAAA,4BAAmB,EAClB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,CAAC,EACD,UAAU,EACV,eAAe,EACf,SAAS,CACT,CAAC;AACH,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 { hasOnDeath } from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { debugState } from '../debug-state';\r\nimport { updateDivineShield } from '../keywords/divine-shield';\r\nimport { updateVenomous } from '../keywords/venomous';\r\nimport { groupByFunction, pickRandom } from '../services/utils';\r\nimport { addImpliedMechanics, hasCorrectTribe, isFish } from '../utils';\r\nimport { applyAfterAttackEffects } from './after-attack';\r\nimport { onEntityDamaged } from './damage-effects';\r\nimport { applyMonstrosity, rememberDeathrattles } from './deathrattle-effects';\r\nimport { orchestrateMinionDeathEffects } from './deathrattle-orchestration';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { makeMinionsDie } from './minion-death';\r\nimport { onMinionKill } from './minion-kill';\r\nimport { applyOnAttackEffects } from './on-attack';\r\nimport { applyOnBeingAttackedBuffs } from './on-being-attacked';\r\nimport { performEntitySpawns } from './spawns';\r\nimport { applyAfterStatsUpdate } from './stats';\r\nimport { handleSummonsWhenSpace } from './summon-when-space';\r\nimport { canAttack } from './utils/entity-utils';\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\tgameState: FullGameState,\r\n): BoardEntity => {\r\n\t// console.debug(\r\n\t// \t'\\nsimulating attack',\r\n\t// \tstringifySimple(attackingBoard, gameState.allCards),\r\n\t// \t'\\n',\r\n\t// \tstringifySimple(defendingBoard, gameState.allCards),\r\n\t// );\r\n\tif (attackingBoard.length === 0 || defendingBoard.length === 0) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst attackingEntity = getAttackingEntity(attackingBoard, gameState.allCards);\r\n\tif (attackingEntity) {\r\n\t\tgameState.sharedState.currentAttackerEntityId = attackingEntity.entityId;\r\n\t\t// Get the left entities now, otherwise things might break if the attacker dies and/or other\r\n\t\t// entities pop\r\n\t\tconst attackingEntityIndex = attackingBoard.indexOf(attackingEntity);\r\n\t\tconst attackingEntitiesToTheLeft = attackingBoard.slice(0, attackingEntityIndex);\r\n\t\tconst isAttackingImmediately = attackingEntity.attackImmediately;\r\n\t\t// In case of Broodmother spawn, it spawns where the dead minion was, and has no influence on the\r\n\t\t// attack order\r\n\t\t// Situation this is trying to resolve by putting this right at the top of the loop:\r\n\t\t// - One scallywag attacks into another one, both die\r\n\t\t// - The first one attacks. To its left is a Harmless Bonehead with 1 HP. The scallywag attacks, and both scallys die\r\n\t\t// - The *other* sky pirate attacks first, and kills the bonehead. Two minions are spawned\r\n\t\t// - The first sy pirate attacks\r\n\t\t// - The initial loop is resolved. If this is at the end, the Harmless Bonehead is already dead, and not flagged\r\n\t\t// While having this right away, we immediately flag all minions to the left\r\n\t\tif (!isAttackingImmediately) {\r\n\t\t\t// Make sure they won't be able to attack until everyone has attacked\r\n\t\t\t// See http://replays.firestoneapp.com/?reviewId=a1b3066d-e806-44c1-ab4b-7ef9dbf9b5b9&turn=5&action=4\r\n\t\t\tattackingEntitiesToTheLeft.forEach((entity) => (entity.hasAttacked = 2));\r\n\t\t}\r\n\r\n\t\tconst numberOfAttacks = 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\t// We still want to flag the entity as having attacked, so that it doesn't attack again\r\n\t\t\t\t// after teammate switch in Duos\r\n\t\t\t\tbreak;\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\tconst defendingEntity: BoardEntity = getDefendingEntity(defendingBoard, attackingEntity);\r\n\t\t\t\t// Can happen with a single defender that has stealth\r\n\t\t\t\tif (defendingEntity) {\r\n\t\t\t\t\tdoFullAttack(\r\n\t\t\t\t\t\tattackingEntity,\r\n\t\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t} else {\r\n\t\t\t\t\t// Solves the edge case of Sky Pirate vs a stealth board\r\n\t\t\t\t\tattackingEntity.attackImmediately = false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tgameState.sharedState.currentAttackerEntityId = null;\r\n\t\tattackingEntity.hasAttacked = 1;\r\n\t}\r\n\treturn attackingEntity;\r\n};\r\n\r\nexport const doFullAttack = (\r\n\tattackingEntity: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingEntity: BoardEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst isAttackingImmediately = attackingEntity.attackImmediately;\r\n\tgameState.spectator.registerAttack(\r\n\t\tattackingEntity,\r\n\t\tdefendingEntity,\r\n\t\tattackingBoard,\r\n\t\tdefendingBoard,\r\n\t\tattackingBoardHero,\r\n\t\tdefendingBoardHero,\r\n\t);\r\n\t// http://replays.firestoneapp.com/?reviewId=50576a9f-2e6a-4600-87ba-6e737ca9853e&turn=21&action=4\r\n\t// Looks like onBeingAttacked effects apply before onAttack effects\r\n\tapplyOnBeingAttackedBuffs(\r\n\t\tattackingEntity,\r\n\t\tattackingBoard,\r\n\t\tattackingBoardHero,\r\n\t\tdefendingEntity,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\tgameState,\r\n\t);\r\n\tconst { damageDoneByAttacker: damageDoneByAttacker1, damageDoneByDefender: damageDoneByDefender1 } =\r\n\t\tapplyOnAttackEffects(\r\n\t\t\tattackingEntity,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingEntity,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\tconst { damageDoneByAttacker: damageDoneByAttacker2, damageDoneByDefender: damageDoneByDefender2 } = performAttack(\r\n\t\tattackingEntity,\r\n\t\tdefendingEntity,\r\n\t\tattackingBoard,\r\n\t\tattackingBoardHero,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\tgameState,\r\n\t);\r\n\tconst damageDoneByAttacker = damageDoneByAttacker1 + damageDoneByAttacker2;\r\n\tconst damageDoneByDefender = damageDoneByDefender1 + damageDoneByDefender2;\r\n\tapplyAfterAttackEffects(\r\n\t\tattackingEntity,\r\n\t\tattackingBoard,\r\n\t\tattackingBoardHero,\r\n\t\tdefendingEntity,\r\n\t\tdefendingBoardHero,\r\n\t\tdamageDoneByAttacker,\r\n\t\tdamageDoneByDefender,\r\n\t\tgameState,\r\n\t);\r\n\r\n\tprocessMinionDeath(\r\n\t\tattackingBoard,\r\n\t\tattackingBoardHero,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\tgameState,\r\n\t\tisAttackingImmediately,\r\n\t);\r\n\tapplyAfterStatsUpdate(gameState);\r\n\tattackingEntity.immuneWhenAttackCharges = Math.max(0, (attackingEntity.immuneWhenAttackCharges ?? 0) - 1);\r\n\tif (\r\n\t\tdefendingEntity.health > 0 &&\r\n\t\t!defendingEntity.definitelyDead &&\r\n\t\t(defendingEntity.cardId === CardIds.YoHoOgre_BGS_060 ||\r\n\t\t\tdefendingEntity.cardId === CardIds.YoHoOgre_TB_BaconUps_150)\r\n\t) {\r\n\t\tdefendingEntity.attackImmediately = true;\r\n\t\tif (defendingEntity.attackImmediately) {\r\n\t\t\tsimulateAttack(defendingBoard, defendingBoardHero, attackingBoard, attackingBoardHero, gameState);\r\n\t\t}\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\tgameState: FullGameState,\r\n): { damageDoneByAttacker: number; damageDoneByDefender: number } => {\r\n\tlet damageDoneByAttacker = 0;\r\n\tlet damageDoneByDefender = 0;\r\n\r\n\tif (hasCorrectTribe(attackingEntity, attackingBoardHero, Race.DRAGON, gameState.anomalies, gameState.allCards)) {\r\n\t\tconst prestors = attackingBoard\r\n\t\t\t.filter((e) => e.entityId !== attackingEntity.entityId)\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId === CardIds.PrestorsPyrospawn_BG21_012 ||\r\n\t\t\t\t\te.cardId === CardIds.PrestorsPyrospawn_BG21_012_G,\r\n\t\t\t);\r\n\t\tprestors.forEach((prestor) => {\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tprestor,\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t);\r\n\t\t\tdamageDoneByAttacker += dealDamageToMinion(\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.PrestorsPyrospawn_BG21_012_G ? 6 : 3,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\tif (\r\n\t\tattackingEntity.cardId === CardIds.Atramedes_BG23_362 ||\r\n\t\tattackingEntity.cardId === CardIds.Atramedes_BG23_362_G\r\n\t) {\r\n\t\tconst targets = [defendingEntity, ...getNeighbours(defendingBoard, defendingEntity)];\r\n\t\tconst multiplier = attackingEntity.cardId === CardIds.Atramedes_BG23_362_G ? 2 : 1;\r\n\r\n\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\ttargets.forEach((target) => {\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattackingEntity,\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t);\r\n\t\t\t\tdamageDoneByAttacker += dealDamageToMinion(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tattackingEntity,\r\n\t\t\t\t\t3,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t\t}\r\n\t} else if ([CardIds.BabyKrush_BG22_001, CardIds.BabyKrush_BG22_001_G].includes(attackingEntity.cardId as CardIds)) {\r\n\t\tconst spawns = spawnEntities(\r\n\t\t\tattackingEntity.cardId === CardIds.BabyKrush_BG22_001_G\r\n\t\t\t\t? CardIds.BabyKrush_BG22_001_G\r\n\t\t\t\t: CardIds.BabyKrush_DevilsaurToken,\r\n\t\t\t1,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tgameState,\r\n\t\t\ttrue,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t\tif (spawns.length > 0) {\r\n\t\t\tconst sourceIndex = attackingBoard.indexOf(attackingEntity);\r\n\t\t\tconst actualSpawns = performEntitySpawns(\r\n\t\t\t\tspawns,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tsourceIndex,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tfor (const actualSpawn of actualSpawns) {\r\n\t\t\t\tif (defendingEntity.health > 0 && !defendingEntity.definitelyDead) {\r\n\t\t\t\t\tperformAttack(\r\n\t\t\t\t\t\tactualSpawn,\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// For Prestor\r\n\tconst defenderAliveBeforeAttack = defendingEntity.health > 0 && !defendingEntity.definitelyDead;\r\n\t// Because of Bristleback Knight, which changes its divine shield status during bumpEntities\r\n\tconst attackerHadDivineShield = attackingEntity.divineShield;\r\n\tconst defenderHadDivineShield = defendingEntity.divineShield;\r\n\t// For cleave\r\n\t// We do that now so that we don't include entities that spawn on entity damaged\r\n\tconst defenderNeighbours: readonly BoardEntity[] = getNeighbours(defendingBoard, defendingEntity);\r\n\tif (defenderAliveBeforeAttack) {\r\n\t\tif (!attackingEntity.immuneWhenAttackCharges) {\r\n\t\t\t// TODO: this bumpEntities approach doesn't work well, as it leads to code duplication\r\n\t\t\tdamageDoneByDefender += bumpEntities(\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t\tdamageDoneByAttacker += bumpEntities(\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\tgameState,\r\n\t\t);\r\n\t\tif (defendingEntity.attack > 0 && attackerHadDivineShield && !attackingEntity.immuneWhenAttackCharges) {\r\n\t\t\tupdateDivineShield(\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tfalse,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t\tif (attackingEntity.attack > 0 && defenderHadDivineShield) {\r\n\t\t\tupdateDivineShield(\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tfalse,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t\t// Do it after the damage has been done, so that entities that update on DS lose / gain (CyborgDrake) don't\r\n\t\t// cause wrong results to happen\r\n\t\t// This whole logic is a MEEEEESSSSSSSSSSSSSSS\r\n\t\tif (damageDoneByDefender > 0) {\r\n\t\t\tonEntityDamaged(\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\tdamageDoneByDefender,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t\tif (damageDoneByAttacker > 0) {\r\n\t\t\tonEntityDamaged(\r\n\t\t\t\tdefendingEntity,\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\tdamageDoneByAttacker,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tif (defendingEntity.health <= 0 || defendingEntity.definitelyDead) {\r\n\t\t\tconst { dmgDoneByAttacker, dmgDoneByDefender } = onMinionKill(\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tdefenderNeighbours,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tdamageDoneByAttacker += dmgDoneByAttacker;\r\n\t\t\tdamageDoneByDefender += dmgDoneByDefender;\r\n\t\t}\r\n\t\tif (attackingEntity.health <= 0 || attackingEntity.definitelyDead) {\r\n\t\t\tconst { dmgDoneByAttacker, dmgDoneByDefender } = onMinionKill(\r\n\t\t\t\tdefendingEntity,\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\tdefenderNeighbours,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tdamageDoneByAttacker += dmgDoneByAttacker;\r\n\t\t\tdamageDoneByDefender += dmgDoneByDefender;\r\n\t\t}\r\n\t}\r\n\t// Cleave\r\n\tif (attackingEntity.cleave) {\r\n\t\tfor (const neighbour of defenderNeighbours) {\r\n\t\t\tconst thisAttackDamage = bumpEntities(\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\tgameState,\r\n\t\t\t);\r\n\t\t\tdamageDoneByAttacker += thisAttackDamage;\r\n\t\t\t// Do it after the damage has been done, so that entities that update on DS lose / gain (CyborgDrake) don't\r\n\t\t\t// cause wrong results to happen\r\n\t\t\tif (attackingEntity.attack > 0 && neighbour.divineShield) {\r\n\t\t\t\tupdateDivineShield(neighbour, defendingBoard, defendingBoardHero, attackingBoardHero, false, gameState);\r\n\t\t\t}\r\n\t\t\tif (thisAttackDamage > 0) {\r\n\t\t\t\tonEntityDamaged(\r\n\t\t\t\t\tneighbour,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tthisAttackDamage,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t\tif (neighbour.health <= 0 || neighbour.definitelyDead) {\r\n\t\t\t\tconst { dmgDoneByAttacker, dmgDoneByDefender } = onMinionKill(\r\n\t\t\t\t\tattackingEntity,\r\n\t\t\t\t\tneighbour,\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\tdefenderNeighbours,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t\tdamageDoneByAttacker += dmgDoneByAttacker;\r\n\t\t\t\tdamageDoneByDefender += dmgDoneByDefender;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tattackingEntity.attackImmediately = false;\r\n\tif (attackingEntity.enchantments.some((e) => e.cardId === CardIds.VolatileVenom_VolatileEnchantment)) {\r\n\t\tattackingEntity.definitelyDead = true;\r\n\t}\r\n\treturn { damageDoneByAttacker, damageDoneByDefender };\r\n};\r\n\r\n// TODO: Could it be possible to store the index of the entity that last attacked? Probably not, because minion\r\n// spawns would mess this up? Could we update the indexes as each entity spawns / dies?\r\nconst getAttackingEntity = (attackingBoard: BoardEntity[], allCards: AllCardsService): BoardEntity => {\r\n\tlet validAttackers = attackingBoard.filter((entity) => canAttack(entity));\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} else if (validAttackers.every((e) => e.hasAttacked)) {\r\n\t\tattackingBoard.forEach((e) => (e.hasAttacked = 0));\r\n\t} else {\r\n\t\tvalidAttackers = validAttackers.filter((entity) => !entity.hasAttacked);\r\n\t}\r\n\tconst attacker = validAttackers[0];\r\n\treturn attacker;\r\n};\r\n\r\nexport const findNearestEnemies = (\r\n\tattackingBoard: BoardEntity[],\r\n\tentity: BoardEntity,\r\n\tentityIndexFromRight: number,\r\n\tdefendingBoard: BoardEntity[],\r\n\tnumberOfTargets: number,\r\n\tallCards: AllCardsService,\r\n): BoardEntity[] => {\r\n\tconst result = [];\r\n\tif (defendingBoard.length > 0) {\r\n\t\t// console.debug('defending board', numberOfTargets, stringifySimple(defendingBoard, allCards));\r\n\t\tconst attackerIndex = attackingBoard.length - entityIndexFromRight - 1;\r\n\t\tconst targetIndex = attackerIndex - (attackingBoard.length - defendingBoard.length) / 2;\r\n\t\t// console.debug('indexes', attackerIndex, entityIndexFromRight, targetIndex, attackingBoard.length);\r\n\r\n\t\tfor (let i = 0; i < numberOfTargets; i++) {\r\n\t\t\tconst possibleTargets = defendingBoard\r\n\t\t\t\t.filter((e) => !e.definitelyDead && e.health > 0)\r\n\t\t\t\t.filter((e) => !result.includes(e));\r\n\t\t\t// console.debug('possibleTargets', stringifySimple(possibleTargets, allCards));\r\n\t\t\tif (!possibleTargets.length) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tconst targetGroups = groupByFunction((e: BoardEntity) => Math.abs(defendingBoard.indexOf(e) - targetIndex))(\r\n\t\t\t\tpossibleTargets,\r\n\t\t\t);\r\n\t\t\tconst distances = Object.keys(targetGroups)\r\n\t\t\t\t.map((k) => +k)\r\n\t\t\t\t.sort();\r\n\t\t\tconst nearestDistance = distances[0];\r\n\t\t\tif (nearestDistance != null) {\r\n\t\t\t\t// console.debug(\r\n\t\t\t\t// \t'targetGroups[nearestDistance]',\r\n\t\t\t\t// \tnearestDistance,\r\n\t\t\t\t// \tstringifySimple(targetGroups[nearestDistance], allCards),\r\n\t\t\t\t// );\r\n\t\t\t\tconst target = pickRandom(targetGroups[nearestDistance]);\r\n\t\t\t\tresult.push(target);\r\n\t\t\t}\r\n\t\t\t// console.debug('\\n');\r\n\t\t}\r\n\t}\r\n\treturn result.filter((e) => !!e);\r\n};\r\n\r\nexport const getNeighbours = (\r\n\tboard: BoardEntity[],\r\n\tentity: BoardEntity,\r\n\tdeadEntityIndexFromRight?: number,\r\n): readonly BoardEntity[] => {\r\n\tconst neighbours = [];\r\n\t// When triggering DR with Hawkstrider, the entity is still on the board\r\n\tif (deadEntityIndexFromRight != null && !board.includes(entity)) {\r\n\t\tconst leftNeighbourIndex = board.length - 1 - deadEntityIndexFromRight;\r\n\t\tconst leftNeighbour = board[leftNeighbourIndex];\r\n\t\tif (leftNeighbour) {\r\n\t\t\tneighbours.push(leftNeighbour);\r\n\t\t}\r\n\r\n\t\t// If the deadEntityIndexFromRight === 0 (right-most minion), no neighbour will be found\r\n\t\tconst rightNeighbourIndex = board.length - 1 - (deadEntityIndexFromRight - 1);\r\n\t\tconst rightNeighbour = board[rightNeighbourIndex];\r\n\t\tif (rightNeighbour) {\r\n\t\t\tneighbours.push(rightNeighbour);\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 getLeftNeighbour = (\r\n\tboard: BoardEntity[],\r\n\tentity: BoardEntity,\r\n\tdeadEntityIndexFromRight?: number,\r\n): BoardEntity => {\r\n\t// When triggering DR with Hawkstrider, the entity is still on the board\r\n\tif (deadEntityIndexFromRight != null && !board.includes(entity)) {\r\n\t\tconst leftNeighbourIndex = board.length - 1 - deadEntityIndexFromRight;\r\n\t\tconst leftNeighbour = board[leftNeighbourIndex];\r\n\t\tif (leftNeighbour) {\r\n\t\t\treturn leftNeighbour;\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\treturn board[index - 1];\r\n\t\t}\r\n\t}\r\n\treturn null;\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\tgameState: FullGameState,\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\tgameState.spectator.registerPowerTarget(\r\n\t\t\tdamageSource,\r\n\t\t\tdefendingEntity,\r\n\t\t\tboardToBeDamaged,\r\n\t\t\tboardToBeDamagedHero,\r\n\t\t\tboardWithAttackOriginHero,\r\n\t\t);\r\n\t\tdealDamageToMinion(\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\tgameState,\r\n\t\t);\r\n\t}\r\n};\r\n\r\nexport const dealDamageToMinion = (\r\n\ttarget: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tdamageSource: BoardEntity,\r\n\tdamage: number,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\t// console.log('dealing damage to', damage, stringifySimpleCard(defendingEntity, allCards));\r\n\tif (!target) {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tconst isDeadBeforeDamage = target.definitelyDead || target.health <= 0;\r\n\tconst spawns = [];\r\n\t// Why do we use a fakeAttacker? Is that for the \"attacking\" prop?\r\n\t// That prop is only used for Overkill, and even in that case it looks like it would work\r\n\t// without it\r\n\tconst fakeAttacker = {\r\n\t\t...(damageSource || {}),\r\n\t\tentityId: -1,\r\n\t\tattack: damage,\r\n\t\t// attacking: true,\r\n\t} as BoardEntity;\r\n\tconst actualDamageDone = bumpEntities(target, fakeAttacker, board, hero, otherBoard, otherHero, gameState);\r\n\r\n\t// Do it after the damage has been done, so that entities that update on DS lose / gain (CyborgDrake) don't\r\n\t// cause wrong results to happen\r\n\t// TODO: why isn't it done in bumpEntities?\r\n\t// Because of how \"bump\" works: we do it first for the attacker, then the defender, and we only want to update\r\n\t// the divine shield once both bumps are done\r\n\t// The problem is with the Frenzy: bumpEntities can trigger the frenzy, and which can act on the divine shield\r\n\tif (fakeAttacker.attack > 0 && target.divineShield) {\r\n\t\tupdateDivineShield(target, board, hero, otherHero, false, gameState);\r\n\t}\r\n\r\n\tif (actualDamageDone > 0) {\r\n\t\t// TODO: handle entities that have been spawned here to adjust the dead entity index from parent stack\r\n\t\tconst newSpawns = onEntityDamaged(target, board, hero, otherBoard, otherHero, actualDamageDone, gameState);\r\n\t}\r\n\tif (!isDeadBeforeDamage && actualDamageDone > 0) {\r\n\t\ttarget.lastAffectedByEntity = damageSource;\r\n\r\n\t\tif (target.health <= 0 || target.definitelyDead) {\r\n\t\t\tonMinionKill(damageSource, target, otherBoard, otherHero, board, hero, [], gameState);\r\n\t\t}\r\n\t}\r\n\tconst defendingEntityIndex = board.map((entity) => entity.entityId).indexOf(target.entityId);\r\n\tboard[defendingEntityIndex] = target;\r\n\treturn actualDamageDone;\r\n};\r\n\r\nexport const getDefendingEntity = (\r\n\tdefendingBoard: BoardEntity[],\r\n\tattackingEntity: BoardEntity,\r\n\tignoreTaunts = false,\r\n): BoardEntity => {\r\n\tif (debugState.active) {\r\n\t\tfor (const forcedFaceOff of debugState.forcedFaceOff) {\r\n\t\t\tif (debugState.isCorrectEntity(forcedFaceOff.attacker, attackingEntity))\r\n\t\t\t\tif (attackingEntity.entityId === forcedFaceOff.attacker.entityId) {\r\n\t\t\t\t\tlet def = null;\r\n\t\t\t\t\tif (!!(def = defendingBoard.find((e) => debugState.isCorrectEntity(forcedFaceOff.defender, e)))) {\r\n\t\t\t\t\t\t// Remove the face-off\r\n\t\t\t\t\t\tdebugState.forcedFaceOff = debugState.forcedFaceOff.filter((f) => f != forcedFaceOff);\r\n\t\t\t\t\t\treturn def;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t}\r\n\t}\r\n\t// if (attackingEntity.entityId === 4946) {\r\n\t// \tlet def = null;\r\n\t// \tif (!!(def = defendingBoard.find((e) => e.entityId === 7170))) {\r\n\t// \t\treturn def;\r\n\t// \t}\r\n\t// }\r\n\r\n\tlet possibleDefenders: readonly BoardEntity[];\r\n\tif (\r\n\t\tattackingEntity.cardId === CardIds.ZappSlywick_BGS_022 ||\r\n\t\tattackingEntity.cardId === CardIds.ZappSlywick_TB_BaconUps_091\r\n\t) {\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 (\r\n\t\tattackingEntity.cardId === CardIds.WorgenVigilante_BG26_921 ||\r\n\t\tattackingEntity.cardId === CardIds.WorgenVigilante_BG26_921_G\r\n\t) {\r\n\t\tpossibleDefenders = defendingBoard\r\n\t\t\t.filter(\r\n\t\t\t\t(entity) =>\r\n\t\t\t\t\tentity.health <= attackingEntity.attack || attackingEntity.venomous || attackingEntity.poisonous,\r\n\t\t\t)\r\n\t\t\t.filter((e) => !e.divineShield);\r\n\t\tif (!possibleDefenders.length) {\r\n\t\t\tpossibleDefenders = defendingBoard;\r\n\t\t}\r\n\t} else {\r\n\t\tpossibleDefenders = defendingBoard.filter((e) => !e.stealth);\r\n\t\tif (!ignoreTaunts) {\r\n\t\t\tconst taunts = possibleDefenders.filter((entity) => entity.taunt);\r\n\t\t\tpossibleDefenders = taunts.length > 0 ? taunts : possibleDefenders;\r\n\t\t}\r\n\t}\r\n\r\n\tlet chosenDefender = pickRandom(possibleDefenders);\r\n\tif (chosenDefender?.taunt) {\r\n\t\tconst elistras = defendingBoard.filter(\r\n\t\t\t(entity) =>\r\n\t\t\t\tentity.cardId === CardIds.ElistraTheImmortal_BGS_205 ||\r\n\t\t\t\tentity.cardId === CardIds.ElistraTheImmortal_TB_BaconUps_306,\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\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\tgameState: FullGameState,\r\n\tapplyVenomous = true,\r\n): number => {\r\n\t// No attack has no impact\r\n\tconst debug = bumpInto.cardId === 'BG26_888';\r\n\tif (bumpInto.attack === 0) {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\t// Matador effect has priority\r\n\tif (\r\n\t\tentity.abiityChargesLeft > 0 &&\r\n\t\t(entity.cardId === CardIds.MadMatador_BG28_404 || entity.cardId === CardIds.MadMatador_BG28_404_G)\r\n\t) {\r\n\t\tentity.abiityChargesLeft--;\r\n\t\tconst newTarget = pickRandom(otherBoard);\r\n\t\tif (newTarget) {\r\n\t\t\tgameState.spectator.registerPowerTarget(entity, newTarget, otherBoard, entityBoardHero, otherHero);\r\n\t\t\t// TODO: here the MadMatador is the source of the damage, not the initial attacker\r\n\t\t\t// Not sure exactly what the impact would be, as there is no counter\r\n\t\t\tconst newSource = {\r\n\t\t\t\t...entity,\r\n\t\t\t\tattack: bumpInto.attack,\r\n\t\t\t\t// attacking: true,\r\n\t\t\t} as BoardEntity;\r\n\t\t\tconst defenderHadDivineShield = newTarget.divineShield;\r\n\t\t\tconst damageDone = bumpEntities(\r\n\t\t\t\tnewTarget,\r\n\t\t\t\tnewSource,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherHero,\r\n\t\t\t\tentityBoard,\r\n\t\t\t\tentityBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t\tif (newSource.attack > 0 && defenderHadDivineShield) {\r\n\t\t\t\tupdateDivineShield(newTarget, otherBoard, otherHero, entityBoardHero, false, gameState);\r\n\t\t\t}\r\n\t\t\tif (damageDone > 0) {\r\n\t\t\t\tonEntityDamaged(newTarget, otherBoard, otherHero, entityBoard, entityBoardHero, damageDone, gameState);\r\n\t\t\t}\r\n\t\t\treturn damageDone;\r\n\t\t}\r\n\t}\r\n\r\n\tif (entity.divineShield) {\r\n\t\tgameState.spectator.registerDamageDealt(bumpInto, entity, 0, entityBoard);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tconst damageDealt = (entity.damageMultiplier || 1) * bumpInto.attack;\r\n\tentity.health = entity.health - damageDealt;\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\tgameState.spectator.registerDamageDealt(bumpInto, entity, damageDealt, entityBoard);\r\n\r\n\tif (entity.cardId === CardIds.Bubblette_BG_TID_713 && bumpInto.attack === 1) {\r\n\t\tentity.definitelyDead = true;\r\n\t} else if (entity.cardId === CardIds.Bubblette_BG_TID_713_G && bumpInto.attack === 2) {\r\n\t\tentity.definitelyDead = true;\r\n\t}\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}\r\n\tif (bumpInto.venomous && applyVenomous) {\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\tupdateVenomous(bumpInto, false, otherBoard, otherHero, entityBoardHero, gameState);\r\n\t}\r\n\t// Ideally we should do the Reckoning stuff here. However, at this point we only have half the damage\r\n\t// information, so it is possible that the entity deals more than 3 (which should trigger Reckoning)\r\n\t// but dies during the exchange (and Reckoning doesn't trigger then)\r\n\r\n\tentity.lastAffectedByEntity = bumpInto;\r\n\t// if (entity.frenzyChargesLeft > 0 && entity.health > 0 && !entity.definitelyDead) {\r\n\t// \tapplyFrenzy(entity, entityBoard, entityBoardHero, gameState);\r\n\t// \tentity.frenzyChargesLeft--;\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\t// const 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// \tgameState.allCards,\r\n\t// \tgameState.cardsData,\r\n\t// \tgameState.sharedState,\r\n\t// \tgameState.spectator,\r\n\t// );\r\n\t// if (!!entitySpawns?.length) {\r\n\t// \t// Spawn to the right\r\n\t// \tconst index = entityBoard.map((e) => e.entityId).indexOf(entity.entityId) + 1;\r\n\t// \taddMinionsToBoard(entityBoard, entityBoardHero, otherHero, index, entitySpawns, gameState);\r\n\t// \tgameState.spectator.registerMinionsSpawn(entity, entityBoard, entitySpawns);\r\n\t// }\r\n\treturn bumpInto.attack;\r\n};\r\n\r\n// const 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_BRM_006) {\r\n// \t\treturn spawnEntities(\r\n// \t\t\tCardIds.ImpGangBoss_ImpToken_BRM_006t,\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.ImpGangBoss_TB_BaconUps_030) {\r\n// \t\treturn spawnEntities(\r\n// \t\t\tCardIds.ImpGangBoss_ImpToken_TB_BaconUps_030t,\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_BGS_044) {\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.ImpMama_TB_BaconUps_116) {\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_BOT_218) {\r\n// \t\treturn spawnEntities(\r\n// \t\t\tCardIds.SecurityRover_GuardBotToken_BOT_218t,\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.SecurityRover_TB_BaconUps_041) {\r\n// \t\treturn spawnEntities(\r\n// \t\t\tCardIds.SecurityRover_GuardBotToken_TB_BaconUps_041t,\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\tgameState: FullGameState,\r\n\t// When we're in an \"attack immediately\" phase, we wait until we're out of the phase to summon minions\r\n\tskipSummonWhenSpace = false,\r\n): void => {\r\n\t// const debug = board1.some((e) => e.health <= 0) || board2.some((e) => e.health <= 0);\r\n\t// debug && console.debug('\\nprocessing minions death');\r\n\t// debug && console.debug(stringifySimple(board1, gameState.allCards));\r\n\t// debug && console.debug(stringifySimple(board2, gameState.allCards));\r\n\tconst [deadMinionIndexesFromLeft1, deadMinionIndexesFromRights1, deadEntities1] = makeMinionsDie(\r\n\t\tboard1,\r\n\t\tboard1Hero,\r\n\t\tboard2,\r\n\t\tboard2Hero,\r\n\t\tgameState,\r\n\t);\r\n\tconst [deadMinionIndexesFromLeft2, deadMinionIndexesFromRights2, deadEntities2] = makeMinionsDie(\r\n\t\tboard2,\r\n\t\tboard2Hero,\r\n\t\tboard1,\r\n\t\tboard1Hero,\r\n\t\tgameState,\r\n\t);\r\n\t// debug && console.debug('after processing minions death');\r\n\t// debug && console.debug(stringifySimple(board1, gameState.allCards));\r\n\t// debug && console.debug(stringifySimple(board2, gameState.allCards));\r\n\t// debug && console.debug(deadMinionIndexesFromRights1);\r\n\t// debug && console.debug(deadMinionIndexesFromRights2);\r\n\t// console.debug('dead entities', stringifySimple(deadEntities1, allCards), stringifySimple(deadEntities2, allCards));\r\n\t// No death to process, we can return\r\n\tif (deadEntities1.length === 0 && deadEntities2.length === 0) {\r\n\t\treturn;\r\n\t\t// return [board1, board2];\r\n\t}\r\n\r\n\t// Remember them right away, so that subsequent deaths do not break the order\r\n\t// TODO: move this to the deathrattle-orchestration?\r\n\t// If the fish dies (from Scallywag for instance), it doesn't remember the deathrattle\r\n\t// console.debug(\r\n\t// \t'\\n\\ndeadEntities',\r\n\t// \tstringifySimple(deadEntities1, gameState.allCards),\r\n\t// \tstringifySimple(deadEntities2, gameState.allCards),\r\n\t// );\r\n\tboard1\r\n\t\t.filter((entity) => isFish(entity))\r\n\t\t.forEach((entity) =>\r\n\t\t\trememberDeathrattles(entity, deadEntities1, gameState.cardsData, gameState.allCards, gameState.sharedState),\r\n\t\t);\r\n\tboard2\r\n\t\t.filter((entity) => isFish(entity))\r\n\t\t.forEach((entity) =>\r\n\t\t\trememberDeathrattles(entity, deadEntities2, gameState.cardsData, gameState.allCards, gameState.sharedState),\r\n\t\t);\r\n\r\n\tgameState.spectator.registerDeadEntities(\r\n\t\tdeadMinionIndexesFromRights1,\r\n\t\tdeadEntities1,\r\n\t\tboard1,\r\n\t\tdeadMinionIndexesFromRights2,\r\n\t\tdeadEntities2,\r\n\t\tboard2,\r\n\t);\r\n\tgameState.sharedState.deaths.push(\r\n\t\t...deadEntities1.map((e, index) =>\r\n\t\t\taddImpliedMechanics(\r\n\t\t\t\t{\r\n\t\t\t\t\t...e,\r\n\t\t\t\t\thealth: e.maxHealth,\r\n\t\t\t\t\tdefinitelyDead: false,\r\n\t\t\t\t\tindexFromLeftAtTimeOfDeath: deadMinionIndexesFromLeft1[index],\r\n\t\t\t\t},\r\n\t\t\t\tgameState.cardsData,\r\n\t\t\t),\r\n\t\t),\r\n\t);\r\n\tgameState.sharedState.deaths.push(\r\n\t\t...deadEntities2.map((e, index) =>\r\n\t\t\taddImpliedMechanics(\r\n\t\t\t\t{\r\n\t\t\t\t\t...e,\r\n\t\t\t\t\thealth: e.maxHealth,\r\n\t\t\t\t\tdefinitelyDead: false,\r\n\t\t\t\t\tindexFromLeftAtTimeOfDeath: deadMinionIndexesFromLeft2[index],\r\n\t\t\t\t},\r\n\t\t\t\tgameState.cardsData,\r\n\t\t\t),\r\n\t\t),\r\n\t);\r\n\r\n\tfor (const deadEntity of deadEntities1) {\r\n\t\tconst onDeathImpl = cardMappings[deadEntity.cardId];\r\n\t\tif (hasOnDeath(onDeathImpl)) {\r\n\t\t\tonDeathImpl.onDeath(deadEntity, {\r\n\t\t\t\thero: board1Hero,\r\n\t\t\t\tboard: board1,\r\n\t\t\t\tgameState: gameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\tfor (const deadEntity of deadEntities2) {\r\n\t\tconst onDeathImpl = cardMappings[deadEntity.cardId];\r\n\t\tif (hasOnDeath(onDeathImpl)) {\r\n\t\t\tonDeathImpl.onDeath(deadEntity, {\r\n\t\t\t\thero: board2Hero,\r\n\t\t\t\tboard: board2,\r\n\t\t\t\tgameState: gameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tboard1Hero.globalInfo.EternalKnightsDeadThisGame =\r\n\t\tboard1Hero.globalInfo.EternalKnightsDeadThisGame +\r\n\t\tdeadEntities1.filter(\r\n\t\t\t(e) => e.cardId === CardIds.EternalKnight_BG25_008 || e.cardId === CardIds.EternalKnight_BG25_008_G,\r\n\t\t).length;\r\n\tboard2Hero.globalInfo.EternalKnightsDeadThisGame =\r\n\t\tboard2Hero.globalInfo.EternalKnightsDeadThisGame +\r\n\t\tdeadEntities2.filter(\r\n\t\t\t(e) => e.cardId === CardIds.EternalKnight_BG25_008 || e.cardId === CardIds.EternalKnight_BG25_008_G,\r\n\t\t).length;\r\n\r\n\torchestrateMinionDeathEffects({\r\n\t\tgameState: gameState,\r\n\t\tplayerDeadEntities: board1Hero.friendly ? deadEntities1 : deadEntities2,\r\n\t\tplayerDeadEntityIndexesFromRight: board1Hero.friendly\r\n\t\t\t? deadMinionIndexesFromRights1\r\n\t\t\t: deadMinionIndexesFromRights2,\r\n\t\topponentDeadEntities: board1Hero.friendly ? deadEntities2 : deadEntities1,\r\n\t\topponentDeadEntityIndexesFromRight: board1Hero.friendly\r\n\t\t\t? deadMinionIndexesFromRights2\r\n\t\t\t: deadMinionIndexesFromRights1,\r\n\t});\r\n\r\n\tboard1\r\n\t\t.filter(\r\n\t\t\t(entity) =>\r\n\t\t\t\tentity.cardId === CardIds.Monstrosity_BG20_HERO_282_Buddy ||\r\n\t\t\t\tentity.cardId === CardIds.Monstrosity_BG20_HERO_282_Buddy_G,\r\n\t\t)\r\n\t\t.forEach((entity) => applyMonstrosity(entity, deadEntities1, board1, board1Hero, gameState));\r\n\tboard2\r\n\t\t.filter(\r\n\t\t\t(entity) =>\r\n\t\t\t\tentity.cardId === CardIds.Monstrosity_BG20_HERO_282_Buddy ||\r\n\t\t\t\tentity.cardId === CardIds.Monstrosity_BG20_HERO_282_Buddy_G,\r\n\t\t)\r\n\t\t.forEach((entity) => applyMonstrosity(entity, deadEntities2, board2, board2Hero, gameState));\r\n\r\n\t// Make sure we only return when there are no more deaths to process\r\n\t// Make sure to do this right before the end of the 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, gameState);\r\n\r\n\t// Not sure about the timing here, but I have bothered Mitchell quite a lot already recently :)\r\n\tif (!skipSummonWhenSpace) {\r\n\t\thandleSummonsWhenSpace(board1, board1Hero, board2, board2Hero, gameState);\r\n\t}\r\n\r\n\t// Apply \"after minion death\" effects\r\n\thandleAfterMinionsDeaths(board1, deadEntities1, board1Hero, board2, deadEntities2, board2Hero, gameState);\r\n};\r\n\r\nconst handleAfterMinionsDeaths = (\r\n\tboard1: BoardEntity[],\r\n\tdeadEntities1: BoardEntity[],\r\n\theroEntity1: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tdeadEntities2: BoardEntity[],\r\n\theroEntity2: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst random = Math.random() > 0.5;\r\n\thandleAfterMinionsDeathsForBoard(\r\n\t\trandom ? board1 : board2,\r\n\t\trandom ? deadEntities1 : deadEntities2,\r\n\t\trandom ? heroEntity1 : heroEntity2,\r\n\t\trandom ? board2 : board1,\r\n\t\trandom ? deadEntities2 : deadEntities1,\r\n\t\trandom ? heroEntity2 : heroEntity1,\r\n\t\tgameState,\r\n\t);\r\n\thandleAfterMinionsDeathsForBoard(\r\n\t\t!random ? board1 : board2,\r\n\t\t!random ? deadEntities1 : deadEntities2,\r\n\t\t!random ? heroEntity1 : heroEntity2,\r\n\t\t!random ? board2 : board1,\r\n\t\t!random ? deadEntities2 : deadEntities1,\r\n\t\t!random ? heroEntity2 : heroEntity1,\r\n\t\tgameState,\r\n\t);\r\n};\r\n\r\nconst handleAfterMinionsDeathsForBoard = (\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyDeadEntities: BoardEntity[],\r\n\tfriendlyHeroEntity: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherDeadEntities: BoardEntity[],\r\n\totherHeroEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst candidateEntities = [];\r\n\tlet secretTriggered = null;\r\n\tif (\r\n\t\t(secretTriggered = friendlyHeroEntity.secrets?.find(\r\n\t\t\t(secret) => !secret.triggered && secret?.cardId === CardIds.MagicBlackSoulstone,\r\n\t\t)) != null\r\n\t) {\r\n\t\tif (friendlyBoard.length === 0) {\r\n\t\t\tsecretTriggered.triggered = true;\r\n\t\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\t\tconst toSummon = pickRandom(gameState.cardsData.demonSpawns);\r\n\t\t\t\tcandidateEntities.push(\r\n\t\t\t\t\t...spawnEntities(\r\n\t\t\t\t\t\ttoSummon,\r\n\t\t\t\t\t\t1,\r\n\t\t\t\t\t\tfriendlyBoard,\r\n\t\t\t\t\t\tfriendlyHeroEntity,\r\n\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\totherHeroEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\tfriendlyHeroEntity.friendly,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t),\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tperformEntitySpawns(\r\n\t\tcandidateEntities,\r\n\t\tfriendlyBoard,\r\n\t\tfriendlyHeroEntity,\r\n\t\tsecretTriggered,\r\n\t\t0,\r\n\t\totherBoard,\r\n\t\totherHeroEntity,\r\n\t\tgameState,\r\n\t);\r\n};\r\n\r\nexport interface OnDeathInput {\r\n\treadonly hero: BgsPlayerEntity;\r\n\treadonly board: readonly BoardEntity[];\r\n\treadonly gameState: FullGameState;\r\n}\r\nexport interface OnMinionKilledInput {\r\n\treadonly minionKilled: BoardEntity;\r\n\treadonly attackingHero: BgsPlayerEntity;\r\n\treadonly attackingBoard: BoardEntity[];\r\n\treadonly defendingHero: BgsPlayerEntity;\r\n\treadonly defendingBoard: BoardEntity[];\r\n\treadonly defenderNeighbours: readonly BoardEntity[];\r\n\treadonly gameState: FullGameState;\r\n\treadonly playerIsFriendly: boolean;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"attack.js","sourceRoot":"","sources":["../../src/simulation/attack.ts"],"names":[],"mappings":";;;AACA,iEAA8E;AAG9E,4DAAqD;AACrD,iEAA4D;AAC5D,gDAA4C;AAC5C,6DAA+D;AAC/D,mDAAsD;AACtD,6CAAgE;AAChE,oCAAwE;AACxE,iDAAyD;AACzD,qDAAmD;AACnD,+DAA+E;AAC/E,2EAA4E;AAC5E,6DAAqD;AAErD,iDAAgD;AAChD,+CAA6C;AAC7C,2CAAmD;AACnD,2DAAgE;AAChE,qCAA+C;AAC/C,mCAAgD;AAChD,2DAA6D;AAC7D,uDAAiD;AAG1C,MAAM,cAAc,GAAG,CAC7B,cAA6B,EAC7B,kBAAmC,EACnC,cAA6B,EAC7B,kBAAmC,EACnC,SAAwB,EACV,EAAE;IAOhB,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;QAC/D,OAAO;KACP;IAED,MAAM,eAAe,GAAG,kBAAkB,CAAC,cAAc,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC/E,IAAI,eAAe,EAAE;QACpB,SAAS,CAAC,WAAW,CAAC,uBAAuB,GAAG,eAAe,CAAC,QAAQ,CAAC;QAGzE,MAAM,oBAAoB,GAAG,cAAc,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QACrE,MAAM,0BAA0B,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,oBAAoB,CAAC,C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AAS,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;gBAC7D,iBAAiB,CAAC,IAAI,CACrB,GAAG,IAAA,kCAAa,EACf,QAAQ,EACR,CAAC,EACD,aAAa,EACb,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,SAAS,EACT,kBAAkB,CAAC,QAAQ,EAC3B,KAAK,CACL,CACD,CAAC;aACF;SACD;KACD;IACD,IAAA,4BAAmB,EAClB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,CAAC,EACD,UAAU,EACV,eAAe,EACf,SAAS,CACT,CAAC;AACH,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 { hasOnDeath } from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { debugState } from '../debug-state';\r\nimport { updateDivineShield } from '../keywords/divine-shield';\r\nimport { updateVenomous } from '../keywords/venomous';\r\nimport { groupByFunction, pickRandom } from '../services/utils';\r\nimport { addImpliedMechanics, hasCorrectTribe, isFish } from '../utils';\r\nimport { applyAfterAttackEffects } from './after-attack';\r\nimport { onEntityDamaged } from './damage-effects';\r\nimport { applyMonstrosity, rememberDeathrattles } from './deathrattle-effects';\r\nimport { orchestrateMinionDeathEffects } from './deathrattle-orchestration';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { makeMinionsDie } from './minion-death';\r\nimport { onMinionKill } from './minion-kill';\r\nimport { applyOnAttackEffects } from './on-attack';\r\nimport { applyOnBeingAttackedBuffs } from './on-being-attacked';\r\nimport { performEntitySpawns } from './spawns';\r\nimport { applyAfterStatsUpdate } from './stats';\r\nimport { handleSummonsWhenSpace } from './summon-when-space';\r\nimport { canAttack } from './utils/entity-utils';\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\tgameState: FullGameState,\r\n): BoardEntity => {\r\n\t// console.debug(\r\n\t// \t'\\nsimulating attack',\r\n\t// \tstringifySimple(attackingBoard, gameState.allCards),\r\n\t// \t'\\n',\r\n\t// \tstringifySimple(defendingBoard, gameState.allCards),\r\n\t// );\r\n\tif (attackingBoard.length === 0 || defendingBoard.length === 0) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst attackingEntity = getAttackingEntity(attackingBoard, gameState.allCards);\r\n\tif (attackingEntity) {\r\n\t\tgameState.sharedState.currentAttackerEntityId = attackingEntity.entityId;\r\n\t\t// Get the left entities now, otherwise things might break if the attacker dies and/or other\r\n\t\t// entities pop\r\n\t\tconst attackingEntityIndex = attackingBoard.indexOf(attackingEntity);\r\n\t\tconst attackingEntitiesToTheLeft = attackingBoard.slice(0, attackingEntityIndex);\r\n\t\tconst isAttackingImmediately = attackingEntity.attackImmediately;\r\n\t\t// In case of Broodmother spawn, it spawns where the dead minion was, and has no influence on the\r\n\t\t// attack order\r\n\t\t// Situation this is trying to resolve by putting this right at the top of the loop:\r\n\t\t// - One scallywag attacks into another one, both die\r\n\t\t// - The first one attacks. To its left is a Harmless Bonehead with 1 HP. The scallywag attacks, and both scallys die\r\n\t\t// - The *other* sky pirate attacks first, and kills the bonehead. Two minions are spawned\r\n\t\t// - The first sy pirate attacks\r\n\t\t// - The initial loop is resolved. If this is at the end, the Harmless Bonehead is already dead, and not flagged\r\n\t\t// While having this right away, we immediately flag all minions to the left\r\n\t\tif (!isAttackingImmediately) {\r\n\t\t\t// Make sure they won't be able to attack until everyone has attacked\r\n\t\t\t// See http://replays.firestoneapp.com/?reviewId=a1b3066d-e806-44c1-ab4b-7ef9dbf9b5b9&turn=5&action=4\r\n\t\t\tattackingEntitiesToTheLeft.forEach((entity) => (entity.hasAttacked = 2));\r\n\t\t}\r\n\r\n\t\tconst numberOfAttacks = 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\t// We still want to flag the entity as having attacked, so that it doesn't attack again\r\n\t\t\t\t// after teammate switch in Duos\r\n\t\t\t\tbreak;\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\tconst defendingEntity: BoardEntity = getDefendingEntity(defendingBoard, attackingEntity);\r\n\t\t\t\t// Can happen with a single defender that has stealth\r\n\t\t\t\tif (defendingEntity) {\r\n\t\t\t\t\tdoFullAttack(\r\n\t\t\t\t\t\tattackingEntity,\r\n\t\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t} else {\r\n\t\t\t\t\t// Solves the edge case of Sky Pirate vs a stealth board\r\n\t\t\t\t\tattackingEntity.attackImmediately = false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tgameState.sharedState.currentAttackerEntityId = null;\r\n\t\tattackingEntity.hasAttacked = 1;\r\n\t}\r\n\treturn attackingEntity;\r\n};\r\n\r\nexport const doFullAttack = (\r\n\tattackingEntity: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingEntity: BoardEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst isAttackingImmediately = attackingEntity.attackImmediately;\r\n\tgameState.spectator.registerAttack(\r\n\t\tattackingEntity,\r\n\t\tdefendingEntity,\r\n\t\tattackingBoard,\r\n\t\tdefendingBoard,\r\n\t\tattackingBoardHero,\r\n\t\tdefendingBoardHero,\r\n\t);\r\n\t// http://replays.firestoneapp.com/?reviewId=50576a9f-2e6a-4600-87ba-6e737ca9853e&turn=21&action=4\r\n\t// Looks like onBeingAttacked effects apply before onAttack effects\r\n\tapplyOnBeingAttackedBuffs(\r\n\t\tattackingEntity,\r\n\t\tattackingBoard,\r\n\t\tattackingBoardHero,\r\n\t\tdefendingEntity,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\tgameState,\r\n\t);\r\n\tconst { damageDoneByAttacker: damageDoneByAttacker1, damageDoneByDefender: damageDoneByDefender1 } =\r\n\t\tapplyOnAttackEffects(\r\n\t\t\tattackingEntity,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingEntity,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\tconst { damageDoneByAttacker: damageDoneByAttacker2, damageDoneByDefender: damageDoneByDefender2 } = performAttack(\r\n\t\tattackingEntity,\r\n\t\tdefendingEntity,\r\n\t\tattackingBoard,\r\n\t\tattackingBoardHero,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\tgameState,\r\n\t);\r\n\tconst damageDoneByAttacker = damageDoneByAttacker1 + damageDoneByAttacker2;\r\n\tconst damageDoneByDefender = damageDoneByDefender1 + damageDoneByDefender2;\r\n\tapplyAfterAttackEffects(\r\n\t\tattackingEntity,\r\n\t\tattackingBoard,\r\n\t\tattackingBoardHero,\r\n\t\tdefendingEntity,\r\n\t\tdefendingBoardHero,\r\n\t\tdamageDoneByAttacker,\r\n\t\tdamageDoneByDefender,\r\n\t\tgameState,\r\n\t);\r\n\r\n\tprocessMinionDeath(\r\n\t\tattackingBoard,\r\n\t\tattackingBoardHero,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\tgameState,\r\n\t\tisAttackingImmediately,\r\n\t);\r\n\tapplyAfterStatsUpdate(gameState);\r\n\tattackingEntity.immuneWhenAttackCharges = Math.max(0, (attackingEntity.immuneWhenAttackCharges ?? 0) - 1);\r\n\tif (\r\n\t\tdefendingEntity.health > 0 &&\r\n\t\t!defendingEntity.definitelyDead &&\r\n\t\t(defendingEntity.cardId === CardIds.YoHoOgre_BGS_060 ||\r\n\t\t\tdefendingEntity.cardId === CardIds.YoHoOgre_TB_BaconUps_150)\r\n\t) {\r\n\t\tdefendingEntity.attackImmediately = true;\r\n\t\tif (defendingEntity.attackImmediately) {\r\n\t\t\tsimulateAttack(defendingBoard, defendingBoardHero, attackingBoard, attackingBoardHero, gameState);\r\n\t\t}\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\tgameState: FullGameState,\r\n): { damageDoneByAttacker: number; damageDoneByDefender: number } => {\r\n\tlet damageDoneByAttacker = 0;\r\n\tlet damageDoneByDefender = 0;\r\n\r\n\tif (hasCorrectTribe(attackingEntity, attackingBoardHero, Race.DRAGON, gameState.anomalies, gameState.allCards)) {\r\n\t\tconst prestors = attackingBoard\r\n\t\t\t.filter((e) => e.entityId !== attackingEntity.entityId)\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId === CardIds.PrestorsPyrospawn_BG21_012 ||\r\n\t\t\t\t\te.cardId === CardIds.PrestorsPyrospawn_BG21_012_G,\r\n\t\t\t);\r\n\t\tprestors.forEach((prestor) => {\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tprestor,\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t);\r\n\t\t\tdamageDoneByAttacker += dealDamageToMinion(\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.PrestorsPyrospawn_BG21_012_G ? 6 : 3,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\tif (\r\n\t\tattackingEntity.cardId === CardIds.Atramedes_BG23_362 ||\r\n\t\tattackingEntity.cardId === CardIds.Atramedes_BG23_362_G\r\n\t) {\r\n\t\tconst targets = [defendingEntity, ...getNeighbours(defendingBoard, defendingEntity)];\r\n\t\tconst multiplier = attackingEntity.cardId === CardIds.Atramedes_BG23_362_G ? 2 : 1;\r\n\r\n\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\ttargets.forEach((target) => {\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattackingEntity,\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t);\r\n\t\t\t\tdamageDoneByAttacker += dealDamageToMinion(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tattackingEntity,\r\n\t\t\t\t\t3,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t\t}\r\n\t} else if ([CardIds.BabyKrush_BG22_001, CardIds.BabyKrush_BG22_001_G].includes(attackingEntity.cardId as CardIds)) {\r\n\t\tconst spawns = spawnEntities(\r\n\t\t\tattackingEntity.cardId === CardIds.BabyKrush_BG22_001_G\r\n\t\t\t\t? CardIds.BabyKrush_BG22_001_G\r\n\t\t\t\t: CardIds.BabyKrush_DevilsaurToken,\r\n\t\t\t1,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tgameState,\r\n\t\t\ttrue,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t\tif (spawns.length > 0) {\r\n\t\t\tconst sourceIndex = attackingBoard.indexOf(attackingEntity);\r\n\t\t\tconst actualSpawns = performEntitySpawns(\r\n\t\t\t\tspawns,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tsourceIndex,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tfor (const actualSpawn of actualSpawns) {\r\n\t\t\t\tif (defendingEntity.health > 0 && !defendingEntity.definitelyDead) {\r\n\t\t\t\t\tperformAttack(\r\n\t\t\t\t\t\tactualSpawn,\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// For Prestor\r\n\tconst defenderAliveBeforeAttack = defendingEntity.health > 0 && !defendingEntity.definitelyDead;\r\n\t// Because of Bristleback Knight, which changes its divine shield status during bumpEntities\r\n\tconst attackerHadDivineShield = attackingEntity.divineShield;\r\n\tconst defenderHadDivineShield = defendingEntity.divineShield;\r\n\t// For cleave\r\n\t// We do that now so that we don't include entities that spawn on entity damaged\r\n\tconst defenderNeighbours: readonly BoardEntity[] = getNeighbours(defendingBoard, defendingEntity);\r\n\tif (defenderAliveBeforeAttack) {\r\n\t\tif (!attackingEntity.immuneWhenAttackCharges) {\r\n\t\t\t// TODO: this bumpEntities approach doesn't work well, as it leads to code duplication\r\n\t\t\tdamageDoneByDefender += bumpEntities(\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t\tdamageDoneByAttacker += bumpEntities(\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\tgameState,\r\n\t\t);\r\n\t\tif (defendingEntity.attack > 0 && attackerHadDivineShield && !attackingEntity.immuneWhenAttackCharges) {\r\n\t\t\tupdateDivineShield(\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tfalse,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t\tif (attackingEntity.attack > 0 && defenderHadDivineShield) {\r\n\t\t\tupdateDivineShield(\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tfalse,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t\t// Do it after the damage has been done, so that entities that update on DS lose / gain (CyborgDrake) don't\r\n\t\t// cause wrong results to happen\r\n\t\t// This whole logic is a MEEEEESSSSSSSSSSSSSSS\r\n\t\tif (damageDoneByDefender > 0) {\r\n\t\t\tonEntityDamaged(\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\tdamageDoneByDefender,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t\tif (damageDoneByAttacker > 0) {\r\n\t\t\tonEntityDamaged(\r\n\t\t\t\tdefendingEntity,\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\tdamageDoneByAttacker,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tif (defendingEntity.health <= 0 || defendingEntity.definitelyDead) {\r\n\t\t\tconst { dmgDoneByAttacker, dmgDoneByDefender } = onMinionKill(\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tdefenderNeighbours,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tdamageDoneByAttacker += dmgDoneByAttacker;\r\n\t\t\tdamageDoneByDefender += dmgDoneByDefender;\r\n\t\t}\r\n\t\tif (attackingEntity.health <= 0 || attackingEntity.definitelyDead) {\r\n\t\t\tconst { dmgDoneByAttacker, dmgDoneByDefender } = onMinionKill(\r\n\t\t\t\tdefendingEntity,\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\tdefenderNeighbours,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tdamageDoneByAttacker += dmgDoneByAttacker;\r\n\t\t\tdamageDoneByDefender += dmgDoneByDefender;\r\n\t\t}\r\n\t}\r\n\t// Cleave\r\n\tif (attackingEntity.cleave) {\r\n\t\tfor (const neighbour of defenderNeighbours) {\r\n\t\t\tconst thisAttackDamage = bumpEntities(\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\tgameState,\r\n\t\t\t);\r\n\t\t\tdamageDoneByAttacker += thisAttackDamage;\r\n\t\t\t// Do it after the damage has been done, so that entities that update on DS lose / gain (CyborgDrake) don't\r\n\t\t\t// cause wrong results to happen\r\n\t\t\tif (attackingEntity.attack > 0 && neighbour.divineShield) {\r\n\t\t\t\tupdateDivineShield(neighbour, defendingBoard, defendingBoardHero, attackingBoardHero, false, gameState);\r\n\t\t\t}\r\n\t\t\tif (thisAttackDamage > 0) {\r\n\t\t\t\tonEntityDamaged(\r\n\t\t\t\t\tneighbour,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tthisAttackDamage,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t\tif (neighbour.health <= 0 || neighbour.definitelyDead) {\r\n\t\t\t\tconst { dmgDoneByAttacker, dmgDoneByDefender } = onMinionKill(\r\n\t\t\t\t\tattackingEntity,\r\n\t\t\t\t\tneighbour,\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\tdefenderNeighbours,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t\tdamageDoneByAttacker += dmgDoneByAttacker;\r\n\t\t\t\tdamageDoneByDefender += dmgDoneByDefender;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tattackingEntity.attackImmediately = false;\r\n\tif (attackingEntity.enchantments.some((e) => e.cardId === CardIds.VolatileVenom_VolatileEnchantment)) {\r\n\t\tattackingEntity.definitelyDead = true;\r\n\t}\r\n\treturn { damageDoneByAttacker, damageDoneByDefender };\r\n};\r\n\r\n// TODO: Could it be possible to store the index of the entity that last attacked? Probably not, because minion\r\n// spawns would mess this up? Could we update the indexes as each entity spawns / dies?\r\nconst getAttackingEntity = (attackingBoard: BoardEntity[], allCards: AllCardsService): BoardEntity => {\r\n\tlet validAttackers = attackingBoard.filter((entity) => canAttack(entity));\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} else if (validAttackers.every((e) => e.hasAttacked)) {\r\n\t\tattackingBoard.forEach((e) => (e.hasAttacked = 0));\r\n\t} else {\r\n\t\tvalidAttackers = validAttackers.filter((entity) => !entity.hasAttacked);\r\n\t}\r\n\tconst attacker = validAttackers[0];\r\n\treturn attacker;\r\n};\r\n\r\nexport const findNearestEnemies = (\r\n\tattackingBoard: BoardEntity[],\r\n\tentity: BoardEntity,\r\n\tentityIndexFromRight: number,\r\n\tdefendingBoard: BoardEntity[],\r\n\tnumberOfTargets: number,\r\n\tallCards: AllCardsService,\r\n): BoardEntity[] => {\r\n\tconst result = [];\r\n\tif (defendingBoard.length > 0) {\r\n\t\t// console.debug('defending board', numberOfTargets, stringifySimple(defendingBoard, allCards));\r\n\t\tconst attackerIndex = attackingBoard.length - entityIndexFromRight - 1;\r\n\t\tconst targetIndex = attackerIndex - (attackingBoard.length - defendingBoard.length) / 2;\r\n\t\t// console.debug('indexes', attackerIndex, entityIndexFromRight, targetIndex, attackingBoard.length);\r\n\r\n\t\tfor (let i = 0; i < numberOfTargets; i++) {\r\n\t\t\tconst possibleTargets = defendingBoard\r\n\t\t\t\t.filter((e) => !e.definitelyDead && e.health > 0)\r\n\t\t\t\t.filter((e) => !result.includes(e));\r\n\t\t\t// console.debug('possibleTargets', stringifySimple(possibleTargets, allCards));\r\n\t\t\tif (!possibleTargets.length) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tconst targetGroups = groupByFunction((e: BoardEntity) => Math.abs(defendingBoard.indexOf(e) - targetIndex))(\r\n\t\t\t\tpossibleTargets,\r\n\t\t\t);\r\n\t\t\tconst distances = Object.keys(targetGroups)\r\n\t\t\t\t.map((k) => +k)\r\n\t\t\t\t.sort();\r\n\t\t\tconst nearestDistance = distances[0];\r\n\t\t\tif (nearestDistance != null) {\r\n\t\t\t\t// console.debug(\r\n\t\t\t\t// \t'targetGroups[nearestDistance]',\r\n\t\t\t\t// \tnearestDistance,\r\n\t\t\t\t// \tstringifySimple(targetGroups[nearestDistance], allCards),\r\n\t\t\t\t// );\r\n\t\t\t\tconst target = pickRandom(targetGroups[nearestDistance]);\r\n\t\t\t\tresult.push(target);\r\n\t\t\t}\r\n\t\t\t// console.debug('\\n');\r\n\t\t}\r\n\t}\r\n\treturn result.filter((e) => !!e);\r\n};\r\n\r\nexport const getNeighbours = (\r\n\tboard: BoardEntity[],\r\n\tentity: BoardEntity,\r\n\tdeadEntityIndexFromRight?: number,\r\n): readonly BoardEntity[] => {\r\n\tconst neighbours = [];\r\n\t// When triggering DR with Hawkstrider, the entity is still on the board\r\n\tif (deadEntityIndexFromRight != null && !board.includes(entity)) {\r\n\t\tconst leftNeighbourIndex = board.length - 1 - deadEntityIndexFromRight;\r\n\t\tconst leftNeighbour = board[leftNeighbourIndex];\r\n\t\tif (leftNeighbour) {\r\n\t\t\tneighbours.push(leftNeighbour);\r\n\t\t}\r\n\r\n\t\t// If the deadEntityIndexFromRight === 0 (right-most minion), no neighbour will be found\r\n\t\tconst rightNeighbourIndex = board.length - 1 - (deadEntityIndexFromRight - 1);\r\n\t\tconst rightNeighbour = board[rightNeighbourIndex];\r\n\t\tif (rightNeighbour) {\r\n\t\t\tneighbours.push(rightNeighbour);\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 getLeftNeighbour = (\r\n\tboard: BoardEntity[],\r\n\tentity: BoardEntity,\r\n\tdeadEntityIndexFromRight?: number,\r\n): BoardEntity => {\r\n\t// When triggering DR with Hawkstrider, the entity is still on the board\r\n\tif (deadEntityIndexFromRight != null && !board.includes(entity)) {\r\n\t\tconst leftNeighbourIndex = board.length - 1 - deadEntityIndexFromRight;\r\n\t\tconst leftNeighbour = board[leftNeighbourIndex];\r\n\t\tif (leftNeighbour) {\r\n\t\t\treturn leftNeighbour;\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\treturn board[index - 1];\r\n\t\t}\r\n\t}\r\n\treturn null;\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\tgameState: FullGameState,\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\tgameState.spectator.registerPowerTarget(\r\n\t\t\tdamageSource,\r\n\t\t\tdefendingEntity,\r\n\t\t\tboardToBeDamaged,\r\n\t\t\tboardToBeDamagedHero,\r\n\t\t\tboardWithAttackOriginHero,\r\n\t\t);\r\n\t\tdealDamageToMinion(\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\tgameState,\r\n\t\t);\r\n\t}\r\n};\r\n\r\nexport const dealDamageToMinion = (\r\n\ttarget: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tdamageSource: BoardEntity,\r\n\tdamage: number,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\t// console.log('dealing damage to', damage, stringifySimpleCard(defendingEntity, allCards));\r\n\tif (!target) {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tconst isDeadBeforeDamage = target.definitelyDead || target.health <= 0;\r\n\tconst spawns = [];\r\n\t// Why do we use a fakeAttacker? Is that for the \"attacking\" prop?\r\n\t// That prop is only used for Overkill, and even in that case it looks like it would work\r\n\t// without it\r\n\tconst fakeAttacker = {\r\n\t\t...(damageSource || {}),\r\n\t\tentityId: -1,\r\n\t\tattack: damage,\r\n\t\t// attacking: true,\r\n\t} as BoardEntity;\r\n\tconst actualDamageDone = bumpEntities(target, fakeAttacker, board, hero, otherBoard, otherHero, gameState);\r\n\r\n\t// Do it after the damage has been done, so that entities that update on DS lose / gain (CyborgDrake) don't\r\n\t// cause wrong results to happen\r\n\t// TODO: why isn't it done in bumpEntities?\r\n\t// Because of how \"bump\" works: we do it first for the attacker, then the defender, and we only want to update\r\n\t// the divine shield once both bumps are done\r\n\t// The problem is with the Frenzy: bumpEntities can trigger the frenzy, and which can act on the divine shield\r\n\tif (fakeAttacker.attack > 0 && target.divineShield) {\r\n\t\tupdateDivineShield(target, board, hero, otherHero, false, gameState);\r\n\t}\r\n\r\n\tif (actualDamageDone > 0) {\r\n\t\t// TODO: handle entities that have been spawned here to adjust the dead entity index from parent stack\r\n\t\tconst newSpawns = onEntityDamaged(target, board, hero, otherBoard, otherHero, actualDamageDone, gameState);\r\n\t}\r\n\tif (!isDeadBeforeDamage && actualDamageDone > 0) {\r\n\t\ttarget.lastAffectedByEntity = damageSource;\r\n\r\n\t\tif (target.health <= 0 || target.definitelyDead) {\r\n\t\t\tonMinionKill(damageSource, target, otherBoard, otherHero, board, hero, [], gameState);\r\n\t\t}\r\n\t}\r\n\tconst defendingEntityIndex = board.map((entity) => entity.entityId).indexOf(target.entityId);\r\n\tboard[defendingEntityIndex] = target;\r\n\treturn actualDamageDone;\r\n};\r\n\r\nexport const getDefendingEntity = (\r\n\tdefendingBoard: BoardEntity[],\r\n\tattackingEntity: BoardEntity,\r\n\tignoreTaunts = false,\r\n): BoardEntity => {\r\n\tif (debugState.active) {\r\n\t\tfor (const forcedFaceOff of debugState.forcedFaceOff) {\r\n\t\t\tif (debugState.isCorrectEntity(forcedFaceOff.attacker, attackingEntity))\r\n\t\t\t\tif (attackingEntity.entityId === forcedFaceOff.attacker.entityId) {\r\n\t\t\t\t\tlet def = null;\r\n\t\t\t\t\tif (!!(def = defendingBoard.find((e) => debugState.isCorrectEntity(forcedFaceOff.defender, e)))) {\r\n\t\t\t\t\t\t// Remove the face-off\r\n\t\t\t\t\t\tdebugState.forcedFaceOff = debugState.forcedFaceOff.filter((f) => f != forcedFaceOff);\r\n\t\t\t\t\t\treturn def;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t}\r\n\t}\r\n\t// if (attackingEntity.entityId === 4946) {\r\n\t// \tlet def = null;\r\n\t// \tif (!!(def = defendingBoard.find((e) => e.entityId === 7170))) {\r\n\t// \t\treturn def;\r\n\t// \t}\r\n\t// }\r\n\r\n\tlet possibleDefenders: readonly BoardEntity[];\r\n\tif (\r\n\t\tattackingEntity.cardId === CardIds.ZappSlywick_BGS_022 ||\r\n\t\tattackingEntity.cardId === CardIds.ZappSlywick_TB_BaconUps_091\r\n\t) {\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 (\r\n\t\tattackingEntity.cardId === CardIds.WorgenVigilante_BG26_921 ||\r\n\t\tattackingEntity.cardId === CardIds.WorgenVigilante_BG26_921_G\r\n\t) {\r\n\t\tpossibleDefenders = defendingBoard\r\n\t\t\t.filter(\r\n\t\t\t\t(entity) =>\r\n\t\t\t\t\tentity.health <= attackingEntity.attack || attackingEntity.venomous || attackingEntity.poisonous,\r\n\t\t\t)\r\n\t\t\t.filter((e) => !e.divineShield);\r\n\t\tif (!possibleDefenders.length) {\r\n\t\t\tpossibleDefenders = defendingBoard;\r\n\t\t}\r\n\t} else {\r\n\t\tpossibleDefenders = defendingBoard.filter((e) => !e.stealth);\r\n\t\tif (!ignoreTaunts) {\r\n\t\t\tconst taunts = possibleDefenders.filter((entity) => entity.taunt);\r\n\t\t\tpossibleDefenders = taunts.length > 0 ? taunts : possibleDefenders;\r\n\t\t}\r\n\t}\r\n\r\n\tlet chosenDefender = pickRandom(possibleDefenders);\r\n\tif (chosenDefender?.taunt) {\r\n\t\tconst elistras = defendingBoard.filter(\r\n\t\t\t(entity) =>\r\n\t\t\t\tentity.cardId === CardIds.ElistraTheImmortal_BGS_205 ||\r\n\t\t\t\tentity.cardId === CardIds.ElistraTheImmortal_TB_BaconUps_306,\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\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\tgameState: FullGameState,\r\n\tapplyVenomous = true,\r\n): number => {\r\n\t// No attack has no impact\r\n\tconst debug = bumpInto.cardId === 'BG26_888';\r\n\tif (bumpInto.attack === 0) {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\t// Matador effect has priority\r\n\tif (\r\n\t\tentity.abiityChargesLeft > 0 &&\r\n\t\t(entity.cardId === CardIds.MadMatador_BG28_404 || entity.cardId === CardIds.MadMatador_BG28_404_G)\r\n\t) {\r\n\t\tentity.abiityChargesLeft--;\r\n\t\tconst newTarget = pickRandom(otherBoard);\r\n\t\tif (newTarget) {\r\n\t\t\tgameState.spectator.registerPowerTarget(entity, newTarget, otherBoard, entityBoardHero, otherHero);\r\n\t\t\t// TODO: here the MadMatador is the source of the damage, not the initial attacker\r\n\t\t\t// Not sure exactly what the impact would be, as there is no counter\r\n\t\t\tconst newSource = {\r\n\t\t\t\t...entity,\r\n\t\t\t\tattack: bumpInto.attack,\r\n\t\t\t\t// attacking: true,\r\n\t\t\t} as BoardEntity;\r\n\t\t\tconst defenderHadDivineShield = newTarget.divineShield;\r\n\t\t\tconst damageDone = bumpEntities(\r\n\t\t\t\tnewTarget,\r\n\t\t\t\tnewSource,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherHero,\r\n\t\t\t\tentityBoard,\r\n\t\t\t\tentityBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t\tif (newSource.attack > 0 && defenderHadDivineShield) {\r\n\t\t\t\tupdateDivineShield(newTarget, otherBoard, otherHero, entityBoardHero, false, gameState);\r\n\t\t\t}\r\n\t\t\tif (damageDone > 0) {\r\n\t\t\t\tonEntityDamaged(newTarget, otherBoard, otherHero, entityBoard, entityBoardHero, damageDone, gameState);\r\n\t\t\t}\r\n\t\t\treturn damageDone;\r\n\t\t}\r\n\t}\r\n\r\n\tif (entity.divineShield) {\r\n\t\tgameState.spectator.registerDamageDealt(bumpInto, entity, 0, entityBoard);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tconst damageDealt = (entity.damageMultiplier || 1) * bumpInto.attack;\r\n\tentity.health = entity.health - damageDealt;\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\tgameState.spectator.registerDamageDealt(bumpInto, entity, damageDealt, entityBoard);\r\n\r\n\tif (entity.cardId === CardIds.Bubblette_BG_TID_713 && bumpInto.attack === 1) {\r\n\t\tentity.definitelyDead = true;\r\n\t} else if (entity.cardId === CardIds.Bubblette_BG_TID_713_G && bumpInto.attack === 2) {\r\n\t\tentity.definitelyDead = true;\r\n\t}\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}\r\n\tif (bumpInto.venomous && applyVenomous) {\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\tupdateVenomous(bumpInto, false, otherBoard, otherHero, entityBoardHero, gameState);\r\n\t}\r\n\t// Ideally we should do the Reckoning stuff here. However, at this point we only have half the damage\r\n\t// information, so it is possible that the entity deals more than 3 (which should trigger Reckoning)\r\n\t// but dies during the exchange (and Reckoning doesn't trigger then)\r\n\r\n\tentity.lastAffectedByEntity = bumpInto;\r\n\t// if (entity.frenzyChargesLeft > 0 && entity.health > 0 && !entity.definitelyDead) {\r\n\t// \tapplyFrenzy(entity, entityBoard, entityBoardHero, gameState);\r\n\t// \tentity.frenzyChargesLeft--;\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\t// const 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// \tgameState.allCards,\r\n\t// \tgameState.cardsData,\r\n\t// \tgameState.sharedState,\r\n\t// \tgameState.spectator,\r\n\t// );\r\n\t// if (!!entitySpawns?.length) {\r\n\t// \t// Spawn to the right\r\n\t// \tconst index = entityBoard.map((e) => e.entityId).indexOf(entity.entityId) + 1;\r\n\t// \taddMinionsToBoard(entityBoard, entityBoardHero, otherHero, index, entitySpawns, gameState);\r\n\t// \tgameState.spectator.registerMinionsSpawn(entity, entityBoard, entitySpawns);\r\n\t// }\r\n\treturn bumpInto.attack;\r\n};\r\n\r\n// const 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_BRM_006) {\r\n// \t\treturn spawnEntities(\r\n// \t\t\tCardIds.ImpGangBoss_ImpToken_BRM_006t,\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.ImpGangBoss_TB_BaconUps_030) {\r\n// \t\treturn spawnEntities(\r\n// \t\t\tCardIds.ImpGangBoss_ImpToken_TB_BaconUps_030t,\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_BGS_044) {\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.ImpMama_TB_BaconUps_116) {\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_BOT_218) {\r\n// \t\treturn spawnEntities(\r\n// \t\t\tCardIds.SecurityRover_GuardBotToken_BOT_218t,\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.SecurityRover_TB_BaconUps_041) {\r\n// \t\treturn spawnEntities(\r\n// \t\t\tCardIds.SecurityRover_GuardBotToken_TB_BaconUps_041t,\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\tgameState: FullGameState,\r\n\t// When we're in an \"attack immediately\" phase, we wait until we're out of the phase to summon minions\r\n\tskipSummonWhenSpace = false,\r\n): void => {\r\n\t// const debug = board1.some((e) => e.health <= 0) || board2.some((e) => e.health <= 0);\r\n\t// debug && console.debug('\\nprocessing minions death');\r\n\t// debug && console.debug(stringifySimple(board1, gameState.allCards));\r\n\t// debug && console.debug(stringifySimple(board2, gameState.allCards));\r\n\tconst [deadMinionIndexesFromLeft1, deadMinionIndexesFromRights1, deadEntities1] = makeMinionsDie(\r\n\t\tboard1,\r\n\t\tboard1Hero,\r\n\t\tboard2,\r\n\t\tboard2Hero,\r\n\t\tgameState,\r\n\t);\r\n\tconst [deadMinionIndexesFromLeft2, deadMinionIndexesFromRights2, deadEntities2] = makeMinionsDie(\r\n\t\tboard2,\r\n\t\tboard2Hero,\r\n\t\tboard1,\r\n\t\tboard1Hero,\r\n\t\tgameState,\r\n\t);\r\n\t// debug && console.debug('after processing minions death');\r\n\t// debug && console.debug(stringifySimple(board1, gameState.allCards));\r\n\t// debug && console.debug(stringifySimple(board2, gameState.allCards));\r\n\t// debug && console.debug(deadMinionIndexesFromRights1);\r\n\t// debug && console.debug(deadMinionIndexesFromRights2);\r\n\t// console.debug('dead entities', stringifySimple(deadEntities1, allCards), stringifySimple(deadEntities2, allCards));\r\n\t// No death to process, we can return\r\n\tif (deadEntities1.length === 0 && deadEntities2.length === 0) {\r\n\t\treturn;\r\n\t\t// return [board1, board2];\r\n\t}\r\n\r\n\t// Remember them right away, so that subsequent deaths do not break the order\r\n\t// TODO: move this to the deathrattle-orchestration?\r\n\t// If the fish dies (from Scallywag for instance), it doesn't remember the deathrattle\r\n\t// console.debug(\r\n\t// \t'\\n\\ndeadEntities',\r\n\t// \tstringifySimple(deadEntities1, gameState.allCards),\r\n\t// \tstringifySimple(deadEntities2, gameState.allCards),\r\n\t// );\r\n\tboard1\r\n\t\t.filter((entity) => isFish(entity))\r\n\t\t.forEach((entity) =>\r\n\t\t\trememberDeathrattles(entity, deadEntities1, gameState.cardsData, gameState.allCards, gameState.sharedState),\r\n\t\t);\r\n\tboard2\r\n\t\t.filter((entity) => isFish(entity))\r\n\t\t.forEach((entity) =>\r\n\t\t\trememberDeathrattles(entity, deadEntities2, gameState.cardsData, gameState.allCards, gameState.sharedState),\r\n\t\t);\r\n\r\n\tgameState.spectator.registerDeadEntities(\r\n\t\tdeadMinionIndexesFromRights1,\r\n\t\tdeadEntities1,\r\n\t\tboard1,\r\n\t\tdeadMinionIndexesFromRights2,\r\n\t\tdeadEntities2,\r\n\t\tboard2,\r\n\t);\r\n\tgameState.sharedState.deaths.push(\r\n\t\t...deadEntities1.map((e, index) =>\r\n\t\t\taddImpliedMechanics(\r\n\t\t\t\t{\r\n\t\t\t\t\t...e,\r\n\t\t\t\t\thealth: e.maxHealth,\r\n\t\t\t\t\tdefinitelyDead: false,\r\n\t\t\t\t\tindexFromLeftAtTimeOfDeath: deadMinionIndexesFromLeft1[index],\r\n\t\t\t\t},\r\n\t\t\t\tgameState.cardsData,\r\n\t\t\t),\r\n\t\t),\r\n\t);\r\n\tgameState.sharedState.deaths.push(\r\n\t\t...deadEntities2.map((e, index) =>\r\n\t\t\taddImpliedMechanics(\r\n\t\t\t\t{\r\n\t\t\t\t\t...e,\r\n\t\t\t\t\thealth: e.maxHealth,\r\n\t\t\t\t\tdefinitelyDead: false,\r\n\t\t\t\t\tindexFromLeftAtTimeOfDeath: deadMinionIndexesFromLeft2[index],\r\n\t\t\t\t},\r\n\t\t\t\tgameState.cardsData,\r\n\t\t\t),\r\n\t\t),\r\n\t);\r\n\r\n\tfor (const deadEntity of deadEntities1) {\r\n\t\tconst onDeathImpl = cardMappings[deadEntity.cardId];\r\n\t\tif (hasOnDeath(onDeathImpl)) {\r\n\t\t\tonDeathImpl.onDeath(deadEntity, {\r\n\t\t\t\thero: board1Hero,\r\n\t\t\t\tboard: board1,\r\n\t\t\t\tgameState: gameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\tfor (const deadEntity of deadEntities2) {\r\n\t\tconst onDeathImpl = cardMappings[deadEntity.cardId];\r\n\t\tif (hasOnDeath(onDeathImpl)) {\r\n\t\t\tonDeathImpl.onDeath(deadEntity, {\r\n\t\t\t\thero: board2Hero,\r\n\t\t\t\tboard: board2,\r\n\t\t\t\tgameState: gameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tboard1Hero.globalInfo.EternalKnightsDeadThisGame =\r\n\t\tboard1Hero.globalInfo.EternalKnightsDeadThisGame +\r\n\t\tdeadEntities1.filter(\r\n\t\t\t(e) => e.cardId === CardIds.EternalKnight_BG25_008 || e.cardId === CardIds.EternalKnight_BG25_008_G,\r\n\t\t).length;\r\n\tboard2Hero.globalInfo.EternalKnightsDeadThisGame =\r\n\t\tboard2Hero.globalInfo.EternalKnightsDeadThisGame +\r\n\t\tdeadEntities2.filter(\r\n\t\t\t(e) => e.cardId === CardIds.EternalKnight_BG25_008 || e.cardId === CardIds.EternalKnight_BG25_008_G,\r\n\t\t).length;\r\n\r\n\torchestrateMinionDeathEffects({\r\n\t\tgameState: gameState,\r\n\t\tplayerDeadEntities: board1Hero.friendly ? deadEntities1 : deadEntities2,\r\n\t\tplayerDeadEntityIndexesFromRight: board1Hero.friendly\r\n\t\t\t? deadMinionIndexesFromRights1\r\n\t\t\t: deadMinionIndexesFromRights2,\r\n\t\topponentDeadEntities: board1Hero.friendly ? deadEntities2 : deadEntities1,\r\n\t\topponentDeadEntityIndexesFromRight: board1Hero.friendly\r\n\t\t\t? deadMinionIndexesFromRights2\r\n\t\t\t: deadMinionIndexesFromRights1,\r\n\t});\r\n\r\n\tboard1\r\n\t\t.filter(\r\n\t\t\t(entity) =>\r\n\t\t\t\tentity.cardId === CardIds.Monstrosity_BG20_HERO_282_Buddy ||\r\n\t\t\t\tentity.cardId === CardIds.Monstrosity_BG20_HERO_282_Buddy_G,\r\n\t\t)\r\n\t\t.forEach((entity) => applyMonstrosity(entity, deadEntities1, board1, board1Hero, gameState));\r\n\tboard2\r\n\t\t.filter(\r\n\t\t\t(entity) =>\r\n\t\t\t\tentity.cardId === CardIds.Monstrosity_BG20_HERO_282_Buddy ||\r\n\t\t\t\tentity.cardId === CardIds.Monstrosity_BG20_HERO_282_Buddy_G,\r\n\t\t)\r\n\t\t.forEach((entity) => applyMonstrosity(entity, deadEntities2, board2, board2Hero, gameState));\r\n\r\n\t// Make sure we only return when there are no more deaths to process\r\n\t// Make sure to do this right before the end of the 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, gameState);\r\n\r\n\t// Not sure about the timing here, but I have bothered Mitchell quite a lot already recently :)\r\n\tif (!skipSummonWhenSpace) {\r\n\t\thandleSummonsWhenSpace(board1, board1Hero, board2, board2Hero, gameState);\r\n\t}\r\n\r\n\t// Apply \"after minion death\" effects\r\n\thandleAfterMinionsDeaths(board1, deadEntities1, board1Hero, board2, deadEntities2, board2Hero, gameState);\r\n};\r\n\r\nconst handleAfterMinionsDeaths = (\r\n\tboard1: BoardEntity[],\r\n\tdeadEntities1: BoardEntity[],\r\n\theroEntity1: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tdeadEntities2: BoardEntity[],\r\n\theroEntity2: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst random = Math.random() > 0.5;\r\n\thandleAfterMinionsDeathsForBoard(\r\n\t\trandom ? board1 : board2,\r\n\t\trandom ? deadEntities1 : deadEntities2,\r\n\t\trandom ? heroEntity1 : heroEntity2,\r\n\t\trandom ? board2 : board1,\r\n\t\trandom ? deadEntities2 : deadEntities1,\r\n\t\trandom ? heroEntity2 : heroEntity1,\r\n\t\tgameState,\r\n\t);\r\n\thandleAfterMinionsDeathsForBoard(\r\n\t\t!random ? board1 : board2,\r\n\t\t!random ? deadEntities1 : deadEntities2,\r\n\t\t!random ? heroEntity1 : heroEntity2,\r\n\t\t!random ? board2 : board1,\r\n\t\t!random ? deadEntities2 : deadEntities1,\r\n\t\t!random ? heroEntity2 : heroEntity1,\r\n\t\tgameState,\r\n\t);\r\n};\r\n\r\nconst handleAfterMinionsDeathsForBoard = (\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyDeadEntities: BoardEntity[],\r\n\tfriendlyHeroEntity: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherDeadEntities: BoardEntity[],\r\n\totherHeroEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst candidateEntities = [];\r\n\tlet secretTriggered = null;\r\n\tif (\r\n\t\t(secretTriggered = friendlyHeroEntity.secrets?.find(\r\n\t\t\t(secret) => !secret.triggered && secret?.cardId === CardIds.MagicBlackSoulstone,\r\n\t\t)) != null\r\n\t) {\r\n\t\tif (friendlyBoard.length === 0) {\r\n\t\t\tsecretTriggered.triggered = true;\r\n\t\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\t\tconst toSummon = pickRandom(gameState.cardsData.demonSpawns);\r\n\t\t\t\tcandidateEntities.push(\r\n\t\t\t\t\t...spawnEntities(\r\n\t\t\t\t\t\ttoSummon,\r\n\t\t\t\t\t\t1,\r\n\t\t\t\t\t\tfriendlyBoard,\r\n\t\t\t\t\t\tfriendlyHeroEntity,\r\n\t\t\t\t\t\totherBoard,\r\n\t\t\t\t\t\totherHeroEntity,\r\n\t\t\t\t\t\tgameState,\r\n\t\t\t\t\t\tfriendlyHeroEntity.friendly,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t),\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tperformEntitySpawns(\r\n\t\tcandidateEntities,\r\n\t\tfriendlyBoard,\r\n\t\tfriendlyHeroEntity,\r\n\t\tsecretTriggered,\r\n\t\t0,\r\n\t\totherBoard,\r\n\t\totherHeroEntity,\r\n\t\tgameState,\r\n\t);\r\n};\r\n\r\nexport interface OnDeathInput {\r\n\treadonly hero: BgsPlayerEntity;\r\n\treadonly board: BoardEntity[];\r\n\treadonly gameState: FullGameState;\r\n}\r\nexport interface OnMinionKilledInput {\r\n\treadonly minionKilled: BoardEntity;\r\n\treadonly attackingHero: BgsPlayerEntity;\r\n\treadonly attackingBoard: BoardEntity[];\r\n\treadonly defendingHero: BgsPlayerEntity;\r\n\treadonly defendingBoard: BoardEntity[];\r\n\treadonly defenderNeighbours: readonly BoardEntity[];\r\n\treadonly gameState: FullGameState;\r\n\treadonly playerIsFriendly: boolean;\r\n}\r\n"]}
|
|
@@ -19,7 +19,6 @@ const makeMinionGolden = (target, source, targetBoard, targetBoardHero, otherBoa
|
|
|
19
19
|
if (!(goldenCard === null || goldenCard === void 0 ? void 0 : goldenCard.id)) {
|
|
20
20
|
goldenCard = refCard;
|
|
21
21
|
}
|
|
22
|
-
const refGoldenCard = gameState.allCards.getCard(target.cardId);
|
|
23
22
|
target.cardId = goldenCard.id;
|
|
24
23
|
(0, stats_1.modifyStats)(target, refCard.attack, refCard.health, targetBoard, targetBoardHero, gameState);
|
|
25
24
|
(0, add_minion_to_board_1.handleAddedMinionAuraEffect)(targetBoard, targetBoardHero, otherBoard, otherHero, target, gameState, true, false);
|
|
@@ -28,7 +27,7 @@ const makeMinionGolden = (target, source, targetBoard, targetBoardHero, otherBoa
|
|
|
28
27
|
const avengeCurrent = target.avengeCurrent;
|
|
29
28
|
(0, utils_1.addImpliedMechanics)(target, gameState.cardsData);
|
|
30
29
|
target.divineShield = hasDivineShield;
|
|
31
|
-
target.reborn = hasReborn || ((_a =
|
|
30
|
+
target.reborn = hasReborn || ((_a = goldenCard.mechanics) === null || _a === void 0 ? void 0 : _a.includes(reference_data_1.GameTag[reference_data_1.GameTag.REBORN]));
|
|
32
31
|
target.avengeCurrent = avengeCurrent;
|
|
33
32
|
};
|
|
34
33
|
exports.makeMinionGolden = makeMinionGolden;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"golden.js","sourceRoot":"","sources":["../../../src/simulation/utils/golden.ts"],"names":[],"mappings":";;;AAAA,iEAAiF;AAGjF,uCAAkD;AAClD,gEAAqE;AAErE,0EAA4E;AAC5E,oCAAuC;AAEhC,MAAM,gBAAgB,GAAG,CAC/B,MAAmB,EACnB,MAAqC,EACrC,WAA0B,EAC1B,eAAgC,EAChC,UAAyB,EACzB,SAA0B,EAC1B,SAAwB,EACjB,EAAE;;IAET,IAAI,IAAA,sBAAc,EAAC,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE;QAC/C,OAAO;KACP;IAED,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAGjF,IAAA,wDAA6B,EAAC,WAAW,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EAAE,MAAM,CAAC,MAAM,GAAG,iBAAiB,GAAG,mBAAmB,CAAC,CAAC;YACrF,MAAM;QACP,kBAAwC;QACxC;YACC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,mBAAyC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAExF,MAAM,wBAAwB,GAAG,IAAI,CAAC,UAAU,CAAC,gCAAgC,GAAG,CAAC,CAAC;YACtF,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,GAAG,gBAAgB,GAAG,wBAAwB,CAAC,CAAC;YAC7F,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,GAAG,gBAAgB,GAAG,wBAAwB,CAAC,CAAC;YAC7F,MAAM;KACP;AACF,CAAC,CAAC","sourcesContent":["import { AllCardsService, CardIds, GameTag } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { addImpliedMechanics } from '../../utils';\r\nimport { handleAddedMinionAuraEffect } from '../add-minion-to-board';\r\nimport { FullGameState } from '../internal-game-state';\r\nimport { handleMinionRemovedAuraEffect } from '../remove-minion-from-board';\r\nimport { modifyStats } from '../stats';\r\n\r\nexport const makeMinionGolden = (\r\n\ttarget: BoardEntity,\r\n\tsource: BoardEntity | BgsPlayerEntity,\r\n\ttargetBoard: BoardEntity[],\r\n\ttargetBoardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// Typically, we are already golden\r\n\tif (isMinionGolden(target, gameState.allCards)) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tgameState.spectator.registerPowerTarget(source, target, targetBoard, null, null);\r\n\r\n\t// console.log('before transforming minion', stringifySimple(targetBoard, allCards));\r\n\thandleMinionRemovedAuraEffect(targetBoard, target, targetBoardHero, gameState);\r\n\t// Specific for making a minion golden\r\n\t// This is not handled in handleMinionRemovedAuraEffect, though I'm not entirely sure why. Maybe because it's a self-effect only?\r\n\t// Also, because of how I implemented auras and such, it's probably good to have something specific for golden\r\n\tremoveMinionAuraEffectsForGolden(target, targetBoardHero);\r\n\t// console.log('after removed effect', stringifySimple(targetBoard, allCards));\r\n\tconst refCard = gameState.allCards.getCard(target.cardId);\r\n\tlet goldenCard = gameState.allCards.getCardFromDbfId(refCard.battlegroundsPremiumDbfId);\r\n\t// Happens when there is no dedicated golden card, like for the Bettle token from Boon of Beetles\r\n\tif (!goldenCard?.id) {\r\n\t\tgoldenCard = refCard;\r\n\t}\r\n\r\n\t// A minion becoming golden ignore the current death.\r\n\t// This way of handling it is not ideal, since it will still trigger if both avenges trigger at the same time, but\r\n\t// should solve the other cases\r\n\t// Update 2024-06-21: I'm not sure what this is about exactly. See\r\n\t// http://replays.firestoneapp.com/?reviewId=5d94ebeb-3691-4509-88de-5d5418b20597&turn=11&action=2\r\n\t// The Sr. Tomb Diver dies, thus gilding the Phaerix. Two other deaths later, the avenge procs\r\n\t// This means the death of the diver counted normally\r\n\t// target.avengeCurrent = Math.min(target.avengeDefault, target.avengeCurrent + 1);\r\n\r\n\t// Only change the card ID after modifying the stats, so that some effects (like Tarecgosa) won't trigger\r\n\t// too early\r\n\t// TODO: add a replay with Tarec to illustrate the difference with Defiant Shipwright, and\r\n\t// check if there is something different with Tarec\r\n\tconst refGoldenCard = gameState.allCards.getCard(target.cardId);\r\n\ttarget.cardId = goldenCard.id;\r\n\r\n\t// The rule for golden minions is to add the base stats\r\n\t// TO CHECK: not sure that this is what actually happens (i.e. do minions that trigger on stats modifications\r\n\t// trigger?)\r\n\t// UPDATE 2024-06-20: Defiant Shipwright (2/5) going golden (4/10) actually ends up at 4/12 because\r\n\t// of the +2 health bonus\r\n\t// http://replays.firestoneapp.com/?reviewId=283dc44c-5fc8-40fb-af89-7d752a39f9b9&turn=7&action=1\r\n\tmodifyStats(target, refCard.attack, refCard.health, targetBoard, targetBoardHero, gameState);\r\n\r\n\t// console.log('before adding new effect', stringifySimple(targetBoard, allCards));\r\n\thandleAddedMinionAuraEffect(targetBoard, targetBoardHero, otherBoard, otherHero, target, gameState, true, false);\r\n\tconst hasDivineShield = target.divineShield;\r\n\tconst hasReborn = target.reborn;\r\n\tconst avengeCurrent = target.avengeCurrent;\r\n\taddImpliedMechanics(target, gameState.cardsData);\r\n\r\n\t// addImpliedMechanics grants divine shield if the card has divine shield, or if the entity had\r\n\t// it at some point. That means that when we gild Zilliax: Defense Module (with Divine Shield) into\r\n\t// Zilliaw: Assembled, we restore the divine shield, while we shouldn't\r\n\ttarget.divineShield = hasDivineShield;\r\n\t// Update 2024-06-19: Hat tested on one of their build, and gilding a zilliax module should NOT\r\n\t// remove its divine shield / reborn status\r\n\t// Gilding a reborn Risen Rider results into a golden Risen Rider with reborn\r\n\t// http://replays.firestoneapp.com/?reviewId=c553c3e7-01e2-494d-80f8-69f33c08fb39&turn=7&action=4\r\n\ttarget.reborn = hasReborn || refGoldenCard.mechanics?.includes(GameTag[GameTag.REBORN]);\r\n\t// target.windfury = refGoldenCard.mechanics?.includes(GameTag[GameTag.WINDFURY]);\r\n\t// target.taunt = refGoldenCard.mechanics?.includes(GameTag[GameTag.TAUNT]);\r\n\t// target.stealth = refGoldenCard.mechanics?.includes(GameTag[GameTag.STEALTH]);\r\n\ttarget.avengeCurrent = avengeCurrent;\r\n\r\n\t// console.log('after adding new effect', stringifySimple(targetBoard, allCards));\r\n};\r\n\r\nexport const isMinionGolden = (entity: BoardEntity, allCards: AllCardsService): boolean => {\r\n\tconst ref = allCards.getCard(entity.cardId);\r\n\t// Some cards (like the Bettle token from Boon of Beetles) don't have a premium dbf id. However, we can still\r\n\t// gild it\r\n\treturn ref.premium;\r\n};\r\n\r\n// This feels wrong, and is probably an indicator that auras are not applied at the right time\r\nconst removeMinionAuraEffectsForGolden = (entity: BoardEntity, hero: BgsPlayerEntity) => {\r\n\tswitch (entity.cardId) {\r\n\t\tcase CardIds.EternalKnight_BG25_008:\r\n\t\tcase CardIds.EternalKnight_BG25_008_G:\r\n\t\t\tconst eternalKnightBuffToRemove = hero.globalInfo.EternalKnightsDeadThisGame;\r\n\t\t\tconst eternalKnighMultiplier = entity.cardId === CardIds.EternalKnight_BG25_008_G ? 2 : 1;\r\n\t\t\tentity.health = Math.max(1, entity.health - eternalKnighMultiplier * eternalKnightBuffToRemove);\r\n\t\t\tentity.attack = Math.max(0, entity.attack - eternalKnighMultiplier * eternalKnightBuffToRemove);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.SanlaynScribe_BGDUO31_208:\r\n\t\tcase CardIds.SanlaynScribe_BGDUO31_208_G:\r\n\t\t\tconst sanlaynBuffToRemove = hero.globalInfo.SanlaynScribesDeadThisGame;\r\n\t\t\tconst sanlaynMultiplier = entity.cardId === CardIds.SanlaynScribe_BGDUO31_208_G ? 2 : 1;\r\n\t\t\tentity.health = Math.max(1, entity.health - sanlaynMultiplier * sanlaynBuffToRemove);\r\n\t\t\tentity.attack = Math.max(0, entity.attack - sanlaynMultiplier * sanlaynBuffToRemove);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.AstralAutomaton_BG_TTN_401:\r\n\t\tcase CardIds.AstralAutomaton_BG_TTN_401_G:\r\n\t\t\tconst multiplierAstral = entity.cardId === CardIds.AstralAutomaton_BG_TTN_401_G ? 2 : 1;\r\n\t\t\t// Doesn't count self\r\n\t\t\tconst statsBonusAstralToRemove = hero.globalInfo.AstralAutomatonsSummonedThisGame - 1;\r\n\t\t\tentity.health = Math.max(1, entity.health - 2 * multiplierAstral * statsBonusAstralToRemove);\r\n\t\t\tentity.attack = Math.max(0, entity.attack - 2 * multiplierAstral * statsBonusAstralToRemove);\r\n\t\t\tbreak;\r\n\t}\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"golden.js","sourceRo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yB,CAAC,CAAC;YAChG,MAAM;QACP,mBAAuC;QACvC;YACC,MAAM,mBAAmB,GAAG,IAAI,CAAC,UAAU,CAAC,0BAA0B,CAAC;YACvE,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,oBAAwC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACxF,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,iBAAiB,GAAG,mBAAmB,CAAC,CAAC;YACrF,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,iBAAiB,GAAG,mBAAmB,CAAC,CAAC;YACrF,MAAM;QACP,kBAAwC;QACxC;YACC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,mBAAyC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAExF,MAAM,wBAAwB,GAAG,IAAI,CAAC,UAAU,CAAC,gCAAgC,GAAG,CAAC,CAAC;YACtF,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,GAAG,gBAAgB,GAAG,wBAAwB,CAAC,CAAC;YAC7F,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,GAAG,gBAAgB,GAAG,wBAAwB,CAAC,CAAC;YAC7F,MAAM;KACP;AACF,CAAC,CAAC","sourcesContent":["import { AllCardsService, CardIds, GameTag } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { addImpliedMechanics } from '../../utils';\r\nimport { handleAddedMinionAuraEffect } from '../add-minion-to-board';\r\nimport { FullGameState } from '../internal-game-state';\r\nimport { handleMinionRemovedAuraEffect } from '../remove-minion-from-board';\r\nimport { modifyStats } from '../stats';\r\n\r\nexport const makeMinionGolden = (\r\n\ttarget: BoardEntity,\r\n\tsource: BoardEntity | BgsPlayerEntity,\r\n\ttargetBoard: BoardEntity[],\r\n\ttargetBoardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// Typically, we are already golden\r\n\tif (isMinionGolden(target, gameState.allCards)) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tgameState.spectator.registerPowerTarget(source, target, targetBoard, null, null);\r\n\r\n\t// console.log('before transforming minion', stringifySimple(targetBoard, allCards));\r\n\thandleMinionRemovedAuraEffect(targetBoard, target, targetBoardHero, gameState);\r\n\t// Specific for making a minion golden\r\n\t// This is not handled in handleMinionRemovedAuraEffect, though I'm not entirely sure why. Maybe because it's a self-effect only?\r\n\t// Also, because of how I implemented auras and such, it's probably good to have something specific for golden\r\n\tremoveMinionAuraEffectsForGolden(target, targetBoardHero);\r\n\t// console.log('after removed effect', stringifySimple(targetBoard, allCards));\r\n\tconst refCard = gameState.allCards.getCard(target.cardId);\r\n\tlet goldenCard = gameState.allCards.getCardFromDbfId(refCard.battlegroundsPremiumDbfId);\r\n\t// Happens when there is no dedicated golden card, like for the Bettle token from Boon of Beetles\r\n\tif (!goldenCard?.id) {\r\n\t\tgoldenCard = refCard;\r\n\t}\r\n\r\n\t// A minion becoming golden ignore the current death.\r\n\t// This way of handling it is not ideal, since it will still trigger if both avenges trigger at the same time, but\r\n\t// should solve the other cases\r\n\t// Update 2024-06-21: I'm not sure what this is about exactly. See\r\n\t// http://replays.firestoneapp.com/?reviewId=5d94ebeb-3691-4509-88de-5d5418b20597&turn=11&action=2\r\n\t// The Sr. Tomb Diver dies, thus gilding the Phaerix. Two other deaths later, the avenge procs\r\n\t// This means the death of the diver counted normally\r\n\t// target.avengeCurrent = Math.min(target.avengeDefault, target.avengeCurrent + 1);\r\n\r\n\t// Only change the card ID after modifying the stats, so that some effects (like Tarecgosa) won't trigger\r\n\t// too early\r\n\t// TODO: add a replay with Tarec to illustrate the difference with Defiant Shipwright, and\r\n\t// check if there is something different with Tarec\r\n\ttarget.cardId = goldenCard.id;\r\n\r\n\t// The rule for golden minions is to add the base stats\r\n\t// TO CHECK: not sure that this is what actually happens (i.e. do minions that trigger on stats modifications\r\n\t// trigger?)\r\n\t// UPDATE 2024-06-20: Defiant Shipwright (2/5) going golden (4/10) actually ends up at 4/12 because\r\n\t// of the +2 health bonus\r\n\t// http://replays.firestoneapp.com/?reviewId=283dc44c-5fc8-40fb-af89-7d752a39f9b9&turn=7&action=1\r\n\tmodifyStats(target, refCard.attack, refCard.health, targetBoard, targetBoardHero, gameState);\r\n\r\n\t// console.log('before adding new effect', stringifySimple(targetBoard, allCards));\r\n\thandleAddedMinionAuraEffect(targetBoard, targetBoardHero, otherBoard, otherHero, target, gameState, true, false);\r\n\tconst hasDivineShield = target.divineShield;\r\n\tconst hasReborn = target.reborn;\r\n\tconst avengeCurrent = target.avengeCurrent;\r\n\taddImpliedMechanics(target, gameState.cardsData);\r\n\r\n\t// addImpliedMechanics grants divine shield if the card has divine shield, or if the entity had\r\n\t// it at some point. That means that when we gild Zilliax: Defense Module (with Divine Shield) into\r\n\t// Zilliaw: Assembled, we restore the divine shield, while we shouldn't\r\n\ttarget.divineShield = hasDivineShield;\r\n\t// Update 2024-06-19: Hat tested on one of their build, and gilding a zilliax module should NOT\r\n\t// remove its divine shield / reborn status\r\n\t// Gilding a reborn Risen Rider results into a golden Risen Rider with reborn\r\n\t// http://replays.firestoneapp.com/?reviewId=c553c3e7-01e2-494d-80f8-69f33c08fb39&turn=7&action=4\r\n\ttarget.reborn = hasReborn || goldenCard.mechanics?.includes(GameTag[GameTag.REBORN]);\r\n\t// target.windfury = refGoldenCard.mechanics?.includes(GameTag[GameTag.WINDFURY]);\r\n\t// target.taunt = refGoldenCard.mechanics?.includes(GameTag[GameTag.TAUNT]);\r\n\t// target.stealth = refGoldenCard.mechanics?.includes(GameTag[GameTag.STEALTH]);\r\n\ttarget.avengeCurrent = avengeCurrent;\r\n\r\n\t// console.log('after adding new effect', stringifySimple(targetBoard, allCards));\r\n};\r\n\r\nexport const isMinionGolden = (entity: BoardEntity, allCards: AllCardsService): boolean => {\r\n\tconst ref = allCards.getCard(entity.cardId);\r\n\t// Some cards (like the Bettle token from Boon of Beetles) don't have a premium dbf id. However, we can still\r\n\t// gild it\r\n\treturn ref.premium;\r\n};\r\n\r\n// This feels wrong, and is probably an indicator that auras are not applied at the right time\r\nconst removeMinionAuraEffectsForGolden = (entity: BoardEntity, hero: BgsPlayerEntity) => {\r\n\tswitch (entity.cardId) {\r\n\t\tcase CardIds.EternalKnight_BG25_008:\r\n\t\tcase CardIds.EternalKnight_BG25_008_G:\r\n\t\t\tconst eternalKnightBuffToRemove = hero.globalInfo.EternalKnightsDeadThisGame;\r\n\t\t\tconst eternalKnighMultiplier = entity.cardId === CardIds.EternalKnight_BG25_008_G ? 2 : 1;\r\n\t\t\tentity.health = Math.max(1, entity.health - eternalKnighMultiplier * eternalKnightBuffToRemove);\r\n\t\t\tentity.attack = Math.max(0, entity.attack - eternalKnighMultiplier * eternalKnightBuffToRemove);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.SanlaynScribe_BGDUO31_208:\r\n\t\tcase CardIds.SanlaynScribe_BGDUO31_208_G:\r\n\t\t\tconst sanlaynBuffToRemove = hero.globalInfo.SanlaynScribesDeadThisGame;\r\n\t\t\tconst sanlaynMultiplier = entity.cardId === CardIds.SanlaynScribe_BGDUO31_208_G ? 2 : 1;\r\n\t\t\tentity.health = Math.max(1, entity.health - sanlaynMultiplier * sanlaynBuffToRemove);\r\n\t\t\tentity.attack = Math.max(0, entity.attack - sanlaynMultiplier * sanlaynBuffToRemove);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.AstralAutomaton_BG_TTN_401:\r\n\t\tcase CardIds.AstralAutomaton_BG_TTN_401_G:\r\n\t\t\tconst multiplierAstral = entity.cardId === CardIds.AstralAutomaton_BG_TTN_401_G ? 2 : 1;\r\n\t\t\t// Doesn't count self\r\n\t\t\tconst statsBonusAstralToRemove = hero.globalInfo.AstralAutomatonsSummonedThisGame - 1;\r\n\t\t\tentity.health = Math.max(1, entity.health - 2 * multiplierAstral * statsBonusAstralToRemove);\r\n\t\t\tentity.attack = Math.max(0, entity.attack - 2 * multiplierAstral * statsBonusAstralToRemove);\r\n\t\t\tbreak;\r\n\t}\r\n};\r\n"]}
|
package/dist/utils.d.ts
CHANGED
|
@@ -31,4 +31,5 @@ export declare const isPilotedWhirlOTron: (entity: BoardEntity) => boolean;
|
|
|
31
31
|
export declare const isGolden: (cardId: string, allCards: AllCardsService) => boolean;
|
|
32
32
|
export declare const getPlayerState: (gameState: GameState, hero: BgsPlayerEntity) => PlayerState;
|
|
33
33
|
export declare const getTeammateInitialState: (gameState: GameState, hero: BgsPlayerEntity) => PlayerState;
|
|
34
|
+
export declare const getTeamInitialStates: (gameState: GameState, hero: BgsPlayerEntity) => PlayerState[];
|
|
34
35
|
export declare const copyEntity: (entity: BoardEntity) => BoardEntity;
|
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.copyEntity = exports.getTeammateInitialState = exports.getPlayerState = exports.isGolden = exports.isPilotedWhirlOTron = exports.isFish = exports.stringifySimpleCard = exports.stringifySimple = exports.normalizeCardIdForSkin = exports.addImpliedMechanics = exports.getRaceEnum = exports.isCorrectTribe = exports.getEffectiveTribesForEntity = exports.hasCorrectTribe = exports.hasMechanic = exports.getMinionsOfDifferentTypes = exports.grantStatsToMinionsOfEachType = exports.addStatsToAliveBoard = exports.addStatsToBoard = exports.getRandomMinionWithHighestHealth = exports.getRandomRevivableMinion = exports.getRandomAliveMinion = exports.grantRandomStats = exports.grantRandomHealth = exports.grantRandomAttack = exports.buildRandomUndeadCreation = exports.buildSingleBoardEntity = void 0;
|
|
3
|
+
exports.copyEntity = exports.getTeamInitialStates = exports.getTeammateInitialState = exports.getPlayerState = exports.isGolden = exports.isPilotedWhirlOTron = exports.isFish = exports.stringifySimpleCard = exports.stringifySimple = exports.normalizeCardIdForSkin = exports.addImpliedMechanics = exports.getRaceEnum = exports.isCorrectTribe = exports.getEffectiveTribesForEntity = exports.hasCorrectTribe = exports.hasMechanic = exports.getMinionsOfDifferentTypes = exports.grantStatsToMinionsOfEachType = exports.addStatsToAliveBoard = exports.addStatsToBoard = exports.getRandomMinionWithHighestHealth = exports.getRandomRevivableMinion = exports.getRandomAliveMinion = exports.grantRandomStats = exports.grantRandomHealth = exports.grantRandomAttack = exports.buildRandomUndeadCreation = exports.buildSingleBoardEntity = void 0;
|
|
4
4
|
const reference_data_1 = require("@firestone-hs/reference-data");
|
|
5
5
|
const card_interface_1 = require("./cards/card.interface");
|
|
6
6
|
const _card_mappings_1 = require("./cards/impl/_card-mappings");
|
|
@@ -436,6 +436,13 @@ const getTeammateInitialState = (gameState, hero) => {
|
|
|
436
436
|
: null;
|
|
437
437
|
};
|
|
438
438
|
exports.getTeammateInitialState = getTeammateInitialState;
|
|
439
|
+
const getTeamInitialStates = (gameState, hero) => {
|
|
440
|
+
var _a;
|
|
441
|
+
return ((_a = gameState.playerInitial.player) === null || _a === void 0 ? void 0 : _a.friendly) === (hero === null || hero === void 0 ? void 0 : hero.friendly)
|
|
442
|
+
? [gameState.playerInitial, gameState.playerInitial.teammate].filter((p) => p)
|
|
443
|
+
: [gameState.opponentInitial, gameState.opponentInitial.teammate].filter((p) => p);
|
|
444
|
+
};
|
|
445
|
+
exports.getTeamInitialStates = getTeamInitialStates;
|
|
439
446
|
const copyEntity = (entity) => {
|
|
440
447
|
var _a, _b, _c;
|
|
441
448
|
const copy = {
|