@firestone-hs/simulate-bgs-battle 1.1.456 → 1.1.458
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/services/utils.js +1 -1
- package/dist/services/utils.js.map +1 -1
- package/dist/simulate-bgs-battle.d.ts +1 -1
- package/dist/simulate-bgs-battle.js +2 -2
- package/dist/simulate-bgs-battle.js.map +1 -1
- package/dist/simulation/attack.js +0 -17
- package/dist/simulation/attack.js.map +1 -1
- package/dist/simulation/avenge.d.ts +1 -1
- package/dist/simulation/avenge.js +5 -2
- package/dist/simulation/avenge.js.map +1 -1
- package/dist/simulation/deathrattle-effects.d.ts +2 -1
- package/dist/simulation/deathrattle-effects.js +25 -6
- package/dist/simulation/deathrattle-effects.js.map +1 -1
- package/dist/simulation/deathrattle-orchestration.js +26 -4
- package/dist/simulation/deathrattle-orchestration.js.map +1 -1
- package/dist/simulation/deathrattle-utils.js +1 -1
- package/dist/simulation/deathrattle-utils.js.map +1 -1
- package/dist/simulation/on-attack.js +1 -1
- package/dist/simulation/on-attack.js.map +1 -1
- package/dist/simulation/stats.js +1 -1
- package/dist/simulation/stats.js.map +1 -1
- package/dist/utils.js +6 -2
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -10,7 +10,8 @@ const deathrattle_spawns_1 = require("./deathrattle-spawns");
|
|
|
10
10
|
const reborn_1 = require("./reborn");
|
|
11
11
|
const spawns_1 = require("./spawns");
|
|
12
12
|
const orchestrateMinionDeathEffects = (deathrattleInput, processAvenge = true, processReborn = true) => {
|
|
13
|
-
|
|
13
|
+
handleAfterMinionsKillEffects(deathrattleInput);
|
|
14
|
+
handleWheneverMinionsDieEffects(deathrattleInput);
|
|
14
15
|
const playerBoardBefore = [...deathrattleInput.gameState.gameState.player.board];
|
|
15
16
|
const opponentBoardBefore = [...deathrattleInput.gameState.gameState.opponent.board];
|
|
16
17
|
const entitiesFromDeathrattles = processDeathrattles(deathrattleInput, processAvenge);
|
|
@@ -45,7 +46,7 @@ const orchestrateMinionDeathEffects = (deathrattleInput, processAvenge = true, p
|
|
|
45
46
|
handlePostDeathrattleEffects(deathrattleInput, [...entitiesFromDeathrattles, ...entitiesFromFeathermanes]);
|
|
46
47
|
};
|
|
47
48
|
exports.orchestrateMinionDeathEffects = orchestrateMinionDeathEffects;
|
|
48
|
-
const
|
|
49
|
+
const handleAfterMinionsKillEffects = (deathrattleInput) => {
|
|
49
50
|
const processPlayerFirst = Math.random() > 0.5;
|
|
50
51
|
const playerStates = processPlayerFirst
|
|
51
52
|
? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]
|
|
@@ -61,7 +62,28 @@ const handlePreDeathrattleEffects = (deathrattleInput) => {
|
|
|
61
62
|
if (deadEntities.length >= 0) {
|
|
62
63
|
for (let j = 0; j < deadEntities.length; j++) {
|
|
63
64
|
const deadEntity = deadEntities[j];
|
|
64
|
-
(0, deathrattle_effects_1.
|
|
65
|
+
(0, deathrattle_effects_1.handleAfterMinionKillsEffect)(deadEntity, playerDeadEntityIndexesFromRight[i][j], playerStates[i].board, playerStates[i].player, playerStates[1 - i].board, playerStates[1 - i].player, deathrattleInput.gameState);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const handleWheneverMinionsDieEffects = (deathrattleInput) => {
|
|
71
|
+
const processPlayerFirst = Math.random() > 0.5;
|
|
72
|
+
const playerStates = processPlayerFirst
|
|
73
|
+
? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]
|
|
74
|
+
: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];
|
|
75
|
+
const playerDeadEntities = processPlayerFirst
|
|
76
|
+
? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]
|
|
77
|
+
: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];
|
|
78
|
+
const playerDeadEntityIndexesFromRight = processPlayerFirst
|
|
79
|
+
? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]
|
|
80
|
+
: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];
|
|
81
|
+
for (let i = 0; i < 2; i++) {
|
|
82
|
+
const deadEntities = playerDeadEntities[i];
|
|
83
|
+
if (deadEntities.length >= 0) {
|
|
84
|
+
for (let j = 0; j < deadEntities.length; j++) {
|
|
85
|
+
const deadEntity = deadEntities[j];
|
|
86
|
+
(0, deathrattle_effects_1.applyWheneverMinionDiesEffect)(deadEntity, playerDeadEntityIndexesFromRight[i][j], playerStates[i].board, playerStates[i].player, playerStates[1 - i].board, playerStates[1 - i].player, deathrattleInput.gameState);
|
|
65
87
|
}
|
|
66
88
|
}
|
|
67
89
|
}
|
|
@@ -149,7 +171,7 @@ const processDeathrattleForMinion = (deadEntity, indexFromRight, deadEntities, d
|
|
|
149
171
|
const drEntities = handleNaturalDeathrattle(deadEntity, indexFromRight, deadEntities, deadEntityPlayerState, otherPlayerState, gameState);
|
|
150
172
|
const enchEntities = handleEnchantmentsDeathrattle(deadEntity, indexFromRight, deadEntities, deadEntityPlayerState, otherPlayerState, gameState);
|
|
151
173
|
if (processAvenge) {
|
|
152
|
-
(0, avenge_1.applyAvengeEffects)(deadEntity, indexFromRight, deadEntityPlayerState.board, deadEntityPlayerState.player, otherPlayerState.board, otherPlayerState.player, gameState);
|
|
174
|
+
(0, avenge_1.applyAvengeEffects)(deadEntity, indexFromRight, deadEntityPlayerState.board, deadEntityPlayerState.player, otherPlayerState.board, otherPlayerState.player, gameState, [...drEntities, ...enchEntities]);
|
|
153
175
|
}
|
|
154
176
|
const afterDeathEntities = (0, death_effects_1.applyAfterDeathEffects)(deadEntity, indexFromRight, deadEntityPlayerState.board, deadEntityPlayerState.player, otherPlayerState.board, otherPlayerState.player, gameState);
|
|
155
177
|
return [...drEntities, ...enchEntities, ...afterDeathEntities];
|
|
@@ -1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AC,YAAY,0CAAE,QAAQ,mBAAsC;SACzF,MAAA,qBAAqB,CAAC,MAAM,CAAC,YAAY,0CAAE,QAAQ,uBAA0C,CAAA,EAC5F;QACD,MAAM,YAAY,GAAG,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,KAAK,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC5G,IAAI,YAAY,EAAE;YACjB,YAAY,CAAC,MAAM,IAAI,CAAC,CAAC;YACzB,YAAY,CAAC,MAAM,IAAI,CAAC,CAAC;SACzB;KACD;IAKD,IAAI,IAAA,uBAAe,EAAC,UAAU,EAAE,qBAAI,CAAC,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE;QACjE,IAAI,qBAAqB,CAAC,MAAM,CAAC,UAAU,CAAC,iBAAiB,GAAG,CAAC,EAAE;YAClE,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAC3B,CAAC,EACD,UAAU,CAAC,MAAM,GAAG,qBAAqB,CAAC,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAC7E,CAAC;SACF;KACD;IACD,IAAI,IAAA,uBAAe,EAAC,UAAU,EAAE,qBAAI,CAAC,KAAK,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE;QAChE,IAAI,qBAAqB,CAAC,MAAM,CAAC,UAAU,CAAC,eAAe,GAAG,CAAC,EAAE;YAChE,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAC3B,CAAC,EACD,UAAU,CAAC,MAAM,GAAG,qBAAqB,CAAC,MAAM,CAAC,UAAU,CAAC,eAAe,CAC3E,CAAC;SACF;KACD;AACF,CAAC,CAAC","sourcesContent":["import { CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { hasCorrectTribe } from '../utils';\r\nimport { applyAvengeEffects } from './avenge';\r\nimport { applyAfterDeathEffects } from './death-effects';\r\nimport { applyMinionDeathEffect, handleDeathrattleEffects } from './deathrattle-effects';\r\nimport { spawnEntities, spawnEntitiesFromDeathrattle, spawnEntitiesFromEnchantments } from './deathrattle-spawns';\r\nimport { FullGameState, PlayerState } from './internal-game-state';\r\nimport { handleRebornForEntity } from './reborn';\r\nimport { performEntitySpawns } from './spawns';\r\n\r\n// FIXME:\r\n// From Mitchell on Discord:\r\n// - Minions die left to right\r\n// - When a minion dies, it procs natural deathrattle, added deathrattles, and then all avenges progress\r\n// by 1 (and trigger as necessary)\r\n// - Then next minion\r\n// - After ALL deathrattles and avenges are done, Reborn triggers\r\n// - (Ideally after all of that I would want Feathermane to trigger, but that is not what it does right now.\r\n// Right now it triggers at deathrattle speed rather than after Reborn speed)\r\nexport const orchestrateMinionDeathEffects = (\r\n\tdeathrattleInput: DeathrattleInput,\r\n\tprocessAvenge = true,\r\n\tprocessReborn = true,\r\n) => {\r\n\t// Not sure about this\r\n\thandlePreDeathrattleEffects(deathrattleInput);\r\n\r\n\tconst playerBoardBefore = [...deathrattleInput.gameState.gameState.player.board];\r\n\tconst opponentBoardBefore = [...deathrattleInput.gameState.gameState.opponent.board];\r\n\r\n\tconst entitiesFromDeathrattles = processDeathrattles(deathrattleInput, processAvenge);\r\n\r\n\t// Hack to try and fix how reborn indices are handled when there are spawns during the deathrattle phase\r\n\t// Ideally, this should probably be rewritten completely to keep the dead entities in the board itself\r\n\t// so we can use that as a source for the spawn index. However this is a big rewrite with lots of\r\n\t// potential side-effects\r\n\tconst playerBoardAfter = [...deathrattleInput.gameState.gameState.player.board];\r\n\tconst opponentBoardAfter = [...deathrattleInput.gameState.gameState.opponent.board];\r\n\tconst opponentIndexOfSpawnedEntities = opponentBoardAfter\r\n\t\t.filter((entity) => !opponentBoardBefore.includes(entity))\r\n\t\t.map((entity) => opponentBoardAfter.length - opponentBoardAfter.indexOf(entity) - 1);\r\n\tconst playerIndexOfSpawnedEntities = playerBoardAfter\r\n\t\t.filter((entity) => !playerBoardBefore.includes(entity))\r\n\t\t.map((entity) => playerBoardAfter.length - playerBoardAfter.indexOf(entity) - 1);\r\n\tdeathrattleInput.opponentDeadEntityIndexesFromRight = deathrattleInput.opponentDeadEntityIndexesFromRight.map(\r\n\t\t(previousIndex) => {\r\n\t\t\topponentIndexOfSpawnedEntities.forEach((index) => {\r\n\t\t\t\tif (index < previousIndex) {\r\n\t\t\t\t\tpreviousIndex++;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\treturn previousIndex;\r\n\t\t},\r\n\t);\r\n\tdeathrattleInput.playerDeadEntityIndexesFromRight = deathrattleInput.playerDeadEntityIndexesFromRight.map(\r\n\t\t(previousIndex) => {\r\n\t\t\tplayerIndexOfSpawnedEntities.forEach((index) => {\r\n\t\t\t\tif (index < previousIndex) {\r\n\t\t\t\t\tpreviousIndex++;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\treturn previousIndex;\r\n\t\t},\r\n\t);\r\n\r\n\tif (processReborn) {\r\n\t\tprocessReborns(deathrattleInput);\r\n\t}\r\n\r\n\tconst entitiesFromFeathermanes = processFeathermaneEffects(deathrattleInput);\r\n\thandlePostDeathrattleEffects(deathrattleInput, [...entitiesFromDeathrattles, ...entitiesFromFeathermanes]);\r\n};\r\n\r\nconst handlePreDeathrattleEffects = (deathrattleInput: DeathrattleInput) => {\r\n\t// Wildfire Element is applied first, before the DR spawns\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\tapplyMinionDeathEffect(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tplayerDeadEntityIndexesFromRight[i][j],\r\n\t\t\t\t\tplayerStates[i].board,\r\n\t\t\t\t\tplayerStates[i].player,\r\n\t\t\t\t\tplayerStates[1 - i].board,\r\n\t\t\t\t\tplayerStates[1 - i].player,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst processDeathrattles = (deathrattleInput: DeathrattleInput, processAvenge = true): BoardEntity[] => {\r\n\tconst entitiesFromDeathrattles: BoardEntity[] = [];\r\n\t// Deathrattles are handled left to right\r\n\t// Then for each minion, natural deathrattles are processed first, then enchantments\r\n\t// http://replays.firestoneapp.com/?reviewId=ec5428bf-a599-4f4c-bea9-8acad5075cb8&turn=11&action=1\r\n\t// http://replays.firestoneapp.com/?reviewId=f32e734a-d5a2-4fa4-ad10-94019969cdd7&turn=6&action=22\r\n\t// http://replays.firestoneapp.com/?reviewId=ea9503c9-2795-49f0-866b-9ea856cec7df&turn=11&action=3\r\n\t// http://replays.firestoneapp.com/?reviewId=1ff37e17-704c-4a73-8c78-377c52b6cb42&turn=13&action=1 is a trap: the enchantment is on the first\r\n\t// minion, but the DR is on the second one.\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\t// Process one player first, then the other\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\t// Entities are processed left to right\r\n\t\t\t// TODO: in fact, the processing order is summoning order, so maybe we can just use the entityId\r\n\t\t\t// to determine the order? https://x.com/LoewenMitchell/status/1750792974383173676?s=20\r\n\t\t\t// \"It should be summoned order (which is most cases would be left to right but mid-combat that could change).\"\r\n\t\t\t// This doesn't actually work: http://replays.firestoneapp.com/?reviewId=ec5428bf-a599-4f4c-bea9-8acad5075cb8&turn=11&action=6\r\n\t\t\t// deadEntities.sort((a, b) => a.entityId - b.entityId);\r\n\t\t\t// So we would need to find another proxy for the order\r\n\t\t\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\tconst deadEntityAttack = deadEntity.attack;\r\n\t\t\t\tconst indexFromRight = playerDeadEntityIndexesFromRight[i][j];\r\n\t\t\t\tconst modifiedIndexFromRight = Math.min(playerStates[i].board.length, indexFromRight);\r\n\t\t\t\tconst deadEntityPlayerState = playerStates[i];\r\n\t\t\t\tconst otherPlayerState = playerStates[1 - i];\r\n\t\t\t\tconst spawns = processDeathrattleForMinion(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\tdeadEntities,\r\n\t\t\t\t\tdeadEntityPlayerState,\r\n\t\t\t\t\totherPlayerState,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t\tprocessAvenge,\r\n\t\t\t\t);\r\n\t\t\t\tentitiesFromDeathrattles.push(...spawns);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn entitiesFromDeathrattles;\r\n};\r\n\r\nconst processFeathermaneEffects = (deathrattleInput: DeathrattleInput, processAvenge = true): BoardEntity[] => {\r\n\tconst entitiesFromDeathrattles: BoardEntity[] = [];\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\t// Process one player first, then the other\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\t// Entities are processed left to right\r\n\t\t\t// TODO: in fact, the processing order is summoning order, so maybe we can just use the entityId\r\n\t\t\t// to determine the order? https://x.com/LoewenMitchell/status/1750792974383173676?s=20\r\n\t\t\t// \"It should be summoned order (which is most cases would be left to right but mid-combat that could change).\"\r\n\t\t\t// This doesn't actually work: http://replays.firestoneapp.com/?reviewId=ec5428bf-a599-4f4c-bea9-8acad5075cb8&turn=11&action=6\r\n\t\t\t// deadEntities.sort((a, b) => a.entityId - b.entityId);\r\n\t\t\t// So we would need to find another proxy for the order\r\n\t\t\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\tconst indexFromRight = playerDeadEntityIndexesFromRight[i][j];\r\n\t\t\t\tconst modifiedIndexFromRight = Math.min(playerStates[i].board.length, indexFromRight);\r\n\t\t\t\tconst deadEntityPlayerState = playerStates[i];\r\n\t\t\t\tconst otherPlayerState = playerStates[1 - i];\r\n\t\t\t\tconst spawns = processFeathermaneForMinion(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\tdeadEntities,\r\n\t\t\t\t\tdeadEntityPlayerState,\r\n\t\t\t\t\totherPlayerState,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t\tprocessAvenge,\r\n\t\t\t\t);\r\n\t\t\t\tentitiesFromDeathrattles.push(...spawns);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn entitiesFromDeathrattles;\r\n};\r\n\r\nconst processFeathermaneForMinion = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tdeadEntities: BoardEntity[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tgameState: FullGameState,\r\n\tprocessAvenge = true,\r\n) => {\r\n\tconst maxSpawns = 7 - deadEntityPlayerState.board.length;\r\n\tconst allSpawns = [];\r\n\r\n\t// Feathermane\r\n\tif (hasCorrectTribe(deadEntity, Race.BEAST, gameState.allCards)) {\r\n\t\tconst feathermanes =\r\n\t\t\tdeadEntityPlayerState.player.hand\r\n\t\t\t\t?.filter((e) => !e.locked)\r\n\t\t\t\t.filter(\r\n\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\te.cardId === CardIds.FreeFlyingFeathermane_BG27_014 ||\r\n\t\t\t\t\t\te.cardId === CardIds.FreeFlyingFeathermane_BG27_014_G,\r\n\t\t\t\t) ?? [];\r\n\t\tfor (const feathermaneSpawn of feathermanes) {\r\n\t\t\tif (allSpawns.length >= maxSpawns) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tfeathermaneSpawn.locked = true;\r\n\t\t\tconst spawns = spawnEntities(\r\n\t\t\t\tfeathermaneSpawn.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tdeadEntityPlayerState.board,\r\n\t\t\t\tdeadEntityPlayerState.player,\r\n\t\t\t\totherPlayerState.board,\r\n\t\t\t\totherPlayerState.player,\r\n\t\t\t\tgameState.allCards,\r\n\t\t\t\tgameState.cardsData,\r\n\t\t\t\tgameState.sharedState,\r\n\t\t\t\tgameState.spectator,\r\n\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\ttrue,\r\n\t\t\t\t{ ...feathermaneSpawn } as BoardEntity,\r\n\t\t\t);\r\n\r\n\t\t\t// So that it can be flagged as \"unspawned\" if it is not spawned in the end\r\n\t\t\tfor (const spawn of spawns) {\r\n\t\t\t\tspawn.onCanceledSummon = () => (feathermaneSpawn.locked = false);\r\n\t\t\t\t// spawn.backRef = feathermaneSpawn;\r\n\t\t\t}\r\n\t\t\tallSpawns.push(...spawns);\r\n\t\t}\r\n\t}\r\n\r\n\tperformEntitySpawns(\r\n\t\tallSpawns,\r\n\t\tdeadEntityPlayerState.board,\r\n\t\tdeadEntityPlayerState.player,\r\n\t\tdeadEntity,\r\n\t\tindexFromRight,\r\n\t\totherPlayerState.board,\r\n\t\totherPlayerState.player,\r\n\t\tgameState,\r\n\t);\r\n\treturn allSpawns;\r\n};\r\n\r\nexport const processDeathrattleForMinion = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tdeadEntities: BoardEntity[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tgameState: FullGameState,\r\n\tprocessAvenge = true,\r\n) => {\r\n\tconst drEntities = handleNaturalDeathrattle(\r\n\t\tdeadEntity,\r\n\t\tindexFromRight,\r\n\t\tdeadEntities,\r\n\t\tdeadEntityPlayerState,\r\n\t\totherPlayerState,\r\n\t\tgameState,\r\n\t);\r\n\tconst enchEntities = handleEnchantmentsDeathrattle(\r\n\t\tdeadEntity,\r\n\t\tindexFromRight,\r\n\t\tdeadEntities,\r\n\t\tdeadEntityPlayerState,\r\n\t\totherPlayerState,\r\n\t\tgameState,\r\n\t);\r\n\t// Avenge trigger before reborn\r\n\t// http://replays.firestoneapp.com/?reviewId=5bb20eb8-e0ca-47ab-adc7-13134716d568&turn=7&action=6\r\n\tif (processAvenge) {\r\n\t\tapplyAvengeEffects(\r\n\t\t\tdeadEntity,\r\n\t\t\tindexFromRight,\r\n\t\t\tdeadEntityPlayerState.board,\r\n\t\t\tdeadEntityPlayerState.player,\r\n\t\t\totherPlayerState.board,\r\n\t\t\totherPlayerState.player,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\r\n\t// TODO: Feathermane should be applied after the Reborn effects have all been processed\r\n\t// Secrets should be processed here (\"at Avenge speed\")\r\n\tconst afterDeathEntities = applyAfterDeathEffects(\r\n\t\tdeadEntity,\r\n\t\tindexFromRight,\r\n\t\tdeadEntityPlayerState.board,\r\n\t\tdeadEntityPlayerState.player,\r\n\t\totherPlayerState.board,\r\n\t\totherPlayerState.player,\r\n\t\tgameState,\r\n\t);\r\n\treturn [...drEntities, ...enchEntities, ...afterDeathEntities];\r\n};\r\n\r\nconst handleNaturalDeathrattle = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tdeadEntities: BoardEntity[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tgameState: FullGameState,\r\n): readonly BoardEntity[] => {\r\n\tconst modifiedIndexFromRight = Math.min(deadEntityPlayerState.board.length, indexFromRight);\r\n\tconst allSpawns = [];\r\n\tconst spawnsToSpawn = [];\r\n\tfor (const dr of deadEntity.rememberedDeathrattles ?? []) {\r\n\t\tconst entityToProcess: BoardEntity = {\r\n\t\t\t...deadEntity,\r\n\t\t\trememberedDeathrattles: undefined,\r\n\t\t\tcardId: dr.cardId,\r\n\t\t\tpendingAttackBuffs: [],\r\n\t\t};\r\n\t\tconst spawns = handleNaturalDeathrattle(\r\n\t\t\tentityToProcess,\r\n\t\t\tindexFromRight,\r\n\t\t\tdeadEntities,\r\n\t\t\tdeadEntityPlayerState,\r\n\t\t\totherPlayerState,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\t// The spawns have already been processed in the \"handleNaturalDeathrattle\" method\r\n\t\t// spawnsToSpawn.push(...spawns);\r\n\t\tallSpawns.push(...spawns);\r\n\t}\r\n\r\n\tconst entitiesFromNativeDeathrattle: readonly BoardEntity[] = spawnEntitiesFromDeathrattle(\r\n\t\tdeadEntity,\r\n\t\tdeadEntityPlayerState.board,\r\n\t\tdeadEntityPlayerState.player,\r\n\t\totherPlayerState.board,\r\n\t\totherPlayerState.player,\r\n\t\tdeadEntities,\r\n\t\tgameState,\r\n\t);\r\n\tallSpawns.push(...entitiesFromNativeDeathrattle);\r\n\tspawnsToSpawn.push(...entitiesFromNativeDeathrattle);\r\n\tperformEntitySpawns(\r\n\t\tspawnsToSpawn,\r\n\t\tdeadEntityPlayerState.board,\r\n\t\tdeadEntityPlayerState.player,\r\n\t\tdeadEntity,\r\n\t\tmodifiedIndexFromRight,\r\n\t\totherPlayerState.board,\r\n\t\totherPlayerState.player,\r\n\t\tgameState,\r\n\t);\r\n\t// In case of leapfrogger, we want to first spawn the minions, then apply the frog effect\r\n\thandleDeathrattleEffects(\r\n\t\tdeadEntityPlayerState.board,\r\n\t\tdeadEntityPlayerState.player,\r\n\t\tdeadEntity,\r\n\t\tmodifiedIndexFromRight,\r\n\t\totherPlayerState.board,\r\n\t\totherPlayerState.player,\r\n\t\tgameState,\r\n\t);\r\n\r\n\treturn allSpawns;\r\n};\r\n\r\nconst handleEnchantmentsDeathrattle = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tdeadEntities: BoardEntity[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tgameState: FullGameState,\r\n\tskipSpawns = false,\r\n) => {\r\n\tconst modifiedIndexFromRight = Math.min(deadEntityPlayerState.board.length, indexFromRight);\r\n\tconst result = [];\r\n\tfor (const dr of deadEntity.rememberedDeathrattles ?? []) {\r\n\t\tconst entityToProcess: BoardEntity = {\r\n\t\t\t...deadEntity,\r\n\t\t\trememberedDeathrattles: undefined,\r\n\t\t\tcardId: dr.cardId,\r\n\t\t\t// So that cards that rely on the tavern tier use the base entity, and not the enchantment / remembered card\r\n\t\t\ttavernTier: gameState.cardsData.getTavernLevel(deadEntity.cardId),\r\n\t\t\tenchantments: [\r\n\t\t\t\t{\r\n\t\t\t\t\tcardId: dr.cardId,\r\n\t\t\t\t\toriginEntityId: deadEntity.entityId,\r\n\t\t\t\t\trepeats: dr.repeats ?? 1,\r\n\t\t\t\t\ttiming: dr.timing,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t\tpendingAttackBuffs: [],\r\n\t\t};\r\n\t\tconst spawns = handleEnchantmentsDeathrattle(\r\n\t\t\tentityToProcess,\r\n\t\t\tindexFromRight,\r\n\t\t\tdeadEntities,\r\n\t\t\tdeadEntityPlayerState,\r\n\t\t\totherPlayerState,\r\n\t\t\tgameState,\r\n\t\t\t// We skip spawns, otherwise it will be added twice\r\n\t\t\ttrue,\r\n\t\t);\r\n\t\tresult.push(...spawns);\r\n\t}\r\n\tconst entitiesFromEnchantments: readonly BoardEntity[] = spawnEntitiesFromEnchantments(\r\n\t\tdeadEntity,\r\n\t\tdeadEntityPlayerState.board,\r\n\t\tdeadEntityPlayerState.player,\r\n\t\totherPlayerState.board,\r\n\t\totherPlayerState.player,\r\n\t\tgameState,\r\n\t);\r\n\tresult.push(...entitiesFromEnchantments);\r\n\tif (!skipSpawns) {\r\n\t\tperformEntitySpawns(\r\n\t\t\tresult,\r\n\t\t\tdeadEntityPlayerState.board,\r\n\t\t\tdeadEntityPlayerState.player,\r\n\t\t\tdeadEntity,\r\n\t\t\tmodifiedIndexFromRight,\r\n\t\t\totherPlayerState.board,\r\n\t\t\totherPlayerState.player,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\treturn result;\r\n};\r\n\r\nconst processReborns = (deathrattleInput: DeathrattleInput) => {\r\n\t// const entitiesFromReborn: BoardEntity[] = [];\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\t// Process one player first, then the other\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\tconst indexFromRight = playerDeadEntityIndexesFromRight[i][j];\r\n\t\t\t\tconst modifiedIndexFromRight = Math.min(playerStates[i].board.length, indexFromRight);\r\n\t\t\t\tconst deadEntityPlayerState = playerStates[i];\r\n\t\t\t\tconst otherPlayerState = playerStates[1 - i];\r\n\t\t\t\thandleRebornForEntity(\r\n\t\t\t\t\tdeadEntityPlayerState.board,\r\n\t\t\t\t\tdeadEntityPlayerState.player,\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\totherPlayerState.board,\r\n\t\t\t\t\totherPlayerState.player,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handlePostDeathrattleEffects = (deathrattleInput: DeathrattleInput, entitiesFromDeathrattles: BoardEntity[]) => {\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\t// Process one player first, then the other\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tconst deadEntityPlayerState = playerStates[i];\r\n\t\tconst otherPlayerState = playerStates[1 - i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\t// Process from right to left, so that we can set the hasAttacked attribute properly\r\n\t\t\t// If two minions die at the same time, both of which having attacked, but the third in line having not,\r\n\t\t\t// processing them from left to right means the first (leftmost) one will check its right neighbor, which\r\n\t\t\t// is the minion that hasn't attacked\r\n\t\t\tfor (let j = deadEntities.length - 1; j >= 0; j--) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\tconst indexFromRight = playerDeadEntityIndexesFromRight[i][j];\r\n\t\t\t\tconst modifiedIndexFromRight = Math.min(playerStates[i].board.length, indexFromRight);\r\n\t\t\t\thandlePostDeathrattleEffect(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\tdeadEntities,\r\n\t\t\t\t\tdeadEntityPlayerState,\r\n\t\t\t\t\totherPlayerState,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t\tentitiesFromDeathrattles,\r\n\t\t\t\t\tdeadEntityPlayerState.player.friendly,\r\n\t\t\t\t\tdeathrattleInput,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const handleDeathrattles = (deathrattleInput: DeathrattleInput) => {\r\n\torchestrateMinionDeathEffects(deathrattleInput, false, false);\r\n};\r\n\r\nconst handlePostDeathrattleEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tdeadEntities: BoardEntity[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tgameState: FullGameState,\r\n\tspawnedEntities: BoardEntity[],\r\n\tisPlayer: boolean,\r\n\tdeathrattleInput: DeathrattleInput,\r\n) => {\r\n\t// This doesn't work if the entity that was to the right died.\r\n\tconst entityRightToSpawns =\r\n\t\tindexFromRight === 0 ? null : deadEntityPlayerState.board[deadEntityPlayerState.board.length - indexFromRight];\r\n\t// To handle minions attack tokens\r\n\t// See http://replays.firestoneapp.com/?reviewId=0583d6a4-6ed0-4b20-894e-4ceb560894fe&turn=6&action=11\r\n\t// When a minion dies, the spawn are either elligible to attack next turn or not\r\n\t// If the minion right to the spawned minion has already attacked, then the spawned\r\n\t// minion cannot attack\r\n\tspawnedEntities.forEach((entity) => {\r\n\t\tentity.hasAttacked = deadEntity.hasAttacked > 1 ? 1 : entityRightToSpawns?.hasAttacked ?? 0;\r\n\t});\r\n\r\n\tif (\r\n\t\tdeadEntityPlayerState.player.questRewards?.includes(CardIds.RitualDagger_BG24_Reward_113) ||\r\n\t\tdeadEntityPlayerState.player.questRewards?.includes(CardIds.RitualDagger_BG24_Reward_113_ALT)\r\n\t) {\r\n\t\tconst ogDeadEntity = gameState.sharedState.deaths.find((entity) => entity.entityId === deadEntity.entityId);\r\n\t\tif (ogDeadEntity) {\r\n\t\t\togDeadEntity.attack += 4;\r\n\t\t\togDeadEntity.health += 4;\r\n\t\t}\r\n\t}\r\n\r\n\t// ISSUE: when we do this, we change the minion's stats before processing deathrattle effects, which can mess\r\n\t// up the simulation in some cases (like Nightbane, Ignited)\r\n\t// FIX: we do it in postDeathrattleEfects, not when removing minions from the board\r\n\tif (hasCorrectTribe(deadEntity, Race.UNDEAD, gameState.allCards)) {\r\n\t\tif (deadEntityPlayerState.player.globalInfo.UndeadAttackBonus > 0) {\r\n\t\t\tdeadEntity.attack = Math.max(\r\n\t\t\t\t0,\r\n\t\t\t\tdeadEntity.attack - deadEntityPlayerState.player.globalInfo.UndeadAttackBonus,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, Race.BEAST, gameState.allCards)) {\r\n\t\tif (deadEntityPlayerState.player.globalInfo.GoldrinnBuffAtk > 0) {\r\n\t\t\tdeadEntity.attack = Math.max(\r\n\t\t\t\t0,\r\n\t\t\t\tdeadEntity.attack - deadEntityPlayerState.player.globalInfo.GoldrinnBuffAtk,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n};\r\n\r\ninterface DeathrattleInput {\r\n\tgameState: FullGameState;\r\n\tplayerDeadEntities: BoardEntity[];\r\n\tplayerDeadEntityIndexesFromRight: number[];\r\n\topponentDeadEntities: BoardEntity[];\r\n\topponentDeadEntityIndexesFromRight: number[];\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"deathrattle-orchestration.js","sourceRoot":"","sources":["../../src/simulation/deathrattle-orchestration.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAE7D,oCAA2C;AAC3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qBAAqB,CAAC,MAAM,CAAC,UAAU,CAAC,eAAe,CAC3E,CAAC;SACF;KACD;AACF,CAAC,CAAC","sourcesContent":["import { CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { hasCorrectTribe } from '../utils';\r\nimport { applyAvengeEffects } from './avenge';\r\nimport { applyAfterDeathEffects } from './death-effects';\r\nimport {\r\n\tapplyWheneverMinionDiesEffect,\r\n\thandleAfterMinionKillsEffect,\r\n\thandleDeathrattleEffects,\r\n} from './deathrattle-effects';\r\nimport { spawnEntities, spawnEntitiesFromDeathrattle, spawnEntitiesFromEnchantments } from './deathrattle-spawns';\r\nimport { FullGameState, PlayerState } from './internal-game-state';\r\nimport { handleRebornForEntity } from './reborn';\r\nimport { performEntitySpawns } from './spawns';\r\n\r\n// FIXME:\r\n// From Mitchell on Discord:\r\n// - Minions die left to right\r\n// - When a minion dies, it procs natural deathrattle, added deathrattles, and then all avenges progress\r\n// by 1 (and trigger as necessary)\r\n// - Then next minion\r\n// - After ALL deathrattles and avenges are done, Reborn triggers\r\n// - (Ideally after all of that I would want Feathermane to trigger, but that is not what it does right now.\r\n// Right now it triggers at deathrattle speed rather than after Reborn speed)\r\nexport const orchestrateMinionDeathEffects = (\r\n\tdeathrattleInput: DeathrattleInput,\r\n\tprocessAvenge = true,\r\n\tprocessReborn = true,\r\n) => {\r\n\t// Icesnarl / Rokara here?\r\n\thandleAfterMinionsKillEffects(deathrattleInput);\r\n\r\n\t// Not sure about this\r\n\thandleWheneverMinionsDieEffects(deathrattleInput);\r\n\r\n\tconst playerBoardBefore = [...deathrattleInput.gameState.gameState.player.board];\r\n\tconst opponentBoardBefore = [...deathrattleInput.gameState.gameState.opponent.board];\r\n\r\n\tconst entitiesFromDeathrattles = processDeathrattles(deathrattleInput, processAvenge);\r\n\r\n\t// Hack to try and fix how reborn indices are handled when there are spawns during the deathrattle phase\r\n\t// Ideally, this should probably be rewritten completely to keep the dead entities in the board itself\r\n\t// so we can use that as a source for the spawn index. However this is a big rewrite with lots of\r\n\t// potential side-effects\r\n\tconst playerBoardAfter = [...deathrattleInput.gameState.gameState.player.board];\r\n\tconst opponentBoardAfter = [...deathrattleInput.gameState.gameState.opponent.board];\r\n\tconst opponentIndexOfSpawnedEntities = opponentBoardAfter\r\n\t\t.filter((entity) => !opponentBoardBefore.includes(entity))\r\n\t\t.map((entity) => opponentBoardAfter.length - opponentBoardAfter.indexOf(entity) - 1);\r\n\tconst playerIndexOfSpawnedEntities = playerBoardAfter\r\n\t\t.filter((entity) => !playerBoardBefore.includes(entity))\r\n\t\t.map((entity) => playerBoardAfter.length - playerBoardAfter.indexOf(entity) - 1);\r\n\tdeathrattleInput.opponentDeadEntityIndexesFromRight = deathrattleInput.opponentDeadEntityIndexesFromRight.map(\r\n\t\t(previousIndex) => {\r\n\t\t\topponentIndexOfSpawnedEntities.forEach((index) => {\r\n\t\t\t\tif (index < previousIndex) {\r\n\t\t\t\t\tpreviousIndex++;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\treturn previousIndex;\r\n\t\t},\r\n\t);\r\n\tdeathrattleInput.playerDeadEntityIndexesFromRight = deathrattleInput.playerDeadEntityIndexesFromRight.map(\r\n\t\t(previousIndex) => {\r\n\t\t\tplayerIndexOfSpawnedEntities.forEach((index) => {\r\n\t\t\t\tif (index < previousIndex) {\r\n\t\t\t\t\tpreviousIndex++;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\treturn previousIndex;\r\n\t\t},\r\n\t);\r\n\r\n\tif (processReborn) {\r\n\t\tprocessReborns(deathrattleInput);\r\n\t}\r\n\r\n\tconst entitiesFromFeathermanes = processFeathermaneEffects(deathrattleInput);\r\n\thandlePostDeathrattleEffects(deathrattleInput, [...entitiesFromDeathrattles, ...entitiesFromFeathermanes]);\r\n};\r\n\r\nconst handleAfterMinionsKillEffects = (deathrattleInput: DeathrattleInput) => {\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\thandleAfterMinionKillsEffect(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tplayerDeadEntityIndexesFromRight[i][j],\r\n\t\t\t\t\tplayerStates[i].board,\r\n\t\t\t\t\tplayerStates[i].player,\r\n\t\t\t\t\tplayerStates[1 - i].board,\r\n\t\t\t\t\tplayerStates[1 - i].player,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleWheneverMinionsDieEffects = (deathrattleInput: DeathrattleInput) => {\r\n\t// Wildfire Element is applied first, before the DR spawns\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\tapplyWheneverMinionDiesEffect(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tplayerDeadEntityIndexesFromRight[i][j],\r\n\t\t\t\t\tplayerStates[i].board,\r\n\t\t\t\t\tplayerStates[i].player,\r\n\t\t\t\t\tplayerStates[1 - i].board,\r\n\t\t\t\t\tplayerStates[1 - i].player,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst processDeathrattles = (deathrattleInput: DeathrattleInput, processAvenge = true): BoardEntity[] => {\r\n\tconst entitiesFromDeathrattles: BoardEntity[] = [];\r\n\t// Deathrattles are handled left to right\r\n\t// Then for each minion, natural deathrattles are processed first, then enchantments\r\n\t// http://replays.firestoneapp.com/?reviewId=ec5428bf-a599-4f4c-bea9-8acad5075cb8&turn=11&action=1\r\n\t// http://replays.firestoneapp.com/?reviewId=f32e734a-d5a2-4fa4-ad10-94019969cdd7&turn=6&action=22\r\n\t// http://replays.firestoneapp.com/?reviewId=ea9503c9-2795-49f0-866b-9ea856cec7df&turn=11&action=3\r\n\t// http://replays.firestoneapp.com/?reviewId=1ff37e17-704c-4a73-8c78-377c52b6cb42&turn=13&action=1 is a trap: the enchantment is on the first\r\n\t// minion, but the DR is on the second one.\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\t// Process one player first, then the other\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\t// Entities are processed left to right\r\n\t\t\t// TODO: in fact, the processing order is summoning order, so maybe we can just use the entityId\r\n\t\t\t// to determine the order? https://x.com/LoewenMitchell/status/1750792974383173676?s=20\r\n\t\t\t// \"It should be summoned order (which is most cases would be left to right but mid-combat that could change).\"\r\n\t\t\t// This doesn't actually work: http://replays.firestoneapp.com/?reviewId=ec5428bf-a599-4f4c-bea9-8acad5075cb8&turn=11&action=6\r\n\t\t\t// deadEntities.sort((a, b) => a.entityId - b.entityId);\r\n\t\t\t// So we would need to find another proxy for the order\r\n\t\t\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\tconst deadEntityAttack = deadEntity.attack;\r\n\t\t\t\tconst indexFromRight = playerDeadEntityIndexesFromRight[i][j];\r\n\t\t\t\tconst modifiedIndexFromRight = Math.min(playerStates[i].board.length, indexFromRight);\r\n\t\t\t\tconst deadEntityPlayerState = playerStates[i];\r\n\t\t\t\tconst otherPlayerState = playerStates[1 - i];\r\n\t\t\t\tconst spawns = processDeathrattleForMinion(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\tdeadEntities,\r\n\t\t\t\t\tdeadEntityPlayerState,\r\n\t\t\t\t\totherPlayerState,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t\tprocessAvenge,\r\n\t\t\t\t);\r\n\t\t\t\tentitiesFromDeathrattles.push(...spawns);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn entitiesFromDeathrattles;\r\n};\r\n\r\nconst processFeathermaneEffects = (deathrattleInput: DeathrattleInput, processAvenge = true): BoardEntity[] => {\r\n\tconst entitiesFromDeathrattles: BoardEntity[] = [];\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\t// Process one player first, then the other\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\t// Entities are processed left to right\r\n\t\t\t// TODO: in fact, the processing order is summoning order, so maybe we can just use the entityId\r\n\t\t\t// to determine the order? https://x.com/LoewenMitchell/status/1750792974383173676?s=20\r\n\t\t\t// \"It should be summoned order (which is most cases would be left to right but mid-combat that could change).\"\r\n\t\t\t// This doesn't actually work: http://replays.firestoneapp.com/?reviewId=ec5428bf-a599-4f4c-bea9-8acad5075cb8&turn=11&action=6\r\n\t\t\t// deadEntities.sort((a, b) => a.entityId - b.entityId);\r\n\t\t\t// So we would need to find another proxy for the order\r\n\t\t\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\tconst indexFromRight = playerDeadEntityIndexesFromRight[i][j];\r\n\t\t\t\tconst modifiedIndexFromRight = Math.min(playerStates[i].board.length, indexFromRight);\r\n\t\t\t\tconst deadEntityPlayerState = playerStates[i];\r\n\t\t\t\tconst otherPlayerState = playerStates[1 - i];\r\n\t\t\t\tconst spawns = processFeathermaneForMinion(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\tdeadEntities,\r\n\t\t\t\t\tdeadEntityPlayerState,\r\n\t\t\t\t\totherPlayerState,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t\tprocessAvenge,\r\n\t\t\t\t);\r\n\t\t\t\tentitiesFromDeathrattles.push(...spawns);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn entitiesFromDeathrattles;\r\n};\r\n\r\nconst processFeathermaneForMinion = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tdeadEntities: BoardEntity[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tgameState: FullGameState,\r\n\tprocessAvenge = true,\r\n) => {\r\n\tconst maxSpawns = 7 - deadEntityPlayerState.board.length;\r\n\tconst allSpawns = [];\r\n\r\n\t// Feathermane\r\n\tif (hasCorrectTribe(deadEntity, Race.BEAST, gameState.allCards)) {\r\n\t\tconst feathermanes =\r\n\t\t\tdeadEntityPlayerState.player.hand\r\n\t\t\t\t?.filter((e) => !e.locked)\r\n\t\t\t\t.filter(\r\n\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\te.cardId === CardIds.FreeFlyingFeathermane_BG27_014 ||\r\n\t\t\t\t\t\te.cardId === CardIds.FreeFlyingFeathermane_BG27_014_G,\r\n\t\t\t\t) ?? [];\r\n\t\tfor (const feathermaneSpawn of feathermanes) {\r\n\t\t\tif (allSpawns.length >= maxSpawns) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tfeathermaneSpawn.locked = true;\r\n\t\t\tconst spawns = spawnEntities(\r\n\t\t\t\tfeathermaneSpawn.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tdeadEntityPlayerState.board,\r\n\t\t\t\tdeadEntityPlayerState.player,\r\n\t\t\t\totherPlayerState.board,\r\n\t\t\t\totherPlayerState.player,\r\n\t\t\t\tgameState.allCards,\r\n\t\t\t\tgameState.cardsData,\r\n\t\t\t\tgameState.sharedState,\r\n\t\t\t\tgameState.spectator,\r\n\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\ttrue,\r\n\t\t\t\t{ ...feathermaneSpawn } as BoardEntity,\r\n\t\t\t);\r\n\r\n\t\t\t// So that it can be flagged as \"unspawned\" if it is not spawned in the end\r\n\t\t\tfor (const spawn of spawns) {\r\n\t\t\t\tspawn.onCanceledSummon = () => (feathermaneSpawn.locked = false);\r\n\t\t\t\t// spawn.backRef = feathermaneSpawn;\r\n\t\t\t}\r\n\t\t\tallSpawns.push(...spawns);\r\n\t\t}\r\n\t}\r\n\r\n\tperformEntitySpawns(\r\n\t\tallSpawns,\r\n\t\tdeadEntityPlayerState.board,\r\n\t\tdeadEntityPlayerState.player,\r\n\t\tdeadEntity,\r\n\t\tindexFromRight,\r\n\t\totherPlayerState.board,\r\n\t\totherPlayerState.player,\r\n\t\tgameState,\r\n\t);\r\n\treturn allSpawns;\r\n};\r\n\r\nexport const processDeathrattleForMinion = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tdeadEntities: BoardEntity[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tgameState: FullGameState,\r\n\tprocessAvenge = true,\r\n) => {\r\n\tconst drEntities = handleNaturalDeathrattle(\r\n\t\tdeadEntity,\r\n\t\tindexFromRight,\r\n\t\tdeadEntities,\r\n\t\tdeadEntityPlayerState,\r\n\t\totherPlayerState,\r\n\t\tgameState,\r\n\t);\r\n\tconst enchEntities = handleEnchantmentsDeathrattle(\r\n\t\tdeadEntity,\r\n\t\tindexFromRight,\r\n\t\tdeadEntities,\r\n\t\tdeadEntityPlayerState,\r\n\t\totherPlayerState,\r\n\t\tgameState,\r\n\t);\r\n\t// Avenge trigger before reborn\r\n\t// http://replays.firestoneapp.com/?reviewId=5bb20eb8-e0ca-47ab-adc7-13134716d568&turn=7&action=6\r\n\tif (processAvenge) {\r\n\t\tapplyAvengeEffects(\r\n\t\t\tdeadEntity,\r\n\t\t\tindexFromRight,\r\n\t\t\tdeadEntityPlayerState.board,\r\n\t\t\tdeadEntityPlayerState.player,\r\n\t\t\totherPlayerState.board,\r\n\t\t\totherPlayerState.player,\r\n\t\t\tgameState,\r\n\t\t\t[...drEntities, ...enchEntities],\r\n\t\t);\r\n\t}\r\n\r\n\t// TODO: Feathermane should be applied after the Reborn effects have all been processed\r\n\t// Secrets should be processed here (\"at Avenge speed\")\r\n\tconst afterDeathEntities = applyAfterDeathEffects(\r\n\t\tdeadEntity,\r\n\t\tindexFromRight,\r\n\t\tdeadEntityPlayerState.board,\r\n\t\tdeadEntityPlayerState.player,\r\n\t\totherPlayerState.board,\r\n\t\totherPlayerState.player,\r\n\t\tgameState,\r\n\t);\r\n\treturn [...drEntities, ...enchEntities, ...afterDeathEntities];\r\n};\r\n\r\nconst handleNaturalDeathrattle = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tdeadEntities: BoardEntity[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tgameState: FullGameState,\r\n): readonly BoardEntity[] => {\r\n\tconst modifiedIndexFromRight = Math.min(deadEntityPlayerState.board.length, indexFromRight);\r\n\tconst allSpawns = [];\r\n\tconst spawnsToSpawn = [];\r\n\tfor (const dr of deadEntity.rememberedDeathrattles ?? []) {\r\n\t\tconst entityToProcess: BoardEntity = {\r\n\t\t\t...deadEntity,\r\n\t\t\trememberedDeathrattles: undefined,\r\n\t\t\tcardId: dr.cardId,\r\n\t\t\tpendingAttackBuffs: [],\r\n\t\t};\r\n\t\tconst spawns = handleNaturalDeathrattle(\r\n\t\t\tentityToProcess,\r\n\t\t\tindexFromRight,\r\n\t\t\tdeadEntities,\r\n\t\t\tdeadEntityPlayerState,\r\n\t\t\totherPlayerState,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\t// The spawns have already been processed in the \"handleNaturalDeathrattle\" method\r\n\t\t// spawnsToSpawn.push(...spawns);\r\n\t\tallSpawns.push(...spawns);\r\n\t}\r\n\r\n\tconst entitiesFromNativeDeathrattle: readonly BoardEntity[] = spawnEntitiesFromDeathrattle(\r\n\t\tdeadEntity,\r\n\t\tdeadEntityPlayerState.board,\r\n\t\tdeadEntityPlayerState.player,\r\n\t\totherPlayerState.board,\r\n\t\totherPlayerState.player,\r\n\t\tdeadEntities,\r\n\t\tgameState,\r\n\t);\r\n\tallSpawns.push(...entitiesFromNativeDeathrattle);\r\n\tspawnsToSpawn.push(...entitiesFromNativeDeathrattle);\r\n\tperformEntitySpawns(\r\n\t\tspawnsToSpawn,\r\n\t\tdeadEntityPlayerState.board,\r\n\t\tdeadEntityPlayerState.player,\r\n\t\tdeadEntity,\r\n\t\tmodifiedIndexFromRight,\r\n\t\totherPlayerState.board,\r\n\t\totherPlayerState.player,\r\n\t\tgameState,\r\n\t);\r\n\t// In case of leapfrogger, we want to first spawn the minions, then apply the frog effect\r\n\thandleDeathrattleEffects(\r\n\t\tdeadEntityPlayerState.board,\r\n\t\tdeadEntityPlayerState.player,\r\n\t\tdeadEntity,\r\n\t\tmodifiedIndexFromRight,\r\n\t\totherPlayerState.board,\r\n\t\totherPlayerState.player,\r\n\t\tgameState,\r\n\t);\r\n\r\n\treturn allSpawns;\r\n};\r\n\r\nconst handleEnchantmentsDeathrattle = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tdeadEntities: BoardEntity[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tgameState: FullGameState,\r\n\tskipSpawns = false,\r\n) => {\r\n\tconst modifiedIndexFromRight = Math.min(deadEntityPlayerState.board.length, indexFromRight);\r\n\tconst result = [];\r\n\tfor (const dr of deadEntity.rememberedDeathrattles ?? []) {\r\n\t\tconst entityToProcess: BoardEntity = {\r\n\t\t\t...deadEntity,\r\n\t\t\trememberedDeathrattles: undefined,\r\n\t\t\tcardId: dr.cardId,\r\n\t\t\t// So that cards that rely on the tavern tier use the base entity, and not the enchantment / remembered card\r\n\t\t\ttavernTier: gameState.cardsData.getTavernLevel(deadEntity.cardId),\r\n\t\t\tenchantments: [\r\n\t\t\t\t{\r\n\t\t\t\t\tcardId: dr.cardId,\r\n\t\t\t\t\toriginEntityId: deadEntity.entityId,\r\n\t\t\t\t\trepeats: dr.repeats ?? 1,\r\n\t\t\t\t\ttiming: dr.timing,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t\tpendingAttackBuffs: [],\r\n\t\t};\r\n\t\tconst spawns = handleEnchantmentsDeathrattle(\r\n\t\t\tentityToProcess,\r\n\t\t\tindexFromRight,\r\n\t\t\tdeadEntities,\r\n\t\t\tdeadEntityPlayerState,\r\n\t\t\totherPlayerState,\r\n\t\t\tgameState,\r\n\t\t\t// We skip spawns, otherwise it will be added twice\r\n\t\t\ttrue,\r\n\t\t);\r\n\t\tresult.push(...spawns);\r\n\t}\r\n\tconst entitiesFromEnchantments: readonly BoardEntity[] = spawnEntitiesFromEnchantments(\r\n\t\tdeadEntity,\r\n\t\tdeadEntityPlayerState.board,\r\n\t\tdeadEntityPlayerState.player,\r\n\t\totherPlayerState.board,\r\n\t\totherPlayerState.player,\r\n\t\tgameState,\r\n\t);\r\n\tresult.push(...entitiesFromEnchantments);\r\n\tif (!skipSpawns) {\r\n\t\tperformEntitySpawns(\r\n\t\t\tresult,\r\n\t\t\tdeadEntityPlayerState.board,\r\n\t\t\tdeadEntityPlayerState.player,\r\n\t\t\tdeadEntity,\r\n\t\t\tmodifiedIndexFromRight,\r\n\t\t\totherPlayerState.board,\r\n\t\t\totherPlayerState.player,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\treturn result;\r\n};\r\n\r\nconst processReborns = (deathrattleInput: DeathrattleInput) => {\r\n\t// const entitiesFromReborn: BoardEntity[] = [];\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\t// Process one player first, then the other\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\tfor (let j = 0; j < deadEntities.length; j++) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\tconst indexFromRight = playerDeadEntityIndexesFromRight[i][j];\r\n\t\t\t\tconst modifiedIndexFromRight = Math.min(playerStates[i].board.length, indexFromRight);\r\n\t\t\t\tconst deadEntityPlayerState = playerStates[i];\r\n\t\t\t\tconst otherPlayerState = playerStates[1 - i];\r\n\t\t\t\thandleRebornForEntity(\r\n\t\t\t\t\tdeadEntityPlayerState.board,\r\n\t\t\t\t\tdeadEntityPlayerState.player,\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\totherPlayerState.board,\r\n\t\t\t\t\totherPlayerState.player,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handlePostDeathrattleEffects = (deathrattleInput: DeathrattleInput, entitiesFromDeathrattles: BoardEntity[]) => {\r\n\tconst processPlayerFirst = Math.random() > 0.5;\r\n\tconst playerStates = processPlayerFirst\r\n\t\t? [deathrattleInput.gameState.gameState.player, deathrattleInput.gameState.gameState.opponent]\r\n\t\t: [deathrattleInput.gameState.gameState.opponent, deathrattleInput.gameState.gameState.player];\r\n\tconst playerDeadEntities = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntities, deathrattleInput.opponentDeadEntities]\r\n\t\t: [deathrattleInput.opponentDeadEntities, deathrattleInput.playerDeadEntities];\r\n\tconst playerDeadEntityIndexesFromRight = processPlayerFirst\r\n\t\t? [deathrattleInput.playerDeadEntityIndexesFromRight, deathrattleInput.opponentDeadEntityIndexesFromRight]\r\n\t\t: [deathrattleInput.opponentDeadEntityIndexesFromRight, deathrattleInput.playerDeadEntityIndexesFromRight];\r\n\t// Process one player first, then the other\r\n\tfor (let i = 0; i < 2; i++) {\r\n\t\tconst deadEntities = playerDeadEntities[i];\r\n\t\tconst deadEntityPlayerState = playerStates[i];\r\n\t\tconst otherPlayerState = playerStates[1 - i];\r\n\t\tif (deadEntities.length >= 0) {\r\n\t\t\t// Process from right to left, so that we can set the hasAttacked attribute properly\r\n\t\t\t// If two minions die at the same time, both of which having attacked, but the third in line having not,\r\n\t\t\t// processing them from left to right means the first (leftmost) one will check its right neighbor, which\r\n\t\t\t// is the minion that hasn't attacked\r\n\t\t\tfor (let j = deadEntities.length - 1; j >= 0; j--) {\r\n\t\t\t\tconst deadEntity = deadEntities[j];\r\n\t\t\t\tconst indexFromRight = playerDeadEntityIndexesFromRight[i][j];\r\n\t\t\t\tconst modifiedIndexFromRight = Math.min(playerStates[i].board.length, indexFromRight);\r\n\t\t\t\thandlePostDeathrattleEffect(\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\tdeadEntities,\r\n\t\t\t\t\tdeadEntityPlayerState,\r\n\t\t\t\t\totherPlayerState,\r\n\t\t\t\t\tdeathrattleInput.gameState,\r\n\t\t\t\t\tentitiesFromDeathrattles,\r\n\t\t\t\t\tdeadEntityPlayerState.player.friendly,\r\n\t\t\t\t\tdeathrattleInput,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const handleDeathrattles = (deathrattleInput: DeathrattleInput) => {\r\n\torchestrateMinionDeathEffects(deathrattleInput, false, false);\r\n};\r\n\r\nconst handlePostDeathrattleEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tindexFromRight: number,\r\n\tdeadEntities: BoardEntity[],\r\n\tdeadEntityPlayerState: PlayerState,\r\n\totherPlayerState: PlayerState,\r\n\tgameState: FullGameState,\r\n\tspawnedEntities: BoardEntity[],\r\n\tisPlayer: boolean,\r\n\tdeathrattleInput: DeathrattleInput,\r\n) => {\r\n\t// This doesn't work if the entity that was to the right died.\r\n\tconst entityRightToSpawns =\r\n\t\tindexFromRight === 0 ? null : deadEntityPlayerState.board[deadEntityPlayerState.board.length - indexFromRight];\r\n\t// To handle minions attack tokens\r\n\t// See http://replays.firestoneapp.com/?reviewId=0583d6a4-6ed0-4b20-894e-4ceb560894fe&turn=6&action=11\r\n\t// When a minion dies, the spawn are either elligible to attack next turn or not\r\n\t// If the minion right to the spawned minion has already attacked, then the spawned\r\n\t// minion cannot attack\r\n\tspawnedEntities.forEach((entity) => {\r\n\t\tentity.hasAttacked = deadEntity.hasAttacked > 1 ? 1 : entityRightToSpawns?.hasAttacked ?? 0;\r\n\t});\r\n\r\n\tif (\r\n\t\tdeadEntityPlayerState.player.questRewards?.includes(CardIds.RitualDagger_BG24_Reward_113) ||\r\n\t\tdeadEntityPlayerState.player.questRewards?.includes(CardIds.RitualDagger_BG24_Reward_113_ALT)\r\n\t) {\r\n\t\tconst ogDeadEntity = gameState.sharedState.deaths.find((entity) => entity.entityId === deadEntity.entityId);\r\n\t\tif (ogDeadEntity) {\r\n\t\t\togDeadEntity.attack += 4;\r\n\t\t\togDeadEntity.health += 4;\r\n\t\t}\r\n\t}\r\n\r\n\t// ISSUE: when we do this, we change the minion's stats before processing deathrattle effects, which can mess\r\n\t// up the simulation in some cases (like Nightbane, Ignited)\r\n\t// FIX: we do it in postDeathrattleEfects, not when removing minions from the board\r\n\tif (hasCorrectTribe(deadEntity, Race.UNDEAD, gameState.allCards)) {\r\n\t\tif (deadEntityPlayerState.player.globalInfo.UndeadAttackBonus > 0) {\r\n\t\t\tdeadEntity.attack = Math.max(\r\n\t\t\t\t0,\r\n\t\t\t\tdeadEntity.attack - deadEntityPlayerState.player.globalInfo.UndeadAttackBonus,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, Race.BEAST, gameState.allCards)) {\r\n\t\tif (deadEntityPlayerState.player.globalInfo.GoldrinnBuffAtk > 0) {\r\n\t\t\tdeadEntity.attack = Math.max(\r\n\t\t\t\t0,\r\n\t\t\t\tdeadEntity.attack - deadEntityPlayerState.player.globalInfo.GoldrinnBuffAtk,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n};\r\n\r\ninterface DeathrattleInput {\r\n\tgameState: FullGameState;\r\n\tplayerDeadEntities: BoardEntity[];\r\n\tplayerDeadEntityIndexesFromRight: number[];\r\n\topponentDeadEntities: BoardEntity[];\r\n\topponentDeadEntityIndexesFromRight: number[];\r\n}\r\n"]}
|
|
@@ -15,7 +15,7 @@ const getValidDeathrattles = (board, gameState) => {
|
|
|
15
15
|
if (entity.enchantments &&
|
|
16
16
|
entity.enchantments
|
|
17
17
|
.map((enchantment) => enchantment.cardId)
|
|
18
|
-
.some((enchantmentId) => simulate_bgs_battle_1.
|
|
18
|
+
.some((enchantmentId) => simulate_bgs_battle_1.VALID_DEATHRATTLE_ENCHANTMENTS.includes(enchantmentId))) {
|
|
19
19
|
return true;
|
|
20
20
|
}
|
|
21
21
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deathrattle-utils.js","sourceRoot":"","sources":["../../src/simulation/deathrattle-utils.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"deathrattle-utils.js","sourceRoot":"","sources":["../../src/simulation/deathrattle-utils.ts"],"names":[],"mappings":";;;AAEA,gEAAwE;AACxE,oCAAuC;AAGhC,MAAM,oBAAoB,GAAG,CAAC,KAAoB,EAAE,SAAwB,EAAiB,EAAE;IACrG,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;;QAC9B,IAAI,IAAA,mBAAW,EAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,EAAE;YAC1E,OAAO,IAAI,CAAC;SACZ;QACD,IAAI,MAAA,MAAM,CAAC,sBAAsB,0CAAE,MAAM,EAAE;YAC1C,OAAO,IAAI,CAAC;SACZ;QACD,IACC,MAAM,CAAC,YAAY;YACnB,MAAM,CAAC,YAAY;iBACjB,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC;iBACxC,IAAI,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,oDAA8B,CAAC,QAAQ,CAAC,aAAwB,CAAC,CAAC,EAC3F;YACD,OAAO,IAAI,CAAC;SACZ;QACD,OAAO,KAAK,CAAC;IACd,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC;AAlBW,QAAA,oBAAoB,wBAkB/B","sourcesContent":["import { CardIds } from '@firestone-hs/reference-data';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { VALID_DEATHRATTLE_ENCHANTMENTS } from '../simulate-bgs-battle';\r\nimport { hasMechanic } from '../utils';\r\nimport { FullGameState } from './internal-game-state';\r\n\r\nexport const getValidDeathrattles = (board: BoardEntity[], gameState: FullGameState): BoardEntity[] => {\r\n\treturn board.filter((entity) => {\r\n\t\tif (hasMechanic(gameState.allCards.getCard(entity.cardId), 'DEATHRATTLE')) {\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\tif (entity.rememberedDeathrattles?.length) {\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\tif (\r\n\t\t\tentity.enchantments &&\r\n\t\t\tentity.enchantments\r\n\t\t\t\t.map((enchantment) => enchantment.cardId)\r\n\t\t\t\t.some((enchantmentId) => VALID_DEATHRATTLE_ENCHANTMENTS.includes(enchantmentId as CardIds))\r\n\t\t) {\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\treturn false;\r\n\t});\r\n};\r\n"]}
|
|
@@ -12,7 +12,7 @@ const applyOnAttackEffects = (attacker, attackingBoard, attackingBoardHero, defe
|
|
|
12
12
|
attacker.cardId === "BG27_017_G") {
|
|
13
13
|
const neighbours = (0, attack_1.getNeighbours)(defendingBoard, defendingEntity);
|
|
14
14
|
const targets = attacker.cardId === "BG27_017_G" ? neighbours : [(0, utils_1.pickRandom)(neighbours)];
|
|
15
|
-
targets.forEach((target) => {
|
|
15
|
+
[defendingEntity, ...targets].forEach((target) => {
|
|
16
16
|
gameState.spectator.registerPowerTarget(attacker, target, defendingBoard, attackingBoardHero, defendingBoardHero);
|
|
17
17
|
(0, attack_1.dealDamageToMinion)(target, defendingBoard, defendingBoardHero, attacker, attacker.attack, attackingBoard, attackingBoardHero, gameState);
|
|
18
18
|
});
|
|
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AC,CAAC,MAAiB,CAAC,IAAI,CAAC,CAAC,iBAAiB,GAAG,CAAC,CAC3D,CAAC;IAEF,IAAI,CAAC,CAAC,SAAS,IAAI,QAAQ,CAAC,uBAAuB,IAAI,IAAI,EAAE;QAC5D,QAAQ,CAAC,uBAAuB,GAAG,CAAC,CAAC;QAErC,cAAc;aACZ,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CACb;;;SAGC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAiB,CAAC,CAC/B;aACA,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACd,CAAC,CAAC,iBAAiB,EAAE,CAAC;QACvB,CAAC,CAAC,CAAC;KACJ;AACF,CAAC,CAAC;AA1OW,QAAA,oBAAoB,wBA0O/B","sourcesContent":["import { CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { pickRandom } from '../services/utils';\r\nimport { isCorrectTribe } from '../utils';\r\nimport { dealDamageToMinion, getNeighbours } from './attack';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { modifyStats } from './stats';\r\n\r\n// Whenever it attacks\r\nexport const applyOnAttackEffects = (\r\n\tattacker: 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): void => {\r\n\t// Damage happens before the entity is buffed, e.g. before an attack buff from Roaring Rallier\r\n\tif (\r\n\t\tattacker.cardId === CardIds.ObsidianRavager_BG27_017 ||\r\n\t\tattacker.cardId === CardIds.ObsidianRavager_BG27_017_G\r\n\t) {\r\n\t\tconst neighbours = getNeighbours(defendingBoard, defendingEntity);\r\n\t\tconst targets = attacker.cardId === CardIds.ObsidianRavager_BG27_017_G ? neighbours : [pickRandom(neighbours)];\r\n\t\ttargets.forEach((target) => {\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tattacker,\r\n\t\t\t\ttarget,\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\t// damageDoneByAttacker +=\r\n\t\t\tdealDamageToMinion(\r\n\t\t\t\ttarget,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tattacker,\r\n\t\t\t\tattacker.attack,\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\r\n\t// Ripsnarl Captain\r\n\tif (isCorrectTribe(gameState.allCards.getCard(attacker.cardId).races, Race.PIRATE)) {\r\n\t\tconst ripsnarls = attackingBoard.filter((e) => e.cardId === CardIds.RipsnarlCaptain_BGS_056);\r\n\t\tconst ripsnarlsTB = attackingBoard.filter(\r\n\t\t\t(entity) => entity.cardId === CardIds.RipsnarlCaptain_TB_BaconUps_139,\r\n\t\t);\r\n\t\tripsnarls.forEach((captain) => {\r\n\t\t\tmodifyStats(attacker, 3, 0, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tcaptain,\r\n\t\t\t\tattacker,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t);\r\n\t\t});\r\n\t\tripsnarlsTB.forEach((captain) => {\r\n\t\t\tmodifyStats(attacker, 6, 0, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tcaptain,\r\n\t\t\t\tattacker,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\r\n\t// Dread Admiral Eliza\r\n\tif (isCorrectTribe(gameState.allCards.getCard(attacker.cardId).races, Race.PIRATE)) {\r\n\t\tconst elizas = attackingBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.DreadAdmiralEliza_BGS_047 || e.cardId === CardIds.AdmiralElizaGoreblade_BG27_555,\r\n\t\t);\r\n\t\tconst elizasTB = attackingBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.DreadAdmiralEliza_TB_BaconUps_134 ||\r\n\t\t\t\te.cardId === CardIds.AdmiralElizaGoreblade_BG27_555_G,\r\n\t\t);\r\n\r\n\t\telizas.forEach((eliza) => {\r\n\t\t\tattackingBoard.forEach((entity) => {\r\n\t\t\t\tmodifyStats(entity, 3, 1, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\teliza,\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tattackingBoard,\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});\r\n\t\t});\r\n\t\telizasTB.forEach((eliza) => {\r\n\t\t\tattackingBoard.forEach((entity) => {\r\n\t\t\t\tmodifyStats(entity, 6, 2, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\teliza,\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tattackingBoard,\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});\r\n\t\t});\r\n\t}\r\n\r\n\t// Roaring Rallier\r\n\tif (isCorrectTribe(gameState.allCards.getCard(attacker.cardId).races, Race.DRAGON)) {\r\n\t\tattackingBoard\r\n\t\t\t.filter(\r\n\t\t\t\t(e) => e.cardId === CardIds.RoaringRallier_BG29_816 || e.cardId === CardIds.RoaringRallier_BG29_816_G,\r\n\t\t\t)\r\n\t\t\t.forEach((rallier) => {\r\n\t\t\t\tconst stats = rallier.cardId === CardIds.RoaringRallier_BG29_816_G ? 2 : 1;\r\n\t\t\t\tmodifyStats(attacker, 3 * stats, stats, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\trallier,\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tattackingBoard,\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});\r\n\t}\r\n\r\n\tif (attacker.cardId === CardIds.GlyphGuardian_BGS_045) {\r\n\t\t// For now the utility method only works additively, so we hack around it\r\n\t\tmodifyStats(attacker, 2 * attacker.attack - attacker.attack, 0, attackingBoard, attackingBoardHero, gameState);\r\n\t} else if (attacker.cardId === CardIds.GlyphGuardian_TB_BaconUps_115) {\r\n\t\tmodifyStats(attacker, 3 * attacker.attack - attacker.attack, 0, attackingBoard, attackingBoardHero, gameState);\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.GlimGuardian_BG29_888 ||\r\n\t\tattacker.cardId === CardIds.GlimGuardian_BG29_888_G\r\n\t) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.GlimGuardian_BG29_888_G ? 2 : 1;\r\n\t\tmodifyStats(attacker, 2 * multiplier, 1 * multiplier, attackingBoard, attackingBoardHero, gameState);\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tattacker,\r\n\t\t\tattacker,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoardHero,\r\n\t\t);\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708 ||\r\n\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708_G\r\n\t) {\r\n\t\tattackingBoard\r\n\t\t\t.filter((e) => isCorrectTribe(gameState.allCards.getCard(e.cardId).races, Race.PIRATE))\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\tmodifyStats(\r\n\t\t\t\t\te,\r\n\t\t\t\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708_G ? 4 : 2,\r\n\t\t\t\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708_G ? 4 : 2,\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\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\te,\r\n\t\t\t\t\tattackingBoard,\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});\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.WhirlingLassOMatic_BG28_635 ||\r\n\t\tattacker.cardId === CardIds.WhirlingLassOMatic_BG28_635_G\r\n\t) {\r\n\t\tconst numberOfCardsToAdd = attacker.cardId === CardIds.WhirlingLassOMatic_BG28_635_G ? 2 : 1;\r\n\t\tconst cardsToAdd = Array.from({ length: numberOfCardsToAdd }).map(() => null);\r\n\t\taddCardsInHand(attackingBoardHero, attackingBoard, cardsToAdd, gameState);\r\n\t} else if (attacker.cardId === CardIds.Rampager_BG29_809 || attacker.cardId === CardIds.Rampager_BG29_809_G) {\r\n\t\tconst loops = attacker.cardId === CardIds.Rampager_BG29_809_G ? 2 : 1;\r\n\t\tfor (let i = 0; i < loops; i++) {\r\n\t\t\t// Don't include new spawns\r\n\t\t\tfor (const entity of [...attackingBoard]) {\r\n\t\t\t\tif (entity.entityId === attacker.entityId) {\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\t\t\t\tconst isSameSide = entity.friendly === attacker.friendly;\r\n\t\t\t\tconst board = isSameSide ? attackingBoard : defendingBoard;\r\n\t\t\t\tconst hero = isSameSide ? attackingBoardHero : defendingBoardHero;\r\n\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tboard,\r\n\t\t\t\t\thero,\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tisSameSide ? defendingBoard : attackingBoard,\r\n\t\t\t\t\tisSameSide ? defendingBoardHero : attackingBoardHero,\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 (attacker.cardId === CardIds.HatefulHag_BG29_120 || attacker.cardId === CardIds.HatefulHag_BG29_120_G) {\r\n\t\tconst loops = attacker.cardId === CardIds.HatefulHag_BG29_120_G ? 2 : 1;\r\n\t\tconst attackerIndex = attackingBoard.indexOf(attacker);\r\n\t\tfor (let i = 1; i <= loops; i++) {\r\n\t\t\tconst target = attackingBoard[attackerIndex + i];\r\n\t\t\tif (!!target) {\r\n\t\t\t\ttarget.reborn = true;\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tattackingBoard,\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}\r\n\t\t}\r\n\t}\r\n\r\n\tconst eclipsion = attackingBoard.find(\r\n\t\t(e) =>\r\n\t\t\t[\r\n\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy,\r\n\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy_G,\r\n\t\t\t].includes(e.cardId as CardIds) && e.abiityChargesLeft > 0,\r\n\t);\r\n\t// Only once per minion\r\n\tif (!!eclipsion && attacker.immuneWhenAttackCharges == null) {\r\n\t\tattacker.immuneWhenAttackCharges = 1;\r\n\t\t// If we have 2 eclipsions, the first minion that attacks eats both charges\r\n\t\tattackingBoard\r\n\t\t\t.filter((e) =>\r\n\t\t\t\t[\r\n\t\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy,\r\n\t\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy_G,\r\n\t\t\t\t].includes(e.cardId as CardIds),\r\n\t\t\t)\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\te.abiityChargesLeft--;\r\n\t\t\t});\r\n\t}\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"on-attack.js","sourceRoot":"","sources":["../../src/simulation/on-attack.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAG7D,6CAA+C;AAC/C,oCAA0C;AAC1C,qCAA6D;AAC7D,mDAAiD;AAEjD,mCAAsC;AAG/B,MAAM,oBAAoB,GAAG,CACnC,QAAqB,EACrB,cAA6B,EAC7B,kBAAmC,EACnC,eAA4B,EAC5B,cAA6B,EAC7B,kBAAmC,EACnC,SAAwB,EACjB,EAAE;IAET,IACC,QAAQ,CAAC,MAAM,eAAqC;QACpD,QAAQ,CAAC,MAAM,iBAAuC,EACrD;QACD,MAAM,UAAU,GAAG,IAAA,sBAAa,EAAC,cAAc,EAAE,eAAe,CAAC,CAAC;QAClE,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,iBAAuC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAA,kBAAU,EAAC,UAAU,CAAC,CAAC,CAAC;QAC/G,CAAC,eAAe,EAAE,GAAG,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YAChD,SAAS,CAAC,SAAS,CAAC,mBAAmB,CACtC,QAAQ,EACR,MAAM,EACN,cAAc,EACd,kBAAkB,EAClB,kBAAkB,CAClB,CAAC;YAEF,IAAA,2BAAkB,EACjB,MAAM,EACN,cAAc,EACd,kBAAkB,EAClB,QAAQ,EACR,QAAQ,CAAC,MAAM,EACf,cAAc,EACd,kBAAkB,EAClB,SAAS,CACT,CAAC;QACH,CAAC,CAAC,CAAC;KACH;IAGD,IAAI,IAAA,sBAAc,EAAC,SAAS,CAAC,QAAQ,CAAC,OA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S,CAAC,mBAAmB,CACtC,QAAQ,EACR,MAAM,EACN,cAAc,EACd,kBAAkB,EAClB,kBAAkB,CAClB,CAAC;aACF;SACD;KACD;IAED,MAAM,SAAS,GAAG,cAAc,CAAC,IAAI,CACpC,CAAC,CAAC,EAAE,EAAE,CACL;;;KAGC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAiB,CAAC,IAAI,CAAC,CAAC,iBAAiB,GAAG,CAAC,CAC3D,CAAC;IAEF,IAAI,CAAC,CAAC,SAAS,IAAI,QAAQ,CAAC,uBAAuB,IAAI,IAAI,EAAE;QAC5D,QAAQ,CAAC,uBAAuB,GAAG,CAAC,CAAC;QAErC,cAAc;aACZ,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CACb;;;SAGC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAiB,CAAC,CAC/B;aACA,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACd,CAAC,CAAC,iBAAiB,EAAE,CAAC;QACvB,CAAC,CAAC,CAAC;KACJ;AACF,CAAC,CAAC;AA1OW,QAAA,oBAAoB,wBA0O/B","sourcesContent":["import { CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { pickRandom } from '../services/utils';\r\nimport { isCorrectTribe } from '../utils';\r\nimport { dealDamageToMinion, getNeighbours } from './attack';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { modifyStats } from './stats';\r\n\r\n// Whenever it attacks\r\nexport const applyOnAttackEffects = (\r\n\tattacker: 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): void => {\r\n\t// Damage happens before the entity is buffed, e.g. before an attack buff from Roaring Rallier\r\n\tif (\r\n\t\tattacker.cardId === CardIds.ObsidianRavager_BG27_017 ||\r\n\t\tattacker.cardId === CardIds.ObsidianRavager_BG27_017_G\r\n\t) {\r\n\t\tconst neighbours = getNeighbours(defendingBoard, defendingEntity);\r\n\t\tconst targets = attacker.cardId === CardIds.ObsidianRavager_BG27_017_G ? neighbours : [pickRandom(neighbours)];\r\n\t\t[defendingEntity, ...targets].forEach((target) => {\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tattacker,\r\n\t\t\t\ttarget,\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\t// damageDoneByAttacker +=\r\n\t\t\tdealDamageToMinion(\r\n\t\t\t\ttarget,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tattacker,\r\n\t\t\t\tattacker.attack,\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\r\n\t// Ripsnarl Captain\r\n\tif (isCorrectTribe(gameState.allCards.getCard(attacker.cardId).races, Race.PIRATE)) {\r\n\t\tconst ripsnarls = attackingBoard.filter((e) => e.cardId === CardIds.RipsnarlCaptain_BGS_056);\r\n\t\tconst ripsnarlsTB = attackingBoard.filter(\r\n\t\t\t(entity) => entity.cardId === CardIds.RipsnarlCaptain_TB_BaconUps_139,\r\n\t\t);\r\n\t\tripsnarls.forEach((captain) => {\r\n\t\t\tmodifyStats(attacker, 3, 0, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tcaptain,\r\n\t\t\t\tattacker,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t);\r\n\t\t});\r\n\t\tripsnarlsTB.forEach((captain) => {\r\n\t\t\tmodifyStats(attacker, 6, 0, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tcaptain,\r\n\t\t\t\tattacker,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\r\n\t// Dread Admiral Eliza\r\n\tif (isCorrectTribe(gameState.allCards.getCard(attacker.cardId).races, Race.PIRATE)) {\r\n\t\tconst elizas = attackingBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.DreadAdmiralEliza_BGS_047 || e.cardId === CardIds.AdmiralElizaGoreblade_BG27_555,\r\n\t\t);\r\n\t\tconst elizasTB = attackingBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.DreadAdmiralEliza_TB_BaconUps_134 ||\r\n\t\t\t\te.cardId === CardIds.AdmiralElizaGoreblade_BG27_555_G,\r\n\t\t);\r\n\r\n\t\telizas.forEach((eliza) => {\r\n\t\t\tattackingBoard.forEach((entity) => {\r\n\t\t\t\tmodifyStats(entity, 3, 1, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\teliza,\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tattackingBoard,\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});\r\n\t\t});\r\n\t\telizasTB.forEach((eliza) => {\r\n\t\t\tattackingBoard.forEach((entity) => {\r\n\t\t\t\tmodifyStats(entity, 6, 2, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\teliza,\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tattackingBoard,\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});\r\n\t\t});\r\n\t}\r\n\r\n\t// Roaring Rallier\r\n\tif (isCorrectTribe(gameState.allCards.getCard(attacker.cardId).races, Race.DRAGON)) {\r\n\t\tattackingBoard\r\n\t\t\t.filter(\r\n\t\t\t\t(e) => e.cardId === CardIds.RoaringRallier_BG29_816 || e.cardId === CardIds.RoaringRallier_BG29_816_G,\r\n\t\t\t)\r\n\t\t\t.forEach((rallier) => {\r\n\t\t\t\tconst stats = rallier.cardId === CardIds.RoaringRallier_BG29_816_G ? 2 : 1;\r\n\t\t\t\tmodifyStats(attacker, 3 * stats, stats, attackingBoard, attackingBoardHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\trallier,\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\tattackingBoard,\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});\r\n\t}\r\n\r\n\tif (attacker.cardId === CardIds.GlyphGuardian_BGS_045) {\r\n\t\t// For now the utility method only works additively, so we hack around it\r\n\t\tmodifyStats(attacker, 2 * attacker.attack - attacker.attack, 0, attackingBoard, attackingBoardHero, gameState);\r\n\t} else if (attacker.cardId === CardIds.GlyphGuardian_TB_BaconUps_115) {\r\n\t\tmodifyStats(attacker, 3 * attacker.attack - attacker.attack, 0, attackingBoard, attackingBoardHero, gameState);\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.GlimGuardian_BG29_888 ||\r\n\t\tattacker.cardId === CardIds.GlimGuardian_BG29_888_G\r\n\t) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.GlimGuardian_BG29_888_G ? 2 : 1;\r\n\t\tmodifyStats(attacker, 2 * multiplier, 1 * multiplier, attackingBoard, attackingBoardHero, gameState);\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tattacker,\r\n\t\t\tattacker,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoardHero,\r\n\t\t);\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708 ||\r\n\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708_G\r\n\t) {\r\n\t\tattackingBoard\r\n\t\t\t.filter((e) => isCorrectTribe(gameState.allCards.getCard(e.cardId).races, Race.PIRATE))\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\tmodifyStats(\r\n\t\t\t\t\te,\r\n\t\t\t\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708_G ? 4 : 2,\r\n\t\t\t\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708_G ? 4 : 2,\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\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\te,\r\n\t\t\t\t\tattackingBoard,\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});\r\n\t} else if (\r\n\t\tattacker.cardId === CardIds.WhirlingLassOMatic_BG28_635 ||\r\n\t\tattacker.cardId === CardIds.WhirlingLassOMatic_BG28_635_G\r\n\t) {\r\n\t\tconst numberOfCardsToAdd = attacker.cardId === CardIds.WhirlingLassOMatic_BG28_635_G ? 2 : 1;\r\n\t\tconst cardsToAdd = Array.from({ length: numberOfCardsToAdd }).map(() => null);\r\n\t\taddCardsInHand(attackingBoardHero, attackingBoard, cardsToAdd, gameState);\r\n\t} else if (attacker.cardId === CardIds.Rampager_BG29_809 || attacker.cardId === CardIds.Rampager_BG29_809_G) {\r\n\t\tconst loops = attacker.cardId === CardIds.Rampager_BG29_809_G ? 2 : 1;\r\n\t\tfor (let i = 0; i < loops; i++) {\r\n\t\t\t// Don't include new spawns\r\n\t\t\tfor (const entity of [...attackingBoard]) {\r\n\t\t\t\tif (entity.entityId === attacker.entityId) {\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\t\t\t\tconst isSameSide = entity.friendly === attacker.friendly;\r\n\t\t\t\tconst board = isSameSide ? attackingBoard : defendingBoard;\r\n\t\t\t\tconst hero = isSameSide ? attackingBoardHero : defendingBoardHero;\r\n\t\t\t\tdealDamageToMinion(\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tboard,\r\n\t\t\t\t\thero,\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tisSameSide ? defendingBoard : attackingBoard,\r\n\t\t\t\t\tisSameSide ? defendingBoardHero : attackingBoardHero,\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 (attacker.cardId === CardIds.HatefulHag_BG29_120 || attacker.cardId === CardIds.HatefulHag_BG29_120_G) {\r\n\t\tconst loops = attacker.cardId === CardIds.HatefulHag_BG29_120_G ? 2 : 1;\r\n\t\tconst attackerIndex = attackingBoard.indexOf(attacker);\r\n\t\tfor (let i = 1; i <= loops; i++) {\r\n\t\t\tconst target = attackingBoard[attackerIndex + i];\r\n\t\t\tif (!!target) {\r\n\t\t\t\ttarget.reborn = true;\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tattacker,\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tattackingBoard,\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}\r\n\t\t}\r\n\t}\r\n\r\n\tconst eclipsion = attackingBoard.find(\r\n\t\t(e) =>\r\n\t\t\t[\r\n\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy,\r\n\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy_G,\r\n\t\t\t].includes(e.cardId as CardIds) && e.abiityChargesLeft > 0,\r\n\t);\r\n\t// Only once per minion\r\n\tif (!!eclipsion && attacker.immuneWhenAttackCharges == null) {\r\n\t\tattacker.immuneWhenAttackCharges = 1;\r\n\t\t// If we have 2 eclipsions, the first minion that attacks eats both charges\r\n\t\tattackingBoard\r\n\t\t\t.filter((e) =>\r\n\t\t\t\t[\r\n\t\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy,\r\n\t\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy_G,\r\n\t\t\t\t].includes(e.cardId as CardIds),\r\n\t\t\t)\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\te.abiityChargesLeft--;\r\n\t\t\t});\r\n\t}\r\n};\r\n"]}
|
package/dist/simulation/stats.js
CHANGED
|
@@ -33,7 +33,7 @@ const modifyStats = (entity, attackAmount, healthAmount, friendlyBoard, friendly
|
|
|
33
33
|
const poetMultipliers = neighbours.filter((e) => e.cardId === "BG29_813_G").length * 2 || 1;
|
|
34
34
|
const tarecgosaMultiplier = entity.cardId === "BG21_015_G" ? 2 : 1;
|
|
35
35
|
const realAttackAmount = attackAmount * poetMultipliers * tarecgosaMultiplier;
|
|
36
|
-
const realHealthAmount =
|
|
36
|
+
const realHealthAmount = healthAmount * poetMultipliers * tarecgosaMultiplier;
|
|
37
37
|
entity.attack = Math.max(0, entity.attack + realAttackAmount);
|
|
38
38
|
entity.previousAttack = entity.attack;
|
|
39
39
|
entity.pendingAttackBuffs.push(realAttackAmount);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/simulation/stats.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAG7D,oCAA4E;AAC5E,+DAAyD;AACzD,qCAAyC;AAEzC,mCAAiD;AAG1C,MAAM,cAAc,GAAG,CAC7B,MAAmB,EACnB,MAAqB,EACrB,MAAqB,EACrB,KAAoB,EACpB,SAA0B,EAC1B,SAAwB,EACjB,EAAE;IACT,IAAI,MAAM,KAAK,IAAI,EAAE;QACpB,M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import { BoardEntity } from '../board-entity';\r\nimport { addStatsToBoard, hasCorrectTribe, isCorrectTribe } from '../utils';\r\nimport { applyAurasToSelf } from './add-minion-to-board';\r\nimport { getNeighbours } from './attack';\r\nimport { FullGameState, PlayerState } from './internal-game-state';\r\nimport { onQuestProgressUpdated } from './quest';\r\nimport { Spectator } from './spectator/spectator';\r\n\r\nexport const setEntityStats = (\r\n\tentity: BoardEntity,\r\n\tattack: number | null,\r\n\thealth: number | null,\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (attack !== null) {\r\n\t\tentity.attack = attack;\r\n\t}\r\n\tif (health !== null) {\r\n\t\tentity.health = health;\r\n\t\tentity.maxHealth = health;\r\n\t}\r\n\tapplyAurasToSelf(entity, board, boardHero, gameState);\r\n};\r\n\r\nexport const modifyStats = (\r\n\tentity: BoardEntity,\r\n\tattackAmount: number,\r\n\thealthAmount: number,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tspectator: Spectator = null,\r\n): void => {\r\n\tif (attackAmount === 0 && healthAmount === 0) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (entity.cardId === CardIds.LocPrince_BG29_889 || entity.cardId === CardIds.LocPrince_BG29_889_G) {\r\n\t\tconst buff = entity.cardId === CardIds.LocPrince_BG29_889_G ? 4 : 2;\r\n\t\tattackAmount += buff;\r\n\t\thealthAmount += buff;\r\n\t}\r\n\r\n\tconst otherBoardHero: BgsPlayerEntity =\r\n\t\tgameState.gameState.player.player === friendlyBoardHero\r\n\t\t\t? gameState.gameState.opponent.player\r\n\t\t\t: gameState.gameState.player.player;\r\n\r\n\tconst neighbours = getNeighbours(friendlyBoard, entity);\r\n\tconst poetMultipliers = neighbours.filter((e) => e.cardId === CardIds.PersistentPoet_BG29_813_G).length * 2 || 1;\r\n\tconst tarecgosaMultiplier = entity.cardId === CardIds.Tarecgosa_BG21_015_G ? 2 : 1;\r\n\r\n\tconst realAttackAmount = attackAmount * poetMultipliers * tarecgosaMultiplier;\r\n\tconst realHealthAmount = entity.cardId === CardIds.Tarecgosa_BG21_015_G ? 2 * healthAmount : healthAmount;\r\n\r\n\tentity.attack = Math.max(0, entity.attack + realAttackAmount);\r\n\tentity.previousAttack = entity.attack;\r\n\tentity.pendingAttackBuffs.push(realAttackAmount);\r\n\tentity.health += realHealthAmount;\r\n\tif (realHealthAmount > 0) {\r\n\t\tentity.maxHealth += realHealthAmount;\r\n\t}\r\n\r\n\tif (realAttackAmount > 0) {\r\n\t\tif (isCorrectTribe(gameState.allCards.getCard(entity.cardId).races, Race.DRAGON)) {\r\n\t\t\tconst whelpSmugglers = friendlyBoard.filter(\r\n\t\t\t\t(e) => e.cardId === CardIds.WhelpSmuggler_BG21_013 || e.cardId === CardIds.WhelpSmuggler_BG21_013_G,\r\n\t\t\t);\r\n\t\t\twhelpSmugglers.forEach((smuggler) => {\r\n\t\t\t\tconst buff = smuggler.cardId === CardIds.WhelpSmuggler_BG21_013_G ? 2 : 1;\r\n\t\t\t\tmodifyStats(entity, 0, buff, friendlyBoard, friendlyBoardHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tsmuggler,\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tfriendlyBoard,\r\n\t\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\r\n\t\t\tif (entity.cardId !== CardIds.Stormbringer_BG26_966 && entity.cardId !== CardIds.Stormbringer_BG26_966_G) {\r\n\t\t\t\tconst stormbringers = friendlyBoard.filter(\r\n\t\t\t\t\t(e) => e.cardId === CardIds.Stormbringer_BG26_966 || e.cardId === CardIds.Stormbringer_BG26_966_G,\r\n\t\t\t\t);\r\n\t\t\t\tstormbringers.forEach((stormbringer) => {\r\n\t\t\t\t\tconst multiplier = stormbringer.cardId === CardIds.Stormbringer_BG26_966_G ? 2 : 1;\r\n\t\t\t\t\t// This is never called?\r\n\t\t\t\t\t(e) => {\r\n\t\t\t\t\t\te.attack += multiplier * realAttackAmount;\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\tstormbringer,\r\n\t\t\t\t\t\t\tentity,\r\n\t\t\t\t\t\t\tfriendlyBoard,\r\n\t\t\t\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t};\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Sinestra\r\n\t\tfriendlyBoard\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId === CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy ||\r\n\t\t\t\t\te.cardId === CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy_G,\r\n\t\t\t)\r\n\t\t\t.forEach((sinestra) => {\r\n\t\t\t\tconst buff = sinestra.cardId === CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy_G ? 2 : 1;\r\n\t\t\t\tentity.health += buff;\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tsinestra,\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tfriendlyBoard,\r\n\t\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\r\n\t\t// TODO: what happens if the Hunter is killed during the attack?\r\n\t\tif (\r\n\t\t\t[CardIds.HunterOfGatherers_BG25_027, CardIds.HunterOfGatherers_BG25_027_G].includes(\r\n\t\t\t\tentity.cardId as CardIds,\r\n\t\t\t)\r\n\t\t) {\r\n\t\t\taddStatsToBoard(\r\n\t\t\t\tentity,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\t0,\r\n\t\t\t\tentity.cardId === CardIds.HunterOfGatherers_BG25_027_G ? 2 : 1,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\tif (realHealthAmount > 0) {\r\n\t\tconst titanicGuardians = friendlyBoard\r\n\t\t\t.filter((e) => e.entityId !== entity.entityId)\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy ||\r\n\t\t\t\t\te.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy_G,\r\n\t\t\t);\r\n\t\ttitanicGuardians.forEach((guardian) => {\r\n\t\t\tconst buff =\r\n\t\t\t\t(guardian.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy_G ? 2 : 1) * realHealthAmount;\r\n\t\t\tif (buff > 0) {\r\n\t\t\t\tguardian.health += buff;\r\n\t\t\t\tguardian.maxHealth += buff;\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tif (\r\n\t\tentity.cardId === CardIds.Menagerist_AmalgamToken ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A_G ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D_G\r\n\t) {\r\n\t\tconst mishmashes = friendlyBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy ||\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G,\r\n\t\t);\r\n\t\tmishmashes.forEach((mishmash) => {\r\n\t\t\tmodifyStats(\r\n\t\t\t\tmishmash,\r\n\t\t\t\t(mishmash.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G ? 2 : 1) * realAttackAmount,\r\n\t\t\t\t(mishmash.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G ? 2 : 1) * realHealthAmount,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t});\r\n\t} else if (\r\n\t\tentity.cardId === CardIds.DefiantShipwright_BG21_018 ||\r\n\t\tentity.cardId === CardIds.DefiantShipwright_BG21_018_G\r\n\t) {\r\n\t\tconst stat = entity.cardId === CardIds.DefiantShipwright_BG21_018_G ? 2 : 1;\r\n\t\tentity.health += stat;\r\n\t}\r\n\r\n\tonStatsUpdate(entity, friendlyBoard, friendlyBoardHero, gameState);\r\n};\r\n\r\nconst onStatsUpdate = (\r\n\tentity: BoardEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tonStatUpdateMinions(entity, friendlyBoard, friendlyHero, gameState);\r\n\tonStatUpdateQuests(entity, friendlyBoard, friendlyHero, gameState);\r\n};\r\n\r\nexport const applyAfterStatsUpdate = (gameState: FullGameState) => {\r\n\tfor (const entity of gameState.gameState.player.board) {\r\n\t\tapplyAfterStatsUpdateForEntity(entity, gameState.gameState.player, gameState.gameState.opponent, gameState);\r\n\t}\r\n\tfor (const entity of gameState.gameState.opponent.board) {\r\n\t\tapplyAfterStatsUpdateForEntity(entity, gameState.gameState.opponent, gameState.gameState.player, gameState);\r\n\t}\r\n};\r\n\r\nconst applyAfterStatsUpdateForEntity = (\r\n\tentity: BoardEntity,\r\n\tplayerState: PlayerState,\r\n\topponentState: PlayerState,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// Attack buffs\r\n\t// Actually this was a bug, and the stats update happen at the same time\r\n\t// Keeping the structure here in case it's useful in the future\r\n\t// for (const attackBuff of entity.pendingAttackBuffs) {\r\n\t// \tif (isCorrectTribe(gameState.allCards.getCard(entity.cardId).races, Race.DRAGON)) {\r\n\t// \t\tconst whelpSmugglers = playerState.board.filter(\r\n\t// \t\t\t(e) => e.cardId === CardIds.WhelpSmuggler_BG21_013 || e.cardId === CardIds.WhelpSmuggler_BG21_013_G,\r\n\t// \t\t);\r\n\t// \t\twhelpSmugglers.forEach((smuggler) => {\r\n\t// \t\t\tconst buff = smuggler.cardId === CardIds.WhelpSmuggler_BG21_013_G ? 2 : 1;\r\n\t// \t\t\tmodifyHealth(entity, buff, playerState.board, playerState.player, gameState);\r\n\t// \t\t\tgameState.spectator.registerPowerTarget(\r\n\t// \t\t\t\tsmuggler,\r\n\t// \t\t\t\tentity,\r\n\t// \t\t\t\tplayerState.board,\r\n\t// \t\t\t\tplayerState.player,\r\n\t// \t\t\t\topponentState.player,\r\n\t// \t\t\t);\r\n\t// \t\t});\r\n\r\n\t// \t\tif (entity.cardId !== CardIds.Stormbringer_BG26_966 && entity.cardId !== CardIds.Stormbringer_BG26_966_G) {\r\n\t// \t\t\tconst stormbringers = playerState.board.filter(\r\n\t// \t\t\t\t(e) => e.cardId === CardIds.Stormbringer_BG26_966 || e.cardId === CardIds.Stormbringer_BG26_966_G,\r\n\t// \t\t\t);\r\n\t// \t\t\tstormbringers.forEach((stormbringer) => {\r\n\t// \t\t\t\tconst multiplier = stormbringer.cardId === CardIds.Stormbringer_BG26_966_G ? 2 : 1;\r\n\t// \t\t\t\t(e) => {\r\n\t// \t\t\t\t\tmodifyAttack(e, multiplier * attackBuff, playerState.board, playerState.player, gameState);\r\n\t// \t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t// \t\t\t\t\t\tstormbringer,\r\n\t// \t\t\t\t\t\tentity,\r\n\t// \t\t\t\t\t\tplayerState.board,\r\n\t// \t\t\t\t\t\tplayerState.player,\r\n\t// \t\t\t\t\t\topponentState.player,\r\n\t// \t\t\t\t\t);\r\n\t// \t\t\t\t};\r\n\t// \t\t\t});\r\n\t// \t\t}\r\n\t// \t}\r\n\r\n\t// \t// TODO: what happens if the Hunter is killed during the attack?\r\n\t// \tif (\r\n\t// \t\t[CardIds.HunterOfGatherers_BG25_027, CardIds.HunterOfGatherers_BG25_027_G].includes(\r\n\t// \t\t\tentity.cardId as CardIds,\r\n\t// \t\t)\r\n\t// \t) {\r\n\t// \t\taddStatsToBoard(\r\n\t// \t\t\tentity,\r\n\t// \t\t\tplayerState.board,\r\n\t// \t\t\tplayerState.player,\r\n\t// \t\t\t0,\r\n\t// \t\t\tentity.cardId === CardIds.HunterOfGatherers_BG25_027_G ? 2 : 1,\r\n\t// \t\t\tgameState,\r\n\t// \t\t);\r\n\t// \t}\r\n\t// }\r\n\tentity.pendingAttackBuffs = [];\r\n};\r\n\r\nconst onStatUpdateQuests = (\r\n\tentity: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst quests = hero.questEntities ?? [];\r\n\tif (!quests.length) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tfor (const quest of quests) {\r\n\t\tswitch (quest.CardId) {\r\n\t\t\tcase CardIds.FindTheMurderWeapon:\r\n\t\t\t\tonQuestProgressUpdated(hero, quest, board, gameState);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.PressureTheAuthorities:\r\n\t\t\t\tconst totalAttack = board.map((e) => e.attack).reduce((a, b) => a + b, 0);\r\n\t\t\t\tif (totalAttack >= 35) {\r\n\t\t\t\t\tonQuestProgressUpdated(hero, quest, board, gameState);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst onStatUpdateMinions = (\r\n\tentity: BoardEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (hasCorrectTribe(entity, Race.ELEMENTAL, gameState.allCards)) {\r\n\t\tconst masterOfRealities = friendlyBoard.filter(\r\n\t\t\t(e) => e.cardId === CardIds.MasterOfRealities_BG21_036 || e.cardId === CardIds.MasterOfRealities_BG21_036_G,\r\n\t\t);\r\n\t\tmasterOfRealities.forEach((master) => {\r\n\t\t\tmodifyStats(\r\n\t\t\t\tmaster,\r\n\t\t\t\tmaster.cardId === CardIds.MasterOfRealities_BG21_036_G ? 2 : 1,\r\n\t\t\t\tmaster.cardId === CardIds.MasterOfRealities_BG21_036_G ? 2 : 1,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\tconst tentaclesOfCthun = friendlyBoard\r\n\t\t.filter((e) => e.entityId !== entity.entityId)\r\n\t\t.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy ||\r\n\t\t\t\te.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G,\r\n\t\t);\r\n\ttentaclesOfCthun.forEach((tentacle) => {\r\n\t\ttentacle.attack += tentacle.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G ? 2 : 1;\r\n\t\ttentacle.health += tentacle.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G ? 2 : 1;\r\n\t});\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/simulation/stats.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAG7D,oCAA4E;AAC5E,+DAAyD;AACzD,qCAAyC;AAEzC,mCAAiD;AAG1C,MAAM,cAAc,GAAG,CAC7B,MAAmB,EACnB,MAAqB,EACrB,MAAqB,EACrB,KAAoB,EACpB,SAA0B,EAC1B,SAAwB,EACjB,EAAE;IACT,IAAI,MAAM,KAAK,IAAI,EAAE;QACpB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;KACvB;IACD,IAAI,MAAM,KAAK,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iB,GAAG,aAAa,CAAC,MAAM,CAC7C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,eAAuC,IAAI,CAAC,CAAC,MAAM,iBAAyC,CAC3G,CAAC;QACF,iBAAiB,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YACpC,IAAA,mBAAW,EACV,MAAM,EACN,MAAM,CAAC,MAAM,iBAAyC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC9D,MAAM,CAAC,MAAM,iBAAyC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC9D,aAAa,EACb,iBAAiB,EACjB,SAAS,CACT,CAAC;QACH,CAAC,CAAC,CAAC;KACH;IACD,MAAM,gBAAgB,GAAG,aAAa;SACpC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,QAAQ,CAAC;SAC7C,MAAM,CACN,CAAC,CAAC,EAAE,EAAE,CACL,CAAC,CAAC,MAAM,iCAAuD;QAC/D,CAAC,CAAC,MAAM,mCAAyD,CAClE,CAAC;IACH,gBAAgB,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;QACrC,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM,mCAAyD,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACpG,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM,mCAAyD,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACrG,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { addStatsToBoard, hasCorrectTribe, isCorrectTribe } from '../utils';\r\nimport { applyAurasToSelf } from './add-minion-to-board';\r\nimport { getNeighbours } from './attack';\r\nimport { FullGameState, PlayerState } from './internal-game-state';\r\nimport { onQuestProgressUpdated } from './quest';\r\nimport { Spectator } from './spectator/spectator';\r\n\r\nexport const setEntityStats = (\r\n\tentity: BoardEntity,\r\n\tattack: number | null,\r\n\thealth: number | null,\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (attack !== null) {\r\n\t\tentity.attack = attack;\r\n\t}\r\n\tif (health !== null) {\r\n\t\tentity.health = health;\r\n\t\tentity.maxHealth = health;\r\n\t}\r\n\tapplyAurasToSelf(entity, board, boardHero, gameState);\r\n};\r\n\r\nexport const modifyStats = (\r\n\tentity: BoardEntity,\r\n\tattackAmount: number,\r\n\thealthAmount: number,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tspectator: Spectator = null,\r\n): void => {\r\n\tif (attackAmount === 0 && healthAmount === 0) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (entity.cardId === CardIds.LocPrince_BG29_889 || entity.cardId === CardIds.LocPrince_BG29_889_G) {\r\n\t\tconst buff = entity.cardId === CardIds.LocPrince_BG29_889_G ? 4 : 2;\r\n\t\tattackAmount += buff;\r\n\t\thealthAmount += buff;\r\n\t}\r\n\r\n\tconst otherBoardHero: BgsPlayerEntity =\r\n\t\tgameState.gameState.player.player === friendlyBoardHero\r\n\t\t\t? gameState.gameState.opponent.player\r\n\t\t\t: gameState.gameState.player.player;\r\n\r\n\tconst neighbours = getNeighbours(friendlyBoard, entity);\r\n\tconst poetMultipliers = neighbours.filter((e) => e.cardId === CardIds.PersistentPoet_BG29_813_G).length * 2 || 1;\r\n\tconst tarecgosaMultiplier = entity.cardId === CardIds.Tarecgosa_BG21_015_G ? 2 : 1;\r\n\r\n\tconst realAttackAmount = attackAmount * poetMultipliers * tarecgosaMultiplier;\r\n\tconst realHealthAmount = healthAmount * poetMultipliers * tarecgosaMultiplier;\r\n\r\n\tentity.attack = Math.max(0, entity.attack + realAttackAmount);\r\n\tentity.previousAttack = entity.attack;\r\n\tentity.pendingAttackBuffs.push(realAttackAmount);\r\n\tentity.health += realHealthAmount;\r\n\tif (realHealthAmount > 0) {\r\n\t\tentity.maxHealth += realHealthAmount;\r\n\t}\r\n\r\n\tif (realAttackAmount > 0) {\r\n\t\tif (isCorrectTribe(gameState.allCards.getCard(entity.cardId).races, Race.DRAGON)) {\r\n\t\t\tconst whelpSmugglers = friendlyBoard.filter(\r\n\t\t\t\t(e) => e.cardId === CardIds.WhelpSmuggler_BG21_013 || e.cardId === CardIds.WhelpSmuggler_BG21_013_G,\r\n\t\t\t);\r\n\t\t\twhelpSmugglers.forEach((smuggler) => {\r\n\t\t\t\tconst buff = smuggler.cardId === CardIds.WhelpSmuggler_BG21_013_G ? 2 : 1;\r\n\t\t\t\tmodifyStats(entity, 0, buff, friendlyBoard, friendlyBoardHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tsmuggler,\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tfriendlyBoard,\r\n\t\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\r\n\t\t\tif (entity.cardId !== CardIds.Stormbringer_BG26_966 && entity.cardId !== CardIds.Stormbringer_BG26_966_G) {\r\n\t\t\t\tconst stormbringers = friendlyBoard.filter(\r\n\t\t\t\t\t(e) => e.cardId === CardIds.Stormbringer_BG26_966 || e.cardId === CardIds.Stormbringer_BG26_966_G,\r\n\t\t\t\t);\r\n\t\t\t\tstormbringers.forEach((stormbringer) => {\r\n\t\t\t\t\tconst multiplier = stormbringer.cardId === CardIds.Stormbringer_BG26_966_G ? 2 : 1;\r\n\t\t\t\t\t// This is never called?\r\n\t\t\t\t\t(e) => {\r\n\t\t\t\t\t\te.attack += multiplier * realAttackAmount;\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\tstormbringer,\r\n\t\t\t\t\t\t\tentity,\r\n\t\t\t\t\t\t\tfriendlyBoard,\r\n\t\t\t\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t};\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Sinestra\r\n\t\tfriendlyBoard\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId === CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy ||\r\n\t\t\t\t\te.cardId === CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy_G,\r\n\t\t\t)\r\n\t\t\t.forEach((sinestra) => {\r\n\t\t\t\tconst buff = sinestra.cardId === CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy_G ? 2 : 1;\r\n\t\t\t\tentity.health += buff;\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tsinestra,\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tfriendlyBoard,\r\n\t\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\r\n\t\t// TODO: what happens if the Hunter is killed during the attack?\r\n\t\tif (\r\n\t\t\t[CardIds.HunterOfGatherers_BG25_027, CardIds.HunterOfGatherers_BG25_027_G].includes(\r\n\t\t\t\tentity.cardId as CardIds,\r\n\t\t\t)\r\n\t\t) {\r\n\t\t\taddStatsToBoard(\r\n\t\t\t\tentity,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\t0,\r\n\t\t\t\tentity.cardId === CardIds.HunterOfGatherers_BG25_027_G ? 2 : 1,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\tif (realHealthAmount > 0) {\r\n\t\tconst titanicGuardians = friendlyBoard\r\n\t\t\t.filter((e) => e.entityId !== entity.entityId)\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy ||\r\n\t\t\t\t\te.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy_G,\r\n\t\t\t);\r\n\t\ttitanicGuardians.forEach((guardian) => {\r\n\t\t\tconst buff =\r\n\t\t\t\t(guardian.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy_G ? 2 : 1) * realHealthAmount;\r\n\t\t\tif (buff > 0) {\r\n\t\t\t\tguardian.health += buff;\r\n\t\t\t\tguardian.maxHealth += buff;\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tif (\r\n\t\tentity.cardId === CardIds.Menagerist_AmalgamToken ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A_G ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D_G\r\n\t) {\r\n\t\tconst mishmashes = friendlyBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy ||\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G,\r\n\t\t);\r\n\t\tmishmashes.forEach((mishmash) => {\r\n\t\t\tmodifyStats(\r\n\t\t\t\tmishmash,\r\n\t\t\t\t(mishmash.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G ? 2 : 1) * realAttackAmount,\r\n\t\t\t\t(mishmash.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G ? 2 : 1) * realHealthAmount,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t});\r\n\t} else if (\r\n\t\tentity.cardId === CardIds.DefiantShipwright_BG21_018 ||\r\n\t\tentity.cardId === CardIds.DefiantShipwright_BG21_018_G\r\n\t) {\r\n\t\tconst stat = entity.cardId === CardIds.DefiantShipwright_BG21_018_G ? 2 : 1;\r\n\t\tentity.health += stat;\r\n\t}\r\n\r\n\tonStatsUpdate(entity, friendlyBoard, friendlyBoardHero, gameState);\r\n};\r\n\r\nconst onStatsUpdate = (\r\n\tentity: BoardEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tonStatUpdateMinions(entity, friendlyBoard, friendlyHero, gameState);\r\n\tonStatUpdateQuests(entity, friendlyBoard, friendlyHero, gameState);\r\n};\r\n\r\nexport const applyAfterStatsUpdate = (gameState: FullGameState) => {\r\n\tfor (const entity of gameState.gameState.player.board) {\r\n\t\tapplyAfterStatsUpdateForEntity(entity, gameState.gameState.player, gameState.gameState.opponent, gameState);\r\n\t}\r\n\tfor (const entity of gameState.gameState.opponent.board) {\r\n\t\tapplyAfterStatsUpdateForEntity(entity, gameState.gameState.opponent, gameState.gameState.player, gameState);\r\n\t}\r\n};\r\n\r\nconst applyAfterStatsUpdateForEntity = (\r\n\tentity: BoardEntity,\r\n\tplayerState: PlayerState,\r\n\topponentState: PlayerState,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// Attack buffs\r\n\t// Actually this was a bug, and the stats update happen at the same time\r\n\t// Keeping the structure here in case it's useful in the future\r\n\t// for (const attackBuff of entity.pendingAttackBuffs) {\r\n\t// \tif (isCorrectTribe(gameState.allCards.getCard(entity.cardId).races, Race.DRAGON)) {\r\n\t// \t\tconst whelpSmugglers = playerState.board.filter(\r\n\t// \t\t\t(e) => e.cardId === CardIds.WhelpSmuggler_BG21_013 || e.cardId === CardIds.WhelpSmuggler_BG21_013_G,\r\n\t// \t\t);\r\n\t// \t\twhelpSmugglers.forEach((smuggler) => {\r\n\t// \t\t\tconst buff = smuggler.cardId === CardIds.WhelpSmuggler_BG21_013_G ? 2 : 1;\r\n\t// \t\t\tmodifyHealth(entity, buff, playerState.board, playerState.player, gameState);\r\n\t// \t\t\tgameState.spectator.registerPowerTarget(\r\n\t// \t\t\t\tsmuggler,\r\n\t// \t\t\t\tentity,\r\n\t// \t\t\t\tplayerState.board,\r\n\t// \t\t\t\tplayerState.player,\r\n\t// \t\t\t\topponentState.player,\r\n\t// \t\t\t);\r\n\t// \t\t});\r\n\r\n\t// \t\tif (entity.cardId !== CardIds.Stormbringer_BG26_966 && entity.cardId !== CardIds.Stormbringer_BG26_966_G) {\r\n\t// \t\t\tconst stormbringers = playerState.board.filter(\r\n\t// \t\t\t\t(e) => e.cardId === CardIds.Stormbringer_BG26_966 || e.cardId === CardIds.Stormbringer_BG26_966_G,\r\n\t// \t\t\t);\r\n\t// \t\t\tstormbringers.forEach((stormbringer) => {\r\n\t// \t\t\t\tconst multiplier = stormbringer.cardId === CardIds.Stormbringer_BG26_966_G ? 2 : 1;\r\n\t// \t\t\t\t(e) => {\r\n\t// \t\t\t\t\tmodifyAttack(e, multiplier * attackBuff, playerState.board, playerState.player, gameState);\r\n\t// \t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t// \t\t\t\t\t\tstormbringer,\r\n\t// \t\t\t\t\t\tentity,\r\n\t// \t\t\t\t\t\tplayerState.board,\r\n\t// \t\t\t\t\t\tplayerState.player,\r\n\t// \t\t\t\t\t\topponentState.player,\r\n\t// \t\t\t\t\t);\r\n\t// \t\t\t\t};\r\n\t// \t\t\t});\r\n\t// \t\t}\r\n\t// \t}\r\n\r\n\t// \t// TODO: what happens if the Hunter is killed during the attack?\r\n\t// \tif (\r\n\t// \t\t[CardIds.HunterOfGatherers_BG25_027, CardIds.HunterOfGatherers_BG25_027_G].includes(\r\n\t// \t\t\tentity.cardId as CardIds,\r\n\t// \t\t)\r\n\t// \t) {\r\n\t// \t\taddStatsToBoard(\r\n\t// \t\t\tentity,\r\n\t// \t\t\tplayerState.board,\r\n\t// \t\t\tplayerState.player,\r\n\t// \t\t\t0,\r\n\t// \t\t\tentity.cardId === CardIds.HunterOfGatherers_BG25_027_G ? 2 : 1,\r\n\t// \t\t\tgameState,\r\n\t// \t\t);\r\n\t// \t}\r\n\t// }\r\n\tentity.pendingAttackBuffs = [];\r\n};\r\n\r\nconst onStatUpdateQuests = (\r\n\tentity: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst quests = hero.questEntities ?? [];\r\n\tif (!quests.length) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tfor (const quest of quests) {\r\n\t\tswitch (quest.CardId) {\r\n\t\t\tcase CardIds.FindTheMurderWeapon:\r\n\t\t\t\tonQuestProgressUpdated(hero, quest, board, gameState);\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.PressureTheAuthorities:\r\n\t\t\t\tconst totalAttack = board.map((e) => e.attack).reduce((a, b) => a + b, 0);\r\n\t\t\t\tif (totalAttack >= 35) {\r\n\t\t\t\t\tonQuestProgressUpdated(hero, quest, board, gameState);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst onStatUpdateMinions = (\r\n\tentity: BoardEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (hasCorrectTribe(entity, Race.ELEMENTAL, gameState.allCards)) {\r\n\t\tconst masterOfRealities = friendlyBoard.filter(\r\n\t\t\t(e) => e.cardId === CardIds.MasterOfRealities_BG21_036 || e.cardId === CardIds.MasterOfRealities_BG21_036_G,\r\n\t\t);\r\n\t\tmasterOfRealities.forEach((master) => {\r\n\t\t\tmodifyStats(\r\n\t\t\t\tmaster,\r\n\t\t\t\tmaster.cardId === CardIds.MasterOfRealities_BG21_036_G ? 2 : 1,\r\n\t\t\t\tmaster.cardId === CardIds.MasterOfRealities_BG21_036_G ? 2 : 1,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tfriendlyBoardHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\tconst tentaclesOfCthun = friendlyBoard\r\n\t\t.filter((e) => e.entityId !== entity.entityId)\r\n\t\t.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy ||\r\n\t\t\t\te.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G,\r\n\t\t);\r\n\ttentaclesOfCthun.forEach((tentacle) => {\r\n\t\ttentacle.attack += tentacle.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G ? 2 : 1;\r\n\t\ttentacle.health += tentacle.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G ? 2 : 1;\r\n\t});\r\n};\r\n"]}
|
package/dist/utils.js
CHANGED
|
@@ -137,9 +137,9 @@ const makeMinionGolden = (target, source, targetBoard, targetBoardHero, gameStat
|
|
|
137
137
|
if (!(goldenCard === null || goldenCard === void 0 ? void 0 : goldenCard.id)) {
|
|
138
138
|
goldenCard = refCard;
|
|
139
139
|
}
|
|
140
|
-
(0, stats_1.modifyStats)(target, refCard.attack, refCard.health, targetBoard, targetBoardHero, gameState);
|
|
141
140
|
const refGoldenCard = gameState.allCards.getCard(target.cardId);
|
|
142
141
|
target.cardId = goldenCard.id;
|
|
142
|
+
(0, stats_1.modifyStats)(target, refCard.attack, refCard.health, targetBoard, targetBoardHero, gameState);
|
|
143
143
|
(0, add_minion_to_board_1.handleAddedMinionAuraEffect)(targetBoard, targetBoardHero, target, gameState);
|
|
144
144
|
const hasDivineShield = target.divineShield;
|
|
145
145
|
const hasReborn = target.reborn;
|
|
@@ -283,9 +283,12 @@ const getMinionsOfDifferentTypes = (board, gameState, canRevive = true, numberOf
|
|
|
283
283
|
let boardCopy = board.filter((e) => { var _a; return !((_a = gameState.allCards.getCard(e.cardId).races) === null || _a === void 0 ? void 0 : _a.includes(reference_data_1.Race[reference_data_1.Race.ALL])); });
|
|
284
284
|
const allRaces = (0, utils_1.shuffleArray)(reference_data_1.ALL_BG_RACES);
|
|
285
285
|
let typesBuffed = 0;
|
|
286
|
+
const racesProcessed = [];
|
|
286
287
|
for (let i = 1; i <= 2; i++) {
|
|
287
288
|
for (const tribe of allRaces) {
|
|
288
|
-
const minionsWithRaces = boardCopy
|
|
289
|
+
const minionsWithRaces = boardCopy
|
|
290
|
+
.filter((e) => { var _a; return ((_a = gameState.allCards.getCard(e.cardId).races) === null || _a === void 0 ? void 0 : _a.length) === i; })
|
|
291
|
+
.filter((e) => gameState.allCards.getCard(e.cardId).races.some((r) => !racesProcessed.includes(reference_data_1.Race[r])));
|
|
289
292
|
if (typesBuffed >= numberOfDifferentTypes) {
|
|
290
293
|
return result;
|
|
291
294
|
}
|
|
@@ -296,6 +299,7 @@ const getMinionsOfDifferentTypes = (board, gameState, canRevive = true, numberOf
|
|
|
296
299
|
result.push(validMinion);
|
|
297
300
|
boardCopy = boardCopy.filter((e) => e !== validMinion);
|
|
298
301
|
typesBuffed++;
|
|
302
|
+
racesProcessed.push(tribe);
|
|
299
303
|
}
|
|
300
304
|
}
|
|
301
305
|
}
|