@firestone-hs/simulate-bgs-battle 1.1.720 → 1.1.721
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cards/impl/bg-spell/upper-hand.d.ts +1 -1
- package/dist/cards/impl/bg-spell/upper-hand.js +2 -2
- package/dist/cards/impl/bg-spell/upper-hand.js.map +1 -1
- package/dist/cards/impl/minion/diremuck-forager.js +5 -20
- package/dist/cards/impl/minion/diremuck-forager.js.map +1 -1
- package/dist/cards/impl/minion/timewarped-promo-drake.js +1 -1
- package/dist/cards/impl/minion/timewarped-promo-drake.js.map +1 -1
- package/dist/debug-state.d.ts +3 -1
- package/dist/debug-state.js +7 -0
- package/dist/debug-state.js.map +1 -1
- package/dist/services/utils.d.ts +3 -1
- package/dist/services/utils.js.map +1 -1
- package/dist/simulation/summon-when-space.js +1 -0
- package/dist/simulation/summon-when-space.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BoardSecret } from '../../../board-secret';
|
|
2
2
|
import { SoCInput } from '../../../simulation/start-of-combat/start-of-combat-input';
|
|
3
3
|
export declare const UpperHand: {
|
|
4
|
-
startOfCombat: (
|
|
4
|
+
startOfCombat: (secret: BoardSecret, input: SoCInput) => boolean;
|
|
5
5
|
};
|
|
@@ -4,9 +4,9 @@ exports.UpperHand = void 0;
|
|
|
4
4
|
const utils_1 = require("../../../services/utils");
|
|
5
5
|
const stats_1 = require("../../../simulation/stats");
|
|
6
6
|
exports.UpperHand = {
|
|
7
|
-
startOfCombat: (
|
|
7
|
+
startOfCombat: (secret, input) => {
|
|
8
8
|
if (!!input.opponentBoard.length) {
|
|
9
|
-
const target = (0, utils_1.pickRandom)(input.opponentBoard);
|
|
9
|
+
const target = (0, utils_1.pickRandom)(input.opponentBoard, secret);
|
|
10
10
|
(0, stats_1.setEntityStats)(target, target.attack, 1, input.opponentBoard, input.opponentEntity, input.gameState);
|
|
11
11
|
input.gameState.spectator.registerPowerTarget(input.playerEntity, target, input.opponentBoard, null, null);
|
|
12
12
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upper-hand.js","sourceRoot":"","sources":["../../../../src/cards/impl/bg-spell/upper-hand.ts"],"names":[],"mappings":";;;AACA,mDAAqD;AAErD,qDAA2D;AAE9C,QAAA,SAAS,GAAG;IACxB,aAAa,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"upper-hand.js","sourceRoot":"","sources":["../../../../src/cards/impl/bg-spell/upper-hand.ts"],"names":[],"mappings":";;;AACA,mDAAqD;AAErD,qDAA2D;AAE9C,QAAA,SAAS,GAAG;IACxB,aAAa,EAAE,CAAC,MAAmB,EAAE,KAAe,EAAE,EAAE;QACvD,IAAI,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,EAAE;YACjC,MAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,KAAK,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;YACvD,IAAA,sBAAc,EAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;YACrG,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAAC,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,aAAa,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;YAC3G,OAAO,IAAI,CAAC;SACZ;IACF,CAAC;CACD,CAAC","sourcesContent":["import { BoardSecret } from '../../../board-secret';\r\nimport { pickRandom } from '../../../services/utils';\r\nimport { SoCInput } from '../../../simulation/start-of-combat/start-of-combat-input';\r\nimport { setEntityStats } from '../../../simulation/stats';\r\n\r\nexport const UpperHand = {\r\n\tstartOfCombat: (secret: BoardSecret, input: SoCInput) => {\r\n\t\tif (!!input.opponentBoard.length) {\r\n\t\t\tconst target = pickRandom(input.opponentBoard, secret);\r\n\t\t\tsetEntityStats(target, target.attack, 1, input.opponentBoard, input.opponentEntity, input.gameState);\r\n\t\t\tinput.gameState.spectator.registerPowerTarget(input.playerEntity, target, input.opponentBoard, null, null);\r\n\t\t\treturn true;\r\n\t\t}\r\n\t},\r\n};\r\n"]}
|
|
@@ -26,14 +26,13 @@ const handleDiremuckPendingSummons = (playerBoard, playerEntity, opponentBoard,
|
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
28
|
const allCards = gameState.allCards;
|
|
29
|
-
const predicate = handMinionPredicate(allCards);
|
|
30
29
|
const nextQueue = [];
|
|
31
30
|
for (const entry of raw) {
|
|
32
31
|
let remaining = entry.remaining;
|
|
33
32
|
const forager = (_b = playerBoard.find((e) => e.entityId === entry.foragerEntityId)) !== null && _b !== void 0 ? _b : null;
|
|
34
33
|
while (playerBoard.length < 7 && remaining > 0) {
|
|
35
34
|
const candidates = playerEntity.hand.filter((e) => (0, utils_1.hasCorrectTribe)(e, playerEntity, reference_data_1.Race.MURLOC, gameState.anomalies, gameState.allCards));
|
|
36
|
-
const targets = (0, hand_minion_priority_1.getHighestAttackHandMinions)(candidates, 1,
|
|
35
|
+
const targets = (0, hand_minion_priority_1.getHighestAttackHandMinions)(candidates, 1, (e) => handMinionPredicate(allCards)(e));
|
|
37
36
|
const handTarget = targets[0];
|
|
38
37
|
if (!(handTarget === null || handTarget === void 0 ? void 0 : handTarget.cardId) || handTarget.locked) {
|
|
39
38
|
break;
|
|
@@ -53,25 +52,11 @@ exports.DiremuckForager = {
|
|
|
53
52
|
startOfCombatTiming: 'start-of-combat',
|
|
54
53
|
startOfCombat: (minion, input) => {
|
|
55
54
|
var _a;
|
|
56
|
-
const allCards = input.gameState.allCards;
|
|
57
55
|
const totalWanted = minion.cardId === "BG27_556_G" ? 2 : 1;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const target = targets[0];
|
|
63
|
-
if (!(target === null || target === void 0 ? void 0 : target.cardId) || target.locked) {
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
summonHandMinionFromDiremuck(minion, target, input.playerBoard, input.playerEntity, input.opponentBoard, input.opponentEntity, input.gameState);
|
|
67
|
-
remaining--;
|
|
68
|
-
}
|
|
69
|
-
if (remaining > 0) {
|
|
70
|
-
input.playerEntity.globalInfo.DiremuckPendingSummons = [
|
|
71
|
-
...((_a = input.playerEntity.globalInfo.DiremuckPendingSummons) !== null && _a !== void 0 ? _a : []),
|
|
72
|
-
{ foragerEntityId: minion.entityId, remaining },
|
|
73
|
-
];
|
|
74
|
-
}
|
|
56
|
+
input.playerEntity.globalInfo.DiremuckPendingSummons = [
|
|
57
|
+
...((_a = input.playerEntity.globalInfo.DiremuckPendingSummons) !== null && _a !== void 0 ? _a : []),
|
|
58
|
+
{ foragerEntityId: minion.entityId, remaining: totalWanted },
|
|
59
|
+
];
|
|
75
60
|
return true;
|
|
76
61
|
},
|
|
77
62
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diremuck-forager.js","sourceRoot":"","sources":["../../../../src/cards/impl/minion/diremuck-forager.ts"],"names":[],"mappings":";;;AAOA,iEAAoD;AAIpD,iFAA4G;AAC5G,+EAAuE;AAEvE,uDAAiE;AAEjE,0CAAiD;AAGjD,MAAM,mBAAmB,GAAG,CAAC,QAAmC,EAAE,EAAE,CAAC,CAAC,CAAc,EAAE,EAAE,CACvF,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,IAAA,4CAAqB,EAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,WAAC,OAAA,MAAA,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,0CAAE,WAAW,EAAE,CAAA,EAAA,CAAC,CAAC;AAG7F,MAAM,4BAA4B,GAAG,CACpC,OAA2B,EAC3B,UAAuB,EACvB,WAA0B,EAC1B,YAA6B,EAC7B,aAA4B,EAC5B,cAA+B,EAC/B,SAAwB,EACjB,EAAE;;IACT,UAA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AAC,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE;SAC5D,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAC","sourcesContent":["/**\r\n * Diremuck Forager (Tier 4, 5/6)\r\n * Start of Combat: When you have space, summon the highest-Attack minion from your hand for this combat only.\r\n *\r\n * Golden Diremuck Forager (Tier 4, 10/12)\r\n * Start of Combat: When you have space, summon the two highest-Attack minions from your hand for this combat only.\r\n */\r\nimport { Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../../../bgs-player-entity';\r\nimport { BoardEntity } from '../../../board-entity';\r\nimport { CardIds } from '../../../services/card-ids';\r\nimport { getHighestAttackHandMinions, isHandMinionCandidate } from '../../../services/hand-minion-priority';\r\nimport { spawnEntities } from '../../../simulation/deathrattle-spawns';\r\nimport { FullGameState } from '../../../simulation/internal-game-state';\r\nimport { performEntitySpawns } from '../../../simulation/spawns';\r\nimport { SoCInput } from '../../../simulation/start-of-combat/start-of-combat-input';\r\nimport { hasCorrectTribe } from '../../../utils';\r\nimport { StartOfCombatCard } from '../../card.interface';\r\n\r\nconst handMinionPredicate = (allCards: FullGameState['allCards']) => (e: BoardEntity) =>\r\n\t!!e.maxHealth && isHandMinionCandidate(e, (id) => allCards.getCard(id).type?.toUpperCase());\r\n\r\n/** If the Forager died after SOC, pass `null` — summons still resolve (spawn source = hero, index from right = 0). */\r\nconst summonHandMinionFromDiremuck = (\r\n\tforager: BoardEntity | null,\r\n\thandTarget: BoardEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\thandTarget.locked = true;\r\n\tconst friendly = forager?.friendly ?? playerEntity.friendly;\r\n\tconst newMinions = spawnEntities(\r\n\t\thandTarget.cardId,\r\n\t\t1,\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tgameState,\r\n\t\tfriendly,\r\n\t\tfalse,\r\n\t\tfalse,\r\n\t\ttrue,\r\n\t\t{ ...handTarget } as BoardEntity,\r\n\t);\r\n\tfor (const s of newMinions) {\r\n\t\ts.onCanceledSummon = () => (handTarget.locked = false);\r\n\t}\r\n\tconst spawnSource = forager ?? playerEntity;\r\n\t// const indexFromRight = 0;\r\n\t// 2026-04-25: https://replays.firestoneapp.com/?reviewId=b498d69f-bf1b-4bc0-8902-3643434394d5&turn=23&action=3\r\n\t// Spawns right of the Forager, if it's on the board\r\n\tconst indexFromRight =\r\n\t\tforager != null && playerBoard.includes(forager) ? playerBoard.length - (playerBoard.indexOf(forager) + 1) : 0;\r\n\tperformEntitySpawns(\r\n\t\tnewMinions,\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\tspawnSource,\r\n\t\tindexFromRight,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tgameState,\r\n\t);\r\n};\r\n\r\n/** Called from `summon-when-space` when board space opens during start-of-combat. */\r\nexport const handleDiremuckPendingSummons = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst raw = playerEntity.globalInfo?.DiremuckPendingSummons;\r\n\tif (!raw?.length) {\r\n\t\treturn;\r\n\t}\r\n\tconst allCards = gameState.allCards;\r\n\tconst nextQueue: { foragerEntityId: number; remaining: number }[] = [];\r\n\r\n\tfor (const entry of raw) {\r\n\t\tlet remaining = entry.remaining;\r\n\t\tconst forager = playerBoard.find((e) => e.entityId === entry.foragerEntityId) ?? null;\r\n\t\twhile (playerBoard.length < 7 && remaining > 0) {\r\n\t\t\tconst candidates = playerEntity.hand.filter((e) =>\r\n\t\t\t\thasCorrectTribe(e, playerEntity, Race.MURLOC, gameState.anomalies, gameState.allCards),\r\n\t\t\t);\r\n\t\t\tconst targets = getHighestAttackHandMinions(candidates, 1, (e) => handMinionPredicate(allCards)(e));\r\n\t\t\tconst handTarget = targets[0];\r\n\t\t\tif (!handTarget?.cardId || handTarget.locked) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tsummonHandMinionFromDiremuck(\r\n\t\t\t\tforager,\r\n\t\t\t\thandTarget,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tremaining--;\r\n\t\t}\r\n\t\tif (remaining > 0) {\r\n\t\t\tnextQueue.push({ foragerEntityId: entry.foragerEntityId, remaining });\r\n\t\t}\r\n\t}\r\n\tplayerEntity.globalInfo.DiremuckPendingSummons = nextQueue.length ? nextQueue : undefined;\r\n};\r\n\r\nexport const DiremuckForager: StartOfCombatCard = {\r\n\tcardIds: [CardIds.DiremuckForager_BG27_556, CardIds.DiremuckForager_BG27_556_G],\r\n\tstartOfCombatTiming: 'start-of-combat',\r\n\tstartOfCombat: (minion: BoardEntity, input: SoCInput) => {\r\n\t\t// Don't clear the info, as multiple Diremuck Foragers can be on the board at the same time,\r\n\t\t// and they stack\r\n\t\t// input.playerEntity.globalInfo.DiremuckPendingSummons = undefined;\r\n\t\tconst totalWanted = minion.cardId === CardIds.DiremuckForager_BG27_556_G ? 2 : 1;\r\n\t\tinput.playerEntity.globalInfo.DiremuckPendingSummons = [\r\n\t\t\t...(input.playerEntity.globalInfo.DiremuckPendingSummons ?? []),\r\n\t\t\t{ foragerEntityId: minion.entityId, remaining: totalWanted },\r\n\t\t];\r\n\t\treturn true;\r\n\t},\r\n};\r\n"]}
|
|
@@ -7,7 +7,7 @@ exports.TimewarpedPromoDrake = {
|
|
|
7
7
|
startOfCombatTiming: 'start-of-combat',
|
|
8
8
|
startOfCombat: (minion, input) => {
|
|
9
9
|
const mult = minion.cardId === "BG34_Giant_088_G" ? 2 : 1;
|
|
10
|
-
const buff =
|
|
10
|
+
const buff = minion.scriptDataNum4 || 5 * mult;
|
|
11
11
|
const targets = input.playerBoard;
|
|
12
12
|
for (const entity of targets) {
|
|
13
13
|
(0, stats_1.modifyStats)(entity, minion, buff, buff, input.playerBoard, input.playerEntity, input.gameState);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timewarped-promo-drake.js","sourceRoot":"","sources":["../../../../src/cards/impl/minion/timewarped-promo-drake.ts"],"names":[],"mappings":";;;AAGA,qDAAwD;AAG3C,QAAA,oBAAoB,GAAsB;IACtD,OAAO,EAAE,sCAA4F;IACrG,mBAAmB,EAAE,iBAAiB;IACtC,aAAa,EAAE,CAAC,MAAmB,EAAE,KAAe,EAAE,EAAE;QACvD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,uBAAkD,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"timewarped-promo-drake.js","sourceRoot":"","sources":["../../../../src/cards/impl/minion/timewarped-promo-drake.ts"],"names":[],"mappings":";;;AAGA,qDAAwD;AAG3C,QAAA,oBAAoB,GAAsB;IACtD,OAAO,EAAE,sCAA4F;IACrG,mBAAmB,EAAE,iBAAiB;IACtC,aAAa,EAAE,CAAC,MAAmB,EAAE,KAAe,EAAE,EAAE;QACvD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,uBAAkD,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACrF,MAAM,IAAI,GAAG,MAAM,CAAC,cAAc,IAAI,CAAC,GAAG,IAAI,CAAC;QAC/C,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC;QAClC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC7B,IAAA,mBAAW,EAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;SAChG;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAC","sourcesContent":["import { BoardEntity } from '../../../board-entity';\r\nimport { CardIds } from '../../../services/card-ids';\r\nimport { SoCInput } from '../../../simulation/start-of-combat/start-of-combat-input';\r\nimport { modifyStats } from '../../../simulation/stats';\r\nimport { StartOfCombatCard } from '../../card.interface';\r\n\r\nexport const TimewarpedPromoDrake: StartOfCombatCard = {\r\n\tcardIds: [CardIds.TimewarpedPromoDrake_BG34_Giant_088, CardIds.TimewarpedPromoDrake_BG34_Giant_088_G],\r\n\tstartOfCombatTiming: 'start-of-combat',\r\n\tstartOfCombat: (minion: BoardEntity, input: SoCInput) => {\r\n\t\tconst mult = minion.cardId === CardIds.TimewarpedPromoDrake_BG34_Giant_088_G ? 2 : 1;\r\n\t\tconst buff = minion.scriptDataNum4 || 5 * mult;\r\n\t\tconst targets = input.playerBoard;\r\n\t\tfor (const entity of targets) {\r\n\t\t\tmodifyStats(entity, minion, buff, buff, input.playerBoard, input.playerEntity, input.gameState);\r\n\t\t}\r\n\t\treturn true;\r\n\t},\r\n};\r\n"]}
|
package/dist/debug-state.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { BoardTrinket } from './bgs-player-entity';
|
|
1
2
|
import { BoardEntity } from './board-entity';
|
|
3
|
+
import { BoardSecret } from './board-secret';
|
|
2
4
|
export declare const debugState: {
|
|
3
5
|
active: boolean;
|
|
4
6
|
forcedCurrentAttacker: number;
|
|
@@ -15,7 +17,7 @@ export declare const debugState: {
|
|
|
15
17
|
target: ForcedFaceOffEntity;
|
|
16
18
|
chosenCardId?: string;
|
|
17
19
|
}[];
|
|
18
|
-
isCorrectEntity: (proposedEntity: ForcedFaceOffEntity, actualEntity: BoardEntity) => boolean;
|
|
20
|
+
isCorrectEntity: (proposedEntity: ForcedFaceOffEntity, actualEntity: BoardEntity | BoardSecret | BoardTrinket) => boolean;
|
|
19
21
|
forcedRandomPicksBase: {
|
|
20
22
|
source: ForcedFaceOffEntity;
|
|
21
23
|
target: ForcedFaceOffEntity;
|
package/dist/debug-state.js
CHANGED
|
@@ -13,11 +13,17 @@ exports.debugState = {
|
|
|
13
13
|
}
|
|
14
14
|
if (proposedEntity.cardId) {
|
|
15
15
|
const cardMatches = proposedEntity.cardId === actualEntity.cardId;
|
|
16
|
+
if (!isBoardEntity(actualEntity)) {
|
|
17
|
+
return cardMatches;
|
|
18
|
+
}
|
|
16
19
|
if (proposedEntity.attack != null && proposedEntity.health != null) {
|
|
17
20
|
return cardMatches && proposedEntity.attack === actualEntity.attack && proposedEntity.health === actualEntity.health;
|
|
18
21
|
}
|
|
19
22
|
return cardMatches;
|
|
20
23
|
}
|
|
24
|
+
if (!isBoardEntity(actualEntity)) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
21
27
|
return (proposedEntity.attack === actualEntity.attack &&
|
|
22
28
|
proposedEntity.health === actualEntity.health);
|
|
23
29
|
},
|
|
@@ -27,4 +33,5 @@ exports.debugState = {
|
|
|
27
33
|
exports.debugState.forcedRandomPicks = [...exports.debugState.forcedRandomPicksBase];
|
|
28
34
|
},
|
|
29
35
|
};
|
|
36
|
+
const isBoardEntity = (entity) => 'attack' in entity && 'health' in entity;
|
|
30
37
|
//# sourceMappingURL=debug-state.js.map
|
package/dist/debug-state.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug-state.js","sourceRoot":"","sources":["../src/debug-state.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"debug-state.js","sourceRoot":"","sources":["../src/debug-state.ts"],"names":[],"mappings":";;;AAIa,QAAA,UAAU,GAAG;IACzB,MAAM,EAAE,KAAK;IACb,qBAAqB,EAAE,IAAqB;IAC5C,aAAa,EAAE,EAAwE;IACvF,iBAAiB,EAAE,EAAwE;IAE3F,iBAAiB,EAAE,EAA2F;IAC9G,eAAe,EAAE,CAAC,cAAmC,EAAE,YAAsD,EAAW,EAAE;QACzH,IAAI,cAAc,CAAC,QAAQ,EAAE;YAC5B,OAAO,cAAc,CAAC,QAAQ,KAAK,YAAY,CAAC,QAAQ,CAAC;SACzD;QAED,IAAI,cAAc,CAAC,MAAM,EAAE;YAC1B,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,KAAK,YAAY,CAAC,MAAM,CAAC;YAClE,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,EAAE;gBACjC,OAAO,WAAW,CAAC;aACnB;YACD,IAAI,cAAc,CAAC,MAAM,IAAI,IAAI,IAAI,cAAc,CAAC,MAAM,IAAI,IAAI,EAAE;gBACnE,OAAO,WAAW,IAAI,cAAc,CAAC,MAAM,KAAK,YAAY,CAAC,MAAM,IAAI,cAAc,CAAC,MAAM,KAAK,YAAY,CAAC,MAAM,CAAC;aACrH;YACD,OAAO,WAAW,CAAC;SACnB;QACD,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,EAAE;YACjC,OAAO,KAAK,CAAC;SACb;QACD,OAAO,CACN,cAAc,CAAC,MAAM,KAAK,YAAY,CAAC,MAAM;YAC7C,cAAc,CAAC,MAAM,KAAK,YAAY,CAAC,MAAM,CAC7C,CAAC;IACH,CAAC;IACD,qBAAqB,EAAE,EAA2F;IAClH,aAAa,EAAE,GAAG,EAAE;QACnB,kBAAU,CAAC,aAAa,GAAG,CAAC,GAAG,kBAAU,CAAC,iBAAiB,CAAC,CAAC;QAC7D,kBAAU,CAAC,iBAAiB,GAAG,CAAC,GAAG,kBAAU,CAAC,qBAAqB,CAAC,CAAC;IACtE,CAAC;CACD,CAAC;AASF,MAAM,aAAa,GAAG,CAAC,MAAgD,EAAyB,EAAE,CACjG,QAAQ,IAAI,MAAM,IAAI,QAAQ,IAAI,MAAM,CAAC","sourcesContent":["import { BoardTrinket } from './bgs-player-entity';\nimport { BoardEntity } from './board-entity';\nimport { BoardSecret } from './board-secret';\n\nexport const debugState = {\n\tactive: false,\n\tforcedCurrentAttacker: null as number | null,\n\tforcedFaceOff: [] as { attacker: ForcedFaceOffEntity; defender: ForcedFaceOffEntity }[],\n\tforcedFaceOffBase: [] as { attacker: ForcedFaceOffEntity; defender: ForcedFaceOffEntity }[],\n\t/** Forced random picks: source -> target. Matched by source entity (like face-offs match by attacker). Optional chosenCardId for card-pool picks (e.g. Apexis Guardian Volumizer). */\n\tforcedRandomPicks: [] as { source: ForcedFaceOffEntity; target: ForcedFaceOffEntity; chosenCardId?: string }[],\n\tisCorrectEntity: (proposedEntity: ForcedFaceOffEntity, actualEntity: BoardEntity | BoardSecret | BoardTrinket): boolean => {\n\t\tif (proposedEntity.entityId) {\n\t\t\treturn proposedEntity.entityId === actualEntity.entityId;\n\t\t}\n\n\t\tif (proposedEntity.cardId) {\n\t\t\tconst cardMatches = proposedEntity.cardId === actualEntity.cardId;\n\t\t\tif (!isBoardEntity(actualEntity)) {\n\t\t\t\treturn cardMatches;\n\t\t\t}\n\t\t\tif (proposedEntity.attack != null && proposedEntity.health != null) {\n\t\t\t\treturn cardMatches && proposedEntity.attack === actualEntity.attack && proposedEntity.health === actualEntity.health;\n\t\t\t}\n\t\t\treturn cardMatches;\n\t\t}\n\t\tif (!isBoardEntity(actualEntity)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn (\n\t\t\tproposedEntity.attack === actualEntity.attack &&\n\t\t\tproposedEntity.health === actualEntity.health\n\t\t);\n\t},\n\tforcedRandomPicksBase: [] as { source: ForcedFaceOffEntity; target: ForcedFaceOffEntity; chosenCardId?: string }[],\n\tonBattleStart: () => {\n\t\tdebugState.forcedFaceOff = [...debugState.forcedFaceOffBase];\n\t\tdebugState.forcedRandomPicks = [...debugState.forcedRandomPicksBase];\n\t},\n};\n\nexport interface ForcedFaceOffEntity {\n\tentityId?: number;\n\tcardId?: string;\n\tattack?: number;\n\thealth?: number;\n}\n\nconst isBoardEntity = (entity: BoardEntity | BoardSecret | BoardTrinket): entity is BoardEntity =>\n\t'attack' in entity && 'health' in entity;\n"]}
|
package/dist/services/utils.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { BoardTrinket } from '../bgs-player-entity';
|
|
1
2
|
import { BoardEntity } from '../board-entity';
|
|
3
|
+
import { BoardSecret } from '../board-secret';
|
|
2
4
|
declare function partitionArray<T>(array: readonly T[], partitionSize: number): readonly T[][];
|
|
3
5
|
declare function sleep(ms: any): Promise<unknown>;
|
|
4
6
|
export declare const groupByFunction: <T>(keyExtractor: (obj: T) => string | number) => (array: readonly T[]) => {
|
|
@@ -6,7 +8,7 @@ export declare const groupByFunction: <T>(keyExtractor: (obj: T) => string | num
|
|
|
6
8
|
};
|
|
7
9
|
export { partitionArray, sleep };
|
|
8
10
|
export declare function pickRandom<T>(array: readonly T[]): T;
|
|
9
|
-
export declare function pickRandom<T extends BoardEntity>(array: readonly T[], sourceEntity: BoardEntity): T;
|
|
11
|
+
export declare function pickRandom<T extends BoardEntity>(array: readonly T[], sourceEntity: BoardEntity | BoardSecret | BoardTrinket): T;
|
|
10
12
|
export declare const pickMultipleRandom: <T>(array: readonly T[], quantity: number) => T[];
|
|
11
13
|
export declare const pickRandomAlive: (board: BoardEntity[]) => BoardEntity;
|
|
12
14
|
export declare const pickMultipleRandomAlive: (board: BoardEntity[], quantity: number) => BoardEntity[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/services/utils.ts"],"names":[],"mappings":";;;AACA,gDAA4C;AAE5C,SAAS,cAAc,CAAI,KAAmB,EAAE,aAAqB;IACpE,MAAM,WAAW,GAAQ,CAAC,GAAG,KAAK,CAAC,CAAC;IACpC,MAAM,MAAM,GAAU,EAAE,CAAC;IACzB,OAAO,WAAW,CAAC,MAAM,EAAE;QAC1B,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC;KAClD;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAkBQ,wCAAc;AA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,YAUnB","sourcesContent":["import { BoardEntity } from '../board-entity';\r\nimport { debugState } from '../debug-state';\r\n\r\nfunction partitionArray<T>(array: readonly T[], partitionSize: number): readonly T[][] {\r\n\tconst workingCopy: T[] = [...array];\r\n\tconst result: T[][] = [];\r\n\twhile (workingCopy.length) {\r\n\t\tresult.push(workingCopy.splice(0, partitionSize));\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nasync function sleep(ms) {\r\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\r\n}\r\n\r\nexport const groupByFunction =\r\n\t<T>(keyExtractor: (obj: T) => string | number) =>\r\n\t(array: readonly T[]): { [key: string]: readonly T[] } => {\r\n\t\treturn (array ?? []).reduce((objectsByKeyValue, obj) => {\r\n\t\t\tconst value = keyExtractor(obj);\r\n\t\t\tobjectsByKeyValue[value] = objectsByKeyValue[value] ?? [];\r\n\t\t\t// Using push instead of concat is thousands of times faster on big arrays\r\n\t\t\tobjectsByKeyValue[value].push(obj);\r\n\t\t\treturn objectsByKeyValue;\r\n\t\t}, {});\r\n\t};\r\n\r\nexport { partitionArray, sleep };\r\n\r\nexport function pickRandom<T>(array: readonly T[]): T;\r\nexport function pickRandom<T extends BoardEntity>(array: readonly T[], sourceEntity: BoardEntity): T;\r\nexport function pickRandom<T>(array: readonly T[], sourceEntity?: BoardEntity): T {\r\n\tif (!array?.length) {\r\n\t\treturn null;\r\n\t}\r\n\tif (\r\n\t\tsourceEntity &&\r\n\t\tdebugState.active &&\r\n\t\tarray.length > 0 &&\r\n\t\ttypeof array[0] === 'object' &&\r\n\t\tarray[0] != null &&\r\n\t\t'entityId' in array[0]\r\n\t) {\r\n\t\tconst forced = debugState.forcedRandomPicks.find((p) => debugState.isCorrectEntity(p.source, sourceEntity));\r\n\t\tif (forced) {\r\n\t\t\tconst match = (array as unknown as BoardEntity[]).find((c) => debugState.isCorrectEntity(forced.target, c));\r\n\t\t\t// Defer consumption when pick has chosenCardId - getRandomMagneticVolumizer will consume (e.g. Apexis Guardian)\r\n\t\t\tif (!forced.chosenCardId) {\r\n\t\t\t\tdebugState.forcedRandomPicks = debugState.forcedRandomPicks.filter((p) => p !== forced);\r\n\t\t\t}\r\n\t\t\tif (match) {\r\n\t\t\t\treturn match as T;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn array[Math.floor(Math.random() * array.length)];\r\n}\r\n\r\nexport const pickMultipleRandom = <T>(array: readonly T[], quantity: number): T[] => {\r\n\tconst picked: T[] = [];\r\n\tfor (let i = 0; i < quantity; i++) {\r\n\t\tconst target = array.filter((e) => !picked.includes(e));\r\n\t\tconst chosenEntity = pickRandom(target);\r\n\t\tif (!!chosenEntity) {\r\n\t\t\tpicked.push(chosenEntity);\r\n\t\t}\r\n\t}\r\n\treturn picked;\r\n};\r\n\r\nexport const pickRandomAlive = (board: BoardEntity[]): BoardEntity => {\r\n\tconst targetBoard = board.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tconst chosenEntity = pickRandom(targetBoard);\r\n\treturn chosenEntity;\r\n};\r\n\r\nexport const pickMultipleRandomAlive = (board: BoardEntity[], quantity: number): BoardEntity[] => {\r\n\tconst picked: BoardEntity[] = [];\r\n\tfor (let i = 0; i < quantity; i++) {\r\n\t\tconst targetBoard = board.filter((e) => e.health > 0 && !e.definitelyDead).filter((e) => !picked.includes(e));\r\n\t\tconst chosenEntity = pickRandom(targetBoard);\r\n\t\tif (!!chosenEntity) {\r\n\t\t\tpicked.push(chosenEntity);\r\n\t\t}\r\n\t}\r\n\treturn picked;\r\n};\r\n\r\nexport const pickRandomLowestHealth = (board: BoardEntity[]): BoardEntity => {\r\n\tconst targetBoard = board.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tconst lowestHealth = Math.min(...targetBoard.map((e) => e.health));\r\n\tconst entitiesWithLowestHealth = targetBoard.filter((e) => e.health === lowestHealth);\r\n\tconst chosenEntity = pickRandom(entitiesWithLowestHealth);\r\n\treturn chosenEntity;\r\n};\r\n\r\nexport const pickRandomLowestAttack = (board: BoardEntity[]): BoardEntity => {\r\n\tconst targetBoard = board.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tconst lowestAttack = Math.min(...targetBoard.map((e) => e.attack));\r\n\tconst entitiesWithLowestAttack = targetBoard.filter((e) => e.attack === lowestAttack);\r\n\tconst chosenEntity = pickRandom(entitiesWithLowestAttack);\r\n\treturn chosenEntity;\r\n};\r\n\r\nexport const pickRandomHighestAttack = (board: BoardEntity[]): BoardEntity => {\r\n\tconst targetBoard = board.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tconst highestAttack = Math.max(...targetBoard.map((e) => e.attack));\r\n\tconst entitiesWithHighestAttack = targetBoard.filter((e) => e.attack === highestAttack);\r\n\tconst chosenEntity = pickRandom(entitiesWithHighestAttack);\r\n\treturn chosenEntity;\r\n};\r\n\r\nexport const pickRandomHighestHealth = (board: BoardEntity[]): BoardEntity => {\r\n\tconst targetBoard = board.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tconst highestHealth = Math.max(...targetBoard.map((e) => e.health));\r\n\tconst entitiesWithHighestHealth = targetBoard.filter((e) => e.health === highestHealth);\r\n\tconst chosenEntity = pickRandom(entitiesWithHighestHealth);\r\n\treturn chosenEntity;\r\n};\r\n\r\nexport const encode = (input: string): string => {\r\n\t// return compressToEncodedURIComponent(input);\r\n\tconst buff = Buffer.from(input, 'utf-8');\r\n\tconst base64 = buff.toString('base64');\r\n\treturn base64;\r\n};\r\n\r\nexport const decode = (base64: string): string => {\r\n\tconst buff = Buffer.from(base64, 'base64');\r\n\tconst str = buff.toString('utf-8');\r\n\treturn str;\r\n};\r\n\r\nexport const pickMultipleRandomDifferent = <T>(list: T[], n: number): T[] => {\r\n\tconst shuffled = shuffleArray([...list]);\r\n\treturn shuffled.slice(0, n);\r\n};\r\n\r\n// https://stackoverflow.com/a/2450976/548701\r\nexport const shuffleArray = <T>(array: T[]): T[] => {\r\n\tlet currentIndex = array.length;\r\n\tlet randomIndex = 0;\r\n\r\n\t// While there remain elements to shuffle...\r\n\twhile (currentIndex != 0) {\r\n\t\t// Pick a remaining element...\r\n\t\trandomIndex = Math.floor(Math.random() * currentIndex);\r\n\t\tcurrentIndex--;\r\n\r\n\t\t// And swap it with the current element.\r\n\t\t[array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];\r\n\t}\r\n\r\n\treturn array;\r\n};\r\n\r\nexport const findLast = <T>(\r\n\tarray: readonly T[],\r\n\tpredicate: (value: T, index: number, obj: readonly T[]) => unknown,\r\n): T => {\r\n\tconst filtred = array.filter(predicate);\r\n\tif (!filtred?.length) {\r\n\t\treturn null;\r\n\t}\r\n\tconst last = filtred[filtred.length - 1];\r\n\treturn last;\r\n};\r\n\r\nexport type Mutable<T> = {\r\n\t-readonly [P in keyof T]: T[P];\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/services/utils.ts"],"names":[],"mappings":";;;AAGA,gDAA4C;AAE5C,SAAS,cAAc,CAAI,KAAmB,EAAE,aAAqB;IACpE,MAAM,WAAW,GAAQ,CAAC,GAAG,KAAK,CAAC,CAAC;IACpC,MAAM,MAAM,GAAU,EAAE,CAAC;IACzB,OAAO,WAAW,CAAC,MAAM,EAAE;QAC1B,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC;KAClD;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAkBQ,wCAAc;AAhBvB,KAAK,UAAU,KAAK,CAAC,EAAE;IACtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC1D,CAAC;AAcwB,sBAAK;AAZvB,MAAM,eAAe,GAC3B,CAAI,YAAyC,EAAE,EAAE,CACjD,CAAC,KAAmB,EAAmC,EAAE;IACxD,OAAO,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC,CAAC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AA,2BAA2B,+BAGtC;AAGK,MAAM,YAAY,GAAG,CAAI,KAAU,EAAO,EAAE;IAClD,IAAI,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC;IAChC,IAAI,WAAW,GAAG,CAAC,CAAC;IAGpB,OAAO,YAAY,IAAI,CAAC,EAAE;QAEzB,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,YAAY,CAAC,CAAC;QACvD,YAAY,EAAE,CAAC;QAGf,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;KACtF;IAED,OAAO,KAAK,CAAC;AACd,CAAC,CAAC;AAfW,QAAA,YAAY,gBAevB;AAEK,MAAM,QAAQ,GAAG,CACvB,KAAmB,EACnB,SAAkE,EAC9D,EAAE;IACN,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACxC,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,CAAA,EAAE;QACrB,OAAO,IAAI,CAAC;KACZ;IACD,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACzC,OAAO,IAAI,CAAC;AACb,CAAC,CAAC;AAVW,QAAA,QAAQ,YAUnB","sourcesContent":["import { BoardTrinket } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { BoardSecret } from '../board-secret';\r\nimport { debugState } from '../debug-state';\r\n\r\nfunction partitionArray<T>(array: readonly T[], partitionSize: number): readonly T[][] {\r\n\tconst workingCopy: T[] = [...array];\r\n\tconst result: T[][] = [];\r\n\twhile (workingCopy.length) {\r\n\t\tresult.push(workingCopy.splice(0, partitionSize));\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nasync function sleep(ms) {\r\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\r\n}\r\n\r\nexport const groupByFunction =\r\n\t<T>(keyExtractor: (obj: T) => string | number) =>\r\n\t(array: readonly T[]): { [key: string]: readonly T[] } => {\r\n\t\treturn (array ?? []).reduce((objectsByKeyValue, obj) => {\r\n\t\t\tconst value = keyExtractor(obj);\r\n\t\t\tobjectsByKeyValue[value] = objectsByKeyValue[value] ?? [];\r\n\t\t\t// Using push instead of concat is thousands of times faster on big arrays\r\n\t\t\tobjectsByKeyValue[value].push(obj);\r\n\t\t\treturn objectsByKeyValue;\r\n\t\t}, {});\r\n\t};\r\n\r\nexport { partitionArray, sleep };\r\n\r\nexport function pickRandom<T>(array: readonly T[]): T;\r\nexport function pickRandom<T extends BoardEntity>(\r\n\tarray: readonly T[],\r\n\tsourceEntity: BoardEntity | BoardSecret | BoardTrinket,\r\n): T;\r\nexport function pickRandom<T>(array: readonly T[], sourceEntity?: BoardEntity | BoardSecret | BoardTrinket): T {\r\n\tif (!array?.length) {\r\n\t\treturn null;\r\n\t}\r\n\tif (\r\n\t\tsourceEntity &&\r\n\t\tdebugState.active &&\r\n\t\tarray.length > 0 &&\r\n\t\ttypeof array[0] === 'object' &&\r\n\t\tarray[0] != null &&\r\n\t\t'entityId' in array[0]\r\n\t) {\r\n\t\tconst forced = debugState.forcedRandomPicks.find((p) => debugState.isCorrectEntity(p.source, sourceEntity));\r\n\t\tif (forced) {\r\n\t\t\tconst match = (array as unknown as BoardEntity[]).find((c) => debugState.isCorrectEntity(forced.target, c));\r\n\t\t\t// Defer consumption when pick has chosenCardId - getRandomMagneticVolumizer will consume (e.g. Apexis Guardian)\r\n\t\t\tif (!forced.chosenCardId) {\r\n\t\t\t\tdebugState.forcedRandomPicks = debugState.forcedRandomPicks.filter((p) => p !== forced);\r\n\t\t\t}\r\n\t\t\tif (match) {\r\n\t\t\t\treturn match as T;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn array[Math.floor(Math.random() * array.length)];\r\n}\r\n\r\nexport const pickMultipleRandom = <T>(array: readonly T[], quantity: number): T[] => {\r\n\tconst picked: T[] = [];\r\n\tfor (let i = 0; i < quantity; i++) {\r\n\t\tconst target = array.filter((e) => !picked.includes(e));\r\n\t\tconst chosenEntity = pickRandom(target);\r\n\t\tif (!!chosenEntity) {\r\n\t\t\tpicked.push(chosenEntity);\r\n\t\t}\r\n\t}\r\n\treturn picked;\r\n};\r\n\r\nexport const pickRandomAlive = (board: BoardEntity[]): BoardEntity => {\r\n\tconst targetBoard = board.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tconst chosenEntity = pickRandom(targetBoard);\r\n\treturn chosenEntity;\r\n};\r\n\r\nexport const pickMultipleRandomAlive = (board: BoardEntity[], quantity: number): BoardEntity[] => {\r\n\tconst picked: BoardEntity[] = [];\r\n\tfor (let i = 0; i < quantity; i++) {\r\n\t\tconst targetBoard = board.filter((e) => e.health > 0 && !e.definitelyDead).filter((e) => !picked.includes(e));\r\n\t\tconst chosenEntity = pickRandom(targetBoard);\r\n\t\tif (!!chosenEntity) {\r\n\t\t\tpicked.push(chosenEntity);\r\n\t\t}\r\n\t}\r\n\treturn picked;\r\n};\r\n\r\nexport const pickRandomLowestHealth = (board: BoardEntity[]): BoardEntity => {\r\n\tconst targetBoard = board.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tconst lowestHealth = Math.min(...targetBoard.map((e) => e.health));\r\n\tconst entitiesWithLowestHealth = targetBoard.filter((e) => e.health === lowestHealth);\r\n\tconst chosenEntity = pickRandom(entitiesWithLowestHealth);\r\n\treturn chosenEntity;\r\n};\r\n\r\nexport const pickRandomLowestAttack = (board: BoardEntity[]): BoardEntity => {\r\n\tconst targetBoard = board.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tconst lowestAttack = Math.min(...targetBoard.map((e) => e.attack));\r\n\tconst entitiesWithLowestAttack = targetBoard.filter((e) => e.attack === lowestAttack);\r\n\tconst chosenEntity = pickRandom(entitiesWithLowestAttack);\r\n\treturn chosenEntity;\r\n};\r\n\r\nexport const pickRandomHighestAttack = (board: BoardEntity[]): BoardEntity => {\r\n\tconst targetBoard = board.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tconst highestAttack = Math.max(...targetBoard.map((e) => e.attack));\r\n\tconst entitiesWithHighestAttack = targetBoard.filter((e) => e.attack === highestAttack);\r\n\tconst chosenEntity = pickRandom(entitiesWithHighestAttack);\r\n\treturn chosenEntity;\r\n};\r\n\r\nexport const pickRandomHighestHealth = (board: BoardEntity[]): BoardEntity => {\r\n\tconst targetBoard = board.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tconst highestHealth = Math.max(...targetBoard.map((e) => e.health));\r\n\tconst entitiesWithHighestHealth = targetBoard.filter((e) => e.health === highestHealth);\r\n\tconst chosenEntity = pickRandom(entitiesWithHighestHealth);\r\n\treturn chosenEntity;\r\n};\r\n\r\nexport const encode = (input: string): string => {\r\n\t// return compressToEncodedURIComponent(input);\r\n\tconst buff = Buffer.from(input, 'utf-8');\r\n\tconst base64 = buff.toString('base64');\r\n\treturn base64;\r\n};\r\n\r\nexport const decode = (base64: string): string => {\r\n\tconst buff = Buffer.from(base64, 'base64');\r\n\tconst str = buff.toString('utf-8');\r\n\treturn str;\r\n};\r\n\r\nexport const pickMultipleRandomDifferent = <T>(list: T[], n: number): T[] => {\r\n\tconst shuffled = shuffleArray([...list]);\r\n\treturn shuffled.slice(0, n);\r\n};\r\n\r\n// https://stackoverflow.com/a/2450976/548701\r\nexport const shuffleArray = <T>(array: T[]): T[] => {\r\n\tlet currentIndex = array.length;\r\n\tlet randomIndex = 0;\r\n\r\n\t// While there remain elements to shuffle...\r\n\twhile (currentIndex != 0) {\r\n\t\t// Pick a remaining element...\r\n\t\trandomIndex = Math.floor(Math.random() * currentIndex);\r\n\t\tcurrentIndex--;\r\n\r\n\t\t// And swap it with the current element.\r\n\t\t[array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];\r\n\t}\r\n\r\n\treturn array;\r\n};\r\n\r\nexport const findLast = <T>(\r\n\tarray: readonly T[],\r\n\tpredicate: (value: T, index: number, obj: readonly T[]) => unknown,\r\n): T => {\r\n\tconst filtred = array.filter(predicate);\r\n\tif (!filtred?.length) {\r\n\t\treturn null;\r\n\t}\r\n\tconst last = filtred[filtred.length - 1];\r\n\treturn last;\r\n};\r\n\r\nexport type Mutable<T> = {\r\n\t-readonly [P in keyof T]: T[P];\r\n};\r\n"]}
|
|
@@ -156,6 +156,7 @@ const handleFrostwolfFervorForPlayer = (heroPower, playerBoard, playerEntity, op
|
|
|
156
156
|
const target = (0, utils_1.pickRandomHighestAttack)(playerBoard);
|
|
157
157
|
if (!!target) {
|
|
158
158
|
const copy = (0, utils_2.copyEntity)(target);
|
|
159
|
+
(0, add_minion_to_board_1.removeAurasFromSelf)(copy, playerBoard, playerEntity, gameState);
|
|
159
160
|
const indexFromRight = playerBoard.length - (playerBoard.indexOf(target) + 1);
|
|
160
161
|
const newMinions = (0, deathrattle_spawns_1.spawnEntities)(copy.cardId, 1, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState, playerEntity.friendly, false, false, false, copy);
|
|
161
162
|
const spawns = (0, spawns_1.performEntitySpawns)(newMinions, playerBoard, playerEntity, playerEntity, indexFromRight, opponentBoard, opponentEntity, gameState);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summon-when-space.js","sourceRoot":"","sources":["../../src/simulation/summon-when-space.ts"],"names":[],"mappings":";;;AAAA,iEAAoD;AAGpD,4EAAqF;AACrF,iFAA4F;AAC5F,6CAAgD;AAEhD,6CAAqF;AACrF,oCAA+E;AAC/E,+DAA4D;AAC5D,6DAAqD;AAErD,qCAA+C;AAExC,MAAM,sBAAsB,GAAG,CACrC,WAA0B,EAC1B,YAA6B,EAC7B,aAA4B,EAC5B,cAA+B,EAC/B,SAAwB,EACd,EAAE;IACZ,IAAI,8BAA8B,GAAG,KAAK,CAAC;IAC3C,IAAI,IAAI,CAAC,MAAM,EAAE,G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AA6B,EAC7B,aAA4B,EAC5B,cAA+B,EAC/B,SAAwB,EACxB,MAAc,EACd,cAAsB,EACtB,UAAmB,EACnB,SAAsB,IAAI,EACD,EAAE;IAC3B,IAAI,WAAW,CAAC,MAAM,IAAI,CAAC,EAAE;QAC5B,OAAO,IAAI,CAAC;KACZ;IACD,MAAM,SAAS,GAAG,IAAA,8BAAsB,EACvC,MAAM,EACN,YAAY,EACZ,WAAW,EACX,SAAS,CAAC,QAAQ,EAClB,YAAY,CAAC,QAAQ,EACrB,SAAS,CAAC,WAAW,CAAC,eAAe,EAAE,EACvC,KAAK,EACL,SAAS,CAAC,SAAS,EACnB,SAAS,CAAC,WAAW,EACrB,MAAM,EACN,IAAI,CACJ,CAAC;IAEF,MAAM,OAAO,GAAG,IAAA,4BAAmB,EAClC,CAAC,SAAS,CAAC,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,aAAa,EACb,cAAc,EACd,SAAS,EACT,UAAU,CACV,CAAC;IACF,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAAC,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC1F,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { Race } from '@firestone-hs/reference-data';\r\nimport { BgsHeroPower, BgsPlayerEntity, BoardTrinket } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { handleDiremuckPendingSummons } from '../cards/impl/minion/diremuck-forager';\r\nimport { handleAutomatonPortraitForPlayer } from '../cards/impl/trinket/automaton-portrait';\r\nimport { updateTaunt } from '../keywords/taunt';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { pickRandomHighestAttack, pickRandomHighestHealth } from '../services/utils';\r\nimport { buildSingleBoardEntity, copyEntity, hasCorrectTribe } from '../utils';\r\nimport { removeAurasFromSelf } from './add-minion-to-board';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { performEntitySpawns } from './spawns';\r\n\r\nexport const handleSummonsWhenSpace = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): boolean => {\r\n\tlet shouldRecomputeCurrentAttacker = false;\r\n\tif (Math.random() < 0.5) {\r\n\t\tshouldRecomputeCurrentAttacker =\r\n\t\t\thandleSummonsWhenSpaceForPlayer(\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t) || shouldRecomputeCurrentAttacker;\r\n\t\tshouldRecomputeCurrentAttacker =\r\n\t\t\thandleSummonsWhenSpaceForPlayer(\r\n\t\t\t\topponentEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t) || shouldRecomputeCurrentAttacker;\r\n\t} else {\r\n\t\tshouldRecomputeCurrentAttacker = handleSummonsWhenSpaceForPlayer(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tshouldRecomputeCurrentAttacker =\r\n\t\t\thandleSummonsWhenSpaceForPlayer(\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t) || shouldRecomputeCurrentAttacker;\r\n\t}\r\n\treturn shouldRecomputeCurrentAttacker;\r\n};\r\n\r\n// TODO: Twin Sky Lanterns wait for 2 spaces\r\nconst handleSummonsWhenSpaceForPlayer = (\r\n\ttargetEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): boolean => {\r\n\tlet shouldRecomputeCurrentAttacker = false;\r\n\tif (targetEntity.questRewards?.includes(CardIds.StableAmalgamation_BG28_Reward_518)) {\r\n\t\tshouldRecomputeCurrentAttacker =\r\n\t\t\thandleStableAmalgamationForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState) ||\r\n\t\t\tshouldRecomputeCurrentAttacker;\r\n\t}\r\n\tif (targetEntity.secrets?.some((s) => s.cardId === CardIds.BoonOfBeetles_BG28_603)) {\r\n\t\tshouldRecomputeCurrentAttacker =\r\n\t\t\thandleBoonOfBeetlesForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState) ||\r\n\t\t\tshouldRecomputeCurrentAttacker;\r\n\t}\r\n\tfor (const heroPower of targetEntity.heroPowers) {\r\n\t\tif (heroPower.cardId === CardIds.Ozumat_Tentacular && heroPower.ready) {\r\n\t\t\tshouldRecomputeCurrentAttacker =\r\n\t\t\t\thandleOzumatForPlayer(\r\n\t\t\t\t\theroPower,\r\n\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentEntity,\r\n\t\t\t\t\ttargetEntity.friendly,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t) || shouldRecomputeCurrentAttacker;\r\n\t\t} else if (\r\n\t\t\theroPower.cardId === CardIds.Drekthar_LeadTheFrostwolves &&\r\n\t\t\tgameState.currentTurn >= 7 &&\r\n\t\t\theroPower.ready &&\r\n\t\t\t!heroPower.activated\r\n\t\t) {\r\n\t\t\tshouldRecomputeCurrentAttacker =\r\n\t\t\t\thandleFrostwolfFervorForPlayer(\r\n\t\t\t\t\theroPower,\r\n\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentEntity,\r\n\t\t\t\t\ttargetEntity.friendly,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t) || shouldRecomputeCurrentAttacker;\r\n\t\t} else if (\r\n\t\t\theroPower.cardId === CardIds.VanndarStormpike_LeadTheStormpikes &&\r\n\t\t\tgameState.currentTurn >= 7 &&\r\n\t\t\theroPower.ready &&\r\n\t\t\t!heroPower.activated\r\n\t\t) {\r\n\t\t\tshouldRecomputeCurrentAttacker =\r\n\t\t\t\thandleStormpikeStrengthForPlayer(\r\n\t\t\t\t\theroPower,\r\n\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentEntity,\r\n\t\t\t\t\ttargetEntity.friendly,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t) || shouldRecomputeCurrentAttacker;\r\n\t\t} else if (\r\n\t\t\theroPower.cardId === CardIds.LockAndLoadToken_BG22_HERO_000p_Alt &&\r\n\t\t\t!heroPower.activated &&\r\n\t\t\theroPower.ready\r\n\t\t) {\r\n\t\t\tshouldRecomputeCurrentAttacker =\r\n\t\t\t\t!!handleLockAndLoadForPlayer(\r\n\t\t\t\t\theroPower,\r\n\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentEntity,\r\n\t\t\t\t\ttargetEntity.friendly,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t) || shouldRecomputeCurrentAttacker;\r\n\t\t} else if (\r\n\t\t\theroPower.cardId === CardIds.TeronGorefiend_RapidReanimation &&\r\n\t\t\t(heroPower.info as BoardEntity)?.cardId\r\n\t\t) {\r\n\t\t\tshouldRecomputeCurrentAttacker =\r\n\t\t\t\thandleRapidReanimationForPlayer(\r\n\t\t\t\t\theroPower,\r\n\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentEntity,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t) || shouldRecomputeCurrentAttacker;\r\n\t\t}\r\n\t}\r\n\ttargetEntity.trinkets\r\n\t\t.filter(\r\n\t\t\t(t) =>\r\n\t\t\t\tt.cardId === CardIds.TwinSkyLanterns_BG30_MagicItem_822 ||\r\n\t\t\t\tt.cardId === CardIds.TwinSkyLanterns_TwinSkyLanternsToken_BG30_MagicItem_822t2,\r\n\t\t)\r\n\t\t.forEach((t) => {\r\n\t\t\thandleTwinSkyLanternsForPlayer(t, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t});\r\n\ttargetEntity.trinkets\r\n\t\t.filter((t) => t.cardId === CardIds.BoomController_BG30_MagicItem_440)\r\n\t\t.forEach((t) => {\r\n\t\t\thandleBoomControllerForPlayer(t, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t});\r\n\ttargetEntity.trinkets\r\n\t\t.filter((t) => t.cardId === CardIds.AutomatonPortrait_BG30_MagicItem_303)\r\n\t\t.forEach((t) => {\r\n\t\t\thandleAutomatonPortraitForPlayer(t, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t});\r\n\tplayerBoard\r\n\t\t.filter(\r\n\t\t\t(e) => e.cardId === CardIds.SharptoothSnapper_BG32_201 || e.cardId === CardIds.SharptoothSnapper_BG32_201_G,\r\n\t\t)\r\n\t\t.forEach((e) => {\r\n\t\t\thandleSharptoothSnapperForPlayer(e, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t});\r\n\thandleDiremuckPendingSummons(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn shouldRecomputeCurrentAttacker;\r\n};\r\n\r\nexport const handleSharptoothSnapperForPlayer = (\r\n\tentity: BoardEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\twhile (playerBoard.length < 7 && entity.abiityChargesLeft > 0) {\r\n\t\tconst candidates = spawnEntities(\r\n\t\t\tCardIds.SharptoothSnapper_PiranhaToken_BG32_201t,\r\n\t\t\t1,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t\tplayerEntity.friendly,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t\tcandidates.forEach((t) => (t.attackImmediately = true));\r\n\t\tconst actualSpawns = performEntitySpawns(\r\n\t\t\tcandidates,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard.length - 1 - playerBoard.indexOf(entity),\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tentity.abiityChargesLeft--;\r\n\t}\r\n};\r\n\r\nconst handleBoomControllerForPlayer = (\r\n\ttrinket: BoardTrinket,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (playerBoard.length < 7 && trinket.scriptDataNum1 > 0) {\r\n\t\tconst candidate = gameState.sharedState.deaths\r\n\t\t\t.filter((d) => d.friendly === playerEntity.friendly)\r\n\t\t\t.filter((d) => hasCorrectTribe(d, playerEntity, Race.MECH, gameState.anomalies, gameState.allCards))[0];\r\n\t\tif (!!candidate) {\r\n\t\t\tconst spawn = copyEntity(candidate);\r\n\t\t\tremoveAurasFromSelf(spawn, playerBoard, playerEntity, gameState);\r\n\t\t\tconst initialIndexFromLeft = candidate.indexFromLeftAtTimeOfDeath;\r\n\t\t\tconst indexFromRight =\r\n\t\t\t\tinitialIndexFromLeft == null\r\n\t\t\t\t\t? 0\r\n\t\t\t\t\t: Math.min(playerBoard.length, Math.max(0, playerBoard.length - initialIndexFromLeft));\r\n\t\t\tconst target = spawnEntities(\r\n\t\t\t\tspawn.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\ttrue,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tspawn,\r\n\t\t\t);\r\n\t\t\t// FIXME: here it should try to match the position at which the original minions died\r\n\t\t\tconst actualSpawns = performEntitySpawns(\r\n\t\t\t\ttarget,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tactualSpawns.forEach((t) =>\r\n\t\t\t\tgameState.spectator.registerPowerTarget(playerEntity, t, playerBoard, playerEntity, opponentEntity),\r\n\t\t\t);\r\n\t\t\ttrinket.scriptDataNum1 = 0;\r\n\t\t\t// It summons an exact copy\r\n\t\t\t// actualSpawns.forEach((entity) => {\r\n\t\t\t// \tswitch (entity.cardId) {\r\n\t\t\t// \t\tcase CardIds.AstralAutomaton_BG_TTN_401:\r\n\t\t\t// \t\tcase CardIds.AstralAutomaton_BG_TTN_401_G:\r\n\t\t\t// \t\t\tconst overstatMult = entity.cardId === CardIds.AstralAutomaton_BG_TTN_401 ? 1 : 2;\r\n\t\t\t// \t\t\tentity.attack = Math.max(1, entity.attack - 2 * overstatMult);\r\n\t\t\t// \t\t\tentity.health = Math.max(0, entity.health - overstatMult);\r\n\t\t\t// \t\t\tbreak;\r\n\t\t\t// \t}\r\n\t\t\t// });\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleTwinSkyLanternsForPlayer = (\r\n\ttrinket: BoardTrinket,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst spawnNumber = trinket.scriptDataNum1 ?? 0;\r\n\tconst canTrigger = spawnNumber >= 1;\r\n\tif (playerBoard.length <= 7 - spawnNumber && trinket.rememberedMinions?.length && canTrigger) {\r\n\t\ttrinket.scriptDataNum1 = 0;\r\n\t\tconst spawn = copyEntity(trinket.rememberedMinions[0]);\r\n\t\tremoveAurasFromSelf(spawn, playerBoard, playerEntity, gameState);\r\n\t\tconst target = spawnEntities(\r\n\t\t\tspawn.cardId,\r\n\t\t\tspawnNumber,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t\tplayerEntity.friendly,\r\n\t\t\ttrue,\r\n\t\t\tfalse,\r\n\t\t\tfalse,\r\n\t\t\tspawn,\r\n\t\t);\r\n\t\tperformEntitySpawns(\r\n\t\t\ttarget,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerEntity,\r\n\t\t\t0,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\ttarget.forEach((t) =>\r\n\t\t\tgameState.spectator.registerPowerTarget(playerEntity, t, playerBoard, playerEntity, opponentEntity),\r\n\t\t);\r\n\t}\r\n};\r\n\r\nconst handleOzumatForPlayer = (\r\n\theroPower: BgsHeroPower,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tif (playerBoard.length < 7 && heroPower.activated === false) {\r\n\t\tconst tentacularSize = +heroPower.info;\r\n\t\tconst tentacular = spawnEntities(\r\n\t\t\tCardIds.Tentacular_OzumatsTentacleToken_BG23_HERO_201pt,\r\n\t\t\t1,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t\tfriendly,\r\n\t\t\ttrue,\r\n\t\t\tfalse,\r\n\t\t\tfalse,\r\n\t\t);\r\n\t\ttentacular[0].attack = tentacularSize;\r\n\t\ttentacular[0].health = tentacularSize;\r\n\t\ttentacular[0].maxHealth = tentacularSize;\r\n\t\ttentacular[0].maxAttack = tentacularSize;\r\n\t\tconst indexFromRight = 0;\r\n\t\tperformEntitySpawns(\r\n\t\t\ttentacular,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerEntity,\r\n\t\t\tindexFromRight,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tgameState.spectator.registerPowerTarget(playerEntity, tentacular[0], playerBoard, playerEntity, opponentEntity);\r\n\t\theroPower.activated = true;\r\n\t}\r\n\treturn true;\r\n};\r\n\r\nconst handleFrostwolfFervorForPlayer = (\r\n\theroPower: BgsHeroPower,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tif (playerBoard.length < 7) {\r\n\t\theroPower.activated = true;\r\n\t\tconst target = pickRandomHighestAttack(playerBoard);\r\n\t\tif (!!target) {\r\n\t\t\tconst copy = copyEntity(target);\r\n\t\t\tconst indexFromRight = playerBoard.length - (playerBoard.indexOf(target) + 1);\r\n\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\tcopy.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tcopy,\r\n\t\t\t);\r\n\t\t\tconst spawns = performEntitySpawns(\r\n\t\t\t\tnewMinions,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(playerEntity, spawns[0], playerBoard, playerEntity, opponentEntity);\r\n\t\t\t// 33.6.2 https://replays.firestoneapp.com/?reviewId=35bc0472-b915-4fa3-8d29-8a8d4d806745&turn=15&action=2\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n\treturn false;\r\n};\r\n\r\nconst handleLockAndLoadForPlayer = (\r\n\theroPower: BgsHeroPower,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tif (playerBoard.length < 7) {\r\n\t\tconst summoned = heroPower.info as BoardEntity;\r\n\t\theroPower.activated = true;\r\n\t\tif (!!summoned?.cardId) {\r\n\t\t\tconst copy = copyEntity(summoned);\r\n\t\t\tcopy.attackImmediately = true;\r\n\t\t\tconst indexFromRight = 0;\r\n\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\tcopy.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tcopy,\r\n\t\t\t);\r\n\t\t\tconst spawns = performEntitySpawns(\r\n\t\t\t\tnewMinions,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(playerEntity, spawns[0], playerBoard, playerEntity, opponentEntity);\r\n\t\t\t// Do the attack right now, so that we can recompute the first attacker once the attack resolves\r\n\t\t\t// Attack is actually performed with the \"performEntitySpawns\" function\r\n\t\t\t// simulateAttack(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t\t// 33.6 https://replays.firestoneapp.com/?reviewId=441da83c-3e40-4630-b98f-caf1932e5be7&turn=11&action=0\r\n\t\t\t// The minion needs to go back to the normal attacking order\r\n\t\t\t// 34.0 https://replays.firestoneapp.com/?reviewId=6902bbda-cd04-4e2d-9643-3c87534e0986&turn=7&action=3\r\n\t\t\t// Can be null if it dies after being spawned\r\n\t\t\tif (spawns[0]) {\r\n\t\t\t\tspawns[0].hasAttacked = undefined;\r\n\t\t\t}\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleStormpikeStrengthForPlayer = (\r\n\theroPower: BgsHeroPower,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tif (playerBoard.length < 7) {\r\n\t\theroPower.activated = true;\r\n\t\tconst target = pickRandomHighestHealth(playerBoard);\r\n\t\tif (!!target) {\r\n\t\t\tconst copy = copyEntity(target);\r\n\t\t\tconst indexFromRight = playerBoard.length - (playerBoard.indexOf(target) + 1);\r\n\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\tcopy.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tcopy,\r\n\t\t\t);\r\n\t\t\tconst spawns = performEntitySpawns(\r\n\t\t\t\tnewMinions,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(playerEntity, spawns[0], playerBoard, playerEntity, opponentEntity);\r\n\t\t\t// 33.6.2 https://replays.firestoneapp.com/?reviewId=35bc0472-b915-4fa3-8d29-8a8d4d806745&turn=15&action=2\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n\treturn false;\r\n};\r\n\r\nconst handleBoonOfBeetlesForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst secretEntity = playerEntity.secrets.find((entity) => entity.cardId === CardIds.BoonOfBeetles_BG28_603);\r\n\tif (secretEntity && secretEntity.triggersLeft > 0) {\r\n\t\twhile (secretEntity.triggersLeft > 0) {\r\n\t\t\tconst hasSummoned = handleSummon(\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tCardIds.BoonOfBeetles_BeetleToken_BG28_603t,\r\n\t\t\t\t0,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t\tif (hasSummoned) {\r\n\t\t\t\thasSummoned.forEach((entity) => {\r\n\t\t\t\t\tupdateTaunt(entity, true, playerBoard, playerEntity, opponentEntity, gameState);\r\n\t\t\t\t});\r\n\t\t\t\tsecretEntity.triggersLeft--;\r\n\t\t\t} else {\r\n\t\t\t\t// No room to summon, we stop here\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn false;\r\n};\r\nconst handleStableAmalgamationForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst rewardEntity = playerEntity.questRewardEntities.find(\r\n\t\t(entity) => entity.cardId === CardIds.StableAmalgamation_BG28_Reward_518,\r\n\t);\r\n\tif (rewardEntity && rewardEntity.scriptDataNum1 > 0) {\r\n\t\twhile (rewardEntity.scriptDataNum1 > 0) {\r\n\t\t\tconst hasSummoned = handleSummon(\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tCardIds.StableAmalgamation_TotallyNormalHorseToken_BG28_Reward_518t,\r\n\t\t\t\t0,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t\tif (hasSummoned) {\r\n\t\t\t\trewardEntity.scriptDataNum1--;\r\n\t\t\t} else {\r\n\t\t\t\t// No room to summon, we stop here\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn false;\r\n};\r\n\r\nconst handleRapidReanimationForPlayer = (\r\n\theroPower: BgsHeroPower,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\t// 2026-01-08: When the sacrificed minion is the far-right one, we want to resurrect it there\r\n\t// https://replays.firestoneapp.com/?reviewId=4e5d8239-2d8d-41db-9b8f-35b5179c28fb&turn=7&action=4\r\n\tconst indexFromRight = heroPower.info2;\r\n\tconst rapidReanimationMinion = heroPower.info as BoardEntity;\r\n\tconst hasSummoned = handleSummon(\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tgameState,\r\n\t\trapidReanimationMinion.cardId,\r\n\t\tindexFromRight,\r\n\t\ttrue, // (Goldrinn gets buffed, so it seems we reapply auras? This is a mess tbh)\r\n\t\trapidReanimationMinion,\r\n\t);\r\n\tif (hasSummoned) {\r\n\t\theroPower.info = null;\r\n\t\t// Hard-coding a correction for Ancestral Automaton\r\n\t\t// Shold not be necessary if we reapply auras\r\n\t\t// hasSummoned.forEach((entity) => {\r\n\t\t// \tswitch (entity.cardId) {\r\n\t\t// \t\tcase CardIds.AstralAutomaton_BG_TTN_401:\r\n\t\t// \t\tcase CardIds.AstralAutomaton_BG_TTN_401_G:\r\n\t\t// \t\t\tconst overstatMult = entity.cardId === CardIds.AstralAutomaton_BG_TTN_401 ? 1 : 2;\r\n\t\t// \t\t\tentity.attack = Math.max(1, entity.attack + 2 * overstatMult);\r\n\t\t// \t\t\tentity.health = Math.max(0, entity.health + 2 * overstatMult);\r\n\t\t// \t\t\tbreak;\r\n\t\t// \t\tcase CardIds.EternalKnight_BG25_008:\r\n\t\t// \t\tcase CardIds.EternalKnight_BG25_008_G:\r\n\t\t// \t\t\tconst knightMult = entity.cardId === CardIds.EternalKnight_BG25_008 ? 1 : 2;\r\n\t\t// \t\t\tentity.attack = Math.max(1, entity.attack + 1 * knightMult);\r\n\t\t// \t\t\tentity.health = Math.max(0, entity.health + 1 * knightMult);\r\n\t\t// \t\t\tbreak;\r\n\t\t// \t}\r\n\t\t// });\r\n\t}\r\n\treturn false;\r\n};\r\n\r\nconst handleSummon = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tcardId: string,\r\n\tindexFromRight: number,\r\n\tapplyAuras: boolean,\r\n\tminion: BoardEntity = null,\r\n): readonly BoardEntity[] => {\r\n\tif (playerBoard.length >= 7) {\r\n\t\treturn null;\r\n\t}\r\n\tconst newMinion = buildSingleBoardEntity(\r\n\t\tcardId,\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\tgameState.allCards,\r\n\t\tplayerEntity.friendly,\r\n\t\tgameState.sharedState.currentEntityId++,\r\n\t\tfalse,\r\n\t\tgameState.cardsData,\r\n\t\tgameState.sharedState,\r\n\t\tminion,\r\n\t\tnull,\r\n\t);\r\n\t// Don't reapply auras in this particular case? See https://x.com/ZerotoHeroes_HS/status/1737422727118487808?s=20\r\n\tconst spawned = performEntitySpawns(\r\n\t\t[newMinion],\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\tplayerEntity,\r\n\t\tindexFromRight,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tgameState,\r\n\t\tapplyAuras,\r\n\t);\r\n\tgameState.spectator.registerPowerTarget(playerEntity, newMinion, playerBoard, null, null);\r\n\treturn spawned;\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"summon-when-space.js","sourceRoot":"","sources":["../../src/simulation/summon-when-space.ts"],"names":[],"mappings":";;;AAAA,iEAAoD;AAGpD,4EAAqF;AACrF,iFAA4F;AAC5F,6CAAgD;AAEhD,6CAAqF;AACrF,oCAA+E;AAC/E,+DAA4D;AAC5D,6DAAqD;AAErD,qCAA+C;AAExC,MAAM,sBAAsB,GAAG,CACrC,WAA0B,EAC1B,YAA6B,EAC7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C7B,cAAc,EACd,IAAI,EACJ,sBAAsB,CACtB,CAAC;IACF,IAAI,WAAW,EAAE;QAChB,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC;KAmBtB;IACD,OAAO,KAAK,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CACpB,WAA0B,EAC1B,YAA6B,EAC7B,aAA4B,EAC5B,cAA+B,EAC/B,SAAwB,EACxB,MAAc,EACd,cAAsB,EACtB,UAAmB,EACnB,SAAsB,IAAI,EACD,EAAE;IAC3B,IAAI,WAAW,CAAC,MAAM,IAAI,CAAC,EAAE;QAC5B,OAAO,IAAI,CAAC;KACZ;IACD,MAAM,SAAS,GAAG,IAAA,8BAAsB,EACvC,MAAM,EACN,YAAY,EACZ,WAAW,EACX,SAAS,CAAC,QAAQ,EAClB,YAAY,CAAC,QAAQ,EACrB,SAAS,CAAC,WAAW,CAAC,eAAe,EAAE,EACvC,KAAK,EACL,SAAS,CAAC,SAAS,EACnB,SAAS,CAAC,WAAW,EACrB,MAAM,EACN,IAAI,CACJ,CAAC;IAEF,MAAM,OAAO,GAAG,IAAA,4BAAmB,EAClC,CAAC,SAAS,CAAC,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,aAAa,EACb,cAAc,EACd,SAAS,EACT,UAAU,CACV,CAAC;IACF,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAAC,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC1F,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { Race } from '@firestone-hs/reference-data';\r\nimport { BgsHeroPower, BgsPlayerEntity, BoardTrinket } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { handleDiremuckPendingSummons } from '../cards/impl/minion/diremuck-forager';\r\nimport { handleAutomatonPortraitForPlayer } from '../cards/impl/trinket/automaton-portrait';\r\nimport { updateTaunt } from '../keywords/taunt';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { pickRandomHighestAttack, pickRandomHighestHealth } from '../services/utils';\r\nimport { buildSingleBoardEntity, copyEntity, hasCorrectTribe } from '../utils';\r\nimport { removeAurasFromSelf } from './add-minion-to-board';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { performEntitySpawns } from './spawns';\r\n\r\nexport const handleSummonsWhenSpace = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): boolean => {\r\n\tlet shouldRecomputeCurrentAttacker = false;\r\n\tif (Math.random() < 0.5) {\r\n\t\tshouldRecomputeCurrentAttacker =\r\n\t\t\thandleSummonsWhenSpaceForPlayer(\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t) || shouldRecomputeCurrentAttacker;\r\n\t\tshouldRecomputeCurrentAttacker =\r\n\t\t\thandleSummonsWhenSpaceForPlayer(\r\n\t\t\t\topponentEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t) || shouldRecomputeCurrentAttacker;\r\n\t} else {\r\n\t\tshouldRecomputeCurrentAttacker = handleSummonsWhenSpaceForPlayer(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tshouldRecomputeCurrentAttacker =\r\n\t\t\thandleSummonsWhenSpaceForPlayer(\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t) || shouldRecomputeCurrentAttacker;\r\n\t}\r\n\treturn shouldRecomputeCurrentAttacker;\r\n};\r\n\r\n// TODO: Twin Sky Lanterns wait for 2 spaces\r\nconst handleSummonsWhenSpaceForPlayer = (\r\n\ttargetEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): boolean => {\r\n\tlet shouldRecomputeCurrentAttacker = false;\r\n\tif (targetEntity.questRewards?.includes(CardIds.StableAmalgamation_BG28_Reward_518)) {\r\n\t\tshouldRecomputeCurrentAttacker =\r\n\t\t\thandleStableAmalgamationForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState) ||\r\n\t\t\tshouldRecomputeCurrentAttacker;\r\n\t}\r\n\tif (targetEntity.secrets?.some((s) => s.cardId === CardIds.BoonOfBeetles_BG28_603)) {\r\n\t\tshouldRecomputeCurrentAttacker =\r\n\t\t\thandleBoonOfBeetlesForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState) ||\r\n\t\t\tshouldRecomputeCurrentAttacker;\r\n\t}\r\n\tfor (const heroPower of targetEntity.heroPowers) {\r\n\t\tif (heroPower.cardId === CardIds.Ozumat_Tentacular && heroPower.ready) {\r\n\t\t\tshouldRecomputeCurrentAttacker =\r\n\t\t\t\thandleOzumatForPlayer(\r\n\t\t\t\t\theroPower,\r\n\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentEntity,\r\n\t\t\t\t\ttargetEntity.friendly,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t) || shouldRecomputeCurrentAttacker;\r\n\t\t} else if (\r\n\t\t\theroPower.cardId === CardIds.Drekthar_LeadTheFrostwolves &&\r\n\t\t\tgameState.currentTurn >= 7 &&\r\n\t\t\theroPower.ready &&\r\n\t\t\t!heroPower.activated\r\n\t\t) {\r\n\t\t\tshouldRecomputeCurrentAttacker =\r\n\t\t\t\thandleFrostwolfFervorForPlayer(\r\n\t\t\t\t\theroPower,\r\n\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentEntity,\r\n\t\t\t\t\ttargetEntity.friendly,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t) || shouldRecomputeCurrentAttacker;\r\n\t\t} else if (\r\n\t\t\theroPower.cardId === CardIds.VanndarStormpike_LeadTheStormpikes &&\r\n\t\t\tgameState.currentTurn >= 7 &&\r\n\t\t\theroPower.ready &&\r\n\t\t\t!heroPower.activated\r\n\t\t) {\r\n\t\t\tshouldRecomputeCurrentAttacker =\r\n\t\t\t\thandleStormpikeStrengthForPlayer(\r\n\t\t\t\t\theroPower,\r\n\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentEntity,\r\n\t\t\t\t\ttargetEntity.friendly,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t) || shouldRecomputeCurrentAttacker;\r\n\t\t} else if (\r\n\t\t\theroPower.cardId === CardIds.LockAndLoadToken_BG22_HERO_000p_Alt &&\r\n\t\t\t!heroPower.activated &&\r\n\t\t\theroPower.ready\r\n\t\t) {\r\n\t\t\tshouldRecomputeCurrentAttacker =\r\n\t\t\t\t!!handleLockAndLoadForPlayer(\r\n\t\t\t\t\theroPower,\r\n\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentEntity,\r\n\t\t\t\t\ttargetEntity.friendly,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t) || shouldRecomputeCurrentAttacker;\r\n\t\t} else if (\r\n\t\t\theroPower.cardId === CardIds.TeronGorefiend_RapidReanimation &&\r\n\t\t\t(heroPower.info as BoardEntity)?.cardId\r\n\t\t) {\r\n\t\t\tshouldRecomputeCurrentAttacker =\r\n\t\t\t\thandleRapidReanimationForPlayer(\r\n\t\t\t\t\theroPower,\r\n\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentEntity,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t) || shouldRecomputeCurrentAttacker;\r\n\t\t}\r\n\t}\r\n\ttargetEntity.trinkets\r\n\t\t.filter(\r\n\t\t\t(t) =>\r\n\t\t\t\tt.cardId === CardIds.TwinSkyLanterns_BG30_MagicItem_822 ||\r\n\t\t\t\tt.cardId === CardIds.TwinSkyLanterns_TwinSkyLanternsToken_BG30_MagicItem_822t2,\r\n\t\t)\r\n\t\t.forEach((t) => {\r\n\t\t\thandleTwinSkyLanternsForPlayer(t, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t});\r\n\ttargetEntity.trinkets\r\n\t\t.filter((t) => t.cardId === CardIds.BoomController_BG30_MagicItem_440)\r\n\t\t.forEach((t) => {\r\n\t\t\thandleBoomControllerForPlayer(t, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t});\r\n\ttargetEntity.trinkets\r\n\t\t.filter((t) => t.cardId === CardIds.AutomatonPortrait_BG30_MagicItem_303)\r\n\t\t.forEach((t) => {\r\n\t\t\thandleAutomatonPortraitForPlayer(t, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t});\r\n\tplayerBoard\r\n\t\t.filter(\r\n\t\t\t(e) => e.cardId === CardIds.SharptoothSnapper_BG32_201 || e.cardId === CardIds.SharptoothSnapper_BG32_201_G,\r\n\t\t)\r\n\t\t.forEach((e) => {\r\n\t\t\thandleSharptoothSnapperForPlayer(e, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t});\r\n\thandleDiremuckPendingSummons(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\treturn shouldRecomputeCurrentAttacker;\r\n};\r\n\r\nexport const handleSharptoothSnapperForPlayer = (\r\n\tentity: BoardEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\twhile (playerBoard.length < 7 && entity.abiityChargesLeft > 0) {\r\n\t\tconst candidates = spawnEntities(\r\n\t\t\tCardIds.SharptoothSnapper_PiranhaToken_BG32_201t,\r\n\t\t\t1,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t\tplayerEntity.friendly,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t\tcandidates.forEach((t) => (t.attackImmediately = true));\r\n\t\tconst actualSpawns = performEntitySpawns(\r\n\t\t\tcandidates,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard.length - 1 - playerBoard.indexOf(entity),\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tentity.abiityChargesLeft--;\r\n\t}\r\n};\r\n\r\nconst handleBoomControllerForPlayer = (\r\n\ttrinket: BoardTrinket,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (playerBoard.length < 7 && trinket.scriptDataNum1 > 0) {\r\n\t\tconst candidate = gameState.sharedState.deaths\r\n\t\t\t.filter((d) => d.friendly === playerEntity.friendly)\r\n\t\t\t.filter((d) => hasCorrectTribe(d, playerEntity, Race.MECH, gameState.anomalies, gameState.allCards))[0];\r\n\t\tif (!!candidate) {\r\n\t\t\tconst spawn = copyEntity(candidate);\r\n\t\t\tremoveAurasFromSelf(spawn, playerBoard, playerEntity, gameState);\r\n\t\t\tconst initialIndexFromLeft = candidate.indexFromLeftAtTimeOfDeath;\r\n\t\t\tconst indexFromRight =\r\n\t\t\t\tinitialIndexFromLeft == null\r\n\t\t\t\t\t? 0\r\n\t\t\t\t\t: Math.min(playerBoard.length, Math.max(0, playerBoard.length - initialIndexFromLeft));\r\n\t\t\tconst target = spawnEntities(\r\n\t\t\t\tspawn.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\ttrue,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tspawn,\r\n\t\t\t);\r\n\t\t\t// FIXME: here it should try to match the position at which the original minions died\r\n\t\t\tconst actualSpawns = performEntitySpawns(\r\n\t\t\t\ttarget,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tactualSpawns.forEach((t) =>\r\n\t\t\t\tgameState.spectator.registerPowerTarget(playerEntity, t, playerBoard, playerEntity, opponentEntity),\r\n\t\t\t);\r\n\t\t\ttrinket.scriptDataNum1 = 0;\r\n\t\t\t// It summons an exact copy\r\n\t\t\t// actualSpawns.forEach((entity) => {\r\n\t\t\t// \tswitch (entity.cardId) {\r\n\t\t\t// \t\tcase CardIds.AstralAutomaton_BG_TTN_401:\r\n\t\t\t// \t\tcase CardIds.AstralAutomaton_BG_TTN_401_G:\r\n\t\t\t// \t\t\tconst overstatMult = entity.cardId === CardIds.AstralAutomaton_BG_TTN_401 ? 1 : 2;\r\n\t\t\t// \t\t\tentity.attack = Math.max(1, entity.attack - 2 * overstatMult);\r\n\t\t\t// \t\t\tentity.health = Math.max(0, entity.health - overstatMult);\r\n\t\t\t// \t\t\tbreak;\r\n\t\t\t// \t}\r\n\t\t\t// });\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleTwinSkyLanternsForPlayer = (\r\n\ttrinket: BoardTrinket,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst spawnNumber = trinket.scriptDataNum1 ?? 0;\r\n\tconst canTrigger = spawnNumber >= 1;\r\n\tif (playerBoard.length <= 7 - spawnNumber && trinket.rememberedMinions?.length && canTrigger) {\r\n\t\ttrinket.scriptDataNum1 = 0;\r\n\t\tconst spawn = copyEntity(trinket.rememberedMinions[0]);\r\n\t\tremoveAurasFromSelf(spawn, playerBoard, playerEntity, gameState);\r\n\t\tconst target = spawnEntities(\r\n\t\t\tspawn.cardId,\r\n\t\t\tspawnNumber,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t\tplayerEntity.friendly,\r\n\t\t\ttrue,\r\n\t\t\tfalse,\r\n\t\t\tfalse,\r\n\t\t\tspawn,\r\n\t\t);\r\n\t\tperformEntitySpawns(\r\n\t\t\ttarget,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerEntity,\r\n\t\t\t0,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\ttarget.forEach((t) =>\r\n\t\t\tgameState.spectator.registerPowerTarget(playerEntity, t, playerBoard, playerEntity, opponentEntity),\r\n\t\t);\r\n\t}\r\n};\r\n\r\nconst handleOzumatForPlayer = (\r\n\theroPower: BgsHeroPower,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tif (playerBoard.length < 7 && heroPower.activated === false) {\r\n\t\tconst tentacularSize = +heroPower.info;\r\n\t\tconst tentacular = spawnEntities(\r\n\t\t\tCardIds.Tentacular_OzumatsTentacleToken_BG23_HERO_201pt,\r\n\t\t\t1,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t\tfriendly,\r\n\t\t\ttrue,\r\n\t\t\tfalse,\r\n\t\t\tfalse,\r\n\t\t);\r\n\t\ttentacular[0].attack = tentacularSize;\r\n\t\ttentacular[0].health = tentacularSize;\r\n\t\ttentacular[0].maxHealth = tentacularSize;\r\n\t\ttentacular[0].maxAttack = tentacularSize;\r\n\t\tconst indexFromRight = 0;\r\n\t\tperformEntitySpawns(\r\n\t\t\ttentacular,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerEntity,\r\n\t\t\tindexFromRight,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t\tgameState.spectator.registerPowerTarget(playerEntity, tentacular[0], playerBoard, playerEntity, opponentEntity);\r\n\t\theroPower.activated = true;\r\n\t}\r\n\treturn true;\r\n};\r\n\r\nconst handleFrostwolfFervorForPlayer = (\r\n\theroPower: BgsHeroPower,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tif (playerBoard.length < 7) {\r\n\t\theroPower.activated = true;\r\n\t\tconst target = pickRandomHighestAttack(playerBoard);\r\n\t\tif (!!target) {\r\n\t\t\tconst copy = copyEntity(target);\r\n\t\t\tremoveAurasFromSelf(copy, playerBoard, playerEntity, gameState);\r\n\t\t\tconst indexFromRight = playerBoard.length - (playerBoard.indexOf(target) + 1);\r\n\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\tcopy.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tcopy,\r\n\t\t\t);\r\n\t\t\tconst spawns = performEntitySpawns(\r\n\t\t\t\tnewMinions,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(playerEntity, spawns[0], playerBoard, playerEntity, opponentEntity);\r\n\t\t\t// 33.6.2 https://replays.firestoneapp.com/?reviewId=35bc0472-b915-4fa3-8d29-8a8d4d806745&turn=15&action=2\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n\treturn false;\r\n};\r\n\r\nconst handleLockAndLoadForPlayer = (\r\n\theroPower: BgsHeroPower,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tif (playerBoard.length < 7) {\r\n\t\tconst summoned = heroPower.info as BoardEntity;\r\n\t\theroPower.activated = true;\r\n\t\tif (!!summoned?.cardId) {\r\n\t\t\tconst copy = copyEntity(summoned);\r\n\t\t\tcopy.attackImmediately = true;\r\n\t\t\tconst indexFromRight = 0;\r\n\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\tcopy.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tcopy,\r\n\t\t\t);\r\n\t\t\tconst spawns = performEntitySpawns(\r\n\t\t\t\tnewMinions,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(playerEntity, spawns[0], playerBoard, playerEntity, opponentEntity);\r\n\t\t\t// Do the attack right now, so that we can recompute the first attacker once the attack resolves\r\n\t\t\t// Attack is actually performed with the \"performEntitySpawns\" function\r\n\t\t\t// simulateAttack(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\t\t// 33.6 https://replays.firestoneapp.com/?reviewId=441da83c-3e40-4630-b98f-caf1932e5be7&turn=11&action=0\r\n\t\t\t// The minion needs to go back to the normal attacking order\r\n\t\t\t// 34.0 https://replays.firestoneapp.com/?reviewId=6902bbda-cd04-4e2d-9643-3c87534e0986&turn=7&action=3\r\n\t\t\t// Can be null if it dies after being spawned\r\n\t\t\tif (spawns[0]) {\r\n\t\t\t\tspawns[0].hasAttacked = undefined;\r\n\t\t\t}\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleStormpikeStrengthForPlayer = (\r\n\theroPower: BgsHeroPower,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tfriendly: boolean,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tif (playerBoard.length < 7) {\r\n\t\theroPower.activated = true;\r\n\t\tconst target = pickRandomHighestHealth(playerBoard);\r\n\t\tif (!!target) {\r\n\t\t\tconst copy = copyEntity(target);\r\n\t\t\tconst indexFromRight = playerBoard.length - (playerBoard.indexOf(target) + 1);\r\n\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\tcopy.cardId,\r\n\t\t\t\t1,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tplayerEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tfalse,\r\n\t\t\t\tcopy,\r\n\t\t\t);\r\n\t\t\tconst spawns = performEntitySpawns(\r\n\t\t\t\tnewMinions,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(playerEntity, spawns[0], playerBoard, playerEntity, opponentEntity);\r\n\t\t\t// 33.6.2 https://replays.firestoneapp.com/?reviewId=35bc0472-b915-4fa3-8d29-8a8d4d806745&turn=15&action=2\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n\treturn false;\r\n};\r\n\r\nconst handleBoonOfBeetlesForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst secretEntity = playerEntity.secrets.find((entity) => entity.cardId === CardIds.BoonOfBeetles_BG28_603);\r\n\tif (secretEntity && secretEntity.triggersLeft > 0) {\r\n\t\twhile (secretEntity.triggersLeft > 0) {\r\n\t\t\tconst hasSummoned = handleSummon(\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tCardIds.BoonOfBeetles_BeetleToken_BG28_603t,\r\n\t\t\t\t0,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t\tif (hasSummoned) {\r\n\t\t\t\thasSummoned.forEach((entity) => {\r\n\t\t\t\t\tupdateTaunt(entity, true, playerBoard, playerEntity, opponentEntity, gameState);\r\n\t\t\t\t});\r\n\t\t\t\tsecretEntity.triggersLeft--;\r\n\t\t\t} else {\r\n\t\t\t\t// No room to summon, we stop here\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn false;\r\n};\r\nconst handleStableAmalgamationForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\tconst rewardEntity = playerEntity.questRewardEntities.find(\r\n\t\t(entity) => entity.cardId === CardIds.StableAmalgamation_BG28_Reward_518,\r\n\t);\r\n\tif (rewardEntity && rewardEntity.scriptDataNum1 > 0) {\r\n\t\twhile (rewardEntity.scriptDataNum1 > 0) {\r\n\t\t\tconst hasSummoned = handleSummon(\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tgameState,\r\n\t\t\t\tCardIds.StableAmalgamation_TotallyNormalHorseToken_BG28_Reward_518t,\r\n\t\t\t\t0,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t\tif (hasSummoned) {\r\n\t\t\t\trewardEntity.scriptDataNum1--;\r\n\t\t\t} else {\r\n\t\t\t\t// No room to summon, we stop here\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn false;\r\n};\r\n\r\nconst handleRapidReanimationForPlayer = (\r\n\theroPower: BgsHeroPower,\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\t// 2026-01-08: When the sacrificed minion is the far-right one, we want to resurrect it there\r\n\t// https://replays.firestoneapp.com/?reviewId=4e5d8239-2d8d-41db-9b8f-35b5179c28fb&turn=7&action=4\r\n\tconst indexFromRight = heroPower.info2;\r\n\tconst rapidReanimationMinion = heroPower.info as BoardEntity;\r\n\tconst hasSummoned = handleSummon(\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tgameState,\r\n\t\trapidReanimationMinion.cardId,\r\n\t\tindexFromRight,\r\n\t\ttrue, // (Goldrinn gets buffed, so it seems we reapply auras? This is a mess tbh)\r\n\t\trapidReanimationMinion,\r\n\t);\r\n\tif (hasSummoned) {\r\n\t\theroPower.info = null;\r\n\t\t// Hard-coding a correction for Ancestral Automaton\r\n\t\t// Shold not be necessary if we reapply auras\r\n\t\t// hasSummoned.forEach((entity) => {\r\n\t\t// \tswitch (entity.cardId) {\r\n\t\t// \t\tcase CardIds.AstralAutomaton_BG_TTN_401:\r\n\t\t// \t\tcase CardIds.AstralAutomaton_BG_TTN_401_G:\r\n\t\t// \t\t\tconst overstatMult = entity.cardId === CardIds.AstralAutomaton_BG_TTN_401 ? 1 : 2;\r\n\t\t// \t\t\tentity.attack = Math.max(1, entity.attack + 2 * overstatMult);\r\n\t\t// \t\t\tentity.health = Math.max(0, entity.health + 2 * overstatMult);\r\n\t\t// \t\t\tbreak;\r\n\t\t// \t\tcase CardIds.EternalKnight_BG25_008:\r\n\t\t// \t\tcase CardIds.EternalKnight_BG25_008_G:\r\n\t\t// \t\t\tconst knightMult = entity.cardId === CardIds.EternalKnight_BG25_008 ? 1 : 2;\r\n\t\t// \t\t\tentity.attack = Math.max(1, entity.attack + 1 * knightMult);\r\n\t\t// \t\t\tentity.health = Math.max(0, entity.health + 1 * knightMult);\r\n\t\t// \t\t\tbreak;\r\n\t\t// \t}\r\n\t\t// });\r\n\t}\r\n\treturn false;\r\n};\r\n\r\nconst handleSummon = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n\tcardId: string,\r\n\tindexFromRight: number,\r\n\tapplyAuras: boolean,\r\n\tminion: BoardEntity = null,\r\n): readonly BoardEntity[] => {\r\n\tif (playerBoard.length >= 7) {\r\n\t\treturn null;\r\n\t}\r\n\tconst newMinion = buildSingleBoardEntity(\r\n\t\tcardId,\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\tgameState.allCards,\r\n\t\tplayerEntity.friendly,\r\n\t\tgameState.sharedState.currentEntityId++,\r\n\t\tfalse,\r\n\t\tgameState.cardsData,\r\n\t\tgameState.sharedState,\r\n\t\tminion,\r\n\t\tnull,\r\n\t);\r\n\t// Don't reapply auras in this particular case? See https://x.com/ZerotoHeroes_HS/status/1737422727118487808?s=20\r\n\tconst spawned = performEntitySpawns(\r\n\t\t[newMinion],\r\n\t\tplayerBoard,\r\n\t\tplayerEntity,\r\n\t\tplayerEntity,\r\n\t\tindexFromRight,\r\n\t\topponentBoard,\r\n\t\topponentEntity,\r\n\t\tgameState,\r\n\t\tapplyAuras,\r\n\t);\r\n\tgameState.spectator.registerPowerTarget(playerEntity, newMinion, playerBoard, null, null);\r\n\treturn spawned;\r\n};\r\n"]}
|