@firestone-hs/simulate-bgs-battle 1.1.467 → 1.1.470

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.
Files changed (76) hide show
  1. package/dist/bgs-player-entity.d.ts +12 -1
  2. package/dist/bgs-player-entity.js.map +1 -1
  3. package/dist/cards/cards-data.d.ts +0 -1
  4. package/dist/cards/cards-data.js +18 -50
  5. package/dist/cards/cards-data.js.map +1 -1
  6. package/dist/divine-shield.d.ts +6 -0
  7. package/dist/divine-shield.js +100 -0
  8. package/dist/divine-shield.js.map +1 -0
  9. package/dist/input-sanitation.js +3 -2
  10. package/dist/input-sanitation.js.map +1 -1
  11. package/dist/simulate-bgs-battle.js +3 -0
  12. package/dist/simulate-bgs-battle.js.map +1 -1
  13. package/dist/simulation/add-minion-to-board.d.ts +2 -5
  14. package/dist/simulation/add-minion-to-board.js +172 -45
  15. package/dist/simulation/add-minion-to-board.js.map +1 -1
  16. package/dist/simulation/attack.js +25 -59
  17. package/dist/simulation/attack.js.map +1 -1
  18. package/dist/simulation/auras.d.ts +2 -0
  19. package/dist/simulation/auras.js +60 -23
  20. package/dist/simulation/auras.js.map +1 -1
  21. package/dist/simulation/avenge.js +36 -7
  22. package/dist/simulation/avenge.js.map +1 -1
  23. package/dist/simulation/battlecries.js +53 -12
  24. package/dist/simulation/battlecries.js.map +1 -1
  25. package/dist/simulation/blood-gems.d.ts +2 -2
  26. package/dist/simulation/blood-gems.js +28 -5
  27. package/dist/simulation/blood-gems.js.map +1 -1
  28. package/dist/simulation/cards-in-hand.js +1 -1
  29. package/dist/simulation/cards-in-hand.js.map +1 -1
  30. package/dist/simulation/damage-effects.js +14 -2
  31. package/dist/simulation/damage-effects.js.map +1 -1
  32. package/dist/simulation/damage-to-hero.d.ts +4 -0
  33. package/dist/simulation/damage-to-hero.js +8 -0
  34. package/dist/simulation/damage-to-hero.js.map +1 -0
  35. package/dist/simulation/death-effects.js +15 -0
  36. package/dist/simulation/death-effects.js.map +1 -1
  37. package/dist/simulation/deathrattle-effects.js +58 -27
  38. package/dist/simulation/deathrattle-effects.js.map +1 -1
  39. package/dist/simulation/deathrattle-orchestration.js +3 -3
  40. package/dist/simulation/deathrattle-orchestration.js.map +1 -1
  41. package/dist/simulation/deathrattle-spawns.js +32 -5
  42. package/dist/simulation/deathrattle-spawns.js.map +1 -1
  43. package/dist/simulation/frenzy.js +2 -2
  44. package/dist/simulation/frenzy.js.map +1 -1
  45. package/dist/simulation/minion-death.d.ts +1 -1
  46. package/dist/simulation/minion-death.js +47 -9
  47. package/dist/simulation/minion-death.js.map +1 -1
  48. package/dist/simulation/on-attack.js +11 -4
  49. package/dist/simulation/on-attack.js.map +1 -1
  50. package/dist/simulation/on-being-attacked.js +3 -2
  51. package/dist/simulation/on-being-attacked.js.map +1 -1
  52. package/dist/simulation/reborn.js +9 -0
  53. package/dist/simulation/reborn.js.map +1 -1
  54. package/dist/simulation/remove-minion-from-board.d.ts +2 -1
  55. package/dist/simulation/remove-minion-from-board.js +9 -7
  56. package/dist/simulation/remove-minion-from-board.js.map +1 -1
  57. package/dist/simulation/spawn-fail.d.ts +4 -0
  58. package/dist/simulation/spawn-fail.js +28 -0
  59. package/dist/simulation/spawn-fail.js.map +1 -0
  60. package/dist/simulation/spawns.js +2 -4
  61. package/dist/simulation/spawns.js.map +1 -1
  62. package/dist/simulation/spectator/spectator.d.ts +2 -2
  63. package/dist/simulation/spectator/spectator.js.map +1 -1
  64. package/dist/simulation/start-of-combat.js +253 -44
  65. package/dist/simulation/start-of-combat.js.map +1 -1
  66. package/dist/simulation/stats.js +2 -2
  67. package/dist/simulation/stats.js.map +1 -1
  68. package/dist/simulation/summon-when-space.js +39 -0
  69. package/dist/simulation/summon-when-space.js.map +1 -1
  70. package/dist/simulation/utils/golden.d.ts +1 -1
  71. package/dist/simulation/utils/golden.js +2 -2
  72. package/dist/simulation/utils/golden.js.map +1 -1
  73. package/dist/utils.d.ts +7 -8
  74. package/dist/utils.js +71 -52
  75. package/dist/utils.js.map +1 -1
  76. package/package.json +2 -2
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.performStartOfCombatMinionsForPlayer = exports.getHeroPowerForHero = exports.handleStartOfCombatHeroPowers = exports.handleIllidanHeroPowers = exports.handleStartOfCombat = void 0;
4
4
  const reference_data_1 = require("@firestone-hs/reference-data");
