@firestone-hs/simulate-bgs-battle 1.1.289 → 1.1.290

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.
@@ -5,6 +5,7 @@ const reference_data_1 = require("@firestone-hs/reference-data");
5
5
  const utils_1 = require("../services/utils");
6
6
  const utils_2 = require("../utils");
7
7
  const attack_1 = require("./attack");
8
+ const blood_gems_1 = require("./blood-gems");
8
9
  const deathrattle_spawns_1 = require("./deathrattle-spawns");
9
10
  const applyAvengeEffects = (deadEntity, deadEntityIndexFromRight, boardWithDeadEntity, boardWithDeadEntityHero, otherBoard, otherBoardHero, allCards, cardsData, sharedState, spectator) => {
10
11
  const candidatesEntitiesSpawnedFromAvenge = [];
@@ -50,7 +51,6 @@ const updateAvengeCounters = (board, boardWithDeadEntityHero) => {
50
51
  }
51
52
  };
52
53
  const handleAvenge = (boardWithDeadEntity, boardWithDeadEntityHero, deadEntity, deadEntityIndexFromRight, avenger, otherBoard, otherBoardHero, cardsData, sharedState, spectator, allCards) => {
53
- var _a, _b, _c, _d;
54
54
  switch (avenger.cardId) {
55
55
  case "BG21_002":
56
56
  (0, utils_2.addStatsToBoard)(avenger, boardWithDeadEntity, 1, 1, allCards, spectator, 'BEAST');
@@ -174,10 +174,13 @@ const handleAvenge = (boardWithDeadEntity, boardWithDeadEntityHero, deadEntity,
174
174
  case "BG26_157":
175
175
  case "BG26_157_G":
176
176
  const bristlebachMultiplier = avenger.cardId === "BG26_157_G" ? 2 : 1;
177
- const bloodGemAttackBuff = 1 + ((_b = (_a = boardWithDeadEntityHero.globalInfo) === null || _a === void 0 ? void 0 : _a.BloodGemAttackBonus) !== null && _b !== void 0 ? _b : 0);
178
- const bloodGemHealthBuff = 1 + ((_d = (_c = boardWithDeadEntityHero.globalInfo) === null || _c === void 0 ? void 0 : _c.BloodGemHealthBonus) !== null && _d !== void 0 ? _d : 0);
179
- for (let i = 0; i < bristlebachMultiplier * 2; i++) {
180
- (0, utils_2.addStatsToBoard)(avenger, boardWithDeadEntity, bloodGemAttackBuff, bloodGemHealthBuff, allCards, spectator, reference_data_1.Race[reference_data_1.Race.QUILBOAR]);
177
+ for (let i = 0; i < bristlebachMultiplier; i++) {
178
+ console.log('playing blood gems on bristlebach');
179
+ for (const entity of boardWithDeadEntity) {
180
+ if ((0, utils_2.hasCorrectTribe)(entity, reference_data_1.Race.QUILBOAR, allCards)) {
181
+ (0, blood_gems_1.playBloodGemsOn)(entity, 1, boardWithDeadEntity, boardWithDeadEntityHero, allCards, spectator);
182
+ }
183
+ }
181
184
  }
182
185
  break;
183
186
  case "BG25_014":
@@ -1 +1 @@
1
- {"version":3,"file":"avenge.js","sourceRoot":"","sources":["../../src/simulation/avenge.ts"],"names":[],"mappings":";;;AAAA,iEAA8E;AAI9E,6CAA+C;AAC/C,oCAYkB;AAClB,qCAAiF;AACjF,6DAAqD;AAI9C,MAAM,kBAAkB,GAAG,CACjC,UAAuB,EACvB,wBAAgC,EAChC,mBAAkC,EAClC,uBAAwC,EACxC,UAAyB,EACzB,cAA+B,EAC/B,QAAyB,EACzB,SAAoB,EACpB,WAAwB,EACxB,SAAoB,EACb,EAAE;IACT,MAAM,mCAAmC,GAAkB,EAAE,CAAC;IAC9D,oBAAoB,CAAC,mBAAmB,EAAE,uBAAuB,CAAC,CAAC;IACnE,MAAM,QAAQ,GAAG,mBAAmB;SAClC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,IAAI,CAAC,CAAC,aAAa,IAAI,CAAC,CAAC;SAGxD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACd,IAAI,CAAC,CAAC,MAAM,eAAiC,IAAI,CAAC,CAAC,MAAM,iBAAmC,EAAE;YAC7F,OAAO,CAAC,CAAC,CAAC;SACV;QACD,IAAI,CAAC,CAAC,MAAM,eAAiC,IAAI,CAAC,CAAC,MAAM,iBAAmC,EAAE;YAC7F,OAAO,CAAC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,uBAAuB,CAAC,aAAa,CAAC;AAC/E,CAAC,CAAC","sourcesContent":["import { AllCardsService, CardIds, 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 { pickRandom } from '../services/utils';\r\nimport {\r\n\taddCardsInHand,\r\n\taddStatsToBoard,\r\n\tafterStatsUpdate,\r\n\tgetRandomAliveMinion,\r\n\tgetRandomMinionWithHighestHealth,\r\n\tgrantRandomStats,\r\n\tgrantStatsToMinionsOfEachType,\r\n\tisMinionGolden,\r\n\tmakeMinionGolden,\r\n\tmodifyAttack,\r\n\tmodifyHealth,\r\n} from '../utils';\r\nimport { dealDamageToEnemy, getNeighbours, performEntitySpawns } from './attack';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { SharedState } from './shared-state';\r\nimport { Spectator } from './spectator/spectator';\r\n\r\nexport const applyAvengeEffects = (\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\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst candidatesEntitiesSpawnedFromAvenge: BoardEntity[] = [];\r\n\tupdateAvengeCounters(boardWithDeadEntity, boardWithDeadEntityHero);\r\n\tconst avengers = boardWithDeadEntity\r\n\t\t.filter((e) => !!e.avengeDefault && e.avengeCurrent <= 0)\r\n\t\t// Get Tony to be processed first, because of the \"when turned golden, the minion ignores the death for the avenge counter\"\r\n\t\t// behavior\r\n\t\t.sort((a, b) => {\r\n\t\t\tif (a.cardId === CardIds.TonyTwoTusk_BG21_031 || a.cardId === CardIds.TonyTwoTusk_BG21_031_G) {\r\n\t\t\t\treturn -1;\r\n\t\t\t}\r\n\t\t\tif (b.cardId === CardIds.TonyTwoTusk_BG21_031 || b.cardId === CardIds.TonyTwoTusk_BG21_031_G) {\r\n\t\t\t\treturn 1;\r\n\t\t\t}\r\n\t\t\treturn 0;\r\n\t\t});\r\n\tfor (const avenger of avengers) {\r\n\t\thandleAvenge(\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\tdeadEntity,\r\n\t\t\tdeadEntityIndexFromRight,\r\n\t\t\tavenger,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t}\r\n\t// console.log('updating dead entity avenge counter', boardWithDeadEntityHero.avengeCurrent, stringifySimpleCard(deadEntity, allCards));\r\n\tconst heroAvenger = !!boardWithDeadEntityHero.avengeDefault && boardWithDeadEntityHero.avengeCurrent === 0;\r\n\tif (heroAvenger) {\r\n\t\t// console.log(\r\n\t\t// \t'Hero is an avenger',\r\n\t\t// \tboardWithDeadEntityHero.avengeCurrent,\r\n\t\t// \tboardWithDeadEntityHero.avengeDefault,\r\n\t\t// \tboardWithDeadEntityHero.heroPowerId,\r\n\t\t// );\r\n\t\thandleHeroAvenge(\r\n\t\t\tdeadEntity,\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tcandidatesEntitiesSpawnedFromAvenge,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t}\r\n\r\n\tconst questRewardAvengers = boardWithDeadEntityHero.questRewardEntities.filter(\r\n\t\t(e) => !!e.avengeDefault && e.avengeCurrent <= 0,\r\n\t);\r\n\tfor (const avenger of questRewardAvengers) {\r\n\t\thandleAvenge(\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\tdeadEntity,\r\n\t\t\tdeadEntityIndexFromRight,\r\n\t\t\tavenger as BoardEntity,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t}\r\n\r\n\tperformEntitySpawns(\r\n\t\tcandidatesEntitiesSpawnedFromAvenge,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tdeadEntity,\r\n\t\tdeadEntityIndexFromRight,\r\n\t\totherBoard,\r\n\t\totherBoardHero,\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 updateAvengeCounters = (board: readonly BoardEntity[], boardWithDeadEntityHero: BgsPlayerEntity) => {\r\n\tfor (const entity of board) {\r\n\t\tif (!!entity.avengeDefault) {\r\n\t\t\tentity.avengeCurrent -= 1;\r\n\t\t}\r\n\t}\r\n\tif (!!boardWithDeadEntityHero.avengeDefault) {\r\n\t\tboardWithDeadEntityHero.avengeCurrent -= 1;\r\n\t}\r\n\r\n\tfor (const reward of boardWithDeadEntityHero.questRewardEntities) {\r\n\t\tif (!!reward.avengeDefault) {\r\n\t\t\treward.avengeCurrent -= 1;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleAvenge = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tavenger: BoardEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n\tallCards: AllCardsService,\r\n) => {\r\n\t// Don't forget to update the avenge data in cards-data\r\n\tswitch (avenger.cardId) {\r\n\t\tcase CardIds.BirdBuddy_BG21_002:\r\n\t\t\taddStatsToBoard(avenger, boardWithDeadEntity, 1, 1, allCards, spectator, 'BEAST');\r\n\t\t\tbreak;\r\n\t\tcase CardIds.BirdBuddy_BG21_002_G:\r\n\t\t\taddStatsToBoard(avenger, boardWithDeadEntity, 2, 2, allCards, spectator, 'BEAST');\r\n\t\t\tbreak;\r\n\t\tcase CardIds.BuddingGreenthumb_BG21_030:\r\n\t\tcase CardIds.BuddingGreenthumb_BG21_030_G:\r\n\t\t\tconst neighbours = getNeighbours(boardWithDeadEntity, avenger);\r\n\t\t\tneighbours.forEach((entity) => {\r\n\t\t\t\tmodifyAttack(\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tavenger.cardId === CardIds.BuddingGreenthumb_BG21_030_G ? 4 : 2,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t);\r\n\t\t\t\tmodifyHealth(\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tavenger.cardId === CardIds.BuddingGreenthumb_BG21_030_G ? 2 : 1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t);\r\n\t\t\t\tafterStatsUpdate(entity, boardWithDeadEntity, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(avenger, entity, boardWithDeadEntity);\r\n\t\t\t});\r\n\t\t\tbreak;\r\n\t\t// case CardIds.FrostwolfLieutenant:\r\n\t\t// case CardIds.FrostwolfLieutenantBattlegrounds:\r\n\t\t// \taddStatsToBoard(\r\n\t\t// \t\tavenger,\r\n\t\t// \t\tboardWithDeadEntity,\r\n\t\t// \t\tavenger.cardId === CardIds.FrostwolfLieutenantBattlegrounds ? 2 : 1,\r\n\t\t// \t\t0,\r\n\t\t// \t\tallCards,\r\n\t\t// \t\tspectator,\r\n\t\t// \t);\r\n\t\t// \tbreak;\r\n\t\tcase CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy:\r\n\t\tcase CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy_G:\r\n\t\t\taddStatsToBoard(\r\n\t\t\t\tavenger,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t0,\r\n\t\t\t\tavenger.cardId === CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy_G ? 2 : 1,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PalescaleCrocolisk_BG21_001:\r\n\t\t\tconst target1 = grantRandomStats(avenger, boardWithDeadEntity, 6, 6, Race.BEAST, true, allCards, spectator);\r\n\t\t\tif (!!target1) {\r\n\t\t\t\tspectator.registerPowerTarget(avenger, target1, boardWithDeadEntity);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PalescaleCrocolisk_BG21_001_G:\r\n\t\t\tconst target2 = grantRandomStats(\r\n\t\t\t\tavenger,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t12,\r\n\t\t\t\t12,\r\n\t\t\t\tRace.BEAST,\r\n\t\t\t\ttrue,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\tif (!!target2) {\r\n\t\t\t\tspectator.registerPowerTarget(avenger, target2, boardWithDeadEntity);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ImpatientDoomsayer_BG21_007:\r\n\t\tcase CardIds.ImpatientDoomsayer_BG21_007_G:\r\n\t\t\tconst doomsayerCardsToAddQuantity = avenger.cardId === CardIds.ImpatientDoomsayer_BG21_007_G ? 2 : 1;\r\n\t\t\tconst doomsayerCardsToAdd = [];\r\n\t\t\tfor (let i = 0; i < doomsayerCardsToAddQuantity; i++) {\r\n\t\t\t\tdoomsayerCardsToAdd.push(pickRandom(cardsData.demonSpawns));\r\n\t\t\t}\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, allCards, spectator, doomsayerCardsToAdd);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PashmarTheVengeful_BG23_014:\r\n\t\tcase CardIds.PashmarTheVengeful_BG23_014_G:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, allCards, spectator, [null]);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.WitchwingNestmatron_BG21_038:\r\n\t\tcase CardIds.WitchwingNestmatron_BG21_038_G:\r\n\t\t\tconst nestmatronToAddQuantity = avenger.cardId === CardIds.WitchwingNestmatron_BG21_038_G ? 2 : 1;\r\n\t\t\tconst nestmatronCardsToAdd = [];\r\n\t\t\tfor (let i = 0; i < nestmatronToAddQuantity; i++) {\r\n\t\t\t\tnestmatronCardsToAdd.push(pickRandom(cardsData.brannEpicEggSpawns));\r\n\t\t\t}\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, allCards, spectator, nestmatronCardsToAdd);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Thorncaller_BG20_105:\r\n\t\tcase CardIds.Thorncaller_BG20_105_G:\r\n\t\t\tconst thorncallerToAddQuantity = avenger.cardId === CardIds.Thorncaller_BG20_105_G ? 2 : 1;\r\n\t\t\tconst thorncallerCardsToAdd = Array(thorncallerToAddQuantity).fill(CardIds.BloodGem);\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, allCards, spectator, thorncallerCardsToAdd);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Sisefin_BG21_009:\r\n\t\tcase CardIds.Sisefin_BG21_009_G:\r\n\t\t\tconst poisonousIterations = avenger.cardId === CardIds.Sisefin_BG21_009_G ? 2 : 1;\r\n\t\t\tfor (let i = 0; i < poisonousIterations; i++) {\r\n\t\t\t\tconst validTargets = boardWithDeadEntity.filter((e) => !e.poisonous && !e.venomous);\r\n\t\t\t\tconst murloc = getRandomAliveMinion(validTargets, Race.MURLOC, allCards);\r\n\t\t\t\tif (murloc) {\r\n\t\t\t\t\tmurloc.venomous = true;\r\n\t\t\t\t\tspectator.registerPowerTarget(avenger, murloc, boardWithDeadEntity);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ScrapScraper_BG26_148:\r\n\t\tcase CardIds.ScrapScraper_BG26_148_G:\r\n\t\t\tconst scraperToAddQuantity = avenger.cardId === CardIds.ScrapScraper_BG26_148_G ? 2 : 1;\r\n\t\t\tconst scraperCardsToAdd = [];\r\n\t\t\tfor (let i = 0; i < scraperToAddQuantity; i++) {\r\n\t\t\t\tscraperCardsToAdd.push(pickRandom(cardsData.scrapScraperSpawns));\r\n\t\t\t}\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, allCards, spectator, scraperCardsToAdd);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.MechanoTank_BG21_023:\r\n\t\t\t// This can be null if the avenge triggers when the last enemy minion dies as well\r\n\t\t\tconst target = getRandomMinionWithHighestHealth(otherBoard);\r\n\t\t\tspectator.registerPowerTarget(avenger, target, otherBoard);\r\n\t\t\tdealDamageToEnemy(\r\n\t\t\t\ttarget,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tavenger,\r\n\t\t\t\t5,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.MechanoTank_BG21_023_G:\r\n\t\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\t\tconst target = getRandomMinionWithHighestHealth(otherBoard);\r\n\t\t\t\tspectator.registerPowerTarget(avenger, target, otherBoard);\r\n\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tavenger,\r\n\t\t\t\t\t5,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\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\tbreak;\r\n\t\tcase CardIds.TonyTwoTusk_BG21_031:\r\n\t\t\tconst nonGoldenMinions = boardWithDeadEntity\r\n\t\t\t\t.filter((e) => e.entityId !== avenger.entityId)\r\n\t\t\t\t.filter((e) => {\r\n\t\t\t\t\tconst ref = allCards.getCard(e.cardId);\r\n\t\t\t\t\treturn (\r\n\t\t\t\t\t\t!!ref.battlegroundsPremiumDbfId && !!allCards.getCardFromDbfId(ref.battlegroundsPremiumDbfId).id\r\n\t\t\t\t\t);\r\n\t\t\t\t});\r\n\t\t\tconst pirate = getRandomAliveMinion(nonGoldenMinions, Race.PIRATE, allCards);\r\n\t\t\tif (pirate) {\r\n\t\t\t\tmakeMinionGolden(pirate, avenger, boardWithDeadEntity, allCards, spectator);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.TonyTwoTusk_BG21_031_G:\r\n\t\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\t\tconst nonGoldenMinions = boardWithDeadEntity.filter((e) => !isMinionGolden(e, allCards));\r\n\t\t\t\tconst pirate = getRandomAliveMinion(nonGoldenMinions, Race.PIRATE, allCards);\r\n\t\t\t\tif (pirate) {\r\n\t\t\t\t\tmakeMinionGolden(pirate, avenger, boardWithDeadEntity, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.GhoulOfTheFeast_BG25_002:\r\n\t\tcase CardIds.GhoulOfTheFeast_BG25_002_G:\r\n\t\t\tconst ghoulMultiplier = avenger.cardId === CardIds.GhoulOfTheFeast_BG25_002_G ? 2 : 1;\r\n\t\t\tgrantStatsToMinionsOfEachType(avenger, boardWithDeadEntity, ghoulMultiplier * 3, 0, allCards, spectator);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Bristlebach_BG26_157:\r\n\t\tcase CardIds.Bristlebach_BG26_157_G:\r\n\t\t\tconst bristlebachMultiplier = avenger.cardId === CardIds.Bristlebach_BG26_157_G ? 2 : 1;\r\n\t\t\tconst bloodGemAttackBuff = 1 + (boardWithDeadEntityHero.globalInfo?.BloodGemAttackBonus ?? 0);\r\n\t\t\tconst bloodGemHealthBuff = 1 + (boardWithDeadEntityHero.globalInfo?.BloodGemHealthBonus ?? 0);\r\n\t\t\tfor (let i = 0; i < bristlebachMultiplier * 2; i++) {\r\n\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\tavenger,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tbloodGemAttackBuff,\r\n\t\t\t\t\tbloodGemHealthBuff,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t\tRace[Race.QUILBOAR],\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.HungeringAbomination_BG25_014:\r\n\t\tcase CardIds.HungeringAbomination_BG25_014_G:\r\n\t\t\tconst abominationMultiplier = avenger.cardId === CardIds.HungeringAbomination_BG25_014_G ? 2 : 1;\r\n\t\t\tmodifyAttack(avenger, abominationMultiplier * 1, boardWithDeadEntity, allCards);\r\n\t\t\tmodifyHealth(avenger, abominationMultiplier * 1, boardWithDeadEntity, allCards);\r\n\t\t\tafterStatsUpdate(avenger, boardWithDeadEntity, allCards);\r\n\t\t\tspectator.registerPowerTarget(avenger, avenger, boardWithDeadEntity);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ShadowyConstruct_BG25_HERO_103_Buddy:\r\n\t\tcase CardIds.ShadowyConstruct_BG25_HERO_103_Buddy_G:\r\n\t\t\tconst neighboursShadowy = getNeighbours(boardWithDeadEntity, null, deadEntityIndexFromRight);\r\n\t\t\tconst multiplierShadowy = avenger.cardId === CardIds.ShadowyConstruct_BG25_HERO_103_Buddy_G ? 2 : 1;\r\n\t\t\tneighboursShadowy.forEach((neighbour) => {\r\n\t\t\t\tmodifyAttack(neighbour, multiplierShadowy * 1, boardWithDeadEntity, allCards);\r\n\t\t\t\tmodifyHealth(neighbour, multiplierShadowy * 1, boardWithDeadEntity, allCards);\r\n\t\t\t\tafterStatsUpdate(neighbour, boardWithDeadEntity, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(avenger, neighbour, boardWithDeadEntity);\r\n\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.IceSickle:\r\n\t\t\tgrantRandomStats(avenger, boardWithDeadEntityHero.hand, 3, 0, null, true, allCards, null);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.BoomSquad_BG27_Reward_502:\r\n\t\t\tconst highestHealthMinion = [...otherBoard].sort((a, b) => b.health - a.health)[0];\r\n\t\t\tdealDamageToEnemy(\r\n\t\t\t\thighestHealthMinion,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tavenger,\r\n\t\t\t\t10,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\tspectator.registerPowerTarget(avenger, highestHealthMinion, otherBoard);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.RelentlessSentry_BG25_003:\r\n\t\tcase CardIds.RelentlessSentry_BG25_003_G:\r\n\t\t\tavenger.reborn = true;\r\n\t\t\tavenger.taunt = true;\r\n\t\t\tbreak;\r\n\t\tcase CardIds.RelentlessMurghoul_BG27_010:\r\n\t\tcase CardIds.RelentlessMurghoul_BG27_010_G:\r\n\t\t\tavenger.reborn = true;\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ChampionOfThePrimus_BG27_029:\r\n\t\tcase CardIds.ChampionOfThePrimus_BG27_029_G:\r\n\t\t\tconst championPrimusStat = avenger.cardId === CardIds.ChampionOfThePrimus_BG27_029_G ? 2 : 1;\r\n\t\t\tboardWithDeadEntityHero.globalInfo.UndeadAttackBonus += championPrimusStat;\r\n\t\t\tbreak;\r\n\t}\r\n\tavenger.avengeCurrent = avenger.avengeDefault;\r\n};\r\n\r\nconst handleHeroAvenge = (\r\n\tdeadEntity: BoardEntity,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tcandidatesEntitiesSpawnedFromAvenge: BoardEntity[],\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n\tallCards: AllCardsService,\r\n) => {\r\n\t// https://twitter.com/LoewenMitchell/status/1491879869457879040\r\n\t// Not affected by Khadgar\r\n\tswitch (boardWithDeadEntityHero?.heroPowerId) {\r\n\t\tcase CardIds.Onyxia_Broodmother:\r\n\t\t\tcandidatesEntitiesSpawnedFromAvenge.push(\r\n\t\t\t\t...spawnEntities(\r\n\t\t\t\t\tCardIds.Onyxia_OnyxianWhelpToken,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\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\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t),\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.VanndarStormpike_LeadTheStormpikes:\r\n\t\t\tboardWithDeadEntity\r\n\t\t\t\t.filter((entity) => !entity.definitelyDead && entity.health > 0)\r\n\t\t\t\t.forEach((entity) => {\r\n\t\t\t\t\tmodifyHealth(entity, 1, boardWithDeadEntity, allCards);\r\n\t\t\t\t\tafterStatsUpdate(entity, boardWithDeadEntity, allCards);\r\n\t\t\t\t\tspectator.registerPowerTarget(boardWithDeadEntityHero, entity, boardWithDeadEntity);\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Drekthar_LeadTheFrostwolves:\r\n\t\t\tboardWithDeadEntity.forEach((entity) => {\r\n\t\t\t\tmodifyAttack(entity, 1, boardWithDeadEntity, allCards);\r\n\t\t\t\tafterStatsUpdate(entity, boardWithDeadEntity, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(boardWithDeadEntityHero, entity, boardWithDeadEntity);\r\n\t\t\t});\r\n\t\t\tbreak;\r\n\t}\r\n\tboardWithDeadEntityHero.avengeCurrent = boardWithDeadEntityHero.avengeDefault;\r\n};\r\n"]}
1
+ {"version":3,"file":"avenge.js","sourceRoot":"","sources":["../../src/simulation/avenge.ts"],"names":[],"mappings":";;;AAAA,iEAA8E;AAI9E,6CAA+C;AAC/C,oCAakB;AAClB,qCAAiF;AACjF,6CAA+C;AAC/C,6DAAqD;AAI9C,MAAM,kBAAkB,GAAG,CACjC,UAAuB,EACvB,wBAAgC,EAChC,mBAAkC,EAClC,uBAAwC,EACxC,UAAyB,EACzB,cAA+B,EAC/B,QAAyB,EACzB,SAAoB,EACpB,WAAwB,EACxB,SAAoB,EACb,EAAE;IACT,MAAM,mCAAmC,GAAkB,EAAE,CAAC;IAC9D,oBAAoB,CAAC,mBAAmB,EAAE,uBAAuB,CAAC,CAAC;IACnE,MAAM,QAAQ,GAAG,mBAAmB;SAClC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,IAAI,CAAC,CAAC,aAAa,IAAI,CAAC,CAAC;SAGxD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACd,IAAI,CAAC,CAAC,MAAM,eAAiC,IAAI,CAAC,CAAC,MAAM,iBA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C;YACH,MAAM;KACP;IACD,uBAAuB,CAAC,aAAa,GAAG,uBAAuB,CAAC,aAAa,CAAC;AAC/E,CAAC,CAAC","sourcesContent":["import { AllCardsService, CardIds, 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 { pickRandom } from '../services/utils';\r\nimport {\r\n\taddCardsInHand,\r\n\taddStatsToBoard,\r\n\tafterStatsUpdate,\r\n\tgetRandomAliveMinion,\r\n\tgetRandomMinionWithHighestHealth,\r\n\tgrantRandomStats,\r\n\tgrantStatsToMinionsOfEachType,\r\n\thasCorrectTribe,\r\n\tisMinionGolden,\r\n\tmakeMinionGolden,\r\n\tmodifyAttack,\r\n\tmodifyHealth,\r\n} from '../utils';\r\nimport { dealDamageToEnemy, getNeighbours, performEntitySpawns } from './attack';\r\nimport { playBloodGemsOn } from './blood-gems';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { SharedState } from './shared-state';\r\nimport { Spectator } from './spectator/spectator';\r\n\r\nexport const applyAvengeEffects = (\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\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst candidatesEntitiesSpawnedFromAvenge: BoardEntity[] = [];\r\n\tupdateAvengeCounters(boardWithDeadEntity, boardWithDeadEntityHero);\r\n\tconst avengers = boardWithDeadEntity\r\n\t\t.filter((e) => !!e.avengeDefault && e.avengeCurrent <= 0)\r\n\t\t// Get Tony to be processed first, because of the \"when turned golden, the minion ignores the death for the avenge counter\"\r\n\t\t// behavior\r\n\t\t.sort((a, b) => {\r\n\t\t\tif (a.cardId === CardIds.TonyTwoTusk_BG21_031 || a.cardId === CardIds.TonyTwoTusk_BG21_031_G) {\r\n\t\t\t\treturn -1;\r\n\t\t\t}\r\n\t\t\tif (b.cardId === CardIds.TonyTwoTusk_BG21_031 || b.cardId === CardIds.TonyTwoTusk_BG21_031_G) {\r\n\t\t\t\treturn 1;\r\n\t\t\t}\r\n\t\t\treturn 0;\r\n\t\t});\r\n\tfor (const avenger of avengers) {\r\n\t\thandleAvenge(\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\tdeadEntity,\r\n\t\t\tdeadEntityIndexFromRight,\r\n\t\t\tavenger,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t}\r\n\t// console.log('updating dead entity avenge counter', boardWithDeadEntityHero.avengeCurrent, stringifySimpleCard(deadEntity, allCards));\r\n\tconst heroAvenger = !!boardWithDeadEntityHero.avengeDefault && boardWithDeadEntityHero.avengeCurrent === 0;\r\n\tif (heroAvenger) {\r\n\t\t// console.log(\r\n\t\t// \t'Hero is an avenger',\r\n\t\t// \tboardWithDeadEntityHero.avengeCurrent,\r\n\t\t// \tboardWithDeadEntityHero.avengeDefault,\r\n\t\t// \tboardWithDeadEntityHero.heroPowerId,\r\n\t\t// );\r\n\t\thandleHeroAvenge(\r\n\t\t\tdeadEntity,\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tcandidatesEntitiesSpawnedFromAvenge,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t}\r\n\r\n\tconst questRewardAvengers = boardWithDeadEntityHero.questRewardEntities.filter(\r\n\t\t(e) => !!e.avengeDefault && e.avengeCurrent <= 0,\r\n\t);\r\n\tfor (const avenger of questRewardAvengers) {\r\n\t\thandleAvenge(\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\tdeadEntity,\r\n\t\t\tdeadEntityIndexFromRight,\r\n\t\t\tavenger as BoardEntity,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t}\r\n\r\n\tperformEntitySpawns(\r\n\t\tcandidatesEntitiesSpawnedFromAvenge,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tdeadEntity,\r\n\t\tdeadEntityIndexFromRight,\r\n\t\totherBoard,\r\n\t\totherBoardHero,\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 updateAvengeCounters = (board: readonly BoardEntity[], boardWithDeadEntityHero: BgsPlayerEntity) => {\r\n\tfor (const entity of board) {\r\n\t\tif (!!entity.avengeDefault) {\r\n\t\t\tentity.avengeCurrent -= 1;\r\n\t\t}\r\n\t}\r\n\tif (!!boardWithDeadEntityHero.avengeDefault) {\r\n\t\tboardWithDeadEntityHero.avengeCurrent -= 1;\r\n\t}\r\n\r\n\tfor (const reward of boardWithDeadEntityHero.questRewardEntities) {\r\n\t\tif (!!reward.avengeDefault) {\r\n\t\t\treward.avengeCurrent -= 1;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleAvenge = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tavenger: BoardEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n\tallCards: AllCardsService,\r\n) => {\r\n\t// Don't forget to update the avenge data in cards-data\r\n\tswitch (avenger.cardId) {\r\n\t\tcase CardIds.BirdBuddy_BG21_002:\r\n\t\t\taddStatsToBoard(avenger, boardWithDeadEntity, 1, 1, allCards, spectator, 'BEAST');\r\n\t\t\tbreak;\r\n\t\tcase CardIds.BirdBuddy_BG21_002_G:\r\n\t\t\taddStatsToBoard(avenger, boardWithDeadEntity, 2, 2, allCards, spectator, 'BEAST');\r\n\t\t\tbreak;\r\n\t\tcase CardIds.BuddingGreenthumb_BG21_030:\r\n\t\tcase CardIds.BuddingGreenthumb_BG21_030_G:\r\n\t\t\tconst neighbours = getNeighbours(boardWithDeadEntity, avenger);\r\n\t\t\tneighbours.forEach((entity) => {\r\n\t\t\t\tmodifyAttack(\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tavenger.cardId === CardIds.BuddingGreenthumb_BG21_030_G ? 4 : 2,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t);\r\n\t\t\t\tmodifyHealth(\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tavenger.cardId === CardIds.BuddingGreenthumb_BG21_030_G ? 2 : 1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t);\r\n\t\t\t\tafterStatsUpdate(entity, boardWithDeadEntity, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(avenger, entity, boardWithDeadEntity);\r\n\t\t\t});\r\n\t\t\tbreak;\r\n\t\t// case CardIds.FrostwolfLieutenant:\r\n\t\t// case CardIds.FrostwolfLieutenantBattlegrounds:\r\n\t\t// \taddStatsToBoard(\r\n\t\t// \t\tavenger,\r\n\t\t// \t\tboardWithDeadEntity,\r\n\t\t// \t\tavenger.cardId === CardIds.FrostwolfLieutenantBattlegrounds ? 2 : 1,\r\n\t\t// \t\t0,\r\n\t\t// \t\tallCards,\r\n\t\t// \t\tspectator,\r\n\t\t// \t);\r\n\t\t// \tbreak;\r\n\t\tcase CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy:\r\n\t\tcase CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy_G:\r\n\t\t\taddStatsToBoard(\r\n\t\t\t\tavenger,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t0,\r\n\t\t\t\tavenger.cardId === CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy_G ? 2 : 1,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PalescaleCrocolisk_BG21_001:\r\n\t\t\tconst target1 = grantRandomStats(avenger, boardWithDeadEntity, 6, 6, Race.BEAST, true, allCards, spectator);\r\n\t\t\tif (!!target1) {\r\n\t\t\t\tspectator.registerPowerTarget(avenger, target1, boardWithDeadEntity);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PalescaleCrocolisk_BG21_001_G:\r\n\t\t\tconst target2 = grantRandomStats(\r\n\t\t\t\tavenger,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t12,\r\n\t\t\t\t12,\r\n\t\t\t\tRace.BEAST,\r\n\t\t\t\ttrue,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\tif (!!target2) {\r\n\t\t\t\tspectator.registerPowerTarget(avenger, target2, boardWithDeadEntity);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ImpatientDoomsayer_BG21_007:\r\n\t\tcase CardIds.ImpatientDoomsayer_BG21_007_G:\r\n\t\t\tconst doomsayerCardsToAddQuantity = avenger.cardId === CardIds.ImpatientDoomsayer_BG21_007_G ? 2 : 1;\r\n\t\t\tconst doomsayerCardsToAdd = [];\r\n\t\t\tfor (let i = 0; i < doomsayerCardsToAddQuantity; i++) {\r\n\t\t\t\tdoomsayerCardsToAdd.push(pickRandom(cardsData.demonSpawns));\r\n\t\t\t}\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, allCards, spectator, doomsayerCardsToAdd);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PashmarTheVengeful_BG23_014:\r\n\t\tcase CardIds.PashmarTheVengeful_BG23_014_G:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, allCards, spectator, [null]);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.WitchwingNestmatron_BG21_038:\r\n\t\tcase CardIds.WitchwingNestmatron_BG21_038_G:\r\n\t\t\tconst nestmatronToAddQuantity = avenger.cardId === CardIds.WitchwingNestmatron_BG21_038_G ? 2 : 1;\r\n\t\t\tconst nestmatronCardsToAdd = [];\r\n\t\t\tfor (let i = 0; i < nestmatronToAddQuantity; i++) {\r\n\t\t\t\tnestmatronCardsToAdd.push(pickRandom(cardsData.brannEpicEggSpawns));\r\n\t\t\t}\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, allCards, spectator, nestmatronCardsToAdd);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Thorncaller_BG20_105:\r\n\t\tcase CardIds.Thorncaller_BG20_105_G:\r\n\t\t\tconst thorncallerToAddQuantity = avenger.cardId === CardIds.Thorncaller_BG20_105_G ? 2 : 1;\r\n\t\t\tconst thorncallerCardsToAdd = Array(thorncallerToAddQuantity).fill(CardIds.BloodGem);\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, allCards, spectator, thorncallerCardsToAdd);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Sisefin_BG21_009:\r\n\t\tcase CardIds.Sisefin_BG21_009_G:\r\n\t\t\tconst poisonousIterations = avenger.cardId === CardIds.Sisefin_BG21_009_G ? 2 : 1;\r\n\t\t\tfor (let i = 0; i < poisonousIterations; i++) {\r\n\t\t\t\tconst validTargets = boardWithDeadEntity.filter((e) => !e.poisonous && !e.venomous);\r\n\t\t\t\tconst murloc = getRandomAliveMinion(validTargets, Race.MURLOC, allCards);\r\n\t\t\t\tif (murloc) {\r\n\t\t\t\t\tmurloc.venomous = true;\r\n\t\t\t\t\tspectator.registerPowerTarget(avenger, murloc, boardWithDeadEntity);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ScrapScraper_BG26_148:\r\n\t\tcase CardIds.ScrapScraper_BG26_148_G:\r\n\t\t\tconst scraperToAddQuantity = avenger.cardId === CardIds.ScrapScraper_BG26_148_G ? 2 : 1;\r\n\t\t\tconst scraperCardsToAdd = [];\r\n\t\t\tfor (let i = 0; i < scraperToAddQuantity; i++) {\r\n\t\t\t\tscraperCardsToAdd.push(pickRandom(cardsData.scrapScraperSpawns));\r\n\t\t\t}\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, allCards, spectator, scraperCardsToAdd);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.MechanoTank_BG21_023:\r\n\t\t\t// This can be null if the avenge triggers when the last enemy minion dies as well\r\n\t\t\tconst target = getRandomMinionWithHighestHealth(otherBoard);\r\n\t\t\tspectator.registerPowerTarget(avenger, target, otherBoard);\r\n\t\t\tdealDamageToEnemy(\r\n\t\t\t\ttarget,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tavenger,\r\n\t\t\t\t5,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.MechanoTank_BG21_023_G:\r\n\t\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\t\tconst target = getRandomMinionWithHighestHealth(otherBoard);\r\n\t\t\t\tspectator.registerPowerTarget(avenger, target, otherBoard);\r\n\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tavenger,\r\n\t\t\t\t\t5,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\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\tbreak;\r\n\t\tcase CardIds.TonyTwoTusk_BG21_031:\r\n\t\t\tconst nonGoldenMinions = boardWithDeadEntity\r\n\t\t\t\t.filter((e) => e.entityId !== avenger.entityId)\r\n\t\t\t\t.filter((e) => {\r\n\t\t\t\t\tconst ref = allCards.getCard(e.cardId);\r\n\t\t\t\t\treturn (\r\n\t\t\t\t\t\t!!ref.battlegroundsPremiumDbfId && !!allCards.getCardFromDbfId(ref.battlegroundsPremiumDbfId).id\r\n\t\t\t\t\t);\r\n\t\t\t\t});\r\n\t\t\tconst pirate = getRandomAliveMinion(nonGoldenMinions, Race.PIRATE, allCards);\r\n\t\t\tif (pirate) {\r\n\t\t\t\tmakeMinionGolden(pirate, avenger, boardWithDeadEntity, allCards, spectator);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.TonyTwoTusk_BG21_031_G:\r\n\t\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\t\tconst nonGoldenMinions = boardWithDeadEntity.filter((e) => !isMinionGolden(e, allCards));\r\n\t\t\t\tconst pirate = getRandomAliveMinion(nonGoldenMinions, Race.PIRATE, allCards);\r\n\t\t\t\tif (pirate) {\r\n\t\t\t\t\tmakeMinionGolden(pirate, avenger, boardWithDeadEntity, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.GhoulOfTheFeast_BG25_002:\r\n\t\tcase CardIds.GhoulOfTheFeast_BG25_002_G:\r\n\t\t\tconst ghoulMultiplier = avenger.cardId === CardIds.GhoulOfTheFeast_BG25_002_G ? 2 : 1;\r\n\t\t\tgrantStatsToMinionsOfEachType(avenger, boardWithDeadEntity, ghoulMultiplier * 3, 0, allCards, spectator);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Bristlebach_BG26_157:\r\n\t\tcase CardIds.Bristlebach_BG26_157_G:\r\n\t\t\tconst bristlebachMultiplier = avenger.cardId === CardIds.Bristlebach_BG26_157_G ? 2 : 1;\r\n\t\t\tfor (let i = 0; i < bristlebachMultiplier; i++) {\r\n\t\t\t\tconsole.log('playing blood gems on bristlebach');\r\n\t\t\t\tfor (const entity of boardWithDeadEntity) {\r\n\t\t\t\t\tif (hasCorrectTribe(entity, Race.QUILBOAR, allCards)) {\r\n\t\t\t\t\t\tplayBloodGemsOn(entity, 1, boardWithDeadEntity, boardWithDeadEntityHero, allCards, spectator);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.HungeringAbomination_BG25_014:\r\n\t\tcase CardIds.HungeringAbomination_BG25_014_G:\r\n\t\t\tconst abominationMultiplier = avenger.cardId === CardIds.HungeringAbomination_BG25_014_G ? 2 : 1;\r\n\t\t\tmodifyAttack(avenger, abominationMultiplier * 1, boardWithDeadEntity, allCards);\r\n\t\t\tmodifyHealth(avenger, abominationMultiplier * 1, boardWithDeadEntity, allCards);\r\n\t\t\tafterStatsUpdate(avenger, boardWithDeadEntity, allCards);\r\n\t\t\tspectator.registerPowerTarget(avenger, avenger, boardWithDeadEntity);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ShadowyConstruct_BG25_HERO_103_Buddy:\r\n\t\tcase CardIds.ShadowyConstruct_BG25_HERO_103_Buddy_G:\r\n\t\t\tconst neighboursShadowy = getNeighbours(boardWithDeadEntity, null, deadEntityIndexFromRight);\r\n\t\t\tconst multiplierShadowy = avenger.cardId === CardIds.ShadowyConstruct_BG25_HERO_103_Buddy_G ? 2 : 1;\r\n\t\t\tneighboursShadowy.forEach((neighbour) => {\r\n\t\t\t\tmodifyAttack(neighbour, multiplierShadowy * 1, boardWithDeadEntity, allCards);\r\n\t\t\t\tmodifyHealth(neighbour, multiplierShadowy * 1, boardWithDeadEntity, allCards);\r\n\t\t\t\tafterStatsUpdate(neighbour, boardWithDeadEntity, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(avenger, neighbour, boardWithDeadEntity);\r\n\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.IceSickle:\r\n\t\t\tgrantRandomStats(avenger, boardWithDeadEntityHero.hand, 3, 0, null, true, allCards, null);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.BoomSquad_BG27_Reward_502:\r\n\t\t\tconst highestHealthMinion = [...otherBoard].sort((a, b) => b.health - a.health)[0];\r\n\t\t\tdealDamageToEnemy(\r\n\t\t\t\thighestHealthMinion,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tavenger,\r\n\t\t\t\t10,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\tspectator.registerPowerTarget(avenger, highestHealthMinion, otherBoard);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.RelentlessSentry_BG25_003:\r\n\t\tcase CardIds.RelentlessSentry_BG25_003_G:\r\n\t\t\tavenger.reborn = true;\r\n\t\t\tavenger.taunt = true;\r\n\t\t\tbreak;\r\n\t\tcase CardIds.RelentlessMurghoul_BG27_010:\r\n\t\tcase CardIds.RelentlessMurghoul_BG27_010_G:\r\n\t\t\tavenger.reborn = true;\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ChampionOfThePrimus_BG27_029:\r\n\t\tcase CardIds.ChampionOfThePrimus_BG27_029_G:\r\n\t\t\tconst championPrimusStat = avenger.cardId === CardIds.ChampionOfThePrimus_BG27_029_G ? 2 : 1;\r\n\t\t\tboardWithDeadEntityHero.globalInfo.UndeadAttackBonus += championPrimusStat;\r\n\t\t\tbreak;\r\n\t}\r\n\tavenger.avengeCurrent = avenger.avengeDefault;\r\n};\r\n\r\nconst handleHeroAvenge = (\r\n\tdeadEntity: BoardEntity,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tcandidatesEntitiesSpawnedFromAvenge: BoardEntity[],\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n\tallCards: AllCardsService,\r\n) => {\r\n\t// https://twitter.com/LoewenMitchell/status/1491879869457879040\r\n\t// Not affected by Khadgar\r\n\tswitch (boardWithDeadEntityHero?.heroPowerId) {\r\n\t\tcase CardIds.Onyxia_Broodmother:\r\n\t\t\tcandidatesEntitiesSpawnedFromAvenge.push(\r\n\t\t\t\t...spawnEntities(\r\n\t\t\t\t\tCardIds.Onyxia_OnyxianWhelpToken,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\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\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t),\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.VanndarStormpike_LeadTheStormpikes:\r\n\t\t\tboardWithDeadEntity\r\n\t\t\t\t.filter((entity) => !entity.definitelyDead && entity.health > 0)\r\n\t\t\t\t.forEach((entity) => {\r\n\t\t\t\t\tmodifyHealth(entity, 1, boardWithDeadEntity, allCards);\r\n\t\t\t\t\tafterStatsUpdate(entity, boardWithDeadEntity, allCards);\r\n\t\t\t\t\tspectator.registerPowerTarget(boardWithDeadEntityHero, entity, boardWithDeadEntity);\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Drekthar_LeadTheFrostwolves:\r\n\t\t\tboardWithDeadEntity.forEach((entity) => {\r\n\t\t\t\tmodifyAttack(entity, 1, boardWithDeadEntity, allCards);\r\n\t\t\t\tafterStatsUpdate(entity, boardWithDeadEntity, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(boardWithDeadEntityHero, entity, boardWithDeadEntity);\r\n\t\t\t});\r\n\t\t\tbreak;\r\n\t}\r\n\tboardWithDeadEntityHero.avengeCurrent = boardWithDeadEntityHero.avengeDefault;\r\n};\r\n"]}
package/dist/utils.js CHANGED
@@ -413,9 +413,6 @@ exports.getRaceEnum = getRaceEnum;
413
413
  const addImpliedMechanics = (entity, cardsData) => {
414
414
  const cleave = CLEAVE_IDS.indexOf(entity.cardId) !== -1;
415
415
  const cantAttack = CANT_ATTACK_IDS.indexOf(entity.cardId) !== -1;
416
- if (!cleave && !cantAttack) {
417
- return entity;
418
- }
419
416
  return setImplicitDataForEntity({
420
417
  ...entity,
421
418
  cleave: cleave,
@@ -428,7 +425,9 @@ const addImpliedMechanics = (entity, cardsData) => {
428
425
  : entity.cardId === "BG20_204"
429
426
  ? 1
430
427
  : 0,
431
- abiityChargesLeft: entity.cardId === "BG27_013_G" ? 2 : 1,
428
+ abiityChargesLeft: ["BG27_013_G", "BG27_507_G"].includes(entity.cardId)
429
+ ? 2
430
+ : 1,
432
431
  }, cardsData);
433
432
  };
434
433
  exports.addImpliedMechanics = addImpliedMechanics;
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AACA,iEAAoH;AAKpH,4CAA4D;AAG5D,MAAM,UAAU,GAAG;;;;;;;CAOlB,CAAC;AACF,MAAM,sBAAsB,GAAG;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* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { ALL_BG_RACES, AllCardsService, CardIds, GameTag, Race, ReferenceCard } from '@firestone-hs/reference-data';\r\nimport { SharedState } from 'src/simulation/shared-state';\r\nimport { BgsPlayerEntity } from './bgs-player-entity';\r\nimport { BoardEntity } from './board-entity';\r\nimport { CardsData } from './cards/cards-data';\r\nimport { pickRandom, shuffleArray } from './services/utils';\r\nimport { Spectator } from './simulation/spectator/spectator';\r\n\r\nconst CLEAVE_IDS = [\r\n\tCardIds.CaveHydra_BG_LOOT_078,\r\n\tCardIds.CaveHydra_TB_BaconUps_151,\r\n\tCardIds.FoeReaper4000_BG_GVG_113,\r\n\tCardIds.FoeReaper4000_TB_BaconUps_153,\r\n\tCardIds.BladeCollector_BG26_817,\r\n\tCardIds.BladeCollector_BG26_817_G,\r\n];\r\nconst ATTACK_IMMEDIATELY_IDS = [\r\n\tCardIds.Scallywag_SkyPirateToken_BGS_061t,\r\n\tCardIds.Scallywag_SkyPirateToken_TB_BaconUps_141t,\r\n\tCardIds.Onyxia_OnyxianWhelpToken,\r\n];\r\nconst CANT_ATTACK_IDS = [CardIds.ArcaneCannon_BGS_077, CardIds.ArcaneCannon_TB_BaconUps_128];\r\n\r\nexport const buildSingleBoardEntity = (\r\n\tcardId: string,\r\n\tcontrollerHero: BgsPlayerEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tfriendly: boolean,\r\n\tentityId = 1,\r\n\tspawnReborn = false,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tentityToSpawn: BoardEntity,\r\n\toriginalEntity: BoardEntity = null,\r\n): BoardEntity => {\r\n\tconst card = allCards.getCard(cardId);\r\n\tconst attackImmediately = ATTACK_IMMEDIATELY_IDS.indexOf(cardId as CardIds) !== -1;\r\n\tconst newEntity = !!entityToSpawn\r\n\t\t? ({\r\n\t\t\t\t...entityToSpawn,\r\n\t\t\t\tentityId: sharedState.currentEntityId++,\r\n\t\t\t\tdefinitelyDead: false,\r\n\t\t\t\tavengeCurrent: entityToSpawn.avengeDefault,\r\n\t\t\t\tattacking: false,\r\n\t\t\t\tdamageMultiplier: 1,\r\n\t\t\t\tfrenzyChargesLeft: 1,\r\n\t\t\t\tfriendly: friendly,\r\n\t\t } as BoardEntity)\r\n\t\t: addImpliedMechanics(\r\n\t\t\t\t{\r\n\t\t\t\t\tentityId: entityId,\r\n\t\t\t\t\tattack: card.attack,\r\n\t\t\t\t\tattacksPerformed: 0,\r\n\t\t\t\t\tcardId: cardId,\r\n\t\t\t\t\tdivineShield: hasMechanic(card, 'DIVINE_SHIELD'),\r\n\t\t\t\t\thealth: card.health,\r\n\t\t\t\t\tmaxHealth: card.health,\r\n\t\t\t\t\ttaunt: hasMechanic(card, GameTag[GameTag.TAUNT]),\r\n\t\t\t\t\treborn: hasMechanic(card, 'REBORN'),\r\n\t\t\t\t\tpoisonous: hasMechanic(card, GameTag[GameTag.POISONOUS]),\r\n\t\t\t\t\tvenomous: hasMechanic(card, GameTag[GameTag.VENOMOUS]),\r\n\t\t\t\t\twindfury:\r\n\t\t\t\t\t\thasMechanic(card, GameTag[GameTag.WINDFURY]) ||\r\n\t\t\t\t\t\tcard.referencedTags?.includes(GameTag[GameTag.WINDFURY]),\r\n\t\t\t\t\tenchantments: [],\r\n\t\t\t\t\tfriendly: friendly,\r\n\t\t\t\t\tattackImmediately: attackImmediately,\r\n\t\t\t\t\tavengeCurrent: cardsData.avengeValue(cardId),\r\n\t\t\t\t\tavengeDefault: cardsData.avengeValue(cardId),\r\n\t\t\t\t} as BoardEntity,\r\n\t\t\t\tcardsData,\r\n\t\t );\r\n\r\n\tif (spawnReborn && !entityToSpawn) {\r\n\t\tif (cardId === CardIds.BuildAnUndead_PutricidesCreationToken) {\r\n\t\t\tconst stitchedCardId = !!originalEntity.additionalCards?.length ? originalEntity.additionalCards[0] : null;\r\n\t\t\tif (stitchedCardId) {\r\n\t\t\t\tconst stitchedCard = allCards.getCard(stitchedCardId);\r\n\t\t\t\tnewEntity.attack = newEntity.attack + stitchedCard.attack;\r\n\t\t\t\tnewEntity.maxHealth = newEntity.maxHealth + stitchedCard.health;\r\n\t\t\t\tnewEntity.taunt = newEntity.taunt || hasMechanic(stitchedCard, GameTag[GameTag.TAUNT]);\r\n\t\t\t\tnewEntity.divineShield =\r\n\t\t\t\t\tnewEntity.divineShield || hasMechanic(stitchedCard, GameTag[GameTag.DIVINE_SHIELD]);\r\n\t\t\t\tnewEntity.poisonous = newEntity.poisonous || hasMechanic(stitchedCard, GameTag[GameTag.POISONOUS]);\r\n\t\t\t\tnewEntity.venomous = newEntity.venomous || hasMechanic(stitchedCard, GameTag[GameTag.VENOMOUS]);\r\n\t\t\t\tnewEntity.windfury = newEntity.windfury || hasMechanic(stitchedCard, GameTag[GameTag.WINDFURY]);\r\n\t\t\t\tnewEntity.avengeCurrent = newEntity.avengeCurrent || cardsData.avengeValue(stitchedCardId);\r\n\t\t\t\tnewEntity.avengeDefault = newEntity.avengeDefault || cardsData.avengeValue(stitchedCardId);\r\n\t\t\t}\r\n\t\t}\r\n\t\tnewEntity.health = 1;\r\n\t\tnewEntity.reborn = false;\r\n\t}\r\n\r\n\tnewEntity.hadDivineShield = newEntity.divineShield || newEntity.hadDivineShield;\r\n\treturn newEntity;\r\n};\r\n\r\nexport const buildRandomUndeadCreation = (\r\n\tcontrollerHero: BgsPlayerEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tfriendly: boolean,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n): BoardEntity => {\r\n\tconst baseCard = pickRandom(cardsData.putricidePool1);\r\n\tconst stitchedCardId =\r\n\t\tbaseCard === CardIds.EternalSummoner_BG25_009\r\n\t\t\t? pickRandom(cardsData.putridicePool2ForEternalSummoner)\r\n\t\t\t: pickRandom(cardsData.putricidePool2);\r\n\tconst newEntity = buildSingleBoardEntity(\r\n\t\tbaseCard,\r\n\t\tcontrollerHero,\r\n\t\tfriendlyBoard,\r\n\t\tallCards,\r\n\t\tfriendly,\r\n\t\tsharedState.currentEntityId++,\r\n\t\tfalse,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tnull,\r\n\t);\r\n\tconst stitchedCard = allCards.getCard(stitchedCardId);\r\n\tnewEntity.attack += stitchedCard.attack;\r\n\tnewEntity.health += stitchedCard.health;\r\n\tnewEntity.taunt = newEntity.taunt || hasMechanic(stitchedCard, GameTag[GameTag.TAUNT]);\r\n\tnewEntity.divineShield = newEntity.divineShield || hasMechanic(stitchedCard, GameTag[GameTag.DIVINE_SHIELD]);\r\n\tnewEntity.poisonous = newEntity.venomous || hasMechanic(stitchedCard, GameTag[GameTag.POISONOUS]);\r\n\tnewEntity.venomous = newEntity.poisonous || hasMechanic(stitchedCard, GameTag[GameTag.VENOMOUS]);\r\n\tnewEntity.windfury = newEntity.windfury || hasMechanic(stitchedCard, GameTag[GameTag.WINDFURY]);\r\n\tnewEntity.avengeCurrent = newEntity.avengeCurrent || cardsData.avengeValue(stitchedCardId);\r\n\tnewEntity.avengeDefault = newEntity.avengeDefault || cardsData.avengeValue(stitchedCardId);\r\n\treturn newEntity;\r\n};\r\n\r\nexport const modifyAttack = (\r\n\tentity: BoardEntity,\r\n\tamount: number,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator = null,\r\n): void => {\r\n\tconst realAmount = entity.cardId === CardIds.Tarecgosa_BG21_015_G ? 2 * amount : amount;\r\n\tentity.attack = Math.max(0, entity.attack + realAmount);\r\n\tentity.previousAttack = entity.attack;\r\n\tif (isCorrectTribe(allCards.getCard(entity.cardId).races, Race.DRAGON)) {\r\n\t\tconst whelpSmugglers = friendlyBoard.filter(\r\n\t\t\t(e) => e.cardId === CardIds.WhelpSmuggler_BG21_013 || e.cardId === CardIds.WhelpSmuggler_BG21_013_G,\r\n\t\t);\r\n\t\twhelpSmugglers.forEach((smuggler) => {\r\n\t\t\tconst buff = smuggler.cardId === CardIds.WhelpSmuggler_BG21_013_G ? 2 : 1;\r\n\t\t\tmodifyHealth(entity, buff, friendlyBoard, allCards);\r\n\t\t});\r\n\r\n\t\tif (entity.cardId !== CardIds.Stormbringer_BG26_966 && entity.cardId !== CardIds.Stormbringer_BG26_966_G) {\r\n\t\t\tconst stormbringers = friendlyBoard.filter(\r\n\t\t\t\t(e) => e.cardId === CardIds.Stormbringer_BG26_966 || e.cardId === CardIds.Stormbringer_BG26_966_G,\r\n\t\t\t);\r\n\t\t\tstormbringers.forEach((stormbringer) => {\r\n\t\t\t\tconst multiplier = stormbringer.cardId === CardIds.Stormbringer_BG26_966_G ? 2 : 1;\r\n\t\t\t\t(e) => modifyAttack(e, multiplier * amount, friendlyBoard, allCards);\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\tif (\r\n\t\tentity.cardId === CardIds.Menagerist_AmalgamToken ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A_G ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D_G\r\n\t) {\r\n\t\tconst mishmashes = friendlyBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy ||\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G,\r\n\t\t);\r\n\t\tmishmashes.forEach((mishmash) => {\r\n\t\t\tmodifyAttack(\r\n\t\t\t\tmishmash,\r\n\t\t\t\t(mishmash.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G ? 2 : 1) * realAmount,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tallCards,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\r\n\tif ([CardIds.HunterOfGatherers_BG25_027, CardIds.HunterOfGatherers_BG25_027_G].includes(entity.cardId as CardIds)) {\r\n\t\taddStatsToBoard(\r\n\t\t\tentity,\r\n\t\t\tfriendlyBoard,\r\n\t\t\t0,\r\n\t\t\tentity.cardId === CardIds.HunterOfGatherers_BG25_027_G ? 2 : 1,\r\n\t\t\tallCards,\r\n\t\t\tnull,\r\n\t\t);\r\n\t}\r\n};\r\n\r\nexport const modifyHealth = (\r\n\tentity: BoardEntity,\r\n\tamount: number,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\tconst realAmount = entity.cardId === CardIds.Tarecgosa_BG21_015 ? 2 * amount : amount;\r\n\tentity.health += realAmount;\r\n\tif (realAmount > 0) {\r\n\t\tentity.maxHealth += realAmount;\r\n\t}\r\n\tif (\r\n\t\tentity.cardId === CardIds.Menagerist_AmalgamToken ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A_G ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D_G\r\n\t) {\r\n\t\tconst mishmashes = friendlyBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy ||\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G,\r\n\t\t);\r\n\t\tmishmashes.forEach((mishmash) => {\r\n\t\t\tmodifyHealth(\r\n\t\t\t\tmishmash,\r\n\t\t\t\t(mishmash.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G ? 2 : 1) * realAmount,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tallCards,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\r\n\tconst titanicGuardians = friendlyBoard\r\n\t\t.filter((e) => e.entityId !== entity.entityId)\r\n\t\t.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy ||\r\n\t\t\t\te.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy_G,\r\n\t\t);\r\n\ttitanicGuardians.forEach((guardian) => {\r\n\t\tmodifyHealth(\r\n\t\t\tguardian,\r\n\t\t\t(guardian.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy_G ? 2 : 1) * realAmount,\r\n\t\t\tfriendlyBoard,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t});\r\n};\r\n\r\nexport const afterStatsUpdate = (\r\n\tentity: BoardEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\tif (hasCorrectTribe(entity, Race.ELEMENTAL, allCards)) {\r\n\t\tconst masterOfRealities = friendlyBoard.filter(\r\n\t\t\t(e) => e.cardId === CardIds.MasterOfRealities_BG21_036 || e.cardId === CardIds.MasterOfRealities_BG21_036_G,\r\n\t\t);\r\n\t\tmasterOfRealities.forEach((master) => {\r\n\t\t\tmodifyAttack(\r\n\t\t\t\tmaster,\r\n\t\t\t\tmaster.cardId === CardIds.MasterOfRealities_BG21_036_G ? 2 : 1,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tallCards,\r\n\t\t\t);\r\n\t\t\tmodifyHealth(\r\n\t\t\t\tmaster,\r\n\t\t\t\tmaster.cardId === CardIds.MasterOfRealities_BG21_036_G ? 2 : 1,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tallCards,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\tconst tentaclesOfCthun = friendlyBoard\r\n\t\t.filter((e) => e.entityId !== entity.entityId)\r\n\t\t.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy ||\r\n\t\t\t\te.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G,\r\n\t\t);\r\n\ttentaclesOfCthun.forEach((tentacle) => {\r\n\t\tmodifyAttack(\r\n\t\t\ttentacle,\r\n\t\t\ttentacle.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G ? 2 : 1,\r\n\t\t\tfriendlyBoard,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t\tmodifyHealth(\r\n\t\t\ttentacle,\r\n\t\t\ttentacle.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G ? 2 : 1,\r\n\t\t\tfriendlyBoard,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t});\r\n};\r\n\r\nexport const makeMinionGolden = (\r\n\ttarget: BoardEntity,\r\n\tsource: BoardEntity | BgsPlayerEntity,\r\n\tsourceBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// Typically, we are already golden\r\n\tif (isMinionGolden(target, allCards)) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst refCard = allCards.getCard(target.cardId);\r\n\tconst goldenCard = allCards.getCardFromDbfId(refCard.battlegroundsPremiumDbfId);\r\n\ttarget.cardId = goldenCard.id;\r\n\t// A minion becoming golden ignore the current death.\r\n\t// This way of handling it is not ideal, since it will still trigger if both avenges trigger at the same time, but\r\n\t// should solve the other cases\r\n\ttarget.avengeCurrent = Math.min(target.avengeDefault, target.avengeCurrent + 1);\r\n\tmodifyAttack(target, refCard.attack, sourceBoard, allCards);\r\n\tmodifyHealth(target, refCard.health, sourceBoard, allCards);\r\n\tafterStatsUpdate(target, sourceBoard, allCards);\r\n\tspectator.registerPowerTarget(source, target, sourceBoard);\r\n};\r\n\r\nexport const isMinionGolden = (entity: BoardEntity, allCards: AllCardsService): boolean => {\r\n\tconst ref = allCards.getCard(entity.cardId);\r\n\treturn !ref.battlegroundsPremiumDbfId;\r\n\t// Why this condition?\r\n\t// || !allCards.getCardFromDbfId(ref.battlegroundsPremiumDbfId).id\r\n};\r\n\r\nexport const grantRandomAttack = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tadditionalAttack: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\texcludeSource = false,\r\n): void => {\r\n\tconst candidateBoard = board\r\n\t\t.filter((e) => !excludeSource || e.entityId !== source.entityId)\r\n\t\t.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tif (candidateBoard.length > 0) {\r\n\t\tconst target = candidateBoard[Math.floor(Math.random() * candidateBoard.length)];\r\n\t\tmodifyAttack(target, additionalAttack, candidateBoard, allCards);\r\n\t\tafterStatsUpdate(target, candidateBoard, allCards);\r\n\t\tspectator.registerPowerTarget(source, target, board);\r\n\t}\r\n};\r\n\r\nexport const grantRandomHealth = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thealth: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\texcludeSource = false,\r\n): void => {\r\n\tconst candidateBoard = board\r\n\t\t.filter((e) => !excludeSource || e.entityId !== source.entityId)\r\n\t\t.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tif (candidateBoard.length > 0) {\r\n\t\tconst target = candidateBoard[Math.floor(Math.random() * candidateBoard.length)];\r\n\t\tmodifyHealth(target, health, board, allCards);\r\n\t\tafterStatsUpdate(target, board, allCards);\r\n\t\tspectator.registerPowerTarget(source, target, board);\r\n\t}\r\n};\r\n\r\nexport const grantRandomStats = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tattack: number,\r\n\thealth: number,\r\n\trace: Race,\r\n\texcludeSource: boolean,\r\n\tallCards: AllCardsService,\r\n\tspectator?: Spectator,\r\n): BoardEntity => {\r\n\tif (board.length > 0) {\r\n\t\tconst target: BoardEntity = getRandomAliveMinion(\r\n\t\t\tboard.filter((e) => (excludeSource ? e.entityId !== source.entityId : true)),\r\n\t\t\trace,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t\tif (target) {\r\n\t\t\tmodifyAttack(target, attack, board, allCards);\r\n\t\t\tmodifyHealth(target, health, board, allCards);\r\n\t\t\tafterStatsUpdate(target, board, allCards);\r\n\t\t\tif (spectator) {\r\n\t\t\t\tspectator.registerPowerTarget(source, target, board);\r\n\t\t\t}\r\n\t\t\treturn target;\r\n\t\t}\r\n\t}\r\n\treturn null;\r\n};\r\n\r\nexport const addCardsInHand = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tboard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tcardsAdded: readonly any[],\r\n): void => {\r\n\tconst previousCardsInHand = playerEntity.hand?.length ?? 0;\r\n\tconst sages = board.filter((e) => e.cardId === CardIds.DeathsHeadSage_BG20_HERO_103_Buddy);\r\n\tconst sagesGolden = board.filter((e) => e.cardId === CardIds.DeathsHeadSage_BG20_HERO_103_Buddy_G);\r\n\tconst multiplier = sages.length + 2 * sagesGolden.length;\r\n\r\n\tconst cardsThatWillBeAdded = [];\r\n\tfor (const cardAdded of cardsAdded) {\r\n\t\tconst cardToAdd: { cardId: string } = (cardAdded as BoardEntity)?.cardId\r\n\t\t\t? (cardAdded as BoardEntity)\r\n\t\t\t: ({ cardId: cardAdded as string } as BoardEntity);\r\n\t\tcardsThatWillBeAdded.push(cardToAdd);\r\n\t\tif (cardToAdd.cardId === CardIds.BloodGem) {\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tcardsThatWillBeAdded.push({ ...cardToAdd });\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tfor (let i = 0; i < cardsThatWillBeAdded.length; i++) {\r\n\t\tif (playerEntity.hand.length >= 10) {\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tplayerEntity.hand.push(cardsThatWillBeAdded[i]);\r\n\t}\r\n\r\n\tconst numCardsAdded = playerEntity.hand.length - previousCardsInHand;\r\n\r\n\tfor (let i = 0; i < numCardsAdded; i++) {\r\n\t\tconst peggys = board.filter(\r\n\t\t\t(e) => e.cardId === CardIds.PeggySturdybone_BG25_032 || e.cardId === CardIds.PeggySturdybone_BG25_032_G,\r\n\t\t);\r\n\t\tpeggys.forEach((peggy) => {\r\n\t\t\tconst pirate = getRandomAliveMinion(\r\n\t\t\t\tboard.filter((e) => e.entityId !== peggy.entityId),\r\n\t\t\t\tRace.PIRATE,\r\n\t\t\t\tallCards,\r\n\t\t\t);\r\n\t\t\tif (pirate) {\r\n\t\t\t\tmodifyAttack(pirate, peggy.cardId === CardIds.PeggySturdybone_BG25_032_G ? 2 : 1, board, allCards);\r\n\t\t\t\tmodifyHealth(pirate, peggy.cardId === CardIds.PeggySturdybone_BG25_032_G ? 2 : 1, board, allCards);\r\n\t\t\t\tafterStatsUpdate(pirate, board, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(peggy, pirate, board);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tconst thornCaptains = board.filter(\r\n\t\t\t(e) => e.cardId === CardIds.Thorncaptain_BG25_045 || e.cardId === CardIds.Thorncaptain_BG25_045_G,\r\n\t\t);\r\n\t\tthornCaptains.forEach((captain) => {\r\n\t\t\tmodifyHealth(captain, captain.cardId === CardIds.Thorncaptain_BG25_045_G ? 2 : 1, board, allCards);\r\n\t\t\tafterStatsUpdate(captain, board, allCards);\r\n\t\t\tspectator.registerPowerTarget(captain, captain, board);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const removeCardFromHand = (playerEntity: BgsPlayerEntity, card: BoardEntity): void => {\r\n\tlet cardToRemove: BoardEntity;\r\n\tif (card?.entityId) {\r\n\t\tcardToRemove = playerEntity.hand.find((c) => c?.entityId !== card.entityId);\r\n\t} else if (card?.cardId) {\r\n\t\tcardToRemove = playerEntity.hand.find((c) => c?.cardId === card.cardId);\r\n\t} else {\r\n\t\t// Remove a single random card in hand that doesn't have an entityId\r\n\t\tcardToRemove =\r\n\t\t\tpickRandom(playerEntity.hand.filter((c) => !c?.entityId && !c?.cardId)) ?? pickRandom(playerEntity.hand);\r\n\t}\r\n\t// Remove the first occurrence of the card from playerEntity.cardsInHand, even if it is null\r\n\tconst index = playerEntity.hand.indexOf(cardToRemove);\r\n\tif (index !== -1) {\r\n\t\tplayerEntity.hand.splice(index, 1);\r\n\t}\r\n};\r\n\r\nexport const grantRandomDivineShield = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst elligibleEntities = board\r\n\t\t.filter((entity) => !entity.divineShield)\r\n\t\t.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\tif (elligibleEntities.length > 0) {\r\n\t\tconst chosen = elligibleEntities[Math.floor(Math.random() * elligibleEntities.length)];\r\n\t\tupdateDivineShield(chosen, board, true, allCards);\r\n\t\tspectator.registerPowerTarget(source, chosen, board);\r\n\t}\r\n\t// return board;\r\n};\r\n\r\nexport const updateDivineShield = (\r\n\tentity: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tnewValue: boolean,\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\t// if ((entity.divineShield ?? false) === newValue) {\r\n\t// \treturn;\r\n\t// }\r\n\tentity.divineShield = newValue;\r\n\tif (entity.divineShield) {\r\n\t\tentity.hadDivineShield = true;\r\n\t}\r\n\tif (entity.divineShield) {\r\n\t\tconst boardForDrake = board;\r\n\t\tconst statsBonus =\r\n\t\t\t8 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043).length +\r\n\t\t\t16 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043_G).length;\r\n\t\t// Don't trigger all \"on attack changed\" effects, since it's an aura\r\n\t\tentity.attack += statsBonus;\r\n\t} else {\r\n\t\t// Also consider itself\r\n\t\tconst boardForDrake = board;\r\n\t\tconst statsBonus =\r\n\t\t\t8 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043).length +\r\n\t\t\t16 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043_G).length;\r\n\t\tentity.attack -= statsBonus;\r\n\t}\r\n};\r\n\r\nexport const grantAllDivineShield = (board: BoardEntity[], tribe: string, cards: AllCardsService): void => {\r\n\tconst elligibleEntities = board\r\n\t\t.filter((entity) => !entity.divineShield)\r\n\t\t.filter((entity) => isCorrectTribe(cards.getCard(entity.cardId).races, getRaceEnum(tribe)));\r\n\tfor (const entity of elligibleEntities) {\r\n\t\tupdateDivineShield(entity, board, true, cards);\r\n\t}\r\n};\r\n\r\nexport const getRandomAliveMinion = (board: BoardEntity[], race: Race, allCards: AllCardsService): BoardEntity => {\r\n\tconst validTribes = board\r\n\t\t.filter((e) => !race || isCorrectTribe(allCards.getCard(e?.cardId).races, race))\r\n\t\t.filter((e) => !!e?.health && !e.definitelyDead);\r\n\tif (!validTribes.length) {\r\n\t\treturn null;\r\n\t}\r\n\tconst randomIndex = Math.floor(Math.random() * validTribes.length);\r\n\treturn validTribes[randomIndex];\r\n};\r\n\r\nexport const getRandomMinionWithHighestHealth = (board: BoardEntity[]): BoardEntity => {\r\n\tif (!board.length) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tconst highestHealth = Math.max(...board.map((e) => e.health));\r\n\tconst validMinions = board.filter((e) => e.health === highestHealth);\r\n\treturn validMinions[Math.floor(Math.random() * validMinions.length)];\r\n};\r\n\r\nexport const addStatsToBoard = (\r\n\tsourceEntity: BoardEntity | BgsPlayerEntity,\r\n\tboard: BoardEntity[],\r\n\tattack: number,\r\n\thealth: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\ttribe?: string,\r\n): void => {\r\n\tfor (const entity of board) {\r\n\t\tif (!tribe || hasCorrectTribe(entity, Race[tribe], allCards)) {\r\n\t\t\tmodifyAttack(entity, attack, board, allCards);\r\n\t\t\tmodifyHealth(entity, health, board, allCards);\r\n\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\tspectator?.registerPowerTarget(sourceEntity, entity, board);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const grantStatsToMinionsOfEachType = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tattack: number,\r\n\thealth: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tnumberOfDifferentTypes = 99,\r\n): void => {\r\n\tif (board.length > 0) {\r\n\t\tlet boardCopy = [...board];\r\n\t\tconst allRaces = shuffleArray(ALL_BG_RACES);\r\n\t\tlet typesBuffed = 0;\r\n\t\tfor (const tribe of allRaces) {\r\n\t\t\tif (typesBuffed >= numberOfDifferentTypes) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tconst validMinion: BoardEntity = getRandomAliveMinion(boardCopy, tribe, allCards);\r\n\t\t\tif (validMinion) {\r\n\t\t\t\tmodifyAttack(validMinion, attack, board, allCards);\r\n\t\t\t\tmodifyHealth(validMinion, health, board, allCards);\r\n\t\t\t\tafterStatsUpdate(validMinion, board, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(source, validMinion, board);\r\n\t\t\t\tboardCopy = boardCopy.filter((e) => e !== validMinion);\r\n\t\t\t\ttypesBuffed++;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const hasMechanic = (card: ReferenceCard, mechanic: string): boolean => {\r\n\treturn card.mechanics?.includes(mechanic);\r\n};\r\n\r\nexport const hasCorrectTribe = (entity: BoardEntity, targetTribe: Race, allCards: AllCardsService): boolean => {\r\n\treturn isCorrectTribe(allCards.getCard(entity.cardId).races, targetTribe);\r\n};\r\n\r\nexport const isCorrectTribe = (cardRaces: readonly string[], targetTribe: Race): boolean => {\r\n\tif (!cardRaces?.length) {\r\n\t\treturn false;\r\n\t}\r\n\treturn cardRaces\r\n\t\t.map((cardRace) => getRaceEnum(cardRace))\r\n\t\t.some((raceEnum) => raceEnum === Race.ALL || raceEnum === targetTribe);\r\n};\r\n\r\nexport const getRaceEnum = (race: string): Race => {\r\n\treturn Race[race];\r\n};\r\n\r\nexport const addImpliedMechanics = (entity: BoardEntity, cardsData: CardsData): BoardEntity => {\r\n\tconst cleave = CLEAVE_IDS.indexOf(entity.cardId as CardIds) !== -1;\r\n\tconst cantAttack = CANT_ATTACK_IDS.indexOf(entity.cardId as CardIds) !== -1;\r\n\t// Avoid creating a new object if not necessary\r\n\tif (!cleave && !cantAttack) {\r\n\t\treturn entity;\r\n\t}\r\n\treturn setImplicitDataForEntity(\r\n\t\t{\r\n\t\t\t...entity,\r\n\t\t\tcleave: cleave,\r\n\t\t\tcantAttack: cantAttack,\r\n\t\t\timmuneWhenAttackCharges:\r\n\t\t\t\tentity.cardId === CardIds.Warpwing_BG24_004 || entity.cardId === CardIds.Warpwing_BG24_004_G\r\n\t\t\t\t\t? 99999\r\n\t\t\t\t\t: 0,\r\n\t\t\tfrenzyChargesLeft:\r\n\t\t\t\tentity.cardId === CardIds.BristlebackKnight_BG20_204_G\r\n\t\t\t\t\t? 2\r\n\t\t\t\t\t: entity.cardId === CardIds.BristlebackKnight_BG20_204\r\n\t\t\t\t\t? 1\r\n\t\t\t\t\t: 0,\r\n\t\t\t// It's not an issue adding a charge for entities without a special ability\r\n\t\t\tabiityChargesLeft: entity.cardId === CardIds.TransmutedBramblewitch_BG27_013_G ? 2 : 1,\r\n\t\t} as BoardEntity,\r\n\t\tcardsData,\r\n\t);\r\n};\r\n\r\nconst setImplicitDataForEntity = (entity: BoardEntity, cardsData: CardsData): BoardEntity => {\r\n\tentity.cardId = normalizeCardIdForSkin(entity.cardId);\r\n\tentity.maxHealth = Math.max(0, entity.health);\r\n\tconst avengeValue = cardsData.avengeValue(entity.cardId);\r\n\tif (avengeValue > 0) {\r\n\t\tentity.avengeCurrent = avengeValue;\r\n\t\tentity.avengeDefault = avengeValue;\r\n\t}\r\n\treturn entity;\r\n};\r\n\r\nexport const normalizeCardIdForSkin = (cardId: string): string => {\r\n\tconst skinMatch = cardId.match(/(.*)_SKIN_.*/);\r\n\tif (skinMatch) {\r\n\t\treturn skinMatch[1];\r\n\t}\r\n\treturn cardId;\r\n};\r\n\r\nexport const stringifySimple = (board: readonly BoardEntity[], allCards: AllCardsService = null): string => {\r\n\treturn '[' + board.map((entity) => stringifySimpleCard(entity, allCards)).join(', ') + ']';\r\n};\r\n\r\nexport const stringifySimpleCard = (entity: BoardEntity, allCards: AllCardsService = null): string => {\r\n\treturn entity\r\n\t\t? `${entity.cardId}/${allCards?.getCard(entity.cardId)?.name ?? ''}/atk=${entity.attack}/hp=${\r\n\t\t\t\tentity.health\r\n\t\t }/ds=${entity.divineShield}`\r\n\t\t: null;\r\n};\r\n\r\nexport const isFish = (entity: BoardEntity): boolean => {\r\n\treturn (\r\n\t\tentity.cardId.startsWith(CardIds.AvatarOfNzoth_FishOfNzothToken) ||\r\n\t\tentity.cardId.startsWith(CardIds.FishOfNzoth) ||\r\n\t\tentity.additionalCards?.includes(CardIds.DevourerOfSouls_BG_RLK_538)\r\n\t);\r\n};\r\n\r\nexport const isGolden = (cardId: string, allCards: AllCardsService): boolean => {\r\n\treturn !!allCards.getCard(cardId).battlegroundsNormalDbfId;\r\n};\r\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AACA,iEAAoH;AAKpH,4CAA4D;AAG5D,MAAM,UAAU,GAAG;;;;;;;CAOlB,CAAC;AACF,MAAM,sBAAsB,GAAG;;;;CAI9B,CAAC;AACF,MAAM,eAAe,GAAG,8BAAoE,CAAC;AAEtF,MAAM,sBAAsB,GAAG,CACrC,MAAc,EACd,cAA+B,EAC/B,aAA4B,EAC5B,QAAyB,EACzB,QAAiB,EACjB,QAAQ,GAAG,CAAC,EACZ,WAAW,GAAG,KAAK,EACnB,SAAoB,EACpB,WAAwB,EACxB,aAA0B,EAC1B,iBAA8B,IAAI,EACpB,EAAE;;IAChB,MAAM,IAAI,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,eAAe,mBAE1B;AAEK,MAAM,mBAAmB,GAAG,CAAC,MAAmB,EAAE,WAA4B,IAAI,EAAU,EAAE;;IACpG,OAAO,MAAM;QACZ,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,IAAI,MAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,0CAAE,IAAI,mCAAI,EAAE,QAAQ,MAAM,CAAC,MAAM,OACrF,MAAM,CAAC,MACP,OAAO,MAAM,CAAC,YAAY,EAAE;QAC9B,CAAC,CAAC,IAAI,CAAC;AACT,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B;AAEK,MAAM,MAAM,GAAG,CAAC,MAAmB,EAAW,EAAE;;IACtD,OAAO,CACN,MAAM,CAAC,MAAM,CAAC,UAAU,wBAAwC;QAChE,MAAM,CAAC,MAAM,CAAC,UAAU,mBAAqB;SAC7C,MAAA,MAAM,CAAC,eAAe,0CAAE,QAAQ,cAAoC,CAAA,CACpE,CAAC;AACH,CAAC,CAAC;AANW,QAAA,MAAM,UAMjB;AAEK,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAE,QAAyB,EAAW,EAAE;IAC9E,OAAO,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,wBAAwB,CAAC;AAC5D,CAAC,CAAC;AAFW,QAAA,QAAQ,YAEnB","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { ALL_BG_RACES, AllCardsService, CardIds, GameTag, Race, ReferenceCard } from '@firestone-hs/reference-data';\r\nimport { SharedState } from 'src/simulation/shared-state';\r\nimport { BgsPlayerEntity } from './bgs-player-entity';\r\nimport { BoardEntity } from './board-entity';\r\nimport { CardsData } from './cards/cards-data';\r\nimport { pickRandom, shuffleArray } from './services/utils';\r\nimport { Spectator } from './simulation/spectator/spectator';\r\n\r\nconst CLEAVE_IDS = [\r\n\tCardIds.CaveHydra_BG_LOOT_078,\r\n\tCardIds.CaveHydra_TB_BaconUps_151,\r\n\tCardIds.FoeReaper4000_BG_GVG_113,\r\n\tCardIds.FoeReaper4000_TB_BaconUps_153,\r\n\tCardIds.BladeCollector_BG26_817,\r\n\tCardIds.BladeCollector_BG26_817_G,\r\n];\r\nconst ATTACK_IMMEDIATELY_IDS = [\r\n\tCardIds.Scallywag_SkyPirateToken_BGS_061t,\r\n\tCardIds.Scallywag_SkyPirateToken_TB_BaconUps_141t,\r\n\tCardIds.Onyxia_OnyxianWhelpToken,\r\n];\r\nconst CANT_ATTACK_IDS = [CardIds.ArcaneCannon_BGS_077, CardIds.ArcaneCannon_TB_BaconUps_128];\r\n\r\nexport const buildSingleBoardEntity = (\r\n\tcardId: string,\r\n\tcontrollerHero: BgsPlayerEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tfriendly: boolean,\r\n\tentityId = 1,\r\n\tspawnReborn = false,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tentityToSpawn: BoardEntity,\r\n\toriginalEntity: BoardEntity = null,\r\n): BoardEntity => {\r\n\tconst card = allCards.getCard(cardId);\r\n\tconst attackImmediately = ATTACK_IMMEDIATELY_IDS.indexOf(cardId as CardIds) !== -1;\r\n\tconst newEntity = !!entityToSpawn\r\n\t\t? ({\r\n\t\t\t\t...entityToSpawn,\r\n\t\t\t\tentityId: sharedState.currentEntityId++,\r\n\t\t\t\tdefinitelyDead: false,\r\n\t\t\t\tavengeCurrent: entityToSpawn.avengeDefault,\r\n\t\t\t\tattacking: false,\r\n\t\t\t\tdamageMultiplier: 1,\r\n\t\t\t\tfrenzyChargesLeft: 1,\r\n\t\t\t\tfriendly: friendly,\r\n\t\t } as BoardEntity)\r\n\t\t: addImpliedMechanics(\r\n\t\t\t\t{\r\n\t\t\t\t\tentityId: entityId,\r\n\t\t\t\t\tattack: card.attack,\r\n\t\t\t\t\tattacksPerformed: 0,\r\n\t\t\t\t\tcardId: cardId,\r\n\t\t\t\t\tdivineShield: hasMechanic(card, 'DIVINE_SHIELD'),\r\n\t\t\t\t\thealth: card.health,\r\n\t\t\t\t\tmaxHealth: card.health,\r\n\t\t\t\t\ttaunt: hasMechanic(card, GameTag[GameTag.TAUNT]),\r\n\t\t\t\t\treborn: hasMechanic(card, 'REBORN'),\r\n\t\t\t\t\tpoisonous: hasMechanic(card, GameTag[GameTag.POISONOUS]),\r\n\t\t\t\t\tvenomous: hasMechanic(card, GameTag[GameTag.VENOMOUS]),\r\n\t\t\t\t\twindfury:\r\n\t\t\t\t\t\thasMechanic(card, GameTag[GameTag.WINDFURY]) ||\r\n\t\t\t\t\t\tcard.referencedTags?.includes(GameTag[GameTag.WINDFURY]),\r\n\t\t\t\t\tenchantments: [],\r\n\t\t\t\t\tfriendly: friendly,\r\n\t\t\t\t\tattackImmediately: attackImmediately,\r\n\t\t\t\t\tavengeCurrent: cardsData.avengeValue(cardId),\r\n\t\t\t\t\tavengeDefault: cardsData.avengeValue(cardId),\r\n\t\t\t\t} as BoardEntity,\r\n\t\t\t\tcardsData,\r\n\t\t );\r\n\r\n\tif (spawnReborn && !entityToSpawn) {\r\n\t\tif (cardId === CardIds.BuildAnUndead_PutricidesCreationToken) {\r\n\t\t\tconst stitchedCardId = !!originalEntity.additionalCards?.length ? originalEntity.additionalCards[0] : null;\r\n\t\t\tif (stitchedCardId) {\r\n\t\t\t\tconst stitchedCard = allCards.getCard(stitchedCardId);\r\n\t\t\t\tnewEntity.attack = newEntity.attack + stitchedCard.attack;\r\n\t\t\t\tnewEntity.maxHealth = newEntity.maxHealth + stitchedCard.health;\r\n\t\t\t\tnewEntity.taunt = newEntity.taunt || hasMechanic(stitchedCard, GameTag[GameTag.TAUNT]);\r\n\t\t\t\tnewEntity.divineShield =\r\n\t\t\t\t\tnewEntity.divineShield || hasMechanic(stitchedCard, GameTag[GameTag.DIVINE_SHIELD]);\r\n\t\t\t\tnewEntity.poisonous = newEntity.poisonous || hasMechanic(stitchedCard, GameTag[GameTag.POISONOUS]);\r\n\t\t\t\tnewEntity.venomous = newEntity.venomous || hasMechanic(stitchedCard, GameTag[GameTag.VENOMOUS]);\r\n\t\t\t\tnewEntity.windfury = newEntity.windfury || hasMechanic(stitchedCard, GameTag[GameTag.WINDFURY]);\r\n\t\t\t\tnewEntity.avengeCurrent = newEntity.avengeCurrent || cardsData.avengeValue(stitchedCardId);\r\n\t\t\t\tnewEntity.avengeDefault = newEntity.avengeDefault || cardsData.avengeValue(stitchedCardId);\r\n\t\t\t}\r\n\t\t}\r\n\t\tnewEntity.health = 1;\r\n\t\tnewEntity.reborn = false;\r\n\t}\r\n\r\n\tnewEntity.hadDivineShield = newEntity.divineShield || newEntity.hadDivineShield;\r\n\treturn newEntity;\r\n};\r\n\r\nexport const buildRandomUndeadCreation = (\r\n\tcontrollerHero: BgsPlayerEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tfriendly: boolean,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n): BoardEntity => {\r\n\tconst baseCard = pickRandom(cardsData.putricidePool1);\r\n\tconst stitchedCardId =\r\n\t\tbaseCard === CardIds.EternalSummoner_BG25_009\r\n\t\t\t? pickRandom(cardsData.putridicePool2ForEternalSummoner)\r\n\t\t\t: pickRandom(cardsData.putricidePool2);\r\n\tconst newEntity = buildSingleBoardEntity(\r\n\t\tbaseCard,\r\n\t\tcontrollerHero,\r\n\t\tfriendlyBoard,\r\n\t\tallCards,\r\n\t\tfriendly,\r\n\t\tsharedState.currentEntityId++,\r\n\t\tfalse,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tnull,\r\n\t);\r\n\tconst stitchedCard = allCards.getCard(stitchedCardId);\r\n\tnewEntity.attack += stitchedCard.attack;\r\n\tnewEntity.health += stitchedCard.health;\r\n\tnewEntity.taunt = newEntity.taunt || hasMechanic(stitchedCard, GameTag[GameTag.TAUNT]);\r\n\tnewEntity.divineShield = newEntity.divineShield || hasMechanic(stitchedCard, GameTag[GameTag.DIVINE_SHIELD]);\r\n\tnewEntity.poisonous = newEntity.venomous || hasMechanic(stitchedCard, GameTag[GameTag.POISONOUS]);\r\n\tnewEntity.venomous = newEntity.poisonous || hasMechanic(stitchedCard, GameTag[GameTag.VENOMOUS]);\r\n\tnewEntity.windfury = newEntity.windfury || hasMechanic(stitchedCard, GameTag[GameTag.WINDFURY]);\r\n\tnewEntity.avengeCurrent = newEntity.avengeCurrent || cardsData.avengeValue(stitchedCardId);\r\n\tnewEntity.avengeDefault = newEntity.avengeDefault || cardsData.avengeValue(stitchedCardId);\r\n\treturn newEntity;\r\n};\r\n\r\nexport const modifyAttack = (\r\n\tentity: BoardEntity,\r\n\tamount: number,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator = null,\r\n): void => {\r\n\tconst realAmount = entity.cardId === CardIds.Tarecgosa_BG21_015_G ? 2 * amount : amount;\r\n\tentity.attack = Math.max(0, entity.attack + realAmount);\r\n\tentity.previousAttack = entity.attack;\r\n\tif (isCorrectTribe(allCards.getCard(entity.cardId).races, Race.DRAGON)) {\r\n\t\tconst whelpSmugglers = friendlyBoard.filter(\r\n\t\t\t(e) => e.cardId === CardIds.WhelpSmuggler_BG21_013 || e.cardId === CardIds.WhelpSmuggler_BG21_013_G,\r\n\t\t);\r\n\t\twhelpSmugglers.forEach((smuggler) => {\r\n\t\t\tconst buff = smuggler.cardId === CardIds.WhelpSmuggler_BG21_013_G ? 2 : 1;\r\n\t\t\tmodifyHealth(entity, buff, friendlyBoard, allCards);\r\n\t\t});\r\n\r\n\t\tif (entity.cardId !== CardIds.Stormbringer_BG26_966 && entity.cardId !== CardIds.Stormbringer_BG26_966_G) {\r\n\t\t\tconst stormbringers = friendlyBoard.filter(\r\n\t\t\t\t(e) => e.cardId === CardIds.Stormbringer_BG26_966 || e.cardId === CardIds.Stormbringer_BG26_966_G,\r\n\t\t\t);\r\n\t\t\tstormbringers.forEach((stormbringer) => {\r\n\t\t\t\tconst multiplier = stormbringer.cardId === CardIds.Stormbringer_BG26_966_G ? 2 : 1;\r\n\t\t\t\t(e) => modifyAttack(e, multiplier * amount, friendlyBoard, allCards);\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\tif (\r\n\t\tentity.cardId === CardIds.Menagerist_AmalgamToken ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A_G ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D_G\r\n\t) {\r\n\t\tconst mishmashes = friendlyBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy ||\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G,\r\n\t\t);\r\n\t\tmishmashes.forEach((mishmash) => {\r\n\t\t\tmodifyAttack(\r\n\t\t\t\tmishmash,\r\n\t\t\t\t(mishmash.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G ? 2 : 1) * realAmount,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tallCards,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\r\n\tif ([CardIds.HunterOfGatherers_BG25_027, CardIds.HunterOfGatherers_BG25_027_G].includes(entity.cardId as CardIds)) {\r\n\t\taddStatsToBoard(\r\n\t\t\tentity,\r\n\t\t\tfriendlyBoard,\r\n\t\t\t0,\r\n\t\t\tentity.cardId === CardIds.HunterOfGatherers_BG25_027_G ? 2 : 1,\r\n\t\t\tallCards,\r\n\t\t\tnull,\r\n\t\t);\r\n\t}\r\n};\r\n\r\nexport const modifyHealth = (\r\n\tentity: BoardEntity,\r\n\tamount: number,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\tconst realAmount = entity.cardId === CardIds.Tarecgosa_BG21_015 ? 2 * amount : amount;\r\n\tentity.health += realAmount;\r\n\tif (realAmount > 0) {\r\n\t\tentity.maxHealth += realAmount;\r\n\t}\r\n\tif (\r\n\t\tentity.cardId === CardIds.Menagerist_AmalgamToken ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A ||\r\n\t\tentity.cardId === CardIds.Cuddlgam_TB_BaconShop_HP_033t_SKIN_A_G ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgam_TB_BaconShop_HP_033t_SKIN_D_G\r\n\t) {\r\n\t\tconst mishmashes = friendlyBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy ||\r\n\t\t\t\te.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G,\r\n\t\t);\r\n\t\tmishmashes.forEach((mishmash) => {\r\n\t\t\tmodifyHealth(\r\n\t\t\t\tmishmash,\r\n\t\t\t\t(mishmash.cardId === CardIds.Mishmash_TB_BaconShop_HERO_33_Buddy_G ? 2 : 1) * realAmount,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tallCards,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\r\n\tconst titanicGuardians = friendlyBoard\r\n\t\t.filter((e) => e.entityId !== entity.entityId)\r\n\t\t.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy ||\r\n\t\t\t\te.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy_G,\r\n\t\t);\r\n\ttitanicGuardians.forEach((guardian) => {\r\n\t\tmodifyHealth(\r\n\t\t\tguardian,\r\n\t\t\t(guardian.cardId === CardIds.TitanicGuardian_TB_BaconShop_HERO_39_Buddy_G ? 2 : 1) * realAmount,\r\n\t\t\tfriendlyBoard,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t});\r\n};\r\n\r\nexport const afterStatsUpdate = (\r\n\tentity: BoardEntity,\r\n\tfriendlyBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\tif (hasCorrectTribe(entity, Race.ELEMENTAL, allCards)) {\r\n\t\tconst masterOfRealities = friendlyBoard.filter(\r\n\t\t\t(e) => e.cardId === CardIds.MasterOfRealities_BG21_036 || e.cardId === CardIds.MasterOfRealities_BG21_036_G,\r\n\t\t);\r\n\t\tmasterOfRealities.forEach((master) => {\r\n\t\t\tmodifyAttack(\r\n\t\t\t\tmaster,\r\n\t\t\t\tmaster.cardId === CardIds.MasterOfRealities_BG21_036_G ? 2 : 1,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tallCards,\r\n\t\t\t);\r\n\t\t\tmodifyHealth(\r\n\t\t\t\tmaster,\r\n\t\t\t\tmaster.cardId === CardIds.MasterOfRealities_BG21_036_G ? 2 : 1,\r\n\t\t\t\tfriendlyBoard,\r\n\t\t\t\tallCards,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\tconst tentaclesOfCthun = friendlyBoard\r\n\t\t.filter((e) => e.entityId !== entity.entityId)\r\n\t\t.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy ||\r\n\t\t\t\te.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G,\r\n\t\t);\r\n\ttentaclesOfCthun.forEach((tentacle) => {\r\n\t\tmodifyAttack(\r\n\t\t\ttentacle,\r\n\t\t\ttentacle.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G ? 2 : 1,\r\n\t\t\tfriendlyBoard,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t\tmodifyHealth(\r\n\t\t\ttentacle,\r\n\t\t\ttentacle.cardId === CardIds.TentacleOfCthun_TB_BaconShop_HERO_29_Buddy_G ? 2 : 1,\r\n\t\t\tfriendlyBoard,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t});\r\n};\r\n\r\nexport const makeMinionGolden = (\r\n\ttarget: BoardEntity,\r\n\tsource: BoardEntity | BgsPlayerEntity,\r\n\tsourceBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// Typically, we are already golden\r\n\tif (isMinionGolden(target, allCards)) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst refCard = allCards.getCard(target.cardId);\r\n\tconst goldenCard = allCards.getCardFromDbfId(refCard.battlegroundsPremiumDbfId);\r\n\ttarget.cardId = goldenCard.id;\r\n\t// A minion becoming golden ignore the current death.\r\n\t// This way of handling it is not ideal, since it will still trigger if both avenges trigger at the same time, but\r\n\t// should solve the other cases\r\n\ttarget.avengeCurrent = Math.min(target.avengeDefault, target.avengeCurrent + 1);\r\n\tmodifyAttack(target, refCard.attack, sourceBoard, allCards);\r\n\tmodifyHealth(target, refCard.health, sourceBoard, allCards);\r\n\tafterStatsUpdate(target, sourceBoard, allCards);\r\n\tspectator.registerPowerTarget(source, target, sourceBoard);\r\n};\r\n\r\nexport const isMinionGolden = (entity: BoardEntity, allCards: AllCardsService): boolean => {\r\n\tconst ref = allCards.getCard(entity.cardId);\r\n\treturn !ref.battlegroundsPremiumDbfId;\r\n\t// Why this condition?\r\n\t// || !allCards.getCardFromDbfId(ref.battlegroundsPremiumDbfId).id\r\n};\r\n\r\nexport const grantRandomAttack = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tadditionalAttack: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\texcludeSource = false,\r\n): void => {\r\n\tconst candidateBoard = board\r\n\t\t.filter((e) => !excludeSource || e.entityId !== source.entityId)\r\n\t\t.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tif (candidateBoard.length > 0) {\r\n\t\tconst target = candidateBoard[Math.floor(Math.random() * candidateBoard.length)];\r\n\t\tmodifyAttack(target, additionalAttack, candidateBoard, allCards);\r\n\t\tafterStatsUpdate(target, candidateBoard, allCards);\r\n\t\tspectator.registerPowerTarget(source, target, board);\r\n\t}\r\n};\r\n\r\nexport const grantRandomHealth = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\thealth: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\texcludeSource = false,\r\n): void => {\r\n\tconst candidateBoard = board\r\n\t\t.filter((e) => !excludeSource || e.entityId !== source.entityId)\r\n\t\t.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tif (candidateBoard.length > 0) {\r\n\t\tconst target = candidateBoard[Math.floor(Math.random() * candidateBoard.length)];\r\n\t\tmodifyHealth(target, health, board, allCards);\r\n\t\tafterStatsUpdate(target, board, allCards);\r\n\t\tspectator.registerPowerTarget(source, target, board);\r\n\t}\r\n};\r\n\r\nexport const grantRandomStats = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tattack: number,\r\n\thealth: number,\r\n\trace: Race,\r\n\texcludeSource: boolean,\r\n\tallCards: AllCardsService,\r\n\tspectator?: Spectator,\r\n): BoardEntity => {\r\n\tif (board.length > 0) {\r\n\t\tconst target: BoardEntity = getRandomAliveMinion(\r\n\t\t\tboard.filter((e) => (excludeSource ? e.entityId !== source.entityId : true)),\r\n\t\t\trace,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t\tif (target) {\r\n\t\t\tmodifyAttack(target, attack, board, allCards);\r\n\t\t\tmodifyHealth(target, health, board, allCards);\r\n\t\t\tafterStatsUpdate(target, board, allCards);\r\n\t\t\tif (spectator) {\r\n\t\t\t\tspectator.registerPowerTarget(source, target, board);\r\n\t\t\t}\r\n\t\t\treturn target;\r\n\t\t}\r\n\t}\r\n\treturn null;\r\n};\r\n\r\nexport const addCardsInHand = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tboard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tcardsAdded: readonly any[],\r\n): void => {\r\n\tconst previousCardsInHand = playerEntity.hand?.length ?? 0;\r\n\tconst sages = board.filter((e) => e.cardId === CardIds.DeathsHeadSage_BG20_HERO_103_Buddy);\r\n\tconst sagesGolden = board.filter((e) => e.cardId === CardIds.DeathsHeadSage_BG20_HERO_103_Buddy_G);\r\n\tconst multiplier = sages.length + 2 * sagesGolden.length;\r\n\r\n\tconst cardsThatWillBeAdded = [];\r\n\tfor (const cardAdded of cardsAdded) {\r\n\t\tconst cardToAdd: { cardId: string } = (cardAdded as BoardEntity)?.cardId\r\n\t\t\t? (cardAdded as BoardEntity)\r\n\t\t\t: ({ cardId: cardAdded as string } as BoardEntity);\r\n\t\tcardsThatWillBeAdded.push(cardToAdd);\r\n\t\tif (cardToAdd.cardId === CardIds.BloodGem) {\r\n\t\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\t\tcardsThatWillBeAdded.push({ ...cardToAdd });\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tfor (let i = 0; i < cardsThatWillBeAdded.length; i++) {\r\n\t\tif (playerEntity.hand.length >= 10) {\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tplayerEntity.hand.push(cardsThatWillBeAdded[i]);\r\n\t}\r\n\r\n\tconst numCardsAdded = playerEntity.hand.length - previousCardsInHand;\r\n\r\n\tfor (let i = 0; i < numCardsAdded; i++) {\r\n\t\tconst peggys = board.filter(\r\n\t\t\t(e) => e.cardId === CardIds.PeggySturdybone_BG25_032 || e.cardId === CardIds.PeggySturdybone_BG25_032_G,\r\n\t\t);\r\n\t\tpeggys.forEach((peggy) => {\r\n\t\t\tconst pirate = getRandomAliveMinion(\r\n\t\t\t\tboard.filter((e) => e.entityId !== peggy.entityId),\r\n\t\t\t\tRace.PIRATE,\r\n\t\t\t\tallCards,\r\n\t\t\t);\r\n\t\t\tif (pirate) {\r\n\t\t\t\tmodifyAttack(pirate, peggy.cardId === CardIds.PeggySturdybone_BG25_032_G ? 2 : 1, board, allCards);\r\n\t\t\t\tmodifyHealth(pirate, peggy.cardId === CardIds.PeggySturdybone_BG25_032_G ? 2 : 1, board, allCards);\r\n\t\t\t\tafterStatsUpdate(pirate, board, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(peggy, pirate, board);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tconst thornCaptains = board.filter(\r\n\t\t\t(e) => e.cardId === CardIds.Thorncaptain_BG25_045 || e.cardId === CardIds.Thorncaptain_BG25_045_G,\r\n\t\t);\r\n\t\tthornCaptains.forEach((captain) => {\r\n\t\t\tmodifyHealth(captain, captain.cardId === CardIds.Thorncaptain_BG25_045_G ? 2 : 1, board, allCards);\r\n\t\t\tafterStatsUpdate(captain, board, allCards);\r\n\t\t\tspectator.registerPowerTarget(captain, captain, board);\r\n\t\t});\r\n\t}\r\n};\r\n\r\nexport const removeCardFromHand = (playerEntity: BgsPlayerEntity, card: BoardEntity): void => {\r\n\tlet cardToRemove: BoardEntity;\r\n\tif (card?.entityId) {\r\n\t\tcardToRemove = playerEntity.hand.find((c) => c?.entityId !== card.entityId);\r\n\t} else if (card?.cardId) {\r\n\t\tcardToRemove = playerEntity.hand.find((c) => c?.cardId === card.cardId);\r\n\t} else {\r\n\t\t// Remove a single random card in hand that doesn't have an entityId\r\n\t\tcardToRemove =\r\n\t\t\tpickRandom(playerEntity.hand.filter((c) => !c?.entityId && !c?.cardId)) ?? pickRandom(playerEntity.hand);\r\n\t}\r\n\t// Remove the first occurrence of the card from playerEntity.cardsInHand, even if it is null\r\n\tconst index = playerEntity.hand.indexOf(cardToRemove);\r\n\tif (index !== -1) {\r\n\t\tplayerEntity.hand.splice(index, 1);\r\n\t}\r\n};\r\n\r\nexport const grantRandomDivineShield = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst elligibleEntities = board\r\n\t\t.filter((entity) => !entity.divineShield)\r\n\t\t.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\tif (elligibleEntities.length > 0) {\r\n\t\tconst chosen = elligibleEntities[Math.floor(Math.random() * elligibleEntities.length)];\r\n\t\tupdateDivineShield(chosen, board, true, allCards);\r\n\t\tspectator.registerPowerTarget(source, chosen, board);\r\n\t}\r\n\t// return board;\r\n};\r\n\r\nexport const updateDivineShield = (\r\n\tentity: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tnewValue: boolean,\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\t// if ((entity.divineShield ?? false) === newValue) {\r\n\t// \treturn;\r\n\t// }\r\n\tentity.divineShield = newValue;\r\n\tif (entity.divineShield) {\r\n\t\tentity.hadDivineShield = true;\r\n\t}\r\n\tif (entity.divineShield) {\r\n\t\tconst boardForDrake = board;\r\n\t\tconst statsBonus =\r\n\t\t\t8 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043).length +\r\n\t\t\t16 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043_G).length;\r\n\t\t// Don't trigger all \"on attack changed\" effects, since it's an aura\r\n\t\tentity.attack += statsBonus;\r\n\t} else {\r\n\t\t// Also consider itself\r\n\t\tconst boardForDrake = board;\r\n\t\tconst statsBonus =\r\n\t\t\t8 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043).length +\r\n\t\t\t16 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake_BG25_043_G).length;\r\n\t\tentity.attack -= statsBonus;\r\n\t}\r\n};\r\n\r\nexport const grantAllDivineShield = (board: BoardEntity[], tribe: string, cards: AllCardsService): void => {\r\n\tconst elligibleEntities = board\r\n\t\t.filter((entity) => !entity.divineShield)\r\n\t\t.filter((entity) => isCorrectTribe(cards.getCard(entity.cardId).races, getRaceEnum(tribe)));\r\n\tfor (const entity of elligibleEntities) {\r\n\t\tupdateDivineShield(entity, board, true, cards);\r\n\t}\r\n};\r\n\r\nexport const getRandomAliveMinion = (board: BoardEntity[], race: Race, allCards: AllCardsService): BoardEntity => {\r\n\tconst validTribes = board\r\n\t\t.filter((e) => !race || isCorrectTribe(allCards.getCard(e?.cardId).races, race))\r\n\t\t.filter((e) => !!e?.health && !e.definitelyDead);\r\n\tif (!validTribes.length) {\r\n\t\treturn null;\r\n\t}\r\n\tconst randomIndex = Math.floor(Math.random() * validTribes.length);\r\n\treturn validTribes[randomIndex];\r\n};\r\n\r\nexport const getRandomMinionWithHighestHealth = (board: BoardEntity[]): BoardEntity => {\r\n\tif (!board.length) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tconst highestHealth = Math.max(...board.map((e) => e.health));\r\n\tconst validMinions = board.filter((e) => e.health === highestHealth);\r\n\treturn validMinions[Math.floor(Math.random() * validMinions.length)];\r\n};\r\n\r\nexport const addStatsToBoard = (\r\n\tsourceEntity: BoardEntity | BgsPlayerEntity,\r\n\tboard: BoardEntity[],\r\n\tattack: number,\r\n\thealth: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\ttribe?: string,\r\n): void => {\r\n\tfor (const entity of board) {\r\n\t\tif (!tribe || hasCorrectTribe(entity, Race[tribe], allCards)) {\r\n\t\t\tmodifyAttack(entity, attack, board, allCards);\r\n\t\t\tmodifyHealth(entity, health, board, allCards);\r\n\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\tspectator?.registerPowerTarget(sourceEntity, entity, board);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const grantStatsToMinionsOfEachType = (\r\n\tsource: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tattack: number,\r\n\thealth: number,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tnumberOfDifferentTypes = 99,\r\n): void => {\r\n\tif (board.length > 0) {\r\n\t\tlet boardCopy = [...board];\r\n\t\tconst allRaces = shuffleArray(ALL_BG_RACES);\r\n\t\tlet typesBuffed = 0;\r\n\t\tfor (const tribe of allRaces) {\r\n\t\t\tif (typesBuffed >= numberOfDifferentTypes) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tconst validMinion: BoardEntity = getRandomAliveMinion(boardCopy, tribe, allCards);\r\n\t\t\tif (validMinion) {\r\n\t\t\t\tmodifyAttack(validMinion, attack, board, allCards);\r\n\t\t\t\tmodifyHealth(validMinion, health, board, allCards);\r\n\t\t\t\tafterStatsUpdate(validMinion, board, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(source, validMinion, board);\r\n\t\t\t\tboardCopy = boardCopy.filter((e) => e !== validMinion);\r\n\t\t\t\ttypesBuffed++;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const hasMechanic = (card: ReferenceCard, mechanic: string): boolean => {\r\n\treturn card.mechanics?.includes(mechanic);\r\n};\r\n\r\nexport const hasCorrectTribe = (entity: BoardEntity, targetTribe: Race, allCards: AllCardsService): boolean => {\r\n\treturn isCorrectTribe(allCards.getCard(entity.cardId).races, targetTribe);\r\n};\r\n\r\nexport const isCorrectTribe = (cardRaces: readonly string[], targetTribe: Race): boolean => {\r\n\tif (!cardRaces?.length) {\r\n\t\treturn false;\r\n\t}\r\n\treturn cardRaces\r\n\t\t.map((cardRace) => getRaceEnum(cardRace))\r\n\t\t.some((raceEnum) => raceEnum === Race.ALL || raceEnum === targetTribe);\r\n};\r\n\r\nexport const getRaceEnum = (race: string): Race => {\r\n\treturn Race[race];\r\n};\r\n\r\nexport const addImpliedMechanics = (entity: BoardEntity, cardsData: CardsData): BoardEntity => {\r\n\tconst cleave = CLEAVE_IDS.indexOf(entity.cardId as CardIds) !== -1;\r\n\tconst cantAttack = CANT_ATTACK_IDS.indexOf(entity.cardId as CardIds) !== -1;\r\n\treturn setImplicitDataForEntity(\r\n\t\t{\r\n\t\t\t...entity,\r\n\t\t\tcleave: cleave,\r\n\t\t\tcantAttack: cantAttack,\r\n\t\t\timmuneWhenAttackCharges:\r\n\t\t\t\tentity.cardId === CardIds.Warpwing_BG24_004 || entity.cardId === CardIds.Warpwing_BG24_004_G\r\n\t\t\t\t\t? 99999\r\n\t\t\t\t\t: 0,\r\n\t\t\tfrenzyChargesLeft:\r\n\t\t\t\tentity.cardId === CardIds.BristlebackKnight_BG20_204_G\r\n\t\t\t\t\t? 2\r\n\t\t\t\t\t: entity.cardId === CardIds.BristlebackKnight_BG20_204\r\n\t\t\t\t\t? 1\r\n\t\t\t\t\t: 0,\r\n\t\t\t// It's not an issue adding a charge for entities without a special ability\r\n\t\t\tabiityChargesLeft: [CardIds.TransmutedBramblewitch_BG27_013_G, CardIds.Mannoroth_BG27_507_G].includes(\r\n\t\t\t\tentity.cardId as CardIds,\r\n\t\t\t)\r\n\t\t\t\t? 2\r\n\t\t\t\t: 1,\r\n\t\t} as BoardEntity,\r\n\t\tcardsData,\r\n\t);\r\n};\r\n\r\nconst setImplicitDataForEntity = (entity: BoardEntity, cardsData: CardsData): BoardEntity => {\r\n\tentity.cardId = normalizeCardIdForSkin(entity.cardId);\r\n\tentity.maxHealth = Math.max(0, entity.health);\r\n\tconst avengeValue = cardsData.avengeValue(entity.cardId);\r\n\tif (avengeValue > 0) {\r\n\t\tentity.avengeCurrent = avengeValue;\r\n\t\tentity.avengeDefault = avengeValue;\r\n\t}\r\n\treturn entity;\r\n};\r\n\r\nexport const normalizeCardIdForSkin = (cardId: string): string => {\r\n\tconst skinMatch = cardId.match(/(.*)_SKIN_.*/);\r\n\tif (skinMatch) {\r\n\t\treturn skinMatch[1];\r\n\t}\r\n\treturn cardId;\r\n};\r\n\r\nexport const stringifySimple = (board: readonly BoardEntity[], allCards: AllCardsService = null): string => {\r\n\treturn '[' + board.map((entity) => stringifySimpleCard(entity, allCards)).join(', ') + ']';\r\n};\r\n\r\nexport const stringifySimpleCard = (entity: BoardEntity, allCards: AllCardsService = null): string => {\r\n\treturn entity\r\n\t\t? `${entity.cardId}/${allCards?.getCard(entity.cardId)?.name ?? ''}/atk=${entity.attack}/hp=${\r\n\t\t\t\tentity.health\r\n\t\t }/ds=${entity.divineShield}`\r\n\t\t: null;\r\n};\r\n\r\nexport const isFish = (entity: BoardEntity): boolean => {\r\n\treturn (\r\n\t\tentity.cardId.startsWith(CardIds.AvatarOfNzoth_FishOfNzothToken) ||\r\n\t\tentity.cardId.startsWith(CardIds.FishOfNzoth) ||\r\n\t\tentity.additionalCards?.includes(CardIds.DevourerOfSouls_BG_RLK_538)\r\n\t);\r\n};\r\n\r\nexport const isGolden = (cardId: string, allCards: AllCardsService): boolean => {\r\n\treturn !!allCards.getCard(cardId).battlegroundsNormalDbfId;\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.289",
3
+ "version": "1.1.290",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "lint": "eslint --color --fix --ext .ts .",