@firestone-hs/simulate-bgs-battle 1.1.210 → 1.1.211
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/utils.js +9 -7
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/dist/utils.js
CHANGED
|
@@ -112,7 +112,8 @@ const buildSingleBoardEntity = (cardId, controllerHero, friendlyBoard, allCards,
|
|
|
112
112
|
};
|
|
113
113
|
exports.buildSingleBoardEntity = buildSingleBoardEntity;
|
|
114
114
|
const modifyAttack = (entity, amount, friendlyBoard, allCards) => {
|
|
115
|
-
|
|
115
|
+
const realAmount = entity.cardId === "BG21_015_G" ? 2 * amount : amount;
|
|
116
|
+
entity.attack = Math.max(0, entity.attack + realAmount);
|
|
116
117
|
entity.previousAttack = entity.attack;
|
|
117
118
|
if (exports.isCorrectTribe(allCards.getCard(entity.cardId).race, reference_data_1.Race.DRAGON)) {
|
|
118
119
|
const whelpSmugglers = friendlyBoard.filter((e) => e.cardId === "BG21_013");
|
|
@@ -128,21 +129,22 @@ const modifyAttack = (entity, amount, friendlyBoard, allCards) => {
|
|
|
128
129
|
const mishmashes = friendlyBoard.filter((e) => e.cardId === "TB_BaconShop_HERO_33_Buddy" ||
|
|
129
130
|
e.cardId === "TB_BaconShop_HERO_33_Buddy_G");
|
|
130
131
|
mishmashes.forEach((mishmash) => {
|
|
131
|
-
exports.modifyAttack(mishmash, (mishmash.cardId === "TB_BaconShop_HERO_33_Buddy_G" ? 2 : 1) *
|
|
132
|
+
exports.modifyAttack(mishmash, (mishmash.cardId === "TB_BaconShop_HERO_33_Buddy_G" ? 2 : 1) * realAmount, friendlyBoard, allCards);
|
|
132
133
|
});
|
|
133
134
|
}
|
|
134
135
|
};
|
|
135
136
|
exports.modifyAttack = modifyAttack;
|
|
136
137
|
const modifyHealth = (entity, amount, friendlyBoard, allCards) => {
|
|
137
|
-
entity.
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
const realAmount = entity.cardId === "BG21_015_G" ? 2 * amount : amount;
|
|
139
|
+
entity.health += realAmount;
|
|
140
|
+
if (realAmount > 0) {
|
|
141
|
+
entity.maxHealth += realAmount;
|
|
140
142
|
}
|
|
141
143
|
if (entity.cardId === "TB_BaconShop_HP_033t" || entity.cardId === "TB_BaconShop_HP_033t_SKIN_A") {
|
|
142
144
|
const mishmashes = friendlyBoard.filter((e) => e.cardId === "TB_BaconShop_HERO_33_Buddy" ||
|
|
143
145
|
e.cardId === "TB_BaconShop_HERO_33_Buddy_G");
|
|
144
146
|
mishmashes.forEach((mishmash) => {
|
|
145
|
-
exports.modifyHealth(mishmash, (mishmash.cardId === "TB_BaconShop_HERO_33_Buddy_G" ? 2 : 1) *
|
|
147
|
+
exports.modifyHealth(mishmash, (mishmash.cardId === "TB_BaconShop_HERO_33_Buddy_G" ? 2 : 1) * realAmount, friendlyBoard, allCards);
|
|
146
148
|
});
|
|
147
149
|
}
|
|
148
150
|
const titanicGuardians = friendlyBoard
|
|
@@ -150,7 +152,7 @@ const modifyHealth = (entity, amount, friendlyBoard, allCards) => {
|
|
|
150
152
|
.filter((e) => e.cardId === "TB_BaconShop_HERO_39_Buddy" ||
|
|
151
153
|
e.cardId === "TB_BaconShop_HERO_39_Buddy_G");
|
|
152
154
|
titanicGuardians.forEach((guardian) => {
|
|
153
|
-
exports.modifyHealth(guardian, (guardian.cardId === "TB_BaconShop_HERO_39_Buddy_G" ? 2 : 1) *
|
|
155
|
+
exports.modifyHealth(guardian, (guardian.cardId === "TB_BaconShop_HERO_39_Buddy_G" ? 2 : 1) * realAmount, friendlyBoard, allCards);
|
|
154
156
|
});
|
|
155
157
|
};
|
|
156
158
|
exports.modifyHealth = modifyHealth;
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AACA,iEAA6F;AAI7F,4CAA+D;AAG/D,MAAM,UAAU,GAA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;AAClB,CAAC,CAAC;AAZW,QAAA,mBAAmB,uBAY9B;AAEK,MAAM,sBAAsB,GAAG,CAAC,MAAc,EAAU,EAAE;IAChE,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAC/C,IAAI,SAAS,EAAE;QACd,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;KACpB;IACD,OAAO,MAAM,CAAC;AACf,CAAC,CAAC;AANW,QAAA,sBAAsB,0BAMjC;AAEK,MAAM,eAAe,GAAG,CAAC,KAA6B,EAAE,WAA4B,IAAI,EAAU,EAAE;IAC1G,OAAO,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,2BAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;AAC5F,CAAC,CAAC;AAFW,QAAA,eAAe,mBAE1B;AAEK,MAAM,mBAAmB,GAAG,CAAC,MAAmB,EAAE,WAA4B,IAAI,EAAU,EAAE;;IACpG,OAAO,MAAM;QACZ,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,IAAI,YAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,CAAC,MAAM,CAAC,MAAM,2CAAG,IAAI,mCAAI,EAAE,QAAQ,MAAM,CAAC,MAAM,OAAO,MAAM,CAAC,MAAM,OACzG,MAAM,CAAC,YACP,UAAU,MAAM,CAAC,KAAK,YAAY,MAAM,CAAC,OAAO,SAAS,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE;QAChG,CAAC,CAAC,IAAI,CAAC;AACT,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds, Race, ReferenceCard } 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 { groupByFunction, pickRandom } 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.CaveHydraBattlegrounds,\r\n\tCardIds.FoeReaper4000_BG_GVG_113,\r\n\tCardIds.FoeReaper4000Battlegrounds,\r\n];\r\n// Because for some reason, the Taunt keyword is only a referenced tag,\r\n// so we have to know when a taunt minion is spawned (the taunt tag\r\n// is passed in input properly, so it's not an issue there)\r\nconst TAUNT_IDS = [\r\n\tCardIds.YoHoOgre,\r\n\tCardIds.YoHoOgreBattlegrounds,\r\n\tCardIds.SecurityRover_GuardBotToken,\r\n\tCardIds.SecurityRover_GuardBotTokenBattlegrounds,\r\n\tCardIds.MoltenRock,\r\n\tCardIds.MoltenRockBattlegrounds,\r\n\tCardIds.LieutenantGarr,\r\n\tCardIds.LieutenantGarrBattlegrounds,\r\n\tCardIds.GentleDjinni,\r\n\tCardIds.GentleDjinniBattlegrounds,\r\n\tCardIds.AcolyteOfCthun,\r\n\tCardIds.AcolyteOfCthunBattlegrounds,\r\n\tCardIds.RingMatron_BG_DMF_533,\r\n\tCardIds.RingMatronBattlegrounds,\r\n\tCardIds.DynamicDuo,\r\n\tCardIds.DynamicDuoBattlegrounds,\r\n\tCardIds.InsatiableUrzul,\r\n\tCardIds.InsatiableUrzulBattlegrounds,\r\n\tCardIds.MasterOfRealities_BG21_036,\r\n\tCardIds.MasterOfRealitiesBattlegrounds,\r\n\tCardIds.BrannsEpicEggBattlegrounds_TB_BaconShop_HERO_43_Buddy,\r\n\tCardIds.BrannsEpicEggBattlegrounds_TB_BaconShop_HERO_43_Buddy_G,\r\n\tCardIds.KilrekBattlegrounds_TB_BaconShop_HERO_37_Buddy,\r\n\tCardIds.KilrekBattlegrounds_TB_BaconShop_HERO_37_Buddy_G,\r\n\tCardIds.Glowscale,\r\n\tCardIds.GlowscaleBattlegrounds,\r\n\tCardIds.SilverbackPatriarch_BG_CS2_127,\r\n\tCardIds.SilverbackPatriarchBattlegrounds,\r\n\tCardIds.SparringPartner_BG_AT_069,\r\n\tCardIds.SparringPartnerBattlegrounds,\r\n\tCardIds.TunnelBlaster_BG_DAL_775,\r\n\tCardIds.TunnelBlasterBattlegrounds,\r\n];\r\nconst ATTACK_IMMEDIATELY_IDS = [\r\n\tCardIds.Scallywag_SkyPirateToken,\r\n\tCardIds.Scallywag_SkyPirateTokenBattlegrounds,\r\n\tCardIds.Onyxia_OnyxianWhelpToken,\r\n];\r\nexport const MEGA_WINDFURY_IDS = [\r\n\tCardIds.ZappSlywickBattlegrounds,\r\n\tCardIds.CracklingCycloneBattlegrounds,\r\n\tCardIds.BristlebackKnightBattlegrounds,\r\n\tCardIds.BonkerBattlegrounds,\r\n];\r\nconst CANT_ATTACK_IDS = [CardIds.ArcaneCannonBattlegrounds];\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\tspectator: Spectator,\r\n): BoardEntity => {\r\n\tconst card = allCards.getCard(cardId);\r\n\tconst megaWindfury = MEGA_WINDFURY_IDS.indexOf(cardId as CardIds) !== -1;\r\n\tconst attackImmediately = ATTACK_IMMEDIATELY_IDS.indexOf(cardId as CardIds) !== -1;\r\n\tconst newEntity = addImpliedMechanics({\r\n\t\tattack: card.attack,\r\n\t\tattacksPerformed: 0,\r\n\t\tcardId: cardId,\r\n\t\tdivineShield: hasMechanic(card, 'DIVINE_SHIELD'),\r\n\t\tentityId: entityId,\r\n\t\thealth: card.health,\r\n\t\tmaxHealth: card.health,\r\n\t\ttaunt: hasMechanic(card, 'TAUNT') || TAUNT_IDS.includes(cardId as CardIds),\r\n\t\treborn: hasMechanic(card, 'REBORN'),\r\n\t\tpoisonous: hasMechanic(card, 'POISONOUS'),\r\n\t\twindfury: !megaWindfury && (hasMechanic(card, 'WINDFURY') || card.referencedTags?.includes('WINDFURY')),\r\n\t\tmegaWindfury: megaWindfury,\r\n\t\tenchantments: [],\r\n\t\tfriendly: friendly,\r\n\t\tattackImmediately: attackImmediately,\r\n\t\tavengeCurrent: cardsData.avengeValue(cardId),\r\n\t\tavengeDefault: cardsData.avengeValue(cardId),\r\n\t} as BoardEntity);\r\n\r\n\tif (spawnReborn) {\r\n\t\tnewEntity.health = 1;\r\n\t\tnewEntity.reborn = false;\r\n\t}\r\n\r\n\tif (controllerHero?.heroPowerId === CardIds.SproutItOutBattlegrounds) {\r\n\t\tnewEntity.taunt = true;\r\n\t\tmodifyAttack(newEntity, 1, friendlyBoard, allCards);\r\n\t\tmodifyHealth(newEntity, 2, friendlyBoard, allCards);\r\n\t\tafterStatsUpdate(newEntity, friendlyBoard, allCards);\r\n\t\t// spectator && spectator.registerPowerTarget(result, result, friendlyBoard);\r\n\t} else if (controllerHero?.heroPowerId === CardIds.KurtrusAshfallen_CloseThePortal) {\r\n\t\tmodifyAttack(newEntity, 2, friendlyBoard, allCards);\r\n\t\tmodifyHealth(newEntity, 2, friendlyBoard, allCards);\r\n\t\tafterStatsUpdate(newEntity, friendlyBoard, allCards);\r\n\t\t// spectator && spectator.registerPowerTarget(result, result, friendlyBoard);\r\n\t}\r\n\r\n\tif (allCards.getCard(cardId).techLevel === controllerHero.tavernTier) {\r\n\t\tconst statsBonus =\r\n\t\t\t4 * friendlyBoard.filter((e) => e.cardId === CardIds.BabyYshaarjBattlegrounds_TB_BaconShop_HERO_92_Buddy).length +\r\n\t\t\t8 * friendlyBoard.filter((e) => e.cardId === CardIds.BabyYshaarjBattlegrounds_TB_BaconShop_HERO_92_Buddy_G).length;\r\n\t\tmodifyAttack(newEntity, statsBonus, friendlyBoard, allCards);\r\n\t\tmodifyHealth(newEntity, statsBonus, friendlyBoard, allCards);\r\n\t\tafterStatsUpdate(newEntity, friendlyBoard, allCards);\r\n\t}\r\n\r\n\tif (newEntity.taunt) {\r\n\t\tconst statsBonus =\r\n\t\t\t2 * friendlyBoard.filter((e) => e.cardId === CardIds.WanderingTreantBattlegrounds_TB_BaconShop_HERO_95_Buddy).length +\r\n\t\t\t4 * friendlyBoard.filter((e) => e.cardId === CardIds.WanderingTreantBattlegrounds_TB_BaconShop_HERO_95_Buddy_G).length;\r\n\t\tmodifyAttack(newEntity, statsBonus, friendlyBoard, allCards);\r\n\t\tmodifyHealth(newEntity, statsBonus, friendlyBoard, allCards);\r\n\t\tafterStatsUpdate(newEntity, friendlyBoard, allCards);\r\n\t}\r\n\r\n\treturn newEntity;\r\n};\r\n\r\nexport const modifyAttack = (entity: BoardEntity, amount: number, friendlyBoard: BoardEntity[], allCards: AllCardsService): void => {\r\n\t// console.log('modifying attack', amount, stringifySimpleCard(entity, allCards), entity.attack);\r\n\tentity.attack = Math.max(0, entity.attack + amount);\r\n\t// console.log('modified attack', amount, stringifySimpleCard(entity, allCards), entity.attack);\r\n\tentity.previousAttack = entity.attack;\r\n\tif (isCorrectTribe(allCards.getCard(entity.cardId).race, Race.DRAGON)) {\r\n\t\tconst whelpSmugglers = friendlyBoard.filter((e) => e.cardId === CardIds.WhelpSmuggler);\r\n\t\tconst whelpSmugglersBattlegrounds = friendlyBoard.filter((e) => e.cardId === CardIds.WhelpSmugglerBattlegrounds);\r\n\t\twhelpSmugglers.forEach((smuggler) => {\r\n\t\t\tmodifyHealth(entity, 1, friendlyBoard, allCards);\r\n\t\t});\r\n\t\twhelpSmugglersBattlegrounds.forEach((smuggler) => {\r\n\t\t\tmodifyHealth(entity, 2, friendlyBoard, allCards);\r\n\t\t});\r\n\t}\r\n\tif (entity.cardId === CardIds.Menagerist_AmalgamTokenBattlegrounds || entity.cardId === CardIds.CuddlgamBattlegrounds) {\r\n\t\tconst mishmashes = friendlyBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.MishmashBattlegrounds_TB_BaconShop_HERO_33_Buddy ||\r\n\t\t\t\te.cardId === CardIds.MishmashBattlegrounds_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.MishmashBattlegrounds_TB_BaconShop_HERO_33_Buddy_G ? 2 : 1) * amount,\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\r\nexport const modifyHealth = (entity: BoardEntity, amount: number, friendlyBoard: BoardEntity[], allCards: AllCardsService): void => {\r\n\tentity.health += amount;\r\n\tif (amount > 0) {\r\n\t\tentity.maxHealth += amount;\r\n\t}\r\n\tif (entity.cardId === CardIds.Menagerist_AmalgamTokenBattlegrounds || entity.cardId === CardIds.CuddlgamBattlegrounds) {\r\n\t\tconst mishmashes = friendlyBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.MishmashBattlegrounds_TB_BaconShop_HERO_33_Buddy ||\r\n\t\t\t\te.cardId === CardIds.MishmashBattlegrounds_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.MishmashBattlegrounds_TB_BaconShop_HERO_33_Buddy_G ? 2 : 1) * amount,\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.TitanicGuardianBattlegrounds_TB_BaconShop_HERO_39_Buddy ||\r\n\t\t\t\te.cardId === CardIds.TitanicGuardianBattlegrounds_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.TitanicGuardianBattlegrounds_TB_BaconShop_HERO_39_Buddy_G ? 2 : 1) * amount,\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 = (entity: BoardEntity, friendlyBoard: BoardEntity[], allCards: AllCardsService): 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.MasterOfRealitiesBattlegrounds,\r\n\t\t);\r\n\t\tmasterOfRealities.forEach((master) => {\r\n\t\t\tmodifyAttack(master, master.cardId === CardIds.MasterOfRealitiesBattlegrounds ? 2 : 1, friendlyBoard, allCards);\r\n\t\t\tmodifyHealth(master, master.cardId === CardIds.MasterOfRealitiesBattlegrounds ? 2 : 1, friendlyBoard, allCards);\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.TentacleOfCthunBattlegrounds_TB_BaconShop_HERO_29_Buddy ||\r\n\t\t\t\te.cardId === CardIds.TentacleOfCthunBattlegrounds_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.TentacleOfCthunBattlegrounds_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.TentacleOfCthunBattlegrounds_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\tconst refCard = allCards.getCard(target.cardId);\r\n\t// Typically, we are already golden\r\n\tif (!refCard.battlegroundsPremiumDbfId) {\r\n\t\treturn;\r\n\t}\r\n\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 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\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): BoardEntity => {\r\n\tif (board.length > 0) {\r\n\t\tconst validBeast: BoardEntity = getRandomAliveMinion(\r\n\t\t\tboard.filter((e) => e.entityId !== source.entityId),\r\n\t\t\trace,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t\t//tmp fix for PalescaleCrocolisk, PalescaleCrocolisk won't apply avenge and dethrattle effect on itself.\r\n\t\t//const validBeast: BoardEntity = getRandomAliveMinion(board, race, allCards);\r\n\t\tif (validBeast) {\r\n\t\t\tmodifyAttack(validBeast, attack, board, allCards);\r\n\t\t\tmodifyHealth(validBeast, health, board, allCards);\r\n\t\t\tafterStatsUpdate(validBeast, board, allCards);\r\n\t\t\tspectator.registerPowerTarget(source, validBeast, board);\r\n\t\t\treturn validBeast;\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\tcards: number,\r\n\tboard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tcardAdded: CardIds = null,\r\n): void => {\r\n\tconst sages = board.filter((e) => e.cardId === CardIds.DeathsHeadSage);\r\n\tconst sagesGolden = board.filter((e) => e.cardId === CardIds.DeathsHeadSageBattlegrounds);\r\n\tconst multiplier = 1 + (cardAdded === CardIds.BloodGem ? sages.length + 2 * sagesGolden.length : 0);\r\n\tplayerEntity.cardsInHand = Math.min(10, (playerEntity.cardsInHand ?? 0) + multiplier * cards);\r\n\r\n\tconst peggys = board.filter((e) => e.cardId === CardIds.PeggyBrittlebone || e.cardId === CardIds.PeggyBrittleboneBattlegrounds);\r\n\tpeggys.forEach((peggy) => {\r\n\t\tconst pirate = getRandomAliveMinion(\r\n\t\t\tboard.filter((e) => e.entityId !== peggy.entityId),\r\n\t\t\tRace.PIRATE,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t\tif (pirate) {\r\n\t\t\tmodifyAttack(pirate, peggy.cardId === CardIds.PeggyBrittleboneBattlegrounds ? 2 : 1, board, allCards);\r\n\t\t\tmodifyHealth(pirate, peggy.cardId === CardIds.PeggyBrittleboneBattlegrounds ? 2 : 1, board, allCards);\r\n\t\t\tafterStatsUpdate(pirate, board, allCards);\r\n\t\t\tspectator.registerPowerTarget(peggy, pirate, board);\r\n\t\t}\r\n\t});\r\n};\r\n\r\nexport const grantRandomDivineShield = (source: BoardEntity, board: BoardEntity[], spectator: Spectator): 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\tchosen.divineShield = true;\r\n\t\tspectator.registerPowerTarget(source, chosen, board);\r\n\t}\r\n\t// return board;\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).race, getRaceEnum(tribe)));\r\n\tfor (const entity of elligibleEntities) {\r\n\t\tentity.divineShield = true;\r\n\t}\r\n\t// return board;\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).race, race))\r\n\t\t.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tif (!validTribes.length) {\r\n\t\treturn null;\r\n\t}\r\n\treturn validTribes[Math.floor(Math.random() * validTribes.length)];\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 || isCorrectTribe(allCards.getCard(entity.cardId).race, Race[tribe])) {\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 applyEffectToMinionTypes = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\teffect: (entity: BoardEntity) => void,\r\n): void => {\r\n\tconst groupedByRace = groupByFunction((e: BoardEntity) => allCards.getCard(e.cardId).race)(\r\n\t\tboard.filter((e) => !!allCards.getCard(e.cardId).race),\r\n\t);\r\n\tObject.values(groupedByRace)\r\n\t\t.filter((minions) => !!minions?.length)\r\n\t\t.forEach((minions) => {\r\n\t\t\tconst target = pickRandom(minions);\r\n\t\t\teffect(target);\r\n\t\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).race, targetTribe);\r\n};\r\n\r\nexport const isCorrectTribe = (cardRace: string, targetTribe: Race): boolean => {\r\n\treturn getRaceEnum(cardRace) === Race.ALL || getRaceEnum(cardRace) === 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): 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 {\r\n\t\t...entity,\r\n\t\tcleave: cleave,\r\n\t\tcantAttack: cantAttack,\r\n\t} as BoardEntity;\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=${entity.health}/ds=${\r\n\t\t\t\tentity.divineShield\r\n\t\t }/taunt=${entity.taunt}/stealth=${entity.stealth}/ench=${JSON.stringify(entity.enchantments)}`\r\n\t\t: null;\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AACA,iEAA6F;AAI7F,4CAA+D;AAG/D,MAAM,UAAU,GAAG;;;;;CAKlB,CAAC;AAIF,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCjB,CAAC;AACF,MAAM,sBAAsB,GAAG;;;;CAI9B,CAAC;AACW,QAAA,iBAAiB,GAAG;;;;;CAKhC,CAAC;AACF,MAAM,eAAe,GAAG,mBAAmC,CAAC;AAErD,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,SAAoB,EACN,EAAE;;IAChB,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,YAAY,GAAG,yBAAiB,CAAC,OAAO,CAAC,MAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;IACzE,MAAM,iBAAiB,GAAG,sBAAsB,CAAC,OAAO,CAAC,MAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;IACnF,MAAM,SAAS,GAAG,2BAAmB,CAAC;QACrC,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,gBAAgB,EAAE,CAAC;QACnB,MAAM,EAAE,MAAM;QACd,YAAY,EAAE,mBAAW,CAAC,IAAI,EAAE,eAAe,CAAC;QAChD,QAAQ,EAAE,QAAQ;QAClB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,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,EAAE;;IACpG,OAAO,MAAM;QACZ,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,IAAI,YAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,CAAC,MAAM,CAAC,MAAM,2CAAG,IAAI,mCAAI,EAAE,QAAQ,MAAM,CAAC,MAAM,OAAO,MAAM,CAAC,MAAM,OACzG,MAAM,CAAC,YACP,UAAU,MAAM,CAAC,KAAK,YAAY,MAAM,CAAC,OAAO,SAAS,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE;QAChG,CAAC,CAAC,IAAI,CAAC;AACT,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds, Race, ReferenceCard } 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 { groupByFunction, pickRandom } 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.CaveHydraBattlegrounds,\r\n\tCardIds.FoeReaper4000_BG_GVG_113,\r\n\tCardIds.FoeReaper4000Battlegrounds,\r\n];\r\n// Because for some reason, the Taunt keyword is only a referenced tag,\r\n// so we have to know when a taunt minion is spawned (the taunt tag\r\n// is passed in input properly, so it's not an issue there)\r\nconst TAUNT_IDS = [\r\n\tCardIds.YoHoOgre,\r\n\tCardIds.YoHoOgreBattlegrounds,\r\n\tCardIds.SecurityRover_GuardBotToken,\r\n\tCardIds.SecurityRover_GuardBotTokenBattlegrounds,\r\n\tCardIds.MoltenRock,\r\n\tCardIds.MoltenRockBattlegrounds,\r\n\tCardIds.LieutenantGarr,\r\n\tCardIds.LieutenantGarrBattlegrounds,\r\n\tCardIds.GentleDjinni,\r\n\tCardIds.GentleDjinniBattlegrounds,\r\n\tCardIds.AcolyteOfCthun,\r\n\tCardIds.AcolyteOfCthunBattlegrounds,\r\n\tCardIds.RingMatron_BG_DMF_533,\r\n\tCardIds.RingMatronBattlegrounds,\r\n\tCardIds.DynamicDuo,\r\n\tCardIds.DynamicDuoBattlegrounds,\r\n\tCardIds.InsatiableUrzul,\r\n\tCardIds.InsatiableUrzulBattlegrounds,\r\n\tCardIds.MasterOfRealities_BG21_036,\r\n\tCardIds.MasterOfRealitiesBattlegrounds,\r\n\tCardIds.BrannsEpicEggBattlegrounds_TB_BaconShop_HERO_43_Buddy,\r\n\tCardIds.BrannsEpicEggBattlegrounds_TB_BaconShop_HERO_43_Buddy_G,\r\n\tCardIds.KilrekBattlegrounds_TB_BaconShop_HERO_37_Buddy,\r\n\tCardIds.KilrekBattlegrounds_TB_BaconShop_HERO_37_Buddy_G,\r\n\tCardIds.Glowscale,\r\n\tCardIds.GlowscaleBattlegrounds,\r\n\tCardIds.SilverbackPatriarch_BG_CS2_127,\r\n\tCardIds.SilverbackPatriarchBattlegrounds,\r\n\tCardIds.SparringPartner_BG_AT_069,\r\n\tCardIds.SparringPartnerBattlegrounds,\r\n\tCardIds.TunnelBlaster_BG_DAL_775,\r\n\tCardIds.TunnelBlasterBattlegrounds,\r\n];\r\nconst ATTACK_IMMEDIATELY_IDS = [\r\n\tCardIds.Scallywag_SkyPirateToken,\r\n\tCardIds.Scallywag_SkyPirateTokenBattlegrounds,\r\n\tCardIds.Onyxia_OnyxianWhelpToken,\r\n];\r\nexport const MEGA_WINDFURY_IDS = [\r\n\tCardIds.ZappSlywickBattlegrounds,\r\n\tCardIds.CracklingCycloneBattlegrounds,\r\n\tCardIds.BristlebackKnightBattlegrounds,\r\n\tCardIds.BonkerBattlegrounds,\r\n];\r\nconst CANT_ATTACK_IDS = [CardIds.ArcaneCannonBattlegrounds];\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\tspectator: Spectator,\r\n): BoardEntity => {\r\n\tconst card = allCards.getCard(cardId);\r\n\tconst megaWindfury = MEGA_WINDFURY_IDS.indexOf(cardId as CardIds) !== -1;\r\n\tconst attackImmediately = ATTACK_IMMEDIATELY_IDS.indexOf(cardId as CardIds) !== -1;\r\n\tconst newEntity = addImpliedMechanics({\r\n\t\tattack: card.attack,\r\n\t\tattacksPerformed: 0,\r\n\t\tcardId: cardId,\r\n\t\tdivineShield: hasMechanic(card, 'DIVINE_SHIELD'),\r\n\t\tentityId: entityId,\r\n\t\thealth: card.health,\r\n\t\tmaxHealth: card.health,\r\n\t\ttaunt: hasMechanic(card, 'TAUNT') || TAUNT_IDS.includes(cardId as CardIds),\r\n\t\treborn: hasMechanic(card, 'REBORN'),\r\n\t\tpoisonous: hasMechanic(card, 'POISONOUS'),\r\n\t\twindfury: !megaWindfury && (hasMechanic(card, 'WINDFURY') || card.referencedTags?.includes('WINDFURY')),\r\n\t\tmegaWindfury: megaWindfury,\r\n\t\tenchantments: [],\r\n\t\tfriendly: friendly,\r\n\t\tattackImmediately: attackImmediately,\r\n\t\tavengeCurrent: cardsData.avengeValue(cardId),\r\n\t\tavengeDefault: cardsData.avengeValue(cardId),\r\n\t} as BoardEntity);\r\n\r\n\tif (spawnReborn) {\r\n\t\tnewEntity.health = 1;\r\n\t\tnewEntity.reborn = false;\r\n\t}\r\n\r\n\tif (controllerHero?.heroPowerId === CardIds.SproutItOutBattlegrounds) {\r\n\t\tnewEntity.taunt = true;\r\n\t\tmodifyAttack(newEntity, 1, friendlyBoard, allCards);\r\n\t\tmodifyHealth(newEntity, 2, friendlyBoard, allCards);\r\n\t\tafterStatsUpdate(newEntity, friendlyBoard, allCards);\r\n\t\t// spectator && spectator.registerPowerTarget(result, result, friendlyBoard);\r\n\t} else if (controllerHero?.heroPowerId === CardIds.KurtrusAshfallen_CloseThePortal) {\r\n\t\tmodifyAttack(newEntity, 2, friendlyBoard, allCards);\r\n\t\tmodifyHealth(newEntity, 2, friendlyBoard, allCards);\r\n\t\tafterStatsUpdate(newEntity, friendlyBoard, allCards);\r\n\t\t// spectator && spectator.registerPowerTarget(result, result, friendlyBoard);\r\n\t}\r\n\r\n\tif (allCards.getCard(cardId).techLevel === controllerHero.tavernTier) {\r\n\t\tconst statsBonus =\r\n\t\t\t4 * friendlyBoard.filter((e) => e.cardId === CardIds.BabyYshaarjBattlegrounds_TB_BaconShop_HERO_92_Buddy).length +\r\n\t\t\t8 * friendlyBoard.filter((e) => e.cardId === CardIds.BabyYshaarjBattlegrounds_TB_BaconShop_HERO_92_Buddy_G).length;\r\n\t\tmodifyAttack(newEntity, statsBonus, friendlyBoard, allCards);\r\n\t\tmodifyHealth(newEntity, statsBonus, friendlyBoard, allCards);\r\n\t\tafterStatsUpdate(newEntity, friendlyBoard, allCards);\r\n\t}\r\n\r\n\tif (newEntity.taunt) {\r\n\t\tconst statsBonus =\r\n\t\t\t2 * friendlyBoard.filter((e) => e.cardId === CardIds.WanderingTreantBattlegrounds_TB_BaconShop_HERO_95_Buddy).length +\r\n\t\t\t4 * friendlyBoard.filter((e) => e.cardId === CardIds.WanderingTreantBattlegrounds_TB_BaconShop_HERO_95_Buddy_G).length;\r\n\t\tmodifyAttack(newEntity, statsBonus, friendlyBoard, allCards);\r\n\t\tmodifyHealth(newEntity, statsBonus, friendlyBoard, allCards);\r\n\t\tafterStatsUpdate(newEntity, friendlyBoard, allCards);\r\n\t}\r\n\r\n\treturn newEntity;\r\n};\r\n\r\nexport const modifyAttack = (entity: BoardEntity, amount: number, friendlyBoard: BoardEntity[], allCards: AllCardsService): void => {\r\n\tconst realAmount = entity.cardId === CardIds.TarecgosaBattlegrounds ? 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).race, Race.DRAGON)) {\r\n\t\tconst whelpSmugglers = friendlyBoard.filter((e) => e.cardId === CardIds.WhelpSmuggler);\r\n\t\tconst whelpSmugglersBattlegrounds = friendlyBoard.filter((e) => e.cardId === CardIds.WhelpSmugglerBattlegrounds);\r\n\t\twhelpSmugglers.forEach((smuggler) => {\r\n\t\t\tmodifyHealth(entity, 1, friendlyBoard, allCards);\r\n\t\t});\r\n\t\twhelpSmugglersBattlegrounds.forEach((smuggler) => {\r\n\t\t\tmodifyHealth(entity, 2, friendlyBoard, allCards);\r\n\t\t});\r\n\t}\r\n\tif (entity.cardId === CardIds.Menagerist_AmalgamTokenBattlegrounds || entity.cardId === CardIds.CuddlgamBattlegrounds) {\r\n\t\tconst mishmashes = friendlyBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.MishmashBattlegrounds_TB_BaconShop_HERO_33_Buddy ||\r\n\t\t\t\te.cardId === CardIds.MishmashBattlegrounds_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.MishmashBattlegrounds_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\r\nexport const modifyHealth = (entity: BoardEntity, amount: number, friendlyBoard: BoardEntity[], allCards: AllCardsService): void => {\r\n\tconst realAmount = entity.cardId === CardIds.TarecgosaBattlegrounds ? 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 (entity.cardId === CardIds.Menagerist_AmalgamTokenBattlegrounds || entity.cardId === CardIds.CuddlgamBattlegrounds) {\r\n\t\tconst mishmashes = friendlyBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.MishmashBattlegrounds_TB_BaconShop_HERO_33_Buddy ||\r\n\t\t\t\te.cardId === CardIds.MishmashBattlegrounds_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.MishmashBattlegrounds_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.TitanicGuardianBattlegrounds_TB_BaconShop_HERO_39_Buddy ||\r\n\t\t\t\te.cardId === CardIds.TitanicGuardianBattlegrounds_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.TitanicGuardianBattlegrounds_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 = (entity: BoardEntity, friendlyBoard: BoardEntity[], allCards: AllCardsService): 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.MasterOfRealitiesBattlegrounds,\r\n\t\t);\r\n\t\tmasterOfRealities.forEach((master) => {\r\n\t\t\tmodifyAttack(master, master.cardId === CardIds.MasterOfRealitiesBattlegrounds ? 2 : 1, friendlyBoard, allCards);\r\n\t\t\tmodifyHealth(master, master.cardId === CardIds.MasterOfRealitiesBattlegrounds ? 2 : 1, friendlyBoard, allCards);\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.TentacleOfCthunBattlegrounds_TB_BaconShop_HERO_29_Buddy ||\r\n\t\t\t\te.cardId === CardIds.TentacleOfCthunBattlegrounds_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.TentacleOfCthunBattlegrounds_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.TentacleOfCthunBattlegrounds_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\tconst refCard = allCards.getCard(target.cardId);\r\n\t// Typically, we are already golden\r\n\tif (!refCard.battlegroundsPremiumDbfId) {\r\n\t\treturn;\r\n\t}\r\n\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 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\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): BoardEntity => {\r\n\tif (board.length > 0) {\r\n\t\tconst validBeast: BoardEntity = getRandomAliveMinion(\r\n\t\t\tboard.filter((e) => e.entityId !== source.entityId),\r\n\t\t\trace,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t\t//tmp fix for PalescaleCrocolisk, PalescaleCrocolisk won't apply avenge and dethrattle effect on itself.\r\n\t\t//const validBeast: BoardEntity = getRandomAliveMinion(board, race, allCards);\r\n\t\tif (validBeast) {\r\n\t\t\tmodifyAttack(validBeast, attack, board, allCards);\r\n\t\t\tmodifyHealth(validBeast, health, board, allCards);\r\n\t\t\tafterStatsUpdate(validBeast, board, allCards);\r\n\t\t\tspectator.registerPowerTarget(source, validBeast, board);\r\n\t\t\treturn validBeast;\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\tcards: number,\r\n\tboard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tcardAdded: CardIds = null,\r\n): void => {\r\n\tconst sages = board.filter((e) => e.cardId === CardIds.DeathsHeadSage);\r\n\tconst sagesGolden = board.filter((e) => e.cardId === CardIds.DeathsHeadSageBattlegrounds);\r\n\tconst multiplier = 1 + (cardAdded === CardIds.BloodGem ? sages.length + 2 * sagesGolden.length : 0);\r\n\tplayerEntity.cardsInHand = Math.min(10, (playerEntity.cardsInHand ?? 0) + multiplier * cards);\r\n\r\n\tconst peggys = board.filter((e) => e.cardId === CardIds.PeggyBrittlebone || e.cardId === CardIds.PeggyBrittleboneBattlegrounds);\r\n\tpeggys.forEach((peggy) => {\r\n\t\tconst pirate = getRandomAliveMinion(\r\n\t\t\tboard.filter((e) => e.entityId !== peggy.entityId),\r\n\t\t\tRace.PIRATE,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t\tif (pirate) {\r\n\t\t\tmodifyAttack(pirate, peggy.cardId === CardIds.PeggyBrittleboneBattlegrounds ? 2 : 1, board, allCards);\r\n\t\t\tmodifyHealth(pirate, peggy.cardId === CardIds.PeggyBrittleboneBattlegrounds ? 2 : 1, board, allCards);\r\n\t\t\tafterStatsUpdate(pirate, board, allCards);\r\n\t\t\tspectator.registerPowerTarget(peggy, pirate, board);\r\n\t\t}\r\n\t});\r\n};\r\n\r\nexport const grantRandomDivineShield = (source: BoardEntity, board: BoardEntity[], spectator: Spectator): 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\tchosen.divineShield = true;\r\n\t\tspectator.registerPowerTarget(source, chosen, board);\r\n\t}\r\n\t// return board;\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).race, getRaceEnum(tribe)));\r\n\tfor (const entity of elligibleEntities) {\r\n\t\tentity.divineShield = true;\r\n\t}\r\n\t// return board;\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).race, race))\r\n\t\t.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tif (!validTribes.length) {\r\n\t\treturn null;\r\n\t}\r\n\treturn validTribes[Math.floor(Math.random() * validTribes.length)];\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 || isCorrectTribe(allCards.getCard(entity.cardId).race, Race[tribe])) {\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 applyEffectToMinionTypes = (\r\n\tboard: BoardEntity[],\r\n\thero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\teffect: (entity: BoardEntity) => void,\r\n): void => {\r\n\tconst groupedByRace = groupByFunction((e: BoardEntity) => allCards.getCard(e.cardId).race)(\r\n\t\tboard.filter((e) => !!allCards.getCard(e.cardId).race),\r\n\t);\r\n\tObject.values(groupedByRace)\r\n\t\t.filter((minions) => !!minions?.length)\r\n\t\t.forEach((minions) => {\r\n\t\t\tconst target = pickRandom(minions);\r\n\t\t\teffect(target);\r\n\t\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).race, targetTribe);\r\n};\r\n\r\nexport const isCorrectTribe = (cardRace: string, targetTribe: Race): boolean => {\r\n\treturn getRaceEnum(cardRace) === Race.ALL || getRaceEnum(cardRace) === 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): 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 {\r\n\t\t...entity,\r\n\t\tcleave: cleave,\r\n\t\tcantAttack: cantAttack,\r\n\t} as BoardEntity;\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=${entity.health}/ds=${\r\n\t\t\t\tentity.divineShield\r\n\t\t }/taunt=${entity.taunt}/stealth=${entity.stealth}/ench=${JSON.stringify(entity.enchantments)}`\r\n\t\t: null;\r\n};\r\n"]}
|