5
+ const divine_shield_1 = require("../divine-shield");
5
6
  const utils_1 = require("../services/utils");
6
7
  const utils_2 = require("../utils");
7
8
  const add_minion_to_board_1 = require("./add-minion-to-board");
@@ -189,10 +190,198 @@ const handleStartOfCombatAnomalies = (playerEntity, playerBoard, opponentEntity,
189
190
  return currentAttacker;
190
191
  };
191
192
  const handleStartOfCombatQuestRewardsForPlayer = (playerEntity, playerBoard, opponentEntity, opponentBoard, currentAttacker, gameState, playerIsFriendly) => {
192
- var _a;
193
- if (!((_a = playerEntity.questRewards) === null || _a === void 0 ? void 0 : _a.length) || playerEntity.startOfCombatDone) {
193
+ var _a, _b;
194
+ if (playerEntity.startOfCombatDone) {
194
195
  return currentAttacker;
195
196
  }
197
+ for (const trinket of playerEntity.trinkets) {
198
+ switch (trinket.cardId) {
199
+ case "BG30_MagicItem_902":
200
+ if (playerBoard.length > 0) {
201
+ (0, divine_shield_1.updateDivineShield)(playerBoard[0], playerBoard, playerEntity, opponentEntity, true, gameState);
202
+ gameState.spectator.registerPowerTarget(playerEntity, playerBoard[0], playerBoard, null, null);
203
+ if (playerBoard.length > 1) {
204
+ (0, divine_shield_1.updateDivineShield)(playerBoard[1], playerBoard, playerEntity, opponentEntity, true, gameState);
205
+ gameState.spectator.registerPowerTarget(playerEntity, playerBoard[1], playerBoard, null, null);
206
+ }
207
+ }
208
+ break;
209
+ case "BG30_MagicItem_962":
210
+ if (playerBoard.length > 0) {
211
+ const minionsByAttack = [...playerBoard].sort((a, b) => a.attack - b.attack);
212
+ const firstTarget = minionsByAttack[0];
213
+ (0, stats_1.setEntityStats)(firstTarget, 2 * firstTarget.maxAttack, 2 * firstTarget.maxHealth, playerBoard, playerEntity, gameState);
214
+ if (playerBoard.length > 1) {
215
+ const secondTarget = minionsByAttack[1];
216
+ (0, stats_1.setEntityStats)(secondTarget, 2 * secondTarget.maxAttack, 2 * secondTarget.maxHealth, playerBoard, playerEntity, gameState);
217
+ }
218
+ }
219
+ break;
220
+ case "BG30_MagicItem_970":
221
+ case "BG30_MagicItem_970t":
222
+ const medallionBuff = trinket.cardId === "BG30_MagicItem_970" ? 2 : 5;
223
+ (0, utils_2.addStatsToBoard)(trinket, playerBoard, playerEntity, medallionBuff, medallionBuff, gameState);
224
+ break;
225
+ case "BG30_MagicItem_542":
226
+ const highestAttack = Math.max(...playerBoard.map((entity) => entity.attack));
227
+ playerBoard
228
+ .filter((e) => (0, utils_2.hasCorrectTribe)(e, playerEntity, reference_data_1.Race.DRAGON, gameState.allCards))
229
+ .forEach((e) => {
230
+ (0, stats_1.setEntityStats)(e, highestAttack, null, playerBoard, playerEntity, gameState);
231
+ });
232
+ break;
233
+ case "BG30_MagicItem_952":
234
+ const elementals = (0, utils_1.shuffleArray)(playerBoard.filter((e) => (0, utils_2.hasCorrectTribe)(e, playerEntity, reference_data_1.Race.ELEMENTAL, gameState.allCards)));
235
+ const targets = elementals.slice(0, 2);
236
+ targets.forEach((e) => {
237
+ var _a;
238
+ e.enchantments = (_a = e.enchantments) !== null && _a !== void 0 ? _a : [];
239
+ e.enchantments.push({
240
+ cardId: "BG30_MagicItem_952e",
241
+ originEntityId: trinket.entityId,
242
+ repeats: 1,
243
+ timing: gameState.sharedState.currentEntityId++,
244
+ });
245
+ gameState.spectator.registerPowerTarget(playerEntity, e, playerBoard, null, null);
246
+ });
247
+ break;
248
+ case "BG30_MagicItem_917":
249
+ playerBoard
250
+ .filter((e) => (0, utils_2.hasCorrectTribe)(e, playerEntity, reference_data_1.Race.NAGA, gameState.allCards))
251
+ .forEach((e) => {
252
+ var _a;
253
+ e.enchantments = (_a = e.enchantments) !== null && _a !== void 0 ? _a : [];
254
+ e.enchantments.push({
255
+ cardId: "BG30_MagicItem_917e",
256
+ originEntityId: trinket.entityId,
257
+ repeats: 1,
258
+ timing: gameState.sharedState.currentEntityId++,
259
+ });
260
+ });
261
+ break;
262
+ case "BG30_MagicItem_411":
263
+ playerBoard
264
+ .filter((e) => (0, utils_2.hasCorrectTribe)(e, playerEntity, reference_data_1.Race.QUILBOAR, gameState.allCards))
265
+ .forEach((e) => {
266
+ var _a;
267
+ e.enchantments = (_a = e.enchantments) !== null && _a !== void 0 ? _a : [];
268
+ e.enchantments.push({
269
+ cardId: "BG30_MagicItem_411e",
270
+ originEntityId: trinket.entityId,
271
+ repeats: 1,
272
+ timing: gameState.sharedState.currentEntityId++,
273
+ });
274
+ });
275
+ break;
276
+ case "BG30_MagicItem_303":
277
+ if (playerBoard.length < 7) {
278
+ const newMinions = (0, deathrattle_spawns_1.spawnEntities)("BG_TTN_401", 1, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState.allCards, gameState.cardsData, gameState.sharedState, gameState.spectator, playerEntity.friendly, true);
279
+ (0, spawns_1.performEntitySpawns)(newMinions, playerBoard, playerEntity, playerEntity, 0, opponentBoard, opponentEntity, gameState);
280
+ }
281
+ break;
282
+ case "BG30_MagicItem_407":
283
+ if (playerBoard.length < 7) {
284
+ const target = (0, utils_1.pickRandom)(gameState.cardsData.pirateSpawns);
285
+ (0, cards_in_hand_1.addCardsInHand)(playerEntity, playerBoard, [target], gameState);
286
+ const newMinions = (0, deathrattle_spawns_1.spawnEntities)(target, 1, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState.allCards, gameState.cardsData, gameState.sharedState, gameState.spectator, playerEntity.friendly, false);
287
+ const spawns = (0, spawns_1.performEntitySpawns)(newMinions, playerBoard, playerEntity, playerEntity, 0, opponentBoard, opponentEntity, gameState);
288
+ spawns.forEach((spawn) => (spawn.attackImmediately = true));
289
+ }
290
+ break;
291
+ case "BG30_MagicItem_301":
292
+ playerBoard
293
+ .filter((e) => e.cardId === "BG25_008" ||
294
+ e.cardId === "BG25_008_G")
295
+ .forEach((knight) => {
296
+ knight.taunt = true;
297
+ knight.reborn = true;
298
+ gameState.spectator.registerPowerTarget(playerEntity, knight, playerBoard, null, null);
299
+ });
300
+ break;
301
+ case "BG30_MagicItem_822":
302
+ case "BG30_MagicItem_822t2":
303
+ trinket.rememberedMinion = null;
304
+ break;
305
+ case "BG30_MagicItem_989":
306
+ case "BG30_MagicItem_989t":
307
+ const artisanalUrnBuff = trinket.cardId === "BG30_MagicItem_989" ? 3 : 7;
308
+ playerEntity.globalInfo.UndeadAttackBonus =
309
+ ((_a = playerEntity.globalInfo.UndeadAttackBonus) !== null && _a !== void 0 ? _a : 0) + artisanalUrnBuff;
310
+ break;
311
+ case "BG30_MagicItem_310":
312
+ playerBoard
313
+ .filter((e) => e.cardId === "BG25_354" ||
314
+ e.cardId === "BG25_354_G")
315
+ .forEach((e) => (e.stealth = true));
316
+ break;
317
+ case "BG30_MagicItem_441":
318
+ const highestHealthMinionInHand = (_b = playerEntity.hand) === null || _b === void 0 ? void 0 : _b.sort((a, b) => b.health - a.health)[0];
319
+ if (highestHealthMinionInHand && playerBoard.length > 0) {
320
+ (0, stats_1.modifyStats)(playerBoard[0], highestHealthMinionInHand.attack, highestHealthMinionInHand.health, playerBoard, playerEntity, gameState);
321
+ }
322
+ break;
323
+ case "BG30_MagicItem_995":
324
+ if (playerBoard.length > 0) {
325
+ playerBoard.forEach((entity) => {
326
+ const highest = Math.max(entity.attack, entity.health);
327
+ (0, stats_1.setEntityStats)(entity, highest, highest, playerBoard, playerEntity, gameState);
328
+ gameState.spectator.registerPowerTarget(trinket, entity, playerBoard, null, null);
329
+ });
330
+ }
331
+ break;
332
+ case "BG30_MagicItem_403":
333
+ if (playerBoard.length > 0) {
334
+ playerBoard
335
+ .filter((e) => (0, utils_2.getEffectiveTribesForEntity)(e, playerEntity, gameState.allCards).length === 0)
336
+ .forEach((entity) => {
337
+ (0, stats_1.setEntityStats)(entity, 3 * entity.attack, 3 * entity.health, playerBoard, playerEntity, gameState);
338
+ gameState.spectator.registerPowerTarget(trinket, entity, playerBoard, null, null);
339
+ });
340
+ }
341
+ break;
342
+ case "BG30_MagicItem_972":
343
+ if (playerBoard.length > 0) {
344
+ for (let i = 0; i < Math.min(playerBoard.length, 7); i++) {
345
+ const entityToCoy = playerBoard[i];
346
+ const copy = (0, utils_2.copyEntity)(entityToCoy);
347
+ const newMinions = (0, deathrattle_spawns_1.spawnEntities)(copy.cardId, 1, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState.allCards, gameState.cardsData, gameState.sharedState, gameState.spectator, playerEntity.friendly, false, false, false, copy);
348
+ const spawns = (0, spawns_1.performEntitySpawns)(newMinions, playerBoard, playerEntity, playerEntity, playerBoard.length - i - 1, opponentBoard, opponentEntity, gameState);
349
+ i += spawns.length;
350
+ }
351
+ }
352
+ currentAttacker =
353
+ playerBoard.length > opponentBoard.length
354
+ ? playerIsFriendly
355
+ ? 0
356
+ : 1
357
+ : opponentBoard.length > playerBoard.length
358
+ ? playerIsFriendly
359
+ ? 1
360
+ : 0
361
+ : Math.round(Math.random());
362
+ break;
363
+ case "BG30_MagicItem_821":
364
+ case "BG30_MagicItem_821t2":
365
+ if (playerBoard.length < 7) {
366
+ const spawnId = trinket.cardId === "BG30_MagicItem_821"
367
+ ? "TB_BaconShop_HP_105t"
368
+ : "TB_BaconUps_307";
369
+ const newMinions = (0, deathrattle_spawns_1.spawnEntities)(spawnId, 1, playerBoard, playerEntity, opponentBoard, opponentEntity, gameState.allCards, gameState.cardsData, gameState.sharedState, gameState.spectator, playerEntity.friendly, false);
370
+ const spawns = (0, spawns_1.performEntitySpawns)(newMinions, playerBoard, playerEntity, playerEntity, 0, opponentBoard, opponentEntity, gameState);
371
+ currentAttacker =
372
+ playerBoard.length > opponentBoard.length
373
+ ? playerIsFriendly
374
+ ? 0
375
+ : 1
376
+ : opponentBoard.length > playerBoard.length
377
+ ? playerIsFriendly
378
+ ? 1
379
+ : 0
380
+ : Math.round(Math.random());
381
+ }
382
+ break;
383
+ }
384
+ }
196
385
  for (const reward of playerEntity.questRewards) {
197
386
  switch (reward) {
198
387
  case "BG24_Reward_111":
@@ -206,15 +395,16 @@ const handleStartOfCombatQuestRewardsForPlayer = (playerEntity, playerBoard, opp
206
395
  const indexFromRight = playerBoard.length - (playerBoard.indexOf(highestHealthMinion) + 1);
207
396
  (0, spawns_1.performEntitySpawns)(newMinions, playerBoard, playerEntity, highestHealthMinion, indexFromRight, opponentBoard, opponentEntity, gameState);
208
397
  gameState.spectator.registerPowerTarget(playerEntity, copy, playerBoard, null, null);
209
- return playerBoard.length > opponentBoard.length
210
- ? playerIsFriendly
211
- ? 0
212
- : 1
213
- : opponentBoard.length > playerBoard.length
398
+ currentAttacker =
399
+ playerBoard.length > opponentBoard.length
214
400
  ? playerIsFriendly
215
- ? 1
216
- : 0
217
- : Math.round(Math.random());
401
+ ? 0
402
+ : 1
403
+ : opponentBoard.length > playerBoard.length
404
+ ? playerIsFriendly
405
+ ? 1
406
+ : 0
407
+ : Math.round(Math.random());
218
408
  }
219
409
  break;
220
410
  case "BG24_Reward_312":
@@ -225,10 +415,10 @@ const handleStartOfCombatQuestRewardsForPlayer = (playerEntity, playerBoard, opp
225
415
  break;
226
416
  case "BG24_Reward_109":
227
417
  if (playerBoard.length > 0) {
228
- (0, golden_1.makeMinionGolden)(playerBoard[0], playerEntity, playerBoard, playerEntity, gameState);
418
+ (0, golden_1.makeMinionGolden)(playerBoard[0], playerEntity, playerBoard, playerEntity, opponentEntity, gameState);
229
419
  }
230
420
  if (playerBoard.length > 1) {
231
- (0, golden_1.makeMinionGolden)(playerBoard[playerBoard.length - 1], playerEntity, playerBoard, playerEntity, gameState);
421
+ (0, golden_1.makeMinionGolden)(playerBoard[playerBoard.length - 1], playerEntity, playerBoard, playerEntity, opponentEntity, gameState);
232
422
  }
233
423
  break;
234
424
  }
@@ -280,7 +470,7 @@ const handleStartOfCombatAnomaliesForPlayer = (playerEntity, playerBoard, oppone
280
470
  case "BG27_Anomaly_726":
281
471
  if (playerBoard.length > 0) {
282
472
  const dsTarget = playerBoard[0];
283
- (0, utils_2.updateDivineShield)(dsTarget, playerBoard, true, gameState.allCards);
473
+ (0, divine_shield_1.updateDivineShield)(dsTarget, playerBoard, playerEntity, opponentEntity, true, gameState);
284
474
  const rebornTarget = playerBoard[playerBoard.length - 1];
285
475
  rebornTarget.reborn = true;
286
476
  }
@@ -356,7 +546,7 @@ const handleAlakirForPlayer = (playerBoard, playerEntity, opponentBoard, opponen
356
546
  const firstEntity = playerBoard[0];
357
547
  firstEntity.windfury = true;
358
548
  if (!firstEntity.divineShield) {
359
- (0, utils_2.updateDivineShield)(firstEntity, playerBoard, true, gameState.allCards);
549
+ (0, divine_shield_1.updateDivineShield)(firstEntity, playerBoard, playerEntity, opponentEntity, true, gameState);
360
550
  }
361
551
  firstEntity.taunt = true;
362
552
  gameState.spectator.registerPowerTarget(firstEntity, firstEntity, playerBoard, playerEntity, opponentEntity);
@@ -441,7 +631,7 @@ const handleTeronForPlayer = (playerBoard, playerEntity, opponentBoard, opponent
441
631
  enchantments: (_a = minionThatWillDie.enchantments.map((e) => ({ ...e }))) !== null && _a !== void 0 ? _a : [],
442
632
  pendingAttackBuffs: [],
443
633
  };
444
- (0, add_minion_to_board_1.removeAurasFromSelf)(minionToCopy, playerBoard, playerEntity, gameState.allCards, gameState.sharedState, gameState.spectator);
634
+ (0, add_minion_to_board_1.removeAurasFromSelf)(minionToCopy, playerBoard, playerEntity, gameState);
445
635
  playerEntity.rapidReanimationMinion = minionToCopy;
446
636
  minionThatWillDie.definitelyDead = true;
447
637
  gameState.spectator.registerPowerTarget(playerEntity, minionThatWillDie, playerBoard, playerEntity, opponentEntity);
@@ -451,12 +641,12 @@ const handleTeronForPlayer = (playerBoard, playerEntity, opponentBoard, opponent
451
641
  };
452
642
  const handleWaxWarbandForPlayer = (playerBoard, playerEntity, opponentBoard, opponentEntity, gameState) => {
453
643
  if (playerBoard.length > 0) {
454
- const boardWithTribes = playerBoard.filter((e) => { var _a, _b; return !!((_b = (_a = gameState.allCards.getCard(e.cardId)) === null || _a === void 0 ? void 0 : _a.races) === null || _b === void 0 ? void 0 : _b.length); });
455
- const boardWithoutAll = boardWithTribes.filter((e) => !gameState.allCards.getCard(e.cardId).races.includes(reference_data_1.Race[reference_data_1.Race.ALL]));
644
+ const boardWithTribes = playerBoard.filter((e) => !!(0, utils_2.getEffectiveTribesForEntity)(e, playerEntity, gameState.allCards).length);
645
+ const boardWithoutAll = boardWithTribes.filter((e) => { var _a; return !((_a = gameState.allCards.getCard(e.cardId).races) === null || _a === void 0 ? void 0 : _a.includes(reference_data_1.Race[reference_data_1.Race.ALL])); });
456
646
  const selectedMinions = selectMinions(boardWithoutAll, reference_data_1.ALL_BG_RACES, gameState.allCards);
457
647
  const allMinions = [
458
648
  ...selectedMinions,
459
- ...boardWithTribes.filter((e) => gameState.allCards.getCard(e.cardId).races.includes(reference_data_1.Race[reference_data_1.Race.ALL])),
649
+ ...boardWithTribes.filter((e) => { var _a; return (_a = gameState.allCards.getCard(e.cardId).races) === null || _a === void 0 ? void 0 : _a.includes(reference_data_1.Race[reference_data_1.Race.ALL]); }),
460
650
  ];
461
651
  allMinions.forEach((e) => {
462
652
  (0, stats_1.modifyStats)(e, gameState.cardsData.getTavernLevel(e.cardId), gameState.cardsData.getTavernLevel(e.cardId), playerBoard, playerEntity, gameState);
@@ -465,10 +655,10 @@ const handleWaxWarbandForPlayer = (playerBoard, playerEntity, opponentBoard, opp
465
655
  }
466
656
  };
467
657
  const selectMinions = (minions, tribes, allCards) => {
468
- var _a;
658
+ var _a, _b;
469
659
  const minionsByTribe = {};
470
660
  for (const minion of minions) {
471
- for (const tribe of allCards.getCard(minion.cardId).races) {
661
+ for (const tribe of (_a = allCards.getCard(minion.cardId).races) !== null && _a !== void 0 ? _a : []) {
472
662
  if (!minionsByTribe[tribe]) {
473
663
  minionsByTribe[tribe] = [];
474
664
  }
@@ -476,7 +666,7 @@ const selectMinions = (minions, tribes, allCards) => {
476
666
  }
477
667
  }
478
668
  for (const tribe of reference_data_1.ALL_BG_RACES) {
479
- minionsByTribe[tribe] = (0, utils_1.shuffleArray)((_a = minionsByTribe[reference_data_1.Race[tribe]]) !== null && _a !== void 0 ? _a : []);
669
+ minionsByTribe[tribe] = (0, utils_1.shuffleArray)((_b = minionsByTribe[reference_data_1.Race[tribe]]) !== null && _b !== void 0 ? _b : []);
480
670
  }
481
671
  const selectedMinions = [];
482
672
  for (const tribe of tribes) {
@@ -560,15 +750,11 @@ const performStartOfCombatMinionsForPlayer = (attacker, attackingBoard, attackin
560
750
  }
561
751
  let hasProcessed = true;
562
752
  if (attacker.cardId === "BGS_019") {
563
- const damage = attackingBoardBefore
564
- .map((entity) => gameState.allCards.getCard(entity.cardId).races)
565
- .filter((races) => (0, utils_2.isCorrectTribe)(races, reference_data_1.Race.DRAGON)).length;
753
+ const damage = attackingBoardBefore.filter((entity) => (0, utils_2.hasCorrectTribe)(entity, attackingBoardHero, reference_data_1.Race.DRAGON, gameState.allCards)).length;
566
754
  (0, attack_1.dealDamageToRandomEnemy)(defendingBoard, defendingBoardHero, attacker, damage, attackingBoard, attackingBoardHero, gameState);
567
755
  }
568
756
  else if (attacker.cardId === "TB_BaconUps_102") {
569
- const damage = attackingBoardBefore
570
- .map((entity) => gameState.allCards.getCard(entity.cardId).races)
571
- .filter((races) => (0, utils_2.isCorrectTribe)(races, reference_data_1.Race.DRAGON)).length;
757
+ const damage = attackingBoardBefore.filter((entity) => (0, utils_2.hasCorrectTribe)(entity, attackingBoardHero, reference_data_1.Race.DRAGON, gameState.allCards)).length;
572
758
  (0, attack_1.dealDamageToRandomEnemy)(defendingBoard, defendingBoardHero, attacker, damage, attackingBoard, attackingBoardHero, gameState);
573
759
  (0, attack_1.dealDamageToRandomEnemy)(defendingBoard, defendingBoardHero, attacker, damage, attackingBoard, attackingBoardHero, gameState);
574
760
  }
@@ -577,7 +763,7 @@ const performStartOfCombatMinionsForPlayer = (attacker, attackingBoard, attackin
577
763
  const stats = attacker.cardId === "BG21_014_G" ? 6 : 3;
578
764
  const targets = attackingBoard
579
765
  .filter((e) => e.entityId !== attacker.entityId)
580
- .filter((e) => (0, utils_2.hasCorrectTribe)(e, reference_data_1.Race.DRAGON, gameState.allCards));
766
+ .filter((e) => (0, utils_2.hasCorrectTribe)(e, attackingBoardHero, reference_data_1.Race.DRAGON, gameState.allCards));
581
767
  for (const entity of targets) {
582
768
  (0, stats_1.modifyStats)(entity, stats, stats, attackingBoard, attackingBoardHero, gameState);
583
769
  gameState.spectator.registerPowerTarget(attacker, entity, attackingBoard, attackingBoardHero, defendingBoardHero);
@@ -592,7 +778,7 @@ const performStartOfCombatMinionsForPlayer = (attacker, attackingBoard, attackin
592
778
  else if (attacker.cardId === "BG24_500" ||
593
779
  attacker.cardId === "BG24_500_G") {
594
780
  const otherDragons = attackingBoard
595
- .filter((e) => (0, utils_2.hasCorrectTribe)(e, reference_data_1.Race.DRAGON, gameState.allCards))
781
+ .filter((e) => (0, utils_2.hasCorrectTribe)(e, attackingBoardHero, reference_data_1.Race.DRAGON, gameState.allCards))
596
782
  .filter((e) => e.entityId !== attacker.entityId);
597
783
  const loops = attacker.cardId === "BG24_500_G" ? 2 : 1;
598
784
  const dragonsToConsider = otherDragons;
@@ -600,7 +786,7 @@ const performStartOfCombatMinionsForPlayer = (attacker, attackingBoard, attackin
600
786
  const otherDragon = (_c = (0, utils_1.pickRandom)(dragonsToConsider.filter((e) => !e.divineShield))) !== null && _c !== void 0 ? _c : (0, utils_1.pickRandom)(dragonsToConsider);
601
787
  if (otherDragon) {
602
788
  if (!otherDragon.divineShield) {
603
- (0, utils_2.updateDivineShield)(otherDragon, attackingBoard, true, gameState.allCards);
789
+ (0, divine_shield_1.updateDivineShield)(otherDragon, attackingBoard, attackingBoardHero, defendingBoardHero, true, gameState);
604
790
  }
605
791
  (0, stats_1.modifyStats)(otherDragon, 7, 7, attackingBoard, attackingBoardHero, gameState);
606
792
  gameState.spectator.registerPowerTarget(attacker, otherDragon, attackingBoard, attackingBoardHero, defendingBoardHero);
@@ -612,7 +798,7 @@ const performStartOfCombatMinionsForPlayer = (attacker, attackingBoard, attackin
612
798
  attacker.cardId === "BG26_356_G") {
613
799
  const buff = attacker.cardId === "BG26_356_G" ? 16 : 8;
614
800
  const otherDragons = attackingBoard
615
- .filter((e) => (0, utils_2.hasCorrectTribe)(e, reference_data_1.Race.DRAGON, gameState.allCards))
801
+ .filter((e) => (0, utils_2.hasCorrectTribe)(e, attackingBoardHero, reference_data_1.Race.DRAGON, gameState.allCards))
616
802
  .filter((e) => e.entityId !== attacker.entityId);
617
803
  otherDragons.forEach((otherDragon) => {
618
804
  (0, stats_1.modifyStats)(otherDragon, 0, buff, attackingBoard, attackingBoardHero, gameState);
@@ -624,7 +810,7 @@ const performStartOfCombatMinionsForPlayer = (attacker, attackingBoard, attackin
624
810
  const numberOfTargets = attacker.cardId === "BG25_023_G" ? 2 : 1;
625
811
  for (let i = 0; i < numberOfTargets; i++) {
626
812
  const undeadsWithoutReborn = attackingBoard
627
- .filter((e) => (0, utils_2.hasCorrectTribe)(e, reference_data_1.Race.UNDEAD, gameState.allCards))
813
+ .filter((e) => (0, utils_2.hasCorrectTribe)(e, attackingBoardHero, reference_data_1.Race.UNDEAD, gameState.allCards))
628
814
  .filter((e) => !e.reborn);
629
815
  const chosenUndead = (0, utils_1.pickRandom)(undeadsWithoutReborn);
630
816
  if (chosenUndead) {
@@ -652,14 +838,15 @@ const performStartOfCombatMinionsForPlayer = (attacker, attackingBoard, attackin
652
838
  else if (attacker.cardId === "BG24_704" ||
653
839
  attacker.cardId === "BG24_704_G") {
654
840
  if (defendingBoard.length > 0) {
655
- const attackerIndex = attackingBoard.indexOf(attacker);
656
- const defenderPosition = attackerIndex - (attackingBoard.length - defendingBoard.length) / 2;
657
- if (Math.round(defenderPosition) === defenderPosition) {
658
- castImpure(defendingBoard[defenderPosition], attacker, attackingBoard, gameState.spectator);
659
- }
660
- else {
661
- castImpure(defendingBoard[defenderPosition - 0.5], attacker, attackingBoard, gameState.spectator);
662
- castImpure(defendingBoard[defenderPosition + 0.5], attacker, attackingBoard, gameState.spectator);
841
+ const validTargets = defendingBoard.filter((e) => gameState.cardsData.getTavernLevel(e.cardId) >= 5);
842
+ const numberOfPicks = attacker.cardId === "BG24_704_G" ? 2 : 1;
843
+ for (let i = 0; i < numberOfPicks; i++) {
844
+ const target = (0, utils_1.pickRandom)(validTargets);
845
+ if (!!target) {
846
+ castImpure(attacker, target, attackingBoard, gameState.spectator);
847
+ const targetIndex = validTargets.findIndex((e) => e.entityId === target.entityId);
848
+ validTargets.splice(targetIndex, 1);
849
+ }
663
850
  }
664
851
  }
665
852
  }
@@ -796,7 +983,7 @@ const performStartOfCombatMinionsForPlayer = (attacker, attackingBoard, attackin
796
983
  attacker.cardId === "BG29_810_G") {
797
984
  const loops = attacker.cardId === "BG29_810_G" ? 2 : 1;
798
985
  const pickedTargets = [];
799
- const dragons = attackingBoard.filter((e) => (0, utils_2.hasCorrectTribe)(e, reference_data_1.Race.DRAGON, gameState.allCards));
986
+ const dragons = attackingBoard.filter((e) => (0, utils_2.hasCorrectTribe)(e, attackingBoardHero, reference_data_1.Race.DRAGON, gameState.allCards));
800
987
  for (let i = 0; i < loops; i++) {
801
988
  const target = dragons.filter((e) => !pickedTargets.includes(e))[0];
802
989
  if (!!target) {
@@ -819,7 +1006,7 @@ const performStartOfCombatMinionsForPlayer = (attacker, attackingBoard, attackin
819
1006
  const candidates = randomBoard.sort((a, b) => gameState.cardsData.getTavernLevel(a.cardId) - gameState.cardsData.getTavernLevel(b.cardId));
820
1007
  const target = candidates[0];
821
1008
  if (!!target) {
822
- (0, golden_1.makeMinionGolden)(target, attacker, attackingBoard, attackingBoardHero, gameState);
1009
+ (0, golden_1.makeMinionGolden)(target, attacker, attackingBoard, attackingBoardHero, defendingBoardHero, gameState);
823
1010
  }
824
1011
  }
825
1012
  }
@@ -864,7 +1051,7 @@ const performStartOfCombatMinionsForPlayer = (attacker, attackingBoard, attackin
864
1051
  const attackerIndex = attackingBoard.indexOf(attacker);
865
1052
  attackingBoard.splice(attackerIndex, 0, copy);
866
1053
  if (isGolden) {
867
- (0, golden_1.makeMinionGolden)(copy, copy, attackingBoard, attackingBoardHero, gameState);
1054
+ (0, golden_1.makeMinionGolden)(copy, copy, attackingBoard, attackingBoardHero, defendingBoardHero, gameState);
868
1055
  }
869
1056
  }
870
1057
  }
@@ -880,7 +1067,7 @@ const performStartOfCombatMinionsForPlayer = (attacker, attackingBoard, attackin
880
1067
  }
881
1068
  else if (attacker.cardId === "TB_BaconShop_HERO_14_Buddy" ||
882
1069
  attacker.cardId === "TB_BaconShop_HERO_14_Buddy_G") {
883
- const minionsOfDifferentTypes = (0, utils_2.getMinionsOfDifferentTypes)(attackingBoard, gameState);
1070
+ const minionsOfDifferentTypes = (0, utils_2.getMinionsOfDifferentTypes)(attackingBoard, attackingBoardHero, gameState);
884
1071
  if (minionsOfDifferentTypes.length >= 4) {
885
1072
  const highestAttackOnBoard = Math.max(...attackingBoard.map((entity) => entity.attack));
886
1073
  const highestHealthOnBoard = Math.max(...attackingBoard.map((entity) => entity.health));
@@ -889,6 +1076,28 @@ const performStartOfCombatMinionsForPlayer = (attacker, attackingBoard, attackin
889
1076
  gameState.spectator.registerPowerTarget(attacker, attacker, attackingBoard, attackingBoardHero, defendingBoardHero);
890
1077
  }
891
1078
  }
1079
+ else if (attacker.cardId === "BG30_101" || attacker.cardId === "BG30_101_G") {
1080
+ if (attackingBoard.length > 0 || defendingBoard.length > 0) {
1081
+ const quantity = attacker.cardId === "BG30_101" ? 3 : 6;
1082
+ (0, divine_shield_1.grantDivineShieldToLeftmostMinions)(attacker, attackingBoard, attackingBoardHero, quantity, defendingBoardHero, gameState);
1083
+ }
1084
+ }
1085
+ else if (attacker.cardId === "BG30_119" ||
1086
+ attacker.cardId === "BG30_119_G") {
1087
+ attackingBoard
1088
+ .filter((e) => e.entityId !== attacker.entityId)
1089
+ .filter((e) => (0, utils_2.hasCorrectTribe)(e, attackingBoardHero, reference_data_1.Race.PIRATE, gameState.allCards))
1090
+ .forEach((e) => {
1091
+ e.enchantments = e.enchantments || [];
1092
+ e.enchantments.push({
1093
+ cardId: attacker.cardId === "BG30_119_G"
1094
+ ? "BG30_119_Ge"
1095
+ : "BG30_119e",
1096
+ originEntityId: attacker.entityId,
1097
+ timing: gameState.sharedState.currentEntityId++,
1098
+ });
1099
+ });
1100
+ }
892
1101
  else {
893
1102
  hasProcessed = false;
894
1103
  }