@firestone-hs/simulate-bgs-battle 1.1.381 → 1.1.383

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.
@@ -69,12 +69,15 @@ const setImplicitDataHero = (hero, cardsData, isPlayer, entityIdContainer) => {
69
69
  if (!!((_a = hero.questRewards) === null || _a === void 0 ? void 0 : _a.length) && !Array.isArray(hero.questRewards)) {
70
70
  hero.questRewards = [hero.questRewards];
71
71
  }
72
- hero.questRewards = [...((_b = hero.questRewards) !== null && _b !== void 0 ? _b : []), hero.heroPowerId].filter((e) => !!e);
72
+ const heroPowerAsReward = hero.cardId === "BG24_HERO_100" ? hero.heroPowerId : null;
73
+ hero.questRewards = [...((_b = hero.questRewards) !== null && _b !== void 0 ? _b : []), heroPowerAsReward].filter((e) => !!e);
73
74
  hero.questRewardEntities = hero.questRewardEntities
74
75
  ? hero.questRewardEntities.map((reward) => ({
75
- ...reward,
76
+ cardId: reward.CardId,
77
+ scriptDataNum1: reward.ScriptDataNum1,
76
78
  entityId: entityIdContainer.entityId--,
77
- avengeDefault: cardsData.avengeValue(reward.cardId),
79
+ avengeDefault: cardsData.avengeValue(reward.CardId),
80
+ avengeCurrent: 0,
78
81
  }))
79
82
  : hero.questRewards.map((reward) => ({
80
83
  cardId: reward,
@@ -1 +1 @@
1
- {"version":3,"file":"auras.js","sourceRoot":"","sources":["../../src/simulation/auras.ts"],"names":[],"mappings":";;;AACA,iEAA8E;AAI9E,oCAA2C;AAEpC,MAAM,eAAe,GAAG,CAC9B,KAAoB,EACpB,SAA0B,EAC1B,SAA0B,EAC1B,QAAyB,EAClB,EAAE;IACT,qBAAqB,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAClD,IAAA,+BAAuB,EAAC,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AACtD,CAAC,CAAC;AARW,QAAA,eAAe,mBAQ1B;AAEK,MAAM,uBAAuB,GAAG,CACtC,KAA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AC,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 } 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, boardHero, allCards);\r\n\tsetMissingHeroPowerAura(board, boardHero, otherHero);\r\n};\r\n\r\nexport const setMissingHeroPowerAura = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n): void => {\r\n\tif (boardHero.heroPowerId === CardIds.TheSmokingGun) {\r\n\t\tboard\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\t!e.enchantments.find(\r\n\t\t\t\t\t\t(ench) => ench.cardId === CardIds.TheSmokingGun_ArmedAndStillSmokingEnchantment,\r\n\t\t\t\t\t),\r\n\t\t\t)\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\te.attack += 4;\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[], boardHero: BgsPlayerEntity, 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_YarrrVanillaEnchantment,\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.SouthseaCaptainLegacy_TB_BaconUps_136,\r\n\t\tCardIds.SouthseaCaptain_YarrrEnchantment,\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.MurlocWarleaderLegacy_BG_EX1_507,\r\n\t\tCardIds.MurlocWarleader_MrgglaarglEnchantment,\r\n\t\t4,\r\n\t\t0,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, Race.BEAST, allCards)),\r\n\t\tCardIds.HummingBird_BG26_805,\r\n\t\tCardIds.HummingBird_EntrancedEnchantment_BG26_805e,\r\n\t\t2,\r\n\t\t0,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, Race.BEAST, allCards)),\r\n\t\tCardIds.HummingBird_BG26_805_G,\r\n\t\tCardIds.HummingBird_EntrancedEnchantment_BG26_805_Ge,\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.Kathranatir_BG21_039_G,\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.LadySinestra_TB_BaconShop_HERO_52_Buddy,\r\n\t\tCardIds.DraconicBlessingEnchantment_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.LadySinestra_TB_BaconShop_HERO_52_Buddy_G,\r\n\t\tCardIds.DraconicBlessingEnchantment_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_BG25_043,\r\n\t\tCardIds.CyborgDrake_CyborgEnhancementEnchantment_BG25_043e,\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_BG25_043_G,\r\n\t\tCardIds.CyborgDrake_CyborgEnhancementEnchantment_BG25_043_Ge,\r\n\t\t12,\r\n\t\t0,\r\n\t\tfalse,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, Race.UNDEAD, allCards)),\r\n\t\tCardIds.SoreLoser_BG27_030,\r\n\t\tCardIds.SoreLoser_NoImWinningEnchantment_BG27_030e,\r\n\t\tboardHero.tavernTier,\r\n\t\t0,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, Race.UNDEAD, allCards)),\r\n\t\tCardIds.SoreLoser_BG27_030_G,\r\n\t\tCardIds.SoreLoser_NoImWinningEnchantment_BG27_030e,\r\n\t\t2 * boardHero.tavernTier,\r\n\t\t0,\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 setImplicitDataHero = (\r\n\thero: BgsPlayerEntity,\r\n\tcardsData: CardsData,\r\n\tisPlayer: boolean,\r\n\tentityIdContainer: { entityId: number },\r\n): 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.questRewardEntities = hero.questRewardEntities\r\n\t\t? hero.questRewardEntities.map((reward) => ({\r\n\t\t\t\t...reward,\r\n\t\t\t\tentityId: entityIdContainer.entityId--,\r\n\t\t\t\tavengeDefault: cardsData.avengeValue(reward.cardId),\r\n\t\t }))\r\n\t\t: hero.questRewards.map((reward) => ({\r\n\t\t\t\tcardId: reward,\r\n\t\t\t\tentityId: entityIdContainer.entityId--,\r\n\t\t\t\tavengeCurrent: 0,\r\n\t\t\t\tavengeDefault: cardsData.avengeValue(reward),\r\n\t\t\t\tscriptDataNum1: 0,\r\n\t\t }));\r\n\thero.entityId = hero.entityId ?? entityIdContainer.entityId--;\r\n\thero.hand = hero.hand ?? [];\r\n\tif (!hero.globalInfo) {\r\n\t\thero.globalInfo = {};\r\n\t}\r\n\r\n\thero.globalInfo.EternalKnightsDeadThisGame = hero.globalInfo.EternalKnightsDeadThisGame ?? 0;\r\n\thero.globalInfo.TavernSpellsCastThisGame = hero.globalInfo.TavernSpellsCastThisGame ?? 0;\r\n\thero.globalInfo.UndeadAttackBonus = hero.globalInfo.UndeadAttackBonus ?? 0;\r\n\thero.globalInfo.FrostlingBonus = hero.globalInfo.FrostlingBonus ?? 0;\r\n\thero.globalInfo.BloodGemAttackBonus = hero.globalInfo.BloodGemAttackBonus ?? 0;\r\n\thero.globalInfo.BloodGemHealthBonus = hero.globalInfo.BloodGemHealthBonus ?? 0;\r\n\thero.globalInfo.GoldrinnBuffAtk = hero.globalInfo.GoldrinnBuffAtk ?? 0;\r\n\thero.globalInfo.GoldrinnBuffHealth = hero.globalInfo.GoldrinnBuffHealth ?? 0;\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,oCAA2C;AAEpC,MAAM,eAAe,GAAG,CAC9B,KAAoB,EACpB,SAA0B,EAC1B,SAA0B,EAC1B,QAAyB,EAClB,EAAE;IACT,qBAAqB,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAClD,IAAA,+BAAuB,EAAC,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AACtD,CAAC,CAAC;AARW,QAAA,eAAe,mBAQ1B;AAEK,MAAM,uBAAuB,GAAG,CACtC,KAAoB,EACpB,SAA0B,EAC1B,SAA0B,EACnB,EAAE;IACT,IAAI,SAAS,CAAC,WAAW,sBAA0B,EAAE;QACpD,KAAK;aACH,MAAM,CACN,CAAC,CAAC,EAAE,EAAE,CACL,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CACnB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,uBAA0D,CAC/E,CACF;aACA,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACd,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;KACJ;IACD,IAAI,SAAS,CAAC,WAAW,sBAA0B,EAAE;QACpD,KAAK;aACH,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,uBAA8C,CAAC,CAAC;aACxG,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACd,CAAC,CAAC,MAAM,IAAI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AM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;QAC9D,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC;KAC1C;IACD,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;QACnE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC;KAC/C;IACD,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,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 } 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, boardHero, allCards);\r\n\tsetMissingHeroPowerAura(board, boardHero, otherHero);\r\n};\r\n\r\nexport const setMissingHeroPowerAura = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n): void => {\r\n\tif (boardHero.heroPowerId === CardIds.TheSmokingGun) {\r\n\t\tboard\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\t!e.enchantments.find(\r\n\t\t\t\t\t\t(ench) => ench.cardId === CardIds.TheSmokingGun_ArmedAndStillSmokingEnchantment,\r\n\t\t\t\t\t),\r\n\t\t\t)\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\te.attack += 4;\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[], boardHero: BgsPlayerEntity, 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_YarrrVanillaEnchantment,\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.SouthseaCaptainLegacy_TB_BaconUps_136,\r\n\t\tCardIds.SouthseaCaptain_YarrrEnchantment,\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.MurlocWarleaderLegacy_BG_EX1_507,\r\n\t\tCardIds.MurlocWarleader_MrgglaarglEnchantment,\r\n\t\t4,\r\n\t\t0,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, Race.BEAST, allCards)),\r\n\t\tCardIds.HummingBird_BG26_805,\r\n\t\tCardIds.HummingBird_EntrancedEnchantment_BG26_805e,\r\n\t\t2,\r\n\t\t0,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, Race.BEAST, allCards)),\r\n\t\tCardIds.HummingBird_BG26_805_G,\r\n\t\tCardIds.HummingBird_EntrancedEnchantment_BG26_805_Ge,\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.Kathranatir_BG21_039_G,\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.LadySinestra_TB_BaconShop_HERO_52_Buddy,\r\n\t\tCardIds.DraconicBlessingEnchantment_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.LadySinestra_TB_BaconShop_HERO_52_Buddy_G,\r\n\t\tCardIds.DraconicBlessingEnchantment_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_BG25_043,\r\n\t\tCardIds.CyborgDrake_CyborgEnhancementEnchantment_BG25_043e,\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_BG25_043_G,\r\n\t\tCardIds.CyborgDrake_CyborgEnhancementEnchantment_BG25_043_Ge,\r\n\t\t12,\r\n\t\t0,\r\n\t\tfalse,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, Race.UNDEAD, allCards)),\r\n\t\tCardIds.SoreLoser_BG27_030,\r\n\t\tCardIds.SoreLoser_NoImWinningEnchantment_BG27_030e,\r\n\t\tboardHero.tavernTier,\r\n\t\t0,\r\n\t);\r\n\tsetMissingAura(\r\n\t\tboard.filter((e) => hasCorrectTribe(e, Race.UNDEAD, allCards)),\r\n\t\tCardIds.SoreLoser_BG27_030_G,\r\n\t\tCardIds.SoreLoser_NoImWinningEnchantment_BG27_030e,\r\n\t\t2 * boardHero.tavernTier,\r\n\t\t0,\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 setImplicitDataHero = (\r\n\thero: BgsPlayerEntity,\r\n\tcardsData: CardsData,\r\n\tisPlayer: boolean,\r\n\tentityIdContainer: { entityId: number },\r\n): 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\tconst heroPowerAsReward = hero.cardId === CardIds.SireDenathrius_BG24_HERO_100 ? hero.heroPowerId : null;\r\n\thero.questRewards = [...(hero.questRewards ?? []), heroPowerAsReward].filter((e) => !!e);\r\n\thero.questRewardEntities = hero.questRewardEntities\r\n\t\t? hero.questRewardEntities.map((reward: any) => ({\r\n\t\t\t\tcardId: reward.CardId,\r\n\t\t\t\tscriptDataNum1: reward.ScriptDataNum1,\r\n\t\t\t\tentityId: entityIdContainer.entityId--,\r\n\t\t\t\tavengeDefault: cardsData.avengeValue(reward.CardId),\r\n\t\t\t\tavengeCurrent: 0,\r\n\t\t }))\r\n\t\t: hero.questRewards.map((reward) => ({\r\n\t\t\t\tcardId: reward,\r\n\t\t\t\tentityId: entityIdContainer.entityId--,\r\n\t\t\t\tavengeCurrent: 0,\r\n\t\t\t\tavengeDefault: cardsData.avengeValue(reward),\r\n\t\t\t\tscriptDataNum1: 0,\r\n\t\t }));\r\n\thero.entityId = hero.entityId ?? entityIdContainer.entityId--;\r\n\thero.hand = hero.hand ?? [];\r\n\tif (!hero.globalInfo) {\r\n\t\thero.globalInfo = {};\r\n\t}\r\n\r\n\thero.globalInfo.EternalKnightsDeadThisGame = hero.globalInfo.EternalKnightsDeadThisGame ?? 0;\r\n\thero.globalInfo.TavernSpellsCastThisGame = hero.globalInfo.TavernSpellsCastThisGame ?? 0;\r\n\thero.globalInfo.UndeadAttackBonus = hero.globalInfo.UndeadAttackBonus ?? 0;\r\n\thero.globalInfo.FrostlingBonus = hero.globalInfo.FrostlingBonus ?? 0;\r\n\thero.globalInfo.BloodGemAttackBonus = hero.globalInfo.BloodGemAttackBonus ?? 0;\r\n\thero.globalInfo.BloodGemHealthBonus = hero.globalInfo.BloodGemHealthBonus ?? 0;\r\n\thero.globalInfo.GoldrinnBuffAtk = hero.globalInfo.GoldrinnBuffAtk ?? 0;\r\n\thero.globalInfo.GoldrinnBuffHealth = hero.globalInfo.GoldrinnBuffHealth ?? 0;\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"]}
@@ -26,7 +26,7 @@ const applyAvengeEffects = (deadEntity, deadEntityIndexFromRight, boardWithDeadE
26
26
  for (const avenger of avengers) {
27
27
  handleAvenge(boardWithDeadEntity, boardWithDeadEntityHero, deadEntity, deadEntityIndexFromRight, avenger, otherBoard, otherBoardHero, gameState);
28
28
  }
29
- const heroAvenger = !!boardWithDeadEntityHero.avengeDefault && boardWithDeadEntityHero.avengeCurrent === 0;
29
+ const heroAvenger = !!boardWithDeadEntityHero.avengeDefault && boardWithDeadEntityHero.avengeCurrent <= 0;
30
30
  if (heroAvenger) {
31
31
  handleHeroAvenge(deadEntity, boardWithDeadEntity, boardWithDeadEntityHero, otherBoard, otherBoardHero, candidatesEntitiesSpawnedFromAvenge, gameState);
32
32
  }
@@ -255,7 +255,7 @@ const handleAvenge = (boardWithDeadEntity, boardWithDeadEntityHero, deadEntity,
255
255
  avenger.scriptDataNum1++;
256
256
  break;
257
257
  }
258
- avenger.avengeCurrent = avenger.avengeDefault;
258
+ avenger.avengeCurrent += avenger.avengeDefault;
259
259
  };
260
260
  const handleHeroAvenge = (deadEntity, boardWithDeadEntity, boardWithDeadEntityHero, otherBoard, otherBoardHero, candidatesEntitiesSpawnedFromAvenge, gameState) => {
261
261
  switch (boardWithDeadEntityHero === null || boardWithDeadEntityHero === void 0 ? void 0 : boardWithDeadEntityHero.heroPowerId) {
@@ -278,6 +278,6 @@ const handleHeroAvenge = (deadEntity, boardWithDeadEntity, boardWithDeadEntityHe
278
278
  });
279
279
  break;
280
280
  }
281
- boardWithDeadEntityHero.avengeCurrent = boardWithDeadEntityHero.avengeDefault;
281
+ boardWithDeadEntityHero.avengeCurrent += boardWithDeadEntityHero.avengeDefault;
282
282
  };
283
283
  //# sourceMappingURL=avenge.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"avenge.js","sourceRoot":"","sources":["../../src/simulation/avenge.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAG7D,6CAA+C;AAC/C,oCAUkB;AAClB,qCAA4D;AAC5D,6CAA+C;AAC/C,mDAAiD;AACjD,6DAAqD;AAErD,qCAA+C;AAC/C,mCAAuE;AAEhE,MAAM,kBAAkB,GAAG,CACjC,UAAuB,EACvB,wBAAgC,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E,CAAC,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,SAAS,CAAC,CAAC;gBACjF,IAAA,wBAAgB,EAAC,MAAM,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,SAAS,CAAC,CAAC;gBAClF,SAAS,CAAC,SAAS,CAAC,mBAAmB,CACtC,uBAAuB,EACvB,MAAM,EACN,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,CACd,CAAC;YACH,CAAC,CAAC,CAAC;YACH,MAAM;KACP;IACD,uBAAuB,CAAC,aAAa,GAAG,uBAAuB,CAAC,aAAa,CAAC;AAC/E,CAAC,CAAC","sourcesContent":["import { CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { pickRandom } from '../services/utils';\r\nimport {\r\n\taddStatsToBoard,\r\n\tgetRandomAliveMinion,\r\n\tgetRandomMinionWithHighestHealth,\r\n\tgrantRandomDivineShield,\r\n\tgrantRandomStats,\r\n\tgrantStatsToMinionsOfEachType,\r\n\thasCorrectTribe,\r\n\tisMinionGolden,\r\n\tmakeMinionGolden,\r\n} from '../utils';\r\nimport { dealDamageToEnemy, getNeighbours } from './attack';\r\nimport { playBloodGemsOn } from './blood-gems';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { performEntitySpawns } from './spawns';\r\nimport { afterStatsUpdate, modifyAttack, modifyHealth } from './stats';\r\n\r\nexport const applyAvengeEffects = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst candidatesEntitiesSpawnedFromAvenge: BoardEntity[] = [];\r\n\t// updateAvengeCounters(boardWithDeadEntity, boardWithDeadEntityHero);\r\n\tconst avengers = boardWithDeadEntity\r\n\t\t.filter((e) => !!e.avengeDefault && e.avengeCurrent <= 0)\r\n\t\t// Get Tony to be processed first, because of the \"when turned golden, the minion ignores the death for the avenge counter\"\r\n\t\t// behavior\r\n\t\t.sort((a, b) => {\r\n\t\t\tif (a.cardId === CardIds.TonyTwoTusk_BG21_031 || a.cardId === CardIds.TonyTwoTusk_BG21_031_G) {\r\n\t\t\t\treturn -1;\r\n\t\t\t}\r\n\t\t\tif (b.cardId === CardIds.TonyTwoTusk_BG21_031 || b.cardId === CardIds.TonyTwoTusk_BG21_031_G) {\r\n\t\t\t\treturn 1;\r\n\t\t\t}\r\n\t\t\treturn 0;\r\n\t\t});\r\n\tfor (const avenger of avengers) {\r\n\t\thandleAvenge(\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\tdeadEntity,\r\n\t\t\tdeadEntityIndexFromRight,\r\n\t\t\tavenger,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\t// console.log('updating dead entity avenge counter', boardWithDeadEntityHero.avengeCurrent, stringifySimpleCard(deadEntity, allCards));\r\n\tconst heroAvenger = !!boardWithDeadEntityHero.avengeDefault && boardWithDeadEntityHero.avengeCurrent === 0;\r\n\tif (heroAvenger) {\r\n\t\t// console.log(\r\n\t\t// \t'Hero is an avenger',\r\n\t\t// \tboardWithDeadEntityHero.avengeCurrent,\r\n\t\t// \tboardWithDeadEntityHero.avengeDefault,\r\n\t\t// \tboardWithDeadEntityHero.heroPowerId,\r\n\t\t// );\r\n\t\thandleHeroAvenge(\r\n\t\t\tdeadEntity,\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tcandidatesEntitiesSpawnedFromAvenge,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\r\n\tconst questRewardAvengers = boardWithDeadEntityHero.questRewardEntities.filter(\r\n\t\t(e) => !!e.avengeDefault && e.avengeCurrent <= 0,\r\n\t);\r\n\tfor (const avenger of questRewardAvengers) {\r\n\t\thandleAvenge(\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\tdeadEntity,\r\n\t\t\tdeadEntityIndexFromRight,\r\n\t\t\tavenger as BoardEntity,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\r\n\tperformEntitySpawns(\r\n\t\tcandidatesEntitiesSpawnedFromAvenge,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tdeadEntity,\r\n\t\tdeadEntityIndexFromRight,\r\n\t\totherBoard,\r\n\t\totherBoardHero,\r\n\t\tgameState,\r\n\t);\r\n};\r\n\r\nexport const updateAvengeCounters = (board: readonly BoardEntity[], boardWithDeadEntityHero: BgsPlayerEntity) => {\r\n\tfor (const entity of board) {\r\n\t\tif (!!entity.avengeDefault) {\r\n\t\t\tentity.avengeCurrent -= 1;\r\n\t\t}\r\n\t}\r\n\tif (!!boardWithDeadEntityHero.avengeDefault) {\r\n\t\tboardWithDeadEntityHero.avengeCurrent -= 1;\r\n\t}\r\n\r\n\tfor (const reward of boardWithDeadEntityHero.questRewardEntities) {\r\n\t\tif (!!reward.avengeDefault) {\r\n\t\t\treward.avengeCurrent -= 1;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleAvenge = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tavenger: BoardEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\t// Don't forget to update the avenge data in cards-data\r\n\tswitch (avenger.cardId) {\r\n\t\tcase CardIds.BirdBuddy_BG21_002:\r\n\t\t\taddStatsToBoard(avenger, boardWithDeadEntity, boardWithDeadEntityHero, 1, 1, gameState, 'BEAST');\r\n\t\t\tbreak;\r\n\t\tcase CardIds.BirdBuddy_BG21_002_G:\r\n\t\t\taddStatsToBoard(avenger, boardWithDeadEntity, boardWithDeadEntityHero, 2, 2, gameState, 'BEAST');\r\n\t\t\tbreak;\r\n\t\tcase CardIds.BuddingGreenthumb_BG21_030:\r\n\t\tcase CardIds.BuddingGreenthumb_BG21_030_G:\r\n\t\t\tconst neighbours = getNeighbours(boardWithDeadEntity, avenger);\r\n\t\t\tneighbours.forEach((entity) => {\r\n\t\t\t\tmodifyAttack(\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tavenger.cardId === CardIds.BuddingGreenthumb_BG21_030_G ? 4 : 2,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t\tmodifyHealth(\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tavenger.cardId === CardIds.BuddingGreenthumb_BG21_030_G ? 2 : 1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t\tafterStatsUpdate(entity, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tavenger,\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t\t\tbreak;\r\n\t\t// case CardIds.FrostwolfLieutenant:\r\n\t\t// case CardIds.FrostwolfLieutenantBattlegrounds:\r\n\t\t// \taddStatsToBoard(\r\n\t\t// \t\tavenger,\r\n\t\t// \t\tboardWithDeadEntity,\r\n\t\t// \t\tavenger.cardId === CardIds.FrostwolfLieutenantBattlegrounds ? 2 : 1,\r\n\t\t// \t\t0,\r\n\t\t// \t\tallCards,\r\n\t\t// \t\tspectator,\r\n\t\t// \t);\r\n\t\t// \tbreak;\r\n\t\tcase CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy:\r\n\t\tcase CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy_G:\r\n\t\t\t// Only for Tavern\r\n\t\t\t// addStatsToBoard(\r\n\t\t\t// \tavenger,\r\n\t\t\t// \tboardWithDeadEntity,\r\n\t\t\t// \t0,\r\n\t\t\t// \tavenger.cardId === CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy_G ? 2 : 1,\r\n\t\t\t// \tgameState.allCards,\r\n\t\t\t// \tgameState.spectator,\r\n\t\t\t// );\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PalescaleCrocolisk_BG21_001:\r\n\t\t\tconst target1 = grantRandomStats(\r\n\t\t\t\tavenger,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t6,\r\n\t\t\t\t6,\r\n\t\t\t\tRace.BEAST,\r\n\t\t\t\ttrue,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tif (!!target1) {\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tavenger,\r\n\t\t\t\t\ttarget1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PalescaleCrocolisk_BG21_001_G:\r\n\t\t\tconst target2 = grantRandomStats(\r\n\t\t\t\tavenger,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t12,\r\n\t\t\t\t12,\r\n\t\t\t\tRace.BEAST,\r\n\t\t\t\ttrue,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tif (!!target2) {\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tavenger,\r\n\t\t\t\t\ttarget2,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ImpatientDoomsayer_BG21_007:\r\n\t\tcase CardIds.ImpatientDoomsayer_BG21_007_G:\r\n\t\t\tconst doomsayerCardsToAddQuantity = avenger.cardId === CardIds.ImpatientDoomsayer_BG21_007_G ? 2 : 1;\r\n\t\t\tconst doomsayerCardsToAdd = [];\r\n\t\t\tfor (let i = 0; i < doomsayerCardsToAddQuantity; i++) {\r\n\t\t\t\tdoomsayerCardsToAdd.push(pickRandom(gameState.cardsData.demonSpawns));\r\n\t\t\t}\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, doomsayerCardsToAdd, gameState);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PashmarTheVengeful_BG23_014:\r\n\t\tcase CardIds.PashmarTheVengeful_BG23_014_G:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, [null], gameState);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.TremblingTrolley_BG28_967:\r\n\t\tcase CardIds.TremblingTrolley_BG28_967_G:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, [null], gameState);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.MysticSporebat_BG28_900:\r\n\t\tcase CardIds.MysticSporebat_BG28_900_G:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, [null], gameState);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.WitchwingNestmatron_BG21_038:\r\n\t\tcase CardIds.WitchwingNestmatron_BG21_038_G:\r\n\t\t\tconst nestmatronToAddQuantity = avenger.cardId === CardIds.WitchwingNestmatron_BG21_038_G ? 2 : 1;\r\n\t\t\tconst nestmatronCardsToAdd = [];\r\n\t\t\tfor (let i = 0; i < nestmatronToAddQuantity; i++) {\r\n\t\t\t\tnestmatronCardsToAdd.push(pickRandom(gameState.cardsData.brannEpicEggSpawns));\r\n\t\t\t}\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, nestmatronCardsToAdd, gameState);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Thorncaller_BG20_105:\r\n\t\tcase CardIds.Thorncaller_BG20_105_G:\r\n\t\t\tconst thorncallerToAddQuantity = avenger.cardId === CardIds.Thorncaller_BG20_105_G ? 2 : 1;\r\n\t\t\tconst thorncallerCardsToAdd = Array(thorncallerToAddQuantity).fill(CardIds.BloodGem);\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, thorncallerCardsToAdd, gameState);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Sisefin_BG21_009:\r\n\t\tcase CardIds.Sisefin_BG21_009_G:\r\n\t\t\tconst poisonousIterations = avenger.cardId === CardIds.Sisefin_BG21_009_G ? 2 : 1;\r\n\t\t\tfor (let i = 0; i < poisonousIterations; i++) {\r\n\t\t\t\tconst validTargets = boardWithDeadEntity.filter((e) => !e.poisonous && !e.venomous);\r\n\t\t\t\tconst murloc = getRandomAliveMinion(validTargets, Race.MURLOC, gameState.allCards);\r\n\t\t\t\tif (murloc) {\r\n\t\t\t\t\tmurloc.venomous = true;\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\tavenger,\r\n\t\t\t\t\t\tmurloc,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.MechanoTank_BG21_023:\r\n\t\t\t// This can be null if the avenge triggers when the last enemy minion dies as well\r\n\t\t\tconst target = getRandomMinionWithHighestHealth(otherBoard);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tavenger,\r\n\t\t\t\ttarget,\r\n\t\t\t\totherBoard,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t);\r\n\t\t\tdealDamageToEnemy(\r\n\t\t\t\ttarget,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tavenger,\r\n\t\t\t\t5,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.MechanoTank_BG21_023_G:\r\n\t\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\t\tconst target = getRandomMinionWithHighestHealth(otherBoard);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tavenger,\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t);\r\n\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tavenger,\r\n\t\t\t\t\t5,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.TonyTwoTusk_BG21_031:\r\n\t\t\tconst nonGoldenMinions = boardWithDeadEntity\r\n\t\t\t\t.filter((e) => e.entityId !== avenger.entityId)\r\n\t\t\t\t.filter((e) => {\r\n\t\t\t\t\tconst ref = gameState.allCards.getCard(e.cardId);\r\n\t\t\t\t\treturn (\r\n\t\t\t\t\t\t!!ref.battlegroundsPremiumDbfId &&\r\n\t\t\t\t\t\t!!gameState.allCards.getCardFromDbfId(ref.battlegroundsPremiumDbfId).id\r\n\t\t\t\t\t);\r\n\t\t\t\t});\r\n\t\t\tconst pirate = getRandomAliveMinion(nonGoldenMinions, Race.PIRATE, gameState.allCards);\r\n\t\t\tif (pirate) {\r\n\t\t\t\tmakeMinionGolden(pirate, avenger, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.TonyTwoTusk_BG21_031_G:\r\n\t\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\t\tconst nonGoldenMinions = boardWithDeadEntity.filter((e) => !isMinionGolden(e, gameState.allCards));\r\n\t\t\t\tconst pirate = getRandomAliveMinion(nonGoldenMinions, Race.PIRATE, gameState.allCards);\r\n\t\t\t\tif (pirate) {\r\n\t\t\t\t\tmakeMinionGolden(pirate, avenger, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.GhoulOfTheFeast_BG25_002:\r\n\t\tcase CardIds.GhoulOfTheFeast_BG25_002_G:\r\n\t\t\tconst ghoulMultiplier = avenger.cardId === CardIds.GhoulOfTheFeast_BG25_002_G ? 2 : 1;\r\n\t\t\tgrantStatsToMinionsOfEachType(\r\n\t\t\t\tavenger,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tghoulMultiplier * 3,\r\n\t\t\t\t0,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Bristlebach_BG26_157:\r\n\t\tcase CardIds.Bristlebach_BG26_157_G:\r\n\t\t\tconst bristlebachMultiplier = avenger.cardId === CardIds.Bristlebach_BG26_157_G ? 4 : 2;\r\n\t\t\tfor (let i = 0; i < bristlebachMultiplier; i++) {\r\n\t\t\t\tfor (const entity of boardWithDeadEntity) {\r\n\t\t\t\t\tif (hasCorrectTribe(entity, Race.QUILBOAR, gameState.allCards)) {\r\n\t\t\t\t\t\tplayBloodGemsOn(entity, 1, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\tavenger,\r\n\t\t\t\t\t\t\tentity,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.HungeringAbomination_BG25_014:\r\n\t\tcase CardIds.HungeringAbomination_BG25_014_G:\r\n\t\t\tconst abominationMultiplier = avenger.cardId === CardIds.HungeringAbomination_BG25_014_G ? 2 : 1;\r\n\t\t\tmodifyAttack(avenger, abominationMultiplier * 1, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\tmodifyHealth(avenger, abominationMultiplier * 1, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\tafterStatsUpdate(avenger, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tavenger,\r\n\t\t\t\tavenger,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ShadowyConstruct_BG25_HERO_103_Buddy:\r\n\t\tcase CardIds.ShadowyConstruct_BG25_HERO_103_Buddy_G:\r\n\t\t\tconst neighboursShadowy = getNeighbours(boardWithDeadEntity, null, deadEntityIndexFromRight);\r\n\t\t\tconst multiplierShadowy = avenger.cardId === CardIds.ShadowyConstruct_BG25_HERO_103_Buddy_G ? 2 : 1;\r\n\t\t\tneighboursShadowy.forEach((neighbour) => {\r\n\t\t\t\tmodifyAttack(neighbour, multiplierShadowy * 1, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\tmodifyHealth(neighbour, multiplierShadowy * 1, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\tafterStatsUpdate(neighbour, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tavenger,\r\n\t\t\t\t\tneighbour,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.IceSickle:\r\n\t\t\tgrantRandomStats(\r\n\t\t\t\tavenger,\r\n\t\t\t\tboardWithDeadEntityHero.hand,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t4,\r\n\t\t\t\t0,\r\n\t\t\t\tnull,\r\n\t\t\t\ttrue,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.BoomSquad_BG27_Reward_502:\r\n\t\t\tconst highestHealthMinion = [...otherBoard].sort((a, b) => b.health - a.health)[0];\r\n\t\t\tdealDamageToEnemy(\r\n\t\t\t\thighestHealthMinion,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tavenger,\r\n\t\t\t\t10,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tavenger,\r\n\t\t\t\thighestHealthMinion,\r\n\t\t\t\totherBoard,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.RelentlessSentry_BG25_003:\r\n\t\tcase CardIds.RelentlessSentry_BG25_003_G:\r\n\t\t\tavenger.reborn = true;\r\n\t\t\tavenger.taunt = true;\r\n\t\t\tbreak;\r\n\t\tcase CardIds.RelentlessMurghoul_BG27_010:\r\n\t\tcase CardIds.RelentlessMurghoul_BG27_010_G:\r\n\t\t\tavenger.reborn = true;\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ChampionOfThePrimus_BG27_029:\r\n\t\tcase CardIds.ChampionOfThePrimus_BG27_029_G:\r\n\t\t\tconst championPrimusStat = avenger.cardId === CardIds.ChampionOfThePrimus_BG27_029_G ? 2 : 1;\r\n\t\t\tboardWithDeadEntityHero.globalInfo.UndeadAttackBonus += championPrimusStat;\r\n\t\t\taddStatsToBoard(\r\n\t\t\t\tavenger,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tchampionPrimusStat,\r\n\t\t\t\t0,\r\n\t\t\t\tgameState,\r\n\t\t\t\tRace[Race.UNDEAD],\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PhaerixWrathOfTheSun_BG28_403:\r\n\t\tcase CardIds.PhaerixWrathOfTheSun_BG28_403_G:\r\n\t\t\tconst phaerixLoops = avenger.cardId === CardIds.PhaerixWrathOfTheSun_BG28_403_G ? 2 : 1;\r\n\t\t\tfor (let i = 0; i < phaerixLoops; i++) {\r\n\t\t\t\tgrantRandomDivineShield(avenger, boardWithDeadEntity, gameState.allCards, gameState.spectator);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.AugmentedLaborer_BG28_740:\r\n\t\tcase CardIds.AugmentedLaborer_BG28_740_G:\r\n\t\t\tconst AugmentedLaborerLoops = avenger.cardId === CardIds.AugmentedLaborer_BG28_740_G ? 2 : 1;\r\n\t\t\tfor (let i = 0; i < AugmentedLaborerLoops; i++) {\r\n\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, [null], gameState);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.TumblingDisaster_BG28_Reward_505:\r\n\t\t\tconst tumblingDisasterEntity = boardWithDeadEntityHero.questRewardEntities?.find(\r\n\t\t\t\t(e) => e.cardId === CardIds.TumblingDisaster_BG28_Reward_505,\r\n\t\t\t);\r\n\t\t\tif (tumblingDisasterEntity) {\r\n\t\t\t\ttumblingDisasterEntity.scriptDataNum1++;\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.CycleOfEnergy_BG28_Reward_504:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, [null], gameState);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.StableAmalgamation_BG28_Reward_518:\r\n\t\t\tavenger.scriptDataNum1++;\r\n\t\t\tbreak;\r\n\t}\r\n\tavenger.avengeCurrent = avenger.avengeDefault;\r\n};\r\n\r\nconst handleHeroAvenge = (\r\n\tdeadEntity: BoardEntity,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tcandidatesEntitiesSpawnedFromAvenge: BoardEntity[],\r\n\tgameState: FullGameState,\r\n) => {\r\n\t// https://twitter.com/LoewenMitchell/status/1491879869457879040\r\n\t// Not affected by Khadgar\r\n\tswitch (boardWithDeadEntityHero?.heroPowerId) {\r\n\t\tcase CardIds.Onyxia_Broodmother:\r\n\t\t\tcandidatesEntitiesSpawnedFromAvenge.push(\r\n\t\t\t\t...spawnEntities(\r\n\t\t\t\t\tCardIds.Onyxia_OnyxianWhelpToken,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t),\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.VanndarStormpike_LeadTheStormpikes:\r\n\t\t\tboardWithDeadEntity\r\n\t\t\t\t// .filter((entity) => !entity.definitelyDead && entity.health > 0)\r\n\t\t\t\t.forEach((entity) => {\r\n\t\t\t\t\tmodifyHealth(entity, 1, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\t\tafterStatsUpdate(entity, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tentity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t);\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Drekthar_LeadTheFrostwolves:\r\n\t\t\tboardWithDeadEntity.forEach((entity) => {\r\n\t\t\t\tmodifyAttack(entity, 1, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\tafterStatsUpdate(entity, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t\t\tbreak;\r\n\t}\r\n\tboardWithDeadEntityHero.avengeCurrent = boardWithDeadEntityHero.avengeDefault;\r\n};\r\n"]}
1
+ {"version":3,"file":"avenge.js","sourceRoot":"","sources":["../../src/simulation/avenge.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAG7D,6CAA+C;AAC/C,oCAUkB;AAClB,qCAA4D;AAC5D,6CAA+C;AAC/C,mDAAiD;AACjD,6DAAqD;AAErD,qCAA+C;AAC/C,mCAAuE;AAEhE,MAAM,kBAAkB,GAAG,CACjC,UAAuB,EACvB,wBAAgC,EAChC,mBAAkC,EAClC,uBAAwC,EACxC,UAAyB,EACzB,cAA+B,EAC/B,SAAwB,EACjB,EAAE;IACT,MAAM,mCAAmC,GAAkB,EAAE,CAAC;IAE9D,MAAM,QAAQ,GAAG,mBAAmB;SAClC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,IAAI,CAAC,CAAC,aAAa,IAAI,CAAC,CAAC;SAGxD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACd,IAAI,CAAC,CAAC,MAAM,eAAiC,IAAI,CAAC,CAAC,MAAM,iBAAmC,EAAE;YAC7F,OAAO,CAAC,CAAC,CAAC;SACV;QACD,IAAI,CAAC,CAAC,MAAM,eAAiC,IAAI,CAAC,CAAC,MAAM,iBAAmC,EAAE;YAC7F,OAAO,CAAC,CAAC;SACT;QACD,OAAO,CAAC,CAAC;IACV,CAAC,CAAC,CAAC;IACJ,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;QAC/B,YAAY,CACX,mBAAmB,EACnB,uBAAuB,EACvB,UAAU,EACV,wBAAwB,EACxB,OAAO,EACP,UAAU,EACV,cAAc,EACd,SAAS,CACT,CAAC;KACF;IAED,MAAM,WAAW,GAAG,CAAC,CAAC,uBAAuB,CAAC,aAAa,IAAI,uBAAuB,CAAC,aAAa,IAAI,CAAC,CAAC;IAC1G,IAAI,WAAW,EAAE;QAOhB,gBAAgB,CACf,UAAU,EACV,mBAAmB,EACnB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AAE,mBAAmB,EAAE,uBAAuB,EAAE,SAAS,CAAC,CAAC;gBAClF,SAAS,CAAC,SAAS,CAAC,mBAAmB,CACtC,uBAAuB,EACvB,MAAM,EACN,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,CACd,CAAC;YACH,CAAC,CAAC,CAAC;YACJ,MAAM;QACP;YACC,mBAAmB,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;gBACtC,IAAA,oBAAY,EAAC,MAAM,EAAE,CAAC,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,SAAS,CAAC,CAAC;gBACjF,IAAA,wBAAgB,EAAC,MAAM,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,SAAS,CAAC,CAAC;gBAClF,SAAS,CAAC,SAAS,CAAC,mBAAmB,CACtC,uBAAuB,EACvB,MAAM,EACN,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,CACd,CAAC;YACH,CAAC,CAAC,CAAC;YACH,MAAM;KACP;IACD,uBAAuB,CAAC,aAAa,IAAI,uBAAuB,CAAC,aAAa,CAAC;AAChF,CAAC,CAAC","sourcesContent":["import { CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { pickRandom } from '../services/utils';\r\nimport {\r\n\taddStatsToBoard,\r\n\tgetRandomAliveMinion,\r\n\tgetRandomMinionWithHighestHealth,\r\n\tgrantRandomDivineShield,\r\n\tgrantRandomStats,\r\n\tgrantStatsToMinionsOfEachType,\r\n\thasCorrectTribe,\r\n\tisMinionGolden,\r\n\tmakeMinionGolden,\r\n} from '../utils';\r\nimport { dealDamageToEnemy, getNeighbours } from './attack';\r\nimport { playBloodGemsOn } from './blood-gems';\r\nimport { addCardsInHand } from './cards-in-hand';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { performEntitySpawns } from './spawns';\r\nimport { afterStatsUpdate, modifyAttack, modifyHealth } from './stats';\r\n\r\nexport const applyAvengeEffects = (\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n): void => {\r\n\tconst candidatesEntitiesSpawnedFromAvenge: BoardEntity[] = [];\r\n\t// updateAvengeCounters(boardWithDeadEntity, boardWithDeadEntityHero);\r\n\tconst avengers = boardWithDeadEntity\r\n\t\t.filter((e) => !!e.avengeDefault && e.avengeCurrent <= 0)\r\n\t\t// Get Tony to be processed first, because of the \"when turned golden, the minion ignores the death for the avenge counter\"\r\n\t\t// behavior\r\n\t\t.sort((a, b) => {\r\n\t\t\tif (a.cardId === CardIds.TonyTwoTusk_BG21_031 || a.cardId === CardIds.TonyTwoTusk_BG21_031_G) {\r\n\t\t\t\treturn -1;\r\n\t\t\t}\r\n\t\t\tif (b.cardId === CardIds.TonyTwoTusk_BG21_031 || b.cardId === CardIds.TonyTwoTusk_BG21_031_G) {\r\n\t\t\t\treturn 1;\r\n\t\t\t}\r\n\t\t\treturn 0;\r\n\t\t});\r\n\tfor (const avenger of avengers) {\r\n\t\thandleAvenge(\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\tdeadEntity,\r\n\t\t\tdeadEntityIndexFromRight,\r\n\t\t\tavenger,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\t// console.log('updating dead entity avenge counter', boardWithDeadEntityHero.avengeCurrent, stringifySimpleCard(deadEntity, allCards));\r\n\tconst heroAvenger = !!boardWithDeadEntityHero.avengeDefault && boardWithDeadEntityHero.avengeCurrent <= 0;\r\n\tif (heroAvenger) {\r\n\t\t// console.log(\r\n\t\t// \t'Hero is an avenger',\r\n\t\t// \tboardWithDeadEntityHero.avengeCurrent,\r\n\t\t// \tboardWithDeadEntityHero.avengeDefault,\r\n\t\t// \tboardWithDeadEntityHero.heroPowerId,\r\n\t\t// );\r\n\t\thandleHeroAvenge(\r\n\t\t\tdeadEntity,\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tcandidatesEntitiesSpawnedFromAvenge,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\r\n\tconst questRewardAvengers = boardWithDeadEntityHero.questRewardEntities.filter(\r\n\t\t(e) => !!e.avengeDefault && e.avengeCurrent <= 0,\r\n\t);\r\n\tfor (const avenger of questRewardAvengers) {\r\n\t\thandleAvenge(\r\n\t\t\tboardWithDeadEntity,\r\n\t\t\tboardWithDeadEntityHero,\r\n\t\t\tdeadEntity,\r\n\t\t\tdeadEntityIndexFromRight,\r\n\t\t\tavenger as BoardEntity,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tgameState,\r\n\t\t);\r\n\t}\r\n\r\n\tperformEntitySpawns(\r\n\t\tcandidatesEntitiesSpawnedFromAvenge,\r\n\t\tboardWithDeadEntity,\r\n\t\tboardWithDeadEntityHero,\r\n\t\tdeadEntity,\r\n\t\tdeadEntityIndexFromRight,\r\n\t\totherBoard,\r\n\t\totherBoardHero,\r\n\t\tgameState,\r\n\t);\r\n};\r\n\r\nexport const updateAvengeCounters = (board: readonly BoardEntity[], boardWithDeadEntityHero: BgsPlayerEntity) => {\r\n\tfor (const entity of board) {\r\n\t\tif (!!entity.avengeDefault) {\r\n\t\t\tentity.avengeCurrent -= 1;\r\n\t\t}\r\n\t}\r\n\tif (!!boardWithDeadEntityHero.avengeDefault) {\r\n\t\tboardWithDeadEntityHero.avengeCurrent -= 1;\r\n\t}\r\n\r\n\tfor (const reward of boardWithDeadEntityHero.questRewardEntities) {\r\n\t\tif (!!reward.avengeDefault) {\r\n\t\t\treward.avengeCurrent -= 1;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleAvenge = (\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tdeadEntityIndexFromRight: number,\r\n\tavenger: BoardEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tgameState: FullGameState,\r\n) => {\r\n\t// Don't forget to update the avenge data in cards-data\r\n\tswitch (avenger.cardId) {\r\n\t\tcase CardIds.BirdBuddy_BG21_002:\r\n\t\t\taddStatsToBoard(avenger, boardWithDeadEntity, boardWithDeadEntityHero, 1, 1, gameState, 'BEAST');\r\n\t\t\tbreak;\r\n\t\tcase CardIds.BirdBuddy_BG21_002_G:\r\n\t\t\taddStatsToBoard(avenger, boardWithDeadEntity, boardWithDeadEntityHero, 2, 2, gameState, 'BEAST');\r\n\t\t\tbreak;\r\n\t\tcase CardIds.BuddingGreenthumb_BG21_030:\r\n\t\tcase CardIds.BuddingGreenthumb_BG21_030_G:\r\n\t\t\tconst neighbours = getNeighbours(boardWithDeadEntity, avenger);\r\n\t\t\tneighbours.forEach((entity) => {\r\n\t\t\t\tmodifyAttack(\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tavenger.cardId === CardIds.BuddingGreenthumb_BG21_030_G ? 4 : 2,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t\tmodifyHealth(\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tavenger.cardId === CardIds.BuddingGreenthumb_BG21_030_G ? 2 : 1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t\tafterStatsUpdate(entity, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tavenger,\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t\t\tbreak;\r\n\t\t// case CardIds.FrostwolfLieutenant:\r\n\t\t// case CardIds.FrostwolfLieutenantBattlegrounds:\r\n\t\t// \taddStatsToBoard(\r\n\t\t// \t\tavenger,\r\n\t\t// \t\tboardWithDeadEntity,\r\n\t\t// \t\tavenger.cardId === CardIds.FrostwolfLieutenantBattlegrounds ? 2 : 1,\r\n\t\t// \t\t0,\r\n\t\t// \t\tallCards,\r\n\t\t// \t\tspectator,\r\n\t\t// \t);\r\n\t\t// \tbreak;\r\n\t\tcase CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy:\r\n\t\tcase CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy_G:\r\n\t\t\t// Only for Tavern\r\n\t\t\t// addStatsToBoard(\r\n\t\t\t// \tavenger,\r\n\t\t\t// \tboardWithDeadEntity,\r\n\t\t\t// \t0,\r\n\t\t\t// \tavenger.cardId === CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy_G ? 2 : 1,\r\n\t\t\t// \tgameState.allCards,\r\n\t\t\t// \tgameState.spectator,\r\n\t\t\t// );\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PalescaleCrocolisk_BG21_001:\r\n\t\t\tconst target1 = grantRandomStats(\r\n\t\t\t\tavenger,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t6,\r\n\t\t\t\t6,\r\n\t\t\t\tRace.BEAST,\r\n\t\t\t\ttrue,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tif (!!target1) {\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tavenger,\r\n\t\t\t\t\ttarget1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PalescaleCrocolisk_BG21_001_G:\r\n\t\t\tconst target2 = grantRandomStats(\r\n\t\t\t\tavenger,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t12,\r\n\t\t\t\t12,\r\n\t\t\t\tRace.BEAST,\r\n\t\t\t\ttrue,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tif (!!target2) {\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tavenger,\r\n\t\t\t\t\ttarget2,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ImpatientDoomsayer_BG21_007:\r\n\t\tcase CardIds.ImpatientDoomsayer_BG21_007_G:\r\n\t\t\tconst doomsayerCardsToAddQuantity = avenger.cardId === CardIds.ImpatientDoomsayer_BG21_007_G ? 2 : 1;\r\n\t\t\tconst doomsayerCardsToAdd = [];\r\n\t\t\tfor (let i = 0; i < doomsayerCardsToAddQuantity; i++) {\r\n\t\t\t\tdoomsayerCardsToAdd.push(pickRandom(gameState.cardsData.demonSpawns));\r\n\t\t\t}\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, doomsayerCardsToAdd, gameState);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PashmarTheVengeful_BG23_014:\r\n\t\tcase CardIds.PashmarTheVengeful_BG23_014_G:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, [null], gameState);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.TremblingTrolley_BG28_967:\r\n\t\tcase CardIds.TremblingTrolley_BG28_967_G:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, [null], gameState);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.MysticSporebat_BG28_900:\r\n\t\tcase CardIds.MysticSporebat_BG28_900_G:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, [null], gameState);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.WitchwingNestmatron_BG21_038:\r\n\t\tcase CardIds.WitchwingNestmatron_BG21_038_G:\r\n\t\t\tconst nestmatronToAddQuantity = avenger.cardId === CardIds.WitchwingNestmatron_BG21_038_G ? 2 : 1;\r\n\t\t\tconst nestmatronCardsToAdd = [];\r\n\t\t\tfor (let i = 0; i < nestmatronToAddQuantity; i++) {\r\n\t\t\t\tnestmatronCardsToAdd.push(pickRandom(gameState.cardsData.brannEpicEggSpawns));\r\n\t\t\t}\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, nestmatronCardsToAdd, gameState);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Thorncaller_BG20_105:\r\n\t\tcase CardIds.Thorncaller_BG20_105_G:\r\n\t\t\tconst thorncallerToAddQuantity = avenger.cardId === CardIds.Thorncaller_BG20_105_G ? 2 : 1;\r\n\t\t\tconst thorncallerCardsToAdd = Array(thorncallerToAddQuantity).fill(CardIds.BloodGem);\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, thorncallerCardsToAdd, gameState);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Sisefin_BG21_009:\r\n\t\tcase CardIds.Sisefin_BG21_009_G:\r\n\t\t\tconst poisonousIterations = avenger.cardId === CardIds.Sisefin_BG21_009_G ? 2 : 1;\r\n\t\t\tfor (let i = 0; i < poisonousIterations; i++) {\r\n\t\t\t\tconst validTargets = boardWithDeadEntity.filter((e) => !e.poisonous && !e.venomous);\r\n\t\t\t\tconst murloc = getRandomAliveMinion(validTargets, Race.MURLOC, gameState.allCards);\r\n\t\t\t\tif (murloc) {\r\n\t\t\t\t\tmurloc.venomous = true;\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\tavenger,\r\n\t\t\t\t\t\tmurloc,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.MechanoTank_BG21_023:\r\n\t\t\t// This can be null if the avenge triggers when the last enemy minion dies as well\r\n\t\t\tconst target = getRandomMinionWithHighestHealth(otherBoard);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tavenger,\r\n\t\t\t\ttarget,\r\n\t\t\t\totherBoard,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t);\r\n\t\t\tdealDamageToEnemy(\r\n\t\t\t\ttarget,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tavenger,\r\n\t\t\t\t5,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.MechanoTank_BG21_023_G:\r\n\t\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\t\tconst target = getRandomMinionWithHighestHealth(otherBoard);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tavenger,\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t);\r\n\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tavenger,\r\n\t\t\t\t\t5,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.TonyTwoTusk_BG21_031:\r\n\t\t\tconst nonGoldenMinions = boardWithDeadEntity\r\n\t\t\t\t.filter((e) => e.entityId !== avenger.entityId)\r\n\t\t\t\t.filter((e) => {\r\n\t\t\t\t\tconst ref = gameState.allCards.getCard(e.cardId);\r\n\t\t\t\t\treturn (\r\n\t\t\t\t\t\t!!ref.battlegroundsPremiumDbfId &&\r\n\t\t\t\t\t\t!!gameState.allCards.getCardFromDbfId(ref.battlegroundsPremiumDbfId).id\r\n\t\t\t\t\t);\r\n\t\t\t\t});\r\n\t\t\tconst pirate = getRandomAliveMinion(nonGoldenMinions, Race.PIRATE, gameState.allCards);\r\n\t\t\tif (pirate) {\r\n\t\t\t\tmakeMinionGolden(pirate, avenger, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.TonyTwoTusk_BG21_031_G:\r\n\t\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\t\tconst nonGoldenMinions = boardWithDeadEntity.filter((e) => !isMinionGolden(e, gameState.allCards));\r\n\t\t\t\tconst pirate = getRandomAliveMinion(nonGoldenMinions, Race.PIRATE, gameState.allCards);\r\n\t\t\t\tif (pirate) {\r\n\t\t\t\t\tmakeMinionGolden(pirate, avenger, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.GhoulOfTheFeast_BG25_002:\r\n\t\tcase CardIds.GhoulOfTheFeast_BG25_002_G:\r\n\t\t\tconst ghoulMultiplier = avenger.cardId === CardIds.GhoulOfTheFeast_BG25_002_G ? 2 : 1;\r\n\t\t\tgrantStatsToMinionsOfEachType(\r\n\t\t\t\tavenger,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tghoulMultiplier * 3,\r\n\t\t\t\t0,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Bristlebach_BG26_157:\r\n\t\tcase CardIds.Bristlebach_BG26_157_G:\r\n\t\t\tconst bristlebachMultiplier = avenger.cardId === CardIds.Bristlebach_BG26_157_G ? 4 : 2;\r\n\t\t\tfor (let i = 0; i < bristlebachMultiplier; i++) {\r\n\t\t\t\tfor (const entity of boardWithDeadEntity) {\r\n\t\t\t\t\tif (hasCorrectTribe(entity, Race.QUILBOAR, gameState.allCards)) {\r\n\t\t\t\t\t\tplayBloodGemsOn(entity, 1, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\t\tavenger,\r\n\t\t\t\t\t\t\tentity,\r\n\t\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.HungeringAbomination_BG25_014:\r\n\t\tcase CardIds.HungeringAbomination_BG25_014_G:\r\n\t\t\tconst abominationMultiplier = avenger.cardId === CardIds.HungeringAbomination_BG25_014_G ? 2 : 1;\r\n\t\t\tmodifyAttack(avenger, abominationMultiplier * 1, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\tmodifyHealth(avenger, abominationMultiplier * 1, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\tafterStatsUpdate(avenger, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tavenger,\r\n\t\t\t\tavenger,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ShadowyConstruct_BG25_HERO_103_Buddy:\r\n\t\tcase CardIds.ShadowyConstruct_BG25_HERO_103_Buddy_G:\r\n\t\t\tconst neighboursShadowy = getNeighbours(boardWithDeadEntity, null, deadEntityIndexFromRight);\r\n\t\t\tconst multiplierShadowy = avenger.cardId === CardIds.ShadowyConstruct_BG25_HERO_103_Buddy_G ? 2 : 1;\r\n\t\t\tneighboursShadowy.forEach((neighbour) => {\r\n\t\t\t\tmodifyAttack(neighbour, multiplierShadowy * 1, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\tmodifyHealth(neighbour, multiplierShadowy * 1, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\tafterStatsUpdate(neighbour, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tavenger,\r\n\t\t\t\t\tneighbour,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.IceSickle:\r\n\t\t\tgrantRandomStats(\r\n\t\t\t\tavenger,\r\n\t\t\t\tboardWithDeadEntityHero.hand,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t4,\r\n\t\t\t\t0,\r\n\t\t\t\tnull,\r\n\t\t\t\ttrue,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.BoomSquad_BG27_Reward_502:\r\n\t\t\tconst highestHealthMinion = [...otherBoard].sort((a, b) => b.health - a.health)[0];\r\n\t\t\tdealDamageToEnemy(\r\n\t\t\t\thighestHealthMinion,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tavenger,\r\n\t\t\t\t10,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tgameState,\r\n\t\t\t);\r\n\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\tavenger,\r\n\t\t\t\thighestHealthMinion,\r\n\t\t\t\totherBoard,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.RelentlessSentry_BG25_003:\r\n\t\tcase CardIds.RelentlessSentry_BG25_003_G:\r\n\t\t\tavenger.reborn = true;\r\n\t\t\tavenger.taunt = true;\r\n\t\t\tbreak;\r\n\t\tcase CardIds.RelentlessMurghoul_BG27_010:\r\n\t\tcase CardIds.RelentlessMurghoul_BG27_010_G:\r\n\t\t\tavenger.reborn = true;\r\n\t\t\tbreak;\r\n\t\tcase CardIds.ChampionOfThePrimus_BG27_029:\r\n\t\tcase CardIds.ChampionOfThePrimus_BG27_029_G:\r\n\t\t\tconst championPrimusStat = avenger.cardId === CardIds.ChampionOfThePrimus_BG27_029_G ? 2 : 1;\r\n\t\t\tboardWithDeadEntityHero.globalInfo.UndeadAttackBonus += championPrimusStat;\r\n\t\t\taddStatsToBoard(\r\n\t\t\t\tavenger,\r\n\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\tchampionPrimusStat,\r\n\t\t\t\t0,\r\n\t\t\t\tgameState,\r\n\t\t\t\tRace[Race.UNDEAD],\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.PhaerixWrathOfTheSun_BG28_403:\r\n\t\tcase CardIds.PhaerixWrathOfTheSun_BG28_403_G:\r\n\t\t\tconst phaerixLoops = avenger.cardId === CardIds.PhaerixWrathOfTheSun_BG28_403_G ? 2 : 1;\r\n\t\t\tfor (let i = 0; i < phaerixLoops; i++) {\r\n\t\t\t\tgrantRandomDivineShield(avenger, boardWithDeadEntity, gameState.allCards, gameState.spectator);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.AugmentedLaborer_BG28_740:\r\n\t\tcase CardIds.AugmentedLaborer_BG28_740_G:\r\n\t\t\tconst AugmentedLaborerLoops = avenger.cardId === CardIds.AugmentedLaborer_BG28_740_G ? 2 : 1;\r\n\t\t\tfor (let i = 0; i < AugmentedLaborerLoops; i++) {\r\n\t\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, [null], gameState);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.TumblingDisaster_BG28_Reward_505:\r\n\t\t\tconst tumblingDisasterEntity = boardWithDeadEntityHero.questRewardEntities?.find(\r\n\t\t\t\t(e) => e.cardId === CardIds.TumblingDisaster_BG28_Reward_505,\r\n\t\t\t);\r\n\t\t\tif (tumblingDisasterEntity) {\r\n\t\t\t\ttumblingDisasterEntity.scriptDataNum1++;\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase CardIds.CycleOfEnergy_BG28_Reward_504:\r\n\t\t\taddCardsInHand(boardWithDeadEntityHero, boardWithDeadEntity, [null], gameState);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.StableAmalgamation_BG28_Reward_518:\r\n\t\t\tavenger.scriptDataNum1++;\r\n\t\t\tbreak;\r\n\t}\r\n\tavenger.avengeCurrent += avenger.avengeDefault;\r\n};\r\n\r\nconst handleHeroAvenge = (\r\n\tdeadEntity: BoardEntity,\r\n\tboardWithDeadEntity: BoardEntity[],\r\n\tboardWithDeadEntityHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tcandidatesEntitiesSpawnedFromAvenge: BoardEntity[],\r\n\tgameState: FullGameState,\r\n) => {\r\n\t// https://twitter.com/LoewenMitchell/status/1491879869457879040\r\n\t// Not affected by Khadgar\r\n\tswitch (boardWithDeadEntityHero?.heroPowerId) {\r\n\t\tcase CardIds.Onyxia_Broodmother:\r\n\t\t\tcandidatesEntitiesSpawnedFromAvenge.push(\r\n\t\t\t\t...spawnEntities(\r\n\t\t\t\t\tCardIds.Onyxia_OnyxianWhelpToken,\r\n\t\t\t\t\t1,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoard,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\tgameState.allCards,\r\n\t\t\t\t\tgameState.cardsData,\r\n\t\t\t\t\tgameState.sharedState,\r\n\t\t\t\t\tgameState.spectator,\r\n\t\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t),\r\n\t\t\t);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.VanndarStormpike_LeadTheStormpikes:\r\n\t\t\tboardWithDeadEntity\r\n\t\t\t\t// .filter((entity) => !entity.definitelyDead && entity.health > 0)\r\n\t\t\t\t.forEach((entity) => {\r\n\t\t\t\t\tmodifyHealth(entity, 1, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\t\tafterStatsUpdate(entity, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\tentity,\r\n\t\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\t\totherBoardHero,\r\n\t\t\t\t\t);\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Drekthar_LeadTheFrostwolves:\r\n\t\t\tboardWithDeadEntity.forEach((entity) => {\r\n\t\t\t\tmodifyAttack(entity, 1, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\tafterStatsUpdate(entity, boardWithDeadEntity, boardWithDeadEntityHero, gameState);\r\n\t\t\t\tgameState.spectator.registerPowerTarget(\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tboardWithDeadEntity,\r\n\t\t\t\t\tboardWithDeadEntityHero,\r\n\t\t\t\t\totherBoardHero,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t\t\tbreak;\r\n\t}\r\n\tboardWithDeadEntityHero.avengeCurrent += boardWithDeadEntityHero.avengeDefault;\r\n};\r\n"]}
@@ -85,12 +85,12 @@ class Spectator {
85
85
  opponentHand: this.sanitize(opponentHero.hand),
86
86
  playerSecrets: (playerSecrets !== null && playerSecrets !== void 0 ? playerSecrets : []).filter((s) => !s.triggered),
87
87
  opponentSecrets: (opponentSecrets !== null && opponentSecrets !== void 0 ? opponentSecrets : []).filter((s) => !s.triggered),
88
- playerRewardCardId: (_c = (_b = (_a = playerHero.questRewardEntities) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.cardId) !== null && _c !== void 0 ? _c : (_d = playerHero.questRewards) === null || _d === void 0 ? void 0 : _d[0],
89
- playerRewardEntityId: (_f = (_e = playerHero.questRewardEntities) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.entityId,
90
- playerRewardData: (_h = (_g = playerHero.questRewardEntities) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.scriptDataNum1,
91
- opponentRewardCardId: (_l = (_k = (_j = opponentHero.questRewardEntities) === null || _j === void 0 ? void 0 : _j[0]) === null || _k === void 0 ? void 0 : _k.cardId) !== null && _l !== void 0 ? _l : (_m = opponentHero.questRewards) === null || _m === void 0 ? void 0 : _m[0],
92
- opponentRewardEntityId: (_p = (_o = opponentHero.questRewardEntities) === null || _o === void 0 ? void 0 : _o[0]) === null || _p === void 0 ? void 0 : _p.entityId,
93
- opponentRewardData: (_r = (_q = opponentHero.questRewardEntities) === null || _q === void 0 ? void 0 : _q[0]) === null || _r === void 0 ? void 0 : _r.scriptDataNum1,
88
+ playerRewardCardId: (_c = (_b = (_a = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewardEntities) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.cardId) !== null && _c !== void 0 ? _c : (_d = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewards) === null || _d === void 0 ? void 0 : _d[0],
89
+ playerRewardEntityId: (_f = (_e = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewardEntities) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.entityId,
90
+ playerRewardData: (_h = (_g = playerHero === null || playerHero === void 0 ? void 0 : playerHero.questRewardEntities) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.scriptDataNum1,
91
+ opponentRewardCardId: (_l = (_k = (_j = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewardEntities) === null || _j === void 0 ? void 0 : _j[0]) === null || _k === void 0 ? void 0 : _k.cardId) !== null && _l !== void 0 ? _l : (_m = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewards) === null || _m === void 0 ? void 0 : _m[0],
92
+ opponentRewardEntityId: (_p = (_o = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewardEntities) === null || _o === void 0 ? void 0 : _o[0]) === null || _p === void 0 ? void 0 : _p.entityId,
93
+ opponentRewardData: (_r = (_q = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewardEntities) === null || _q === void 0 ? void 0 : _q[0]) === null || _r === void 0 ? void 0 : _r.scriptDataNum1,
94
94
  };
95
95
  this.addAction(action);
96
96
  }
@@ -211,12 +211,12 @@ class Spectator {
211
211
  opponentHand: this.sanitize(opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.hand),
212
212
  playerSecrets: ((_a = friendlyHero === null || friendlyHero === void 0 ? void 0 : friendlyHero.secrets) !== null && _a !== void 0 ? _a : []).filter((s) => !s.triggered),
213
213
  opponentSecrets: ((_b = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.secrets) !== null && _b !== void 0 ? _b : []).filter((s) => !s.triggered),
214
- playerRewardCardId: (_e = (_d = (_c = friendlyHero.questRewardEntities) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.cardId) !== null && _e !== void 0 ? _e : (_f = friendlyHero.questRewards) === null || _f === void 0 ? void 0 : _f[0],
215
- playerRewardEntityId: (_h = (_g = friendlyHero.questRewardEntities) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.entityId,
216
- playerRewardData: (_k = (_j = friendlyHero.questRewardEntities) === null || _j === void 0 ? void 0 : _j[0]) === null || _k === void 0 ? void 0 : _k.scriptDataNum1,
217
- opponentRewardCardId: (_o = (_m = (_l = opponentHero.questRewardEntities) === null || _l === void 0 ? void 0 : _l[0]) === null || _m === void 0 ? void 0 : _m.cardId) !== null && _o !== void 0 ? _o : (_p = opponentHero.questRewards) === null || _p === void 0 ? void 0 : _p[0],
218
- opponentRewardEntityId: (_r = (_q = opponentHero.questRewardEntities) === null || _q === void 0 ? void 0 : _q[0]) === null || _r === void 0 ? void 0 : _r.entityId,
219
- opponentRewardData: (_t = (_s = opponentHero.questRewardEntities) === null || _s === void 0 ? void 0 : _s[0]) === null || _t === void 0 ? void 0 : _t.scriptDataNum1,
214
+ playerRewardCardId: (_e = (_d = (_c = friendlyHero === null || friendlyHero === void 0 ? void 0 : friendlyHero.questRewardEntities) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.cardId) !== null && _e !== void 0 ? _e : (_f = friendlyHero === null || friendlyHero === void 0 ? void 0 : friendlyHero.questRewards) === null || _f === void 0 ? void 0 : _f[0],
215
+ playerRewardEntityId: (_h = (_g = friendlyHero === null || friendlyHero === void 0 ? void 0 : friendlyHero.questRewardEntities) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.entityId,
216
+ playerRewardData: (_k = (_j = friendlyHero === null || friendlyHero === void 0 ? void 0 : friendlyHero.questRewardEntities) === null || _j === void 0 ? void 0 : _j[0]) === null || _k === void 0 ? void 0 : _k.scriptDataNum1,
217
+ opponentRewardCardId: (_o = (_m = (_l = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewardEntities) === null || _l === void 0 ? void 0 : _l[0]) === null || _m === void 0 ? void 0 : _m.cardId) !== null && _o !== void 0 ? _o : (_p = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewards) === null || _p === void 0 ? void 0 : _p[0],
218
+ opponentRewardEntityId: (_r = (_q = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewardEntities) === null || _q === void 0 ? void 0 : _q[0]) === null || _r === void 0 ? void 0 : _r.entityId,
219
+ opponentRewardData: (_t = (_s = opponentHero === null || opponentHero === void 0 ? void 0 : opponentHero.questRewardEntities) === null || _s === void 0 ? void 0 : _s[0]) === null || _t === void 0 ? void 0 : _t.scriptDataNum1,
220
220
  };
221
221
  this.addAction(action);
222
222
  }
@@ -1 +1 @@
1
- {"version":3,"file":"spectator.js","sourceRoot":"","sources":["../../../src/simulation/spectator/spectator.ts"],"names":[],"mappings":";;;AAOA,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,MAAa,SAAS;IAiBrB,YAAY,WAA0B;QACrC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC;QAC1D,IAAI,CAAC,qBAAqB,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC;QACxE,IAAI,CAAC,mBAAmB,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,aAAa,CAAC;QACxE,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC;QAC9D,IAAI,CAAC,uBAAuB,GAAG,WAAW,CAAC,aAAa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cesContent":["import { BgsPlayerEntity } from 'src/bgs-player-entity';\r\nimport { BgsBattleInfo } from '../../bgs-battle-info';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { BoardSecret } from '../../board-secret';\r\nimport { GameAction } from './game-action';\r\nimport { GameSample } from './game-sample';\r\n\r\nconst MAX_SAMPLES = 1;\r\n\r\nexport class Spectator {\r\n\tprivate actionsForCurrentBattle: GameAction[];\r\n\tprivate wonBattles: GameSample[];\r\n\tprivate tiedBattles: GameSample[];\r\n\tprivate lostBattles: GameSample[];\r\n\r\n\tprivate readonly playerCardId?: string;\r\n\tprivate readonly playerHeroPowerCardId: string;\r\n\tprivate readonly playerHeroPowerUsed: boolean;\r\n\t// private readonly playerRewardCardId: string;\r\n\t// private readonly playerRewardData: number;\r\n\tprivate readonly opponentCardId: string;\r\n\tprivate readonly opponentHeroPowerCardId: string;\r\n\tprivate readonly opponentHeroPowerUsed: boolean;\r\n\t// private readonly opponentRewardCardId: string;\r\n\t// private readonly opponentRewardData: number;\r\n\r\n\tconstructor(battleInput: BgsBattleInfo) {\r\n\t\tthis.playerCardId = battleInput.playerBoard.player.cardId;\r\n\t\tthis.playerHeroPowerCardId = battleInput.playerBoard.player.heroPowerId;\r\n\t\tthis.playerHeroPowerUsed = battleInput.playerBoard.player.heroPowerUsed;\r\n\t\tthis.opponentCardId = battleInput.opponentBoard.player.cardId;\r\n\t\tthis.opponentHeroPowerCardId = battleInput.opponentBoard.player.heroPowerId;\r\n\t\tthis.opponentHeroPowerUsed = battleInput.opponentBoard.player.heroPowerUsed;\r\n\r\n\t\tthis.actionsForCurrentBattle = [];\r\n\t\tthis.wonBattles = [];\r\n\t\tthis.tiedBattles = [];\r\n\t\tthis.lostBattles = [];\r\n\t}\r\n\r\n\tpublic prune(): void {\r\n\t\tthis.wonBattles = this.wonBattles.slice(0, MAX_SAMPLES);\r\n\t\tthis.lostBattles = this.lostBattles.slice(0, MAX_SAMPLES);\r\n\t\tthis.tiedBattles = this.tiedBattles.slice(0, MAX_SAMPLES);\r\n\t}\r\n\r\n\tpublic buildOutcomeSamples(): {\r\n\t\twon: readonly GameSample[];\r\n\t\tlost: readonly GameSample[];\r\n\t\ttied: readonly GameSample[];\r\n\t} {\r\n\t\treturn {\r\n\t\t\twon: this.wonBattles?.map((battle) => this.cleanUpActions(battle)),\r\n\t\t\tlost: this.lostBattles?.map((battle) => this.cleanUpActions(battle)),\r\n\t\t\ttied: this.tiedBattles?.map((battle) => this.cleanUpActions(battle)),\r\n\t\t};\r\n\t}\r\n\r\n\tprivate cleanUpActions(battle: GameSample): GameSample {\r\n\t\tconst collapsed = this.collapseActions(battle.actions);\r\n\t\tconst result: GameSample = {\r\n\t\t\t...battle,\r\n\t\t\tactions: collapsed,\r\n\t\t};\r\n\t\treturn result;\r\n\t}\r\n\r\n\tpublic commitBattleResult(result: 'won' | 'lost' | 'tied'): void {\r\n\t\tif (\r\n\t\t\tthis.wonBattles.length >= MAX_SAMPLES &&\r\n\t\t\tthis.lostBattles.length >= MAX_SAMPLES &&\r\n\t\t\tthis.tiedBattles.length >= MAX_SAMPLES\r\n\t\t) {\r\n\t\t\tthis.actionsForCurrentBattle = [];\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// const actionsForBattle = this.collapseActions(this.actionsForCurrentBattle);\r\n\t\tconst actionsForBattle = this.actionsForCurrentBattle;\r\n\t\tthis.actionsForCurrentBattle = [];\r\n\r\n\t\tconst battle: GameSample = {\r\n\t\t\tactions: actionsForBattle,\r\n\t\t\tplayerCardId: this.playerCardId,\r\n\t\t\tplayerHeroPowerCardId: this.playerHeroPowerCardId,\r\n\t\t\tplayerHeroPowerUsed: this.playerHeroPowerUsed,\r\n\t\t\t// playerRewardCardId: this.playerRewardCardId,\r\n\t\t\t// playerRewardData: this.playerRewardData,\r\n\t\t\topponentCardId: this.opponentCardId,\r\n\t\t\topponentHeroPowerCardId: this.opponentHeroPowerCardId,\r\n\t\t\topponentHeroPowerUsed: this.opponentHeroPowerUsed,\r\n\t\t\t// opponentRewardCardId: this.opponentRewardCardId,\r\n\t\t\t// opponentRewardData: this.opponentRewardData,\r\n\t\t};\r\n\t\tswitch (result) {\r\n\t\t\tcase 'won':\r\n\t\t\t\tthis.wonBattles.push(battle);\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'lost':\r\n\t\t\t\tthis.lostBattles.push(battle);\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'tied':\r\n\t\t\t\tthis.tiedBattles.push(battle);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic registerAttack(\r\n\t\tattackingEntity: BoardEntity,\r\n\t\tdefendingEntity: BoardEntity,\r\n\t\tattackingBoard: readonly BoardEntity[],\r\n\t\tdefendingBoard: readonly BoardEntity[],\r\n\t\tattackingBoardHero: BgsPlayerEntity,\r\n\t\tdefendingBoardHero: BgsPlayerEntity,\r\n\t): void {\r\n\t\t// console.debug(\r\n\t\t// \t'\\n register attack',\r\n\t\t// \tstringifySimple(attackingBoard),\r\n\t\t// \t'\\n',\r\n\t\t// \tstringifySimple(defendingBoard),\r\n\t\t// \t'\\n',\r\n\t\t// \tattackingBoard.find((e) => e.entityId === 2441),\r\n\t\t// \t'\\n',\r\n\t\t// \tattackingBoard.find((e) => e.entityId === 2442),\r\n\t\t// );\r\n\t\tconst isAttackerFriendly = attackingBoard.every((entity) => entity.friendly);\r\n\t\tconst friendlyBoard = isAttackerFriendly ? attackingBoard : defendingBoard;\r\n\t\tconst opponentBoard = isAttackerFriendly ? defendingBoard : attackingBoard;\r\n\t\tconst playerSecrets = isAttackerFriendly ? attackingBoardHero.secrets : defendingBoardHero.secrets;\r\n\t\tconst opponentSecrets = isAttackerFriendly ? defendingBoardHero.secrets : attackingBoardHero.secrets;\r\n\t\tconst playerHero = isAttackerFriendly ? attackingBoardHero : defendingBoardHero;\r\n\t\tconst opponentHero = isAttackerFriendly ? defendingBoardHero : attackingBoardHero;\r\n\t\tconst action: GameAction = {\r\n\t\t\ttype: 'attack',\r\n\t\t\tsourceEntityId: attackingEntity.entityId,\r\n\t\t\ttargetEntityId: defendingEntity.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\tplayerHand: this.sanitize(playerHero.hand),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\topponentHand: this.sanitize(opponentHero.hand),\r\n\t\t\tplayerSecrets: (playerSecrets ?? []).filter((s) => !s.triggered),\r\n\t\t\topponentSecrets: (opponentSecrets ?? []).filter((s) => !s.triggered),\r\n\r\n\t\t\tplayerRewardCardId: playerHero.questRewardEntities?.[0]?.cardId ?? playerHero.questRewards?.[0],\r\n\t\t\tplayerRewardEntityId: playerHero.questRewardEntities?.[0]?.entityId,\r\n\t\t\tplayerRewardData: playerHero.questRewardEntities?.[0]?.scriptDataNum1,\r\n\t\t\topponentRewardCardId: opponentHero.questRewardEntities?.[0]?.cardId ?? opponentHero.questRewards?.[0],\r\n\t\t\topponentRewardEntityId: opponentHero.questRewardEntities?.[0]?.entityId,\r\n\t\t\topponentRewardData: opponentHero.questRewardEntities?.[0]?.scriptDataNum1,\r\n\t\t};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerStartOfCombat(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tfriendlyHero: BgsPlayerEntity,\r\n\t\topponentHero: BgsPlayerEntity,\r\n\t): void {\r\n\t\tconst playerSecrets = friendlyHero.secrets;\r\n\t\tconst opponentSecrets = opponentHero.secrets;\r\n\t\tconst action: GameAction = {\r\n\t\t\ttype: 'start-of-combat',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: this.sanitize(friendlyHero.hand),\r\n\t\t\topponentHand: this.sanitize(opponentHero.hand),\r\n\t\t\tplayerSecrets: playerSecrets ?? [],\r\n\t\t\topponentSecrets: opponentSecrets ?? [],\r\n\t\t\tplayerRewardCardId: friendlyHero.questRewardEntities?.[0]?.cardId ?? friendlyHero.questRewards?.[0],\r\n\t\t\tplayerRewardEntityId: friendlyHero.questRewardEntities?.[0]?.entityId,\r\n\t\t\tplayerRewardData: friendlyHero.questRewardEntities?.[0]?.scriptDataNum1,\r\n\t\t\topponentRewardCardId: opponentHero.questRewardEntities?.[0]?.cardId ?? opponentHero.questRewards?.[0],\r\n\t\t\topponentRewardEntityId: opponentHero.questRewardEntities?.[0]?.entityId,\r\n\t\t\topponentRewardData: opponentHero.questRewardEntities?.[0]?.scriptDataNum1,\r\n\t\t};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerPlayerAttack(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tdamage: number,\r\n\t): void {\r\n\t\tconst action: GameAction = {\r\n\t\t\ttype: 'player-attack',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tplayerSecrets: null,\r\n\t\t\topponentSecrets: null,\r\n\t\t\tplayerRewardCardId: null,\r\n\t\t\tplayerRewardEntityId: null,\r\n\t\t\tplayerRewardData: null,\r\n\t\t\topponentRewardCardId: null,\r\n\t\t\topponentRewardEntityId: null,\r\n\t\t\topponentRewardData: null,\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tdamage: damage,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerOpponentAttack(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tdamage: number,\r\n\t): void {\r\n\t\tconst action: GameAction = {\r\n\t\t\ttype: 'opponent-attack',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tplayerSecrets: null,\r\n\t\t\topponentSecrets: null,\r\n\t\t\tplayerRewardCardId: null,\r\n\t\t\tplayerRewardEntityId: null,\r\n\t\t\tplayerRewardData: null,\r\n\t\t\topponentRewardCardId: null,\r\n\t\t\topponentRewardEntityId: null,\r\n\t\t\topponentRewardData: null,\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tdamage: damage,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerDamageDealt(\r\n\t\tdamagingEntity: BoardEntity,\r\n\t\tdamagedEntity: BoardEntity,\r\n\t\tdamageTaken: number,\r\n\t\tdamagedEntityBoard: BoardEntity[],\r\n\t): void {\r\n\t\tif (!damagingEntity.entityId) {\r\n\t\t\t// console.error('missing damaging entity id', damagingEntity.cardId);\r\n\t\t}\r\n\t\tconst friendlyBoard = damagedEntityBoard.every((entity) => entity.friendly) ? damagedEntityBoard : null;\r\n\t\tconst opponentBoard = damagedEntityBoard.every((entity) => !entity.friendly) ? damagedEntityBoard : null;\r\n\t\tconst action: GameAction = {\r\n\t\t\ttype: 'damage',\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tsourceEntityId: damagingEntity.entityId,\r\n\t\t\t\t\ttargetEntityId: damagedEntity.entityId,\r\n\t\t\t\t\tdamage: damageTaken,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tplayerSecrets: null,\r\n\t\t\topponentSecrets: null,\r\n\t\t\tplayerRewardCardId: null,\r\n\t\t\tplayerRewardEntityId: null,\r\n\t\t\tplayerRewardData: null,\r\n\t\t\topponentRewardCardId: null,\r\n\t\t\topponentRewardEntityId: null,\r\n\t\t\topponentRewardData: null,\r\n\t\t};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerPowerTarget(\r\n\t\tsourceEntity: BoardEntity | BgsPlayerEntity | BoardSecret,\r\n\t\ttargetEntity: BoardEntity | BgsPlayerEntity,\r\n\t\ttargetBoard: BoardEntity[],\r\n\t\thero1: BgsPlayerEntity,\r\n\t\thero2: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!targetEntity) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!sourceEntity.entityId && !(sourceEntity as BgsPlayerEntity).heroPowerId) {\r\n\t\t\t// console.error('missing damaging entity id', sourceEntity.cardId);\r\n\t\t}\r\n\t\t// console.log('registerPowerTarget', stringifySimpleCard(sourceEntity), stringifySimpleCard(targetEntity), new Error().stack);\r\n\t\tconst friendlyBoard = targetBoard?.every((entity) => entity.friendly) ? targetBoard : null;\r\n\t\tconst opponentBoard = targetBoard?.every((entity) => !entity.friendly) ? targetBoard : null;\r\n\t\tconst friendlyHero = hero1?.friendly ? hero1 : hero2?.friendly ? hero2 : null;\r\n\t\tconst opponentHero = hero1?.friendly ? hero2 : hero2?.friendly ? hero1 : null;\r\n\t\tconst action: GameAction = {\r\n\t\t\ttype: 'power-target',\r\n\t\t\tsourceEntityId: sourceEntity.entityId,\r\n\t\t\ttargetEntityId: targetEntity.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: this.sanitize(friendlyHero?.hand),\r\n\t\t\topponentHand: this.sanitize(opponentHero?.hand),\r\n\t\t\tplayerSecrets: (friendlyHero?.secrets ?? []).filter((s) => !s.triggered),\r\n\t\t\topponentSecrets: (opponentHero?.secrets ?? []).filter((s) => !s.triggered),\r\n\t\t\tplayerRewardCardId: friendlyHero.questRewardEntities?.[0]?.cardId ?? friendlyHero.questRewards?.[0],\r\n\t\t\tplayerRewardEntityId: friendlyHero.questRewardEntities?.[0]?.entityId,\r\n\t\t\tplayerRewardData: friendlyHero.questRewardEntities?.[0]?.scriptDataNum1,\r\n\t\t\topponentRewardCardId: opponentHero.questRewardEntities?.[0]?.cardId ?? opponentHero.questRewards?.[0],\r\n\t\t\topponentRewardEntityId: opponentHero.questRewardEntities?.[0]?.entityId,\r\n\t\t\topponentRewardData: opponentHero.questRewardEntities?.[0]?.scriptDataNum1,\r\n\t\t};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerMinionsSpawn(\r\n\t\tsourceEntity: BoardEntity | BgsPlayerEntity,\r\n\t\tboardOnWhichToSpawn: BoardEntity[],\r\n\t\tspawnedEntities: readonly BoardEntity[],\r\n\t): void {\r\n\t\tif (!spawnedEntities || spawnedEntities.length === 0) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (!sourceEntity.entityId) {\r\n\t\t\tconsole.error('missing spawn source entity id', sourceEntity);\r\n\t\t}\r\n\t\tconst friendlyBoard = boardOnWhichToSpawn.every((entity) => entity.friendly) ? boardOnWhichToSpawn : null;\r\n\t\tconst opponentBoard = boardOnWhichToSpawn.every((entity) => !entity.friendly) ? boardOnWhichToSpawn : null;\r\n\t\tconst action: GameAction = {\r\n\t\t\ttype: 'spawn',\r\n\t\t\tspawns: this.sanitize(spawnedEntities),\r\n\t\t\tsourceEntityId: sourceEntity?.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tplayerSecrets: null,\r\n\t\t\topponentSecrets: null,\r\n\t\t\tplayerRewardCardId: null,\r\n\t\t\tplayerRewardEntityId: null,\r\n\t\t\tplayerRewardData: null,\r\n\t\t\topponentRewardCardId: null,\r\n\t\t\topponentRewardEntityId: null,\r\n\t\t\topponentRewardData: null,\r\n\t\t};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerDeadEntities(\r\n\t\tdeadMinionIndexes1: number[],\r\n\t\tdeadEntities1: BoardEntity[],\r\n\t\tboard1: BoardEntity[],\r\n\t\tdeadMinionIndexes2: number[],\r\n\t\tdeadEntities2: BoardEntity[],\r\n\t\tboard2: BoardEntity[],\r\n\t): void {\r\n\t\tconst deaths = [...(deadEntities1 || []), ...(deadEntities2 || [])];\r\n\t\tif (!deaths || deaths.length === 0) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = {\r\n\t\t\ttype: 'minion-death',\r\n\t\t\tdeaths: this.sanitize(deaths),\r\n\t\t\tdeadMinionsPositionsOnBoard: [\r\n\t\t\t\t...(deadMinionIndexes1 || []).map((i) => board1.length - i),\r\n\t\t\t\t...(deadMinionIndexes2 || []).map((i) => board2.length - i),\r\n\t\t\t],\r\n\t\t\tplayerBoard: undefined,\r\n\t\t\topponentBoard: undefined,\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tplayerSecrets: null,\r\n\t\t\topponentSecrets: null,\r\n\t\t\tplayerRewardCardId: null,\r\n\t\t\tplayerRewardEntityId: null,\r\n\t\t\tplayerRewardData: null,\r\n\t\t\topponentRewardCardId: null,\r\n\t\t\topponentRewardEntityId: null,\r\n\t\t\topponentRewardData: null,\r\n\t\t};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tprivate addAction(action: GameAction) {\r\n\t\tthis.actionsForCurrentBattle.push(action);\r\n\t}\r\n\r\n\tprivate collapseActions(actions: readonly GameAction[]): readonly GameAction[] {\r\n\t\tif (!actions || actions.length === 0) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\t\tconst result: GameAction[] = [];\r\n\t\tfor (let i = 0; i < actions.length; i++) {\r\n\t\t\tconst action: GameAction = {\r\n\t\t\t\t...actions[i],\r\n\t\t\t\tplayerBoard: this.sanitize(actions[i].playerBoard),\r\n\t\t\t\topponentBoard: this.sanitize(actions[i].opponentBoard),\r\n\t\t\t\tplayerHand: this.sanitize(actions[i].playerHand),\r\n\t\t\t\topponentHand: this.sanitize(actions[i].opponentHand),\r\n\t\t\t\t// spawns: this.sanitize(actions[i].spawns),\r\n\t\t\t\tdeaths: this.sanitize(actions[i].deaths),\r\n\t\t\t};\r\n\t\t\t// action.playerBoard && console.debug('\\naction playerboard', stringifySimple(action.playerBoard));\r\n\t\t\tconst lastAction = result.length > 0 ? result[result.length - 1] : null;\r\n\r\n\t\t\tif (lastAction && !action.playerBoard) {\r\n\t\t\t\taction.playerBoard = lastAction.playerBoard;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.opponentBoard) {\r\n\t\t\t\taction.opponentBoard = lastAction.opponentBoard;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.playerHand) {\r\n\t\t\t\taction.playerHand = lastAction.playerHand;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.opponentHand) {\r\n\t\t\t\taction.opponentHand = lastAction.opponentHand;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.playerSecrets) {\r\n\t\t\t\taction.playerSecrets = lastAction.playerSecrets;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.opponentSecrets) {\r\n\t\t\t\taction.opponentSecrets = lastAction.opponentSecrets;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.playerRewardCardId) {\r\n\t\t\t\taction.playerRewardCardId = lastAction.playerRewardCardId;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.playerRewardEntityId) {\r\n\t\t\t\taction.playerRewardEntityId = lastAction.playerRewardEntityId;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.playerRewardData) {\r\n\t\t\t\taction.playerRewardData = lastAction.playerRewardData;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.opponentRewardCardId) {\r\n\t\t\t\taction.opponentRewardCardId = lastAction.opponentRewardCardId;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.opponentRewardEntityId) {\r\n\t\t\t\taction.opponentRewardEntityId = lastAction.opponentRewardEntityId;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.opponentRewardData) {\r\n\t\t\t\taction.opponentRewardData = lastAction.opponentRewardData;\r\n\t\t\t}\r\n\r\n\t\t\tif (lastAction && action.type === 'damage' && lastAction.type === 'attack') {\r\n\t\t\t\tlastAction.damages = lastAction.damages || [];\r\n\t\t\t\tlastAction.damages.push({\r\n\t\t\t\t\tdamage: action.damages[0].damage,\r\n\t\t\t\t\tsourceEntityId: action.damages[0].sourceEntityId,\r\n\t\t\t\t\ttargetEntityId: action.damages[0].targetEntityId,\r\n\t\t\t\t});\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t} else if (lastAction && action.type === 'damage' && lastAction.type === 'damage') {\r\n\t\t\t\tlastAction.damages = lastAction.damages || [];\r\n\t\t\t\tlastAction.damages.push({\r\n\t\t\t\t\tdamage: action.damages[0].damage,\r\n\t\t\t\t\tsourceEntityId: action.damages[0].sourceEntityId,\r\n\t\t\t\t\ttargetEntityId: action.damages[0].targetEntityId,\r\n\t\t\t\t});\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t} else if (\r\n\t\t\t\tlastAction &&\r\n\t\t\t\taction.type === 'power-target' &&\r\n\t\t\t\tlastAction.type === 'power-target' &&\r\n\t\t\t\taction.sourceEntityId === lastAction.sourceEntityId\r\n\t\t\t) {\r\n\t\t\t\tlastAction.targetEntityIds =\r\n\t\t\t\t\tlastAction.targetEntityIds ?? (lastAction.targetEntityId ? [lastAction.targetEntityId] : []);\r\n\t\t\t\taction.targetEntityIds =\r\n\t\t\t\t\taction.targetEntityIds ?? (action.targetEntityId ? [action.targetEntityId] : []);\r\n\t\t\t\tlastAction.targetEntityIds.push(...action.targetEntityIds);\r\n\t\t\t\t// So that when multiple Leapfroggers enchantments target the same minion,\r\n\t\t\t\t// we can count them in the replay viewer's text\r\n\t\t\t\t// lastAction.targetEntityIds = [...new Set(lastAction.targetEntityIds)];\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t} else {\r\n\t\t\t\tresult.push(action);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\t// Calling sanitize every time before we add an action to the list is mandatory, since\r\n\t// the entities and boards are mutable\r\n\tprivate sanitize(board: readonly BoardEntity[]): readonly BoardEntity[] {\r\n\t\tif (!board) {\r\n\t\t\treturn undefined;\r\n\t\t}\r\n\t\treturn board.map(\r\n\t\t\t(entity) =>\r\n\t\t\t\t({\r\n\t\t\t\t\tentityId: entity.entityId,\r\n\t\t\t\t\tcardId: entity.cardId,\r\n\t\t\t\t\tfriendly: entity.friendly,\r\n\t\t\t\t\tattack: entity.attack,\r\n\t\t\t\t\thealth: entity.health,\r\n\t\t\t\t\tmaxHealth: entity.maxHealth,\r\n\t\t\t\t\ttaunt: entity.taunt,\r\n\t\t\t\t\tdivineShield: entity.divineShield,\r\n\t\t\t\t\tpoisonous: entity.poisonous,\r\n\t\t\t\t\tvenomous: entity.venomous,\r\n\t\t\t\t\treborn: entity.reborn,\r\n\t\t\t\t\twindfury: entity.windfury,\r\n\t\t\t\t\tstealth: entity.stealth,\r\n\t\t\t\t} as BoardEntity),\r\n\t\t);\r\n\t\t// return board.map(\r\n\t\t// \t(entity) =>\r\n\t\t// \t\t({\r\n\t\t// \t\t\t...entity,\r\n\t\t// \t\t\tenchantments: undefined,\r\n\t\t// \t\t\tcantAttack: undefined,\r\n\t\t// \t\t\thasAttacked: undefined,\r\n\t\t// \t\t\tattackImmediately: undefined,\r\n\t\t// \t\t\tpreviousAttack: undefined,\r\n\t\t// \t\t\tlastAffectedByEntity: undefined,\r\n\t\t// \t\t\tattacking: undefined,\r\n\t\t// \t\t} as BoardEntity),\r\n\t\t// );\r\n\t}\r\n}\r\n"]}
1
+ {"version":3,"file":"spectator.js","sourceRoot":"","sources":["../../../src/simulation/spectator/spectator.ts"],"names":[],"mappings":";;;AAOA,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,MAAa,SAAS;IAiBrB,YAAY,WAA0B;QACrC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC;QAC1D,IAAI,CAAC,qBAAqB,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC;QACxE,IAAI,CAAC,mBAAmB,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,aAAa,CAAC;QACxE,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC;QAC9D,IAAI,CAAC,uBAAuB,GAAG,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC;QAC5E,IAAI,CAAC,qBAAqB,GAAG,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,aAAa,CAAC;QAE5E,IAAI,CAAC,uBAAuB,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,EAAE,CAA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AAE,MAAM,CAAC,QAAQ;YACzB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,OAAO,EAAE,MAAM,CAAC,OAAO;SACP,CAAA,CAClB,CAAC;IAcH,CAAC;CACD;AAvgBD,8BAugBC","sourcesContent":["import { BgsPlayerEntity } from 'src/bgs-player-entity';\r\nimport { BgsBattleInfo } from '../../bgs-battle-info';\r\nimport { BoardEntity } from '../../board-entity';\r\nimport { BoardSecret } from '../../board-secret';\r\nimport { GameAction } from './game-action';\r\nimport { GameSample } from './game-sample';\r\n\r\nconst MAX_SAMPLES = 1;\r\n\r\nexport class Spectator {\r\n\tprivate actionsForCurrentBattle: GameAction[];\r\n\tprivate wonBattles: GameSample[];\r\n\tprivate tiedBattles: GameSample[];\r\n\tprivate lostBattles: GameSample[];\r\n\r\n\tprivate readonly playerCardId?: string;\r\n\tprivate readonly playerHeroPowerCardId: string;\r\n\tprivate readonly playerHeroPowerUsed: boolean;\r\n\t// private readonly playerRewardCardId: string;\r\n\t// private readonly playerRewardData: number;\r\n\tprivate readonly opponentCardId: string;\r\n\tprivate readonly opponentHeroPowerCardId: string;\r\n\tprivate readonly opponentHeroPowerUsed: boolean;\r\n\t// private readonly opponentRewardCardId: string;\r\n\t// private readonly opponentRewardData: number;\r\n\r\n\tconstructor(battleInput: BgsBattleInfo) {\r\n\t\tthis.playerCardId = battleInput.playerBoard.player.cardId;\r\n\t\tthis.playerHeroPowerCardId = battleInput.playerBoard.player.heroPowerId;\r\n\t\tthis.playerHeroPowerUsed = battleInput.playerBoard.player.heroPowerUsed;\r\n\t\tthis.opponentCardId = battleInput.opponentBoard.player.cardId;\r\n\t\tthis.opponentHeroPowerCardId = battleInput.opponentBoard.player.heroPowerId;\r\n\t\tthis.opponentHeroPowerUsed = battleInput.opponentBoard.player.heroPowerUsed;\r\n\r\n\t\tthis.actionsForCurrentBattle = [];\r\n\t\tthis.wonBattles = [];\r\n\t\tthis.tiedBattles = [];\r\n\t\tthis.lostBattles = [];\r\n\t}\r\n\r\n\tpublic prune(): void {\r\n\t\tthis.wonBattles = this.wonBattles.slice(0, MAX_SAMPLES);\r\n\t\tthis.lostBattles = this.lostBattles.slice(0, MAX_SAMPLES);\r\n\t\tthis.tiedBattles = this.tiedBattles.slice(0, MAX_SAMPLES);\r\n\t}\r\n\r\n\tpublic buildOutcomeSamples(): {\r\n\t\twon: readonly GameSample[];\r\n\t\tlost: readonly GameSample[];\r\n\t\ttied: readonly GameSample[];\r\n\t} {\r\n\t\treturn {\r\n\t\t\twon: this.wonBattles?.map((battle) => this.cleanUpActions(battle)),\r\n\t\t\tlost: this.lostBattles?.map((battle) => this.cleanUpActions(battle)),\r\n\t\t\ttied: this.tiedBattles?.map((battle) => this.cleanUpActions(battle)),\r\n\t\t};\r\n\t}\r\n\r\n\tprivate cleanUpActions(battle: GameSample): GameSample {\r\n\t\tconst collapsed = this.collapseActions(battle.actions);\r\n\t\tconst result: GameSample = {\r\n\t\t\t...battle,\r\n\t\t\tactions: collapsed,\r\n\t\t};\r\n\t\treturn result;\r\n\t}\r\n\r\n\tpublic commitBattleResult(result: 'won' | 'lost' | 'tied'): void {\r\n\t\tif (\r\n\t\t\tthis.wonBattles.length >= MAX_SAMPLES &&\r\n\t\t\tthis.lostBattles.length >= MAX_SAMPLES &&\r\n\t\t\tthis.tiedBattles.length >= MAX_SAMPLES\r\n\t\t) {\r\n\t\t\tthis.actionsForCurrentBattle = [];\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t// const actionsForBattle = this.collapseActions(this.actionsForCurrentBattle);\r\n\t\tconst actionsForBattle = this.actionsForCurrentBattle;\r\n\t\tthis.actionsForCurrentBattle = [];\r\n\r\n\t\tconst battle: GameSample = {\r\n\t\t\tactions: actionsForBattle,\r\n\t\t\tplayerCardId: this.playerCardId,\r\n\t\t\tplayerHeroPowerCardId: this.playerHeroPowerCardId,\r\n\t\t\tplayerHeroPowerUsed: this.playerHeroPowerUsed,\r\n\t\t\t// playerRewardCardId: this.playerRewardCardId,\r\n\t\t\t// playerRewardData: this.playerRewardData,\r\n\t\t\topponentCardId: this.opponentCardId,\r\n\t\t\topponentHeroPowerCardId: this.opponentHeroPowerCardId,\r\n\t\t\topponentHeroPowerUsed: this.opponentHeroPowerUsed,\r\n\t\t\t// opponentRewardCardId: this.opponentRewardCardId,\r\n\t\t\t// opponentRewardData: this.opponentRewardData,\r\n\t\t};\r\n\t\tswitch (result) {\r\n\t\t\tcase 'won':\r\n\t\t\t\tthis.wonBattles.push(battle);\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'lost':\r\n\t\t\t\tthis.lostBattles.push(battle);\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'tied':\r\n\t\t\t\tthis.tiedBattles.push(battle);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic registerAttack(\r\n\t\tattackingEntity: BoardEntity,\r\n\t\tdefendingEntity: BoardEntity,\r\n\t\tattackingBoard: readonly BoardEntity[],\r\n\t\tdefendingBoard: readonly BoardEntity[],\r\n\t\tattackingBoardHero: BgsPlayerEntity,\r\n\t\tdefendingBoardHero: BgsPlayerEntity,\r\n\t): void {\r\n\t\t// console.debug(\r\n\t\t// \t'\\n register attack',\r\n\t\t// \tstringifySimple(attackingBoard),\r\n\t\t// \t'\\n',\r\n\t\t// \tstringifySimple(defendingBoard),\r\n\t\t// \t'\\n',\r\n\t\t// \tattackingBoard.find((e) => e.entityId === 2441),\r\n\t\t// \t'\\n',\r\n\t\t// \tattackingBoard.find((e) => e.entityId === 2442),\r\n\t\t// );\r\n\t\tconst isAttackerFriendly = attackingBoard.every((entity) => entity.friendly);\r\n\t\tconst friendlyBoard = isAttackerFriendly ? attackingBoard : defendingBoard;\r\n\t\tconst opponentBoard = isAttackerFriendly ? defendingBoard : attackingBoard;\r\n\t\tconst playerSecrets = isAttackerFriendly ? attackingBoardHero.secrets : defendingBoardHero.secrets;\r\n\t\tconst opponentSecrets = isAttackerFriendly ? defendingBoardHero.secrets : attackingBoardHero.secrets;\r\n\t\tconst playerHero = isAttackerFriendly ? attackingBoardHero : defendingBoardHero;\r\n\t\tconst opponentHero = isAttackerFriendly ? defendingBoardHero : attackingBoardHero;\r\n\t\tconst action: GameAction = {\r\n\t\t\ttype: 'attack',\r\n\t\t\tsourceEntityId: attackingEntity.entityId,\r\n\t\t\ttargetEntityId: defendingEntity.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\tplayerHand: this.sanitize(playerHero.hand),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\topponentHand: this.sanitize(opponentHero.hand),\r\n\t\t\tplayerSecrets: (playerSecrets ?? []).filter((s) => !s.triggered),\r\n\t\t\topponentSecrets: (opponentSecrets ?? []).filter((s) => !s.triggered),\r\n\r\n\t\t\tplayerRewardCardId: playerHero?.questRewardEntities?.[0]?.cardId ?? playerHero?.questRewards?.[0],\r\n\t\t\tplayerRewardEntityId: playerHero?.questRewardEntities?.[0]?.entityId,\r\n\t\t\tplayerRewardData: playerHero?.questRewardEntities?.[0]?.scriptDataNum1,\r\n\t\t\topponentRewardCardId: opponentHero?.questRewardEntities?.[0]?.cardId ?? opponentHero?.questRewards?.[0],\r\n\t\t\topponentRewardEntityId: opponentHero?.questRewardEntities?.[0]?.entityId,\r\n\t\t\topponentRewardData: opponentHero?.questRewardEntities?.[0]?.scriptDataNum1,\r\n\t\t};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerStartOfCombat(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tfriendlyHero: BgsPlayerEntity,\r\n\t\topponentHero: BgsPlayerEntity,\r\n\t): void {\r\n\t\tconst playerSecrets = friendlyHero.secrets;\r\n\t\tconst opponentSecrets = opponentHero.secrets;\r\n\t\tconst action: GameAction = {\r\n\t\t\ttype: 'start-of-combat',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: this.sanitize(friendlyHero.hand),\r\n\t\t\topponentHand: this.sanitize(opponentHero.hand),\r\n\t\t\tplayerSecrets: playerSecrets ?? [],\r\n\t\t\topponentSecrets: opponentSecrets ?? [],\r\n\t\t\tplayerRewardCardId: friendlyHero.questRewardEntities?.[0]?.cardId ?? friendlyHero.questRewards?.[0],\r\n\t\t\tplayerRewardEntityId: friendlyHero.questRewardEntities?.[0]?.entityId,\r\n\t\t\tplayerRewardData: friendlyHero.questRewardEntities?.[0]?.scriptDataNum1,\r\n\t\t\topponentRewardCardId: opponentHero.questRewardEntities?.[0]?.cardId ?? opponentHero.questRewards?.[0],\r\n\t\t\topponentRewardEntityId: opponentHero.questRewardEntities?.[0]?.entityId,\r\n\t\t\topponentRewardData: opponentHero.questRewardEntities?.[0]?.scriptDataNum1,\r\n\t\t};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerPlayerAttack(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tdamage: number,\r\n\t): void {\r\n\t\tconst action: GameAction = {\r\n\t\t\ttype: 'player-attack',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tplayerSecrets: null,\r\n\t\t\topponentSecrets: null,\r\n\t\t\tplayerRewardCardId: null,\r\n\t\t\tplayerRewardEntityId: null,\r\n\t\t\tplayerRewardData: null,\r\n\t\t\topponentRewardCardId: null,\r\n\t\t\topponentRewardEntityId: null,\r\n\t\t\topponentRewardData: null,\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tdamage: damage,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerOpponentAttack(\r\n\t\tfriendlyBoard: readonly BoardEntity[],\r\n\t\topponentBoard: readonly BoardEntity[],\r\n\t\tdamage: number,\r\n\t): void {\r\n\t\tconst action: GameAction = {\r\n\t\t\ttype: 'opponent-attack',\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tplayerSecrets: null,\r\n\t\t\topponentSecrets: null,\r\n\t\t\tplayerRewardCardId: null,\r\n\t\t\tplayerRewardEntityId: null,\r\n\t\t\tplayerRewardData: null,\r\n\t\t\topponentRewardCardId: null,\r\n\t\t\topponentRewardEntityId: null,\r\n\t\t\topponentRewardData: null,\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tdamage: damage,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerDamageDealt(\r\n\t\tdamagingEntity: BoardEntity,\r\n\t\tdamagedEntity: BoardEntity,\r\n\t\tdamageTaken: number,\r\n\t\tdamagedEntityBoard: BoardEntity[],\r\n\t): void {\r\n\t\tif (!damagingEntity.entityId) {\r\n\t\t\t// console.error('missing damaging entity id', damagingEntity.cardId);\r\n\t\t}\r\n\t\tconst friendlyBoard = damagedEntityBoard.every((entity) => entity.friendly) ? damagedEntityBoard : null;\r\n\t\tconst opponentBoard = damagedEntityBoard.every((entity) => !entity.friendly) ? damagedEntityBoard : null;\r\n\t\tconst action: GameAction = {\r\n\t\t\ttype: 'damage',\r\n\t\t\tdamages: [\r\n\t\t\t\t{\r\n\t\t\t\t\tsourceEntityId: damagingEntity.entityId,\r\n\t\t\t\t\ttargetEntityId: damagedEntity.entityId,\r\n\t\t\t\t\tdamage: damageTaken,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tplayerSecrets: null,\r\n\t\t\topponentSecrets: null,\r\n\t\t\tplayerRewardCardId: null,\r\n\t\t\tplayerRewardEntityId: null,\r\n\t\t\tplayerRewardData: null,\r\n\t\t\topponentRewardCardId: null,\r\n\t\t\topponentRewardEntityId: null,\r\n\t\t\topponentRewardData: null,\r\n\t\t};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerPowerTarget(\r\n\t\tsourceEntity: BoardEntity | BgsPlayerEntity | BoardSecret,\r\n\t\ttargetEntity: BoardEntity | BgsPlayerEntity,\r\n\t\ttargetBoard: BoardEntity[],\r\n\t\thero1: BgsPlayerEntity,\r\n\t\thero2: BgsPlayerEntity,\r\n\t): void {\r\n\t\tif (!targetEntity) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (!sourceEntity.entityId && !(sourceEntity as BgsPlayerEntity).heroPowerId) {\r\n\t\t\t// console.error('missing damaging entity id', sourceEntity.cardId);\r\n\t\t}\r\n\t\t// console.log('registerPowerTarget', stringifySimpleCard(sourceEntity), stringifySimpleCard(targetEntity), new Error().stack);\r\n\t\tconst friendlyBoard = targetBoard?.every((entity) => entity.friendly) ? targetBoard : null;\r\n\t\tconst opponentBoard = targetBoard?.every((entity) => !entity.friendly) ? targetBoard : null;\r\n\t\tconst friendlyHero = hero1?.friendly ? hero1 : hero2?.friendly ? hero2 : null;\r\n\t\tconst opponentHero = hero1?.friendly ? hero2 : hero2?.friendly ? hero1 : null;\r\n\t\tconst action: GameAction = {\r\n\t\t\ttype: 'power-target',\r\n\t\t\tsourceEntityId: sourceEntity.entityId,\r\n\t\t\ttargetEntityId: targetEntity.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: this.sanitize(friendlyHero?.hand),\r\n\t\t\topponentHand: this.sanitize(opponentHero?.hand),\r\n\t\t\tplayerSecrets: (friendlyHero?.secrets ?? []).filter((s) => !s.triggered),\r\n\t\t\topponentSecrets: (opponentHero?.secrets ?? []).filter((s) => !s.triggered),\r\n\t\t\tplayerRewardCardId: friendlyHero?.questRewardEntities?.[0]?.cardId ?? friendlyHero?.questRewards?.[0],\r\n\t\t\tplayerRewardEntityId: friendlyHero?.questRewardEntities?.[0]?.entityId,\r\n\t\t\tplayerRewardData: friendlyHero?.questRewardEntities?.[0]?.scriptDataNum1,\r\n\t\t\topponentRewardCardId: opponentHero?.questRewardEntities?.[0]?.cardId ?? opponentHero?.questRewards?.[0],\r\n\t\t\topponentRewardEntityId: opponentHero?.questRewardEntities?.[0]?.entityId,\r\n\t\t\topponentRewardData: opponentHero?.questRewardEntities?.[0]?.scriptDataNum1,\r\n\t\t};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerMinionsSpawn(\r\n\t\tsourceEntity: BoardEntity | BgsPlayerEntity,\r\n\t\tboardOnWhichToSpawn: BoardEntity[],\r\n\t\tspawnedEntities: readonly BoardEntity[],\r\n\t): void {\r\n\t\tif (!spawnedEntities || spawnedEntities.length === 0) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (!sourceEntity.entityId) {\r\n\t\t\tconsole.error('missing spawn source entity id', sourceEntity);\r\n\t\t}\r\n\t\tconst friendlyBoard = boardOnWhichToSpawn.every((entity) => entity.friendly) ? boardOnWhichToSpawn : null;\r\n\t\tconst opponentBoard = boardOnWhichToSpawn.every((entity) => !entity.friendly) ? boardOnWhichToSpawn : null;\r\n\t\tconst action: GameAction = {\r\n\t\t\ttype: 'spawn',\r\n\t\t\tspawns: this.sanitize(spawnedEntities),\r\n\t\t\tsourceEntityId: sourceEntity?.entityId,\r\n\t\t\tplayerBoard: this.sanitize(friendlyBoard),\r\n\t\t\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tplayerSecrets: null,\r\n\t\t\topponentSecrets: null,\r\n\t\t\tplayerRewardCardId: null,\r\n\t\t\tplayerRewardEntityId: null,\r\n\t\t\tplayerRewardData: null,\r\n\t\t\topponentRewardCardId: null,\r\n\t\t\topponentRewardEntityId: null,\r\n\t\t\topponentRewardData: null,\r\n\t\t};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerDeadEntities(\r\n\t\tdeadMinionIndexes1: number[],\r\n\t\tdeadEntities1: BoardEntity[],\r\n\t\tboard1: BoardEntity[],\r\n\t\tdeadMinionIndexes2: number[],\r\n\t\tdeadEntities2: BoardEntity[],\r\n\t\tboard2: BoardEntity[],\r\n\t): void {\r\n\t\tconst deaths = [...(deadEntities1 || []), ...(deadEntities2 || [])];\r\n\t\tif (!deaths || deaths.length === 0) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst action: GameAction = {\r\n\t\t\ttype: 'minion-death',\r\n\t\t\tdeaths: this.sanitize(deaths),\r\n\t\t\tdeadMinionsPositionsOnBoard: [\r\n\t\t\t\t...(deadMinionIndexes1 || []).map((i) => board1.length - i),\r\n\t\t\t\t...(deadMinionIndexes2 || []).map((i) => board2.length - i),\r\n\t\t\t],\r\n\t\t\tplayerBoard: undefined,\r\n\t\t\topponentBoard: undefined,\r\n\t\t\tplayerHand: null,\r\n\t\t\topponentHand: null,\r\n\t\t\tplayerSecrets: null,\r\n\t\t\topponentSecrets: null,\r\n\t\t\tplayerRewardCardId: null,\r\n\t\t\tplayerRewardEntityId: null,\r\n\t\t\tplayerRewardData: null,\r\n\t\t\topponentRewardCardId: null,\r\n\t\t\topponentRewardEntityId: null,\r\n\t\t\topponentRewardData: null,\r\n\t\t};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tprivate addAction(action: GameAction) {\r\n\t\tthis.actionsForCurrentBattle.push(action);\r\n\t}\r\n\r\n\tprivate collapseActions(actions: readonly GameAction[]): readonly GameAction[] {\r\n\t\tif (!actions || actions.length === 0) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\t\tconst result: GameAction[] = [];\r\n\t\tfor (let i = 0; i < actions.length; i++) {\r\n\t\t\tconst action: GameAction = {\r\n\t\t\t\t...actions[i],\r\n\t\t\t\tplayerBoard: this.sanitize(actions[i].playerBoard),\r\n\t\t\t\topponentBoard: this.sanitize(actions[i].opponentBoard),\r\n\t\t\t\tplayerHand: this.sanitize(actions[i].playerHand),\r\n\t\t\t\topponentHand: this.sanitize(actions[i].opponentHand),\r\n\t\t\t\t// spawns: this.sanitize(actions[i].spawns),\r\n\t\t\t\tdeaths: this.sanitize(actions[i].deaths),\r\n\t\t\t};\r\n\t\t\t// action.playerBoard && console.debug('\\naction playerboard', stringifySimple(action.playerBoard));\r\n\t\t\tconst lastAction = result.length > 0 ? result[result.length - 1] : null;\r\n\r\n\t\t\tif (lastAction && !action.playerBoard) {\r\n\t\t\t\taction.playerBoard = lastAction.playerBoard;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.opponentBoard) {\r\n\t\t\t\taction.opponentBoard = lastAction.opponentBoard;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.playerHand) {\r\n\t\t\t\taction.playerHand = lastAction.playerHand;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.opponentHand) {\r\n\t\t\t\taction.opponentHand = lastAction.opponentHand;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.playerSecrets) {\r\n\t\t\t\taction.playerSecrets = lastAction.playerSecrets;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.opponentSecrets) {\r\n\t\t\t\taction.opponentSecrets = lastAction.opponentSecrets;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.playerRewardCardId) {\r\n\t\t\t\taction.playerRewardCardId = lastAction.playerRewardCardId;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.playerRewardEntityId) {\r\n\t\t\t\taction.playerRewardEntityId = lastAction.playerRewardEntityId;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.playerRewardData) {\r\n\t\t\t\taction.playerRewardData = lastAction.playerRewardData;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.opponentRewardCardId) {\r\n\t\t\t\taction.opponentRewardCardId = lastAction.opponentRewardCardId;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.opponentRewardEntityId) {\r\n\t\t\t\taction.opponentRewardEntityId = lastAction.opponentRewardEntityId;\r\n\t\t\t}\r\n\t\t\tif (lastAction && !action.opponentRewardData) {\r\n\t\t\t\taction.opponentRewardData = lastAction.opponentRewardData;\r\n\t\t\t}\r\n\r\n\t\t\tif (lastAction && action.type === 'damage' && lastAction.type === 'attack') {\r\n\t\t\t\tlastAction.damages = lastAction.damages || [];\r\n\t\t\t\tlastAction.damages.push({\r\n\t\t\t\t\tdamage: action.damages[0].damage,\r\n\t\t\t\t\tsourceEntityId: action.damages[0].sourceEntityId,\r\n\t\t\t\t\ttargetEntityId: action.damages[0].targetEntityId,\r\n\t\t\t\t});\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t} else if (lastAction && action.type === 'damage' && lastAction.type === 'damage') {\r\n\t\t\t\tlastAction.damages = lastAction.damages || [];\r\n\t\t\t\tlastAction.damages.push({\r\n\t\t\t\t\tdamage: action.damages[0].damage,\r\n\t\t\t\t\tsourceEntityId: action.damages[0].sourceEntityId,\r\n\t\t\t\t\ttargetEntityId: action.damages[0].targetEntityId,\r\n\t\t\t\t});\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t} else if (\r\n\t\t\t\tlastAction &&\r\n\t\t\t\taction.type === 'power-target' &&\r\n\t\t\t\tlastAction.type === 'power-target' &&\r\n\t\t\t\taction.sourceEntityId === lastAction.sourceEntityId\r\n\t\t\t) {\r\n\t\t\t\tlastAction.targetEntityIds =\r\n\t\t\t\t\tlastAction.targetEntityIds ?? (lastAction.targetEntityId ? [lastAction.targetEntityId] : []);\r\n\t\t\t\taction.targetEntityIds =\r\n\t\t\t\t\taction.targetEntityIds ?? (action.targetEntityId ? [action.targetEntityId] : []);\r\n\t\t\t\tlastAction.targetEntityIds.push(...action.targetEntityIds);\r\n\t\t\t\t// So that when multiple Leapfroggers enchantments target the same minion,\r\n\t\t\t\t// we can count them in the replay viewer's text\r\n\t\t\t\t// lastAction.targetEntityIds = [...new Set(lastAction.targetEntityIds)];\r\n\t\t\t\tlastAction.playerBoard = action.playerBoard;\r\n\t\t\t\tlastAction.opponentBoard = action.opponentBoard;\r\n\t\t\t\tlastAction.playerHand = action.playerHand;\r\n\t\t\t\tlastAction.opponentHand = action.opponentHand;\r\n\t\t\t\tlastAction.playerSecrets = action.playerSecrets;\r\n\t\t\t\tlastAction.opponentSecrets = action.opponentSecrets;\r\n\t\t\t} else {\r\n\t\t\t\tresult.push(action);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\t// Calling sanitize every time before we add an action to the list is mandatory, since\r\n\t// the entities and boards are mutable\r\n\tprivate sanitize(board: readonly BoardEntity[]): readonly BoardEntity[] {\r\n\t\tif (!board) {\r\n\t\t\treturn undefined;\r\n\t\t}\r\n\t\treturn board.map(\r\n\t\t\t(entity) =>\r\n\t\t\t\t({\r\n\t\t\t\t\tentityId: entity.entityId,\r\n\t\t\t\t\tcardId: entity.cardId,\r\n\t\t\t\t\tfriendly: entity.friendly,\r\n\t\t\t\t\tattack: entity.attack,\r\n\t\t\t\t\thealth: entity.health,\r\n\t\t\t\t\tmaxHealth: entity.maxHealth,\r\n\t\t\t\t\ttaunt: entity.taunt,\r\n\t\t\t\t\tdivineShield: entity.divineShield,\r\n\t\t\t\t\tpoisonous: entity.poisonous,\r\n\t\t\t\t\tvenomous: entity.venomous,\r\n\t\t\t\t\treborn: entity.reborn,\r\n\t\t\t\t\twindfury: entity.windfury,\r\n\t\t\t\t\tstealth: entity.stealth,\r\n\t\t\t\t} as BoardEntity),\r\n\t\t);\r\n\t\t// return board.map(\r\n\t\t// \t(entity) =>\r\n\t\t// \t\t({\r\n\t\t// \t\t\t...entity,\r\n\t\t// \t\t\tenchantments: undefined,\r\n\t\t// \t\t\tcantAttack: undefined,\r\n\t\t// \t\t\thasAttacked: undefined,\r\n\t\t// \t\t\tattackImmediately: undefined,\r\n\t\t// \t\t\tpreviousAttack: undefined,\r\n\t\t// \t\t\tlastAffectedByEntity: undefined,\r\n\t\t// \t\t\tattacking: undefined,\r\n\t\t// \t\t} as BoardEntity),\r\n\t\t// );\r\n\t}\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestone-hs/simulate-bgs-battle",
3
- "version": "1.1.381",
3
+ "version": "1.1.383",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "lint": "eslint --color --fix --ext .ts .",