@firestone-hs/simulate-bgs-battle 1.1.681 → 1.1.682

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.
@@ -6,24 +6,24 @@ const utils_1 = require("../../../utils");
6
6
  exports.RapidReanimation = {
7
7
  startOfCombatTiming: 'pre-combat',
8
8
  cardIds: ["BG25_HERO_103p"],
9
- startOfCombat: (trinket, input) => {
10
- for (const heroPower of input.playerEntity.heroPowers) {
11
- if (exports.RapidReanimation.cardIds.includes(heroPower.cardId) && heroPower.used) {
12
- const minionThatWillDie = input.playerBoard
13
- .filter((m) => m.enchantments.some((e) => e.cardId === "BG25_HERO_103pe"))
14
- .sort((a, b) => b.enchantments.find((e) => e.cardId === "BG25_HERO_103pe")
15
- .originEntityId -
16
- a.enchantments.find((e) => e.cardId === "BG25_HERO_103pe").originEntityId || b.entityId - a.entityId)[0];
17
- if (minionThatWillDie) {
18
- const rapidReanimationIndexFromLeft = input.playerBoard.indexOf(minionThatWillDie);
19
- const minionToCopy = (0, utils_1.copyEntity)(minionThatWillDie);
20
- heroPower.info = minionToCopy;
21
- heroPower.info2 = input.playerBoard.length - 1 - rapidReanimationIndexFromLeft;
22
- (0, add_minion_to_board_1.removeAurasFromSelf)(minionToCopy, input.playerBoard, input.playerEntity, input.gameState);
23
- minionThatWillDie.definitelyDead = true;
24
- input.gameState.spectator.registerPowerTarget(input.playerEntity, minionThatWillDie, input.playerBoard, input.playerEntity, input.opponentEntity);
25
- return { hasTriggered: true, shouldRecomputeCurrentAttacker: true };
26
- }
9
+ startOfCombat: (heroPower, input) => {
10
+ if (exports.RapidReanimation.cardIds.includes(heroPower.cardId) && heroPower.used) {
11
+ const minionThatWillDie = input.playerBoard
12
+ .filter((m) => m.enchantments.some((e) => e.cardId === "BG25_HERO_103pe"))
13
+ .sort((a, b) => a.enchantments.find((e) => e.cardId === "BG25_HERO_103pe")
14
+ .originEntityId -
15
+ b.enchantments.find((e) => e.cardId === "BG25_HERO_103pe")
16
+ .originEntityId || b.entityId - a.entityId)[0];
17
+ if (minionThatWillDie) {
18
+ minionThatWillDie.enchantments = minionThatWillDie.enchantments.filter((e) => e.cardId !== "BG25_HERO_103pe");
19
+ const rapidReanimationIndexFromLeft = input.playerBoard.indexOf(minionThatWillDie);
20
+ const minionToCopy = (0, utils_1.copyEntity)(minionThatWillDie);
21
+ heroPower.info = minionToCopy;
22
+ heroPower.info2 = input.playerBoard.length - 1 - rapidReanimationIndexFromLeft;
23
+ (0, add_minion_to_board_1.removeAurasFromSelf)(minionToCopy, input.playerBoard, input.playerEntity, input.gameState);
24
+ minionThatWillDie.definitelyDead = true;
25
+ input.gameState.spectator.registerPowerTarget(input.playerEntity, minionThatWillDie, input.playerBoard, input.playerEntity, input.opponentEntity);
26
+ return { hasTriggered: true, shouldRecomputeCurrentAttacker: true };
27
27
  }
28
28
  }
29
29
  },
@@ -1 +1 @@
1
- {"version":3,"file":"rapid-reanimation.js","sourceRoot":"","sources":["../../../../src/cards/impl/hero-power/rapid-reanimation.ts"],"names":[],"mappings":";;;AAEA,iFAA8E;AAE9E,0CAA4C;AAG/B,QAAA,gBAAgB,GAAsB;IAClD,mBAAmB,EAAE,YAAY;IACjC,OAAO,EAAE,kBAAyC;IAClD,aAAa,EAAE,CAAC,OAAqB,EAAE,KAAe,EAAE,EAAE;QACzD,KAAK,MAAM,SAAS,IAAI,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE;YACtD,IAAI,wBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,SAAS,CAAC,IAAI,EAAE;gBAM1E,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW;qBACzC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CACb,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,sBAAuD,CAAC,CAC3F;qBACA,IAAI,CACJ,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACR,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,sBAAuD,CAAC;qBACzF,cAAc;oBACf,CAAC,CAAC,YAAY,CAAC,IAAI,CAClB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,sBAAuD,CACtE,CAAC,cAAc,IAAI,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAC7C,CAAC,CAAC,CAAC,CAAC;gBACN,IAAI,iBAAiB,EAAE;oBAUtB,MAAM,6BAA6B,GAAG,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;oBAOnF,MAAM,YAAY,GAAG,IAAA,kBAAU,EAAC,iBAAiB,CAAC,CAAC;oBAGnD,SAAS,CAAC,IAAI,GAAG,YAAY,CAAC;oBAC9B,SAAS,CAAC,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,GAAG,6BAA6B,CAAC;oBAC/E,IAAA,yCAAmB,EAAC,YAAY,EAAE,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;oBAC1F,iBAAiB,CAAC,cAAc,GAAG,IAAI,CAAC;oBACxC,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAC5C,KAAK,CAAC,YAAY,EAClB,iBAAiB,EACjB,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,YAAY,EAClB,KAAK,CAAC,cAAc,CACpB,CAAC;oBACF,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,8BAA8B,EAAE,IAAI,EAAE,CAAC;iBACpE;aACD;SACD;IACF,CAAC;CACD,CAAC","sourcesContent":["import { CardIds } from '../../../services/card-ids';\r\nimport { BoardTrinket } from '../../../bgs-player-entity';\r\nimport { removeAurasFromSelf } from '../../../simulation/add-minion-to-board';\r\nimport { SoCInput } from '../../../simulation/start-of-combat/start-of-combat-input';\r\nimport { copyEntity } from '../../../utils';\r\nimport { StartOfCombatCard } from '../../card.interface';\r\n\r\nexport const RapidReanimation: StartOfCombatCard = {\r\n\tstartOfCombatTiming: 'pre-combat',\r\n\tcardIds: [CardIds.TeronGorefiend_RapidReanimation],\r\n\tstartOfCombat: (trinket: BoardTrinket, input: SoCInput) => {\r\n\t\tfor (const heroPower of input.playerEntity.heroPowers) {\r\n\t\t\tif (RapidReanimation.cardIds.includes(heroPower.cardId) && heroPower.used) {\r\n\t\t\t\t// Getting the right enchantment can be tricky. The RapidReanimation enchantment can sometimes be\r\n\t\t\t\t// in the Graveyard zone, so we can't filter them out. In that case, we can have multiple\r\n\t\t\t\t// enchantments\r\n\t\t\t\t// However, because of how things are handled in the logs, we should be able to always take the one *\r\n\t\t\t\t// with the biggest entityId\r\n\t\t\t\tconst minionThatWillDie = input.playerBoard\r\n\t\t\t\t\t.filter((m) =>\r\n\t\t\t\t\t\tm.enchantments.some((e) => e.cardId === CardIds.RapidReanimation_ImpendingDeathEnchantment),\r\n\t\t\t\t\t)\r\n\t\t\t\t\t.sort(\r\n\t\t\t\t\t\t(a, b) =>\r\n\t\t\t\t\t\t\tb.enchantments.find((e) => e.cardId === CardIds.RapidReanimation_ImpendingDeathEnchantment)\r\n\t\t\t\t\t\t\t\t.originEntityId -\r\n\t\t\t\t\t\t\t\ta.enchantments.find(\r\n\t\t\t\t\t\t\t\t\t(e) => e.cardId === CardIds.RapidReanimation_ImpendingDeathEnchantment,\r\n\t\t\t\t\t\t\t\t).originEntityId || b.entityId - a.entityId,\r\n\t\t\t\t\t)[0];\r\n\t\t\t\tif (minionThatWillDie) {\r\n\t\t\t\t\t// So this is a bit tricky (as all the stuff with indices...). Because in practice it's more likely that players use Rapid Reanimation\r\n\t\t\t\t\t// on minions that they want to die quickly, most of the time they will be placed\r\n\t\t\t\t\t// to the left of the board\r\n\t\t\t\t\t// So using a left-based index (usually 0) is more likely to be correct after minions spawn on the board\r\n\t\t\t\t\t// Update: this looks like it's not the case, and looking at\r\n\t\t\t\t\t// http://replays.firestoneapp.com/?reviewId=2e6b389f-d904-43a2-a7cd-928a60d973ce&turn=11&action=1\r\n\t\t\t\t\t// the index seems to be right-based at least in some cases\r\n\t\t\t\t\t// Looks like even this is wrong:\r\n\t\t\t\t\t// http://replays.firestoneapp.com/?reviewId=9a46ab39-ccf0-478c-a010-68f2abb06c6f&turn=9&action=0\r\n\t\t\t\t\tconst rapidReanimationIndexFromLeft = input.playerBoard.indexOf(minionThatWillDie);\r\n\t\t\t\t\t// input.playerBoard.indexOf(minionThatWillDie) === input.playerBoard.length - 1\r\n\t\t\t\t\t// \t? input.playerBoard.indexOf(minionThatWillDie)\r\n\t\t\t\t\t// \t: input.playerBoard.indexOf(minionThatWillDie) + 1;\r\n\t\t\t\t\t// input.playerBoard.indexOf(minionThatWillDie)\r\n\t\t\t\t\t// input.playerEntity.rapidReanimationIndexFromRight =\r\n\t\t\t\t\t// \tinput.playerBoard.length - 1 - rapidReanimationIndexFromLeft;\r\n\t\t\t\t\tconst minionToCopy = copyEntity(minionThatWillDie);\r\n\t\t\t\t\t// We don't reapply auras when resummoning\r\n\t\t\t\t\t// Actually we should: a dead Goldrinn is then buffed by the auras upon resummon\r\n\t\t\t\t\theroPower.info = minionToCopy;\r\n\t\t\t\t\theroPower.info2 = input.playerBoard.length - 1 - rapidReanimationIndexFromLeft;\r\n\t\t\t\t\tremoveAurasFromSelf(minionToCopy, input.playerBoard, input.playerEntity, input.gameState);\r\n\t\t\t\t\tminionThatWillDie.definitelyDead = true;\r\n\t\t\t\t\tinput.gameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\tinput.playerEntity,\r\n\t\t\t\t\t\tminionThatWillDie,\r\n\t\t\t\t\t\tinput.playerBoard,\r\n\t\t\t\t\t\tinput.playerEntity,\r\n\t\t\t\t\t\tinput.opponentEntity,\r\n\t\t\t\t\t);\r\n\t\t\t\t\treturn { hasTriggered: true, shouldRecomputeCurrentAttacker: true };\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n};\r\n"]}
1
+ {"version":3,"file":"rapid-reanimation.js","sourceRoot":"","sources":["../../../../src/cards/impl/hero-power/rapid-reanimation.ts"],"names":[],"mappings":";;;AAEA,iFAA8E;AAE9E,0CAA4C;AAG/B,QAAA,gBAAgB,GAAsB;IAClD,mBAAmB,EAAE,YAAY;IACjC,OAAO,EAAE,kBAAyC;IAClD,aAAa,EAAE,CAAC,SAAuB,EAAE,KAAe,EAAE,EAAE;QAC3D,IAAI,wBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,SAAS,CAAC,IAAI,EAAE;YAM1E,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW;iBACzC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CACb,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,sBAAuD,CAAC,CAC3F;iBACA,IAAI,CACJ,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACR,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,sBAAuD,CAAC;iBACzF,cAAc;gBACf,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,sBAAuD,CAAC;qBACzF,cAAc,IAAI,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAC7C,CAAC,CAAC,CAAC,CAAC;YACN,IAAI,iBAAiB,EAAE;gBACtB,iBAAiB,CAAC,YAAY,GAAG,iBAAiB,CAAC,YAAY,CAAC,MAAM,CACrE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,sBAAuD,CACtE,CAAC;gBAUF,MAAM,6BAA6B,GAAG,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;gBAOnF,MAAM,YAAY,GAAG,IAAA,kBAAU,EAAC,iBAAiB,CAAC,CAAC;gBAGnD,SAAS,CAAC,IAAI,GAAG,YAAY,CAAC;gBAC9B,SAAS,CAAC,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,GAAG,6BAA6B,CAAC;gBAC/E,IAAA,yCAAmB,EAAC,YAAY,EAAE,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;gBAC1F,iBAAiB,CAAC,cAAc,GAAG,IAAI,CAAC;gBACxC,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAC5C,KAAK,CAAC,YAAY,EAClB,iBAAiB,EACjB,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,YAAY,EAClB,KAAK,CAAC,cAAc,CACpB,CAAC;gBACF,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,8BAA8B,EAAE,IAAI,EAAE,CAAC;aACpE;SACD;IACF,CAAC;CACD,CAAC","sourcesContent":["import { BgsHeroPower } from '../../../bgs-player-entity';\r\nimport { CardIds } from '../../../services/card-ids';\r\nimport { removeAurasFromSelf } from '../../../simulation/add-minion-to-board';\r\nimport { SoCInput } from '../../../simulation/start-of-combat/start-of-combat-input';\r\nimport { copyEntity } from '../../../utils';\r\nimport { StartOfCombatCard } from '../../card.interface';\r\n\r\nexport const RapidReanimation: StartOfCombatCard = {\r\n\tstartOfCombatTiming: 'pre-combat',\r\n\tcardIds: [CardIds.TeronGorefiend_RapidReanimation],\r\n\tstartOfCombat: (heroPower: BgsHeroPower, input: SoCInput) => {\r\n\t\tif (RapidReanimation.cardIds.includes(heroPower.cardId) && heroPower.used) {\r\n\t\t\t// Getting the right enchantment can be tricky. The RapidReanimation enchantment can sometimes be\r\n\t\t\t// in the Graveyard zone, so we can't filter them out. In that case, we can have multiple\r\n\t\t\t// enchantments\r\n\t\t\t// However, because of how things are handled in the logs, we should be able to always take the one *\r\n\t\t\t// with the biggest entityId\r\n\t\t\tconst minionThatWillDie = input.playerBoard\r\n\t\t\t\t.filter((m) =>\r\n\t\t\t\t\tm.enchantments.some((e) => e.cardId === CardIds.RapidReanimation_ImpendingDeathEnchantment),\r\n\t\t\t\t)\r\n\t\t\t\t.sort(\r\n\t\t\t\t\t(a, b) =>\r\n\t\t\t\t\t\ta.enchantments.find((e) => e.cardId === CardIds.RapidReanimation_ImpendingDeathEnchantment)\r\n\t\t\t\t\t\t\t.originEntityId -\r\n\t\t\t\t\t\t\tb.enchantments.find((e) => e.cardId === CardIds.RapidReanimation_ImpendingDeathEnchantment)\r\n\t\t\t\t\t\t\t\t.originEntityId || b.entityId - a.entityId,\r\n\t\t\t\t)[0];\r\n\t\t\tif (minionThatWillDie) {\r\n\t\t\t\tminionThatWillDie.enchantments = minionThatWillDie.enchantments.filter(\r\n\t\t\t\t\t(e) => e.cardId !== CardIds.RapidReanimation_ImpendingDeathEnchantment,\r\n\t\t\t\t);\r\n\t\t\t\t// So this is a bit tricky (as all the stuff with indices...). Because in practice it's more likely that players use Rapid Reanimation\r\n\t\t\t\t// on minions that they want to die quickly, most of the time they will be placed\r\n\t\t\t\t// to the left of the board\r\n\t\t\t\t// So using a left-based index (usually 0) is more likely to be correct after minions spawn on the board\r\n\t\t\t\t// Update: this looks like it's not the case, and looking at\r\n\t\t\t\t// http://replays.firestoneapp.com/?reviewId=2e6b389f-d904-43a2-a7cd-928a60d973ce&turn=11&action=1\r\n\t\t\t\t// the index seems to be right-based at least in some cases\r\n\t\t\t\t// Looks like even this is wrong:\r\n\t\t\t\t// http://replays.firestoneapp.com/?reviewId=9a46ab39-ccf0-478c-a010-68f2abb06c6f&turn=9&action=0\r\n\t\t\t\tconst rapidReanimationIndexFromLeft = input.playerBoard.indexOf(minionThatWillDie);\r\n\t\t\t\t// input.playerBoard.indexOf(minionThatWillDie) === input.playerBoard.length - 1\r\n\t\t\t\t// \t? input.playerBoard.indexOf(minionThatWillDie)\r\n\t\t\t\t// \t: input.playerBoard.indexOf(minionThatWillDie) + 1;\r\n\t\t\t\t// input.playerBoard.indexOf(minionThatWillDie)\r\n\t\t\t\t// input.playerEntity.rapidReanimationIndexFromRight =\r\n\t\t\t\t// \tinput.playerBoard.length - 1 - rapidReanimationIndexFromLeft;\r\n\t\t\t\tconst minionToCopy = copyEntity(minionThatWillDie);\r\n\t\t\t\t// We don't reapply auras when resummoning\r\n\t\t\t\t// Actually we should: a dead Goldrinn is then buffed by the auras upon resummon\r\n\t\t\t\theroPower.info = minionToCopy;\r\n\t\t\t\theroPower.info2 = input.playerBoard.length - 1 - rapidReanimationIndexFromLeft;\r\n\t\t\t\tremoveAurasFromSelf(minionToCopy, input.playerBoard, input.playerEntity, input.gameState);\r\n\t\t\t\tminionThatWillDie.definitelyDead = true;\r\n\t\t\t\tinput.gameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tinput.playerEntity,\r\n\t\t\t\t\tminionThatWillDie,\r\n\t\t\t\t\tinput.playerBoard,\r\n\t\t\t\t\tinput.playerEntity,\r\n\t\t\t\t\tinput.opponentEntity,\r\n\t\t\t\t);\r\n\t\t\t\treturn { hasTriggered: true, shouldRecomputeCurrentAttacker: true };\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n};\r\n"]}
@@ -6,7 +6,7 @@ exports.TimewarpedTamuzo = {
6
6
  cardIds: ["BG34_Giant_595", "BG34_Giant_595_G"],
7
7
  afterOtherSpawned: (minion, input) => {
8
8
  const mult = minion.cardId === "BG34_Giant_595_G" ? 2 : 1;
9
- (0, stats_1.modifyStats)(input.spawned, minion, input.spawned.attack * mult, input.spawned.maxHealth * mult, input.board, input.hero, input.gameState);
9
+ (0, stats_1.setEntityStats)(input.spawned, input.spawned.attack + input.spawned.attack * mult, input.spawned.health + input.spawned.maxHealth * mult, input.board, input.hero, input.gameState);
10
10
  },
11
11
  };
12
12
  //# sourceMappingURL=timewarped-tamuzo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"timewarped-tamuzo.js","sourceRoot":"","sources":["../../../../src/cards/impl/minion/timewarped-tamuzo.ts"],"names":[],"mappings":";;;AAGA,qDAAwD;AAG3C,QAAA,gBAAgB,GAA0B;IACtD,OAAO,EAAE,sCAAoF;IAC7F,iBAAiB,EAAE,CAAC,MAAmB,EAAE,KAAwB,EAAE,EAAE;QACpE,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,uBAA8C,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACjF,IAAA,mBAAW,EACV,KAAK,CAAC,OAAO,EACb,MAAM,EACN,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,EAC3B,KAAK,CAAC,OAAO,CAAC,SAAS,GAAG,IAAI,EAC9B,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,SAAS,CACf,CAAC;IACH,CAAC;CACD,CAAC","sourcesContent":["import { BoardEntity } from '../../../board-entity';\r\nimport { CardIds } from '../../../services/card-ids';\r\nimport { OnOtherSpawnInput } from '../../../simulation/add-minion-to-board';\r\nimport { modifyStats } from '../../../simulation/stats';\r\nimport { AfterOtherSpawnedCard } from '../../card.interface';\r\n\r\nexport const TimewarpedTamuzo: AfterOtherSpawnedCard = {\r\n\tcardIds: [CardIds.TimewarpedTamuzo_BG34_Giant_595, CardIds.TimewarpedTamuzo_BG34_Giant_595_G],\r\n\tafterOtherSpawned: (minion: BoardEntity, input: OnOtherSpawnInput) => {\r\n\t\tconst mult = minion.cardId === CardIds.TimewarpedTamuzo_BG34_Giant_595_G ? 2 : 1;\r\n\t\tmodifyStats(\r\n\t\t\tinput.spawned,\r\n\t\t\tminion,\r\n\t\t\tinput.spawned.attack * mult,\r\n\t\t\tinput.spawned.maxHealth * mult,\r\n\t\t\tinput.board,\r\n\t\t\tinput.hero,\r\n\t\t\tinput.gameState,\r\n\t\t);\r\n\t},\r\n};\r\n"]}
1
+ {"version":3,"file":"timewarped-tamuzo.js","sourceRoot":"","sources":["../../../../src/cards/impl/minion/timewarped-tamuzo.ts"],"names":[],"mappings":";;;AAGA,qDAA2D;AAG9C,QAAA,gBAAgB,GAA0B;IACtD,OAAO,EAAE,sCAAoF;IAC7F,iBAAiB,EAAE,CAAC,MAAmB,EAAE,KAAwB,EAAE,EAAE;QACpE,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,uBAA8C,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAUjF,IAAA,sBAAc,EACb,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,EAClD,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,GAAG,IAAI,EACrD,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,SAAS,CACf,CAAC;IACH,CAAC;CACD,CAAC","sourcesContent":["import { BoardEntity } from '../../../board-entity';\r\nimport { CardIds } from '../../../services/card-ids';\r\nimport { OnOtherSpawnInput } from '../../../simulation/add-minion-to-board';\r\nimport { setEntityStats } from '../../../simulation/stats';\r\nimport { AfterOtherSpawnedCard } from '../../card.interface';\r\n\r\nexport const TimewarpedTamuzo: AfterOtherSpawnedCard = {\r\n\tcardIds: [CardIds.TimewarpedTamuzo_BG34_Giant_595, CardIds.TimewarpedTamuzo_BG34_Giant_595_G],\r\n\tafterOtherSpawned: (minion: BoardEntity, input: OnOtherSpawnInput) => {\r\n\t\tconst mult = minion.cardId === CardIds.TimewarpedTamuzo_BG34_Giant_595_G ? 2 : 1;\r\n\t\t// modifyStats(\r\n\t\t// \tinput.spawned,\r\n\t\t// \tminion,\r\n\t\t// \tinput.spawned.attack * mult,\r\n\t\t// \tinput.spawned.maxHealth * mult,\r\n\t\t// \tinput.board,\r\n\t\t// \tinput.hero,\r\n\t\t// \tinput.gameState,\r\n\t\t// );\r\n\t\tsetEntityStats(\r\n\t\t\tinput.spawned,\r\n\t\t\tinput.spawned.attack + input.spawned.attack * mult,\r\n\t\t\tinput.spawned.health + input.spawned.maxHealth * mult,\r\n\t\t\tinput.board,\r\n\t\t\tinput.hero,\r\n\t\t\tinput.gameState,\r\n\t\t);\r\n\t},\r\n};\r\n"]}
@@ -295,24 +295,28 @@ const rememberDeathrattles = (fish, inputDeadEntities, cardsData, allCards, shar
295
295
  const validDeathrattles = deadEntities
296
296
  .filter((entity) => { var _a; return (_a = allCards.getCard(entity.cardId).mechanics) === null || _a === void 0 ? void 0 : _a.includes(reference_data_1.GameTag[reference_data_1.GameTag.DEATHRATTLE]); })
297
297
  .filter((e) => !DEATHRATTLES_REQUIRE_MEMORY.includes(e.cardId) || e.memory)
298
- .map((entity) => ({
299
- cardId: entity.cardId,
300
- repeats: 1,
301
- timing: sharedState.currentEntityId++,
302
- memory: entity.memory,
303
- scriptDataNum1: entity.scriptDataNum1,
304
- scriptDataNum2: entity.scriptDataNum2,
305
- }));
298
+ .map((entity) => {
299
+ const result = {
300
+ cardId: entity.cardId,
301
+ repeats: 1,
302
+ timing: sharedState.currentEntityId++,
303
+ memory: entity.memory,
304
+ tagScriptDataNum1: entity.scriptDataNum1,
305
+ tagScriptDataNum2: entity.scriptDataNum2,
306
+ };
307
+ return result;
308
+ });
306
309
  const validEnchantments = deadEntities
307
310
  .map((entity) => entity.enchantments)
308
311
  .reduce((a, b) => a.concat(b), [])
309
312
  .flatMap((enchantment) => {
310
313
  var _a;
311
- return ({
314
+ const result = {
312
315
  cardId: enchantment.cardId,
313
316
  repeats: (_a = enchantment.repeats) !== null && _a !== void 0 ? _a : 1,
314
317
  timing: sharedState.currentEntityId++,
315
- });
318
+ };
319
+ return result;
316
320
  })
317
321
  .filter((enchantment) => (0, simulate_bgs_battle_1.isValidDeathrattleEnchantment)(enchantment.cardId));
318
322
  const deadEntityRememberedDeathrattles = (_b = deadEntities
@@ -1 +1 @@
1
- {"version":3,"file":"deathrattle-effects.js","sourceRoot":"","sources":["../../src/simulation/deathrattle-effects.ts"],"names":[],"mappings":";;;AACA,iEAA8E;AAI9E,6EAAkG;AAClG,6DAA+D;AAC/D,6CAAgD;AAEhD,6CAAgE;AAChE,gEAAuE;AACvE,oCAOkB;AAClB,qCAA8C;AAC9C,mDAAiD;AACjD,6DAAqD;AAErD,qEAAwE;AAExE,mCAAsC;AAEtC,MAAM,2BAA2B,GAAG,0BAAwE,CAAC;AAC7G,MAAM,2BAA2B,GAAG;;;;CAInC,CAAC;AACF,MAAM,2BAA2B,GAAG,kCAA+E,CAAC;AAE7G,MAAM,4BAA4B,GAAG,CAC3C,KAAoB,EACpB,SAA0B,EAC1B,UAAuB,EACvB,WAAwB,EACf,EAAE;;IACX,MAAM,OAAO,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,MAAA,MAAA,SAAS,CAAC,OAAO,0CAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,mCAAI,EAAE,CAAC,CAAC,CAAC;IACpG,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,2BAA2B,CAAC,QAAQ,CAAC,MAAiB,CAAC,CAAC;QACpG,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,2BAA2B,CAAC,QAAQ,CAAC,MAAiB,CAAC,CAAC;YACnF,CAAC,CAAC,CAAC;YACH,CAAC,CAAC,CAAC,CAAC;IAEL,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,eAAoC,CAAC,CAAC,MAAM,CAAC;IACjG,MA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F,MAAM,uBAAuB,GAAG,IAAA,qDAA4B,EAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;YAC1F,IAAI,CAAC,sBAAsB,GAAG;gBAC7B,GAAG,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,WAAC,OAAA,CAAC,CAAA,MAAA,CAAC,CAAC,MAAM,0CAAE,UAAU,YAA8B,CAAA,CAAA,EAAA,CAAC;gBACjG,GAAG,uBAAuB;aAC1B,CAAC;SACF;KACD;AAYF,CAAC,CAAC;AAnFW,QAAA,oBAAoB,wBAmF/B;AAEF,MAAM,sBAAsB,GAAG,CAC9B,mBAAkC,EAClC,IAAqB,EACrB,SAAwB,EACvB,EAAE;AAWJ,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, GameTag, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardsData } from '../cards/cards-data';\r\nimport { eternalKnightAttack, eternalKnightHealth } from '../cards/impl/trinket/eternal-portrait';\r\nimport { updateDivineShield } from '../keywords/divine-shield';\r\nimport { updateTaunt } from '../keywords/taunt';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { pickMultipleRandomDifferent } from '../services/utils';\r\nimport { isValidDeathrattleEnchantment } from '../simulate-bgs-battle';\r\nimport {\r\n\tgetRandomMinionWithHighestHealth,\r\n\tgrantRandomStats,\r\n\thasCorrectTribe,\r\n\tisDead,\r\n\tisFish,\r\n\tisGolden,\r\n} from '../utils';\r\nimport { dealDamageToMinion } from './attack';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { groupLeapfroggerDeathrattles } from './remembered-deathrattle';\r\nimport { SharedState } from './shared-state';\r\nimport { modifyStats } from './stats';\r\n\r\nconst DEATHRATTLES_REQUIRE_MEMORY = [CardIds.StitchedSalvager_BG31_999, CardIds.StitchedSalvager_BG31_999_G];\r\nconst DOUBLE_DEATHRATTLE_CARD_IDS = [\r\n\tCardIds.MoiraBronzebeard_BG27_518,\r\n\tCardIds.TitusTribute_BG28_843,\r\n\tCardIds.TimewarpedDeios_BG34_Giant_376,\r\n];\r\nconst TRIPLE_DEATHRATTLE_CARD_IDS = [CardIds.MoiraBronzebeard_BG27_518_G, CardIds.TimewarpedDeios_BG34_Giant_376_G];\r\n\r\nexport const computeDeathrattleMultiplier = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tsharedState: SharedState,\r\n): number => {\r\n\tconst cardIds = [...board.map((e) => e.cardId), ...(boardHero.secrets?.map((e) => e.cardId) ?? [])];\r\n\tconst triggerMult = cardIds.some((cardId) => TRIPLE_DEATHRATTLE_CARD_IDS.includes(cardId as CardIds))\r\n\t\t? 3\r\n\t\t: cardIds.some((cardId) => DOUBLE_DEATHRATTLE_CARD_IDS.includes(cardId as CardIds))\r\n\t\t? 2\r\n\t\t: 1;\r\n\r\n\tconst titus = board.filter((entity) => entity.cardId === CardIds.TitusRivendare_BG25_354).length;\r\n\tconst goldenTitus = board.filter((entity) => entity.cardId === CardIds.TitusRivendare_BG25_354_G).length;\r\n\tconst deathlyPhylacteries = boardHero.trinkets.filter(\r\n\t\t(t) => t.cardId === CardIds.DeathlyPhylactery_BG30_MagicItem_700 && t.scriptDataNum1 > 0,\r\n\t).length;\r\n\tconst tombs =\r\n\t\tboardHero.questRewardEntities?.filter((entity) => entity.cardId === CardIds.TurbulentTombs)?.length ?? 0;\r\n\tconst echoesOfArgus = sharedState.anomalies.includes(CardIds.EchoesOfArgus_BG27_Anomaly_802) ? 1 : 0;\r\n\tconst scourgeMultiplier = deadEntity.additionalCards?.includes(CardIds.ScourgeTroll) ? 2 : 1;\r\n\r\n\tconst multiplier =\r\n\t\tscourgeMultiplier * (triggerMult + deathlyPhylacteries + titus + 2 * goldenTitus + tombs + echoesOfArgus);\r\n\treturn multiplier;\r\n};\r\n\r\nexport const applyLightningInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity | BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// Because the golden version doubles all the remembered effects\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tconst previousVenomous = (deadEntity as BoardEntity).venomous;\r\n\t(deadEntity as BoardEntity).venomous = false;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst targets = pickMultipleRandomDifferent(otherBoard, 5);\r\n\t\tfor (const target of targets) {\r\n\t\t\tdealDamageToMinion(\r\n\t\t\t\ttarget,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tdeadEntity,\r\n\t\t\t\t1,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\t(deadEntity as BoardEntity).venomous = previousVenomous;\r\n};\r\n\r\nexport const applyWaterInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity, // Can be null when trinket is used\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst validBoard = boardWithDeadEntity.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\t\tconst target: BoardEntity = validBoard[validBoard.length - 1];\r\n\t\tif (!!target) {\r\n\t\t\tupdateTaunt(target, true, boardWithDeadEntity, boardWithDeadEntityHero, otherHero, gameState);\r\n\t\t\tupdateDivineShield(target, boardWithDeadEntity, boardWithDeadEntityHero, otherHero, true, gameState);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyFireInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst target: BoardEntity = boardWithDeadEntity.filter((e) => e.health > 0 && !e.definitelyDead)[0];\r\n\t\tif (!!target) {\r\n\t\t\tmodifyStats(\r\n\t\t\t\ttarget,\r\n\t\t\t\tsourceEntity,\r\n\t\t\t\ttarget.attack,\r\n\t\t\t\t0,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyEarthInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst minionsGrantedDeathrattle: BoardEntity[] = pickMultipleRandomDifferent(boardWithDeadEntity, 4);\r\n\t\tminionsGrantedDeathrattle.forEach((minion) => {\r\n\t\t\tminion.enchantments.push({\r\n\t\t\t\tcardId: CardIds.EarthInvocation_ElementEarthEnchantment,\r\n\t\t\t\toriginEntityId: deadEntity?.entityId,\r\n\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t});\r\n\t\t\tgameState.spectator.registerPowerTarget(sourceEntity, minion, boardWithDeadEntity, null, null);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const applyLeapFroggerEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tgameState: FullGameState,\r\n\tmultiplier: number,\r\n): void => {\r\n\tmultiplier = multiplier ?? deadEntity.deathrattleRepeats ?? 1;\r\n\t// console.debug('applying leapfrogger effect', deadEntity.entityId, multiplier);\r\n\tconst buffed = grantRandomStats(\r\n\t\tdeadEntity,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tmultiplier * (isPremium ? 2 : 1),\r\n\t\tmultiplier * (isPremium ? 2 : 1),\r\n\t\tRace.BEAST,\r\n\t\tfalse,\r\n\t\tgameState,\r\n\t);\r\n\tif (buffed) {\r\n\t\tconst enchantmentCardId = isPremium\r\n\t\t\t? CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge\r\n\t\t\t: CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e;\r\n\t\tbuffed.enchantments.push({\r\n\t\t\tcardId: enchantmentCardId,\r\n\t\t\toriginEntityId: deadEntity.entityId,\r\n\t\t\trepeats: multiplier > 1 ? multiplier : 1,\r\n\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t});\r\n\t\tconst leapfroggerDeathrattles = groupLeapfroggerDeathrattles(buffed.enchantments);\r\n\t\tconst nonLeapfroggerEnchants = buffed.enchantments.filter(\r\n\t\t\t(d) => !d.cardId?.startsWith(CardIds.Leapfrogger_BG21_000),\r\n\t\t);\r\n\t\tconst newEnchants = [...leapfroggerDeathrattles, ...nonLeapfroggerEnchants];\r\n\t\tbuffed.enchantments = newEnchants;\r\n\t}\r\n};\r\n\r\nexport const applyRecurringNightmareDeathrattleEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tgameState: FullGameState,\r\n\tmultiplier = 1,\r\n): void => {\r\n\t// multiplier = multiplier || 1;\r\n\t// const target = pickRandom(\r\n\t// \tboardWithDeadEntity\r\n\t// \t\t.filter((e) =>\r\n\t// \t\t\thasCorrectTribe(e, boardWithDeadEntityHero, Race.UNDEAD, gameState.anomalies, gameState.allCards),\r\n\t// \t\t)\r\n\t// \t\t.filter(\r\n\t// \t\t\t(e) =>\r\n\t// \t\t\t\te.cardId !== CardIds.RecurringNightmare_BG26_055 &&\r\n\t// \t\t\t\te.cardId !== CardIds.RecurringNightmare_BG26_055_G,\r\n\t// \t\t),\r\n\t// );\r\n\t// if (target) {\r\n\t// \ttarget.enchantments = target.enchantments ?? [];\r\n\t// \ttarget.enchantments.push({\r\n\t// \t\tcardId: isPremium\r\n\t// \t\t\t? CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055_Ge\r\n\t// \t\t\t: CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055e,\r\n\t// \t\toriginEntityId: deadEntity.entityId,\r\n\t// \t\trepeats: multiplier > 1 ? multiplier : 1,\r\n\t// \t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t// \t});\r\n\t// \tgameState.spectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity, null, null);\r\n\t// }\r\n};\r\n\r\n// Some minions like Icesnarl can revive themselves when killing a minion, so it needs to be handled before\r\n// we actually make the minion die\r\nexport const handleWheneverMinionsKillEffect = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\thandleWheneverMinionsKillEffectForBoard(board, hero, otherBoard, otherHero, gameState);\r\n\t// It's called once for each board already, so don't duplicate it here\r\n\t// handleWheneverMinionsKillEffectForBoard(otherBoard, otherHero, board, hero, gameState);\r\n};\r\n\r\nconst handleWheneverMinionsKillEffectForBoard = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].health <= 0 || board[i].definitelyDead) {\r\n\t\t\tconst futureDeadEntity = board[i];\r\n\t\t\tconst killer = futureDeadEntity.lastAffectedByEntity;\r\n\t\t\tif (!killer) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Killed an enemy minion\r\n\t\t\tif (killer.friendly !== futureDeadEntity.friendly) {\r\n\t\t\t\tfor (const heroPower of otherHero.heroPowers) {\r\n\t\t\t\t\t// Can't be used to resurrect a dead minion\r\n\t\t\t\t\t// https://replays.firestoneapp.com/?reviewId=d1fffee8-0bc3-40f5-9a59-85eef8367095&turn=11&action=4\r\n\t\t\t\t\tif (heroPower.cardId === CardIds.Rokara_GloryOfCombat && !isDead(killer)) {\r\n\t\t\t\t\t\tmodifyStats(killer, otherHero, 1, 0, otherBoard, otherHero, gameState);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Icesnarl the Mighty\r\n\t\t\t\totherBoard\r\n\t\t\t\t\t.filter(\r\n\t\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\t\te.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy ||\r\n\t\t\t\t\t\t\te.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy_G,\r\n\t\t\t\t\t)\r\n\t\t\t\t\t// Can't be revived\r\n\t\t\t\t\t// 33.6 https://replays.firestoneapp.com/?reviewId=608ddffb-6c04-4def-a8de-fd39228f4de4&turn=11&action=4\r\n\t\t\t\t\t// Maybe should move to an \"after kill\" phase, where dead minions are already dead?\r\n\t\t\t\t\t.filter((e) => e.health > 0 && !e.definitelyDead)\r\n\t\t\t\t\t.forEach((icesnarl) => {\r\n\t\t\t\t\t\tconst mult = icesnarl.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy_G ? 2 : 1;\r\n\t\t\t\t\t\tmodifyStats(icesnarl, icesnarl, 0, 3 * mult, board, hero, gameState);\r\n\t\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const handleAfterMinionKillsEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// Moved to \"whenever kills\", as these can revive the minion that kills\r\n\t// const killer = deadEntity.lastAffectedByEntity;\r\n\t// if (!killer) {\r\n\t// \treturn;\r\n\t// }\r\n\t// // Killed an enemy minion\r\n\t// if (killer.friendly !== deadEntity.friendly) {\r\n\t// }\r\n};\r\n\r\nexport const applyAfterMinionDiesEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.DEMON, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplySoulJugglerEffect(boardWithDeadEntity, boardWithDeadEntityHero, otherBoard, otherBoardHero, gameState);\r\n\t}\r\n};\r\n\r\nexport const applyWheneverMinionDiesEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// console.log('applying minion death effect', stringifySimpleCard(deadEntity, allCards));\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.BEAST, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplyScavengingHyenaEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.MECH, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplyJunkbotEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.MURLOC, gameState.anomalies, gameState.allCards)) {\r\n\t\tremoveOldMurkEyeAttack(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\tremoveOldMurkEyeAttack(otherBoard, otherBoardHero, gameState);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.ELEMENTAL, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplyMossOfTheSchlossEffect(deadEntity, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\r\n\tif (deadEntity.taunt) {\r\n\t\tapplyBristlemaneScrapsmithEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\tapplyQirajiHarbringerEffect(boardWithDeadEntity, boardWithDeadEntityHero, deadEntityIndexFromRight, gameState);\r\n\t}\r\n\r\n\tif (\r\n\t\tdeadEntity.cardId === CardIds.EternalKnight_BG25_008 ||\r\n\t\tdeadEntity.cardId === CardIds.EternalKnight_BG25_008_G\r\n\t) {\r\n\t\tapplyEternalKnightEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\r\n\t// Putricide-only\r\n\tboardWithDeadEntity\r\n\t\t.filter((e) => e.additionalCards?.includes(CardIds.FlesheatingGhoulLegacy_BG26_tt_004))\r\n\t\t.forEach((e) => {\r\n\t\t\tmodifyStats(e, null, 1, 0, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t});\r\n\r\n\tapplyRotHideGnollEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\r\n\t// Overkill\r\n\tif (\r\n\t\tdeadEntity.health < 0 &&\r\n\t\tgameState.sharedState.currentAttackerEntityId != null &&\r\n\t\tgameState.sharedState.currentAttackerEntityId === deadEntity.lastAffectedByEntity?.entityId\r\n\t) {\r\n\t\t// if (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlame_BGS_032) {\r\n\t\t// \tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t// \tif (targets.length > 0) {\r\n\t\t// \t\tconst target = targets[0];\r\n\t\t// \t\tdealDamageToMinion(\r\n\t\t// \t\t\ttarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\t3,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tgameState,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlame_TB_BaconUps_103) {\r\n\t\t// \tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t// \tif (targets.length > 0) {\r\n\t\t// \t\tconst target = targets[0];\r\n\t\t// \t\tdealDamageToMinion(\r\n\t\t// \t\t\ttarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\t6,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tgameState,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// }\r\n\t\t// else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental && deadEntity.lastAffectedByEntity.attacking) {\r\n\t\t// \t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental) {\r\n\t\t// \t// console.log('applying WildfireElemental effect', stringifySimple(boardWithDeadEntity, allCards));\r\n\t\t// \tconst excessDamage = -deadEntity.health;\r\n\t\t// \t// Prevent propagation of the effect\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking = false;\r\n\t\t// \tconst neighbours = getNeighbours(boardWithDeadEntity, null, boardWithDeadEntity.length - deadEntityIndexFromRight);\r\n\t\t// \t// console.log('neighbours', stringifySimple(neighbours, allCards));\r\n\t\t// \tif (neighbours.length > 0) {\r\n\t\t// \t\tconst randomTarget = neighbours[Math.floor(Math.random() * neighbours.length)];\r\n\t\t// \t\tdealDamageToEnemy(\r\n\t\t// \t\t\trandomTarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\texcessDamage,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tallCards,\r\n\t\t// \t\t\tcardsData,\r\n\t\t// \t\t\tsharedState,\r\n\t\t// \t\t\tspectator,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// } else if (\r\n\t\t// \tdeadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElementalBattlegrounds &&\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking\r\n\t\t// ) {\r\n\t\t// \tconst excessDamage = -deadEntity.health;\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking = false;\r\n\t\t// \tconst neighbours = getNeighbours(boardWithDeadEntity, null, boardWithDeadEntity.length - deadEntityIndexFromRight);\r\n\t\t// \tneighbours.forEach((neighbour) =>\r\n\t\t// \t\tdealDamageToEnemy(\r\n\t\t// \t\t\tneighbour,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\texcessDamage,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tallCards,\r\n\t\t// \t\t\tcardsData,\r\n\t\t// \t\t\tsharedState,\r\n\t\t// \t\t\tspectator,\r\n\t\t// \t\t),\r\n\t\t// \t);\r\n\t\t// }\r\n\t\tif (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn_TRL_232) {\r\n\t\t\tconst newEntities = spawnEntities(\r\n\t\t\t\tCardIds.IronhideDirehorn_IronhideRuntToken_TRL_232t,\r\n\t\t\t\t1,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\t!deadEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t\totherBoard.splice(otherBoard.length - deadEntityIndexFromRight, 0, ...newEntities);\r\n\t\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn_TB_BaconUps_051) {\r\n\t\t\t// \tconst newEntities = spawnEntities(\r\n\t\t\t// \t\tCardIds.IronhideDirehorn_IronhideRuntToken_TB_BaconUps_051t,\r\n\t\t\t// \t\t1,\r\n\t\t\t// \t\totherBoard,\r\n\t\t\t// \t\totherBoardHero,\r\n\t\t\t// \t\tboardWithDeadEntity,\r\n\t\t\t// \t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\tgameState,\r\n\t\t\t// \t\t!deadEntity.friendly,\r\n\t\t\t// \t\tfalse,\r\n\t\t\t// \t);\r\n\t\t\t// \totherBoard.splice(otherBoard.length - deadEntityIndexFromRight, 0, ...newEntities);\r\n\t\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath_BGS_080) {\r\n\t\t\t// \tconst otherPirates = otherBoard\r\n\t\t\t// \t\t.filter((entity) =>\r\n\t\t\t// \t\t\thasCorrectTribe(\r\n\t\t\t// \t\t\t\tentity,\r\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\t\tRace.PIRATE,\r\n\t\t\t// \t\t\t\tgameState.anomalies,\r\n\t\t\t// \t\t\t\tgameState.allCards,\r\n\t\t\t// \t\t\t),\r\n\t\t\t// \t\t)\r\n\t\t\t// \t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\t// \totherPirates.forEach((pirate) => {\r\n\t\t\t// \t\tmodifyStats(\r\n\t\t\t// \t\t\tpirate,\r\n\t\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t// \t\t\t2,\r\n\t\t\t// \t\t\t2,\r\n\t\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\tgameState,\r\n\t\t\t// \t\t);\r\n\t\t\t// \t});\r\n\t\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath_TB_BaconUps_142) {\r\n\t\t\t// \tconst otherPirates = otherBoard\r\n\t\t\t// \t\t.filter((entity) =>\r\n\t\t\t// \t\t\thasCorrectTribe(\r\n\t\t\t// \t\t\t\tentity,\r\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\t\tRace.PIRATE,\r\n\t\t\t// \t\t\t\tgameState.anomalies,\r\n\t\t\t// \t\t\t\tgameState.allCards,\r\n\t\t\t// \t\t\t),\r\n\t\t\t// \t\t)\r\n\t\t\t// \t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\t// \totherPirates.forEach((pirate) => {\r\n\t\t\t// \t\tmodifyStats(\r\n\t\t\t// \t\t\tpirate,\r\n\t\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t// \t\t\t4,\r\n\t\t\t// \t\t\t4,\r\n\t\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\tgameState,\r\n\t\t\t// \t\t);\r\n\t\t\t// \t});\r\n\t\t}\r\n\t}\r\n};\r\n\r\n/** @deprecated */\r\nexport const dealDamageToAllMinions = (\r\n\tboard1: BoardEntity[],\r\n\tboard1Hero: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tboard2Hero: BgsPlayerEntity,\r\n\tdamageSource: BoardEntity,\r\n\tdamageDealt: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (board1.length === 0 && board2.length === 0) {\r\n\t\treturn;\r\n\t}\r\n\tfor (let i = 0; i < board1.length; i++) {\r\n\t\tdealDamageToMinion(board1[i], board1, board1Hero, damageSource, damageDealt, board2, board2Hero, gameState);\r\n\t}\r\n\tfor (let i = 0; i < board2.length; i++) {\r\n\t\tdealDamageToMinion(board2[i], board2, board2Hero, damageSource, damageDealt, board1, board1Hero, gameState);\r\n\t}\r\n};\r\n\r\nexport const applySoulJugglerEffect = (\r\n\tboardWithJugglers: BoardEntity[],\r\n\tboardWithJugglersHero: BgsPlayerEntity,\r\n\tboardToAttack: BoardEntity[],\r\n\tboardToAttackHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (boardWithJugglers.length === 0 && boardToAttack.length === 0) {\r\n\t\treturn;\r\n\t\t// return [boardWithJugglers, boardToAttack];\r\n\t}\r\n\tconst jugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler_BGS_002);\r\n\tfor (const juggler of jugglers) {\r\n\t\tconst target = getRandomMinionWithHighestHealth(boardToAttack);\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tjuggler,\r\n\t\t\ttarget,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tboardToAttackHero,\r\n\t\t);\r\n\t\tdealDamageToMinion(\r\n\t\t\ttarget,\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t4,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\tconst goldenJugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler_TB_BaconUps_075);\r\n\tfor (const juggler of goldenJugglers) {\r\n\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\tconst target = getRandomMinionWithHighestHealth(boardToAttack);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tjuggler,\r\n\t\t\t\ttarget,\r\n\t\t\t\tboardWithJugglers,\r\n\t\t\t\tboardWithJugglersHero,\r\n\t\t\t\tboardToAttackHero,\r\n\t\t\t);\r\n\t\t\tdealDamageToMinion(\r\n\t\t\t\ttarget,\r\n\t\t\t\tboardToAttack,\r\n\t\t\t\tboardToAttackHero,\r\n\t\t\t\tjuggler,\r\n\t\t\t\t4,\r\n\t\t\t\tboardWithJugglers,\r\n\t\t\t\tboardWithJugglersHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\t// processMinionDeath(\r\n\t// \tboardWithJugglers,\r\n\t// \tboardWithJugglersHero,\r\n\t// \tboardToAttack,\r\n\t// \tboardToAttackHero,\r\n\t// \tallCards,\r\n\t// \tcardsData,\r\n\t// \tsharedState,\r\n\t// \tspectator,\r\n\t// );\r\n};\r\n\r\nconst applyScavengingHyenaEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// const copy = [...board];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.ScavengingHyenaLegacy_BG_EX1_531) {\r\n\t\t\tmodifyStats(board[i], null, 2, 1, board, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t} else if (board[i].cardId === CardIds.ScavengingHyenaLegacy_TB_BaconUps_043) {\r\n\t\t\tmodifyStats(board[i], null, 4, 2, board, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyEternalKnightEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (\r\n\t\t\tboard[i].cardId === CardIds.EternalKnight_BG25_008 ||\r\n\t\t\tboard[i].cardId === CardIds.EternalKnight_BG25_008_G\r\n\t\t) {\r\n\t\t\tconst multiplier = board[i].cardId === CardIds.EternalKnight_BG25_008_G ? 2 : 1;\r\n\t\t\tmodifyStats(\r\n\t\t\t\tboard[i],\r\n\t\t\t\tnull,\r\n\t\t\t\tmultiplier * eternalKnightAttack,\r\n\t\t\t\tmultiplier * eternalKnightHealth,\r\n\t\t\t\tboard,\r\n\t\t\t\thero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyRotHideGnollEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.RotHideGnoll_BG25_013 || board[i].cardId === CardIds.RotHideGnoll_BG25_013_G) {\r\n\t\t\tconst multiplier = board[i].cardId === CardIds.RotHideGnoll_BG25_013_G ? 2 : 1;\r\n\t\t\tmodifyStats(board[i], null, multiplier * 1, 0, board, hero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyBristlemaneScrapsmithEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardPlayerEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (\r\n\t\t\tboard[i].cardId === CardIds.BristlemaneScrapsmith_BG24_707 ||\r\n\t\t\tboard[i].cardId === CardIds.BristlemaneScrapsmith_BG24_707_G\r\n\t\t) {\r\n\t\t\tconst cardsToAdd = Array(CardIds.BristlemaneScrapsmith_BG24_707_G ? 2 : 1).fill(CardIds.BloodGem);\r\n\t\t\taddCardsInHand(boardPlayerEntity, board, cardsToAdd, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, boardPlayerEntity, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyMossOfTheSchlossEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tboard\r\n\t\t.filter(\r\n\t\t\t(e) => e.cardId === CardIds.MossOfTheSchloss_BG30_111 || e.cardId === CardIds.MossOfTheSchloss_BG30_111_G,\r\n\t\t)\r\n\t\t.filter((e) => e.abiityChargesLeft > 0)\r\n\t\t.forEach((entity) => {\r\n\t\t\tmodifyStats(entity, null, deadEntity.maxAttack, deadEntity.maxHealth, board, hero, gameState);\r\n\t\t\tentity.abiityChargesLeft--;\r\n\t\t\tgameState.spectator.registerPowerTarget(entity, entity, board, null, null);\r\n\t\t});\r\n};\r\n\r\nconst applyJunkbotEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.Junkbot_GVG_106) {\r\n\t\t\tmodifyStats(board[i], board[i], 2, 2, board, hero, gameState);\r\n\t\t\t// } else if (board[i].cardId === CardIds.Junkbot_TB_BaconUps_046) {\r\n\t\t\t// \tmodifyStats(board[i], board[i], 4, 4, board, hero, gameState);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyQirajiHarbringerEffect = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// const qiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger_BGS_112);\r\n\t// const goldenQiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger_TB_BaconUps_303);\r\n\t// // TODO: if reactivated, properly apply buffs one by one, instead of all together\r\n\t// if (qiraji.length + goldenQiraji.length > 0) {\r\n\t// \tconst neighbours = getNeighbours(board, null, deadEntityIndexFromRight);\r\n\t// \tconst buff = 2 * qiraji.length + 4 * goldenQiraji.length;\r\n\t// \tneighbours.forEach((entity) => {\r\n\t// \t\tmodifyStats(entity, null, buff, buff, board, hero, gameState);\r\n\t// \t});\r\n\t// }\r\n};\r\n\r\nexport const rememberDeathrattles = (\r\n\tfish: BoardEntity,\r\n\tinputDeadEntities: readonly BoardEntity[],\r\n\tcardsData: CardsData,\r\n\tallCards: AllCardsService,\r\n\tsharedState: SharedState,\r\n): void => {\r\n\tconst deadEntities = inputDeadEntities.filter((e) => !isFish(e));\r\n\tif (!deadEntities?.length) {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// Some infinite loops going on?\r\n\tif (fish.rememberedDeathrattles?.length > 100) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst debug = deadEntities.some((e) => e.cardId === CardIds.CorruptedBristler_BG32_431);\r\n\r\n\tconst validDeathrattles = deadEntities\r\n\t\t.filter((entity) => allCards.getCard(entity.cardId).mechanics?.includes(GameTag[GameTag.DEATHRATTLE]))\r\n\t\t.filter((e) => !DEATHRATTLES_REQUIRE_MEMORY.includes(e.cardId as CardIds) || e.memory)\r\n\t\t.map((entity) => ({\r\n\t\t\tcardId: entity.cardId,\r\n\t\t\trepeats: 1,\r\n\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t\tmemory: entity.memory,\r\n\t\t\tscriptDataNum1: entity.scriptDataNum1,\r\n\t\t\tscriptDataNum2: entity.scriptDataNum2,\r\n\t\t}));\r\n\tconst validEnchantments = deadEntities\r\n\t\t.map((entity) => entity.enchantments)\r\n\t\t.reduce((a, b) => a.concat(b), [])\r\n\t\t.flatMap((enchantment) => ({\r\n\t\t\tcardId: enchantment.cardId,\r\n\t\t\trepeats: enchantment.repeats ?? 1,\r\n\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t}))\r\n\t\t.filter((enchantment) => isValidDeathrattleEnchantment(enchantment.cardId));\r\n\t// Multiple fish\r\n\tconst deadEntityRememberedDeathrattles =\r\n\t\tdeadEntities\r\n\t\t\t.filter((e) => !!e.rememberedDeathrattles?.length)\r\n\t\t\t// If the fish has reborn, it will inherit its own Deathrattles, and we don't want that\r\n\t\t\t.filter((e) => e.entityId !== fish.rebornFromEntityId)\r\n\t\t\t.filter((e) => !DEATHRATTLES_REQUIRE_MEMORY.includes(e.cardId as CardIds) || e.memory)\r\n\t\t\t.flatMap((e) => e.rememberedDeathrattles) ?? [];\r\n\tconst newDeathrattles = [...validDeathrattles, ...validEnchantments, ...deadEntityRememberedDeathrattles];\r\n\r\n\tif (newDeathrattles.length > 0) {\r\n\t\t// Order is important - the DR are triggered in the order d the minions have died\r\n\t\t// The \"golden\" part is handled at the card level for the other non-fish cards, like Piloted Whirl-o-Tron\r\n\t\tif (isFish(fish) && isGolden(fish.cardId, allCards)) {\r\n\t\t\t// https://stackoverflow.com/questions/33305152/how-to-duplicate-elements-in-a-js-array\r\n\t\t\tconst doubleDr = newDeathrattles.reduce((res, current) => res.concat([current, current]), []);\r\n\t\t\tfish.rememberedDeathrattles = [...(fish.rememberedDeathrattles || []), ...doubleDr];\r\n\t\t} else {\r\n\t\t\tfish.rememberedDeathrattles = [...(fish.rememberedDeathrattles || []), ...newDeathrattles];\r\n\t\t}\r\n\r\n\t\tif (newDeathrattles.some((d) => d.cardId?.startsWith(CardIds.Leapfrogger_BG21_000))) {\r\n\t\t\t// Not sure exactly why, but if a leapfrogger dies first, then a manasaber,\r\n\t\t\t// when the fish dies, the manasaber's effect (spawning tokens) is triggered first\r\n\t\t\t// https://replays.firestoneapp.com/?reviewId=521733fb-8ba1-4663-9a87-3da58e8a09c8&turn=21&action=3\r\n\t\t\t// HACK: So I will hardcode a rule for now to put leapfrogger effects last\r\n\t\t\tconst leapfroggerDeathrattles = groupLeapfroggerDeathrattles(fish.rememberedDeathrattles);\r\n\t\t\tfish.rememberedDeathrattles = [\r\n\t\t\t\t...fish.rememberedDeathrattles.filter((d) => !d.cardId?.startsWith(CardIds.Leapfrogger_BG21_000)),\r\n\t\t\t\t...leapfroggerDeathrattles,\r\n\t\t\t];\r\n\t\t}\r\n\t}\r\n\t// console.debug(\r\n\t// \t'remembered',\r\n\t// \tfish.cardId,\r\n\t// \tfish.entityId,\r\n\t// \tfish.rememberedDeathrattles.map((d) => ({\r\n\t// \t\tcardId: d.cardId,\r\n\t// \t\tname: allCards.getCard(d.cardId)?.name,\r\n\t// \t\t// repeats: d.repeats,\r\n\t// \t\t// timing: d.timing,\r\n\t// \t})),\r\n\t// );\r\n};\r\n\r\nconst removeOldMurkEyeAttack = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\t// const murkeyes = boardWithDeadEntity.filter(\r\n\t// \t(entity) => entity.cardId === CardIds.OldMurkEyeLegacy || entity.cardId === CardIds.OldMurkEyeVanilla,\r\n\t// );\r\n\t// const goldenMurkeyes = boardWithDeadEntity.filter((entity) => entity.cardId === CardIds.OldMurkEye);\r\n\t// murkeyes.forEach((entity) => {\r\n\t// \tmodifyStats(entity, null, -1, 0, boardWithDeadEntity, hero, gameState);\r\n\t// });\r\n\t// goldenMurkeyes.forEach((entity) => {\r\n\t// \tmodifyStats(entity, null, -2, 0, boardWithDeadEntity, hero, gameState);\r\n\t// });\r\n};\r\n"]}
1
+ {"version":3,"file":"deathrattle-effects.js","sourceRoot":"","sources":["../../src/simulation/deathrattle-effects.ts"],"names":[],"mappings":";;;AACA,iEAA8E;AAI9E,6EAAkG;AAClG,6DAA+D;AAC/D,6CAAgD;AAEhD,6CAAgE;AAChE,gEAAuE;AACvE,oCAOkB;AAClB,qCAA8C;AAC9C,mDAAiD;AACjD,6DAAqD;AAErD,qEAAwE;AAExE,mCAAsC;AAEtC,MAAM,2BAA2B,GAAG,0BAAwE,CAAC;AAC7G,MAAM,2BAA2B,GAAG;;;;CAInC,CAAC;AACF,MAAM,2BAA2B,GAAG,kCAA+E,CAAC;AAE7G,MAAM,4BAA4B,GAAG,CAC3C,KAAoB,EACpB,SAA0B,EAC1B,UAAuB,EACvB,WAAwB,EACf,EAAE;;IACX,MAAM,OAAO,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,MAAA,MAAA,SAAS,CAAC,OAAO,0CAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,mCAAI,EAAE,CAAC,CAAC,CAAC;IACpG,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,2BAA2B,CAAC,QAAQ,CAAC,MAAiB,CAAC,CAAC;QACpG,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,2BAA2B,CAAC,QAAQ,CAAC,MAAiB,CAAC,CAAC;YACnF,CAAC,CAAC,CAAC;YACH,CAAC,CAAC,CAAC,CAAC;IAEL,MAAM,KAAK,GAAG,KAAK,CAAC,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EAAE,GAAG,eAAe,CAAC,CAAC;SAC3F;QAED,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,WAAC,OAAA,MAAA,CAAC,CAAC,MAAM,0CAAE,UAAU,YAA8B,CAAA,EAAA,CAAC,EAAE;YAKpF,MAAM,uBAAuB,GAAG,IAAA,qDAA4B,EAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;YAC1F,IAAI,CAAC,sBAAsB,GAAG;gBAC7B,GAAG,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,WAAC,OAAA,CAAC,CAAA,MAAA,CAAC,CAAC,MAAM,0CAAE,UAAU,YAA8B,CAAA,CAAA,EAAA,CAAC;gBACjG,GAAG,uBAAuB;aAC1B,CAAC;SACF;KACD;AAYF,CAAC,CAAC;AAzFW,QAAA,oBAAoB,wBAyF/B;AAEF,MAAM,sBAAsB,GAAG,CAC9B,mBAAkC,EAClC,IAAqB,EACrB,SAAwB,EACvB,EAAE;AAWJ,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, GameTag, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEnchantment, BoardEntity } from '../board-entity';\r\nimport { CardsData } from '../cards/cards-data';\r\nimport { eternalKnightAttack, eternalKnightHealth } from '../cards/impl/trinket/eternal-portrait';\r\nimport { updateDivineShield } from '../keywords/divine-shield';\r\nimport { updateTaunt } from '../keywords/taunt';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { pickMultipleRandomDifferent } from '../services/utils';\r\nimport { isValidDeathrattleEnchantment } from '../simulate-bgs-battle';\r\nimport {\r\n\tgetRandomMinionWithHighestHealth,\r\n\tgrantRandomStats,\r\n\thasCorrectTribe,\r\n\tisDead,\r\n\tisFish,\r\n\tisGolden,\r\n} from '../utils';\r\nimport { dealDamageToMinion } from './attack';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { groupLeapfroggerDeathrattles } from './remembered-deathrattle';\r\nimport { SharedState } from './shared-state';\r\nimport { modifyStats } from './stats';\r\n\r\nconst DEATHRATTLES_REQUIRE_MEMORY = [CardIds.StitchedSalvager_BG31_999, CardIds.StitchedSalvager_BG31_999_G];\r\nconst DOUBLE_DEATHRATTLE_CARD_IDS = [\r\n\tCardIds.MoiraBronzebeard_BG27_518,\r\n\tCardIds.TitusTribute_BG28_843,\r\n\tCardIds.TimewarpedDeios_BG34_Giant_376,\r\n];\r\nconst TRIPLE_DEATHRATTLE_CARD_IDS = [CardIds.MoiraBronzebeard_BG27_518_G, CardIds.TimewarpedDeios_BG34_Giant_376_G];\r\n\r\nexport const computeDeathrattleMultiplier = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tsharedState: SharedState,\r\n): number => {\r\n\tconst cardIds = [...board.map((e) => e.cardId), ...(boardHero.secrets?.map((e) => e.cardId) ?? [])];\r\n\tconst triggerMult = cardIds.some((cardId) => TRIPLE_DEATHRATTLE_CARD_IDS.includes(cardId as CardIds))\r\n\t\t? 3\r\n\t\t: cardIds.some((cardId) => DOUBLE_DEATHRATTLE_CARD_IDS.includes(cardId as CardIds))\r\n\t\t? 2\r\n\t\t: 1;\r\n\r\n\tconst titus = board.filter((entity) => entity.cardId === CardIds.TitusRivendare_BG25_354).length;\r\n\tconst goldenTitus = board.filter((entity) => entity.cardId === CardIds.TitusRivendare_BG25_354_G).length;\r\n\tconst deathlyPhylacteries = boardHero.trinkets.filter(\r\n\t\t(t) => t.cardId === CardIds.DeathlyPhylactery_BG30_MagicItem_700 && t.scriptDataNum1 > 0,\r\n\t).length;\r\n\tconst tombs =\r\n\t\tboardHero.questRewardEntities?.filter((entity) => entity.cardId === CardIds.TurbulentTombs)?.length ?? 0;\r\n\tconst echoesOfArgus = sharedState.anomalies.includes(CardIds.EchoesOfArgus_BG27_Anomaly_802) ? 1 : 0;\r\n\tconst scourgeMultiplier = deadEntity.additionalCards?.includes(CardIds.ScourgeTroll) ? 2 : 1;\r\n\r\n\tconst multiplier =\r\n\t\tscourgeMultiplier * (triggerMult + deathlyPhylacteries + titus + 2 * goldenTitus + tombs + echoesOfArgus);\r\n\treturn multiplier;\r\n};\r\n\r\nexport const applyLightningInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity | BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// Because the golden version doubles all the remembered effects\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tconst previousVenomous = (deadEntity as BoardEntity).venomous;\r\n\t(deadEntity as BoardEntity).venomous = false;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst targets = pickMultipleRandomDifferent(otherBoard, 5);\r\n\t\tfor (const target of targets) {\r\n\t\t\tdealDamageToMinion(\r\n\t\t\t\ttarget,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tdeadEntity,\r\n\t\t\t\t1,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\t(deadEntity as BoardEntity).venomous = previousVenomous;\r\n};\r\n\r\nexport const applyWaterInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity, // Can be null when trinket is used\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst validBoard = boardWithDeadEntity.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\t\tconst target: BoardEntity = validBoard[validBoard.length - 1];\r\n\t\tif (!!target) {\r\n\t\t\tupdateTaunt(target, true, boardWithDeadEntity, boardWithDeadEntityHero, otherHero, gameState);\r\n\t\t\tupdateDivineShield(target, boardWithDeadEntity, boardWithDeadEntityHero, otherHero, true, gameState);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyFireInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst target: BoardEntity = boardWithDeadEntity.filter((e) => e.health > 0 && !e.definitelyDead)[0];\r\n\t\tif (!!target) {\r\n\t\t\tmodifyStats(\r\n\t\t\t\ttarget,\r\n\t\t\t\tsourceEntity,\r\n\t\t\t\ttarget.attack,\r\n\t\t\t\t0,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const applyEarthInvocationEnchantment = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tdeadEntity: BoardEntity,\r\n\tsourceEntity: BgsPlayerEntity | BoardEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst multiplier = deadEntity?.cardId === CardIds.SpiritRaptor_BG22_HERO_001_Buddy_G ? 2 : 1;\r\n\tfor (let i = 0; i < multiplier; i++) {\r\n\t\tconst minionsGrantedDeathrattle: BoardEntity[] = pickMultipleRandomDifferent(boardWithDeadEntity, 4);\r\n\t\tminionsGrantedDeathrattle.forEach((minion) => {\r\n\t\t\tminion.enchantments.push({\r\n\t\t\t\tcardId: CardIds.EarthInvocation_ElementEarthEnchantment,\r\n\t\t\t\toriginEntityId: deadEntity?.entityId,\r\n\t\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t\t});\r\n\t\t\tgameState.spectator.registerPowerTarget(sourceEntity, minion, boardWithDeadEntity, null, null);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const applyLeapFroggerEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tgameState: FullGameState,\r\n\tmultiplier: number,\r\n): void => {\r\n\tmultiplier = multiplier ?? deadEntity.deathrattleRepeats ?? 1;\r\n\t// console.debug('applying leapfrogger effect', deadEntity.entityId, multiplier);\r\n\tconst buffed = grantRandomStats(\r\n\t\tdeadEntity,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tmultiplier * (isPremium ? 2 : 1),\r\n\t\tmultiplier * (isPremium ? 2 : 1),\r\n\t\tRace.BEAST,\r\n\t\tfalse,\r\n\t\tgameState,\r\n\t);\r\n\tif (buffed) {\r\n\t\tconst enchantmentCardId = isPremium\r\n\t\t\t? CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000_Ge\r\n\t\t\t: CardIds.Leapfrogger_LeapfrogginEnchantment_BG21_000e;\r\n\t\tbuffed.enchantments.push({\r\n\t\t\tcardId: enchantmentCardId,\r\n\t\t\toriginEntityId: deadEntity.entityId,\r\n\t\t\trepeats: multiplier > 1 ? multiplier : 1,\r\n\t\t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t\t});\r\n\t\tconst leapfroggerDeathrattles = groupLeapfroggerDeathrattles(buffed.enchantments);\r\n\t\tconst nonLeapfroggerEnchants = buffed.enchantments.filter(\r\n\t\t\t(d) => !d.cardId?.startsWith(CardIds.Leapfrogger_BG21_000),\r\n\t\t);\r\n\t\tconst newEnchants = [...leapfroggerDeathrattles, ...nonLeapfroggerEnchants];\r\n\t\tbuffed.enchantments = newEnchants;\r\n\t}\r\n};\r\n\r\nexport const applyRecurringNightmareDeathrattleEffect = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tisPremium: boolean,\r\n\tgameState: FullGameState,\r\n\tmultiplier = 1,\r\n): void => {\r\n\t// multiplier = multiplier || 1;\r\n\t// const target = pickRandom(\r\n\t// \tboardWithDeadEntity\r\n\t// \t\t.filter((e) =>\r\n\t// \t\t\thasCorrectTribe(e, boardWithDeadEntityHero, Race.UNDEAD, gameState.anomalies, gameState.allCards),\r\n\t// \t\t)\r\n\t// \t\t.filter(\r\n\t// \t\t\t(e) =>\r\n\t// \t\t\t\te.cardId !== CardIds.RecurringNightmare_BG26_055 &&\r\n\t// \t\t\t\te.cardId !== CardIds.RecurringNightmare_BG26_055_G,\r\n\t// \t\t),\r\n\t// );\r\n\t// if (target) {\r\n\t// \ttarget.enchantments = target.enchantments ?? [];\r\n\t// \ttarget.enchantments.push({\r\n\t// \t\tcardId: isPremium\r\n\t// \t\t\t? CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055_Ge\r\n\t// \t\t\t: CardIds.RecurringNightmare_NightmareInsideEnchantment_BG26_055e,\r\n\t// \t\toriginEntityId: deadEntity.entityId,\r\n\t// \t\trepeats: multiplier > 1 ? multiplier : 1,\r\n\t// \t\ttiming: gameState.sharedState.currentEntityId++,\r\n\t// \t});\r\n\t// \tgameState.spectator.registerPowerTarget(deadEntity, target, boardWithDeadEntity, null, null);\r\n\t// }\r\n};\r\n\r\n// Some minions like Icesnarl can revive themselves when killing a minion, so it needs to be handled before\r\n// we actually make the minion die\r\nexport const handleWheneverMinionsKillEffect = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\thandleWheneverMinionsKillEffectForBoard(board, hero, otherBoard, otherHero, gameState);\r\n\t// It's called once for each board already, so don't duplicate it here\r\n\t// handleWheneverMinionsKillEffectForBoard(otherBoard, otherHero, board, hero, gameState);\r\n};\r\n\r\nconst handleWheneverMinionsKillEffectForBoard = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].health <= 0 || board[i].definitelyDead) {\r\n\t\t\tconst futureDeadEntity = board[i];\r\n\t\t\tconst killer = futureDeadEntity.lastAffectedByEntity;\r\n\t\t\tif (!killer) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Killed an enemy minion\r\n\t\t\tif (killer.friendly !== futureDeadEntity.friendly) {\r\n\t\t\t\tfor (const heroPower of otherHero.heroPowers) {\r\n\t\t\t\t\t// Can't be used to resurrect a dead minion\r\n\t\t\t\t\t// https://replays.firestoneapp.com/?reviewId=d1fffee8-0bc3-40f5-9a59-85eef8367095&turn=11&action=4\r\n\t\t\t\t\tif (heroPower.cardId === CardIds.Rokara_GloryOfCombat && !isDead(killer)) {\r\n\t\t\t\t\t\tmodifyStats(killer, otherHero, 1, 0, otherBoard, otherHero, gameState);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Icesnarl the Mighty\r\n\t\t\t\totherBoard\r\n\t\t\t\t\t.filter(\r\n\t\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\t\te.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy ||\r\n\t\t\t\t\t\t\te.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy_G,\r\n\t\t\t\t\t)\r\n\t\t\t\t\t// Can't be revived\r\n\t\t\t\t\t// 33.6 https://replays.firestoneapp.com/?reviewId=608ddffb-6c04-4def-a8de-fd39228f4de4&turn=11&action=4\r\n\t\t\t\t\t// Maybe should move to an \"after kill\" phase, where dead minions are already dead?\r\n\t\t\t\t\t.filter((e) => e.health > 0 && !e.definitelyDead)\r\n\t\t\t\t\t.forEach((icesnarl) => {\r\n\t\t\t\t\t\tconst mult = icesnarl.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy_G ? 2 : 1;\r\n\t\t\t\t\t\tmodifyStats(icesnarl, icesnarl, 0, 3 * mult, board, hero, gameState);\r\n\t\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const handleAfterMinionKillsEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// Moved to \"whenever kills\", as these can revive the minion that kills\r\n\t// const killer = deadEntity.lastAffectedByEntity;\r\n\t// if (!killer) {\r\n\t// \treturn;\r\n\t// }\r\n\t// // Killed an enemy minion\r\n\t// if (killer.friendly !== deadEntity.friendly) {\r\n\t// }\r\n};\r\n\r\nexport const applyAfterMinionDiesEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.DEMON, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplySoulJugglerEffect(boardWithDeadEntity, boardWithDeadEntityHero, otherBoard, otherBoardHero, gameState);\r\n\t}\r\n};\r\n\r\nexport const applyWheneverMinionDiesEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// console.log('applying minion death effect', stringifySimpleCard(deadEntity, allCards));\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.BEAST, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplyScavengingHyenaEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.MECH, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplyJunkbotEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.MURLOC, gameState.anomalies, gameState.allCards)) {\r\n\t\tremoveOldMurkEyeAttack(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\tremoveOldMurkEyeAttack(otherBoard, otherBoardHero, gameState);\r\n\t}\r\n\tif (hasCorrectTribe(deadEntity, boardWithDeadEntityHero, Race.ELEMENTAL, gameState.anomalies, gameState.allCards)) {\r\n\t\tapplyMossOfTheSchlossEffect(deadEntity, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\r\n\tif (deadEntity.taunt) {\r\n\t\tapplyBristlemaneScrapsmithEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\tapplyQirajiHarbringerEffect(boardWithDeadEntity, boardWithDeadEntityHero, deadEntityIndexFromRight, gameState);\r\n\t}\r\n\r\n\tif (\r\n\t\tdeadEntity.cardId === CardIds.EternalKnight_BG25_008 ||\r\n\t\tdeadEntity.cardId === CardIds.EternalKnight_BG25_008_G\r\n\t) {\r\n\t\tapplyEternalKnightEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t}\r\n\r\n\t// Putricide-only\r\n\tboardWithDeadEntity\r\n\t\t.filter((e) => e.additionalCards?.includes(CardIds.FlesheatingGhoulLegacy_BG26_tt_004))\r\n\t\t.forEach((e) => {\r\n\t\t\tmodifyStats(e, null, 1, 0, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t});\r\n\r\n\tapplyRotHideGnollEffect(boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\r\n\t// Overkill\r\n\tif (\r\n\t\tdeadEntity.health < 0 &&\r\n\t\tgameState.sharedState.currentAttackerEntityId != null &&\r\n\t\tgameState.sharedState.currentAttackerEntityId === deadEntity.lastAffectedByEntity?.entityId\r\n\t) {\r\n\t\t// if (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlame_BGS_032) {\r\n\t\t// \tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t// \tif (targets.length > 0) {\r\n\t\t// \t\tconst target = targets[0];\r\n\t\t// \t\tdealDamageToMinion(\r\n\t\t// \t\t\ttarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\t3,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tgameState,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.HeraldOfFlame_TB_BaconUps_103) {\r\n\t\t// \tconst targets = boardWithDeadEntity.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\t\t// \tif (targets.length > 0) {\r\n\t\t// \t\tconst target = targets[0];\r\n\t\t// \t\tdealDamageToMinion(\r\n\t\t// \t\t\ttarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\t6,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tgameState,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// }\r\n\t\t// else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental && deadEntity.lastAffectedByEntity.attacking) {\r\n\t\t// \t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElemental) {\r\n\t\t// \t// console.log('applying WildfireElemental effect', stringifySimple(boardWithDeadEntity, allCards));\r\n\t\t// \tconst excessDamage = -deadEntity.health;\r\n\t\t// \t// Prevent propagation of the effect\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking = false;\r\n\t\t// \tconst neighbours = getNeighbours(boardWithDeadEntity, null, boardWithDeadEntity.length - deadEntityIndexFromRight);\r\n\t\t// \t// console.log('neighbours', stringifySimple(neighbours, allCards));\r\n\t\t// \tif (neighbours.length > 0) {\r\n\t\t// \t\tconst randomTarget = neighbours[Math.floor(Math.random() * neighbours.length)];\r\n\t\t// \t\tdealDamageToEnemy(\r\n\t\t// \t\t\trandomTarget,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\texcessDamage,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tallCards,\r\n\t\t// \t\t\tcardsData,\r\n\t\t// \t\t\tsharedState,\r\n\t\t// \t\t\tspectator,\r\n\t\t// \t\t);\r\n\t\t// \t}\r\n\t\t// } else if (\r\n\t\t// \tdeadEntity.lastAffectedByEntity.cardId === CardIds.WildfireElementalBattlegrounds &&\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking\r\n\t\t// ) {\r\n\t\t// \tconst excessDamage = -deadEntity.health;\r\n\t\t// \tdeadEntity.lastAffectedByEntity.attacking = false;\r\n\t\t// \tconst neighbours = getNeighbours(boardWithDeadEntity, null, boardWithDeadEntity.length - deadEntityIndexFromRight);\r\n\t\t// \tneighbours.forEach((neighbour) =>\r\n\t\t// \t\tdealDamageToEnemy(\r\n\t\t// \t\t\tneighbour,\r\n\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t// \t\t\texcessDamage,\r\n\t\t// \t\t\totherBoard,\r\n\t\t// \t\t\totherBoardHero,\r\n\t\t// \t\t\tallCards,\r\n\t\t// \t\t\tcardsData,\r\n\t\t// \t\t\tsharedState,\r\n\t\t// \t\t\tspectator,\r\n\t\t// \t\t),\r\n\t\t// \t);\r\n\t\t// }\r\n\t\tif (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn_TRL_232) {\r\n\t\t\tconst newEntities = spawnEntities(\r\n\t\t\t\tCardIds.IronhideDirehorn_IronhideRuntToken_TRL_232t,\r\n\t\t\t\t1,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t\t!deadEntity.friendly,\r\n\t\t\t\tfalse,\r\n\t\t\t);\r\n\t\t\totherBoard.splice(otherBoard.length - deadEntityIndexFromRight, 0, ...newEntities);\r\n\t\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.IronhideDirehorn_TB_BaconUps_051) {\r\n\t\t\t// \tconst newEntities = spawnEntities(\r\n\t\t\t// \t\tCardIds.IronhideDirehorn_IronhideRuntToken_TB_BaconUps_051t,\r\n\t\t\t// \t\t1,\r\n\t\t\t// \t\totherBoard,\r\n\t\t\t// \t\totherBoardHero,\r\n\t\t\t// \t\tboardWithDeadEntity,\r\n\t\t\t// \t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\tgameState,\r\n\t\t\t// \t\t!deadEntity.friendly,\r\n\t\t\t// \t\tfalse,\r\n\t\t\t// \t);\r\n\t\t\t// \totherBoard.splice(otherBoard.length - deadEntityIndexFromRight, 0, ...newEntities);\r\n\t\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath_BGS_080) {\r\n\t\t\t// \tconst otherPirates = otherBoard\r\n\t\t\t// \t\t.filter((entity) =>\r\n\t\t\t// \t\t\thasCorrectTribe(\r\n\t\t\t// \t\t\t\tentity,\r\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\t\tRace.PIRATE,\r\n\t\t\t// \t\t\t\tgameState.anomalies,\r\n\t\t\t// \t\t\t\tgameState.allCards,\r\n\t\t\t// \t\t\t),\r\n\t\t\t// \t\t)\r\n\t\t\t// \t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\t// \totherPirates.forEach((pirate) => {\r\n\t\t\t// \t\tmodifyStats(\r\n\t\t\t// \t\t\tpirate,\r\n\t\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t// \t\t\t2,\r\n\t\t\t// \t\t\t2,\r\n\t\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\tgameState,\r\n\t\t\t// \t\t);\r\n\t\t\t// \t});\r\n\t\t\t// } else if (deadEntity.lastAffectedByEntity.cardId === CardIds.SeabreakerGoliath_TB_BaconUps_142) {\r\n\t\t\t// \tconst otherPirates = otherBoard\r\n\t\t\t// \t\t.filter((entity) =>\r\n\t\t\t// \t\t\thasCorrectTribe(\r\n\t\t\t// \t\t\t\tentity,\r\n\t\t\t// \t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\t\tRace.PIRATE,\r\n\t\t\t// \t\t\t\tgameState.anomalies,\r\n\t\t\t// \t\t\t\tgameState.allCards,\r\n\t\t\t// \t\t\t),\r\n\t\t\t// \t\t)\r\n\t\t\t// \t\t.filter((entity) => entity.entityId !== deadEntity.lastAffectedByEntity.entityId);\r\n\t\t\t// \totherPirates.forEach((pirate) => {\r\n\t\t\t// \t\tmodifyStats(\r\n\t\t\t// \t\t\tpirate,\r\n\t\t\t// \t\t\tdeadEntity.lastAffectedByEntity,\r\n\t\t\t// \t\t\t4,\r\n\t\t\t// \t\t\t4,\r\n\t\t\t// \t\t\tboardWithDeadEntity,\r\n\t\t\t// \t\t\tboardWithDeadEntityHero,\r\n\t\t\t// \t\t\tgameState,\r\n\t\t\t// \t\t);\r\n\t\t\t// \t});\r\n\t\t}\r\n\t}\r\n};\r\n\r\n/** @deprecated */\r\nexport const dealDamageToAllMinions = (\r\n\tboard1: BoardEntity[],\r\n\tboard1Hero: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tboard2Hero: BgsPlayerEntity,\r\n\tdamageSource: BoardEntity,\r\n\tdamageDealt: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (board1.length === 0 && board2.length === 0) {\r\n\t\treturn;\r\n\t}\r\n\tfor (let i = 0; i < board1.length; i++) {\r\n\t\tdealDamageToMinion(board1[i], board1, board1Hero, damageSource, damageDealt, board2, board2Hero, gameState);\r\n\t}\r\n\tfor (let i = 0; i < board2.length; i++) {\r\n\t\tdealDamageToMinion(board2[i], board2, board2Hero, damageSource, damageDealt, board1, board1Hero, gameState);\r\n\t}\r\n};\r\n\r\nexport const applySoulJugglerEffect = (\r\n\tboardWithJugglers: BoardEntity[],\r\n\tboardWithJugglersHero: BgsPlayerEntity,\r\n\tboardToAttack: BoardEntity[],\r\n\tboardToAttackHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tif (boardWithJugglers.length === 0 && boardToAttack.length === 0) {\r\n\t\treturn;\r\n\t\t// return [boardWithJugglers, boardToAttack];\r\n\t}\r\n\tconst jugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler_BGS_002);\r\n\tfor (const juggler of jugglers) {\r\n\t\tconst target = getRandomMinionWithHighestHealth(boardToAttack);\r\n\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\tjuggler,\r\n\t\t\ttarget,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tboardToAttackHero,\r\n\t\t);\r\n\t\tdealDamageToMinion(\r\n\t\t\ttarget,\r\n\t\t\tboardToAttack,\r\n\t\t\tboardToAttackHero,\r\n\t\t\tjuggler,\r\n\t\t\t4,\r\n\t\t\tboardWithJugglers,\r\n\t\t\tboardWithJugglersHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\tconst goldenJugglers = boardWithJugglers.filter((entity) => entity.cardId === CardIds.SoulJuggler_TB_BaconUps_075);\r\n\tfor (const juggler of goldenJugglers) {\r\n\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\tconst target = getRandomMinionWithHighestHealth(boardToAttack);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tjuggler,\r\n\t\t\t\ttarget,\r\n\t\t\t\tboardWithJugglers,\r\n\t\t\t\tboardWithJugglersHero,\r\n\t\t\t\tboardToAttackHero,\r\n\t\t\t);\r\n\t\t\tdealDamageToMinion(\r\n\t\t\t\ttarget,\r\n\t\t\t\tboardToAttack,\r\n\t\t\t\tboardToAttackHero,\r\n\t\t\t\tjuggler,\r\n\t\t\t\t4,\r\n\t\t\t\tboardWithJugglers,\r\n\t\t\t\tboardWithJugglersHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\t// processMinionDeath(\r\n\t// \tboardWithJugglers,\r\n\t// \tboardWithJugglersHero,\r\n\t// \tboardToAttack,\r\n\t// \tboardToAttackHero,\r\n\t// \tallCards,\r\n\t// \tcardsData,\r\n\t// \tsharedState,\r\n\t// \tspectator,\r\n\t// );\r\n};\r\n\r\nconst applyScavengingHyenaEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// const copy = [...board];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.ScavengingHyenaLegacy_BG_EX1_531) {\r\n\t\t\tmodifyStats(board[i], null, 2, 1, board, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t} else if (board[i].cardId === CardIds.ScavengingHyenaLegacy_TB_BaconUps_043) {\r\n\t\t\tmodifyStats(board[i], null, 4, 2, board, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyEternalKnightEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (\r\n\t\t\tboard[i].cardId === CardIds.EternalKnight_BG25_008 ||\r\n\t\t\tboard[i].cardId === CardIds.EternalKnight_BG25_008_G\r\n\t\t) {\r\n\t\t\tconst multiplier = board[i].cardId === CardIds.EternalKnight_BG25_008_G ? 2 : 1;\r\n\t\t\tmodifyStats(\r\n\t\t\t\tboard[i],\r\n\t\t\t\tnull,\r\n\t\t\t\tmultiplier * eternalKnightAttack,\r\n\t\t\t\tmultiplier * eternalKnightHealth,\r\n\t\t\t\tboard,\r\n\t\t\t\thero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyRotHideGnollEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.RotHideGnoll_BG25_013 || board[i].cardId === CardIds.RotHideGnoll_BG25_013_G) {\r\n\t\t\tconst multiplier = board[i].cardId === CardIds.RotHideGnoll_BG25_013_G ? 2 : 1;\r\n\t\t\tmodifyStats(board[i], null, multiplier * 1, 0, board, hero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, null, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyBristlemaneScrapsmithEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardPlayerEntity: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (\r\n\t\t\tboard[i].cardId === CardIds.BristlemaneScrapsmith_BG24_707 ||\r\n\t\t\tboard[i].cardId === CardIds.BristlemaneScrapsmith_BG24_707_G\r\n\t\t) {\r\n\t\t\tconst cardsToAdd = Array(CardIds.BristlemaneScrapsmith_BG24_707_G ? 2 : 1).fill(CardIds.BloodGem);\r\n\t\t\taddCardsInHand(boardPlayerEntity, board, cardsToAdd, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(board[i], board[i], board, boardPlayerEntity, null);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyMossOfTheSchlossEffect = (\r\n\tdeadEntity: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tboard\r\n\t\t.filter(\r\n\t\t\t(e) => e.cardId === CardIds.MossOfTheSchloss_BG30_111 || e.cardId === CardIds.MossOfTheSchloss_BG30_111_G,\r\n\t\t)\r\n\t\t.filter((e) => e.abiityChargesLeft > 0)\r\n\t\t.forEach((entity) => {\r\n\t\t\tmodifyStats(entity, null, deadEntity.maxAttack, deadEntity.maxHealth, board, hero, gameState);\r\n\t\t\tentity.abiityChargesLeft--;\r\n\t\t\tgameState.spectator.registerPowerTarget(entity, entity, board, null, null);\r\n\t\t});\r\n};\r\n\r\nconst applyJunkbotEffect = (board: BoardEntity[], hero: BgsPlayerEntity, gameState: FullGameState): void => {\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].cardId === CardIds.Junkbot_GVG_106) {\r\n\t\t\tmodifyStats(board[i], board[i], 2, 2, board, hero, gameState);\r\n\t\t\t// } else if (board[i].cardId === CardIds.Junkbot_TB_BaconUps_046) {\r\n\t\t\t// \tmodifyStats(board[i], board[i], 4, 4, board, hero, gameState);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyQirajiHarbringerEffect = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\t// const qiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger_BGS_112);\r\n\t// const goldenQiraji = board.filter((entity) => entity.cardId === CardIds.QirajiHarbinger_TB_BaconUps_303);\r\n\t// // TODO: if reactivated, properly apply buffs one by one, instead of all together\r\n\t// if (qiraji.length + goldenQiraji.length > 0) {\r\n\t// \tconst neighbours = getNeighbours(board, null, deadEntityIndexFromRight);\r\n\t// \tconst buff = 2 * qiraji.length + 4 * goldenQiraji.length;\r\n\t// \tneighbours.forEach((entity) => {\r\n\t// \t\tmodifyStats(entity, null, buff, buff, board, hero, gameState);\r\n\t// \t});\r\n\t// }\r\n};\r\n\r\nexport const rememberDeathrattles = (\r\n\tfish: BoardEntity,\r\n\tinputDeadEntities: readonly BoardEntity[],\r\n\tcardsData: CardsData,\r\n\tallCards: AllCardsService,\r\n\tsharedState: SharedState,\r\n): void => {\r\n\tconst deadEntities = inputDeadEntities.filter((e) => !isFish(e));\r\n\tif (!deadEntities?.length) {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// Some infinite loops going on?\r\n\tif (fish.rememberedDeathrattles?.length > 100) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst debug = deadEntities.some((e) => e.cardId === CardIds.CorruptedBristler_BG32_431);\r\n\r\n\tconst validDeathrattles: BoardEnchantment[] = deadEntities\r\n\t\t.filter((entity) => allCards.getCard(entity.cardId).mechanics?.includes(GameTag[GameTag.DEATHRATTLE]))\r\n\t\t.filter((e) => !DEATHRATTLES_REQUIRE_MEMORY.includes(e.cardId as CardIds) || e.memory)\r\n\t\t.map((entity) => {\r\n\t\t\tconst result: BoardEnchantment = {\r\n\t\t\t\tcardId: entity.cardId,\r\n\t\t\t\trepeats: 1,\r\n\t\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t\t\tmemory: entity.memory,\r\n\t\t\t\ttagScriptDataNum1: entity.scriptDataNum1,\r\n\t\t\t\ttagScriptDataNum2: entity.scriptDataNum2,\r\n\t\t\t};\r\n\t\t\treturn result;\r\n\t\t});\r\n\tconst validEnchantments: BoardEnchantment[] = deadEntities\r\n\t\t.map((entity) => entity.enchantments)\r\n\t\t.reduce((a, b) => a.concat(b), [])\r\n\t\t.flatMap((enchantment) => {\r\n\t\t\tconst result: BoardEnchantment = {\r\n\t\t\t\tcardId: enchantment.cardId,\r\n\t\t\t\trepeats: enchantment.repeats ?? 1,\r\n\t\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t\t};\r\n\t\t\treturn result;\r\n\t\t})\r\n\t\t.filter((enchantment) => isValidDeathrattleEnchantment(enchantment.cardId));\r\n\t// Multiple fish\r\n\tconst deadEntityRememberedDeathrattles =\r\n\t\tdeadEntities\r\n\t\t\t.filter((e) => !!e.rememberedDeathrattles?.length)\r\n\t\t\t// If the fish has reborn, it will inherit its own Deathrattles, and we don't want that\r\n\t\t\t.filter((e) => e.entityId !== fish.rebornFromEntityId)\r\n\t\t\t.filter((e) => !DEATHRATTLES_REQUIRE_MEMORY.includes(e.cardId as CardIds) || e.memory)\r\n\t\t\t.flatMap((e) => e.rememberedDeathrattles) ?? [];\r\n\tconst newDeathrattles = [...validDeathrattles, ...validEnchantments, ...deadEntityRememberedDeathrattles];\r\n\r\n\tif (newDeathrattles.length > 0) {\r\n\t\t// Order is important - the DR are triggered in the order d the minions have died\r\n\t\t// The \"golden\" part is handled at the card level for the other non-fish cards, like Piloted Whirl-o-Tron\r\n\t\tif (isFish(fish) && isGolden(fish.cardId, allCards)) {\r\n\t\t\t// https://stackoverflow.com/questions/33305152/how-to-duplicate-elements-in-a-js-array\r\n\t\t\tconst doubleDr = newDeathrattles.reduce((res, current) => res.concat([current, current]), []);\r\n\t\t\tfish.rememberedDeathrattles = [...(fish.rememberedDeathrattles || []), ...doubleDr];\r\n\t\t} else {\r\n\t\t\tfish.rememberedDeathrattles = [...(fish.rememberedDeathrattles || []), ...newDeathrattles];\r\n\t\t}\r\n\r\n\t\tif (newDeathrattles.some((d) => d.cardId?.startsWith(CardIds.Leapfrogger_BG21_000))) {\r\n\t\t\t// Not sure exactly why, but if a leapfrogger dies first, then a manasaber,\r\n\t\t\t// when the fish dies, the manasaber's effect (spawning tokens) is triggered first\r\n\t\t\t// https://replays.firestoneapp.com/?reviewId=521733fb-8ba1-4663-9a87-3da58e8a09c8&turn=21&action=3\r\n\t\t\t// HACK: So I will hardcode a rule for now to put leapfrogger effects last\r\n\t\t\tconst leapfroggerDeathrattles = groupLeapfroggerDeathrattles(fish.rememberedDeathrattles);\r\n\t\t\tfish.rememberedDeathrattles = [\r\n\t\t\t\t...fish.rememberedDeathrattles.filter((d) => !d.cardId?.startsWith(CardIds.Leapfrogger_BG21_000)),\r\n\t\t\t\t...leapfroggerDeathrattles,\r\n\t\t\t];\r\n\t\t}\r\n\t}\r\n\t// console.debug(\r\n\t// \t'remembered',\r\n\t// \tfish.cardId,\r\n\t// \tfish.entityId,\r\n\t// \tfish.rememberedDeathrattles.map((d) => ({\r\n\t// \t\tcardId: d.cardId,\r\n\t// \t\tname: allCards.getCard(d.cardId)?.name,\r\n\t// \t\t// repeats: d.repeats,\r\n\t// \t\t// timing: d.timing,\r\n\t// \t})),\r\n\t// );\r\n};\r\n\r\nconst removeOldMurkEyeAttack = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\t// const murkeyes = boardWithDeadEntity.filter(\r\n\t// \t(entity) => entity.cardId === CardIds.OldMurkEyeLegacy || entity.cardId === CardIds.OldMurkEyeVanilla,\r\n\t// );\r\n\t// const goldenMurkeyes = boardWithDeadEntity.filter((entity) => entity.cardId === CardIds.OldMurkEye);\r\n\t// murkeyes.forEach((entity) => {\r\n\t// \tmodifyStats(entity, null, -1, 0, boardWithDeadEntity, hero, gameState);\r\n\t// });\r\n\t// goldenMurkeyes.forEach((entity) => {\r\n\t// \tmodifyStats(entity, null, -2, 0, boardWithDeadEntity, hero, gameState);\r\n\t// });\r\n};\r\n"]}
@@ -76,7 +76,7 @@ const handlePreCombatHeroPowersForPlayer = (input) => {
76
76
  return input.currentAttacker;
77
77
  }
78
78
  for (const heroPower of input.playerEntity.heroPowers) {
79
- (0, soc_action_processor_1.performStartOfCombatAction)(heroPower.cardId, input.playerEntity, input, true, 'pre-combat');
79
+ (0, soc_action_processor_1.performStartOfCombatAction)(heroPower.cardId, heroPower, input, true, 'pre-combat');
80
80
  }
81
81
  }
82
82
  return input.currentAttacker;
@@ -1 +1 @@
1
- {"version":3,"file":"soc-pre-combat-hero-power.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-pre-combat-hero-power.ts"],"names":[],"mappings":";;;AAIA,4DAA8D;AAC9D,iEAAoE;AAG7D,MAAM,yBAAyB,GAAG,CACxC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IACX,IAAI,sBAAsB,GAAG,WAAW,CAAC,MAAM,CAAC;IAChD,IAAI,wBAAwB,GAAG,aAAa,CAAC,MAAM,CAAC;IACpD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC7B,IAAI,MAAM,GAAG,GAAG,E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,OAAO,KAAK,CAAC,eAAe,CAAC;AAC9B,CAAC,CAAC","sourcesContent":["import { CardIds } from '../../services/card-ids';\nimport { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { FullGameState } from '../internal-game-state';\r\nimport { handleSummonsWhenSpace } from '../summon-when-space';\r\nimport { performStartOfCombatAction } from './soc-action-processor';\r\nimport { SoCInput } from './start-of-combat-input';\r\n\r\nexport const handlePreCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tlet initialPlayerBoardSize = playerBoard.length;\r\n\tlet initialOpponentBoardSize = opponentBoard.length;\r\n\tconst random = Math.random();\r\n\tif (random < 0.5) {\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialPlayerBoardSize = playerBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialOpponentBoardSize = opponentBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t} else {\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialOpponentBoardSize = opponentBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialPlayerBoardSize = playerBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t}\r\n\t// Ozumat's Tentaclecan cause the first player to be recomputed\r\n\t// https://replays.firestoneapp.com/?reviewId=f15c90de-8b3c-4017-960d-365fe09eb7ab&turn=5&action=1\r\n\tif (playerBoard.length !== initialPlayerBoardSize || opponentBoard.length !== initialOpponentBoardSize) {\r\n\t\tcurrentAttacker =\r\n\t\t\tplayerBoard.length > opponentBoard.length\r\n\t\t\t\t? 0\r\n\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t? 1\r\n\t\t\t\t: Math.round(Math.random());\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePreCombatHeroPowersForPlayer = (input: SoCInput): number => {\r\n\tconst loops = input.playerEntity.trinkets?.some((t) => t.cardId === CardIds.ValdrakkenWindChimes_BG32_MagicItem_365)\r\n\t\t? 2\r\n\t\t: 1;\r\n\tfor (let i = 0; i < loops; i++) {\r\n\t\tif (input.playerEntity.startOfCombatDone || input.playerEntity.hpLeft <= 0) {\r\n\t\t\treturn input.currentAttacker;\r\n\t\t}\r\n\r\n\t\tfor (const heroPower of input.playerEntity.heroPowers) {\r\n\t\t\tperformStartOfCombatAction(heroPower.cardId, input.playerEntity, input, true, 'pre-combat');\r\n\t\t}\r\n\t}\r\n\r\n\treturn input.currentAttacker;\r\n};\r\n"]}
1
+ {"version":3,"file":"soc-pre-combat-hero-power.js","sourceRoot":"","sources":["../../../src/simulation/start-of-combat/soc-pre-combat-hero-power.ts"],"names":[],"mappings":";;;AAIA,4DAA8D;AAC9D,iEAAoE;AAG7D,MAAM,yBAAyB,GAAG,CACxC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,SAAwB,EACf,EAAE;IACX,IAAI,sBAAsB,GAAG,WAAW,CAAC,MAAM,CAAC;IAChD,IAAI,wBAAwB,GAAG,aAAa,CAAC,MAAM,CAAC;IACpD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC7B,IAAI,MAAM,GAAG,GAAG,EAAE;QACjB,eAAe,GAAG,kCAAkC,CAAC;YACpD,YAAY,EAAE,YAAY;YAC1B,WAAW,EAAE,WAAW;YACxB,cAAc,EAAE,cAAc;YAC9B,aAAa,EAAE,aAAa;YAC5B,eAAe;YACf,gBAAgB,EAAE,IAAI;YACtB,SAAS;SACT,CAAC,CAAC;QACH,sBAAsB,GAAG,WAAW,CAAC,MAAM,CAAC;QAC5C,IAAA,0CAAsB,EAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;QAC5F,eAAe,GAAG,kCAAkC,CAAC;YACpD,YAAY,EAAE,cAAc;YAC5B,WAAW,EAAE,aAAa;YAC1B,cAAc,EAAE,YAAY;YAC5B,aAAa,EAAE,WAAW;YAC1B,eAAe;YACf,gBAAgB,EAAE,KAAK;YACvB,SAAS;SACT,CAAC,CAAC;QACH,wBAAwB,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AEF,MAAM,kCAAkC,GAAG,CAAC,KAAe,EAAU,EAAE;;IACtE,MAAM,KAAK,GAAG,CAAA,MAAA,KAAK,CAAC,YAAY,CAAC,QAAQ,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,yBAAoD,CAAC;QACnH,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,CAAC,CAAC;IACL,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;QAC/B,IAAI,KAAK,CAAC,YAAY,CAAC,iBAAiB,IAAI,KAAK,CAAC,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE;YAC3E,OAAO,KAAK,CAAC,eAAe,CAAC;SAC7B;QAED,KAAK,MAAM,SAAS,IAAI,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE;YACtD,IAAA,iDAA0B,EAAC,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;SACnF;KACD;IAED,OAAO,KAAK,CAAC,eAAe,CAAC;AAC9B,CAAC,CAAC","sourcesContent":["import { BgsPlayerEntity } from '../../bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { CardIds } from '../../services/card-ids';\r\nimport { FullGameState } from '../internal-game-state';\r\nimport { handleSummonsWhenSpace } from '../summon-when-space';\r\nimport { performStartOfCombatAction } from './soc-action-processor';\r\nimport { SoCInput } from './start-of-combat-input';\r\n\r\nexport const handlePreCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tgameState: FullGameState,\r\n): number => {\r\n\tlet initialPlayerBoardSize = playerBoard.length;\r\n\tlet initialOpponentBoardSize = opponentBoard.length;\r\n\tconst random = Math.random();\r\n\tif (random < 0.5) {\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialPlayerBoardSize = playerBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialOpponentBoardSize = opponentBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t} else {\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: opponentEntity,\r\n\t\t\tplayerBoard: opponentBoard,\r\n\t\t\topponentEntity: playerEntity,\r\n\t\t\topponentBoard: playerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: false,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialOpponentBoardSize = opponentBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t\tcurrentAttacker = handlePreCombatHeroPowersForPlayer({\r\n\t\t\tplayerEntity: playerEntity,\r\n\t\t\tplayerBoard: playerBoard,\r\n\t\t\topponentEntity: opponentEntity,\r\n\t\t\topponentBoard: opponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tplayerIsFriendly: true,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t\tinitialPlayerBoardSize = playerBoard.length;\r\n\t\thandleSummonsWhenSpace(playerBoard, playerEntity, opponentBoard, opponentEntity, gameState);\r\n\t}\r\n\t// Ozumat's Tentaclecan cause the first player to be recomputed\r\n\t// https://replays.firestoneapp.com/?reviewId=f15c90de-8b3c-4017-960d-365fe09eb7ab&turn=5&action=1\r\n\tif (playerBoard.length !== initialPlayerBoardSize || opponentBoard.length !== initialOpponentBoardSize) {\r\n\t\tcurrentAttacker =\r\n\t\t\tplayerBoard.length > opponentBoard.length\r\n\t\t\t\t? 0\r\n\t\t\t\t: opponentBoard.length > playerBoard.length\r\n\t\t\t\t? 1\r\n\t\t\t\t: Math.round(Math.random());\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePreCombatHeroPowersForPlayer = (input: SoCInput): number => {\r\n\tconst loops = input.playerEntity.trinkets?.some((t) => t.cardId === CardIds.ValdrakkenWindChimes_BG32_MagicItem_365)\r\n\t\t? 2\r\n\t\t: 1;\r\n\tfor (let i = 0; i < loops; i++) {\r\n\t\tif (input.playerEntity.startOfCombatDone || input.playerEntity.hpLeft <= 0) {\r\n\t\t\treturn input.currentAttacker;\r\n\t\t}\r\n\r\n\t\tfor (const heroPower of input.playerEntity.heroPowers) {\r\n\t\t\tperformStartOfCombatAction(heroPower.cardId, heroPower, input, true, 'pre-combat');\r\n\t\t}\r\n\t}\r\n\r\n\treturn input.currentAttacker;\r\n};\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestone-hs/simulate-bgs-battle",
3
- "version": "1.1.681",
3
+ "version": "1.1.682",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "lint": "eslint --color --fix --ext .ts .",