@firestone-hs/simulate-bgs-battle 1.1.235 → 1.1.237
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/simulation/auras.js
CHANGED
|
@@ -49,10 +49,10 @@ const setMissingMinionsAura = (board, allCards) => {
|
|
|
49
49
|
setMissingAura(board.filter((e) => utils_1.hasCorrectTribe(e, reference_data_1.Race.DEMON, allCards)), "BG21_039_G", "BG21_039_Ge", 4, 0);
|
|
50
50
|
setMissingAura(board, "TB_BaconShop_HERO_52_Buddy", "TB_BaconShop_HERO_52_Buddy_e", 3, 0, false);
|
|
51
51
|
setMissingAura(board, "TB_BaconShop_HERO_52_Buddy_G", "TB_BaconShop_HERO_52_Buddy_G_e", 6, 0, false);
|
|
52
|
-
setMissingAura(board.filter((e) => e.divineShield), "BG25_043", "
|
|
53
|
-
setMissingAura(board.filter((e) => e.divineShield), "BG25_043_G", "
|
|
52
|
+
setMissingAura(board.filter((e) => e.divineShield), "BG25_043", "BG25_043e", 10, 0, false);
|
|
53
|
+
setMissingAura(board.filter((e) => e.divineShield), "BG25_043_G", "BG25_043_Ge", 20, 0, false);
|
|
54
54
|
};
|
|
55
|
-
const setMissingAura = (board, minionCardId, enchantmentCardId, attack, health, ignoreSelf = true) => {
|
|
55
|
+
const setMissingAura = (board, minionCardId, enchantmentCardId, attack, health, ignoreSelf = true, allCards = null) => {
|
|
56
56
|
const buffers = board.filter((e) => e.cardId === minionCardId);
|
|
57
57
|
for (const buffer of buffers) {
|
|
58
58
|
board
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auras.js","sourceRoot":"","sources":["../../src/simulation/auras.ts"],"names":[],"mappings":";;;AACA,iEAA8E;AAI9E,oCAAmE;AAE5D,MAAM,eAAe,GAAG,CAC9B,KAAoB,EACpB,SAA0B,EAC1B,SAA0B,EAC1B,QAAyB,EAClB,EAAE;IACT,qBAAqB,CAAC,KAAK,EAAE,QAAQ,CAAC,CA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AAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE;QACxE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC;QAC1C,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC;KAC/C;AACF,CAAC,CAAC;AAZW,QAAA,oBAAoB,wBAY/B","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from 'src/bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardsData } from '../cards/cards-data';\r\nimport { hasCorrectTribe, normalizeCardIdForSkin } from '../utils';\r\n\r\nexport const setMissingAuras = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\tsetMissingMinionsAura(board, allCards);\r\n\tsetMissingHeroPowerAura(board, boardHero, otherHero);\r\n};\r\n\r\nexport const setMissingHeroPowerAura = (board: BoardEntity[], boardHero: BgsPlayerEntity, otherHero: BgsPlayerEntity): void => {\r\n\tif (boardHero.heroPowerId === CardIds.AllWillBurnBattlegrounds || otherHero.heroPowerId === CardIds.AllWillBurnBattlegrounds) {\r\n\t\tconst bonus =\r\n\t\t\t(boardHero.heroPowerId === CardIds.AllWillBurnBattlegrounds ? 3 : 0) +\r\n\t\t\t(otherHero.heroPowerId === CardIds.AllWillBurnBattlegrounds ? 3 : 0);\r\n\t\tboard\r\n\t\t\t.filter((e) => !e.enchantments.find((ench) => ench.cardId === CardIds.AllWillBurn_AllWillBurnEnchantmentBattlegrounds))\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\te.attack += bonus;\r\n\t\t\t});\r\n\t}\r\n\tif (boardHero.heroPowerId === CardIds.TheSmokingGun) {\r\n\t\tboard\r\n\t\t\t.filter((e) => !e.enchantments.find((ench) => ench.cardId === CardIds.TheSmokingGun_ArmedAndStillSmokingEnchantment))\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\te.attack += 5;\r\n\t\t\t});\r\n\t}\r\n\tif (boardHero.heroPowerId === CardIds.VolatileVenom) {\r\n\t\tboard\r\n\t\t\t.filter((e) => !e.enchantments.find((ench) => ench.cardId === CardIds.VolatileVenom_VolatileEnchantment))\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\te.attack += 7;\r\n\t\t\t\te.health += 7;\r\n\t\t\t\te.enchantments.push({\r\n\t\t\t\t\tcardId: CardIds.VolatileVenom_VolatileEnchantment,\r\n\t\t\t\t\toriginEntityId: undefined,\r\n\t\t\t\t\ttiming: 0,\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t}\r\n};\r\n\r\nconst setMissingMinionsAura = (board: BoardEntity[], allCards: AllCardsService): void => {\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, Race.PIRATE, allCards)),\r\n\t\tCardIds.SouthseaCaptainLegacy_BG_NEW1_027,\r\n\t\tCardIds.SouthseaCaptain_YarrrLegacyEnchantment,\r\n\t\t1,\r\n\t\t1,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, Race.PIRATE, allCards)),\r\n\t\tCardIds.SouthseaCaptainLegacyBattlegrounds,\r\n\t\tCardIds.SouthseaCaptain_YarrrEnchantmentBattlegrounds,\r\n\t\t2,\r\n\t\t2,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, Race.MURLOC, allCards)),\r\n\t\tCardIds.MurlocWarleaderLegacy_BG_EX1_507,\r\n\t\tCardIds.MurlocWarleader_MrgglaarglLegacyEnchantment,\r\n\t\t2,\r\n\t\t0,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, Race.MURLOC, allCards)),\r\n\t\tCardIds.MurlocWarleaderLegacyBattlegrounds,\r\n\t\tCardIds.MurlocWarleader_MrgglaarglEnchantmentBattlegrounds,\r\n\t\t4,\r\n\t\t0,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, Race.DEMON, allCards)),\r\n\t\tCardIds.Kathranatir_BG21_039,\r\n\t\tCardIds.Kathranatir_GraspOfKathranatirEnchantment_BG21_039e,\r\n\t\t2,\r\n\t\t0,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, Race.DEMON, allCards)),\r\n\t\tCardIds.KathranatirBattlegrounds,\r\n\t\tCardIds.Kathranatir_GraspOfKathranatirEnchantment_BG21_039_Ge,\r\n\t\t4,\r\n\t\t0,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard,\r\n\t\tCardIds.LadySinestraBattlegrounds_TB_BaconShop_HERO_52_Buddy,\r\n\t\tCardIds.DraconicBlessingEnchantmentBattlegrounds_TB_BaconShop_HERO_52_Buddy_e,\r\n\t\t3,\r\n\t\t0,\r\n\t\tfalse,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard,\r\n\t\tCardIds.LadySinestraBattlegrounds_TB_BaconShop_HERO_52_Buddy_G,\r\n\t\tCardIds.DraconicBlessingEnchantmentBattlegrounds_TB_BaconShop_HERO_52_Buddy_G_e,\r\n\t\t6,\r\n\t\t0,\r\n\t\tfalse,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => e.divineShield),\r\n\t\tCardIds.CyborgDrake,\r\n\t\tCardIds.CyborgEnhancementEnchantment_BG25_901e,\r\n\t\t10,\r\n\t\t0,\r\n\t\tfalse,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => e.divineShield),\r\n\t\tCardIds.CyborgDrakeBattlegrounds,\r\n\t\tCardIds.CyborgEnhancementEnchantment_BG25_901e2,\r\n\t\t20,\r\n\t\t0,\r\n\t\tfalse,\r\n\t);\r\n};\r\n\r\nconst setMissingAura = (\r\n\tboard: BoardEntity[],\r\n\tminionCardId: string,\r\n\tenchantmentCardId: string,\r\n\tattack: number,\r\n\thealth: number,\r\n\tignoreSelf = true,\r\n): void => {\r\n\tconst buffers = board.filter((e) => e.cardId === minionCardId);\r\n\tfor (const buffer of buffers) {\r\n\t\tboard\r\n\t\t\t.filter((e) => !e.enchantments.find((ench) => ench.cardId === enchantmentCardId))\r\n\t\t\t.filter((e) => (ignoreSelf ? e.entityId !== buffer.entityId : true))\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\te.attack += attack;\r\n\t\t\t\te.health += health;\r\n\t\t\t});\r\n\t}\r\n};\r\n\r\nexport const setImplicitData = (board: BoardEntity[], cardsData: CardsData): void => {\r\n\tfor (const entity of board) {\r\n\t\tentity.cardId = normalizeCardIdForSkin(entity.cardId);\r\n\t\tentity.maxHealth = entity.health;\r\n\t\tconst avengeValue = cardsData.avengeValue(entity.cardId);\r\n\t\tif (avengeValue > 0) {\r\n\t\t\tentity.avengeCurrent = avengeValue;\r\n\t\t\tentity.avengeDefault = avengeValue;\r\n\t\t}\r\n\t\tentity.immuneWhenAttackCharges = 0;\r\n\t}\r\n};\r\n\r\nexport const setImplicitDataHero = (hero: BgsPlayerEntity, cardsData: CardsData, isPlayer: boolean): void => {\r\n\tconst avengeValue = cardsData.avengeValue(hero.heroPowerId);\r\n\tif (avengeValue > 0) {\r\n\t\thero.avengeCurrent = avengeValue;\r\n\t\thero.avengeDefault = avengeValue;\r\n\t}\r\n\t// Backward compatibility\r\n\tif (!!hero.questRewards?.length && !Array.isArray(hero.questRewards)) {\r\n\t\thero.questRewards = [hero.questRewards as any];\r\n\t}\r\n\r\n\t// Because Denathrius can send a quest reward as its hero power (I think)\r\n\thero.questRewards = [...(hero.questRewards ?? []), hero.heroPowerId].filter((e) => !!e);\r\n\thero.entityId = hero.entityId ?? (isPlayer ? 999_999_998 : 999_999_999);\r\n\tif (!hero.globalInfo) {\r\n\t\thero.globalInfo = {\r\n\t\t\tEternalKnightsDeadThisGame: 0,\r\n\t\t\tUndeadAttackBonus: 0,\r\n\t\t};\r\n\t}\r\n};\r\n\r\nexport const clearStealthIfNeeded = (board: BoardEntity[], otherBoard: BoardEntity[]): void => {\r\n\t// https://twitter.com/DCalkosz/status/1562194944688660481?s=20&t=100I8IVZmBKgYQWkdK8nIA\r\n\tif (board.every((entity) => entity.stealth && !entity.attack)) {\r\n\t\tboard.forEach((e) => (e.stealth = false));\r\n\t}\r\n\tif (otherBoard.every((entity) => entity.stealth && !entity.attack)) {\r\n\t\totherBoard.forEach((e) => (e.stealth = false));\r\n\t}\r\n\tif (board.every((e) => e.stealth) && otherBoard.every((e) => e.stealth)) {\r\n\t\tboard.forEach((e) => (e.stealth = false));\r\n\t\totherBoard.forEach((e) => (e.stealth = false));\r\n\t}\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"auras.js","sourceRoot":"","sources":["../../src/simulation/auras.ts"],"names":[],"mappings":";;;AACA,iEAA8E;AAI9E,oCAAmE;AAE5D,MAAM,eAAe,GAAG,CAC9B,KAAoB,EACpB,SAA0B,EAC1B,SAA0B,EAC1B,QAAyB,EAClB,EAAE;IACT,qBAAqB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACvC,+BAAuB,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AACtD,CAAC,CAAC;AARW,QAAA,eAAe,mBAQ1B;AAEK,MAAM,uBAAuB,GAAG,CAAC,KAAoB,EAAE,SAA0B,EAAE,SAA0B,EAAQ,EAAE;IAC7H,IAAI,SAAS,CAAC,WAAW,0BAAqC,IAAI,SAAS,CAAC,WAAW,0BAAqC,EAAE;QAC7H,MAAM,KAAK,GACV,CAAC,SAAS,CAAC,WAAW,0BAAqC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAA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AAC;AAZW,QAAA,oBAAoB,wBAY/B","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from 'src/bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardsData } from '../cards/cards-data';\r\nimport { hasCorrectTribe, normalizeCardIdForSkin } from '../utils';\r\n\r\nexport const setMissingAuras = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n): void => {\r\n\tsetMissingMinionsAura(board, allCards);\r\n\tsetMissingHeroPowerAura(board, boardHero, otherHero);\r\n};\r\n\r\nexport const setMissingHeroPowerAura = (board: BoardEntity[], boardHero: BgsPlayerEntity, otherHero: BgsPlayerEntity): void => {\r\n\tif (boardHero.heroPowerId === CardIds.AllWillBurnBattlegrounds || otherHero.heroPowerId === CardIds.AllWillBurnBattlegrounds) {\r\n\t\tconst bonus =\r\n\t\t\t(boardHero.heroPowerId === CardIds.AllWillBurnBattlegrounds ? 3 : 0) +\r\n\t\t\t(otherHero.heroPowerId === CardIds.AllWillBurnBattlegrounds ? 3 : 0);\r\n\t\tboard\r\n\t\t\t.filter((e) => !e.enchantments.find((ench) => ench.cardId === CardIds.AllWillBurn_AllWillBurnEnchantmentBattlegrounds))\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\te.attack += bonus;\r\n\t\t\t});\r\n\t}\r\n\tif (boardHero.heroPowerId === CardIds.TheSmokingGun) {\r\n\t\tboard\r\n\t\t\t.filter((e) => !e.enchantments.find((ench) => ench.cardId === CardIds.TheSmokingGun_ArmedAndStillSmokingEnchantment))\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\te.attack += 5;\r\n\t\t\t});\r\n\t}\r\n\tif (boardHero.heroPowerId === CardIds.VolatileVenom) {\r\n\t\tboard\r\n\t\t\t.filter((e) => !e.enchantments.find((ench) => ench.cardId === CardIds.VolatileVenom_VolatileEnchantment))\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\te.attack += 7;\r\n\t\t\t\te.health += 7;\r\n\t\t\t\te.enchantments.push({\r\n\t\t\t\t\tcardId: CardIds.VolatileVenom_VolatileEnchantment,\r\n\t\t\t\t\toriginEntityId: undefined,\r\n\t\t\t\t\ttiming: 0,\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t}\r\n};\r\n\r\nconst setMissingMinionsAura = (board: BoardEntity[], allCards: AllCardsService): void => {\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, Race.PIRATE, allCards)),\r\n\t\tCardIds.SouthseaCaptainLegacy_BG_NEW1_027,\r\n\t\tCardIds.SouthseaCaptain_YarrrLegacyEnchantment,\r\n\t\t1,\r\n\t\t1,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, Race.PIRATE, allCards)),\r\n\t\tCardIds.SouthseaCaptainLegacyBattlegrounds,\r\n\t\tCardIds.SouthseaCaptain_YarrrEnchantmentBattlegrounds,\r\n\t\t2,\r\n\t\t2,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, Race.MURLOC, allCards)),\r\n\t\tCardIds.MurlocWarleaderLegacy_BG_EX1_507,\r\n\t\tCardIds.MurlocWarleader_MrgglaarglLegacyEnchantment,\r\n\t\t2,\r\n\t\t0,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, Race.MURLOC, allCards)),\r\n\t\tCardIds.MurlocWarleaderLegacyBattlegrounds,\r\n\t\tCardIds.MurlocWarleader_MrgglaarglEnchantmentBattlegrounds,\r\n\t\t4,\r\n\t\t0,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, Race.DEMON, allCards)),\r\n\t\tCardIds.Kathranatir_BG21_039,\r\n\t\tCardIds.Kathranatir_GraspOfKathranatirEnchantment_BG21_039e,\r\n\t\t2,\r\n\t\t0,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, Race.DEMON, allCards)),\r\n\t\tCardIds.KathranatirBattlegrounds,\r\n\t\tCardIds.Kathranatir_GraspOfKathranatirEnchantment_BG21_039_Ge,\r\n\t\t4,\r\n\t\t0,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard,\r\n\t\tCardIds.LadySinestraBattlegrounds_TB_BaconShop_HERO_52_Buddy,\r\n\t\tCardIds.DraconicBlessingEnchantmentBattlegrounds_TB_BaconShop_HERO_52_Buddy_e,\r\n\t\t3,\r\n\t\t0,\r\n\t\tfalse,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard,\r\n\t\tCardIds.LadySinestraBattlegrounds_TB_BaconShop_HERO_52_Buddy_G,\r\n\t\tCardIds.DraconicBlessingEnchantmentBattlegrounds_TB_BaconShop_HERO_52_Buddy_G_e,\r\n\t\t6,\r\n\t\t0,\r\n\t\tfalse,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => e.divineShield),\r\n\t\tCardIds.CyborgDrake,\r\n\t\tCardIds.CyborgDrake_CyborgEnhancementEnchantment_BG25_043e,\r\n\t\t10,\r\n\t\t0,\r\n\t\tfalse,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => e.divineShield),\r\n\t\tCardIds.CyborgDrakeBattlegrounds,\r\n\t\tCardIds.CyborgDrake_CyborgEnhancementEnchantment_BG25_043_Ge,\r\n\t\t20,\r\n\t\t0,\r\n\t\tfalse,\r\n\t);\r\n};\r\n\r\nconst setMissingAura = (\r\n\tboard: BoardEntity[],\r\n\tminionCardId: string,\r\n\tenchantmentCardId: string,\r\n\tattack: number,\r\n\thealth: number,\r\n\tignoreSelf = true,\r\n\tallCards: AllCardsService = null,\r\n): void => {\r\n\tconst buffers = board.filter((e) => e.cardId === minionCardId);\r\n\tfor (const buffer of buffers) {\r\n\t\tboard\r\n\t\t\t.filter((e) => !e.enchantments.find((ench) => ench.cardId === enchantmentCardId))\r\n\t\t\t.filter((e) => (ignoreSelf ? e.entityId !== buffer.entityId : true))\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\te.attack += attack;\r\n\t\t\t\te.health += health;\r\n\t\t\t});\r\n\t}\r\n};\r\n\r\nexport const setImplicitData = (board: BoardEntity[], cardsData: CardsData): void => {\r\n\tfor (const entity of board) {\r\n\t\tentity.cardId = normalizeCardIdForSkin(entity.cardId);\r\n\t\tentity.maxHealth = entity.health;\r\n\t\tconst avengeValue = cardsData.avengeValue(entity.cardId);\r\n\t\tif (avengeValue > 0) {\r\n\t\t\tentity.avengeCurrent = avengeValue;\r\n\t\t\tentity.avengeDefault = avengeValue;\r\n\t\t}\r\n\t\tentity.immuneWhenAttackCharges = 0;\r\n\t}\r\n};\r\n\r\nexport const setImplicitDataHero = (hero: BgsPlayerEntity, cardsData: CardsData, isPlayer: boolean): void => {\r\n\tconst avengeValue = cardsData.avengeValue(hero.heroPowerId);\r\n\tif (avengeValue > 0) {\r\n\t\thero.avengeCurrent = avengeValue;\r\n\t\thero.avengeDefault = avengeValue;\r\n\t}\r\n\t// Backward compatibility\r\n\tif (!!hero.questRewards?.length && !Array.isArray(hero.questRewards)) {\r\n\t\thero.questRewards = [hero.questRewards as any];\r\n\t}\r\n\r\n\t// Because Denathrius can send a quest reward as its hero power (I think)\r\n\thero.questRewards = [...(hero.questRewards ?? []), hero.heroPowerId].filter((e) => !!e);\r\n\thero.entityId = hero.entityId ?? (isPlayer ? 999_999_998 : 999_999_999);\r\n\tif (!hero.globalInfo) {\r\n\t\thero.globalInfo = {\r\n\t\t\tEternalKnightsDeadThisGame: 0,\r\n\t\t\tUndeadAttackBonus: 0,\r\n\t\t};\r\n\t}\r\n};\r\n\r\nexport const clearStealthIfNeeded = (board: BoardEntity[], otherBoard: BoardEntity[]): void => {\r\n\t// https://twitter.com/DCalkosz/status/1562194944688660481?s=20&t=100I8IVZmBKgYQWkdK8nIA\r\n\tif (board.every((entity) => entity.stealth && !entity.attack)) {\r\n\t\tboard.forEach((e) => (e.stealth = false));\r\n\t}\r\n\tif (otherBoard.every((entity) => entity.stealth && !entity.attack)) {\r\n\t\totherBoard.forEach((e) => (e.stealth = false));\r\n\t}\r\n\tif (board.every((e) => e.stealth) && otherBoard.every((e) => e.stealth)) {\r\n\t\tboard.forEach((e) => (e.stealth = false));\r\n\t\totherBoard.forEach((e) => (e.stealth = false));\r\n\t}\r\n};\r\n"]}
|
|
@@ -299,11 +299,14 @@ const performStartOfCombatMinionsForPlayer = (attacker, attackingBoard, attackin
|
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
else if (attacker.cardId === "BG25_023" || attacker.cardId === "BG25_023_G") {
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
chosenUndead
|
|
306
|
-
|
|
302
|
+
const numberOfTargets = attacker.cardId === "BG25_023_G" ? 2 : 1;
|
|
303
|
+
for (let i = 0; i < numberOfTargets; i++) {
|
|
304
|
+
const undeadsWithoutReborn = attackingBoard.filter((e) => utils_2.hasCorrectTribe(e, reference_data_1.Race.UNDEAD, allCards)).filter((e) => !e.reborn);
|
|
305
|
+
const chosenUndead = utils_1.pickRandom(undeadsWithoutReborn);
|
|
306
|
+
if (chosenUndead) {
|
|
307
|
+
chosenUndead.reborn = true;
|
|
308
|
+
spectator.registerPowerTarget(attacker, chosenUndead, attackingBoard);
|
|
309
|
+
}
|
|
307
310
|
}
|
|
308
311
|
}
|
|
309
312
|
else if (attacker.cardId === "BG22_HERO_000_Buddy" || attacker.cardId === "BG22_HERO_000_Buddy_G") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-of-combat.js","sourceRoot":"","sources":["../../src/simulation/start-of-combat.ts"],"names":[],"mappings":";;;AACA,iEAA8E;AAI9E,oDAA0E;AAC1E,6CAA4E;AAC5E,oCASkB;AAClB,qCAOkB;AAClB,+DAK+B;AAC/B,6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,CAAC;AAClC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsGameState } from '../bgs-battle-info';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardsData, START_OF_COMBAT_CARD_IDS } from '../cards/cards-data';\r\nimport { pickMultipleRandomDifferent, pickRandom } from '../services/utils';\r\nimport {\r\n\tafterStatsUpdate,\r\n\thasCorrectTribe,\r\n\tisCorrectTribe,\r\n\tmakeMinionGolden,\r\n\tmodifyAttack,\r\n\tmodifyHealth,\r\n\tstringifySimple,\r\n\tupdateDivineShield,\r\n} from '../utils';\r\nimport {\r\n\tdealDamageToEnemy,\r\n\tdealDamageToRandomEnemy,\r\n\tgetNeighbours,\r\n\tperformEntitySpawns,\r\n\tprocessMinionDeath,\r\n\tsimulateAttack,\r\n} from './attack';\r\nimport {\r\n\tapplyEarthInvocationEnchantment,\r\n\tapplyFireInvocationEnchantment,\r\n\tapplyLightningInvocationEnchantment,\r\n\tapplyWaterInvocationEnchantment,\r\n} from './deathrattle-effects';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { SharedState } from './shared-state';\r\nimport { Spectator } from './spectator/spectator';\r\n\r\nexport const handleStartOfCombat = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// https://twitter.com/DCalkosz/status/1564705111850434561\r\n\tcurrentAttacker = handleStartOfCombatQuestRewards(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\t// https://twitter.com/DCalkosz/status/1488361384320528388?s=20&t=1ECxRZFdjqwEa2fRsXk32Q\r\n\t// There’s a certain order for Start of Combat hero powers, rather than “coin flips” where\r\n\t// an unlucky trigger order could mess up some positioning you had planned for your own hero\r\n\t// power. “Precombat” (Al’Akir, Y’Shaarj), then Illidan, then others.\r\n\tcurrentAttacker = handlePreCombatHeroPowers(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\t// Because start of combat powers like Red Whelp's use the board composition before Illidan's strike to know the amount of damage\r\n\tconst playerBoardBefore = playerBoard.map((e) => ({ ...e }));\r\n\tconst opponentBoardBefore = opponentBoard.map((e) => ({ ...e }));\r\n\tcurrentAttacker = handleIllidanHeroPowers(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\tcurrentAttacker = handleStartOfCombatHeroPowers(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\tcurrentAttacker = handleStartOfCombatMinions(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tplayerBoardBefore,\r\n\t\topponentBoardBefore,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePreCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\tcurrentAttacker = handlePreCombatHeroPowersForPlayer(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\tcurrentAttacker = handlePreCombatHeroPowersForPlayer(\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePreCombatHeroPowersForPlayer = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// Some are part of the incoming board: Y'Shaarj, Lich King, Ozumat\r\n\t// Since the order is not important here, we just always do the player first\r\n\tconst playerHeroPowerId = playerEntity.heroPowerId || getHeroPowerForHero(playerEntity.cardId);\r\n\tif (playerHeroPowerId === CardIds.SwattingInsectsBattlegrounds && playerBoard.length > 0) {\r\n\t\t// Should be sent by the app, but it is an idempotent operation, so we can just reapply it here\r\n\t\thandleAlakirForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, spawns, sharedState, spectator);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.EarthInvocationToken) {\r\n\t\tapplyEarthInvocationEnchantment(playerBoard, null, playerEntity, allCards, sharedState, spectator);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.WaterInvocationToken) {\r\n\t\tapplyWaterInvocationEnchantment(playerBoard, null, playerEntity, allCards, spectator);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.FireInvocationToken) {\r\n\t\tapplyFireInvocationEnchantment(playerBoard, null, playerEntity, allCards, spectator);\r\n\t}\r\n\r\n\treturn currentAttacker;\r\n};\r\n\r\nexport const handleIllidanHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// console.log('current attacker before', currentAttacker);\r\n\t// Apparently it's a toin coss about whether to handle Illidan first or Al'Akir first\r\n\t// Auras are only relevant for Illidan, and already applied there\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else {\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\tprocessMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t// console.log('current attacker after', currentAttacker);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatMinions = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tplayerBoardBefore: BoardEntity[],\r\n\topponentBoardBefore: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\tlet attackerForStart = currentAttacker;\r\n\tconst playerAttackers = playerBoard.filter((entity) => START_OF_COMBAT_CARD_IDS.includes(entity.cardId as CardIds));\r\n\tconst opponentAttackers = opponentBoard.filter((entity) => START_OF_COMBAT_CARD_IDS.includes(entity.cardId as CardIds));\r\n\twhile (playerAttackers.length > 0 || opponentAttackers.length > 0) {\r\n\t\tif (attackerForStart === 0 && playerAttackers.length > 0) {\r\n\t\t\tconst attacker = playerAttackers.splice(0, 1)[0];\r\n\t\t\tperformStartOfCombatMinionsForPlayer(\r\n\t\t\t\tattacker,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tplayerBoardBefore,\r\n\t\t\t\topponentBoardBefore,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspawns,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tgameState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t} else if (attackerForStart === 1 && opponentAttackers.length > 0) {\r\n\t\t\tconst attacker = opponentAttackers.splice(0, 1)[0];\r\n\t\t\tperformStartOfCombatMinionsForPlayer(\r\n\t\t\t\tattacker,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoardBefore,\r\n\t\t\t\tplayerBoardBefore,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspawns,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tgameState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t\tattackerForStart = (attackerForStart + 1) % 2;\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatQuestRewards = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\tcurrentAttacker = handleStartOfCombatQuestRewardsForPlayer(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\tcurrentAttacker = handleStartOfCombatQuestRewardsForPlayer(\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatQuestRewardsForPlayer = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\tif (!playerEntity.questRewards?.length) {\r\n\t\treturn currentAttacker;\r\n\t}\r\n\tfor (const reward of playerEntity.questRewards) {\r\n\t\tswitch (reward) {\r\n\t\t\tcase CardIds.EvilTwin:\r\n\t\t\t\tif (!!playerBoard.length && playerBoard.length < 7) {\r\n\t\t\t\t\tconst highestHealthMinion = [...playerBoard].sort((a, b) => b.health - a.health)[0];\r\n\t\t\t\t\tconst copy: BoardEntity = {\r\n\t\t\t\t\t\t...highestHealthMinion,\r\n\t\t\t\t\t\tlastAffectedByEntity: null,\r\n\t\t\t\t\t};\r\n\t\t\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\t\t\tcopy.cardId,\r\n\t\t\t\t\t\t1,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tspawns,\r\n\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t\thighestHealthMinion.friendly,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\tcopy,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tconst indexFromRight = playerBoard.length - (playerBoard.indexOf(highestHealthMinion) + 1);\r\n\t\t\t\t\tperformEntitySpawns(\r\n\t\t\t\t\t\tnewMinions,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\thighestHealthMinion,\r\n\t\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tspawns,\r\n\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tspectator.registerPowerTarget(playerEntity, copy, playerBoard);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.StaffOfOrigination_BG24_Reward_312:\r\n\t\t\t\tplayerBoard.forEach((entity) => {\r\n\t\t\t\t\tmodifyAttack(entity, 15, playerBoard, allCards);\r\n\t\t\t\t\tmodifyHealth(entity, 15, playerBoard, allCards);\r\n\t\t\t\t\tafterStatsUpdate(entity, playerBoard, allCards);\r\n\t\t\t\t\tspectator.registerPowerTarget(playerEntity, entity, playerBoard);\r\n\t\t\t\t});\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.StolenGold:\r\n\t\t\t\tif (playerBoard.length > 0) {\r\n\t\t\t\t\tmakeMinionGolden(playerBoard[0], playerEntity, playerBoard, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t\tif (playerBoard.length > 1) {\r\n\t\t\t\t\tmakeMinionGolden(playerBoard[playerBoard.length - 1], playerEntity, playerBoard, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\treturn currentAttacker;\r\n};\r\n\r\nexport const handleStartOfCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// Apparently it's a toin coss about whether to handle Illidan first or Al'Akir first\r\n\t// Auras are only relevant for Illidan, and already applied there\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else {\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePlayerIllidanHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tfriendly: boolean,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\tconst playerHeroPowerId = playerEntity.heroPowerId || getHeroPowerForHero(playerEntity.cardId);\r\n\tif (playerHeroPowerId === CardIds.WingmenBattlegrounds && playerBoard.length > 0) {\r\n\t\thandleIllidanForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, spawns, sharedState, spectator);\r\n\t\tcurrentAttacker = (currentAttacker + 1) % 2;\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\n// TODO: not exactly correct, because of \"attack immediately\", but it's close enough\r\nconst handleIllidanForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// Otherwise, if the first minion dies on the attack, and the board has only 2 minions, we\r\n\t// miss the second one\r\n\tconst minionsAtStart = playerBoard.length;\r\n\tconst firstAttacker = playerBoard[0];\r\n\tconst secondAttacker = minionsAtStart > 1 ? playerBoard[playerBoard.length - 1] : null;\r\n\r\n\tmodifyAttack(firstAttacker, 2, playerBoard, allCards);\r\n\tafterStatsUpdate(firstAttacker, playerBoard, allCards);\r\n\tspectator.registerPowerTarget(firstAttacker, firstAttacker, playerBoard);\r\n\tif (\r\n\t\tplayerBoard.map((e) => e.cardId).includes(CardIds.EclipsionIllidariBattlegrounds_TB_BaconShop_HERO_08_Buddy) ||\r\n\t\tplayerBoard.map((e) => e.cardId).includes(CardIds.EclipsionIllidariBattlegrounds_TB_BaconShop_HERO_08_Buddy_G)\r\n\t) {\r\n\t\tfirstAttacker.immuneWhenAttackCharges = 1;\r\n\t}\r\n\tsimulateAttack(playerBoard, playerEntity, opponentBoard, opponentEntity, undefined, allCards, spawns, sharedState, spectator, 0);\r\n\r\n\tif (!!secondAttacker && !secondAttacker.definitelyDead && secondAttacker.health > 0) {\r\n\t\tmodifyAttack(secondAttacker, 2, playerBoard, allCards);\r\n\t\tafterStatsUpdate(secondAttacker, playerBoard, allCards);\r\n\t\tspectator.registerPowerTarget(secondAttacker, secondAttacker, playerBoard);\r\n\t\tif (playerBoard.map((e) => e.cardId).includes(CardIds.EclipsionIllidariBattlegrounds_TB_BaconShop_HERO_08_Buddy_G)) {\r\n\t\t\tsecondAttacker.immuneWhenAttackCharges = 1;\r\n\t\t}\r\n\t\tsimulateAttack(\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tundefined,\r\n\t\t\tallCards,\r\n\t\t\tspawns,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tplayerBoard.length - 1,\r\n\t\t);\r\n\t}\r\n};\r\n\r\nconst handleAlakirForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst firstEntity = playerBoard[0];\r\n\tfirstEntity.windfury = true;\r\n\tif (!firstEntity.divineShield) {\r\n\t\tupdateDivineShield(firstEntity, playerBoard, true, allCards);\r\n\t}\r\n\tfirstEntity.taunt = true;\r\n\tspectator.registerPowerTarget(firstEntity, firstEntity, playerBoard);\r\n};\r\n\r\nconst handleTamsinForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst lowestHealth = Math.min(...playerBoard.map((e) => e.health));\r\n\tconst entitiesWithLowestHealth = playerBoard.filter((e) => e.health === lowestHealth);\r\n\tconst chosenEntity = pickRandom(entitiesWithLowestHealth);\r\n\tif (!chosenEntity) {\r\n\t\tconsole.warn('could not pick any entity for tamsin', stringifySimple(entitiesWithLowestHealth, allCards));\r\n\t\treturn;\r\n\t}\r\n\tconst newBoard = playerBoard.filter((e) => e.entityId !== chosenEntity.entityId);\r\n\tconst buffedEntities = pickMultipleRandomDifferent(newBoard, 5);\r\n\t// How to mark the minion as dead\r\n\tchosenEntity.definitelyDead = true;\r\n\tbuffedEntities.forEach((e) => {\r\n\t\tmodifyAttack(e, chosenEntity.attack, newBoard, allCards);\r\n\t\tmodifyHealth(e, chosenEntity.health, newBoard, allCards);\r\n\t\tafterStatsUpdate(e, newBoard, allCards);\r\n\t\tspectator.registerPowerTarget(chosenEntity, e, newBoard);\r\n\t});\r\n};\r\n\r\nconst handlePlayerStartOfCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tfriendly: boolean,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\tlet shouldRecomputeCurrentAttacker = false;\r\n\tconst playerHeroPowerId = playerEntity.heroPowerId || getHeroPowerForHero(playerEntity.cardId);\r\n\tif (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.TamsinRoame_FragrantPhylactery) {\r\n\t\thandleTamsinForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\t// Tamsin's hero power somehow happens before the current attacker is chosen.\r\n\t\t// See http://replays.firestoneapp.com/?reviewId=bce94e6b-c807-48e4-9c72-2c5c04421213&turn=6&action=9\r\n\t\tshouldRecomputeCurrentAttacker = true;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimLeftToken) {\r\n\t\tconst target = opponentBoard[0];\r\n\t\tconst damageDone = dealDamageToEnemy(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimRightToken) {\r\n\t\tconst target = opponentBoard[opponentBoard.length - 1];\r\n\t\tconst damageDone = dealDamageToEnemy(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimLowToken) {\r\n\t\tconst smallestHealthMinion = [...opponentBoard].sort((a, b) => a.health - b.health)[0];\r\n\t\tconst target = pickRandom(opponentBoard.filter((e) => e.health === smallestHealthMinion.health));\r\n\t\tconst damageDone = dealDamageToEnemy(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimHighToken) {\r\n\t\tconst highestHealthMinion = [...opponentBoard].sort((a, b) => b.health - a.health)[0];\r\n\t\tconst target = pickRandom(opponentBoard.filter((e) => e.health === highestHealthMinion.health));\r\n\t\tconst damageDone = dealDamageToEnemy(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.LightningInvocationToken) {\r\n\t\tapplyLightningInvocationEnchantment(\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tnull,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\tprocessMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\tif (shouldRecomputeCurrentAttacker) {\r\n\t\tcurrentAttacker = playerBoard.length > opponentBoard.length ? 0 : opponentBoard.length > playerBoard.length ? 1 : currentAttacker;\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\nexport const getHeroPowerForHero = (heroCardId: string): string => {\r\n\tswitch (heroCardId) {\r\n\t\tcase CardIds.IllidanStormrageBattlegrounds:\r\n\t\t\treturn CardIds.WingmenBattlegrounds;\r\n\t\tcase CardIds.TheLichKingBattlegrounds:\r\n\t\t\treturn CardIds.RebornRitesBattlegrounds;\r\n\t\tcase CardIds.ProfessorPutricideBattlegrounds:\r\n\t\t\treturn CardIds.RagePotionBattlegrounds;\r\n\t\tcase CardIds.DeathwingBattlegrounds:\r\n\t\t\treturn CardIds.AllWillBurnBattlegrounds;\r\n\t}\r\n\treturn null;\r\n};\r\n\r\nexport const performStartOfCombatMinionsForPlayer = (\r\n\tattacker: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\t// Apparently, the board composition used for start of combat minion effects (like Red Whelp, and I assume it works the\r\n\t// same way for others like Prized Promo Drake or Mantid Queen) is the one that is used before Illidan's effect is handled.\r\n\t// Since this also runs before HP start of combat, we probably also use the state as it was before HP were triggered, like\r\n\t// Tamsin's Phylactery.\r\n\tattackingBoardBefore: BoardEntity[],\r\n\tdefendingBoardBefore: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// Don't forget to update START_OF_COMBAT_CARD_IDS\r\n\tif (attacker.cardId === CardIds.RedWhelp) {\r\n\t\tconst damage = attackingBoardBefore\r\n\t\t\t.map((entity) => allCards.getCard(entity.cardId).races)\r\n\t\t\t.filter((races) => isCorrectTribe(races, Race.DRAGON)).length;\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tattacker,\r\n\t\t\tdamage,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tprocessMinionDeath(\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else if (attacker.cardId === CardIds.RedWhelpBattlegrounds) {\r\n\t\tconst damage = attackingBoardBefore\r\n\t\t\t.map((entity) => allCards.getCard(entity.cardId).races)\r\n\t\t\t.filter((races) => isCorrectTribe(races, Race.DRAGON)).length;\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tattacker,\r\n\t\t\tdamage,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tattacker,\r\n\t\t\tdamage,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tprocessMinionDeath(\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else if (attacker.cardId === CardIds.PrizedPromoDrake) {\r\n\t\tconst numberOfDragons = attackingBoardBefore\r\n\t\t\t.map((entity) => allCards.getCard(entity.cardId).races)\r\n\t\t\t.filter((races) => isCorrectTribe(races, Race.DRAGON)).length;\r\n\t\tconst neighbours = getNeighbours(attackingBoard, attacker);\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, numberOfDragons, attackingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, numberOfDragons, attackingBoard, allCards);\r\n\t\t\tafterStatsUpdate(entity, attackingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(attacker, entity, attackingBoard);\r\n\t\t});\r\n\t} else if (attacker.cardId === CardIds.PrizedPromoDrakeBattlegrounds) {\r\n\t\tconst dragons = attackingBoardBefore\r\n\t\t\t.map((entity) => allCards.getCard(entity.cardId).races)\r\n\t\t\t.filter((races) => isCorrectTribe(races, Race.DRAGON)).length;\r\n\t\tconst neighbours = getNeighbours(attackingBoard, attacker);\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 2 * dragons, attackingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 2 * dragons, attackingBoard, allCards);\r\n\t\t\tafterStatsUpdate(entity, attackingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(attacker, entity, attackingBoard);\r\n\t\t});\r\n\t} else if (attacker.cardId === CardIds.AmberGuardian || attacker.cardId === CardIds.AmberGuardianBattlegrounds) {\r\n\t\t// First try to get a target without divine shield, and if none is available, pick one with divine shield\r\n\t\tconst otherDragons = attackingBoard\r\n\t\t\t.filter((e) => hasCorrectTribe(e, Race.DRAGON, allCards))\r\n\t\t\t.filter((e) => e.entityId !== attacker.entityId);\r\n\t\tconst loops = attacker.cardId === CardIds.AmberGuardianBattlegrounds ? 2 : 1;\r\n\t\tfor (let i = 0; i < loops; i++) {\r\n\t\t\tconst dragonsToConsider = otherDragons;\r\n\t\t\tconst otherDragon = pickRandom(dragonsToConsider.filter((e) => !e.divineShield)) ?? pickRandom(dragonsToConsider);\r\n\t\t\tif (otherDragon) {\r\n\t\t\t\tif (!otherDragon.divineShield) {\r\n\t\t\t\t\tupdateDivineShield(otherDragon, attackingBoard, true, allCards);\r\n\t\t\t\t}\r\n\t\t\t\tmodifyAttack(otherDragon, 2, attackingBoard, allCards);\r\n\t\t\t\tmodifyHealth(otherDragon, 2, attackingBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(otherDragon, attackingBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(attacker, otherDragon, attackingBoard);\r\n\t\t\t\tdragonsToConsider.splice(dragonsToConsider.indexOf(otherDragon), 1);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (attacker.cardId === CardIds.Soulsplitter || attacker.cardId === CardIds.SoulsplitterBattlegrounds) {\r\n\t\tconst undeadsWithoutReborn = attackingBoard.filter((e) => hasCorrectTribe(e, Race.UNDEAD, allCards)).filter((e) => !e.reborn);\r\n\t\tconst chosenUndead = pickRandom(undeadsWithoutReborn);\r\n\t\tif (chosenUndead) {\r\n\t\t\tchosenUndead.reborn = true;\r\n\t\t\tspectator.registerPowerTarget(attacker, chosenUndead, attackingBoard);\r\n\t\t}\r\n\t} else if (attacker.cardId === CardIds.Crabby_BG22_HERO_000_Buddy || attacker.cardId === CardIds.CrabbyBattlegrounds) {\r\n\t\tconst neighbours = getNeighbours(attackingBoard, attacker);\r\n\t\tconst multiplier = attacker.cardId === CardIds.CrabbyBattlegrounds ? 2 : 1;\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, multiplier * (attackingBoardHero.deadEyeDamageDone ?? 0), attackingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, multiplier * (attackingBoardHero.deadEyeDamageDone ?? 0), attackingBoard, allCards);\r\n\t\t\tafterStatsUpdate(entity, attackingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(attacker, entity, attackingBoard);\r\n\t\t});\r\n\t} else if (attacker.cardId === CardIds.CorruptedMyrmidon || attacker.cardId === CardIds.CorruptedMyrmidonBattlegrounds) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.CorruptedMyrmidonBattlegrounds ? 2 : 1;\r\n\t\tmodifyAttack(attacker, multiplier * attacker.attack, attackingBoard, allCards);\r\n\t\tmodifyHealth(attacker, multiplier * attacker.health, attackingBoard, allCards);\r\n\t\tafterStatsUpdate(attacker, attackingBoard, allCards);\r\n\t\tspectator.registerPowerTarget(attacker, attacker, attackingBoard);\r\n\t} else if (attacker.cardId === CardIds.InterrogatorWhitemane_BG24_704 || attacker.cardId === CardIds.InterrogatorWhitemane_BG24_704_G) {\r\n\t\tif (defendingBoard.length > 0) {\r\n\t\t\tconst attackerIndex = attackingBoard.indexOf(attacker);\r\n\t\t\tconst defenderPosition = attackerIndex - (attackingBoard.length - defendingBoard.length) / 2;\r\n\t\t\tif (Math.round(defenderPosition) === defenderPosition) {\r\n\t\t\t\tcastImpure(defendingBoard[defenderPosition], attacker, attackingBoard, spectator);\r\n\t\t\t} else {\r\n\t\t\t\tcastImpure(defendingBoard[defenderPosition - 0.5], attacker, attackingBoard, spectator);\r\n\t\t\t\tcastImpure(defendingBoard[defenderPosition + 0.5], attacker, attackingBoard, spectator);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (attacker.cardId === CardIds.MantidQueen || attacker.cardId === CardIds.MantidQueenBattlegrounds) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.MantidQueenBattlegrounds ? 2 : 1;\r\n\t\tconst allRaces = attackingBoardBefore\r\n\t\t\t.map((entity) => entity.cardId)\r\n\t\t\t.flatMap((cardId) => allCards.getCard(cardId).races)\r\n\t\t\t.filter((race) => !!race && race !== Race[Race.BLANK]);\r\n\t\tconst totalRaces =\r\n\t\t\t[...new Set(allRaces.filter((race) => race !== Race[Race.ALL]))].length +\r\n\t\t\tallRaces.filter((race) => race === Race[Race.ALL]).length;\r\n\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\tfor (let j = 0; j < totalRaces; j++) {\r\n\t\t\t\tconst buffType = getRandomMantidQueenBuffType(attacker);\r\n\t\t\t\tswitch (buffType) {\r\n\t\t\t\t\tcase 'stats':\r\n\t\t\t\t\t\tmodifyAttack(attacker, 5, attackingBoard, allCards);\r\n\t\t\t\t\t\tmodifyHealth(attacker, 5, attackingBoard, allCards);\r\n\t\t\t\t\t\tafterStatsUpdate(attacker, attackingBoard, allCards);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'divine-shield':\r\n\t\t\t\t\t\tif (!attacker.divineShield) {\r\n\t\t\t\t\t\t\tupdateDivineShield(attacker, attackingBoard, true, allCards);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'taunt':\r\n\t\t\t\t\t\tattacker.taunt = true;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'windfury':\r\n\t\t\t\t\t\tattacker.windfury = true;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tspectator.registerPowerTarget(attacker, attacker, attackingBoard);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst castImpure = (entity: BoardEntity, source: BoardEntity, board: BoardEntity[], spectator: Spectator) => {\r\n\tif (!entity) {\r\n\t\treturn;\r\n\t}\r\n\tconst multiplier = source.cardId === CardIds.InterrogatorWhitemane_BG24_704_G ? 3 : 2;\r\n\tentity.taunt = true;\r\n\tentity.damageMultiplier = entity.damageMultiplier ?? 1;\r\n\tentity.damageMultiplier *= multiplier;\r\n\tspectator.registerPowerTarget(source, entity, board);\r\n};\r\n\r\nconst getRandomMantidQueenBuffType = (entity: BoardEntity): 'stats' | 'divine-shield' | 'windfury' | 'taunt' => {\r\n\tconst possibilities: ('stats' | 'divine-shield' | 'windfury' | 'taunt')[] = ['stats'];\r\n\tif (!entity.divineShield) {\r\n\t\tpossibilities.push('divine-shield');\r\n\t}\r\n\tif (!entity.windfury) {\r\n\t\tpossibilities.push('windfury');\r\n\t}\r\n\tif (!entity.taunt) {\r\n\t\tpossibilities.push('taunt');\r\n\t}\r\n\treturn pickRandom(possibilities);\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"start-of-combat.js","sourceRoot":"","sources":["../../src/simulation/start-of-combat.ts"],"names":[],"mappings":";;;AACA,iEAA8E;AAI9E,oDAA0E;AAC1E,6CAA4E;AAC5E,oCASkB;AAClB,qCAOkB;AAClB,+DAK+B;AAC/B,6DAAqD;AAI9C,MAAM,mBAAmB,GAAG,CAClC,YAA6B,EAC7B,WAA0B,EAC1B,cAA+B,EAC/B,aAA4B,EAC5B,eAAuB,EACvB,QAAyB,EACzB,MAAiB,EACjB,WAAwB,EACxB,SAAuB,EACvB,SAAoB,EACX,EAAE;IAEX,eAAe,GAAG,+BAA+B,CAChD,YAAY,EACZ,WAAW,EACX,cAAc,EACd,aAAa,EACb,eAAe,EACf,QAAQ,EACR,MAAM,EACN,WAAW,EACX,SAAS,EACT,SAAS,CACT,CAAC;IAKF,eAAe,GAAG,yBAAyB,CAC1C,YAAY,EACZ,WAAW,EACX,cAAc,EACd,aAAa,EACb,eAAe,EACf,QAAQ,EACR,MAAM,EACN,WAAW,EACX,SAAS,EACT,SAAS,CACT,CAAC;IAEF,MAAM,iBAAiB,GAAG,WAA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,MAAM,UAAU,GAAG,CAAC,MAAmB,EAAE,MAAmB,EAAE,KAAoB,EAAE,SAAoB,EAAE,EAAE;;IAC3G,IAAI,CAAC,MAAM,EAAE;QACZ,OAAO;KACP;IACD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,iBAA6C,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtF,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,CAAC,gBAAgB,SAAG,MAAM,CAAC,gBAAgB,mCAAI,CAAC,CAAC;IACvD,MAAM,CAAC,gBAAgB,IAAI,UAAU,CAAC;IACtC,SAAS,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AACtD,CAAC,CAAC;AAEF,MAAM,4BAA4B,GAAG,CAAC,MAAmB,EAAoD,EAAE;IAC9G,MAAM,aAAa,GAAyD,CAAC,OAAO,CAAC,CAAC;IACtF,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE;QACzB,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;KACpC;IACD,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;QACrB,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;KAC/B;IACD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;QAClB,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KAC5B;IACD,OAAO,kBAAU,CAAC,aAAa,CAAC,CAAC;AAClC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsGameState } from '../bgs-battle-info';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardsData, START_OF_COMBAT_CARD_IDS } from '../cards/cards-data';\r\nimport { pickMultipleRandomDifferent, pickRandom } from '../services/utils';\r\nimport {\r\n\tafterStatsUpdate,\r\n\thasCorrectTribe,\r\n\tisCorrectTribe,\r\n\tmakeMinionGolden,\r\n\tmodifyAttack,\r\n\tmodifyHealth,\r\n\tstringifySimple,\r\n\tupdateDivineShield,\r\n} from '../utils';\r\nimport {\r\n\tdealDamageToEnemy,\r\n\tdealDamageToRandomEnemy,\r\n\tgetNeighbours,\r\n\tperformEntitySpawns,\r\n\tprocessMinionDeath,\r\n\tsimulateAttack,\r\n} from './attack';\r\nimport {\r\n\tapplyEarthInvocationEnchantment,\r\n\tapplyFireInvocationEnchantment,\r\n\tapplyLightningInvocationEnchantment,\r\n\tapplyWaterInvocationEnchantment,\r\n} from './deathrattle-effects';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { SharedState } from './shared-state';\r\nimport { Spectator } from './spectator/spectator';\r\n\r\nexport const handleStartOfCombat = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// https://twitter.com/DCalkosz/status/1564705111850434561\r\n\tcurrentAttacker = handleStartOfCombatQuestRewards(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\t// https://twitter.com/DCalkosz/status/1488361384320528388?s=20&t=1ECxRZFdjqwEa2fRsXk32Q\r\n\t// There’s a certain order for Start of Combat hero powers, rather than “coin flips” where\r\n\t// an unlucky trigger order could mess up some positioning you had planned for your own hero\r\n\t// power. “Precombat” (Al’Akir, Y’Shaarj), then Illidan, then others.\r\n\tcurrentAttacker = handlePreCombatHeroPowers(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\t// Because start of combat powers like Red Whelp's use the board composition before Illidan's strike to know the amount of damage\r\n\tconst playerBoardBefore = playerBoard.map((e) => ({ ...e }));\r\n\tconst opponentBoardBefore = opponentBoard.map((e) => ({ ...e }));\r\n\tcurrentAttacker = handleIllidanHeroPowers(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\tcurrentAttacker = handleStartOfCombatHeroPowers(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\tcurrentAttacker = handleStartOfCombatMinions(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tplayerBoardBefore,\r\n\t\topponentBoardBefore,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePreCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\tcurrentAttacker = handlePreCombatHeroPowersForPlayer(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\tcurrentAttacker = handlePreCombatHeroPowersForPlayer(\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePreCombatHeroPowersForPlayer = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// Some are part of the incoming board: Y'Shaarj, Lich King, Ozumat\r\n\t// Since the order is not important here, we just always do the player first\r\n\tconst playerHeroPowerId = playerEntity.heroPowerId || getHeroPowerForHero(playerEntity.cardId);\r\n\tif (playerHeroPowerId === CardIds.SwattingInsectsBattlegrounds && playerBoard.length > 0) {\r\n\t\t// Should be sent by the app, but it is an idempotent operation, so we can just reapply it here\r\n\t\thandleAlakirForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, spawns, sharedState, spectator);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.EarthInvocationToken) {\r\n\t\tapplyEarthInvocationEnchantment(playerBoard, null, playerEntity, allCards, sharedState, spectator);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.WaterInvocationToken) {\r\n\t\tapplyWaterInvocationEnchantment(playerBoard, null, playerEntity, allCards, spectator);\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.FireInvocationToken) {\r\n\t\tapplyFireInvocationEnchantment(playerBoard, null, playerEntity, allCards, spectator);\r\n\t}\r\n\r\n\treturn currentAttacker;\r\n};\r\n\r\nexport const handleIllidanHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// console.log('current attacker before', currentAttacker);\r\n\t// Apparently it's a toin coss about whether to handle Illidan first or Al'Akir first\r\n\t// Auras are only relevant for Illidan, and already applied there\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else {\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerIllidanHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\tprocessMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t// console.log('current attacker after', currentAttacker);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatMinions = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tplayerBoardBefore: BoardEntity[],\r\n\topponentBoardBefore: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\tlet attackerForStart = currentAttacker;\r\n\tconst playerAttackers = playerBoard.filter((entity) => START_OF_COMBAT_CARD_IDS.includes(entity.cardId as CardIds));\r\n\tconst opponentAttackers = opponentBoard.filter((entity) => START_OF_COMBAT_CARD_IDS.includes(entity.cardId as CardIds));\r\n\twhile (playerAttackers.length > 0 || opponentAttackers.length > 0) {\r\n\t\tif (attackerForStart === 0 && playerAttackers.length > 0) {\r\n\t\t\tconst attacker = playerAttackers.splice(0, 1)[0];\r\n\t\t\tperformStartOfCombatMinionsForPlayer(\r\n\t\t\t\tattacker,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tplayerBoardBefore,\r\n\t\t\t\topponentBoardBefore,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspawns,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tgameState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t} else if (attackerForStart === 1 && opponentAttackers.length > 0) {\r\n\t\t\tconst attacker = opponentAttackers.splice(0, 1)[0];\r\n\t\t\tperformStartOfCombatMinionsForPlayer(\r\n\t\t\t\tattacker,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentEntity,\r\n\t\t\t\tplayerBoard,\r\n\t\t\t\tplayerEntity,\r\n\t\t\t\topponentBoardBefore,\r\n\t\t\t\tplayerBoardBefore,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspawns,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tgameState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t\tattackerForStart = (attackerForStart + 1) % 2;\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatQuestRewards = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\tcurrentAttacker = handleStartOfCombatQuestRewardsForPlayer(\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\tcurrentAttacker = handleStartOfCombatQuestRewardsForPlayer(\r\n\t\topponentEntity,\r\n\t\topponentBoard,\r\n\t\tplayerEntity,\r\n\t\tplayerBoard,\r\n\t\tcurrentAttacker,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tgameState,\r\n\t\tspectator,\r\n\t);\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handleStartOfCombatQuestRewardsForPlayer = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\tif (!playerEntity.questRewards?.length) {\r\n\t\treturn currentAttacker;\r\n\t}\r\n\tfor (const reward of playerEntity.questRewards) {\r\n\t\tswitch (reward) {\r\n\t\t\tcase CardIds.EvilTwin:\r\n\t\t\t\tif (!!playerBoard.length && playerBoard.length < 7) {\r\n\t\t\t\t\tconst highestHealthMinion = [...playerBoard].sort((a, b) => b.health - a.health)[0];\r\n\t\t\t\t\tconst copy: BoardEntity = {\r\n\t\t\t\t\t\t...highestHealthMinion,\r\n\t\t\t\t\t\tlastAffectedByEntity: null,\r\n\t\t\t\t\t};\r\n\t\t\t\t\tconst newMinions = spawnEntities(\r\n\t\t\t\t\t\tcopy.cardId,\r\n\t\t\t\t\t\t1,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tspawns,\r\n\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t\thighestHealthMinion.friendly,\r\n\t\t\t\t\t\ttrue,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\tcopy,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tconst indexFromRight = playerBoard.length - (playerBoard.indexOf(highestHealthMinion) + 1);\r\n\t\t\t\t\tperformEntitySpawns(\r\n\t\t\t\t\t\tnewMinions,\r\n\t\t\t\t\t\tplayerBoard,\r\n\t\t\t\t\t\tplayerEntity,\r\n\t\t\t\t\t\thighestHealthMinion,\r\n\t\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\t\topponentBoard,\r\n\t\t\t\t\t\topponentEntity,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tspawns,\r\n\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t);\r\n\t\t\t\t\tspectator.registerPowerTarget(playerEntity, copy, playerBoard);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.StaffOfOrigination_BG24_Reward_312:\r\n\t\t\t\tplayerBoard.forEach((entity) => {\r\n\t\t\t\t\tmodifyAttack(entity, 15, playerBoard, allCards);\r\n\t\t\t\t\tmodifyHealth(entity, 15, playerBoard, allCards);\r\n\t\t\t\t\tafterStatsUpdate(entity, playerBoard, allCards);\r\n\t\t\t\t\tspectator.registerPowerTarget(playerEntity, entity, playerBoard);\r\n\t\t\t\t});\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.StolenGold:\r\n\t\t\t\tif (playerBoard.length > 0) {\r\n\t\t\t\t\tmakeMinionGolden(playerBoard[0], playerEntity, playerBoard, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t\tif (playerBoard.length > 1) {\r\n\t\t\t\t\tmakeMinionGolden(playerBoard[playerBoard.length - 1], playerEntity, playerBoard, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\treturn currentAttacker;\r\n};\r\n\r\nexport const handleStartOfCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// Apparently it's a toin coss about whether to handle Illidan first or Al'Akir first\r\n\t// Auras are only relevant for Illidan, and already applied there\r\n\tif (Math.random() < 0.5) {\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else {\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\tfalse,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tcurrentAttacker = handlePlayerStartOfCombatHeroPowers(\r\n\t\t\tplayerEntity,\r\n\t\t\tplayerBoard,\r\n\t\t\topponentEntity,\r\n\t\t\topponentBoard,\r\n\t\t\tcurrentAttacker,\r\n\t\t\ttrue,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\nconst handlePlayerIllidanHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tfriendly: boolean,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\tconst playerHeroPowerId = playerEntity.heroPowerId || getHeroPowerForHero(playerEntity.cardId);\r\n\tif (playerHeroPowerId === CardIds.WingmenBattlegrounds && playerBoard.length > 0) {\r\n\t\thandleIllidanForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, spawns, sharedState, spectator);\r\n\t\tcurrentAttacker = (currentAttacker + 1) % 2;\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\n// TODO: not exactly correct, because of \"attack immediately\", but it's close enough\r\nconst handleIllidanForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// Otherwise, if the first minion dies on the attack, and the board has only 2 minions, we\r\n\t// miss the second one\r\n\tconst minionsAtStart = playerBoard.length;\r\n\tconst firstAttacker = playerBoard[0];\r\n\tconst secondAttacker = minionsAtStart > 1 ? playerBoard[playerBoard.length - 1] : null;\r\n\r\n\tmodifyAttack(firstAttacker, 2, playerBoard, allCards);\r\n\tafterStatsUpdate(firstAttacker, playerBoard, allCards);\r\n\tspectator.registerPowerTarget(firstAttacker, firstAttacker, playerBoard);\r\n\tif (\r\n\t\tplayerBoard.map((e) => e.cardId).includes(CardIds.EclipsionIllidariBattlegrounds_TB_BaconShop_HERO_08_Buddy) ||\r\n\t\tplayerBoard.map((e) => e.cardId).includes(CardIds.EclipsionIllidariBattlegrounds_TB_BaconShop_HERO_08_Buddy_G)\r\n\t) {\r\n\t\tfirstAttacker.immuneWhenAttackCharges = 1;\r\n\t}\r\n\tsimulateAttack(playerBoard, playerEntity, opponentBoard, opponentEntity, undefined, allCards, spawns, sharedState, spectator, 0);\r\n\r\n\tif (!!secondAttacker && !secondAttacker.definitelyDead && secondAttacker.health > 0) {\r\n\t\tmodifyAttack(secondAttacker, 2, playerBoard, allCards);\r\n\t\tafterStatsUpdate(secondAttacker, playerBoard, allCards);\r\n\t\tspectator.registerPowerTarget(secondAttacker, secondAttacker, playerBoard);\r\n\t\tif (playerBoard.map((e) => e.cardId).includes(CardIds.EclipsionIllidariBattlegrounds_TB_BaconShop_HERO_08_Buddy_G)) {\r\n\t\t\tsecondAttacker.immuneWhenAttackCharges = 1;\r\n\t\t}\r\n\t\tsimulateAttack(\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tundefined,\r\n\t\t\tallCards,\r\n\t\t\tspawns,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tplayerBoard.length - 1,\r\n\t\t);\r\n\t}\r\n};\r\n\r\nconst handleAlakirForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst firstEntity = playerBoard[0];\r\n\tfirstEntity.windfury = true;\r\n\tif (!firstEntity.divineShield) {\r\n\t\tupdateDivineShield(firstEntity, playerBoard, true, allCards);\r\n\t}\r\n\tfirstEntity.taunt = true;\r\n\tspectator.registerPowerTarget(firstEntity, firstEntity, playerBoard);\r\n};\r\n\r\nconst handleTamsinForPlayer = (\r\n\tplayerBoard: BoardEntity[],\r\n\tplayerEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst lowestHealth = Math.min(...playerBoard.map((e) => e.health));\r\n\tconst entitiesWithLowestHealth = playerBoard.filter((e) => e.health === lowestHealth);\r\n\tconst chosenEntity = pickRandom(entitiesWithLowestHealth);\r\n\tif (!chosenEntity) {\r\n\t\tconsole.warn('could not pick any entity for tamsin', stringifySimple(entitiesWithLowestHealth, allCards));\r\n\t\treturn;\r\n\t}\r\n\tconst newBoard = playerBoard.filter((e) => e.entityId !== chosenEntity.entityId);\r\n\tconst buffedEntities = pickMultipleRandomDifferent(newBoard, 5);\r\n\t// How to mark the minion as dead\r\n\tchosenEntity.definitelyDead = true;\r\n\tbuffedEntities.forEach((e) => {\r\n\t\tmodifyAttack(e, chosenEntity.attack, newBoard, allCards);\r\n\t\tmodifyHealth(e, chosenEntity.health, newBoard, allCards);\r\n\t\tafterStatsUpdate(e, newBoard, allCards);\r\n\t\tspectator.registerPowerTarget(chosenEntity, e, newBoard);\r\n\t});\r\n};\r\n\r\nconst handlePlayerStartOfCombatHeroPowers = (\r\n\tplayerEntity: BgsPlayerEntity,\r\n\tplayerBoard: BoardEntity[],\r\n\topponentEntity: BgsPlayerEntity,\r\n\topponentBoard: BoardEntity[],\r\n\tcurrentAttacker: number,\r\n\tfriendly: boolean,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\tlet shouldRecomputeCurrentAttacker = false;\r\n\tconst playerHeroPowerId = playerEntity.heroPowerId || getHeroPowerForHero(playerEntity.cardId);\r\n\tif (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.TamsinRoame_FragrantPhylactery) {\r\n\t\thandleTamsinForPlayer(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\t// Tamsin's hero power somehow happens before the current attacker is chosen.\r\n\t\t// See http://replays.firestoneapp.com/?reviewId=bce94e6b-c807-48e4-9c72-2c5c04421213&turn=6&action=9\r\n\t\tshouldRecomputeCurrentAttacker = true;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimLeftToken) {\r\n\t\tconst target = opponentBoard[0];\r\n\t\tconst damageDone = dealDamageToEnemy(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimRightToken) {\r\n\t\tconst target = opponentBoard[opponentBoard.length - 1];\r\n\t\tconst damageDone = dealDamageToEnemy(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimLowToken) {\r\n\t\tconst smallestHealthMinion = [...opponentBoard].sort((a, b) => a.health - b.health)[0];\r\n\t\tconst target = pickRandom(opponentBoard.filter((e) => e.health === smallestHealthMinion.health));\r\n\t\tconst damageDone = dealDamageToEnemy(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.AimHighToken) {\r\n\t\tconst highestHealthMinion = [...opponentBoard].sort((a, b) => b.health - a.health)[0];\r\n\t\tconst target = pickRandom(opponentBoard.filter((e) => e.health === highestHealthMinion.health));\r\n\t\tconst damageDone = dealDamageToEnemy(\r\n\t\t\ttarget,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tnull,\r\n\t\t\tplayerEntity.heroPowerInfo ?? 0,\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// processMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\t\tplayerEntity.deadEyeDamageDone = damageDone;\r\n\t} else if (playerEntity.heroPowerUsed && playerHeroPowerId === CardIds.LightningInvocationToken) {\r\n\t\tapplyLightningInvocationEnchantment(\r\n\t\t\tplayerBoard,\r\n\t\t\tplayerEntity,\r\n\t\t\tnull,\r\n\t\t\topponentBoard,\r\n\t\t\topponentEntity,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\tprocessMinionDeath(playerBoard, playerEntity, opponentBoard, opponentEntity, allCards, cardsData, sharedState, spectator);\r\n\tif (shouldRecomputeCurrentAttacker) {\r\n\t\tcurrentAttacker = playerBoard.length > opponentBoard.length ? 0 : opponentBoard.length > playerBoard.length ? 1 : currentAttacker;\r\n\t}\r\n\treturn currentAttacker;\r\n};\r\n\r\nexport const getHeroPowerForHero = (heroCardId: string): string => {\r\n\tswitch (heroCardId) {\r\n\t\tcase CardIds.IllidanStormrageBattlegrounds:\r\n\t\t\treturn CardIds.WingmenBattlegrounds;\r\n\t\tcase CardIds.TheLichKingBattlegrounds:\r\n\t\t\treturn CardIds.RebornRitesBattlegrounds;\r\n\t\tcase CardIds.ProfessorPutricideBattlegrounds:\r\n\t\t\treturn CardIds.RagePotionBattlegrounds;\r\n\t\tcase CardIds.DeathwingBattlegrounds:\r\n\t\t\treturn CardIds.AllWillBurnBattlegrounds;\r\n\t}\r\n\treturn null;\r\n};\r\n\r\nexport const performStartOfCombatMinionsForPlayer = (\r\n\tattacker: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\t// Apparently, the board composition used for start of combat minion effects (like Red Whelp, and I assume it works the\r\n\t// same way for others like Prized Promo Drake or Mantid Queen) is the one that is used before Illidan's effect is handled.\r\n\t// Since this also runs before HP start of combat, we probably also use the state as it was before HP were triggered, like\r\n\t// Tamsin's Phylactery.\r\n\tattackingBoardBefore: BoardEntity[],\r\n\tdefendingBoardBefore: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tgameState: BgsGameState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// Don't forget to update START_OF_COMBAT_CARD_IDS\r\n\tif (attacker.cardId === CardIds.RedWhelp) {\r\n\t\tconst damage = attackingBoardBefore\r\n\t\t\t.map((entity) => allCards.getCard(entity.cardId).races)\r\n\t\t\t.filter((races) => isCorrectTribe(races, Race.DRAGON)).length;\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tattacker,\r\n\t\t\tdamage,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tprocessMinionDeath(\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else if (attacker.cardId === CardIds.RedWhelpBattlegrounds) {\r\n\t\tconst damage = attackingBoardBefore\r\n\t\t\t.map((entity) => allCards.getCard(entity.cardId).races)\r\n\t\t\t.filter((races) => isCorrectTribe(races, Race.DRAGON)).length;\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tattacker,\r\n\t\t\tdamage,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tdealDamageToRandomEnemy(\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tattacker,\r\n\t\t\tdamage,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\tprocessMinionDeath(\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else if (attacker.cardId === CardIds.PrizedPromoDrake) {\r\n\t\tconst numberOfDragons = attackingBoardBefore\r\n\t\t\t.map((entity) => allCards.getCard(entity.cardId).races)\r\n\t\t\t.filter((races) => isCorrectTribe(races, Race.DRAGON)).length;\r\n\t\tconst neighbours = getNeighbours(attackingBoard, attacker);\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, numberOfDragons, attackingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, numberOfDragons, attackingBoard, allCards);\r\n\t\t\tafterStatsUpdate(entity, attackingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(attacker, entity, attackingBoard);\r\n\t\t});\r\n\t} else if (attacker.cardId === CardIds.PrizedPromoDrakeBattlegrounds) {\r\n\t\tconst dragons = attackingBoardBefore\r\n\t\t\t.map((entity) => allCards.getCard(entity.cardId).races)\r\n\t\t\t.filter((races) => isCorrectTribe(races, Race.DRAGON)).length;\r\n\t\tconst neighbours = getNeighbours(attackingBoard, attacker);\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 2 * dragons, attackingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 2 * dragons, attackingBoard, allCards);\r\n\t\t\tafterStatsUpdate(entity, attackingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(attacker, entity, attackingBoard);\r\n\t\t});\r\n\t} else if (attacker.cardId === CardIds.AmberGuardian || attacker.cardId === CardIds.AmberGuardianBattlegrounds) {\r\n\t\t// First try to get a target without divine shield, and if none is available, pick one with divine shield\r\n\t\tconst otherDragons = attackingBoard\r\n\t\t\t.filter((e) => hasCorrectTribe(e, Race.DRAGON, allCards))\r\n\t\t\t.filter((e) => e.entityId !== attacker.entityId);\r\n\t\tconst loops = attacker.cardId === CardIds.AmberGuardianBattlegrounds ? 2 : 1;\r\n\t\tfor (let i = 0; i < loops; i++) {\r\n\t\t\tconst dragonsToConsider = otherDragons;\r\n\t\t\tconst otherDragon = pickRandom(dragonsToConsider.filter((e) => !e.divineShield)) ?? pickRandom(dragonsToConsider);\r\n\t\t\tif (otherDragon) {\r\n\t\t\t\tif (!otherDragon.divineShield) {\r\n\t\t\t\t\tupdateDivineShield(otherDragon, attackingBoard, true, allCards);\r\n\t\t\t\t}\r\n\t\t\t\tmodifyAttack(otherDragon, 2, attackingBoard, allCards);\r\n\t\t\t\tmodifyHealth(otherDragon, 2, attackingBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(otherDragon, attackingBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(attacker, otherDragon, attackingBoard);\r\n\t\t\t\tdragonsToConsider.splice(dragonsToConsider.indexOf(otherDragon), 1);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (attacker.cardId === CardIds.Soulsplitter || attacker.cardId === CardIds.SoulsplitterBattlegrounds) {\r\n\t\tconst numberOfTargets = attacker.cardId === CardIds.SoulsplitterBattlegrounds ? 2 : 1;\r\n\t\tfor (let i = 0; i < numberOfTargets; i++) {\r\n\t\t\tconst undeadsWithoutReborn = attackingBoard.filter((e) => hasCorrectTribe(e, Race.UNDEAD, allCards)).filter((e) => !e.reborn);\r\n\t\t\tconst chosenUndead = pickRandom(undeadsWithoutReborn);\r\n\t\t\tif (chosenUndead) {\r\n\t\t\t\tchosenUndead.reborn = true;\r\n\t\t\t\tspectator.registerPowerTarget(attacker, chosenUndead, attackingBoard);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (attacker.cardId === CardIds.Crabby_BG22_HERO_000_Buddy || attacker.cardId === CardIds.CrabbyBattlegrounds) {\r\n\t\tconst neighbours = getNeighbours(attackingBoard, attacker);\r\n\t\tconst multiplier = attacker.cardId === CardIds.CrabbyBattlegrounds ? 2 : 1;\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, multiplier * (attackingBoardHero.deadEyeDamageDone ?? 0), attackingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, multiplier * (attackingBoardHero.deadEyeDamageDone ?? 0), attackingBoard, allCards);\r\n\t\t\tafterStatsUpdate(entity, attackingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(attacker, entity, attackingBoard);\r\n\t\t});\r\n\t} else if (attacker.cardId === CardIds.CorruptedMyrmidon || attacker.cardId === CardIds.CorruptedMyrmidonBattlegrounds) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.CorruptedMyrmidonBattlegrounds ? 2 : 1;\r\n\t\tmodifyAttack(attacker, multiplier * attacker.attack, attackingBoard, allCards);\r\n\t\tmodifyHealth(attacker, multiplier * attacker.health, attackingBoard, allCards);\r\n\t\tafterStatsUpdate(attacker, attackingBoard, allCards);\r\n\t\tspectator.registerPowerTarget(attacker, attacker, attackingBoard);\r\n\t} else if (attacker.cardId === CardIds.InterrogatorWhitemane_BG24_704 || attacker.cardId === CardIds.InterrogatorWhitemane_BG24_704_G) {\r\n\t\tif (defendingBoard.length > 0) {\r\n\t\t\tconst attackerIndex = attackingBoard.indexOf(attacker);\r\n\t\t\tconst defenderPosition = attackerIndex - (attackingBoard.length - defendingBoard.length) / 2;\r\n\t\t\tif (Math.round(defenderPosition) === defenderPosition) {\r\n\t\t\t\tcastImpure(defendingBoard[defenderPosition], attacker, attackingBoard, spectator);\r\n\t\t\t} else {\r\n\t\t\t\tcastImpure(defendingBoard[defenderPosition - 0.5], attacker, attackingBoard, spectator);\r\n\t\t\t\tcastImpure(defendingBoard[defenderPosition + 0.5], attacker, attackingBoard, spectator);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (attacker.cardId === CardIds.MantidQueen || attacker.cardId === CardIds.MantidQueenBattlegrounds) {\r\n\t\tconst multiplier = attacker.cardId === CardIds.MantidQueenBattlegrounds ? 2 : 1;\r\n\t\tconst allRaces = attackingBoardBefore\r\n\t\t\t.map((entity) => entity.cardId)\r\n\t\t\t.flatMap((cardId) => allCards.getCard(cardId).races)\r\n\t\t\t.filter((race) => !!race && race !== Race[Race.BLANK]);\r\n\t\tconst totalRaces =\r\n\t\t\t[...new Set(allRaces.filter((race) => race !== Race[Race.ALL]))].length +\r\n\t\t\tallRaces.filter((race) => race === Race[Race.ALL]).length;\r\n\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\tfor (let j = 0; j < totalRaces; j++) {\r\n\t\t\t\tconst buffType = getRandomMantidQueenBuffType(attacker);\r\n\t\t\t\tswitch (buffType) {\r\n\t\t\t\t\tcase 'stats':\r\n\t\t\t\t\t\tmodifyAttack(attacker, 5, attackingBoard, allCards);\r\n\t\t\t\t\t\tmodifyHealth(attacker, 5, attackingBoard, allCards);\r\n\t\t\t\t\t\tafterStatsUpdate(attacker, attackingBoard, allCards);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'divine-shield':\r\n\t\t\t\t\t\tif (!attacker.divineShield) {\r\n\t\t\t\t\t\t\tupdateDivineShield(attacker, attackingBoard, true, allCards);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'taunt':\r\n\t\t\t\t\t\tattacker.taunt = true;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'windfury':\r\n\t\t\t\t\t\tattacker.windfury = true;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tspectator.registerPowerTarget(attacker, attacker, attackingBoard);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst castImpure = (entity: BoardEntity, source: BoardEntity, board: BoardEntity[], spectator: Spectator) => {\r\n\tif (!entity) {\r\n\t\treturn;\r\n\t}\r\n\tconst multiplier = source.cardId === CardIds.InterrogatorWhitemane_BG24_704_G ? 3 : 2;\r\n\tentity.taunt = true;\r\n\tentity.damageMultiplier = entity.damageMultiplier ?? 1;\r\n\tentity.damageMultiplier *= multiplier;\r\n\tspectator.registerPowerTarget(source, entity, board);\r\n};\r\n\r\nconst getRandomMantidQueenBuffType = (entity: BoardEntity): 'stats' | 'divine-shield' | 'windfury' | 'taunt' => {\r\n\tconst possibilities: ('stats' | 'divine-shield' | 'windfury' | 'taunt')[] = ['stats'];\r\n\tif (!entity.divineShield) {\r\n\t\tpossibilities.push('divine-shield');\r\n\t}\r\n\tif (!entity.windfury) {\r\n\t\tpossibilities.push('windfury');\r\n\t}\r\n\tif (!entity.taunt) {\r\n\t\tpossibilities.push('taunt');\r\n\t}\r\n\treturn pickRandom(possibilities);\r\n};\r\n"]}
|
package/dist/utils.js
CHANGED
|
@@ -382,7 +382,9 @@ const stringifySimple = (board, allCards = null) => {
|
|
|
382
382
|
exports.stringifySimple = stringifySimple;
|
|
383
383
|
const stringifySimpleCard = (entity, allCards = null) => {
|
|
384
384
|
var _a, _b;
|
|
385
|
-
return entity
|
|
385
|
+
return entity
|
|
386
|
+
? `${entity.cardId}/${(_b = (_a = allCards === null || allCards === void 0 ? void 0 : allCards.getCard(entity.cardId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : ''}/atk=${entity.attack}/hp=${entity.health}/ench=${entity.enchantments}`
|
|
387
|
+
: null;
|
|
386
388
|
};
|
|
387
389
|
exports.stringifySimpleCard = stringifySimpleCard;
|
|
388
390
|
const isFish = (entity) => {
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AACA,iEAAoH;AAOpH,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,E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,QAAQ,uBAAR,QAAQ,CAAE,OAAO,CAAC,MAAM,CAAC,MAAM,2CAAG,IAAI,mCAAI,EAAE,QAAQ,MAAM,CAAC,MAAM,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AACrI,CAAC,CAAC;AAFW,QAAA,mBAAmB,uBAE9B;AAEK,MAAM,MAAM,GAAG,CAAC,MAAmB,EAAW,EAAE;;IACtD,OAAO,CACN,MAAM,CAAC,MAAM,CAAC,UAAU,wBAAqD;QAC7E,MAAM,CAAC,MAAM,CAAC,UAAU,mBAAkC,WAC1D,MAAM,CAAC,eAAe,0CAAE,QAAQ,eAAoC,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 { AllCardsService, ALL_BG_RACES, 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 { 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.SilverbackPatriarch_BG_CS2_127_G,\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.Bonker_BG20_104_G,\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\tsharedState: SharedState,\r\n\tentityToSpawn: BoardEntity,\r\n\toriginalEntity: BoardEntity = null,\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 = !!entityToSpawn\r\n\t\t? { ...entityToSpawn, entityId: sharedState.currentEntityId++ }\r\n\t\t: addImpliedMechanics({\r\n\t\t\t\tentityId: entityId,\r\n\t\t\t\tattack: card.attack,\r\n\t\t\t\tattacksPerformed: 0,\r\n\t\t\t\tcardId: cardId,\r\n\t\t\t\tdivineShield: hasMechanic(card, 'DIVINE_SHIELD'),\r\n\t\t\t\thealth: card.health,\r\n\t\t\t\tmaxHealth: card.health,\r\n\t\t\t\ttaunt: hasMechanic(card, 'TAUNT') || TAUNT_IDS.includes(cardId as CardIds),\r\n\t\t\t\treborn: hasMechanic(card, 'REBORN'),\r\n\t\t\t\tpoisonous: hasMechanic(card, 'POISONOUS'),\r\n\t\t\t\twindfury: !megaWindfury && (hasMechanic(card, 'WINDFURY') || card.referencedTags?.includes('WINDFURY')),\r\n\t\t\t\tmegaWindfury: megaWindfury,\r\n\t\t\t\tenchantments: [],\r\n\t\t\t\tfriendly: friendly,\r\n\t\t\t\tattackImmediately: attackImmediately,\r\n\t\t\t\tavengeCurrent: cardsData.avengeValue(cardId),\r\n\t\t\t\tavengeDefault: cardsData.avengeValue(cardId),\r\n\t\t } as BoardEntity);\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 =\r\n\t\t\t\t\tnewEntity.taunt || hasMechanic(stitchedCard, GameTag[GameTag.TAUNT]) || TAUNT_IDS.includes(stitchedCardId as CardIds);\r\n\t\t\t\tnewEntity.divineShield = newEntity.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.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\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).races, 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 (\r\n\t\tentity.cardId === CardIds.Menagerist_AmalgamTokenBattlegrounds ||\r\n\t\tentity.cardId === CardIds.CuddlgamBattlegrounds_TB_BaconShop_HP_033t_SKIN_A ||\r\n\t\tentity.cardId === CardIds.CuddlgamBattlegrounds_TB_BaconShop_HP_033t_SKIN_A_G ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgamBattlegrounds_TB_BaconShop_HP_033t_SKIN_D ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgamBattlegrounds_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.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 (\r\n\t\tentity.cardId === CardIds.Menagerist_AmalgamTokenBattlegrounds ||\r\n\t\tentity.cardId === CardIds.CuddlgamBattlegrounds_TB_BaconShop_HP_033t_SKIN_A ||\r\n\t\tentity.cardId === CardIds.CuddlgamBattlegrounds_TB_BaconShop_HP_033t_SKIN_A_G ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgamBattlegrounds_TB_BaconShop_HP_033t_SKIN_D ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgamBattlegrounds_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.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\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\tconst newCardsInHand = Math.min(10, (playerEntity.cardsInHand ?? 0) + multiplier * cards);\r\n\tif (newCardsInHand <= playerEntity.cardsInHand) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tplayerEntity.cardsInHand = newCardsInHand;\r\n\r\n\tconst peggys = board.filter((e) => e.cardId === CardIds.PeggySturdybone || e.cardId === CardIds.PeggySturdyboneBattlegrounds);\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.PeggySturdyboneBattlegrounds ? 2 : 1, board, allCards);\r\n\t\t\tmodifyHealth(pirate, peggy.cardId === CardIds.PeggySturdyboneBattlegrounds ? 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\tconst thornCaptains = board.filter((e) => e.cardId === CardIds.Thorncaptain || e.cardId === CardIds.ThorncaptainBattlegrounds);\r\n\tthornCaptains.forEach((captain) => {\r\n\t\tmodifyHealth(captain, captain.cardId === CardIds.ThorncaptainBattlegrounds ? 2 : 1, board, allCards);\r\n\t\tafterStatsUpdate(captain, board, allCards);\r\n\t\tspectator.registerPowerTarget(captain, captain, board);\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 = (entity: BoardEntity, board: BoardEntity[], newValue: boolean, allCards: AllCardsService): 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\tconst boardForDrake = board;\r\n\t\tconst statsBonus =\r\n\t\t\t10 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake).length +\r\n\t\t\t20 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrakeBattlegrounds).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\t10 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake).length +\r\n\t\t\t20 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrakeBattlegrounds).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 > 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 || 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): void => {\r\n\tif (board.length > 0) {\r\n\t\tlet boardCopy = [...board];\r\n\t\tfor (const tribe of ALL_BG_RACES) {\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}\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.map((cardRace) => getRaceEnum(cardRace)).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): 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 ? `${entity.cardId}/${allCards?.getCard(entity.cardId)?.name ?? ''}/atk=${entity.attack}/hp=${entity.health}}` : null;\r\n};\r\n\r\nexport const isFish = (entity: BoardEntity): boolean => {\r\n\treturn (\r\n\t\tentity.cardId.startsWith(CardIds.AvatarOfNzoth_FishOfNzothTokenBattlegrounds) ||\r\n\t\tentity.cardId.startsWith(CardIds.FishOfNzothBattlegrounds) ||\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;AAOpH,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,WAAwB,EACxB,aAA0B,EAC1B,iBAA8B,IAAI,EACpB,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,CAAC,CAAC,aAAa;QAChC,CAAC,CAAC,EAAE,GAAG,aAAa,EAAE,QAAQ,EAAE,WAAW,CAAC,eAAe,EAAE,EAAE;QAC/D,CAAC,C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,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 { AllCardsService, ALL_BG_RACES, 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 { 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.SilverbackPatriarch_BG_CS2_127_G,\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.Bonker_BG20_104_G,\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\tsharedState: SharedState,\r\n\tentityToSpawn: BoardEntity,\r\n\toriginalEntity: BoardEntity = null,\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 = !!entityToSpawn\r\n\t\t? { ...entityToSpawn, entityId: sharedState.currentEntityId++ }\r\n\t\t: addImpliedMechanics({\r\n\t\t\t\tentityId: entityId,\r\n\t\t\t\tattack: card.attack,\r\n\t\t\t\tattacksPerformed: 0,\r\n\t\t\t\tcardId: cardId,\r\n\t\t\t\tdivineShield: hasMechanic(card, 'DIVINE_SHIELD'),\r\n\t\t\t\thealth: card.health,\r\n\t\t\t\tmaxHealth: card.health,\r\n\t\t\t\ttaunt: hasMechanic(card, 'TAUNT') || TAUNT_IDS.includes(cardId as CardIds),\r\n\t\t\t\treborn: hasMechanic(card, 'REBORN'),\r\n\t\t\t\tpoisonous: hasMechanic(card, 'POISONOUS'),\r\n\t\t\t\twindfury: !megaWindfury && (hasMechanic(card, 'WINDFURY') || card.referencedTags?.includes('WINDFURY')),\r\n\t\t\t\tmegaWindfury: megaWindfury,\r\n\t\t\t\tenchantments: [],\r\n\t\t\t\tfriendly: friendly,\r\n\t\t\t\tattackImmediately: attackImmediately,\r\n\t\t\t\tavengeCurrent: cardsData.avengeValue(cardId),\r\n\t\t\t\tavengeDefault: cardsData.avengeValue(cardId),\r\n\t\t } as BoardEntity);\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 =\r\n\t\t\t\t\tnewEntity.taunt || hasMechanic(stitchedCard, GameTag[GameTag.TAUNT]) || TAUNT_IDS.includes(stitchedCardId as CardIds);\r\n\t\t\t\tnewEntity.divineShield = newEntity.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.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\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).races, 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 (\r\n\t\tentity.cardId === CardIds.Menagerist_AmalgamTokenBattlegrounds ||\r\n\t\tentity.cardId === CardIds.CuddlgamBattlegrounds_TB_BaconShop_HP_033t_SKIN_A ||\r\n\t\tentity.cardId === CardIds.CuddlgamBattlegrounds_TB_BaconShop_HP_033t_SKIN_A_G ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgamBattlegrounds_TB_BaconShop_HP_033t_SKIN_D ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgamBattlegrounds_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.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 (\r\n\t\tentity.cardId === CardIds.Menagerist_AmalgamTokenBattlegrounds ||\r\n\t\tentity.cardId === CardIds.CuddlgamBattlegrounds_TB_BaconShop_HP_033t_SKIN_A ||\r\n\t\tentity.cardId === CardIds.CuddlgamBattlegrounds_TB_BaconShop_HP_033t_SKIN_A_G ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgamBattlegrounds_TB_BaconShop_HP_033t_SKIN_D ||\r\n\t\tentity.cardId === CardIds.AbominableAmalgamBattlegrounds_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.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\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\tconst newCardsInHand = Math.min(10, (playerEntity.cardsInHand ?? 0) + multiplier * cards);\r\n\tif (newCardsInHand <= playerEntity.cardsInHand) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tplayerEntity.cardsInHand = newCardsInHand;\r\n\r\n\tconst peggys = board.filter((e) => e.cardId === CardIds.PeggySturdybone || e.cardId === CardIds.PeggySturdyboneBattlegrounds);\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.PeggySturdyboneBattlegrounds ? 2 : 1, board, allCards);\r\n\t\t\tmodifyHealth(pirate, peggy.cardId === CardIds.PeggySturdyboneBattlegrounds ? 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\tconst thornCaptains = board.filter((e) => e.cardId === CardIds.Thorncaptain || e.cardId === CardIds.ThorncaptainBattlegrounds);\r\n\tthornCaptains.forEach((captain) => {\r\n\t\tmodifyHealth(captain, captain.cardId === CardIds.ThorncaptainBattlegrounds ? 2 : 1, board, allCards);\r\n\t\tafterStatsUpdate(captain, board, allCards);\r\n\t\tspectator.registerPowerTarget(captain, captain, board);\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 = (entity: BoardEntity, board: BoardEntity[], newValue: boolean, allCards: AllCardsService): 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\tconst boardForDrake = board;\r\n\t\tconst statsBonus =\r\n\t\t\t10 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake).length +\r\n\t\t\t20 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrakeBattlegrounds).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\t10 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrake).length +\r\n\t\t\t20 * boardForDrake.filter((e) => e.cardId === CardIds.CyborgDrakeBattlegrounds).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 > 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 || 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): void => {\r\n\tif (board.length > 0) {\r\n\t\tlet boardCopy = [...board];\r\n\t\tfor (const tribe of ALL_BG_RACES) {\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}\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.map((cardRace) => getRaceEnum(cardRace)).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): 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}/ench=${\r\n\t\t\t\tentity.enchantments\r\n\t\t }`\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_FishOfNzothTokenBattlegrounds) ||\r\n\t\tentity.cardId.startsWith(CardIds.FishOfNzothBattlegrounds) ||\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"]}
|