@firestone-hs/simulate-bgs-battle 1.1.327 → 1.1.329
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cards/cards-data.js +4 -1
- package/dist/cards/cards-data.js.map +1 -1
- package/dist/simulation/add-minion-to-board.js +9 -9
- package/dist/simulation/add-minion-to-board.js.map +1 -1
- package/dist/simulation/attack.js +1 -1
- package/dist/simulation/attack.js.map +1 -1
- package/dist/simulation/auras.js +8 -9
- package/dist/simulation/auras.js.map +1 -1
- package/dist/simulation/spectator/spectator.js +2 -2
- package/dist/simulation/spectator/spectator.js.map +1 -1
- package/package.json +1 -1
package/dist/cards/cards-data.js
CHANGED
|
@@ -31,6 +31,8 @@ exports.START_OF_COMBAT_CARD_IDS = [
|
|
|
31
31
|
"BG27_079_G",
|
|
32
32
|
"BG28_904",
|
|
33
33
|
"BG28_904_G",
|
|
34
|
+
"BG27_556",
|
|
35
|
+
"BG27_556_G",
|
|
34
36
|
];
|
|
35
37
|
exports.WHELP_CARD_IDS = [
|
|
36
38
|
"BGS_019",
|
|
@@ -135,9 +137,10 @@ class CardsData {
|
|
|
135
137
|
case "BG26_148_G":
|
|
136
138
|
case "BG25_003":
|
|
137
139
|
case "BG25_003_G":
|
|
140
|
+
return 4;
|
|
138
141
|
case "BG27_010":
|
|
139
142
|
case "BG27_010_G":
|
|
140
|
-
return
|
|
143
|
+
return 5;
|
|
141
144
|
}
|
|
142
145
|
return 0;
|
|
143
146
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cards-data.js","sourceRoot":"","sources":["../../src/cards/cards-data.ts"],"names":[],"mappings":";;;AAAA,iEAQsC;AACtC,6CAAgE;AAChE,oCAAoE;AAEvD,QAAA,wBAAwB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BvC,CAAC;AACW,QAAA,cAAc,GAAG;;;;CAI7B,CAAC;AAEF,MAAa,SAAS;IAuBrB,YAA6B,Q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r\n\tRace,\r\n\tReferenceCard,\r\n} from '@firestone-hs/reference-data';\r\nimport { groupByFunction, pickRandom } from '../services/utils';\r\nimport { getRaceEnum, hasMechanic, isCorrectTribe } from '../utils';\r\n\r\nexport const START_OF_COMBAT_CARD_IDS = [\r\n\tCardIds.CorruptedMyrmidon_BG23_012,\r\n\tCardIds.CorruptedMyrmidon_BG23_012_G,\r\n\tCardIds.Crabby_BG22_HERO_000_Buddy,\r\n\tCardIds.Crabby_BG22_HERO_000_Buddy_G,\r\n\tCardIds.MantidQueen_BG22_402,\r\n\tCardIds.MantidQueen_BG22_402_G,\r\n\tCardIds.PrizedPromoDrake_BG21_014,\r\n\tCardIds.PrizedPromoDrake_BG21_014_G,\r\n\tCardIds.RedWhelp_BGS_019,\r\n\tCardIds.RedWhelp_TB_BaconUps_102,\r\n\tCardIds.AmberGuardian_BG24_500,\r\n\tCardIds.AmberGuardian_BG24_500_G,\r\n\tCardIds.InterrogatorWhitemane_BG24_704,\r\n\tCardIds.InterrogatorWhitemane_BG24_704_G,\r\n\tCardIds.Soulsplitter_BG25_023,\r\n\tCardIds.Soulsplitter_BG25_023_G,\r\n\tCardIds.ChoralMrrrglr_BG26_354,\r\n\tCardIds.ChoralMrrrglr_BG26_354_G,\r\n\tCardIds.SanctumRester_BG26_356,\r\n\tCardIds.SanctumRester_BG26_356_G,\r\n\tCardIds.CarbonicCopy_BG27_503,\r\n\tCardIds.CarbonicCopy_BG27_503_G,\r\n\tCardIds.HawkstriderHerald_BG27_079,\r\n\tCardIds.HawkstriderHerald_BG27_079_G,\r\n\tCardIds.AudaciousAnchor_BG28_904,\r\n\tCardIds.AudaciousAnchor_BG28_904_G,\r\n];\r\nexport const WHELP_CARD_IDS = [\r\n\tCardIds.RedWhelp_BGS_019,\r\n\tCardIds.RedWhelp_TB_BaconUps_102,\r\n\tCardIds.Onyxia_OnyxianWhelpToken,\r\n];\r\n\r\nexport class CardsData {\r\n\tpublic ghastcoilerSpawns: readonly string[];\r\n\t// public shredderSpawns: readonly string[];\r\n\tpublic validDeathrattles: readonly string[];\r\n\tpublic impMamaSpawns: readonly string[];\r\n\tpublic demonSpawns: readonly string[];\r\n\tpublic gentleDjinniSpawns: readonly string[];\r\n\t// public festergutSpawns: readonly string[];\r\n\tpublic kilrekSpawns: readonly string[];\r\n\tpublic brannEpicEggSpawns: readonly string[];\r\n\t// public sneedsSpawns: readonly string[];\r\n\t// public treasureChestSpawns: readonly string[];\r\n\tpublic pirateSpawns: readonly string[];\r\n\tpublic beastSpawns: readonly string[];\r\n\tpublic scrapScraperSpawns: readonly string[];\r\n\r\n\tpublic putricidePool1: readonly string[];\r\n\tpublic putricidePool2: readonly string[];\r\n\tpublic putridicePool2ForEternalSummoner: readonly string[];\r\n\r\n\tprivate pool: readonly ReferenceCard[];\r\n\tprivate minionsForTier: { [key: string]: readonly ReferenceCard[] };\r\n\r\n\tconstructor(private readonly allCards: AllCardsService, init = true) {\r\n\t\tif (init) {\r\n\t\t\tthis.inititialize();\r\n\t\t}\r\n\t}\r\n\r\n\tpublic inititialize(validTribes?: readonly Race[], anomalies?: readonly string[]): void {\r\n\t\tconst poolWithoutGolden = this.allCards\r\n\t\t\t.getCards()\r\n\t\t\t.filter((card) => isBattlegroundsCard(card))\r\n\t\t\t.filter((card) => !NON_BUYABLE_MINION_IDS.includes(card.id as CardIds))\r\n\t\t\t.filter((card) => !!card.techLevel)\r\n\t\t\t.filter((card) => !hasMechanic(card, GameTag[GameTag.BACON_BUDDY]))\r\n\t\t\t.filter((card) => card.set !== 'Vanilla')\r\n\t\t\t.filter((card) =>\r\n\t\t\t\tanomalies?.includes(CardIds.BigLeague_BG27_Anomaly_100)\r\n\t\t\t\t\t? card.techLevel >= 3\r\n\t\t\t\t\t: anomalies?.includes(CardIds.LittleLeague_BG27_Anomaly_800)\r\n\t\t\t\t\t? card.techLevel <= 4\r\n\t\t\t\t\t: true,\r\n\t\t\t);\r\n\t\tthis.pool = poolWithoutGolden.filter((card) =>\r\n\t\t\tanomalies?.includes(CardIds.TheGoldenArena_BG27_Anomaly_801) ? this.isGolden(card) : !this.isGolden(card),\r\n\t\t);\r\n\t\tthis.minionsForTier = groupByFunction((card: ReferenceCard) => card.techLevel)(this.pool);\r\n\t\tthis.ghastcoilerSpawns = this.pool\r\n\t\t\t.filter((card) => card.id !== 'BGS_008')\r\n\t\t\t.filter((card) => hasMechanic(card, 'DEATHRATTLE'))\r\n\t\t\t.filter((card) => this.isValidTribe(validTribes, card.races))\r\n\t\t\t.map((card) => card.id);\r\n\t\tthis.validDeathrattles = poolWithoutGolden\r\n\t\t\t.filter((card) => hasMechanic(card, 'DEATHRATTLE'))\r\n\t\t\t.filter((card) => this.isValidTribe(validTribes, card.races))\r\n\t\t\t.map((card) => card.id);\r\n\t\tthis.demonSpawns = this.pool.filter((card) => isCorrectTribe(card.races, Race.DEMON)).map((card) => card.id);\r\n\t\tthis.impMamaSpawns = this.demonSpawns.filter((cardId) => cardId !== CardIds.ImpMama_BGS_044);\r\n\t\tthis.gentleDjinniSpawns = this.pool\r\n\t\t\t.filter((card) => isCorrectTribe(card.races, Race.ELEMENTAL))\r\n\t\t\t.filter((card) => card.id !== CardIds.GentleDjinni_BGS_121)\r\n\t\t\t.map((card) => card.id);\r\n\t\t// FIXME: just spawn a random undead instead of an Undead Creation\r\n\t\t// this.festergutSpawns = pool\r\n\t\t// \t.filter((card) => !this.isGolden(card))\r\n\t\t// \t.filter((card) => isCorrectTribe(card.races, Race.UNDEAD))\r\n\t\t// \t.filter((card) => card.id !== CardIds.Festergut_BG25_HERO_100_Buddy)\r\n\t\t// \t// .filter((card) => REMOVED_CARD_IDS.indexOf(card.id) === -1)\r\n\t\t// \t.map((card) => card.id);\r\n\t\tthis.kilrekSpawns = this.pool\r\n\t\t\t.filter((card) => isCorrectTribe(card.races, Race.DEMON))\r\n\t\t\t.filter((card) => card.id !== CardIds.Kilrek_TB_BaconShop_HERO_37_Buddy)\r\n\t\t\t.map((card) => card.id);\r\n\t\tthis.brannEpicEggSpawns = this.pool.filter((card) => hasMechanic(card, 'BATTLECRY')).map((card) => card.id);\r\n\t\tthis.pirateSpawns = this.pool.filter((card) => isCorrectTribe(card.races, Race.PIRATE)).map((card) => card.id);\r\n\t\tthis.beastSpawns = this.pool.filter((card) => isCorrectTribe(card.races, Race.BEAST)).map((card) => card.id);\r\n\t\tthis.scrapScraperSpawns = this.pool\r\n\t\t\t.filter((card) => hasMechanic(card, GameTag[GameTag.MAGNETIC]))\r\n\t\t\t.map((card) => card.id);\r\n\r\n\t\tthis.putricidePool1 = this.pool.filter((card) => card.battlegroundsPutridicePool1).map((card) => card.id);\r\n\t\tthis.putricidePool2 = this.pool.filter((card) => card.battlegroundsPutridicePool2).map((card) => card.id);\r\n\t\tthis.putridicePool2ForEternalSummoner = this.pool\r\n\t\t\t.filter((card) => card.battlegroundsPutridicePool2)\r\n\t\t\t.filter((card) => !card.battlegroundsPutridiceSummonerExclusion)\r\n\t\t\t.map((card) => card.id);\r\n\t}\r\n\r\n\tpublic avengeValue(cardId: string): number {\r\n\t\tswitch (cardId) {\r\n\t\t\tcase CardIds.BirdBuddy_BG21_002:\r\n\t\t\tcase CardIds.BirdBuddy_BG21_002_G:\r\n\t\t\tcase CardIds.HungeringAbomination_BG25_014:\r\n\t\t\tcase CardIds.HungeringAbomination_BG25_014_G:\r\n\t\t\t// Not technically an avenge, but behaves as if\r\n\t\t\tcase CardIds.ShadowyConstruct_BG25_HERO_103_Buddy:\r\n\t\t\tcase CardIds.ShadowyConstruct_BG25_HERO_103_Buddy_G:\r\n\t\t\tcase CardIds.Bristlebach_BG26_157:\r\n\t\t\tcase CardIds.Bristlebach_BG26_157_G:\r\n\t\t\tcase CardIds.IceSickle:\r\n\t\t\t\treturn 1;\r\n\t\t\tcase CardIds.GhoulOfTheFeast_BG25_002:\r\n\t\t\tcase CardIds.GhoulOfTheFeast_BG25_002_G:\r\n\t\t\tcase CardIds.MechanoTank_BG21_023:\r\n\t\t\tcase CardIds.MechanoTank_BG21_023_G:\r\n\t\t\tcase CardIds.PalescaleCrocolisk_BG21_001:\r\n\t\t\tcase CardIds.PalescaleCrocolisk_BG21_001_G:\r\n\t\t\tcase CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy:\r\n\t\t\tcase CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy_G:\r\n\t\t\tcase CardIds.VanndarStormpike_LeadTheStormpikes:\r\n\t\t\tcase CardIds.Drekthar_LeadTheFrostwolves:\r\n\t\t\t\treturn 2;\r\n\t\t\tcase CardIds.BuddingGreenthumb_BG21_030:\r\n\t\t\tcase CardIds.BuddingGreenthumb_BG21_030_G:\r\n\t\t\t// case CardIds.FrostwolfLieutenant:\r\n\t\t\t// case CardIds.FrostwolfLieutenantBattlegrounds:\r\n\t\t\tcase CardIds.Onyxia_Broodmother:\r\n\t\t\tcase CardIds.PashmarTheVengeful_BG23_014:\r\n\t\t\tcase CardIds.PashmarTheVengeful_BG23_014_G:\r\n\t\t\tcase CardIds.WitchwingNestmatron_BG21_038:\r\n\t\t\tcase CardIds.WitchwingNestmatron_BG21_038_G:\r\n\t\t\tcase CardIds.BoomSquad_BG27_Reward_502:\r\n\t\t\tcase CardIds.ChampionOfThePrimus_BG27_029:\r\n\t\t\tcase CardIds.ChampionOfThePrimus_BG27_029_G:\r\n\t\t\t\treturn 3;\r\n\t\t\tcase CardIds.ImpatientDoomsayer_BG21_007:\r\n\t\t\tcase CardIds.ImpatientDoomsayer_BG21_007_G:\r\n\t\t\tcase CardIds.Sisefin_BG21_009:\r\n\t\t\tcase CardIds.Sisefin_BG21_009_G:\r\n\t\t\tcase CardIds.TonyTwoTusk_BG21_031:\r\n\t\t\tcase CardIds.TonyTwoTusk_BG21_031_G:\r\n\t\t\tcase CardIds.ScrapScraper_BG26_148:\r\n\t\t\tcase CardIds.ScrapScraper_BG26_148_G:\r\n\t\t\tcase CardIds.RelentlessSentry_BG25_003:\r\n\t\t\tcase CardIds.RelentlessSentry_BG25_003_G:\r\n\t\t\tcase CardIds.RelentlessMurghoul_BG27_010:\r\n\t\t\tcase CardIds.RelentlessMurghoul_BG27_010_G:\r\n\t\t\t\treturn 4;\r\n\t\t}\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tpublic getTavernLevel(cardId: string): number {\r\n\t\treturn this.allCards.getCard(cardId).techLevel ?? 1;\r\n\t}\r\n\r\n\tpublic getRandomMinionForTavernTier(tavernTier: number): string {\r\n\t\t// Tzvern tier can be undefined for hero-power specific tokens, like the Amalgam, or when\r\n\t\t// for some reason tokens end up in the shop. For now, defaulting to 1 for tavern\r\n\t\t// level seems to work in all cases\r\n\t\tconst minionsForTier = this.minionsForTier[tavernTier ?? 1];\r\n\t\tif (!minionsForTier?.length) {\r\n\t\t\tconsole.error('incorrect minions for tier', tavernTier, this.minionsForTier, minionsForTier);\r\n\t\t}\r\n\t\treturn pickRandom(this.minionsForTier[tavernTier ?? 1])?.id;\r\n\t}\r\n\r\n\tpublic getRandomMinionForTribe(tribe: Race, tavernLimitUpper: number): string {\r\n\t\tconst pool = this.pool\r\n\t\t\t.filter((m) => this.isValidTribe([tribe], m.races))\r\n\t\t\t.filter((m) => m.techLevel <= tavernLimitUpper);\r\n\t\treturn pickRandom(pool)?.id;\r\n\t}\r\n\r\n\tprivate isGolden(card: ReferenceCard): boolean {\r\n\t\treturn !!card.battlegroundsNormalDbfId;\r\n\t}\r\n\r\n\tprivate isValidTribe(validTribes: readonly Race[], cardRaces: readonly string[]): boolean {\r\n\t\t// Blank races are always ok\r\n\t\tif (!cardRaces?.length) {\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\treturn cardRaces\r\n\t\t\t.map((race) => getRaceEnum(race))\r\n\t\t\t.some((raceEnum) => raceEnum === Race.ALL || !validTribes?.length || validTribes.includes(raceEnum));\r\n\t}\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"cards-data.js","sourceRoot":"","sources":["../../src/cards/cards-data.ts"],"names":[],"mappings":";;;AAAA,iEAQsC;AACtC,6CAAgE;AAChE,o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Q,CAAC,QAAQ,CAAC,CAAC,CAAC;IACvG,CAAC;CACD;AAnLD,8BAmLC","sourcesContent":["import {\r\n\tAllCardsService,\r\n\tCardIds,\r\n\tGameTag,\r\n\tisBattlegroundsCard,\r\n\tNON_BUYABLE_MINION_IDS,\r\n\tRace,\r\n\tReferenceCard,\r\n} from '@firestone-hs/reference-data';\r\nimport { groupByFunction, pickRandom } from '../services/utils';\r\nimport { getRaceEnum, hasMechanic, isCorrectTribe } from '../utils';\r\n\r\nexport const START_OF_COMBAT_CARD_IDS = [\r\n\tCardIds.CorruptedMyrmidon_BG23_012,\r\n\tCardIds.CorruptedMyrmidon_BG23_012_G,\r\n\tCardIds.Crabby_BG22_HERO_000_Buddy,\r\n\tCardIds.Crabby_BG22_HERO_000_Buddy_G,\r\n\tCardIds.MantidQueen_BG22_402,\r\n\tCardIds.MantidQueen_BG22_402_G,\r\n\tCardIds.PrizedPromoDrake_BG21_014,\r\n\tCardIds.PrizedPromoDrake_BG21_014_G,\r\n\tCardIds.RedWhelp_BGS_019,\r\n\tCardIds.RedWhelp_TB_BaconUps_102,\r\n\tCardIds.AmberGuardian_BG24_500,\r\n\tCardIds.AmberGuardian_BG24_500_G,\r\n\tCardIds.InterrogatorWhitemane_BG24_704,\r\n\tCardIds.InterrogatorWhitemane_BG24_704_G,\r\n\tCardIds.Soulsplitter_BG25_023,\r\n\tCardIds.Soulsplitter_BG25_023_G,\r\n\tCardIds.ChoralMrrrglr_BG26_354,\r\n\tCardIds.ChoralMrrrglr_BG26_354_G,\r\n\tCardIds.SanctumRester_BG26_356,\r\n\tCardIds.SanctumRester_BG26_356_G,\r\n\tCardIds.CarbonicCopy_BG27_503,\r\n\tCardIds.CarbonicCopy_BG27_503_G,\r\n\tCardIds.HawkstriderHerald_BG27_079,\r\n\tCardIds.HawkstriderHerald_BG27_079_G,\r\n\tCardIds.AudaciousAnchor_BG28_904,\r\n\tCardIds.AudaciousAnchor_BG28_904_G,\r\n\tCardIds.DiremuckForager_BG27_556,\r\n\tCardIds.DiremuckForager_BG27_556_G,\r\n];\r\nexport const WHELP_CARD_IDS = [\r\n\tCardIds.RedWhelp_BGS_019,\r\n\tCardIds.RedWhelp_TB_BaconUps_102,\r\n\tCardIds.Onyxia_OnyxianWhelpToken,\r\n];\r\n\r\nexport class CardsData {\r\n\tpublic ghastcoilerSpawns: readonly string[];\r\n\t// public shredderSpawns: readonly string[];\r\n\tpublic validDeathrattles: readonly string[];\r\n\tpublic impMamaSpawns: readonly string[];\r\n\tpublic demonSpawns: readonly string[];\r\n\tpublic gentleDjinniSpawns: readonly string[];\r\n\t// public festergutSpawns: readonly string[];\r\n\tpublic kilrekSpawns: readonly string[];\r\n\tpublic brannEpicEggSpawns: readonly string[];\r\n\t// public sneedsSpawns: readonly string[];\r\n\t// public treasureChestSpawns: readonly string[];\r\n\tpublic pirateSpawns: readonly string[];\r\n\tpublic beastSpawns: readonly string[];\r\n\tpublic scrapScraperSpawns: readonly string[];\r\n\r\n\tpublic putricidePool1: readonly string[];\r\n\tpublic putricidePool2: readonly string[];\r\n\tpublic putridicePool2ForEternalSummoner: readonly string[];\r\n\r\n\tprivate pool: readonly ReferenceCard[];\r\n\tprivate minionsForTier: { [key: string]: readonly ReferenceCard[] };\r\n\r\n\tconstructor(private readonly allCards: AllCardsService, init = true) {\r\n\t\tif (init) {\r\n\t\t\tthis.inititialize();\r\n\t\t}\r\n\t}\r\n\r\n\tpublic inititialize(validTribes?: readonly Race[], anomalies?: readonly string[]): void {\r\n\t\tconst poolWithoutGolden = this.allCards\r\n\t\t\t.getCards()\r\n\t\t\t.filter((card) => isBattlegroundsCard(card))\r\n\t\t\t.filter((card) => !NON_BUYABLE_MINION_IDS.includes(card.id as CardIds))\r\n\t\t\t.filter((card) => !!card.techLevel)\r\n\t\t\t.filter((card) => !hasMechanic(card, GameTag[GameTag.BACON_BUDDY]))\r\n\t\t\t.filter((card) => card.set !== 'Vanilla')\r\n\t\t\t.filter((card) =>\r\n\t\t\t\tanomalies?.includes(CardIds.BigLeague_BG27_Anomaly_100)\r\n\t\t\t\t\t? card.techLevel >= 3\r\n\t\t\t\t\t: anomalies?.includes(CardIds.LittleLeague_BG27_Anomaly_800)\r\n\t\t\t\t\t? card.techLevel <= 4\r\n\t\t\t\t\t: true,\r\n\t\t\t);\r\n\t\tthis.pool = poolWithoutGolden.filter((card) =>\r\n\t\t\tanomalies?.includes(CardIds.TheGoldenArena_BG27_Anomaly_801) ? this.isGolden(card) : !this.isGolden(card),\r\n\t\t);\r\n\t\tthis.minionsForTier = groupByFunction((card: ReferenceCard) => card.techLevel)(this.pool);\r\n\t\tthis.ghastcoilerSpawns = this.pool\r\n\t\t\t.filter((card) => card.id !== 'BGS_008')\r\n\t\t\t.filter((card) => hasMechanic(card, 'DEATHRATTLE'))\r\n\t\t\t.filter((card) => this.isValidTribe(validTribes, card.races))\r\n\t\t\t.map((card) => card.id);\r\n\t\tthis.validDeathrattles = poolWithoutGolden\r\n\t\t\t.filter((card) => hasMechanic(card, 'DEATHRATTLE'))\r\n\t\t\t.filter((card) => this.isValidTribe(validTribes, card.races))\r\n\t\t\t.map((card) => card.id);\r\n\t\tthis.demonSpawns = this.pool.filter((card) => isCorrectTribe(card.races, Race.DEMON)).map((card) => card.id);\r\n\t\tthis.impMamaSpawns = this.demonSpawns.filter((cardId) => cardId !== CardIds.ImpMama_BGS_044);\r\n\t\tthis.gentleDjinniSpawns = this.pool\r\n\t\t\t.filter((card) => isCorrectTribe(card.races, Race.ELEMENTAL))\r\n\t\t\t.filter((card) => card.id !== CardIds.GentleDjinni_BGS_121)\r\n\t\t\t.map((card) => card.id);\r\n\t\t// FIXME: just spawn a random undead instead of an Undead Creation\r\n\t\t// this.festergutSpawns = pool\r\n\t\t// \t.filter((card) => !this.isGolden(card))\r\n\t\t// \t.filter((card) => isCorrectTribe(card.races, Race.UNDEAD))\r\n\t\t// \t.filter((card) => card.id !== CardIds.Festergut_BG25_HERO_100_Buddy)\r\n\t\t// \t// .filter((card) => REMOVED_CARD_IDS.indexOf(card.id) === -1)\r\n\t\t// \t.map((card) => card.id);\r\n\t\tthis.kilrekSpawns = this.pool\r\n\t\t\t.filter((card) => isCorrectTribe(card.races, Race.DEMON))\r\n\t\t\t.filter((card) => card.id !== CardIds.Kilrek_TB_BaconShop_HERO_37_Buddy)\r\n\t\t\t.map((card) => card.id);\r\n\t\tthis.brannEpicEggSpawns = this.pool.filter((card) => hasMechanic(card, 'BATTLECRY')).map((card) => card.id);\r\n\t\tthis.pirateSpawns = this.pool.filter((card) => isCorrectTribe(card.races, Race.PIRATE)).map((card) => card.id);\r\n\t\tthis.beastSpawns = this.pool.filter((card) => isCorrectTribe(card.races, Race.BEAST)).map((card) => card.id);\r\n\t\tthis.scrapScraperSpawns = this.pool\r\n\t\t\t.filter((card) => hasMechanic(card, GameTag[GameTag.MAGNETIC]))\r\n\t\t\t.map((card) => card.id);\r\n\r\n\t\tthis.putricidePool1 = this.pool.filter((card) => card.battlegroundsPutridicePool1).map((card) => card.id);\r\n\t\tthis.putricidePool2 = this.pool.filter((card) => card.battlegroundsPutridicePool2).map((card) => card.id);\r\n\t\tthis.putridicePool2ForEternalSummoner = this.pool\r\n\t\t\t.filter((card) => card.battlegroundsPutridicePool2)\r\n\t\t\t.filter((card) => !card.battlegroundsPutridiceSummonerExclusion)\r\n\t\t\t.map((card) => card.id);\r\n\t}\r\n\r\n\tpublic avengeValue(cardId: string): number {\r\n\t\tswitch (cardId) {\r\n\t\t\tcase CardIds.BirdBuddy_BG21_002:\r\n\t\t\tcase CardIds.BirdBuddy_BG21_002_G:\r\n\t\t\tcase CardIds.HungeringAbomination_BG25_014:\r\n\t\t\tcase CardIds.HungeringAbomination_BG25_014_G:\r\n\t\t\t// Not technically an avenge, but behaves as if\r\n\t\t\tcase CardIds.ShadowyConstruct_BG25_HERO_103_Buddy:\r\n\t\t\tcase CardIds.ShadowyConstruct_BG25_HERO_103_Buddy_G:\r\n\t\t\tcase CardIds.Bristlebach_BG26_157:\r\n\t\t\tcase CardIds.Bristlebach_BG26_157_G:\r\n\t\t\tcase CardIds.IceSickle:\r\n\t\t\t\treturn 1;\r\n\t\t\tcase CardIds.GhoulOfTheFeast_BG25_002:\r\n\t\t\tcase CardIds.GhoulOfTheFeast_BG25_002_G:\r\n\t\t\tcase CardIds.MechanoTank_BG21_023:\r\n\t\t\tcase CardIds.MechanoTank_BG21_023_G:\r\n\t\t\tcase CardIds.PalescaleCrocolisk_BG21_001:\r\n\t\t\tcase CardIds.PalescaleCrocolisk_BG21_001_G:\r\n\t\t\tcase CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy:\r\n\t\t\tcase CardIds.StormpikeLieutenant_BG22_HERO_003_Buddy_G:\r\n\t\t\tcase CardIds.VanndarStormpike_LeadTheStormpikes:\r\n\t\t\tcase CardIds.Drekthar_LeadTheFrostwolves:\r\n\t\t\t\treturn 2;\r\n\t\t\tcase CardIds.BuddingGreenthumb_BG21_030:\r\n\t\t\tcase CardIds.BuddingGreenthumb_BG21_030_G:\r\n\t\t\t// case CardIds.FrostwolfLieutenant:\r\n\t\t\t// case CardIds.FrostwolfLieutenantBattlegrounds:\r\n\t\t\tcase CardIds.Onyxia_Broodmother:\r\n\t\t\tcase CardIds.PashmarTheVengeful_BG23_014:\r\n\t\t\tcase CardIds.PashmarTheVengeful_BG23_014_G:\r\n\t\t\tcase CardIds.WitchwingNestmatron_BG21_038:\r\n\t\t\tcase CardIds.WitchwingNestmatron_BG21_038_G:\r\n\t\t\tcase CardIds.BoomSquad_BG27_Reward_502:\r\n\t\t\tcase CardIds.ChampionOfThePrimus_BG27_029:\r\n\t\t\tcase CardIds.ChampionOfThePrimus_BG27_029_G:\r\n\t\t\t\treturn 3;\r\n\t\t\tcase CardIds.ImpatientDoomsayer_BG21_007:\r\n\t\t\tcase CardIds.ImpatientDoomsayer_BG21_007_G:\r\n\t\t\tcase CardIds.Sisefin_BG21_009:\r\n\t\t\tcase CardIds.Sisefin_BG21_009_G:\r\n\t\t\tcase CardIds.TonyTwoTusk_BG21_031:\r\n\t\t\tcase CardIds.TonyTwoTusk_BG21_031_G:\r\n\t\t\tcase CardIds.ScrapScraper_BG26_148:\r\n\t\t\tcase CardIds.ScrapScraper_BG26_148_G:\r\n\t\t\tcase CardIds.RelentlessSentry_BG25_003:\r\n\t\t\tcase CardIds.RelentlessSentry_BG25_003_G:\r\n\t\t\t\treturn 4;\r\n\t\t\tcase CardIds.RelentlessMurghoul_BG27_010:\r\n\t\t\tcase CardIds.RelentlessMurghoul_BG27_010_G:\r\n\t\t\t\treturn 5;\r\n\t\t}\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tpublic getTavernLevel(cardId: string): number {\r\n\t\treturn this.allCards.getCard(cardId).techLevel ?? 1;\r\n\t}\r\n\r\n\tpublic getRandomMinionForTavernTier(tavernTier: number): string {\r\n\t\t// Tzvern tier can be undefined for hero-power specific tokens, like the Amalgam, or when\r\n\t\t// for some reason tokens end up in the shop. For now, defaulting to 1 for tavern\r\n\t\t// level seems to work in all cases\r\n\t\tconst minionsForTier = this.minionsForTier[tavernTier ?? 1];\r\n\t\tif (!minionsForTier?.length) {\r\n\t\t\tconsole.error('incorrect minions for tier', tavernTier, this.minionsForTier, minionsForTier);\r\n\t\t}\r\n\t\treturn pickRandom(this.minionsForTier[tavernTier ?? 1])?.id;\r\n\t}\r\n\r\n\tpublic getRandomMinionForTribe(tribe: Race, tavernLimitUpper: number): string {\r\n\t\tconst pool = this.pool\r\n\t\t\t.filter((m) => this.isValidTribe([tribe], m.races))\r\n\t\t\t.filter((m) => m.techLevel <= tavernLimitUpper);\r\n\t\treturn pickRandom(pool)?.id;\r\n\t}\r\n\r\n\tprivate isGolden(card: ReferenceCard): boolean {\r\n\t\treturn !!card.battlegroundsNormalDbfId;\r\n\t}\r\n\r\n\tprivate isValidTribe(validTribes: readonly Race[], cardRaces: readonly string[]): boolean {\r\n\t\t// Blank races are always ok\r\n\t\tif (!cardRaces?.length) {\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\treturn cardRaces\r\n\t\t\t.map((race) => getRaceEnum(race))\r\n\t\t\t.some((raceEnum) => raceEnum === Race.ALL || !validTribes?.length || validTribes.includes(raceEnum));\r\n\t}\r\n}\r\n"]}
|
|
@@ -14,8 +14,8 @@ const addMinionsToBoard = (board, boardHero, otherHero, index, minionsToAdd, all
|
|
|
14
14
|
exports.addMinionsToBoard = addMinionsToBoard;
|
|
15
15
|
const addMinionToBoard = (board, boardHero, otherHero, index, minionToAdd, allCards, spectator, sharedState, performAfterSpawnEffects = true) => {
|
|
16
16
|
board.splice(index, 0, minionToAdd);
|
|
17
|
-
handleSpawnEffect(board, boardHero, otherHero, minionToAdd, allCards, spectator, sharedState);
|
|
18
17
|
(0, exports.handleAddedMinionAuraEffect)(board, boardHero, minionToAdd, allCards, spectator, sharedState);
|
|
18
|
+
handleSpawnEffect(board, boardHero, otherHero, minionToAdd, allCards, spectator, sharedState);
|
|
19
19
|
if (performAfterSpawnEffects) {
|
|
20
20
|
handleAfterSpawnEffects(board, [minionToAdd], allCards, spectator);
|
|
21
21
|
}
|
|
@@ -23,14 +23,6 @@ const addMinionToBoard = (board, boardHero, otherHero, index, minionToAdd, allCa
|
|
|
23
23
|
exports.addMinionToBoard = addMinionToBoard;
|
|
24
24
|
const handleSpawnEffect = (board, boardHero, otherHero, spawned, allCards, spectator, sharedState) => {
|
|
25
25
|
var _a;
|
|
26
|
-
switch (boardHero.heroPowerId) {
|
|
27
|
-
case "TB_BaconShop_HP_107":
|
|
28
|
-
spawned.taunt = true;
|
|
29
|
-
(0, utils_1.modifyAttack)(spawned, 1, board, allCards);
|
|
30
|
-
(0, utils_1.modifyHealth)(spawned, 2, board, allCards);
|
|
31
|
-
(0, utils_1.afterStatsUpdate)(spawned, board, allCards);
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
26
|
const cardIds = [spawned.cardId, ...((_a = spawned.additionalCards) !== null && _a !== void 0 ? _a : [])];
|
|
35
27
|
if (cardIds.some((cardId) => cards_data_1.WHELP_CARD_IDS.includes(cardId))) {
|
|
36
28
|
const manyWhelps = board.filter((entity) => entity.cardId === "BG22_HERO_305_Buddy");
|
|
@@ -123,6 +115,12 @@ const handleSpawnEffect = (board, boardHero, otherHero, spawned, allCards, spect
|
|
|
123
115
|
const handleAddedMinionAuraEffect = (board, boardHero, spawned, allCards, spectator, sharedState) => {
|
|
124
116
|
var _a, _b;
|
|
125
117
|
switch (boardHero.heroPowerId) {
|
|
118
|
+
case "TB_BaconShop_HP_107":
|
|
119
|
+
spawned.taunt = true;
|
|
120
|
+
(0, utils_1.modifyAttack)(spawned, 1, board, allCards);
|
|
121
|
+
(0, utils_1.modifyHealth)(spawned, 2, board, allCards);
|
|
122
|
+
(0, utils_1.afterStatsUpdate)(spawned, board, allCards);
|
|
123
|
+
break;
|
|
126
124
|
case "BG20_HERO_280p3":
|
|
127
125
|
(0, utils_1.modifyAttack)(spawned, 2, board, allCards);
|
|
128
126
|
(0, utils_1.modifyHealth)(spawned, 2, board, allCards);
|
|
@@ -168,6 +166,7 @@ const handleAddedMinionAuraEffect = (board, boardHero, spawned, allCards, specta
|
|
|
168
166
|
(0, utils_1.modifyAttack)(spawned, boardHero.globalInfo.GoldrinnBuff, board, allCards);
|
|
169
167
|
(0, utils_1.modifyHealth)(spawned, boardHero.globalInfo.GoldrinnBuff, board, allCards);
|
|
170
168
|
(0, utils_1.afterStatsUpdate)(spawned, board, allCards);
|
|
169
|
+
spectator.registerPowerTarget(boardHero, spawned, board);
|
|
171
170
|
}
|
|
172
171
|
}
|
|
173
172
|
for (const entity of board) {
|
|
@@ -355,6 +354,7 @@ const handleAfterSpawnEffect = (board, spawned, allCards, spectator) => {
|
|
|
355
354
|
const bananaStatBuff = entity.cardId === "BG26_802_G" ? 3 : 2;
|
|
356
355
|
spawned.attack = spawned.attack * bananaStatBuff;
|
|
357
356
|
spawned.health = spawned.health * bananaStatBuff;
|
|
357
|
+
spectator.registerPowerTarget(entity, spawned, board);
|
|
358
358
|
}
|
|
359
359
|
break;
|
|
360
360
|
case "BG26_370":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-minion-to-board.js","sourceRoot":"","sources":["../../src/simulation/add-minion-to-board.ts"],"names":[],"mappings":";;;AAAA,iEAA8E;AAG9E,oDAAqD;AACrD,oCAQkB;AAIX,MAAM,iBAAiB,GAAG,CAChC,KAAoB,EACpB,SAA0B,EAC1B,SAA0B,EAC1B,KAAa,EACb,YAAoC,EACpC,QAAyB,EACzB,SAAoB,EACpB,WAAwB,EACjB,EAAE;IACT,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,YAAY,CAAC,CAAC;IACxC,KAAK,MAAM,WAAW,IAAI,CAAC,GAAG,YAAY,CAAC,CAAC,OAAO,EAAE,EAAE;QACtD,IAAA,wBAAgB,EAAC,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;KAC3G;IACD,uBAAuB,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AACnE,CAAC,CAAC;AAfW,QAAA,iBAAiB,qBAe5B;AAEK,MAAM,gBAAgB,GAAG,CAC/B,KAAoB,EACpB,SAA0B,EAC1B,SAA0B,EAC1B,KAAa,EACb,WAAwB,EACxB,QAAyB,EACzB,SAAoB,EACpB,WAAwB,EACxB,wBAAwB,GAAG,IAAI,EACxB,EAAE;IACT,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;IAEpC,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;IAC9F,IAAA,mCAA2B,EAAC,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;IAC7F,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ACnC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,mBAAyC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBACpF,IAAA,uBAAe,EAAC,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;iBACrE;gBACD,MAAM;YAGP;gBACC,IAAI,IAAA,uBAAe,EAAC,OAAO,EAAE,qBAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,CAAC,QAAQ,EAAE;oBAC5F,IAAA,oBAAY,EAAC,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;oBAC1C,IAAA,wBAAgB,EAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;oBAC1C,SAAS,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;iBACrD;gBACD,MAAM;SACP;KACD;AACF,CAAC,CAAC","sourcesContent":["import { AllCardsService, CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { WHELP_CARD_IDS } from '../cards/cards-data';\r\nimport {\r\n\taddStatsToBoard,\r\n\tafterStatsUpdate,\r\n\thasCorrectTribe,\r\n\tisCorrectTribe,\r\n\tmodifyAttack,\r\n\tmodifyHealth,\r\n\tupdateDivineShield,\r\n} from '../utils';\r\nimport { SharedState } from './shared-state';\r\nimport { Spectator } from './spectator/spectator';\r\n\r\nexport const addMinionsToBoard = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n\tindex: number,\r\n\tminionsToAdd: readonly BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tsharedState: SharedState,\r\n): void => {\r\n\tboard.splice(index, 0, ...minionsToAdd);\r\n\tfor (const minionToAdd of [...minionsToAdd].reverse()) {\r\n\t\taddMinionToBoard(board, boardHero, otherHero, index, minionToAdd, allCards, spectator, sharedState, false);\r\n\t}\r\n\thandleAfterSpawnEffects(board, minionsToAdd, allCards, spectator);\r\n};\r\n\r\nexport const addMinionToBoard = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n\tindex: number,\r\n\tminionToAdd: BoardEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tsharedState: SharedState,\r\n\tperformAfterSpawnEffects = true,\r\n): void => {\r\n\tboard.splice(index, 0, minionToAdd);\r\n\t// Minion has already been removed from the board in the previous step\r\n\thandleSpawnEffect(board, boardHero, otherHero, minionToAdd, allCards, spectator, sharedState);\r\n\thandleAddedMinionAuraEffect(board, boardHero, minionToAdd, allCards, spectator, sharedState);\r\n\tif (performAfterSpawnEffects) {\r\n\t\thandleAfterSpawnEffects(board, [minionToAdd], allCards, spectator);\r\n\t}\r\n};\r\n\r\nconst handleSpawnEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n\tspawned: BoardEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tsharedState: SharedState,\r\n): void => {\r\n\tswitch (boardHero.heroPowerId) {\r\n\t\tcase CardIds.SproutItOut:\r\n\t\t\tspawned.taunt = true;\r\n\t\t\tmodifyAttack(spawned, 1, board, allCards);\r\n\t\t\tmodifyHealth(spawned, 2, board, allCards);\r\n\t\t\tafterStatsUpdate(spawned, board, allCards);\r\n\t\t\tbreak;\r\n\t}\r\n\r\n\tconst cardIds = [spawned.cardId, ...(spawned.additionalCards ?? [])];\r\n\r\n\t// https://twitter.com/LoewenMitchell/status/1491879869457879040\r\n\tif (cardIds.some((cardId) => WHELP_CARD_IDS.includes(cardId as CardIds))) {\r\n\t\tconst manyWhelps = board.filter((entity) => entity.cardId === CardIds.ManyWhelps_BG22_HERO_305_Buddy);\r\n\t\tconst goldenManyWhelps = board.filter((entity) => entity.cardId === CardIds.ManyWhelps_BG22_HERO_305_Buddy_G);\r\n\t\tmanyWhelps.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 2, board, allCards);\r\n\t\t\tmodifyHealth(entity, 2, board, allCards);\r\n\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t});\r\n\t\tgoldenManyWhelps.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 4, board, allCards);\r\n\t\t\tmodifyHealth(entity, 4, board, allCards);\r\n\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t});\r\n\t}\r\n\r\n\tfor (const entity of board) {\r\n\t\tswitch (entity.cardId) {\r\n\t\t\tcase CardIds.BabyYshaarj_TB_BaconShop_HERO_92_Buddy:\r\n\t\t\tcase CardIds.BabyYshaarj_TB_BaconShop_HERO_92_Buddy_G:\r\n\t\t\t\tif (allCards.getCard(spawned.cardId).techLevel === boardHero.tavernTier) {\r\n\t\t\t\t\tconst statsBonus = entity.cardId === CardIds.BabyYshaarj_TB_BaconShop_HERO_92_Buddy_G ? 8 : 4;\r\n\t\t\t\t\tmodifyAttack(spawned, statsBonus, board, allCards);\r\n\t\t\t\t\tmodifyHealth(spawned, statsBonus, board, allCards);\r\n\t\t\t\t\tafterStatsUpdate(spawned, board, allCards);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t// This has to happen after greybough's hero power kicks in\r\n\t\t\tcase CardIds.WanderingTreant_TB_BaconShop_HERO_95_Buddy:\r\n\t\t\tcase CardIds.WanderingTreant_TB_BaconShop_HERO_95_Buddy_G:\r\n\t\t\t\tif (spawned.taunt) {\r\n\t\t\t\t\tconst statsBonus = entity.cardId === CardIds.WanderingTreant_TB_BaconShop_HERO_95_Buddy_G ? 4 : 2;\r\n\t\t\t\t\tmodifyAttack(spawned, statsBonus, board, allCards);\r\n\t\t\t\t\tmodifyHealth(spawned, statsBonus, board, allCards);\r\n\t\t\t\t\tafterStatsUpdate(spawned, board, allCards);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.CobaltGuardian:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.MECH, allCards)) {\r\n\t\t\t\t\tif (!entity.divineShield) {\r\n\t\t\t\t\t\tupdateDivineShield(entity, board, true, allCards);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tmodifyAttack(entity, 2, board, allCards);\r\n\t\t\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\t\t\tspectator.registerPowerTarget(entity, entity, board);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.DeflectOBot_BGS_071:\r\n\t\t\tcase CardIds.DeflectOBot_TB_BaconUps_123:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.MECH, allCards)) {\r\n\t\t\t\t\tconst statsBonus = entity.cardId === CardIds.DeflectOBot_TB_BaconUps_123 ? 4 : 2;\r\n\t\t\t\t\tif (!entity.divineShield) {\r\n\t\t\t\t\t\tupdateDivineShield(entity, board, true, allCards);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tmodifyAttack(entity, statsBonus, board, allCards);\r\n\t\t\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\t\t\tspectator.registerPowerTarget(entity, entity, board);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Bigfernal_BGS_204:\r\n\t\t\tcase CardIds.Bigfernal_TB_BaconUps_304:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.DEMON, allCards)) {\r\n\t\t\t\t\tconst statsBonus = entity.cardId === CardIds.Bigfernal_TB_BaconUps_304 ? 2 : 1;\r\n\t\t\t\t\tmodifyAttack(entity, statsBonus, board, allCards);\r\n\t\t\t\t\tmodifyHealth(entity, statsBonus, board, allCards);\r\n\t\t\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\t\t\tspectator.registerPowerTarget(entity, entity, board);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.MamaBear_BGS_021:\r\n\t\t\tcase CardIds.MamaBear_TB_BaconUps_090:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.BEAST, allCards)) {\r\n\t\t\t\t\tconst statsBonus = entity.cardId === CardIds.MamaBear_TB_BaconUps_090 ? 8 : 4;\r\n\t\t\t\t\tmodifyAttack(spawned, statsBonus, board, allCards);\r\n\t\t\t\t\tmodifyHealth(spawned, statsBonus, board, allCards);\r\n\t\t\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\t\t\tspectator.registerPowerTarget(entity, entity, board);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.PackLeader_BGS_017:\r\n\t\t\tcase CardIds.PackLeader_TB_BaconUps_086:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.BEAST, allCards)) {\r\n\t\t\t\t\tconst statsBonus = entity.cardId === CardIds.PackLeader_TB_BaconUps_086 ? 4 : 2;\r\n\t\t\t\t\tmodifyAttack(spawned, statsBonus, board, allCards);\r\n\t\t\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\t\t\tspectator.registerPowerTarget(entity, entity, board);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\nexport const handleAddedMinionAuraEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tspawned: BoardEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tsharedState: SharedState,\r\n): void => {\r\n\tswitch (boardHero.heroPowerId) {\r\n\t\tcase CardIds.KurtrusAshfallen_CloseThePortal:\r\n\t\t\tmodifyAttack(spawned, 2, board, allCards);\r\n\t\t\tmodifyHealth(spawned, 2, board, allCards);\r\n\t\t\tafterStatsUpdate(spawned, board, allCards);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Tinker_TB_BaconShop_HP_015:\r\n\t\t\tif (hasCorrectTribe(spawned, Race.MECH, allCards)) {\r\n\t\t\t\tmodifyAttack(spawned, 2, board, allCards);\r\n\t\t\t\tafterStatsUpdate(spawned, board, allCards);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t}\r\n\r\n\tif (!!boardHero.questRewards?.length) {\r\n\t\tfor (const quest of boardHero.questRewards) {\r\n\t\t\tswitch (quest) {\r\n\t\t\t\tcase CardIds.VolatileVenom:\r\n\t\t\t\t\tspawned.attack += 7;\r\n\t\t\t\t\tspawned.health += 7;\r\n\t\t\t\t\tspawned.enchantments.push({\r\n\t\t\t\t\t\tcardId: CardIds.VolatileVenom_VolatileEnchantment,\r\n\t\t\t\t\t\toriginEntityId: undefined,\r\n\t\t\t\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t\t\t\t});\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.TheSmokingGun:\r\n\t\t\t\t\tspawned.attack += 4;\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tconst cardIds = [spawned.cardId, ...(spawned.additionalCards ?? [])];\r\n\tfor (const spawnedCardId of cardIds) {\r\n\t\thandleMinionAddedAuraEffect(spawnedCardId, spawned, board, boardHero, allCards, spectator, sharedState);\r\n\t}\r\n\r\n\tif (hasCorrectTribe(spawned, Race.UNDEAD, allCards)) {\r\n\t\tif (boardHero.globalInfo.UndeadAttackBonus > 0) {\r\n\t\t\tmodifyAttack(spawned, boardHero.globalInfo.UndeadAttackBonus, board, allCards);\r\n\t\t\tafterStatsUpdate(spawned, board, allCards);\r\n\t\t}\r\n\t}\r\n\tif (hasCorrectTribe(spawned, Race.BEAST, allCards)) {\r\n\t\tif (boardHero.globalInfo.GoldrinnBuff > 0) {\r\n\t\t\tmodifyAttack(spawned, boardHero.globalInfo.GoldrinnBuff, board, allCards);\r\n\t\t\tmodifyHealth(spawned, boardHero.globalInfo.GoldrinnBuff, board, allCards);\r\n\t\t\tafterStatsUpdate(spawned, board, allCards);\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const entity of board) {\r\n\t\tswitch (entity.cardId) {\r\n\t\t\tcase CardIds.MurlocWarleaderLegacy_BG_EX1_507:\r\n\t\t\tcase CardIds.MurlocWarleaderLegacy_TB_BaconUps_008:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.MURLOC, allCards) && entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tspawned.attack += entity.cardId === CardIds.MurlocWarleaderLegacy_TB_BaconUps_008 ? 4 : 2;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.HummingBird_BG26_805:\r\n\t\t\tcase CardIds.HummingBird_BG26_805_G:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.BEAST, allCards) && entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tspawned.attack += entity.cardId === CardIds.HummingBird_BG26_805_G ? 4 : 2;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SouthseaCaptainLegacy_BG_NEW1_027:\r\n\t\t\tcase CardIds.SouthseaCaptainLegacy_TB_BaconUps_136:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.PIRATE, allCards) && entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tspawned.attack += entity.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1;\r\n\t\t\t\t\tspawned.health += entity.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy:\r\n\t\t\tcase CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy_G:\r\n\t\t\t\tspawned.attack += entity.cardId === CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy_G ? 6 : 3;\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Kathranatir_BG21_039:\r\n\t\t\tcase CardIds.Kathranatir_BG21_039_G:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.DEMON, allCards) && entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tspawned.attack += entity.cardId === CardIds.Kathranatir_BG21_039_G ? 2 : 1;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.CyborgDrake_BG25_043:\r\n\t\t\tcase CardIds.CyborgDrake_BG25_043_G:\r\n\t\t\t\tif (spawned.divineShield) {\r\n\t\t\t\t\tspawned.attack += entity.cardId === CardIds.CyborgDrake_BG25_043_G ? 12 : 6;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SoreLoser_BG27_030:\r\n\t\t\tcase CardIds.SoreLoser_BG27_030_G:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.UNDEAD, allCards) && entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tspawned.attack += (entity.cardId === CardIds.SoreLoser_BG27_030_G ? 2 : 1) * boardHero.tavernTier;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const handleMinionAddedAuraEffect = (\r\n\tspawnedCardId: string,\r\n\tspawned: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tsharedState: SharedState,\r\n): void => {\r\n\tswitch (spawnedCardId) {\r\n\t\tcase CardIds.SouthseaCaptainLegacy_BG_NEW1_027:\r\n\t\tcase CardIds.SouthseaCaptainLegacy_TB_BaconUps_136:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, Race.PIRATE, allCards))\r\n\t\t\t\t// Other\r\n\t\t\t\t.filter((e) => e.entityId !== spawned.entityId)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += spawned.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1;\r\n\t\t\t\t\te.health += spawned.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1;\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.MurlocWarleaderLegacy_BG_EX1_507:\r\n\t\tcase CardIds.MurlocWarleaderLegacy_TB_BaconUps_008:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, Race.MURLOC, allCards))\r\n\t\t\t\t.filter((e) => e.entityId !== spawned.entityId)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += spawned.cardId === CardIds.MurlocWarleaderLegacy_TB_BaconUps_008 ? 4 : 2;\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.HummingBird_BG26_805:\r\n\t\tcase CardIds.HummingBird_BG26_805_G:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, Race.BEAST, allCards))\r\n\t\t\t\t.filter((e) => e.entityId !== spawned.entityId)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += spawned.cardId === CardIds.HummingBird_BG26_805_G ? 4 : 2;\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy:\r\n\t\tcase CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy_G:\r\n\t\t\tboard.forEach((e) => {\r\n\t\t\t\te.attack += spawned.cardId === CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy_G ? 6 : 3;\r\n\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Kathranatir_BG21_039:\r\n\t\tcase CardIds.Kathranatir_BG21_039_G:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, Race.DEMON, allCards))\r\n\t\t\t\t.filter((e) => e.entityId !== spawned.entityId)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += spawned.cardId === CardIds.Kathranatir_BG21_039_G ? 4 : 2;\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.CyborgDrake_BG25_043:\r\n\t\tcase CardIds.CyborgDrake_BG25_043_G:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => e.divineShield)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += spawned.cardId === CardIds.CyborgDrake_BG25_043_G ? 12 : 6;\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\r\n\t\tcase CardIds.EternalKnight_BG25_008:\r\n\t\tcase CardIds.EternalKnight_BG25_008_G:\r\n\t\t\tconst multiplierKnight = spawned.cardId === CardIds.EternalKnight_BG25_008_G ? 2 : 1;\r\n\t\t\tconst statsBonusKnight = multiplierKnight * boardHero.globalInfo.EternalKnightsDeadThisGame;\r\n\t\t\tmodifyAttack(spawned, statsBonusKnight, board, allCards);\r\n\t\t\tmodifyHealth(spawned, statsBonusKnight, board, allCards);\r\n\t\t\tafterStatsUpdate(spawned, board, allCards);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.FlourishingFrostling_BG26_537:\r\n\t\tcase CardIds.FlourishingFrostling_BG26_537_G:\r\n\t\t\tconst multiplierFrostling = spawned.cardId === CardIds.FlourishingFrostling_BG26_537_G ? 2 : 1;\r\n\t\t\tconst statsBonusFrostling = multiplierFrostling * boardHero.globalInfo.FrostlingBonus;\r\n\t\t\tmodifyAttack(spawned, statsBonusFrostling, board, allCards);\r\n\t\t\tafterStatsUpdate(spawned, board, allCards);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.RotHideGnoll_BG25_013:\r\n\t\tcase CardIds.RotHideGnoll_BG25_013_G:\r\n\t\t\tconst multiplierGnoll = spawned.cardId === CardIds.RotHideGnoll_BG25_013_G ? 2 : 1;\r\n\t\t\tconst statsBonusGnoll =\r\n\t\t\t\tmultiplierGnoll * sharedState.deaths.filter((e) => e.friendly === spawned.friendly).length;\r\n\t\t\tmodifyAttack(spawned, statsBonusGnoll, board, allCards);\r\n\t\t\tafterStatsUpdate(spawned, board, allCards);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.SoreLoser_BG27_030:\r\n\t\tcase CardIds.SoreLoser_BG27_030_G:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, Race.UNDEAD, allCards))\r\n\t\t\t\t.filter((e) => e.entityId !== spawned.entityId)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += (spawned.cardId === CardIds.SoreLoser_BG27_030_G ? 2 : 1) * boardHero.tavernTier;\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t}\r\n};\r\n\r\nconst handleAfterSpawnEffects = (\r\n\tboard: BoardEntity[],\r\n\tallSpawned: readonly BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tfor (const spawned of allSpawned) {\r\n\t\thandleAfterSpawnEffect(board, spawned, allCards, spectator);\r\n\t}\r\n};\r\n\r\nconst handleAfterSpawnEffect = (\r\n\tboard: BoardEntity[],\r\n\tspawned: BoardEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// console.debug('after spawn', stringifySimpleCard(spawned, allCards), stringifySimple(board, allCards));\r\n\tfor (const entity of board) {\r\n\t\tswitch (entity.cardId) {\r\n\t\t\t// case CardIds.MurlocTidecallerLegacy:\r\n\t\t\t// case CardIds.MurlocTidecallerCore:\r\n\t\t\t// \tconst multiplier = entity.cardId === CardIds.MurlocTidecallerBattlegrounds ? 2 : 1;\r\n\t\t\t// \tconst buffAmount =\r\n\t\t\t// \t\tmultiplier * (isCorrectTribe(allCards.getCard(spawned.cardId).races, Race.MURLOC) ? 1 : 0);\r\n\t\t\t// \tif (buffAmount > 0) {\r\n\t\t\t// \t\tmodifyAttack(entity, buffAmount, board, allCards);\r\n\t\t\t// \t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\t// \t\tspectator.registerPowerTarget(entity, entity, board);\r\n\t\t\t// \t}\r\n\t\t\t// \tbreak;\r\n\t\t\tcase CardIds.Swampstriker_BG22_401:\r\n\t\t\tcase CardIds.Swampstriker_BG22_401_G:\r\n\t\t\t\tif (entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tconst multiplier2 = entity.cardId === CardIds.Swampstriker_BG22_401_G ? 2 : 1;\r\n\t\t\t\t\tconst buffAmount2 =\r\n\t\t\t\t\t\tmultiplier2 * (isCorrectTribe(allCards.getCard(spawned.cardId).races, Race.MURLOC) ? 1 : 0);\r\n\t\t\t\t\tif (buffAmount2 > 0) {\r\n\t\t\t\t\t\tmodifyAttack(entity, buffAmount2, board, allCards);\r\n\t\t\t\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\t\t\t\tspectator.registerPowerTarget(entity, entity, board);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Felstomper_BG25_042:\r\n\t\t\tcase CardIds.Felstomper_BG25_042_G:\r\n\t\t\t\t// console.debug('felstomper');\r\n\t\t\t\tif (entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tconst felstomperBuff = entity.cardId === CardIds.Felstomper_BG25_042_G ? 6 : 3;\r\n\t\t\t\t\tboard.forEach((e) => {\r\n\t\t\t\t\t\tmodifyAttack(e, felstomperBuff, board, allCards);\r\n\t\t\t\t\t\tafterStatsUpdate(e, board, allCards);\r\n\t\t\t\t\t\tspectator.registerPowerTarget(entity, e, board);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.XyloBones_BG26_172:\r\n\t\t\tcase CardIds.XyloBones_BG26_172_G:\r\n\t\t\t\tif (entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tconst xylobonesBuff = entity.cardId === CardIds.XyloBones_BG26_172_G ? 6 : 3;\r\n\t\t\t\t\tmodifyHealth(entity, xylobonesBuff, board, allCards);\r\n\t\t\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\t\t\tspectator.registerPowerTarget(entity, entity, board);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.OctosariWrapGod_BG26_804:\r\n\t\t\tcase CardIds.OctosariWrapGod_BG26_804_G:\r\n\t\t\t\tconst octoStats = entity.cardId === CardIds.OctosariWrapGod_BG26_804_G ? 4 : 2;\r\n\t\t\t\tentity.scriptDataNum1 += octoStats;\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.BananaSlamma_BG26_802:\r\n\t\t\tcase CardIds.BananaSlamma_BG26_802_G:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.BEAST, allCards) && entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tconst bananaStatBuff = entity.cardId === CardIds.BananaSlamma_BG26_802_G ? 3 : 2;\r\n\t\t\t\t\tspawned.attack = spawned.attack * bananaStatBuff;\r\n\t\t\t\t\tspawned.health = spawned.health * bananaStatBuff;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.HungrySnapjaw_BG26_370:\r\n\t\t\tcase CardIds.HungrySnapjaw_BG26_370_G:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.BEAST, allCards) && entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tconst snapjawBuff = entity.cardId === CardIds.HungrySnapjaw_BG26_370_G ? 2 : 1;\r\n\t\t\t\t\tmodifyHealth(entity, snapjawBuff, board, allCards);\r\n\t\t\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ObserverOfMyths_BG_TTN_078:\r\n\t\t\tcase CardIds.ObserverOfMyths_BG_TTN_078_G:\r\n\t\t\t\tif (spawned.attack > entity.attack) {\r\n\t\t\t\t\tconst observerBuff = entity.cardId === CardIds.ObserverOfMyths_BG_TTN_078_G ? 2 : 1;\r\n\t\t\t\t\taddStatsToBoard(entity, board, observerBuff, 0, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t// Putricide-only\r\n\t\t\tcase CardIds.ArmsDealer_BG26_RLK_824:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.UNDEAD, allCards) && entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tmodifyAttack(spawned, 1, board, allCards);\r\n\t\t\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\t\t\tspectator.registerPowerTarget(entity, entity, board);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"add-minion-to-board.js","sourceRoot":"","sources":["../../src/simulation/add-minion-to-board.ts"],"names":[],"mappings":";;;AAAA,iEAA8E;AAG9E,oDAAqD;AACrD,oCAQkB;AAIX,MAAM,iBAAiB,GAAG,CAChC,KAAoB,EACpB,SAA0B,EAC1B,SAA0B,EAC1B,KAAa,EACb,YAAoC,EACpC,QAAyB,EACzB,SAAoB,EACpB,WAAwB,EACjB,EAAE;IACT,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,YAAY,CAAC,CAAC;IACxC,KAAK,MAAM,WAAW,IAAI,CAAC,GAAG,YAAY,CAAC,CAAC,OAAO,EAAE,EAAE;QACtD,IAAA,wBAAgB,EAAC,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;KAC3G;IACD,uBAAuB,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AACnE,CAAC,CAAC;AAfW,QAAA,iBAAiB,qBAe5B;AAEK,MAAM,gBAAgB,GAAG,CAC/B,KAAoB,EACpB,SAA0B,EAC1B,SAA0B,EAC1B,KAAa,EACb,WAAwB,EACxB,QAAyB,EACzB,SAAoB,EACpB,W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AAC,KAAK,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,CAAC,QAAQ,EAAE;oBAC3F,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,iBAAqC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC/E,IAAA,oBAAY,EAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;oBACnD,IAAA,wBAAgB,EAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;iBAC1C;gBACD,MAAM;YACP,kBAAwC;YACxC;gBACC,IAAI,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE;oBACnC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,mBAAyC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBACpF,IAAA,uBAAe,EAAC,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;iBACrE;gBACD,MAAM;YAGP;gBACC,IAAI,IAAA,uBAAe,EAAC,OAAO,EAAE,qBAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,CAAC,QAAQ,EAAE;oBAC5F,IAAA,oBAAY,EAAC,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;oBAC1C,IAAA,wBAAgB,EAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;oBAC1C,SAAS,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;iBACrD;gBACD,MAAM;SACP;KACD;AACF,CAAC,CAAC","sourcesContent":["import { AllCardsService, CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { WHELP_CARD_IDS } from '../cards/cards-data';\r\nimport {\r\n\taddStatsToBoard,\r\n\tafterStatsUpdate,\r\n\thasCorrectTribe,\r\n\tisCorrectTribe,\r\n\tmodifyAttack,\r\n\tmodifyHealth,\r\n\tupdateDivineShield,\r\n} from '../utils';\r\nimport { SharedState } from './shared-state';\r\nimport { Spectator } from './spectator/spectator';\r\n\r\nexport const addMinionsToBoard = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n\tindex: number,\r\n\tminionsToAdd: readonly BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tsharedState: SharedState,\r\n): void => {\r\n\tboard.splice(index, 0, ...minionsToAdd);\r\n\tfor (const minionToAdd of [...minionsToAdd].reverse()) {\r\n\t\taddMinionToBoard(board, boardHero, otherHero, index, minionToAdd, allCards, spectator, sharedState, false);\r\n\t}\r\n\thandleAfterSpawnEffects(board, minionsToAdd, allCards, spectator);\r\n};\r\n\r\nexport const addMinionToBoard = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n\tindex: number,\r\n\tminionToAdd: BoardEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tsharedState: SharedState,\r\n\tperformAfterSpawnEffects = true,\r\n): void => {\r\n\tboard.splice(index, 0, minionToAdd);\r\n\t// Minion has already been removed from the board in the previous step\r\n\thandleAddedMinionAuraEffect(board, boardHero, minionToAdd, allCards, spectator, sharedState);\r\n\thandleSpawnEffect(board, boardHero, otherHero, minionToAdd, allCards, spectator, sharedState);\r\n\tif (performAfterSpawnEffects) {\r\n\t\thandleAfterSpawnEffects(board, [minionToAdd], allCards, spectator);\r\n\t}\r\n};\r\n\r\nconst handleSpawnEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\totherHero: BgsPlayerEntity,\r\n\tspawned: BoardEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tsharedState: SharedState,\r\n): void => {\r\n\tconst cardIds = [spawned.cardId, ...(spawned.additionalCards ?? [])];\r\n\r\n\t// https://twitter.com/LoewenMitchell/status/1491879869457879040\r\n\tif (cardIds.some((cardId) => WHELP_CARD_IDS.includes(cardId as CardIds))) {\r\n\t\tconst manyWhelps = board.filter((entity) => entity.cardId === CardIds.ManyWhelps_BG22_HERO_305_Buddy);\r\n\t\tconst goldenManyWhelps = board.filter((entity) => entity.cardId === CardIds.ManyWhelps_BG22_HERO_305_Buddy_G);\r\n\t\tmanyWhelps.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 2, board, allCards);\r\n\t\t\tmodifyHealth(entity, 2, board, allCards);\r\n\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t});\r\n\t\tgoldenManyWhelps.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 4, board, allCards);\r\n\t\t\tmodifyHealth(entity, 4, board, allCards);\r\n\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t});\r\n\t}\r\n\r\n\tfor (const entity of board) {\r\n\t\tswitch (entity.cardId) {\r\n\t\t\tcase CardIds.BabyYshaarj_TB_BaconShop_HERO_92_Buddy:\r\n\t\t\tcase CardIds.BabyYshaarj_TB_BaconShop_HERO_92_Buddy_G:\r\n\t\t\t\tif (allCards.getCard(spawned.cardId).techLevel === boardHero.tavernTier) {\r\n\t\t\t\t\tconst statsBonus = entity.cardId === CardIds.BabyYshaarj_TB_BaconShop_HERO_92_Buddy_G ? 8 : 4;\r\n\t\t\t\t\tmodifyAttack(spawned, statsBonus, board, allCards);\r\n\t\t\t\t\tmodifyHealth(spawned, statsBonus, board, allCards);\r\n\t\t\t\t\tafterStatsUpdate(spawned, board, allCards);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t// This has to happen after greybough's hero power kicks in\r\n\t\t\tcase CardIds.WanderingTreant_TB_BaconShop_HERO_95_Buddy:\r\n\t\t\tcase CardIds.WanderingTreant_TB_BaconShop_HERO_95_Buddy_G:\r\n\t\t\t\tif (spawned.taunt) {\r\n\t\t\t\t\tconst statsBonus = entity.cardId === CardIds.WanderingTreant_TB_BaconShop_HERO_95_Buddy_G ? 4 : 2;\r\n\t\t\t\t\tmodifyAttack(spawned, statsBonus, board, allCards);\r\n\t\t\t\t\tmodifyHealth(spawned, statsBonus, board, allCards);\r\n\t\t\t\t\tafterStatsUpdate(spawned, board, allCards);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.CobaltGuardian:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.MECH, allCards)) {\r\n\t\t\t\t\tif (!entity.divineShield) {\r\n\t\t\t\t\t\tupdateDivineShield(entity, board, true, allCards);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tmodifyAttack(entity, 2, board, allCards);\r\n\t\t\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\t\t\tspectator.registerPowerTarget(entity, entity, board);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.DeflectOBot_BGS_071:\r\n\t\t\tcase CardIds.DeflectOBot_TB_BaconUps_123:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.MECH, allCards)) {\r\n\t\t\t\t\tconst statsBonus = entity.cardId === CardIds.DeflectOBot_TB_BaconUps_123 ? 4 : 2;\r\n\t\t\t\t\tif (!entity.divineShield) {\r\n\t\t\t\t\t\tupdateDivineShield(entity, board, true, allCards);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tmodifyAttack(entity, statsBonus, board, allCards);\r\n\t\t\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\t\t\tspectator.registerPowerTarget(entity, entity, board);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Bigfernal_BGS_204:\r\n\t\t\tcase CardIds.Bigfernal_TB_BaconUps_304:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.DEMON, allCards)) {\r\n\t\t\t\t\tconst statsBonus = entity.cardId === CardIds.Bigfernal_TB_BaconUps_304 ? 2 : 1;\r\n\t\t\t\t\tmodifyAttack(entity, statsBonus, board, allCards);\r\n\t\t\t\t\tmodifyHealth(entity, statsBonus, board, allCards);\r\n\t\t\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\t\t\tspectator.registerPowerTarget(entity, entity, board);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.MamaBear_BGS_021:\r\n\t\t\tcase CardIds.MamaBear_TB_BaconUps_090:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.BEAST, allCards)) {\r\n\t\t\t\t\tconst statsBonus = entity.cardId === CardIds.MamaBear_TB_BaconUps_090 ? 8 : 4;\r\n\t\t\t\t\tmodifyAttack(spawned, statsBonus, board, allCards);\r\n\t\t\t\t\tmodifyHealth(spawned, statsBonus, board, allCards);\r\n\t\t\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\t\t\tspectator.registerPowerTarget(entity, entity, board);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.PackLeader_BGS_017:\r\n\t\t\tcase CardIds.PackLeader_TB_BaconUps_086:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.BEAST, allCards)) {\r\n\t\t\t\t\tconst statsBonus = entity.cardId === CardIds.PackLeader_TB_BaconUps_086 ? 4 : 2;\r\n\t\t\t\t\tmodifyAttack(spawned, statsBonus, board, allCards);\r\n\t\t\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\t\t\tspectator.registerPowerTarget(entity, entity, board);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\nexport const handleAddedMinionAuraEffect = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tspawned: BoardEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tsharedState: SharedState,\r\n): void => {\r\n\tswitch (boardHero.heroPowerId) {\r\n\t\tcase CardIds.SproutItOut:\r\n\t\t\tspawned.taunt = true;\r\n\t\t\tmodifyAttack(spawned, 1, board, allCards);\r\n\t\t\tmodifyHealth(spawned, 2, board, allCards);\r\n\t\t\tafterStatsUpdate(spawned, board, allCards);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.KurtrusAshfallen_CloseThePortal:\r\n\t\t\tmodifyAttack(spawned, 2, board, allCards);\r\n\t\t\tmodifyHealth(spawned, 2, board, allCards);\r\n\t\t\tafterStatsUpdate(spawned, board, allCards);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Tinker_TB_BaconShop_HP_015:\r\n\t\t\tif (hasCorrectTribe(spawned, Race.MECH, allCards)) {\r\n\t\t\t\tmodifyAttack(spawned, 2, board, allCards);\r\n\t\t\t\tafterStatsUpdate(spawned, board, allCards);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t}\r\n\r\n\tif (!!boardHero.questRewards?.length) {\r\n\t\tfor (const quest of boardHero.questRewards) {\r\n\t\t\tswitch (quest) {\r\n\t\t\t\tcase CardIds.VolatileVenom:\r\n\t\t\t\t\tspawned.attack += 7;\r\n\t\t\t\t\tspawned.health += 7;\r\n\t\t\t\t\tspawned.enchantments.push({\r\n\t\t\t\t\t\tcardId: CardIds.VolatileVenom_VolatileEnchantment,\r\n\t\t\t\t\t\toriginEntityId: undefined,\r\n\t\t\t\t\t\ttiming: sharedState.currentEntityId++,\r\n\t\t\t\t\t});\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CardIds.TheSmokingGun:\r\n\t\t\t\t\tspawned.attack += 4;\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tconst cardIds = [spawned.cardId, ...(spawned.additionalCards ?? [])];\r\n\tfor (const spawnedCardId of cardIds) {\r\n\t\thandleMinionAddedAuraEffect(spawnedCardId, spawned, board, boardHero, allCards, spectator, sharedState);\r\n\t}\r\n\r\n\tif (hasCorrectTribe(spawned, Race.UNDEAD, allCards)) {\r\n\t\tif (boardHero.globalInfo.UndeadAttackBonus > 0) {\r\n\t\t\tmodifyAttack(spawned, boardHero.globalInfo.UndeadAttackBonus, board, allCards);\r\n\t\t\tafterStatsUpdate(spawned, board, allCards);\r\n\t\t}\r\n\t}\r\n\tif (hasCorrectTribe(spawned, Race.BEAST, allCards)) {\r\n\t\tif (boardHero.globalInfo.GoldrinnBuff > 0) {\r\n\t\t\tmodifyAttack(spawned, boardHero.globalInfo.GoldrinnBuff, board, allCards);\r\n\t\t\tmodifyHealth(spawned, boardHero.globalInfo.GoldrinnBuff, board, allCards);\r\n\t\t\tafterStatsUpdate(spawned, board, allCards);\r\n\t\t\tspectator.registerPowerTarget(boardHero, spawned, board);\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const entity of board) {\r\n\t\tswitch (entity.cardId) {\r\n\t\t\tcase CardIds.MurlocWarleaderLegacy_BG_EX1_507:\r\n\t\t\tcase CardIds.MurlocWarleaderLegacy_TB_BaconUps_008:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.MURLOC, allCards) && entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tspawned.attack += entity.cardId === CardIds.MurlocWarleaderLegacy_TB_BaconUps_008 ? 4 : 2;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.HummingBird_BG26_805:\r\n\t\t\tcase CardIds.HummingBird_BG26_805_G:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.BEAST, allCards) && entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tspawned.attack += entity.cardId === CardIds.HummingBird_BG26_805_G ? 4 : 2;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SouthseaCaptainLegacy_BG_NEW1_027:\r\n\t\t\tcase CardIds.SouthseaCaptainLegacy_TB_BaconUps_136:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.PIRATE, allCards) && entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tspawned.attack += entity.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1;\r\n\t\t\t\t\tspawned.health += entity.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy:\r\n\t\t\tcase CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy_G:\r\n\t\t\t\tspawned.attack += entity.cardId === CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy_G ? 6 : 3;\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Kathranatir_BG21_039:\r\n\t\t\tcase CardIds.Kathranatir_BG21_039_G:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.DEMON, allCards) && entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tspawned.attack += entity.cardId === CardIds.Kathranatir_BG21_039_G ? 2 : 1;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.CyborgDrake_BG25_043:\r\n\t\t\tcase CardIds.CyborgDrake_BG25_043_G:\r\n\t\t\t\tif (spawned.divineShield) {\r\n\t\t\t\t\tspawned.attack += entity.cardId === CardIds.CyborgDrake_BG25_043_G ? 12 : 6;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.SoreLoser_BG27_030:\r\n\t\t\tcase CardIds.SoreLoser_BG27_030_G:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.UNDEAD, allCards) && entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tspawned.attack += (entity.cardId === CardIds.SoreLoser_BG27_030_G ? 2 : 1) * boardHero.tavernTier;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport const handleMinionAddedAuraEffect = (\r\n\tspawnedCardId: string,\r\n\tspawned: BoardEntity,\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n\tsharedState: SharedState,\r\n): void => {\r\n\tswitch (spawnedCardId) {\r\n\t\tcase CardIds.SouthseaCaptainLegacy_BG_NEW1_027:\r\n\t\tcase CardIds.SouthseaCaptainLegacy_TB_BaconUps_136:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, Race.PIRATE, allCards))\r\n\t\t\t\t// Other\r\n\t\t\t\t.filter((e) => e.entityId !== spawned.entityId)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += spawned.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1;\r\n\t\t\t\t\te.health += spawned.cardId === CardIds.SouthseaCaptainLegacy_TB_BaconUps_136 ? 2 : 1;\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.MurlocWarleaderLegacy_BG_EX1_507:\r\n\t\tcase CardIds.MurlocWarleaderLegacy_TB_BaconUps_008:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, Race.MURLOC, allCards))\r\n\t\t\t\t.filter((e) => e.entityId !== spawned.entityId)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += spawned.cardId === CardIds.MurlocWarleaderLegacy_TB_BaconUps_008 ? 4 : 2;\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.HummingBird_BG26_805:\r\n\t\tcase CardIds.HummingBird_BG26_805_G:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, Race.BEAST, allCards))\r\n\t\t\t\t.filter((e) => e.entityId !== spawned.entityId)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += spawned.cardId === CardIds.HummingBird_BG26_805_G ? 4 : 2;\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy:\r\n\t\tcase CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy_G:\r\n\t\t\tboard.forEach((e) => {\r\n\t\t\t\te.attack += spawned.cardId === CardIds.LadySinestra_TB_BaconShop_HERO_52_Buddy_G ? 6 : 3;\r\n\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.Kathranatir_BG21_039:\r\n\t\tcase CardIds.Kathranatir_BG21_039_G:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, Race.DEMON, allCards))\r\n\t\t\t\t.filter((e) => e.entityId !== spawned.entityId)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += spawned.cardId === CardIds.Kathranatir_BG21_039_G ? 4 : 2;\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t\tcase CardIds.CyborgDrake_BG25_043:\r\n\t\tcase CardIds.CyborgDrake_BG25_043_G:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => e.divineShield)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += spawned.cardId === CardIds.CyborgDrake_BG25_043_G ? 12 : 6;\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\r\n\t\tcase CardIds.EternalKnight_BG25_008:\r\n\t\tcase CardIds.EternalKnight_BG25_008_G:\r\n\t\t\tconst multiplierKnight = spawned.cardId === CardIds.EternalKnight_BG25_008_G ? 2 : 1;\r\n\t\t\tconst statsBonusKnight = multiplierKnight * boardHero.globalInfo.EternalKnightsDeadThisGame;\r\n\t\t\tmodifyAttack(spawned, statsBonusKnight, board, allCards);\r\n\t\t\tmodifyHealth(spawned, statsBonusKnight, board, allCards);\r\n\t\t\tafterStatsUpdate(spawned, board, allCards);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.FlourishingFrostling_BG26_537:\r\n\t\tcase CardIds.FlourishingFrostling_BG26_537_G:\r\n\t\t\tconst multiplierFrostling = spawned.cardId === CardIds.FlourishingFrostling_BG26_537_G ? 2 : 1;\r\n\t\t\tconst statsBonusFrostling = multiplierFrostling * boardHero.globalInfo.FrostlingBonus;\r\n\t\t\tmodifyAttack(spawned, statsBonusFrostling, board, allCards);\r\n\t\t\tafterStatsUpdate(spawned, board, allCards);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.RotHideGnoll_BG25_013:\r\n\t\tcase CardIds.RotHideGnoll_BG25_013_G:\r\n\t\t\tconst multiplierGnoll = spawned.cardId === CardIds.RotHideGnoll_BG25_013_G ? 2 : 1;\r\n\t\t\tconst statsBonusGnoll =\r\n\t\t\t\tmultiplierGnoll * sharedState.deaths.filter((e) => e.friendly === spawned.friendly).length;\r\n\t\t\tmodifyAttack(spawned, statsBonusGnoll, board, allCards);\r\n\t\t\tafterStatsUpdate(spawned, board, allCards);\r\n\t\t\tbreak;\r\n\t\tcase CardIds.SoreLoser_BG27_030:\r\n\t\tcase CardIds.SoreLoser_BG27_030_G:\r\n\t\t\tboard\r\n\t\t\t\t.filter((e) => hasCorrectTribe(e, Race.UNDEAD, allCards))\r\n\t\t\t\t.filter((e) => e.entityId !== spawned.entityId)\r\n\t\t\t\t.forEach((e) => {\r\n\t\t\t\t\te.attack += (spawned.cardId === CardIds.SoreLoser_BG27_030_G ? 2 : 1) * boardHero.tavernTier;\r\n\t\t\t\t});\r\n\t\t\tbreak;\r\n\t}\r\n};\r\n\r\nconst handleAfterSpawnEffects = (\r\n\tboard: BoardEntity[],\r\n\tallSpawned: readonly BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tfor (const spawned of allSpawned) {\r\n\t\thandleAfterSpawnEffect(board, spawned, allCards, spectator);\r\n\t}\r\n};\r\n\r\nconst handleAfterSpawnEffect = (\r\n\tboard: BoardEntity[],\r\n\tspawned: BoardEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// console.debug('after spawn', stringifySimpleCard(spawned, allCards), stringifySimple(board, allCards));\r\n\tfor (const entity of board) {\r\n\t\tswitch (entity.cardId) {\r\n\t\t\t// case CardIds.MurlocTidecallerLegacy:\r\n\t\t\t// case CardIds.MurlocTidecallerCore:\r\n\t\t\t// \tconst multiplier = entity.cardId === CardIds.MurlocTidecallerBattlegrounds ? 2 : 1;\r\n\t\t\t// \tconst buffAmount =\r\n\t\t\t// \t\tmultiplier * (isCorrectTribe(allCards.getCard(spawned.cardId).races, Race.MURLOC) ? 1 : 0);\r\n\t\t\t// \tif (buffAmount > 0) {\r\n\t\t\t// \t\tmodifyAttack(entity, buffAmount, board, allCards);\r\n\t\t\t// \t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\t// \t\tspectator.registerPowerTarget(entity, entity, board);\r\n\t\t\t// \t}\r\n\t\t\t// \tbreak;\r\n\t\t\tcase CardIds.Swampstriker_BG22_401:\r\n\t\t\tcase CardIds.Swampstriker_BG22_401_G:\r\n\t\t\t\tif (entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tconst multiplier2 = entity.cardId === CardIds.Swampstriker_BG22_401_G ? 2 : 1;\r\n\t\t\t\t\tconst buffAmount2 =\r\n\t\t\t\t\t\tmultiplier2 * (isCorrectTribe(allCards.getCard(spawned.cardId).races, Race.MURLOC) ? 1 : 0);\r\n\t\t\t\t\tif (buffAmount2 > 0) {\r\n\t\t\t\t\t\tmodifyAttack(entity, buffAmount2, board, allCards);\r\n\t\t\t\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\t\t\t\tspectator.registerPowerTarget(entity, entity, board);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.Felstomper_BG25_042:\r\n\t\t\tcase CardIds.Felstomper_BG25_042_G:\r\n\t\t\t\t// console.debug('felstomper');\r\n\t\t\t\tif (entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tconst felstomperBuff = entity.cardId === CardIds.Felstomper_BG25_042_G ? 6 : 3;\r\n\t\t\t\t\tboard.forEach((e) => {\r\n\t\t\t\t\t\tmodifyAttack(e, felstomperBuff, board, allCards);\r\n\t\t\t\t\t\tafterStatsUpdate(e, board, allCards);\r\n\t\t\t\t\t\tspectator.registerPowerTarget(entity, e, board);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.XyloBones_BG26_172:\r\n\t\t\tcase CardIds.XyloBones_BG26_172_G:\r\n\t\t\t\tif (entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tconst xylobonesBuff = entity.cardId === CardIds.XyloBones_BG26_172_G ? 6 : 3;\r\n\t\t\t\t\tmodifyHealth(entity, xylobonesBuff, board, allCards);\r\n\t\t\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\t\t\tspectator.registerPowerTarget(entity, entity, board);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.OctosariWrapGod_BG26_804:\r\n\t\t\tcase CardIds.OctosariWrapGod_BG26_804_G:\r\n\t\t\t\tconst octoStats = entity.cardId === CardIds.OctosariWrapGod_BG26_804_G ? 4 : 2;\r\n\t\t\t\tentity.scriptDataNum1 += octoStats;\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.BananaSlamma_BG26_802:\r\n\t\t\tcase CardIds.BananaSlamma_BG26_802_G:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.BEAST, allCards) && entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tconst bananaStatBuff = entity.cardId === CardIds.BananaSlamma_BG26_802_G ? 3 : 2;\r\n\t\t\t\t\tspawned.attack = spawned.attack * bananaStatBuff;\r\n\t\t\t\t\tspawned.health = spawned.health * bananaStatBuff;\r\n\t\t\t\t\tspectator.registerPowerTarget(entity, spawned, board);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.HungrySnapjaw_BG26_370:\r\n\t\t\tcase CardIds.HungrySnapjaw_BG26_370_G:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.BEAST, allCards) && entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tconst snapjawBuff = entity.cardId === CardIds.HungrySnapjaw_BG26_370_G ? 2 : 1;\r\n\t\t\t\t\tmodifyHealth(entity, snapjawBuff, board, allCards);\r\n\t\t\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase CardIds.ObserverOfMyths_BG_TTN_078:\r\n\t\t\tcase CardIds.ObserverOfMyths_BG_TTN_078_G:\r\n\t\t\t\tif (spawned.attack > entity.attack) {\r\n\t\t\t\t\tconst observerBuff = entity.cardId === CardIds.ObserverOfMyths_BG_TTN_078_G ? 2 : 1;\r\n\t\t\t\t\taddStatsToBoard(entity, board, observerBuff, 0, allCards, spectator);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t// Putricide-only\r\n\t\t\tcase CardIds.ArmsDealer_BG26_RLK_824:\r\n\t\t\t\tif (hasCorrectTribe(spawned, Race.UNDEAD, allCards) && entity.entityId !== spawned.entityId) {\r\n\t\t\t\t\tmodifyAttack(spawned, 1, board, allCards);\r\n\t\t\t\t\tafterStatsUpdate(entity, board, allCards);\r\n\t\t\t\t\tspectator.registerPowerTarget(entity, entity, board);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n"]}
|
|
@@ -634,7 +634,7 @@ const applyOnAttackBuffs = (attacker, attackingBoard, allCards, spectator) => {
|
|
|
634
634
|
e.cardId === "BG27_555_G");
|
|
635
635
|
elizas.forEach((eliza) => {
|
|
636
636
|
attackingBoard.forEach((entity) => {
|
|
637
|
-
(0, utils_2.modifyAttack)(entity,
|
|
637
|
+
(0, utils_2.modifyAttack)(entity, 3, attackingBoard, allCards);
|
|
638
638
|
(0, utils_2.modifyHealth)(entity, 1, attackingBoard, allCards);
|
|
639
639
|
spectator.registerPowerTarget(eliza, entity, att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AAC,MAAM,GAAG,+BAA+B,CAAC;QACtF,IAAA,sCAAgB,EACf,qBAAqB,EACrB,yBAAyB,EACzB,iBAAiB,EACjB,cAAc,EACd,SAAS,EACT,QAAQ,EACR,SAAS,EACT,WAAW,CACX,CAAC;QACF,IAAI,SAAS,CAAC,iBAAiB,EAAE;YAEhC,IAAA,sBAAc,EACb,qBAAqB,EACrB,yBAAyB,EACzB,aAAa,EACb,iBAAiB,EACjB,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,WAAW,EACX,SAAS,CACT,CAAC;SACF;QACD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE;YACtD,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAChC;KACD;IAED,SAAS,CAAC,oBAAoB,CAAC,iBAAiB,EAAE,qBAAqB,EAAE,eAAe,CAAC,CAAC;IAC1F,OAAO,eAAe,CAAC;AACxB,CAAC,CAAC;AA9DW,QAAA,mBAAmB,uBA8D9B","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardsData } from '../cards/cards-data';\r\nimport { groupByFunction, pickRandom } from '../services/utils';\r\nimport { validEnchantments } from '../simulate-bgs-battle';\r\nimport {\r\n\taddCardsInHand,\r\n\taddImpliedMechanics,\r\n\taddStatsToBoard,\r\n\tafterStatsUpdate,\r\n\tgrantRandomStats,\r\n\tgrantStatsToMinionsOfEachType,\r\n\thasCorrectTribe,\r\n\thasMechanic,\r\n\tisCorrectTribe,\r\n\tisFish,\r\n\tmodifyAttack,\r\n\tmodifyHealth,\r\n\tstringifySimple,\r\n\tstringifySimpleCard,\r\n\tupdateDivineShield,\r\n} from '../utils';\r\nimport { addMinionToBoard, addMinionsToBoard } from './add-minion-to-board';\r\nimport { applyAvengeEffects } from './avenge';\r\nimport { applyAfterDeathEffects, applyOnDeathEffects } from './death-effects';\r\nimport {\r\n\tapplyMinionDeathEffect,\r\n\tapplyMonstrosity,\r\n\thandleDeathrattles,\r\n\trememberDeathrattles,\r\n} from './deathrattle-effects';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { applyFrenzy } from './frenzy';\r\nimport { onMinionKill } from './minion-kill';\r\nimport { removeMinionFromBoard } from './remove-minion-from-board';\r\nimport { SharedState } from './shared-state';\r\nimport { Spectator } from './spectator/spectator';\r\nimport { canAttack } from './utils/entity-utils';\r\n\r\n// Only use it to simulate actual attack. To simulate damage, or something similar, use bumpInto\r\nexport const simulateAttack = (\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tlastAttackerEntityId: number,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n\tforceAttackingEntityIndex?: number,\r\n): number => {\r\n\tif (attackingBoard.length === 0 || defendingBoard.length === 0) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst attackingEntity =\r\n\t\tforceAttackingEntityIndex != null\r\n\t\t\t? attackingBoard[forceAttackingEntityIndex]\r\n\t\t\t: getAttackingEntity(attackingBoard, lastAttackerEntityId);\r\n\tconst attackingEntityIndex = attackingBoard.map((e) => e.entityId).indexOf(attackingEntity?.entityId);\r\n\tif (attackingEntity) {\r\n\t\tattackingEntity.attacking = true;\r\n\t\tconst numberOfAttacks = attackingEntity.windfury ? 2 : 1;\r\n\t\tfor (let i = 0; i < numberOfAttacks; i++) {\r\n\t\t\t// We refresh the entity in case of windfury\r\n\t\t\tif (attackingBoard.length === 0 || defendingBoard.length === 0) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\t// console.log(\r\n\t\t\t// \t'\\nattack by',\r\n\t\t\t// \tstringifySimpleCard(attackingEntity, allCards),\r\n\t\t\t// \tstringifySimple(defendingBoard, allCards),\r\n\t\t\t// \tstringifySimple(attackingBoard, allCards),\r\n\t\t\t// );\r\n\t\t\t// Check that didn't die\r\n\t\t\tif (attackingBoard.find((entity) => entity.entityId === attackingEntity.entityId)) {\r\n\t\t\t\tconst defendingEntity: BoardEntity = getDefendingEntity(defendingBoard, attackingEntity);\r\n\t\t\t\t// Can happen with a single defender that has stealth\r\n\t\t\t\tif (defendingEntity) {\r\n\t\t\t\t\tdoFullAttack(\r\n\t\t\t\t\t\tattackingEntity,\r\n\t\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tspawns,\r\n\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t);\r\n\t\t\t\t} else {\r\n\t\t\t\t\t// Solves the edge case of Sky Pirate vs a stealth board\r\n\t\t\t\t\tattackingEntity.attackImmediately = false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tattackingEntity.attacking = false;\r\n\t}\r\n\t// If entities that were before the attacker died, we need to update the attacker index\r\n\treturn attackingEntityIndex;\r\n};\r\n\r\nexport const doFullAttack = (\r\n\tattackingEntity: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingEntity: BoardEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n) => {\r\n\tapplyOnAttackBuffs(attackingEntity, attackingBoard, allCards, spectator);\r\n\tspectator.registerAttack(attackingEntity, defendingEntity, attackingBoard, defendingBoard);\r\n\tapplyOnBeingAttackedBuffs(attackingEntity, defendingEntity, defendingBoard, allCards, spectator);\r\n\tperformAttack(\r\n\t\tattackingEntity,\r\n\t\tdefendingEntity,\r\n\t\tattackingBoard,\r\n\t\tattackingBoardHero,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\tapplyAfterAttackEffects(attackingEntity, attackingBoard, attackingBoardHero, allCards, spectator);\r\n\tprocessMinionDeath(\r\n\t\tattackingBoard,\r\n\t\tattackingBoardHero,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\tif (\r\n\t\tdefendingEntity.health > 0 &&\r\n\t\t!defendingEntity.definitelyDead &&\r\n\t\t(defendingEntity.cardId === CardIds.YoHoOgre_BGS_060 ||\r\n\t\t\tdefendingEntity.cardId === CardIds.YoHoOgre_TB_BaconUps_150)\r\n\t) {\r\n\t\tdefendingEntity.attackImmediately = true;\r\n\t\tif (defendingEntity.attackImmediately) {\r\n\t\t\tsimulateAttack(\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tnull,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspawns,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyAfterAttackEffects = (\r\n\tattackingEntity: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (attackingEntity.cardId === CardIds.Bonker_BG20_104 || attackingEntity.cardId === CardIds.Bonker_BG20_104_G) {\r\n\t\tconst quantity = attackingEntity.cardId === CardIds.Bonker_BG20_104_G ? 2 : 1;\r\n\t\tconst cards = quantity === 1 ? [CardIds.BloodGem] : [CardIds.BloodGem, CardIds.BloodGem];\r\n\t\taddCardsInHand(attackingBoardHero, attackingBoard, allCards, spectator, cards);\r\n\t} else if (attackingEntity.cardId === CardIds.Yrel_BG23_350 || attackingEntity.cardId === CardIds.Yrel_BG23_350_G) {\r\n\t\tconst modifier = attackingEntity.cardId === CardIds.Yrel_BG23_350_G ? 2 : 1;\r\n\t\tgrantStatsToMinionsOfEachType(attackingEntity, attackingBoard, modifier * 1, modifier * 2, allCards, spectator);\r\n\t} else if (\r\n\t\tattackingEntity.cardId === CardIds.IncorporealCorporal_BG26_RLK_117 ||\r\n\t\tattackingEntity.cardId === CardIds.IncorporealCorporal_BG26_RLK_117_G\r\n\t) {\r\n\t\tattackingEntity.definitelyDead = true;\r\n\t}\r\n\t// Putricide-only\r\n\telse if (attackingEntity.additionalCards?.includes(CardIds.IncorporealCorporal_BG26_RLK_117)) {\r\n\t\tattackingEntity.definitelyDead = true;\r\n\t}\r\n\tattackingBoard\r\n\t\t.filter((e) => e.additionalCards?.includes(CardIds.FesterootHulk_BG_GIL_655))\r\n\t\t.forEach((e) => {\r\n\t\t\tmodifyAttack(e, 1, attackingBoard, allCards);\r\n\t\t\tafterStatsUpdate(e, attackingBoard, allCards);\r\n\t\t});\r\n\r\n\tattackingEntity.stealth = false;\r\n};\r\n\r\nconst performAttack = (\r\n\tattackingEntity: BoardEntity,\r\n\tdefendingEntity: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (hasCorrectTribe(attackingEntity, Race.DRAGON, allCards)) {\r\n\t\tconst prestors = attackingBoard\r\n\t\t\t.filter((e) => e.entityId !== attackingEntity.entityId)\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId === CardIds.PrestorsPyrospawn_BG21_012 ||\r\n\t\t\t\t\te.cardId === CardIds.PrestorsPyrospawn_BG21_012_G,\r\n\t\t\t);\r\n\t\tprestors.forEach((prestor) => {\r\n\t\t\tspectator.registerPowerTarget(prestor, defendingEntity, defendingBoard);\r\n\t\t\tdealDamageToEnemy(\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tprestor,\r\n\t\t\t\tprestor.cardId === CardIds.PrestorsPyrospawn_BG21_012_G ? 6 : 3,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\tif (\r\n\t\tattackingEntity.cardId === CardIds.Atramedes_BG23_362 ||\r\n\t\tattackingEntity.cardId === CardIds.Atramedes_BG23_362_G\r\n\t) {\r\n\t\tconst targets = [defendingEntity, ...getNeighbours(defendingBoard, defendingEntity)];\r\n\t\tconst multiplier = attackingEntity.cardId === CardIds.Atramedes_BG23_362_G ? 2 : 1;\r\n\r\n\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\ttargets.forEach((target) => {\r\n\t\t\t\tspectator.registerPowerTarget(attackingEntity, target, defendingBoard);\r\n\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tattackingEntity,\r\n\t\t\t\t\t3,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tcardsData,\r\n\t\t\t\t\tsharedState,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t\t}\r\n\t} else if (\r\n\t\tattackingEntity.cardId === CardIds.Niuzao_BG27_822 ||\r\n\t\tattackingEntity.cardId === CardIds.Niuzao_BG27_822\r\n\t) {\r\n\t\tconst multiplier = attackingEntity.cardId === CardIds.Niuzao_BG27_822 ? 2 : 1;\r\n\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\tconst target = pickRandom(defendingBoard.filter((e) => e.entityId != defendingEntity.entityId));\r\n\t\t\tif (target) {\r\n\t\t\t\tspectator.registerPowerTarget(attackingEntity, target, defendingBoard);\r\n\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tattackingEntity,\r\n\t\t\t\t\tattackingEntity.attack,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tcardsData,\r\n\t\t\t\t\tsharedState,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (\r\n\t\tattackingEntity.cardId === CardIds.ObsidianRavager_BG27_017 ||\r\n\t\tattackingEntity.cardId === CardIds.ObsidianRavager_BG27_017_G\r\n\t) {\r\n\t\tconst neighbours = getNeighbours(defendingBoard, defendingEntity);\r\n\t\tconst targets =\r\n\t\t\tattackingEntity.cardId === CardIds.ObsidianRavager_BG27_017_G ? neighbours : [pickRandom(neighbours)];\r\n\t\ttargets.forEach((target) => {\r\n\t\t\tspectator.registerPowerTarget(attackingEntity, target, defendingBoard);\r\n\t\t\tdealDamageToEnemy(\r\n\t\t\t\ttarget,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tattackingEntity.attack,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t});\r\n\t} else if ([CardIds.BabyKrush_BG22_001, CardIds.BabyKrush_BG22_001_G].includes(attackingEntity.cardId as CardIds)) {\r\n\t\tconst spawns = spawnEntities(\r\n\t\t\tattackingEntity.cardId === CardIds.BabyKrush_BG22_001_G\r\n\t\t\t\t? CardIds.BabyKrush_BG22_001_G\r\n\t\t\t\t: CardIds.BabyKrush_DevilsaurToken,\r\n\t\t\t1,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\ttrue,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t\tif (spawns.length > 0) {\r\n\t\t\tconst sourceIndex = attackingBoard.indexOf(attackingEntity);\r\n\t\t\tconst actualSpawns = performEntitySpawns(\r\n\t\t\t\tspawns,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tsourceIndex,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\tfor (const actualSpawn of actualSpawns) {\r\n\t\t\t\tif (defendingEntity.health > 0 && !defendingEntity.definitelyDead) {\r\n\t\t\t\t\tperformAttack(\r\n\t\t\t\t\t\tactualSpawn,\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// For Prestor\r\n\tconst defenderAliveBeforeAttack = defendingEntity.health > 0 && !defendingEntity.definitelyDead;\r\n\t// Because of Bristleback Knight, which changes its divine shield status during bumpEntities\r\n\tconst attackerHadDivineShield = attackingEntity.divineShield;\r\n\tconst defenderHadDivineShield = defendingEntity.divineShield;\r\n\tif (defenderAliveBeforeAttack) {\r\n\t\tif (!attackingEntity.immuneWhenAttackCharges) {\r\n\t\t\t// TODO: this bumpEntities approach doesn't work well, as it leads to code duplication\r\n\t\t\tbumpEntities(\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t\tbumpEntities(\r\n\t\t\tdefendingEntity,\r\n\t\t\tattackingEntity,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// Do it after the damage has been done, so that entities that update on DS lose / gain (CyborgDrake) don't\r\n\t\t// cause wrong results to happen\r\n\t\t// This whole logic is a MEEEEESSSSSSSSSSSSSSS\r\n\t\tif (defendingEntity.attack > 0 && attackerHadDivineShield && !attackingEntity.immuneWhenAttackCharges) {\r\n\t\t\tupdateDivineShield(attackingEntity, attackingBoard, false, allCards);\r\n\t\t}\r\n\t\tif (attackingEntity.attack > 0 && defenderHadDivineShield) {\r\n\t\t\tupdateDivineShield(defendingEntity, defendingBoard, false, allCards);\r\n\t\t}\r\n\r\n\t\tif (defendingEntity.health <= 0 || defendingEntity.definitelyDead) {\r\n\t\t\tonMinionKill(\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t\tif (attackingEntity.health <= 0 || attackingEntity.definitelyDead) {\r\n\t\t\tonMinionKill(\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\t// Cleave\r\n\tif (attackingEntity.cleave) {\r\n\t\tconst defenderNeighbours: readonly BoardEntity[] = getNeighbours(defendingBoard, defendingEntity);\r\n\t\tfor (const neighbour of defenderNeighbours) {\r\n\t\t\tbumpEntities(\r\n\t\t\t\tneighbour,\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\t// Do it after the damage has been done, so that entities that update on DS lose / gain (CyborgDrake) don't\r\n\t\t\t// cause wrong results to happen\r\n\t\t\tif (attackingEntity.attack > 0 && neighbour.divineShield) {\r\n\t\t\t\tupdateDivineShield(neighbour, defendingBoard, false, allCards);\r\n\t\t\t}\r\n\t\t\tif (neighbour.health <= 0 || neighbour.definitelyDead) {\r\n\t\t\t\tonMinionKill(\r\n\t\t\t\t\tattackingEntity,\r\n\t\t\t\t\tneighbour,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (\r\n\t\t(defendingEntity.health <= 0 || defendingEntity.definitelyDead) &&\r\n\t\t(attackingEntity.cardId === CardIds.WildfireElemental_BGS_126 ||\r\n\t\t\tattackingEntity.cardId === CardIds.WildfireElemental_TB_BaconUps_166)\r\n\t) {\r\n\t\tconst excessDamage = -defendingEntity.health;\r\n\t\tconst neighbours = getNeighbours(defendingBoard, defendingEntity);\r\n\t\t// console.log('neighbours', stringifySimple(neighbours, allCards));\r\n\t\tif (neighbours.length > 0) {\r\n\t\t\tif (attackingEntity.cardId === CardIds.WildfireElemental_BGS_126) {\r\n\t\t\t\tconst randomTarget = neighbours[Math.floor(Math.random() * neighbours.length)];\r\n\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\trandomTarget,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tdefendingEntity.lastAffectedByEntity,\r\n\t\t\t\t\texcessDamage,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tcardsData,\r\n\t\t\t\t\tsharedState,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t);\r\n\t\t\t} else {\r\n\t\t\t\tneighbours.forEach((neighbour) =>\r\n\t\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\t\tneighbour,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\t\tdefendingEntity.lastAffectedByEntity,\r\n\t\t\t\t\t\texcessDamage,\r\n\t\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t),\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// After attack hooks\r\n\t// Arcane Cannon\r\n\t// Monstrous Macaw\r\n\tif (attackingEntity.cardId === CardIds.MonstrousMacaw_BGS_078) {\r\n\t\ttriggerRandomDeathrattle(\r\n\t\t\tattackingEntity,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t} else if (attackingEntity.cardId === CardIds.MonstrousMacaw_TB_BaconUps_135) {\r\n\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\ttriggerRandomDeathrattle(\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\tattackingEntity.attackImmediately = false;\r\n\tif (attackingEntity.enchantments.some((e) => e.cardId === CardIds.VolatileVenom_VolatileEnchantment)) {\r\n\t\tattackingEntity.definitelyDead = true;\r\n\t}\r\n\tprocessMinionDeath(\r\n\t\tattackingBoard,\r\n\t\tattackingBoardHero,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\tattackingEntity.immuneWhenAttackCharges = Math.max(0, attackingEntity.immuneWhenAttackCharges - 1);\r\n};\r\n\r\nconst triggerRandomDeathrattle = (\r\n\tsourceEntity: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n\texcludeSource = false,\r\n): void => {\r\n\tconst validDeathrattles = attackingBoard\r\n\t\t.filter((entity) => !excludeSource || entity.entityId !== sourceEntity.entityId)\r\n\t\t.filter((entity) => {\r\n\t\t\tif (hasMechanic(allCards.getCard(entity.cardId), 'DEATHRATTLE')) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\tif (entity.rememberedDeathrattles?.length) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\tif (\r\n\t\t\t\tentity.enchantments &&\r\n\t\t\t\tentity.enchantments\r\n\t\t\t\t\t.map((enchantment) => enchantment.cardId)\r\n\t\t\t\t\t.some((enchantmentId) => validEnchantments.includes(enchantmentId as CardIds))\r\n\t\t\t) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\treturn false;\r\n\t\t});\r\n\tif (validDeathrattles.length === 0) {\r\n\t\treturn;\r\n\t}\r\n\tconst targetEntity = pickRandom(validDeathrattles);\r\n\tif (!targetEntity?.cardId) {\r\n\t\tconsole.error(\r\n\t\t\t'missing card id when triggering random deathrattle',\r\n\t\t\tstringifySimpleCard(targetEntity, allCards),\r\n\t\t\ttargetEntity,\r\n\t\t\tvalidDeathrattles.length,\r\n\t\t\tstringifySimple(validDeathrattles, allCards),\r\n\t\t\tstringifySimple(attackingBoard, allCards),\r\n\t\t\texcludeSource,\r\n\t\t\tstringifySimpleCard(sourceEntity, allCards),\r\n\t\t);\r\n\t}\r\n\tspectator.registerPowerTarget(sourceEntity, targetEntity, attackingBoard);\r\n\tconst indexFromRight = attackingBoard.length - (attackingBoard.indexOf(targetEntity) + 1);\r\n\tbuildBoardAfterDeathrattleSpawns(\r\n\t\tattackingBoard,\r\n\t\tattackingBoardHero,\r\n\t\ttargetEntity,\r\n\t\tindexFromRight,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\t[],\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\t// The reborn minion spawns to the right of the DR spawns\r\n\t// buildBoardAfterRebornSpawns(\r\n\t// \tattackingBoard,\r\n\t// \tattackingBoardHero,\r\n\t// \ttargetEntity,\r\n\t// \tindexFromRight,\r\n\t// \tdefendingBoard,\r\n\t// \tdefendingBoardHero,\r\n\t// \tallCards,\r\n\t// \tspawns,\r\n\t// \tsharedState,\r\n\t// \tspectator,\r\n\t// );\r\n};\r\n\r\nconst getAttackingEntity = (attackingBoard: BoardEntity[], lastAttackerIndex: number): BoardEntity => {\r\n\tlet validAttackers = attackingBoard.filter((entity) => canAttack(entity));\r\n\tif (validAttackers.length === 0) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tif (validAttackers.some((entity) => entity.attackImmediately)) {\r\n\t\tvalidAttackers = validAttackers.filter((entity) => entity.attackImmediately);\r\n\t}\r\n\r\n\t// Once an entity has attacked, no entity to the left of it can attack until all entities\r\n\t// on the board have attacked\r\n\t// Once the last attacker index is the last entity on the board, we cycle back to the start\r\n\tif (lastAttackerIndex != null && lastAttackerIndex < validAttackers.length - 1) {\r\n\t\t// This doesn't work if any entity that appears before the attacked index died in-between\r\n\t\tconst candidates = validAttackers.slice(lastAttackerIndex);\r\n\t\tif (candidates.length > 0) {\r\n\t\t\tvalidAttackers = candidates;\r\n\t\t}\r\n\t}\r\n\r\n\tlet attackingEntity = validAttackers[0];\r\n\tlet minNumberOfAttacks: number = attackingEntity.attacksPerformed || 0;\r\n\tfor (const entity of validAttackers) {\r\n\t\tif ((entity.attacksPerformed || 0) < minNumberOfAttacks) {\r\n\t\t\tattackingEntity = entity;\r\n\t\t\tminNumberOfAttacks = entity.attacksPerformed;\r\n\t\t}\r\n\t}\r\n\r\n\tif (!attackingEntity.attackImmediately) {\r\n\t\tattackingEntity.attacksPerformed = (attackingEntity.attacksPerformed || 0) + 1;\r\n\t}\r\n\treturn attackingEntity;\r\n};\r\n\r\nexport const findNearestEnemies = (\r\n\tattackingBoard: BoardEntity[],\r\n\tentity: BoardEntity,\r\n\tentityIndexFromRight: number,\r\n\tdefendingBoard: BoardEntity[],\r\n\tnumberOfTargets: number,\r\n\tallCards: AllCardsService,\r\n): BoardEntity[] => {\r\n\tconst result = [];\r\n\tif (defendingBoard.length > 0) {\r\n\t\t// console.debug('defending board', numberOfTargets, stringifySimple(defendingBoard, allCards));\r\n\t\tconst attackerIndex = attackingBoard.length - entityIndexFromRight - 1;\r\n\t\tconst targetIndex = attackerIndex - (attackingBoard.length - defendingBoard.length) / 2;\r\n\t\t// console.debug('indexes', attackerIndex, entityIndexFromRight, targetIndex, attackingBoard.length);\r\n\r\n\t\tfor (let i = 0; i < numberOfTargets; i++) {\r\n\t\t\tconst possibleTargets = defendingBoard\r\n\t\t\t\t.filter((e) => !e.definitelyDead && e.health > 0)\r\n\t\t\t\t.filter((e) => !result.includes(e));\r\n\t\t\t// console.debug('possibleTargets', stringifySimple(possibleTargets, allCards));\r\n\t\t\tif (!possibleTargets.length) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tconst targetGroups = groupByFunction((e: BoardEntity) => Math.abs(defendingBoard.indexOf(e) - targetIndex))(\r\n\t\t\t\tpossibleTargets,\r\n\t\t\t);\r\n\t\t\tconst distances = Object.keys(targetGroups)\r\n\t\t\t\t.map((k) => +k)\r\n\t\t\t\t.sort();\r\n\t\t\tconst nearestDistance = distances[0];\r\n\t\t\tif (nearestDistance != null) {\r\n\t\t\t\t// console.debug(\r\n\t\t\t\t// \t'targetGroups[nearestDistance]',\r\n\t\t\t\t// \tnearestDistance,\r\n\t\t\t\t// \tstringifySimple(targetGroups[nearestDistance], allCards),\r\n\t\t\t\t// );\r\n\t\t\t\tconst target = pickRandom(targetGroups[nearestDistance]);\r\n\t\t\t\tresult.push(target);\r\n\t\t\t}\r\n\t\t\t// console.debug('\\n');\r\n\t\t}\r\n\t}\r\n\treturn result.filter((e) => !!e);\r\n};\r\n\r\nexport const getNeighbours = (\r\n\tboard: BoardEntity[],\r\n\tentity: BoardEntity,\r\n\tdeadEntityIndexFromRight?: number,\r\n): readonly BoardEntity[] => {\r\n\tconst neighbours = [];\r\n\tif (deadEntityIndexFromRight != null) {\r\n\t\t// If the deadEntityIndexFromRight === 0 (right-most minion), no neighbour will be found\r\n\t\tconst rightNeighbourIndex = board.length - 1 - (deadEntityIndexFromRight - 1);\r\n\t\tconst rightNeighbour = board[rightNeighbourIndex];\r\n\t\tif (rightNeighbour) {\r\n\t\t\tneighbours.push(rightNeighbour);\r\n\t\t}\r\n\r\n\t\tconst leftNeighbourIndex = board.length - 1 - deadEntityIndexFromRight;\r\n\t\tconst leftNeighbour = board[leftNeighbourIndex];\r\n\t\tif (leftNeighbour) {\r\n\t\t\tneighbours.push(leftNeighbour);\r\n\t\t}\r\n\t} else {\r\n\t\tconst index = board.map((e) => e.entityId).indexOf(entity.entityId);\r\n\t\tif (index - 1 >= 0) {\r\n\t\t\tneighbours.push(board[index - 1]);\r\n\t\t}\r\n\t\t// neighbours.push(entity);\r\n\t\tif (index + 1 < board.length) {\r\n\t\t\tneighbours.push(board[index + 1]);\r\n\t\t}\r\n\t}\r\n\treturn neighbours;\r\n};\r\n\r\nexport const dealDamageToRandomEnemy = (\r\n\tboardToBeDamaged: BoardEntity[],\r\n\tboardToBeDamagedHero: BgsPlayerEntity,\r\n\tdamageSource: BoardEntity,\r\n\tdamage: number,\r\n\tboardWithAttackOrigin: BoardEntity[],\r\n\tboardWithAttackOriginHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (boardToBeDamaged.length === 0) {\r\n\t\treturn;\r\n\t}\r\n\tconst validTargets = boardToBeDamaged.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tconst defendingEntity: BoardEntity = pickRandom(validTargets);\r\n\tif (defendingEntity) {\r\n\t\tspectator.registerPowerTarget(damageSource, defendingEntity, boardToBeDamaged);\r\n\t\tdealDamageToEnemy(\r\n\t\t\tdefendingEntity,\r\n\t\t\tboardToBeDamaged,\r\n\t\t\tboardToBeDamagedHero,\r\n\t\t\tdamageSource,\r\n\t\t\tdamage,\r\n\t\t\tboardWithAttackOrigin,\r\n\t\t\tboardWithAttackOriginHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n};\r\n\r\nexport const dealDamageToEnemy = (\r\n\tdefendingEntity: BoardEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tdamageSource: BoardEntity,\r\n\tdamage: number,\r\n\tboardWithAttackOrigin: BoardEntity[],\r\n\tboardWithAttackOriginHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// console.log('dealing damage to', damage, stringifySimpleCard(defendingEntity, allCards));\r\n\tif (!defendingEntity) {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tconst isDeadBeforeDamage = defendingEntity.definitelyDead || defendingEntity.health <= 0;\r\n\t// Why do we use a fakeAttacker? Is that for the \"attacking\" prop?\r\n\t// That prop is only used for Overkill, and even in that case it looks like it would work\r\n\t// without it\r\n\tconst fakeAttacker = {\r\n\t\t...(damageSource || {}),\r\n\t\tentityId: -1,\r\n\t\tattack: damage,\r\n\t\tattacking: true,\r\n\t} as BoardEntity;\r\n\tconst actualDamageDone = bumpEntities(\r\n\t\tdefendingEntity,\r\n\t\tfakeAttacker,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\tboardWithAttackOrigin,\r\n\t\tboardWithAttackOriginHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\t// Do it after the damage has been done, so that entities that update on DS lose / gain (CyborgDrake) don't\r\n\t// cause wrong results to happen\r\n\tif (fakeAttacker.attack > 0 && defendingEntity.divineShield) {\r\n\t\tupdateDivineShield(defendingEntity, defendingBoard, false, allCards);\r\n\t}\r\n\tif (!isDeadBeforeDamage && actualDamageDone > 0) {\r\n\t\tdefendingEntity.lastAffectedByEntity = damageSource;\r\n\r\n\t\tif (defendingEntity.health <= 0 || defendingEntity.definitelyDead) {\r\n\t\t\tonMinionKill(\r\n\t\t\t\tdamageSource,\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tboardWithAttackOrigin,\r\n\t\t\t\tboardWithAttackOriginHero,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\tconst defendingEntityIndex = defendingBoard.map((entity) => entity.entityId).indexOf(defendingEntity.entityId);\r\n\tdefendingBoard[defendingEntityIndex] = defendingEntity;\r\n\treturn actualDamageDone;\r\n};\r\n\r\nexport const getDefendingEntity = (\r\n\tdefendingBoard: BoardEntity[],\r\n\tattackingEntity: BoardEntity,\r\n\tignoreTaunts = false,\r\n): BoardEntity => {\r\n\tlet possibleDefenders: readonly BoardEntity[];\r\n\tif (\r\n\t\tattackingEntity.cardId === CardIds.ZappSlywick_BGS_022 ||\r\n\t\tattackingEntity.cardId === CardIds.ZappSlywick_TB_BaconUps_091\r\n\t) {\r\n\t\tconst minAttack = Math.min(...defendingBoard.map((entity) => entity.attack));\r\n\t\tpossibleDefenders = defendingBoard.filter((entity) => entity.attack === minAttack);\r\n\t} else {\r\n\t\tpossibleDefenders = defendingBoard.filter((e) => !e.stealth);\r\n\t\tif (!ignoreTaunts) {\r\n\t\t\tconst taunts = possibleDefenders.filter((entity) => entity.taunt);\r\n\t\t\tpossibleDefenders = taunts.length > 0 ? taunts : possibleDefenders;\r\n\t\t}\r\n\t}\r\n\tlet chosenDefender = possibleDefenders[Math.floor(Math.random() * possibleDefenders.length)];\r\n\tif (chosenDefender?.taunt) {\r\n\t\tconst elistras = defendingBoard.filter(\r\n\t\t\t(entity) =>\r\n\t\t\t\tentity.cardId === CardIds.ElistraTheImmortal_BGS_205 ||\r\n\t\t\t\tentity.cardId === CardIds.ElistraTheImmortal_TB_BaconUps_306,\r\n\t\t);\r\n\t\tif (elistras.length > 0) {\r\n\t\t\tchosenDefender = elistras[Math.floor(Math.random() * elistras.length)];\r\n\t\t}\r\n\t}\r\n\treturn chosenDefender;\r\n};\r\n\r\nexport const bumpEntities = (\r\n\tentity: BoardEntity,\r\n\tbumpInto: BoardEntity,\r\n\tentityBoard: BoardEntity[],\r\n\tentityBoardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// No attack has no impact\r\n\tif (bumpInto.attack === 0) {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tif (entity.divineShield) {\r\n\t\t// Handle all the divine shield loss effects here\r\n\t\tfor (let i = 0; i < entityBoard.length; i++) {\r\n\t\t\tif (entityBoard[i].cardId === CardIds.BolvarFireblood_ICC_858) {\r\n\t\t\t\tmodifyAttack(entityBoard[i], 2, entityBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(entityBoard[i], entityBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(entityBoard[i], entityBoard[i], entityBoard);\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.BolvarFireblood_TB_BaconUps_047) {\r\n\t\t\t\tmodifyAttack(entityBoard[i], 4, entityBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(entityBoard[i], entityBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(entityBoard[i], entityBoard[i], entityBoard);\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.DrakonidEnforcer_BGS_067) {\r\n\t\t\t\tmodifyAttack(entityBoard[i], 2, entityBoard, allCards);\r\n\t\t\t\tmodifyHealth(entityBoard[i], 2, entityBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(entityBoard[i], entityBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(entityBoard[i], entityBoard[i], entityBoard);\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.DrakonidEnforcer_TB_BaconUps_117) {\r\n\t\t\t\tmodifyAttack(entityBoard[i], 4, entityBoard, allCards);\r\n\t\t\t\tmodifyHealth(entityBoard[i], 4, entityBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(entityBoard[i], entityBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(entityBoard[i], entityBoard[i], entityBoard);\r\n\t\t\t} else if (\r\n\t\t\t\tentityBoard[i].entityId !== entity.entityId &&\r\n\t\t\t\t(entityBoard[i].cardId === CardIds.HolyMecherel_BG20_401 ||\r\n\t\t\t\t\tentityBoard[i].cardId === CardIds.HolyMecherel_BG20_401_G)\r\n\t\t\t) {\r\n\t\t\t\tupdateDivineShield(entityBoard[i], entityBoard, true, allCards);\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.Gemsplitter_BG21_037) {\r\n\t\t\t\taddCardsInHand(entityBoardHero, entityBoard, allCards, spectator, [CardIds.BloodGem]);\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.Gemsplitter_BG21_037_G) {\r\n\t\t\t\taddCardsInHand(entityBoardHero, entityBoard, allCards, spectator, [CardIds.BloodGem, CardIds.BloodGem]);\r\n\t\t\t} else if (\r\n\t\t\t\tentityBoard[i].cardId === CardIds.CogworkCopter_BG24_008 ||\r\n\t\t\t\tentityBoard[i].cardId === CardIds.CogworkCopter_BG24_008_G\r\n\t\t\t) {\r\n\t\t\t\tconst buff = entityBoard[i].cardId === CardIds.CogworkCopter_BG24_008_G ? 2 : 1;\r\n\t\t\t\tgrantRandomStats(entityBoard[i], entityBoardHero.hand, buff, buff, null, true, allCards, null);\r\n\t\t\t}\r\n\r\n\t\t\t// So that self-buffs from Bolvar are taken into account\r\n\t\t\t// if (entityBoard[i].entityId === entity.entityId && entity.divineShield) {\r\n\t\t\t// \tupdateDivineShield(entityBoard[i], entityBoard, false, allCards);\r\n\t\t\t// }\r\n\t\t}\r\n\t\tconst greaseBots = entityBoard.filter((entity) => entity.cardId === CardIds.GreaseBot_BG21_024);\r\n\t\tconst greaseBotBattlegrounds = entityBoard.filter((entity) => entity.cardId === CardIds.GreaseBot_BG21_024_G);\r\n\t\tgreaseBots.forEach((bot) => {\r\n\t\t\tmodifyAttack(entity, 2, entityBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 2, entityBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(bot, entity, entityBoard);\r\n\t\t});\r\n\t\tgreaseBotBattlegrounds.forEach((bot) => {\r\n\t\t\tmodifyAttack(entity, 4, entityBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 4, entityBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(bot, entity, entityBoard);\r\n\t\t});\r\n\r\n\t\tspectator.registerDamageDealt(bumpInto, entity, 0, entityBoard);\r\n\t\treturn 0;\r\n\t\t// return entity;\r\n\t}\r\n\tentity.health = entity.health - (entity.damageMultiplier || 1) * bumpInto.attack;\r\n\r\n\tif (entity.cardId === CardIds.Bubblette_BG_TID_713 && bumpInto.attack === 1) {\r\n\t\tentity.definitelyDead = true;\r\n\t} else if (entity.cardId === CardIds.Bubblette_BG_TID_713_G && bumpInto.attack === 2) {\r\n\t\tentity.definitelyDead = true;\r\n\t}\r\n\r\n\t// Do it last, so that other effects are still processed\r\n\tif (bumpInto.poisonous) {\r\n\t\t// So that further buffs don't revive it\r\n\t\t// And we don't just set the health to avoid applying overkill effects\r\n\t\tentity.definitelyDead = true;\r\n\t}\r\n\tif (bumpInto.venomous) {\r\n\t\t// So that further buffs don't revive it\r\n\t\t// And we don't just set the health to avoid applying overkill effects\r\n\t\tentity.definitelyDead = true;\r\n\t\tbumpInto.venomous = false;\r\n\t}\r\n\t// FIXME: This will likely be incorrect in terms of timings, e.g. if the entity ends up\r\n\t// surviving following a buff like Spawn.\r\n\tspectator.registerDamageDealt(bumpInto, entity, (entity.damageMultiplier || 1) * bumpInto.attack, entityBoard);\r\n\tentity.lastAffectedByEntity = bumpInto;\r\n\tif (entity.frenzyChargesLeft > 0 && entity.health > 0 && !entity.definitelyDead) {\r\n\t\tapplyFrenzy(entity, entityBoard, entityBoardHero, allCards, cardsData, sharedState, spectator);\r\n\t\tentity.frenzyChargesLeft--;\r\n\t}\r\n\r\n\t// We spawn them here, because it says \"whenever\", and so happens right away\r\n\t// FIXME: there could be a bug here, if a Cleave attacks several IGB at the same time. The current\r\n\t// implementation could spawn minions above the max board size. Fringe case though, so leaving it\r\n\t// like this for now\r\n\tconst entitySpawns = getWheneverEntitySpawns(\r\n\t\tentity,\r\n\t\tentityBoard,\r\n\t\tentityBoardHero,\r\n\t\totherBoard,\r\n\t\totherHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\tif (!!entitySpawns?.length) {\r\n\t\tconst index = entityBoard.map((e) => e.entityId).indexOf(entity.entityId);\r\n\t\taddMinionsToBoard(\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherHero,\r\n\t\t\tindex,\r\n\t\t\tentitySpawns,\r\n\t\t\tallCards,\r\n\t\t\tspectator,\r\n\t\t\tsharedState,\r\n\t\t);\r\n\t\tspectator.registerMinionsSpawn(entity, entityBoard, entitySpawns);\r\n\t}\r\n\treturn bumpInto.attack;\r\n};\r\n\r\nconst getWheneverEntitySpawns = (\r\n\tentity: BoardEntity,\r\n\tentityBoard: BoardEntity[],\r\n\tentityBoardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): readonly BoardEntity[] => {\r\n\tif (entityBoard.length === 7) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tif (entity.cardId === CardIds.ImpGangBoss_BRM_006) {\r\n\t\treturn spawnEntities(\r\n\t\t\tCardIds.ImpGangBoss_ImpToken_BRM_006t,\r\n\t\t\t1,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t} else if (entity.cardId === CardIds.ImpGangBoss_TB_BaconUps_030) {\r\n\t\treturn spawnEntities(\r\n\t\t\tCardIds.ImpGangBoss_ImpToken_TB_BaconUps_030t,\r\n\t\t\t1,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t} else if (entity.cardId === CardIds.ImpMama_BGS_044) {\r\n\t\treturn spawnEntities(\r\n\t\t\tcardsData.impMamaSpawns[Math.floor(Math.random() * cardsData.impMamaSpawns.length)],\r\n\t\t\t1,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t).map((entity) => ({ ...entity, taunt: true }));\r\n\t} else if (entity.cardId === CardIds.ImpMama_TB_BaconUps_116) {\r\n\t\treturn spawnEntities(\r\n\t\t\tcardsData.impMamaSpawns[Math.floor(Math.random() * cardsData.impMamaSpawns.length)],\r\n\t\t\t2,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t).map((entity) => ({ ...entity, taunt: true }));\r\n\t} else if (entity.cardId === CardIds.SecurityRover_BOT_218) {\r\n\t\treturn spawnEntities(\r\n\t\t\tCardIds.SecurityRover_GuardBotToken_BOT_218t,\r\n\t\t\t1,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t} else if (entity.cardId === CardIds.SecurityRover_TB_BaconUps_041) {\r\n\t\treturn spawnEntities(\r\n\t\t\tCardIds.SecurityRover_GuardBotToken_TB_BaconUps_041t,\r\n\t\t\t1,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t}\r\n\treturn null;\r\n};\r\n\r\nexport const processMinionDeath = (\r\n\tboard1: BoardEntity[],\r\n\tboard1Hero: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tboard2Hero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// console.debug('processing minions death', stringifySimple(board1, allCards), stringifySimple(board2, allCards));\r\n\tconst [deadMinionIndexesFromRights1, deadEntities1] = makeMinionsDie(board1, board1Hero, allCards, spectator);\r\n\tconst [deadMinionIndexesFromRights2, deadEntities2] = makeMinionsDie(board2, board2Hero, allCards, spectator);\r\n\tspectator.registerDeadEntities(\r\n\t\tdeadMinionIndexesFromRights1,\r\n\t\tdeadEntities1,\r\n\t\tboard1,\r\n\t\tdeadMinionIndexesFromRights2,\r\n\t\tdeadEntities2,\r\n\t\tboard2,\r\n\t);\r\n\t// No death to process, we can return\r\n\tif (deadEntities1.length === 0 && deadEntities2.length === 0) {\r\n\t\treturn;\r\n\t\t// return [board1, board2];\r\n\t}\r\n\r\n\tsharedState.deaths.push(\r\n\t\t...deadEntities1.map((e) =>\r\n\t\t\taddImpliedMechanics({ ...e, health: e.maxHealth, definitelyDead: false }, cardsData),\r\n\t\t),\r\n\t);\r\n\tsharedState.deaths.push(\r\n\t\t...deadEntities2.map((e) =>\r\n\t\t\taddImpliedMechanics({ ...e, health: e.maxHealth, definitelyDead: false }, cardsData),\r\n\t\t),\r\n\t);\r\n\tboard1Hero.globalInfo.EternalKnightsDeadThisGame =\r\n\t\tboard1Hero.globalInfo.EternalKnightsDeadThisGame +\r\n\t\tdeadEntities1.filter(\r\n\t\t\t(e) => e.cardId === CardIds.EternalKnight_BG25_008 || e.cardId === CardIds.EternalKnight_BG25_008_G,\r\n\t\t).length;\r\n\tboard2Hero.globalInfo.EternalKnightsDeadThisGame =\r\n\t\tboard2Hero.globalInfo.EternalKnightsDeadThisGame +\r\n\t\tdeadEntities2.filter(\r\n\t\t\t(e) => e.cardId === CardIds.EternalKnight_BG25_008 || e.cardId === CardIds.EternalKnight_BG25_008_G,\r\n\t\t).length;\r\n\r\n\t// First process all DRs, then process the reborn\r\n\tif (Math.random() > 0.5) {\r\n\t\t// Now proceed to trigger all deathrattle effects on baord1\r\n\t\thandleDeathrattlesForFirstBoard(\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdeadMinionIndexesFromRights1,\r\n\t\t\tdeadEntities1,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// Now handle the other board's deathrattles\r\n\t\thandleDeathrattlesForFirstBoard(\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdeadMinionIndexesFromRights2,\r\n\t\t\tdeadEntities2,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else {\r\n\t\thandleDeathrattlesForFirstBoard(\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdeadMinionIndexesFromRights2,\r\n\t\t\tdeadEntities2,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\thandleDeathrattlesForFirstBoard(\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdeadMinionIndexesFromRights1,\r\n\t\t\tdeadEntities1,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\r\n\t// Now the reborn\r\n\tif (Math.random() > 0.5) {\r\n\t\t// Now proceed to trigger all deathrattle effects on baord1\r\n\t\thandleRebornForFirstBoard(\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdeadMinionIndexesFromRights1,\r\n\t\t\tdeadEntities1,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// Now handle the other board's deathrattles\r\n\t\thandleRebornForFirstBoard(\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdeadMinionIndexesFromRights2,\r\n\t\t\tdeadEntities2,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else {\r\n\t\thandleRebornForFirstBoard(\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdeadMinionIndexesFromRights2,\r\n\t\t\tdeadEntities2,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\thandleRebornForFirstBoard(\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdeadMinionIndexesFromRights1,\r\n\t\t\tdeadEntities1,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\r\n\tif (Math.random() > 0.5) {\r\n\t\thandleAfterDeathEffectsForFirstBoard(\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdeadMinionIndexesFromRights2,\r\n\t\t\tdeadEntities2,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\thandleAfterDeathEffectsForFirstBoard(\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdeadMinionIndexesFromRights1,\r\n\t\t\tdeadEntities1,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else {\r\n\t\thandleAfterDeathEffectsForFirstBoard(\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdeadMinionIndexesFromRights1,\r\n\t\t\tdeadEntities1,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\thandleAfterDeathEffectsForFirstBoard(\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdeadMinionIndexesFromRights2,\r\n\t\t\tdeadEntities2,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\r\n\t// If the fish dies (from Scallywag for instance), it doesn't remember the deathrattle\r\n\tboard1\r\n\t\t.filter((entity) => isFish(entity))\r\n\t\t.forEach((entity) => rememberDeathrattles(entity, deadEntities1, cardsData, allCards, sharedState));\r\n\tboard2\r\n\t\t.filter((entity) => isFish(entity))\r\n\t\t.forEach((entity) => rememberDeathrattles(entity, deadEntities2, cardsData, allCards, sharedState));\r\n\r\n\tboard1\r\n\t\t.filter(\r\n\t\t\t(entity) =>\r\n\t\t\t\tentity.cardId === CardIds.Monstrosity_BG20_HERO_282_Buddy ||\r\n\t\t\t\tentity.cardId === CardIds.Monstrosity_BG20_HERO_282_Buddy_G,\r\n\t\t)\r\n\t\t.forEach((entity) => applyMonstrosity(entity, deadEntities1, board1, allCards));\r\n\tboard2\r\n\t\t.filter(\r\n\t\t\t(entity) =>\r\n\t\t\t\tentity.cardId === CardIds.Monstrosity_BG20_HERO_282_Buddy ||\r\n\t\t\t\tentity.cardId === CardIds.Monstrosity_BG20_HERO_282_Buddy_G,\r\n\t\t)\r\n\t\t.forEach((entity) => applyMonstrosity(entity, deadEntities2, board2, allCards));\r\n\r\n\t// Make sure we only return when there are no more deaths to process\r\n\t// Make sure to do this right before the end of the process\r\n\t// FIXME: this will propagate the killer between rounds, which is incorrect. For instance,\r\n\t// if a dragon kills a Ghoul, then the Ghoul's deathrattle kills a Kaboom, the killer should\r\n\t// now be the ghoul. Then if the Kaboom kills someone, the killer should again change. You could\r\n\t// also have multiple killers, which is not taken into account here.\r\n\t// The current assumption is that it's a suffienctly fringe case to not matter too much\r\n\tprocessMinionDeath(board1, board1Hero, board2, board2Hero, allCards, cardsData, sharedState, spectator);\r\n\r\n\t// Apply \"after minion death\" effects\r\n\thandleAfterMinionsDeaths(\r\n\t\tboard1,\r\n\t\tdeadEntities1,\r\n\t\tboard1Hero,\r\n\t\tboard2,\r\n\t\tdeadEntities2,\r\n\t\tboard2Hero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n};\r\n\r\nconst handleAfterMinionsDeaths = (\r\n\tboard1: BoardEntity[],\r\n\tdeadEntities1: BoardEntity[],\r\n\theroEntity1: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tdeadEntities2: BoardEntity[],\r\n\theroEntity2: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n) => {\r\n\tconst random = Math.random() > 0.5;\r\n\thandleAfterMinionsDeathsForBoard(\r\n\t\trandom ? board1 : board2,\r\n\t\trandom ? deadEntities1 : deadEntities2,\r\n\t\trandom ? heroEntity1 : heroEntity2,\r\n\t\trandom ? board2 : board1,\r\n\t\trandom ? deadEntities2 : deadEntities1,\r\n\t\trandom ? heroEntity2 : heroEntity1,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\thandleAfterMinionsDeathsForBoard(\r\n\t\t!random ? board1 : board2,\r\n\t\t!random ? deadEntities1 : deadEntities2,\r\n\t\t!random ? heroEntity1 : heroEntity2,\r\n\t\t!random ? board2 : board1,\r\n\t\t!random ? deadEntities2 : deadEntities1,\r\n\t\t!random ? heroEntity2 : heroEntity1,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n};\r\n\r\nconst handleAfterMinionsDeathsForBoard = (\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyDeadEntities: BoardEntity[],\r\n\tfriendlyHeroEntity: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherDeadEntities: BoardEntity[],\r\n\totherHeroEntity: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n) => {\r\n\tfor (const deadEntity of friendlyDeadEntities) {\r\n\t\tconst killer = deadEntity.lastAffectedByEntity;\r\n\t\tif (!killer) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\t\t// Killed an enemy minion\r\n\t\tif (killer.friendly !== deadEntity.friendly) {\r\n\t\t\tif (otherHeroEntity.heroPowerId === CardIds.Rokara_GloryOfCombat) {\r\n\t\t\t\tmodifyAttack(killer, 1, otherBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(killer, otherBoard, allCards);\r\n\t\t\t\t// Icesnarl the Mighty\r\n\t\t\t\totherBoard\r\n\t\t\t\t\t.filter(\r\n\t\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\t\te.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy ||\r\n\t\t\t\t\t\t\te.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy_G,\r\n\t\t\t\t\t)\r\n\t\t\t\t\t.forEach((icesnarl) => {\r\n\t\t\t\t\t\tmodifyHealth(\r\n\t\t\t\t\t\t\ticesnarl,\r\n\t\t\t\t\t\t\ticesnarl.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy_G ? 2 : 1,\r\n\t\t\t\t\t\t\tfriendlyBoard,\r\n\t\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tafterStatsUpdate(icesnarl, friendlyBoard, allCards);\r\n\t\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleDeathrattlesForFirstBoard = (\r\n\tfirstBoard: BoardEntity[],\r\n\tfirstBoardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tdeadMinionIndexesFromRight: readonly number[],\r\n\tdeadEntities: readonly BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tfor (let i = 0; i < deadMinionIndexesFromRight.length; i++) {\r\n\t\tconst entity = deadEntities[i];\r\n\t\tconst indexFromRight = deadMinionIndexesFromRight[i];\r\n\t\tif (entity.health <= 0 || entity.definitelyDead) {\r\n\t\t\tbuildBoardAfterDeathrattleSpawns(\r\n\t\t\t\tfirstBoard,\r\n\t\t\t\tfirstBoardHero,\r\n\t\t\t\tentity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tdeadEntities,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t} else if (firstBoard.length > 0) {\r\n\t\t\t// const newBoardD = [...firstBoard];\r\n\t\t\tfirstBoard.splice(firstBoard.length - indexFromRight, 1, entity);\r\n\t\t\t// firstBoard = newBoardD;\r\n\t\t}\r\n\t}\r\n\t// return [firstBoard, otherBoard];\r\n};\r\n\r\nconst handleRebornForFirstBoard = (\r\n\tfirstBoard: BoardEntity[],\r\n\tfirstBoardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tdeadMinionIndexesFromRight: readonly number[],\r\n\tdeadEntities: readonly BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// console.log('will handle reborn', stringifySimple(firstBoard, allCards), deadMinionIndexesFromRight);\r\n\tfor (let i = deadMinionIndexesFromRight.length - 1; i >= 0; i--) {\r\n\t\tconst entity = deadEntities[i];\r\n\t\tconst indexFromRight = deadMinionIndexesFromRight[i];\r\n\t\tif (entity.health <= 0 || entity.definitelyDead) {\r\n\t\t\tif (!entity?.cardId) {\r\n\t\t\t\tconsole.error(\r\n\t\t\t\t\t'missing card id for entity that died',\r\n\t\t\t\t\tstringifySimpleCard(entity, allCards),\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\tdeadMinionIndexesFromRight,\r\n\t\t\t\t\tstringifySimple(firstBoard, allCards),\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t\t// console.log('dead entity', stringifySimpleCard(entity, allCards), indexFromRight);\r\n\t\t\tbuildBoardAfterRebornSpawns(\r\n\t\t\t\tfirstBoard,\r\n\t\t\t\tfirstBoardHero,\r\n\t\t\t\tentity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\t// console.log('after rebord', stringifySimple(firstBoard, allCards));\r\n\t\t} else if (firstBoard.length > 0) {\r\n\t\t\t// const newBoardD = [...firstBoard];\r\n\t\t\tfirstBoard.splice(firstBoard.length - indexFromRight, 1, entity);\r\n\t\t\t// firstBoard = newBoardD;\r\n\t\t}\r\n\t}\r\n\t// return [firstBoard, otherBoard];\r\n};\r\n\r\nconst handleAfterDeathEffectsForFirstBoard = (\r\n\tfirstBoard: BoardEntity[],\r\n\tfirstBoardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tdeadMinionIndexesFromRight: readonly number[],\r\n\tdeadEntities: readonly BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tfor (let i = 0; i < deadMinionIndexesFromRight.length; i++) {\r\n\t\tconst entity = deadEntities[i];\r\n\t\tconst indexFromRight = deadMinionIndexesFromRight[i];\r\n\t\tapplyAfterDeathEffects(\r\n\t\t\tentity,\r\n\t\t\tindexFromRight,\r\n\t\t\tfirstBoard,\r\n\t\t\tfirstBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n};\r\n\r\nexport const applyOnAttackBuffs = (\r\n\tattacker: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (attacker.cardId === CardIds.GlyphGuardian_BGS_045) {\r\n\t\t// For now the utility method only works additively, so we hack around it\r\n\t\tmodifyAttack(attacker, 2 * attacker.attack - attacker.attack, attackingBoard, allCards);\r\n\t}\r\n\tif (attacker.cardId === CardIds.GlyphGuardian_TB_BaconUps_115) {\r\n\t\tmodifyAttack(attacker, 3 * attacker.attack - attacker.attack, attackingBoard, allCards);\r\n\t}\r\n\r\n\t// Ripsnarl Captain\r\n\tif (isCorrectTribe(allCards.getCard(attacker.cardId).races, Race.PIRATE)) {\r\n\t\tconst ripsnarls = attackingBoard.filter((e) => e.cardId === CardIds.RipsnarlCaptain_BGS_056);\r\n\t\tconst ripsnarlsTB = attackingBoard.filter(\r\n\t\t\t(entity) => entity.cardId === CardIds.RipsnarlCaptain_TB_BaconUps_139,\r\n\t\t);\r\n\t\tripsnarls.forEach((captain) => {\r\n\t\t\tmodifyAttack(attacker, 3, attackingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(captain, attacker, attackingBoard);\r\n\t\t});\r\n\t\tripsnarlsTB.forEach((captain) => {\r\n\t\t\tmodifyAttack(attacker, 6, attackingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(captain, attacker, attackingBoard);\r\n\t\t});\r\n\t}\r\n\r\n\t// Dread Admiral Eliza\r\n\tif (isCorrectTribe(allCards.getCard(attacker.cardId).races, Race.PIRATE)) {\r\n\t\tconst elizas = attackingBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.DreadAdmiralEliza_BGS_047 || e.cardId === CardIds.AdmiralElizaGoreblade_BG27_555,\r\n\t\t);\r\n\t\tconst elizasTB = attackingBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.DreadAdmiralEliza_TB_BaconUps_134 ||\r\n\t\t\t\te.cardId === CardIds.AdmiralElizaGoreblade_BG27_555_G,\r\n\t\t);\r\n\r\n\t\telizas.forEach((eliza) => {\r\n\t\t\tattackingBoard.forEach((entity) => {\r\n\t\t\t\tmodifyAttack(entity, 2, attackingBoard, allCards);\r\n\t\t\t\tmodifyHealth(entity, 1, attackingBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(eliza, entity, attackingBoard);\r\n\t\t\t});\r\n\t\t});\r\n\t\telizasTB.forEach((eliza) => {\r\n\t\t\tattackingBoard.forEach((entity) => {\r\n\t\t\t\tmodifyAttack(entity, 4, attackingBoard, allCards);\r\n\t\t\t\tmodifyHealth(entity, 2, attackingBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(eliza, entity, attackingBoard);\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n\tif (\r\n\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708 ||\r\n\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708_G\r\n\t) {\r\n\t\tattackingBoard\r\n\t\t\t.filter((e) => isCorrectTribe(allCards.getCard(e.cardId).races, Race.PIRATE))\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\tmodifyAttack(\r\n\t\t\t\t\te,\r\n\t\t\t\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708_G ? 4 : 2,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t);\r\n\t\t\t\tmodifyHealth(\r\n\t\t\t\t\te,\r\n\t\t\t\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708_G ? 4 : 2,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t);\r\n\t\t\t\tspectator.registerPowerTarget(attacker, e, attackingBoard);\r\n\t\t\t});\r\n\t}\r\n\r\n\tconst eclipsion = attackingBoard.find(\r\n\t\t(e) =>\r\n\t\t\t[\r\n\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy,\r\n\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy_G,\r\n\t\t\t].includes(e.cardId as CardIds) && e.abiityChargesLeft > 0,\r\n\t);\r\n\tif (!!eclipsion) {\r\n\t\tattacker.immuneWhenAttackCharges = 1;\r\n\t\teclipsion.abiityChargesLeft--;\r\n\t}\r\n};\r\n\r\nexport const applyOnBeingAttackedBuffs = (\r\n\tattackerEntity: BoardEntity,\r\n\tdefendingEntity: BoardEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (defendingEntity.taunt) {\r\n\t\tconst champions = defendingBoard.filter((entity) => entity.cardId === CardIds.ChampionOfYshaarj_BGS_111);\r\n\t\tconst goldenChampions = defendingBoard.filter(\r\n\t\t\t(entity) => entity.cardId === CardIds.ChampionOfYshaarj_TB_BaconUps_301,\r\n\t\t);\r\n\t\tchampions.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 1, defendingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 2, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(entity, entity, defendingBoard);\r\n\t\t});\r\n\t\tgoldenChampions.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 2, defendingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 4, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(entity, entity, defendingBoard);\r\n\t\t});\r\n\r\n\t\tconst arms = defendingBoard.filter((entity) => entity.cardId === CardIds.ArmOfTheEmpire_BGS_110);\r\n\t\tconst goldenArms = defendingBoard.filter((entity) => entity.cardId === CardIds.ArmOfTheEmpire_TB_BaconUps_302);\r\n\t\tarms.forEach((arm) => {\r\n\t\t\tmodifyAttack(defendingEntity, 2, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(arm, defendingEntity, defendingBoard);\r\n\t\t});\r\n\t\tgoldenArms.forEach((arm) => {\r\n\t\t\tmodifyAttack(defendingEntity, 4, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(arm, defendingEntity, defendingBoard);\r\n\t\t});\r\n\t}\r\n\r\n\t// Based on defending entity\r\n\tif (defendingEntity.cardId === CardIds.TormentedRitualist_BGS_201) {\r\n\t\tconst neighbours = getNeighbours(defendingBoard, defendingEntity);\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 1, defendingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 1, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(defendingEntity, entity, defendingBoard);\r\n\t\t});\r\n\t} else if (defendingEntity.cardId === CardIds.TormentedRitualist_TB_BaconUps_257) {\r\n\t\tconst neighbours = getNeighbours(defendingBoard, defendingEntity);\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 2, defendingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 2, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(defendingEntity, entity, defendingBoard);\r\n\t\t});\r\n\t} else if (\r\n\t\tdefendingEntity.cardId === CardIds.DozyWhelp_BG24_300 ||\r\n\t\tdefendingEntity.cardId === CardIds.DozyWhelp_BG24_300_G\r\n\t) {\r\n\t\tmodifyAttack(\r\n\t\t\tdefendingEntity,\r\n\t\t\tdefendingEntity.cardId === CardIds.DozyWhelp_BG24_300_G ? 2 : 1,\r\n\t\t\tdefendingBoard,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t\tspectator.registerPowerTarget(defendingEntity, defendingEntity, defendingBoard);\r\n\t} else if (\r\n\t\t[CardIds.AdaptableBarricade_BG27_022, CardIds.AdaptableBarricade_BG27_022_G].includes(\r\n\t\t\tdefendingEntity.cardId as CardIds,\r\n\t\t)\r\n\t) {\r\n\t\t// https://twitter.com/LoewenMitchell/status/1692225556559901031?s=20\r\n\t\tconst totalStats = defendingEntity.attack + defendingEntity.health;\r\n\t\tconst attackerAttack = attackerEntity.attack;\r\n\t\tif (defendingEntity.divineShield) {\r\n\t\t\tdefendingEntity.health = 1;\r\n\t\t\tdefendingEntity.attack = totalStats - defendingEntity.health;\r\n\t\t} else if (attackerEntity.venomous || attackerEntity.poisonous) {\r\n\t\t\t// Do nothing\r\n\t\t} else if (attackerAttack < totalStats) {\r\n\t\t\tdefendingEntity.health = attackerAttack + 1;\r\n\t\t\tdefendingEntity.attack = totalStats - defendingEntity.health;\r\n\t\t}\r\n\t} else if (\r\n\t\t[CardIds.GraniteGuardian_BG24_001, CardIds.GraniteGuardian_BG24_001_G].includes(\r\n\t\t\tdefendingEntity.cardId as CardIds,\r\n\t\t)\r\n\t) {\r\n\t\tattackerEntity.health = 1;\r\n\t}\r\n\r\n\t// Based on attacking entity\r\n\tif (\r\n\t\tattackerEntity.cardId === CardIds.SindoreiStraightShot_BG25_016 ||\r\n\t\tattackerEntity.cardId === CardIds.SindoreiStraightShot_BG25_016_G\r\n\t) {\r\n\t\tdefendingEntity.taunt = false;\r\n\t\tdefendingEntity.reborn = false;\r\n\t} else if (\r\n\t\t[CardIds.TransmutedBramblewitch_BG27_013, CardIds.TransmutedBramblewitch_BG27_013_G].includes(\r\n\t\t\tattackerEntity.cardId as CardIds,\r\n\t\t) &&\r\n\t\tattackerEntity.abiityChargesLeft > 0\r\n\t) {\r\n\t\tdefendingEntity.attack = 3;\r\n\t\tdefendingEntity.health = 3;\r\n\t\tattackerEntity.abiityChargesLeft--;\r\n\t}\r\n};\r\n\r\nconst makeMinionsDie = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): [number[], BoardEntity[]] => {\r\n\t// Because entities spawn to the left, so the right index is unchanged\r\n\tconst deadMinionIndexesFromRight: number[] = [];\r\n\tconst deadEntities: BoardEntity[] = [];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].health <= 0 || board[i].definitelyDead) {\r\n\t\t\tdeadMinionIndexesFromRight.push(board.length - (i + 1));\r\n\t\t\tdeadEntities.push(board[i]);\r\n\t\t\tremoveMinionFromBoard(board, boardHero, i, allCards, spectator);\r\n\t\t\t// We modify the original array, so we need to update teh current index accordingly\r\n\t\t\ti--;\r\n\t\t}\r\n\t}\r\n\t// Treat all dead entities as a single block\r\n\tconst blockIndexesFromRight = [...deadMinionIndexesFromRight];\r\n\tfor (let i = deadMinionIndexesFromRight.length - 1; i >= 0; i--) {\r\n\t\tif (i === deadMinionIndexesFromRight.length - 1) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\t\tif (Math.abs(deadMinionIndexesFromRight[i] - deadMinionIndexesFromRight[i + 1]) <= 1) {\r\n\t\t\tblockIndexesFromRight[i] = blockIndexesFromRight[i + 1];\r\n\t\t} else {\r\n\t\t\t// blockIndexesFromRight[i] = blockIndexesFromRight[i];\r\n\t\t}\r\n\t}\r\n\treturn [blockIndexesFromRight, deadEntities];\r\n};\r\n\r\n// const handleKillEffects = (\r\n// \tboardWithKilledMinion: BoardEntity[],\r\n// \tkillerBoard: BoardEntity[],\r\n// \tdeadEntity: BoardEntity,\r\n// \tallCards: AllCardsService,\r\n// \tspectator: Spectator,\r\n// ): void => {\r\n// \tif (\r\n// \t\tdeadEntity.lastAffectedByEntity?.cardId &&\r\n// \t\tisCorrectTribe(allCards.getCard(deadEntity.lastAffectedByEntity.cardId).race, Race.DRAGON)\r\n// \t) {\r\n// \t\tfor (const entity of killerBoard) {\r\n// \t\t\tif (entity.cardId === CardIds.WaxriderTogwaggle2) {\r\n// \t\t\t\tmodifyAttack(entity, 2, killerBoard, allCards);\r\n// \t\t\t\tmodifyHealth(entity, 2, killerBoard, allCards);\r\n// \t\t\t\tafterStatsUpdate(entity, killerBoard, allCards);\r\n// \t\t\t\tspectator.registerPowerTarget(entity, entity, killerBoard);\r\n// \t\t\t} else if (entity.cardId === CardIds.WaxriderTogwaggleBattlegrounds) {\r\n// \t\t\t\tmodifyAttack(entity, 4, killerBoard, allCards);\r\n// \t\t\t\tmodifyHealth(entity, 4, killerBoard, allCards);\r\n// \t\t\t\tafterStatsUpdate(entity, killerBoard, allCards);\r\n// \t\t\t\tspectator.registerPowerTarget(entity, entity, killerBoard);\r\n// \t\t\t}\r\n// \t\t}\r\n// \t}\r\n// };\r\n\r\nexport const buildBoardAfterDeathrattleSpawns = (\r\n\tboardWithKilledMinion: BoardEntity[],\r\n\tboardWithKilledMinionHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tdeadMinionIndexFromRight2: number,\r\n\topponentBoard: BoardEntity[],\r\n\topponentBoardHero: BgsPlayerEntity,\r\n\tentitiesDeadThisAttack: readonly BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// TODO: don't apply this for FishOfNZoth\r\n\t// if (deadMinionIndex >= 0) {\r\n\t// \thandleKillEffects(boardWithKilledMinion, opponentBoard, deadEntity, allCards, spectator);\r\n\t// }\r\n\r\n\t// But Wildfire Element is applied first, before the DR spawns\r\n\tif (deadMinionIndexFromRight2 >= 0) {\r\n\t\tapplyMinionDeathEffect(\r\n\t\t\tdeadEntity,\r\n\t\t\tdeadMinionIndexFromRight2,\r\n\t\t\tboardWithKilledMinion,\r\n\t\t\tboardWithKilledMinionHero,\r\n\t\t\topponentBoard,\r\n\t\t\topponentBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\r\n\thandleDeathrattles(\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\tdeadEntity,\r\n\t\tdeadMinionIndexFromRight2,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tentitiesDeadThisAttack,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\r\n\t// TODO: check if Avenge effects should proc after deathrattles instead\r\n\t// They most certainly do, since the rat pack + avenge beast buffer works\r\n\tapplyAvengeEffects(\r\n\t\tdeadEntity,\r\n\t\tdeadMinionIndexFromRight2,\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\r\n\tconst entitiesFromAfterDeath: readonly BoardEntity[] = applyOnDeathEffects(\r\n\t\tdeadEntity,\r\n\t\tdeadMinionIndexFromRight2,\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\tperformEntitySpawns(\r\n\t\tentitiesFromAfterDeath,\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\tdeadEntity,\r\n\t\tdeadMinionIndexFromRight2,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\t// console.log('board after spawn', stringifySimple(boardWithKilledMinion, allCards));\r\n};\r\n\r\nconst buildBoardAfterRebornSpawns = (\r\n\tboardWithKilledMinion: BoardEntity[],\r\n\tboardWithKilledMinionHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tdeadMinionIndexFromRight: number,\r\n\topponentBoard: BoardEntity[],\r\n\topponentBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst numberOfReborns = 1;\r\n\t// Reborn happens after deathrattles\r\n\tif (!deadEntity.cardId) {\r\n\t\tconsole.error('missing card id for dead entity', stringifySimpleCard(deadEntity, allCards), deadEntity);\r\n\t}\r\n\tlet entityToSpawn: BoardEntity = null;\r\n\t// TODO: test\r\n\tif (\r\n\t\tdeadEntity.cardId === CardIds.SinrunnerBlanchy_BG24_005 ||\r\n\t\tdeadEntity.cardId === CardIds.SinrunnerBlanchy_BG24_005_G\r\n\t) {\r\n\t\tentityToSpawn = {\r\n\t\t\t...deadEntity,\r\n\t\t\thealth: deadEntity.maxHealth,\r\n\t\t\tdivineShield: deadEntity.hadDivineShield,\r\n\t\t\treborn: false,\r\n\t\t};\r\n\t}\r\n\tconst entitiesFromReborn: readonly BoardEntity[] =\r\n\t\tdeadEntity.reborn && deadMinionIndexFromRight >= 0\r\n\t\t\t? spawnEntities(\r\n\t\t\t\t\tdeadEntity.cardId,\r\n\t\t\t\t\tnumberOfReborns,\r\n\t\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentBoardHero,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tcardsData,\r\n\t\t\t\t\tsharedState,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t\tentityToSpawn,\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t )\r\n\t\t\t: [];\r\n\tconst entitiesThatWereReborn = performEntitySpawns(\r\n\t\tentitiesFromReborn,\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\tdeadEntity,\r\n\t\tdeadMinionIndexFromRight,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\r\n\tconst arfus = boardWithKilledMinion\r\n\t\t.filter((e) => e.cardId === CardIds.Arfus_TB_BaconShop_HERO_22_Buddy)\r\n\t\t.map((e) => e.attack)\r\n\t\t.reduce((a, b) => a + b, 0);\r\n\tconst goldenArfus = boardWithKilledMinion\r\n\t\t.filter((e) => e.cardId === CardIds.Arfus_TB_BaconShop_HERO_22_Buddy_G)\r\n\t\t.map((e) => 2 * e.attack)\r\n\t\t.reduce((a, b) => a + b, 0);\r\n\tif (arfus + goldenArfus > 0) {\r\n\t\tentitiesThatWereReborn.forEach((e) => {\r\n\t\t\tmodifyAttack(e, arfus + goldenArfus, boardWithKilledMinion, allCards);\r\n\t\t\tafterStatsUpdate(e, boardWithKilledMinion, allCards);\r\n\t\t});\r\n\t}\r\n\r\n\tconst numberOfTriggersForDeathwhisper = Math.min(entitiesFromReborn.length, 1);\r\n\tfor (let i = 0; i < numberOfTriggersForDeathwhisper; i++) {\r\n\t\tboardWithKilledMinion\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId === CardIds.SisterDeathwhisper_BG25_020 ||\r\n\t\t\t\t\te.cardId === CardIds.SisterDeathwhisper_BG25_020_G,\r\n\t\t\t)\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\tconst multiplier = e.cardId === CardIds.SisterDeathwhisper_BG25_020_G ? 2 : 1;\r\n\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\te,\r\n\t\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\t\tmultiplier * 1,\r\n\t\t\t\t\tmultiplier * 3,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t\tRace[Race.UNDEAD],\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t\tboardWithKilledMinion\r\n\t\t\t.filter((e) => e.cardId === CardIds.JellyBelly_BG25_005 || e.cardId === CardIds.JellyBelly_BG25_005_G)\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\tconst multiplier = e.cardId === CardIds.JellyBelly_BG25_005_G ? 2 : 1;\r\n\t\t\t\tmodifyAttack(e, multiplier * 3, boardWithKilledMinion, allCards);\r\n\t\t\t\tmodifyHealth(e, multiplier * 3, boardWithKilledMinion, allCards);\r\n\t\t\t\tafterStatsUpdate(e, boardWithKilledMinion, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(e, e, boardWithKilledMinion);\r\n\t\t\t});\r\n\t}\r\n};\r\n\r\nexport const performEntitySpawns = (\r\n\tcandidateEntities: readonly BoardEntity[],\r\n\tboardWithKilledMinion: BoardEntity[],\r\n\tboardWithKilledMinionHero: BgsPlayerEntity,\r\n\tspawnSourceEntity: BoardEntity | BgsPlayerEntity,\r\n\tspawnSourceEntityIndexFromRight: number,\r\n\topponentBoard: BoardEntity[],\r\n\topponentBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): readonly BoardEntity[] => {\r\n\tconst aliveEntites = candidateEntities.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\tconst spawnedEntities = [];\r\n\tfor (let i = 0; i < aliveEntites.length; i++) {\r\n\t\tconst newMinion = aliveEntites[i];\r\n\t\t// All entities have been spawned\r\n\t\tif (boardWithKilledMinion.length >= 7) {\r\n\t\t\tfor (let j = i; j < aliveEntites.length; j++) {\r\n\t\t\t\tif (aliveEntites[j]?.onCanceledSummon) {\r\n\t\t\t\t\taliveEntites[j].onCanceledSummon();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t// Avoid minions spawning backwards (we don't have this issue if we add all elements at\r\n\t\t// the same time, but here we want to be able to attack after each spawn, which in turn\r\n\t\t// means that the minion can die before the other one spawns)\r\n\t\t// In boardWithKilledMinion, the dead minion has already been removed\r\n\t\tconst indexToSpawnAt = boardWithKilledMinion.length - spawnSourceEntityIndexFromRight;\r\n\t\taddMinionToBoard(\r\n\t\t\tboardWithKilledMinion,\r\n\t\t\tboardWithKilledMinionHero,\r\n\t\t\topponentBoardHero,\r\n\t\t\tindexToSpawnAt,\r\n\t\t\tnewMinion,\r\n\t\t\tallCards,\r\n\t\t\tspectator,\r\n\t\t\tsharedState,\r\n\t\t);\r\n\t\tif (newMinion.attackImmediately) {\r\n\t\t\t// Whenever we are already in a combat phase, we need to first clean up the state\r\n\t\t\tsimulateAttack(\r\n\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentBoardHero,\r\n\t\t\t\tnull,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t\tif (newMinion.health > 0 && !newMinion.definitelyDead) {\r\n\t\t\tspawnedEntities.push(newMinion);\r\n\t\t}\r\n\t}\r\n\r\n\tspectator.registerMinionsSpawn(spawnSourceEntity, boardWithKilledMinion, spawnedEntities);\r\n\treturn spawnedEntities;\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"attack.js","sourceRoot":"","sources":["../../src/simulation/attack.ts"],"names":[],"mappings":";;;AACA,iEAA8E;AAI9E,6CAAgE;AAChE,gEAA2D;AAC3D,oCAgBkB;AAClB,+DAA4E;AAC5E,qCAA8C;AAC9C,mDAA8E;AAC9E,+DAK+B;AAC/B,6DAAqD;AACrD,qCAAuC;AACvC,+CAA6C;AAC7C,yEAAmE;AAGnE,uDAAiD;AAG1C,MAAM,cAAc,GAAG,CAC7B,cAA6B,EAC7B,kBAAmC,EACnC,cAA6B,EAC7B,kBAAmC,EACnC,oBAA4B,EAC5B,QAAyB,EACzB,MAAiB,EACjB,WAAwB,EACxB,SAAoB,EACpB,yBAAkC,EACzB,EAAE;IACX,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;QAC/D,OAAO;KACP;IAED,MAAM,eAAe,GACpB,yBAAyB,IAAI,IAAI;QAChC,CAAC,CAAC,cAAc,CAAC,yBAAyB,CAAC;QAC3C,CAAC,CAAC,kBAAkB,CAAC,cAAc,EAAE,oBAAoB,CAAC,CAAC;IAC7D,MAAM,oBAAoB,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,QAAQ,CAAC,CAAC;IACtG,IAAI,eAAe,EAAE;QACpB,eAAe,CAAC,SAAS,GAAG,IAAI,CAAC;QACjC,MAAM,eAAe,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,EAAE,CAAC,EAAE,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ACD;YACD,MAAM;SACN;QAKD,MAAM,cAAc,GAAG,qBAAqB,CAAC,MAAM,GAAG,+BAA+B,CAAC;QACtF,IAAA,sCAAgB,EACf,qBAAqB,EACrB,yBAAyB,EACzB,iBAAiB,EACjB,cAAc,EACd,SAAS,EACT,QAAQ,EACR,SAAS,EACT,WAAW,CACX,CAAC;QACF,IAAI,SAAS,CAAC,iBAAiB,EAAE;YAEhC,IAAA,sBAAc,EACb,qBAAqB,EACrB,yBAAyB,EACzB,aAAa,EACb,iBAAiB,EACjB,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,WAAW,EACX,SAAS,CACT,CAAC;SACF;QACD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE;YACtD,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAChC;KACD;IAED,SAAS,CAAC,oBAAoB,CAAC,iBAAiB,EAAE,qBAAqB,EAAE,eAAe,CAAC,CAAC;IAC1F,OAAO,eAAe,CAAC;AACxB,CAAC,CAAC;AA9DW,QAAA,mBAAmB,uBA8D9B","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { AllCardsService, CardIds, Race } from '@firestone-hs/reference-data';\r\nimport { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport { CardsData } from '../cards/cards-data';\r\nimport { groupByFunction, pickRandom } from '../services/utils';\r\nimport { validEnchantments } from '../simulate-bgs-battle';\r\nimport {\r\n\taddCardsInHand,\r\n\taddImpliedMechanics,\r\n\taddStatsToBoard,\r\n\tafterStatsUpdate,\r\n\tgrantRandomStats,\r\n\tgrantStatsToMinionsOfEachType,\r\n\thasCorrectTribe,\r\n\thasMechanic,\r\n\tisCorrectTribe,\r\n\tisFish,\r\n\tmodifyAttack,\r\n\tmodifyHealth,\r\n\tstringifySimple,\r\n\tstringifySimpleCard,\r\n\tupdateDivineShield,\r\n} from '../utils';\r\nimport { addMinionToBoard, addMinionsToBoard } from './add-minion-to-board';\r\nimport { applyAvengeEffects } from './avenge';\r\nimport { applyAfterDeathEffects, applyOnDeathEffects } from './death-effects';\r\nimport {\r\n\tapplyMinionDeathEffect,\r\n\tapplyMonstrosity,\r\n\thandleDeathrattles,\r\n\trememberDeathrattles,\r\n} from './deathrattle-effects';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { applyFrenzy } from './frenzy';\r\nimport { onMinionKill } from './minion-kill';\r\nimport { removeMinionFromBoard } from './remove-minion-from-board';\r\nimport { SharedState } from './shared-state';\r\nimport { Spectator } from './spectator/spectator';\r\nimport { canAttack } from './utils/entity-utils';\r\n\r\n// Only use it to simulate actual attack. To simulate damage, or something similar, use bumpInto\r\nexport const simulateAttack = (\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tlastAttackerEntityId: number,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n\tforceAttackingEntityIndex?: number,\r\n): number => {\r\n\tif (attackingBoard.length === 0 || defendingBoard.length === 0) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst attackingEntity =\r\n\t\tforceAttackingEntityIndex != null\r\n\t\t\t? attackingBoard[forceAttackingEntityIndex]\r\n\t\t\t: getAttackingEntity(attackingBoard, lastAttackerEntityId);\r\n\tconst attackingEntityIndex = attackingBoard.map((e) => e.entityId).indexOf(attackingEntity?.entityId);\r\n\tif (attackingEntity) {\r\n\t\tattackingEntity.attacking = true;\r\n\t\tconst numberOfAttacks = attackingEntity.windfury ? 2 : 1;\r\n\t\tfor (let i = 0; i < numberOfAttacks; i++) {\r\n\t\t\t// We refresh the entity in case of windfury\r\n\t\t\tif (attackingBoard.length === 0 || defendingBoard.length === 0) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\t// console.log(\r\n\t\t\t// \t'\\nattack by',\r\n\t\t\t// \tstringifySimpleCard(attackingEntity, allCards),\r\n\t\t\t// \tstringifySimple(defendingBoard, allCards),\r\n\t\t\t// \tstringifySimple(attackingBoard, allCards),\r\n\t\t\t// );\r\n\t\t\t// Check that didn't die\r\n\t\t\tif (attackingBoard.find((entity) => entity.entityId === attackingEntity.entityId)) {\r\n\t\t\t\tconst defendingEntity: BoardEntity = getDefendingEntity(defendingBoard, attackingEntity);\r\n\t\t\t\t// Can happen with a single defender that has stealth\r\n\t\t\t\tif (defendingEntity) {\r\n\t\t\t\t\tdoFullAttack(\r\n\t\t\t\t\t\tattackingEntity,\r\n\t\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tspawns,\r\n\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t);\r\n\t\t\t\t} else {\r\n\t\t\t\t\t// Solves the edge case of Sky Pirate vs a stealth board\r\n\t\t\t\t\tattackingEntity.attackImmediately = false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tattackingEntity.attacking = false;\r\n\t}\r\n\t// If entities that were before the attacker died, we need to update the attacker index\r\n\treturn attackingEntityIndex;\r\n};\r\n\r\nexport const doFullAttack = (\r\n\tattackingEntity: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingEntity: BoardEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n) => {\r\n\tapplyOnAttackBuffs(attackingEntity, attackingBoard, allCards, spectator);\r\n\tspectator.registerAttack(attackingEntity, defendingEntity, attackingBoard, defendingBoard);\r\n\tapplyOnBeingAttackedBuffs(attackingEntity, defendingEntity, defendingBoard, allCards, spectator);\r\n\tperformAttack(\r\n\t\tattackingEntity,\r\n\t\tdefendingEntity,\r\n\t\tattackingBoard,\r\n\t\tattackingBoardHero,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\tapplyAfterAttackEffects(attackingEntity, attackingBoard, attackingBoardHero, allCards, spectator);\r\n\tprocessMinionDeath(\r\n\t\tattackingBoard,\r\n\t\tattackingBoardHero,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\tif (\r\n\t\tdefendingEntity.health > 0 &&\r\n\t\t!defendingEntity.definitelyDead &&\r\n\t\t(defendingEntity.cardId === CardIds.YoHoOgre_BGS_060 ||\r\n\t\t\tdefendingEntity.cardId === CardIds.YoHoOgre_TB_BaconUps_150)\r\n\t) {\r\n\t\tdefendingEntity.attackImmediately = true;\r\n\t\tif (defendingEntity.attackImmediately) {\r\n\t\t\tsimulateAttack(\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tnull,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspawns,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst applyAfterAttackEffects = (\r\n\tattackingEntity: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (attackingEntity.cardId === CardIds.Bonker_BG20_104 || attackingEntity.cardId === CardIds.Bonker_BG20_104_G) {\r\n\t\tconst quantity = attackingEntity.cardId === CardIds.Bonker_BG20_104_G ? 2 : 1;\r\n\t\tconst cards = quantity === 1 ? [CardIds.BloodGem] : [CardIds.BloodGem, CardIds.BloodGem];\r\n\t\taddCardsInHand(attackingBoardHero, attackingBoard, allCards, spectator, cards);\r\n\t} else if (attackingEntity.cardId === CardIds.Yrel_BG23_350 || attackingEntity.cardId === CardIds.Yrel_BG23_350_G) {\r\n\t\tconst modifier = attackingEntity.cardId === CardIds.Yrel_BG23_350_G ? 2 : 1;\r\n\t\tgrantStatsToMinionsOfEachType(attackingEntity, attackingBoard, modifier * 1, modifier * 2, allCards, spectator);\r\n\t} else if (\r\n\t\tattackingEntity.cardId === CardIds.IncorporealCorporal_BG26_RLK_117 ||\r\n\t\tattackingEntity.cardId === CardIds.IncorporealCorporal_BG26_RLK_117_G\r\n\t) {\r\n\t\tattackingEntity.definitelyDead = true;\r\n\t}\r\n\t// Putricide-only\r\n\telse if (attackingEntity.additionalCards?.includes(CardIds.IncorporealCorporal_BG26_RLK_117)) {\r\n\t\tattackingEntity.definitelyDead = true;\r\n\t}\r\n\tattackingBoard\r\n\t\t.filter((e) => e.additionalCards?.includes(CardIds.FesterootHulk_BG_GIL_655))\r\n\t\t.forEach((e) => {\r\n\t\t\tmodifyAttack(e, 1, attackingBoard, allCards);\r\n\t\t\tafterStatsUpdate(e, attackingBoard, allCards);\r\n\t\t});\r\n\r\n\tattackingEntity.stealth = false;\r\n};\r\n\r\nconst performAttack = (\r\n\tattackingEntity: BoardEntity,\r\n\tdefendingEntity: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (hasCorrectTribe(attackingEntity, Race.DRAGON, allCards)) {\r\n\t\tconst prestors = attackingBoard\r\n\t\t\t.filter((e) => e.entityId !== attackingEntity.entityId)\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId === CardIds.PrestorsPyrospawn_BG21_012 ||\r\n\t\t\t\t\te.cardId === CardIds.PrestorsPyrospawn_BG21_012_G,\r\n\t\t\t);\r\n\t\tprestors.forEach((prestor) => {\r\n\t\t\tspectator.registerPowerTarget(prestor, defendingEntity, defendingBoard);\r\n\t\t\tdealDamageToEnemy(\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tprestor,\r\n\t\t\t\tprestor.cardId === CardIds.PrestorsPyrospawn_BG21_012_G ? 6 : 3,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n\tif (\r\n\t\tattackingEntity.cardId === CardIds.Atramedes_BG23_362 ||\r\n\t\tattackingEntity.cardId === CardIds.Atramedes_BG23_362_G\r\n\t) {\r\n\t\tconst targets = [defendingEntity, ...getNeighbours(defendingBoard, defendingEntity)];\r\n\t\tconst multiplier = attackingEntity.cardId === CardIds.Atramedes_BG23_362_G ? 2 : 1;\r\n\r\n\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\ttargets.forEach((target) => {\r\n\t\t\t\tspectator.registerPowerTarget(attackingEntity, target, defendingBoard);\r\n\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tattackingEntity,\r\n\t\t\t\t\t3,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tcardsData,\r\n\t\t\t\t\tsharedState,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t\t}\r\n\t} else if (\r\n\t\tattackingEntity.cardId === CardIds.Niuzao_BG27_822 ||\r\n\t\tattackingEntity.cardId === CardIds.Niuzao_BG27_822\r\n\t) {\r\n\t\tconst multiplier = attackingEntity.cardId === CardIds.Niuzao_BG27_822 ? 2 : 1;\r\n\t\tfor (let i = 0; i < multiplier; i++) {\r\n\t\t\tconst target = pickRandom(defendingBoard.filter((e) => e.entityId != defendingEntity.entityId));\r\n\t\t\tif (target) {\r\n\t\t\t\tspectator.registerPowerTarget(attackingEntity, target, defendingBoard);\r\n\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\ttarget,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tattackingEntity,\r\n\t\t\t\t\tattackingEntity.attack,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tcardsData,\r\n\t\t\t\t\tsharedState,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t} else if (\r\n\t\tattackingEntity.cardId === CardIds.ObsidianRavager_BG27_017 ||\r\n\t\tattackingEntity.cardId === CardIds.ObsidianRavager_BG27_017_G\r\n\t) {\r\n\t\tconst neighbours = getNeighbours(defendingBoard, defendingEntity);\r\n\t\tconst targets =\r\n\t\t\tattackingEntity.cardId === CardIds.ObsidianRavager_BG27_017_G ? neighbours : [pickRandom(neighbours)];\r\n\t\ttargets.forEach((target) => {\r\n\t\t\tspectator.registerPowerTarget(attackingEntity, target, defendingBoard);\r\n\t\t\tdealDamageToEnemy(\r\n\t\t\t\ttarget,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tattackingEntity.attack,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t});\r\n\t} else if ([CardIds.BabyKrush_BG22_001, CardIds.BabyKrush_BG22_001_G].includes(attackingEntity.cardId as CardIds)) {\r\n\t\tconst spawns = spawnEntities(\r\n\t\t\tattackingEntity.cardId === CardIds.BabyKrush_BG22_001_G\r\n\t\t\t\t? CardIds.BabyKrush_BG22_001_G\r\n\t\t\t\t: CardIds.BabyKrush_DevilsaurToken,\r\n\t\t\t1,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\ttrue,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t\tif (spawns.length > 0) {\r\n\t\t\tconst sourceIndex = attackingBoard.indexOf(attackingEntity);\r\n\t\t\tconst actualSpawns = performEntitySpawns(\r\n\t\t\t\tspawns,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tsourceIndex,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\tfor (const actualSpawn of actualSpawns) {\r\n\t\t\t\tif (defendingEntity.health > 0 && !defendingEntity.definitelyDead) {\r\n\t\t\t\t\tperformAttack(\r\n\t\t\t\t\t\tactualSpawn,\r\n\t\t\t\t\t\tdefendingEntity,\r\n\t\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// For Prestor\r\n\tconst defenderAliveBeforeAttack = defendingEntity.health > 0 && !defendingEntity.definitelyDead;\r\n\t// Because of Bristleback Knight, which changes its divine shield status during bumpEntities\r\n\tconst attackerHadDivineShield = attackingEntity.divineShield;\r\n\tconst defenderHadDivineShield = defendingEntity.divineShield;\r\n\tif (defenderAliveBeforeAttack) {\r\n\t\tif (!attackingEntity.immuneWhenAttackCharges) {\r\n\t\t\t// TODO: this bumpEntities approach doesn't work well, as it leads to code duplication\r\n\t\t\tbumpEntities(\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t\tbumpEntities(\r\n\t\t\tdefendingEntity,\r\n\t\t\tattackingEntity,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// Do it after the damage has been done, so that entities that update on DS lose / gain (CyborgDrake) don't\r\n\t\t// cause wrong results to happen\r\n\t\t// This whole logic is a MEEEEESSSSSSSSSSSSSSS\r\n\t\tif (defendingEntity.attack > 0 && attackerHadDivineShield && !attackingEntity.immuneWhenAttackCharges) {\r\n\t\t\tupdateDivineShield(attackingEntity, attackingBoard, false, allCards);\r\n\t\t}\r\n\t\tif (attackingEntity.attack > 0 && defenderHadDivineShield) {\r\n\t\t\tupdateDivineShield(defendingEntity, defendingBoard, false, allCards);\r\n\t\t}\r\n\r\n\t\tif (defendingEntity.health <= 0 || defendingEntity.definitelyDead) {\r\n\t\t\tonMinionKill(\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t\tif (attackingEntity.health <= 0 || attackingEntity.definitelyDead) {\r\n\t\t\tonMinionKill(\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\t// Cleave\r\n\tif (attackingEntity.cleave) {\r\n\t\tconst defenderNeighbours: readonly BoardEntity[] = getNeighbours(defendingBoard, defendingEntity);\r\n\t\tfor (const neighbour of defenderNeighbours) {\r\n\t\t\tbumpEntities(\r\n\t\t\t\tneighbour,\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\t// Do it after the damage has been done, so that entities that update on DS lose / gain (CyborgDrake) don't\r\n\t\t\t// cause wrong results to happen\r\n\t\t\tif (attackingEntity.attack > 0 && neighbour.divineShield) {\r\n\t\t\t\tupdateDivineShield(neighbour, defendingBoard, false, allCards);\r\n\t\t\t}\r\n\t\t\tif (neighbour.health <= 0 || neighbour.definitelyDead) {\r\n\t\t\t\tonMinionKill(\r\n\t\t\t\t\tattackingEntity,\r\n\t\t\t\t\tneighbour,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (\r\n\t\t(defendingEntity.health <= 0 || defendingEntity.definitelyDead) &&\r\n\t\t(attackingEntity.cardId === CardIds.WildfireElemental_BGS_126 ||\r\n\t\t\tattackingEntity.cardId === CardIds.WildfireElemental_TB_BaconUps_166)\r\n\t) {\r\n\t\tconst excessDamage = -defendingEntity.health;\r\n\t\tconst neighbours = getNeighbours(defendingBoard, defendingEntity);\r\n\t\t// console.log('neighbours', stringifySimple(neighbours, allCards));\r\n\t\tif (neighbours.length > 0) {\r\n\t\t\tif (attackingEntity.cardId === CardIds.WildfireElemental_BGS_126) {\r\n\t\t\t\tconst randomTarget = neighbours[Math.floor(Math.random() * neighbours.length)];\r\n\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\trandomTarget,\r\n\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\tdefendingEntity.lastAffectedByEntity,\r\n\t\t\t\t\texcessDamage,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tcardsData,\r\n\t\t\t\t\tsharedState,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t);\r\n\t\t\t} else {\r\n\t\t\t\tneighbours.forEach((neighbour) =>\r\n\t\t\t\t\tdealDamageToEnemy(\r\n\t\t\t\t\t\tneighbour,\r\n\t\t\t\t\t\tdefendingBoard,\r\n\t\t\t\t\t\tdefendingBoardHero,\r\n\t\t\t\t\t\tdefendingEntity.lastAffectedByEntity,\r\n\t\t\t\t\t\texcessDamage,\r\n\t\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\t\tattackingBoardHero,\r\n\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\tcardsData,\r\n\t\t\t\t\t\tsharedState,\r\n\t\t\t\t\t\tspectator,\r\n\t\t\t\t\t),\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// After attack hooks\r\n\t// Arcane Cannon\r\n\t// Monstrous Macaw\r\n\tif (attackingEntity.cardId === CardIds.MonstrousMacaw_BGS_078) {\r\n\t\ttriggerRandomDeathrattle(\r\n\t\t\tattackingEntity,\r\n\t\t\tattackingBoard,\r\n\t\t\tattackingBoardHero,\r\n\t\t\tdefendingBoard,\r\n\t\t\tdefendingBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t} else if (attackingEntity.cardId === CardIds.MonstrousMacaw_TB_BaconUps_135) {\r\n\t\tfor (let i = 0; i < 2; i++) {\r\n\t\t\ttriggerRandomDeathrattle(\r\n\t\t\t\tattackingEntity,\r\n\t\t\t\tattackingBoard,\r\n\t\t\t\tattackingBoardHero,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t\ttrue,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\tattackingEntity.attackImmediately = false;\r\n\tif (attackingEntity.enchantments.some((e) => e.cardId === CardIds.VolatileVenom_VolatileEnchantment)) {\r\n\t\tattackingEntity.definitelyDead = true;\r\n\t}\r\n\tprocessMinionDeath(\r\n\t\tattackingBoard,\r\n\t\tattackingBoardHero,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\tattackingEntity.immuneWhenAttackCharges = Math.max(0, attackingEntity.immuneWhenAttackCharges - 1);\r\n};\r\n\r\nconst triggerRandomDeathrattle = (\r\n\tsourceEntity: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tattackingBoardHero: BgsPlayerEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspawns: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n\texcludeSource = false,\r\n): void => {\r\n\tconst validDeathrattles = attackingBoard\r\n\t\t.filter((entity) => !excludeSource || entity.entityId !== sourceEntity.entityId)\r\n\t\t.filter((entity) => {\r\n\t\t\tif (hasMechanic(allCards.getCard(entity.cardId), 'DEATHRATTLE')) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\tif (entity.rememberedDeathrattles?.length) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\tif (\r\n\t\t\t\tentity.enchantments &&\r\n\t\t\t\tentity.enchantments\r\n\t\t\t\t\t.map((enchantment) => enchantment.cardId)\r\n\t\t\t\t\t.some((enchantmentId) => validEnchantments.includes(enchantmentId as CardIds))\r\n\t\t\t) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\treturn false;\r\n\t\t});\r\n\tif (validDeathrattles.length === 0) {\r\n\t\treturn;\r\n\t}\r\n\tconst targetEntity = pickRandom(validDeathrattles);\r\n\tif (!targetEntity?.cardId) {\r\n\t\tconsole.error(\r\n\t\t\t'missing card id when triggering random deathrattle',\r\n\t\t\tstringifySimpleCard(targetEntity, allCards),\r\n\t\t\ttargetEntity,\r\n\t\t\tvalidDeathrattles.length,\r\n\t\t\tstringifySimple(validDeathrattles, allCards),\r\n\t\t\tstringifySimple(attackingBoard, allCards),\r\n\t\t\texcludeSource,\r\n\t\t\tstringifySimpleCard(sourceEntity, allCards),\r\n\t\t);\r\n\t}\r\n\tspectator.registerPowerTarget(sourceEntity, targetEntity, attackingBoard);\r\n\tconst indexFromRight = attackingBoard.length - (attackingBoard.indexOf(targetEntity) + 1);\r\n\tbuildBoardAfterDeathrattleSpawns(\r\n\t\tattackingBoard,\r\n\t\tattackingBoardHero,\r\n\t\ttargetEntity,\r\n\t\tindexFromRight,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\t[],\r\n\t\tallCards,\r\n\t\tspawns,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\t// The reborn minion spawns to the right of the DR spawns\r\n\t// buildBoardAfterRebornSpawns(\r\n\t// \tattackingBoard,\r\n\t// \tattackingBoardHero,\r\n\t// \ttargetEntity,\r\n\t// \tindexFromRight,\r\n\t// \tdefendingBoard,\r\n\t// \tdefendingBoardHero,\r\n\t// \tallCards,\r\n\t// \tspawns,\r\n\t// \tsharedState,\r\n\t// \tspectator,\r\n\t// );\r\n};\r\n\r\nconst getAttackingEntity = (attackingBoard: BoardEntity[], lastAttackerIndex: number): BoardEntity => {\r\n\tlet validAttackers = attackingBoard.filter((entity) => canAttack(entity));\r\n\tif (validAttackers.length === 0) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tif (validAttackers.some((entity) => entity.attackImmediately)) {\r\n\t\tvalidAttackers = validAttackers.filter((entity) => entity.attackImmediately);\r\n\t}\r\n\r\n\t// Once an entity has attacked, no entity to the left of it can attack until all entities\r\n\t// on the board have attacked\r\n\t// Once the last attacker index is the last entity on the board, we cycle back to the start\r\n\tif (lastAttackerIndex != null && lastAttackerIndex < validAttackers.length - 1) {\r\n\t\t// This doesn't work if any entity that appears before the attacked index died in-between\r\n\t\tconst candidates = validAttackers.slice(lastAttackerIndex);\r\n\t\tif (candidates.length > 0) {\r\n\t\t\tvalidAttackers = candidates;\r\n\t\t}\r\n\t}\r\n\r\n\tlet attackingEntity = validAttackers[0];\r\n\tlet minNumberOfAttacks: number = attackingEntity.attacksPerformed || 0;\r\n\tfor (const entity of validAttackers) {\r\n\t\tif ((entity.attacksPerformed || 0) < minNumberOfAttacks) {\r\n\t\t\tattackingEntity = entity;\r\n\t\t\tminNumberOfAttacks = entity.attacksPerformed;\r\n\t\t}\r\n\t}\r\n\r\n\tif (!attackingEntity.attackImmediately) {\r\n\t\tattackingEntity.attacksPerformed = (attackingEntity.attacksPerformed || 0) + 1;\r\n\t}\r\n\treturn attackingEntity;\r\n};\r\n\r\nexport const findNearestEnemies = (\r\n\tattackingBoard: BoardEntity[],\r\n\tentity: BoardEntity,\r\n\tentityIndexFromRight: number,\r\n\tdefendingBoard: BoardEntity[],\r\n\tnumberOfTargets: number,\r\n\tallCards: AllCardsService,\r\n): BoardEntity[] => {\r\n\tconst result = [];\r\n\tif (defendingBoard.length > 0) {\r\n\t\t// console.debug('defending board', numberOfTargets, stringifySimple(defendingBoard, allCards));\r\n\t\tconst attackerIndex = attackingBoard.length - entityIndexFromRight - 1;\r\n\t\tconst targetIndex = attackerIndex - (attackingBoard.length - defendingBoard.length) / 2;\r\n\t\t// console.debug('indexes', attackerIndex, entityIndexFromRight, targetIndex, attackingBoard.length);\r\n\r\n\t\tfor (let i = 0; i < numberOfTargets; i++) {\r\n\t\t\tconst possibleTargets = defendingBoard\r\n\t\t\t\t.filter((e) => !e.definitelyDead && e.health > 0)\r\n\t\t\t\t.filter((e) => !result.includes(e));\r\n\t\t\t// console.debug('possibleTargets', stringifySimple(possibleTargets, allCards));\r\n\t\t\tif (!possibleTargets.length) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tconst targetGroups = groupByFunction((e: BoardEntity) => Math.abs(defendingBoard.indexOf(e) - targetIndex))(\r\n\t\t\t\tpossibleTargets,\r\n\t\t\t);\r\n\t\t\tconst distances = Object.keys(targetGroups)\r\n\t\t\t\t.map((k) => +k)\r\n\t\t\t\t.sort();\r\n\t\t\tconst nearestDistance = distances[0];\r\n\t\t\tif (nearestDistance != null) {\r\n\t\t\t\t// console.debug(\r\n\t\t\t\t// \t'targetGroups[nearestDistance]',\r\n\t\t\t\t// \tnearestDistance,\r\n\t\t\t\t// \tstringifySimple(targetGroups[nearestDistance], allCards),\r\n\t\t\t\t// );\r\n\t\t\t\tconst target = pickRandom(targetGroups[nearestDistance]);\r\n\t\t\t\tresult.push(target);\r\n\t\t\t}\r\n\t\t\t// console.debug('\\n');\r\n\t\t}\r\n\t}\r\n\treturn result.filter((e) => !!e);\r\n};\r\n\r\nexport const getNeighbours = (\r\n\tboard: BoardEntity[],\r\n\tentity: BoardEntity,\r\n\tdeadEntityIndexFromRight?: number,\r\n): readonly BoardEntity[] => {\r\n\tconst neighbours = [];\r\n\tif (deadEntityIndexFromRight != null) {\r\n\t\t// If the deadEntityIndexFromRight === 0 (right-most minion), no neighbour will be found\r\n\t\tconst rightNeighbourIndex = board.length - 1 - (deadEntityIndexFromRight - 1);\r\n\t\tconst rightNeighbour = board[rightNeighbourIndex];\r\n\t\tif (rightNeighbour) {\r\n\t\t\tneighbours.push(rightNeighbour);\r\n\t\t}\r\n\r\n\t\tconst leftNeighbourIndex = board.length - 1 - deadEntityIndexFromRight;\r\n\t\tconst leftNeighbour = board[leftNeighbourIndex];\r\n\t\tif (leftNeighbour) {\r\n\t\t\tneighbours.push(leftNeighbour);\r\n\t\t}\r\n\t} else {\r\n\t\tconst index = board.map((e) => e.entityId).indexOf(entity.entityId);\r\n\t\tif (index - 1 >= 0) {\r\n\t\t\tneighbours.push(board[index - 1]);\r\n\t\t}\r\n\t\t// neighbours.push(entity);\r\n\t\tif (index + 1 < board.length) {\r\n\t\t\tneighbours.push(board[index + 1]);\r\n\t\t}\r\n\t}\r\n\treturn neighbours;\r\n};\r\n\r\nexport const dealDamageToRandomEnemy = (\r\n\tboardToBeDamaged: BoardEntity[],\r\n\tboardToBeDamagedHero: BgsPlayerEntity,\r\n\tdamageSource: BoardEntity,\r\n\tdamage: number,\r\n\tboardWithAttackOrigin: BoardEntity[],\r\n\tboardWithAttackOriginHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (boardToBeDamaged.length === 0) {\r\n\t\treturn;\r\n\t}\r\n\tconst validTargets = boardToBeDamaged.filter((e) => e.health > 0 && !e.definitelyDead);\r\n\tconst defendingEntity: BoardEntity = pickRandom(validTargets);\r\n\tif (defendingEntity) {\r\n\t\tspectator.registerPowerTarget(damageSource, defendingEntity, boardToBeDamaged);\r\n\t\tdealDamageToEnemy(\r\n\t\t\tdefendingEntity,\r\n\t\t\tboardToBeDamaged,\r\n\t\t\tboardToBeDamagedHero,\r\n\t\t\tdamageSource,\r\n\t\t\tdamage,\r\n\t\t\tboardWithAttackOrigin,\r\n\t\t\tboardWithAttackOriginHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n};\r\n\r\nexport const dealDamageToEnemy = (\r\n\tdefendingEntity: BoardEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tdefendingBoardHero: BgsPlayerEntity,\r\n\tdamageSource: BoardEntity,\r\n\tdamage: number,\r\n\tboardWithAttackOrigin: BoardEntity[],\r\n\tboardWithAttackOriginHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// console.log('dealing damage to', damage, stringifySimpleCard(defendingEntity, allCards));\r\n\tif (!defendingEntity) {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tconst isDeadBeforeDamage = defendingEntity.definitelyDead || defendingEntity.health <= 0;\r\n\t// Why do we use a fakeAttacker? Is that for the \"attacking\" prop?\r\n\t// That prop is only used for Overkill, and even in that case it looks like it would work\r\n\t// without it\r\n\tconst fakeAttacker = {\r\n\t\t...(damageSource || {}),\r\n\t\tentityId: -1,\r\n\t\tattack: damage,\r\n\t\tattacking: true,\r\n\t} as BoardEntity;\r\n\tconst actualDamageDone = bumpEntities(\r\n\t\tdefendingEntity,\r\n\t\tfakeAttacker,\r\n\t\tdefendingBoard,\r\n\t\tdefendingBoardHero,\r\n\t\tboardWithAttackOrigin,\r\n\t\tboardWithAttackOriginHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\t// Do it after the damage has been done, so that entities that update on DS lose / gain (CyborgDrake) don't\r\n\t// cause wrong results to happen\r\n\tif (fakeAttacker.attack > 0 && defendingEntity.divineShield) {\r\n\t\tupdateDivineShield(defendingEntity, defendingBoard, false, allCards);\r\n\t}\r\n\tif (!isDeadBeforeDamage && actualDamageDone > 0) {\r\n\t\tdefendingEntity.lastAffectedByEntity = damageSource;\r\n\r\n\t\tif (defendingEntity.health <= 0 || defendingEntity.definitelyDead) {\r\n\t\t\tonMinionKill(\r\n\t\t\t\tdamageSource,\r\n\t\t\t\tdefendingEntity,\r\n\t\t\t\tboardWithAttackOrigin,\r\n\t\t\t\tboardWithAttackOriginHero,\r\n\t\t\t\tdefendingBoard,\r\n\t\t\t\tdefendingBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\tconst defendingEntityIndex = defendingBoard.map((entity) => entity.entityId).indexOf(defendingEntity.entityId);\r\n\tdefendingBoard[defendingEntityIndex] = defendingEntity;\r\n\treturn actualDamageDone;\r\n};\r\n\r\nexport const getDefendingEntity = (\r\n\tdefendingBoard: BoardEntity[],\r\n\tattackingEntity: BoardEntity,\r\n\tignoreTaunts = false,\r\n): BoardEntity => {\r\n\tlet possibleDefenders: readonly BoardEntity[];\r\n\tif (\r\n\t\tattackingEntity.cardId === CardIds.ZappSlywick_BGS_022 ||\r\n\t\tattackingEntity.cardId === CardIds.ZappSlywick_TB_BaconUps_091\r\n\t) {\r\n\t\tconst minAttack = Math.min(...defendingBoard.map((entity) => entity.attack));\r\n\t\tpossibleDefenders = defendingBoard.filter((entity) => entity.attack === minAttack);\r\n\t} else {\r\n\t\tpossibleDefenders = defendingBoard.filter((e) => !e.stealth);\r\n\t\tif (!ignoreTaunts) {\r\n\t\t\tconst taunts = possibleDefenders.filter((entity) => entity.taunt);\r\n\t\t\tpossibleDefenders = taunts.length > 0 ? taunts : possibleDefenders;\r\n\t\t}\r\n\t}\r\n\tlet chosenDefender = possibleDefenders[Math.floor(Math.random() * possibleDefenders.length)];\r\n\tif (chosenDefender?.taunt) {\r\n\t\tconst elistras = defendingBoard.filter(\r\n\t\t\t(entity) =>\r\n\t\t\t\tentity.cardId === CardIds.ElistraTheImmortal_BGS_205 ||\r\n\t\t\t\tentity.cardId === CardIds.ElistraTheImmortal_TB_BaconUps_306,\r\n\t\t);\r\n\t\tif (elistras.length > 0) {\r\n\t\t\tchosenDefender = elistras[Math.floor(Math.random() * elistras.length)];\r\n\t\t}\r\n\t}\r\n\treturn chosenDefender;\r\n};\r\n\r\nexport const bumpEntities = (\r\n\tentity: BoardEntity,\r\n\tbumpInto: BoardEntity,\r\n\tentityBoard: BoardEntity[],\r\n\tentityBoardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): number => {\r\n\t// No attack has no impact\r\n\tif (bumpInto.attack === 0) {\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tif (entity.divineShield) {\r\n\t\t// Handle all the divine shield loss effects here\r\n\t\tfor (let i = 0; i < entityBoard.length; i++) {\r\n\t\t\tif (entityBoard[i].cardId === CardIds.BolvarFireblood_ICC_858) {\r\n\t\t\t\tmodifyAttack(entityBoard[i], 2, entityBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(entityBoard[i], entityBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(entityBoard[i], entityBoard[i], entityBoard);\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.BolvarFireblood_TB_BaconUps_047) {\r\n\t\t\t\tmodifyAttack(entityBoard[i], 4, entityBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(entityBoard[i], entityBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(entityBoard[i], entityBoard[i], entityBoard);\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.DrakonidEnforcer_BGS_067) {\r\n\t\t\t\tmodifyAttack(entityBoard[i], 2, entityBoard, allCards);\r\n\t\t\t\tmodifyHealth(entityBoard[i], 2, entityBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(entityBoard[i], entityBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(entityBoard[i], entityBoard[i], entityBoard);\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.DrakonidEnforcer_TB_BaconUps_117) {\r\n\t\t\t\tmodifyAttack(entityBoard[i], 4, entityBoard, allCards);\r\n\t\t\t\tmodifyHealth(entityBoard[i], 4, entityBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(entityBoard[i], entityBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(entityBoard[i], entityBoard[i], entityBoard);\r\n\t\t\t} else if (\r\n\t\t\t\tentityBoard[i].entityId !== entity.entityId &&\r\n\t\t\t\t(entityBoard[i].cardId === CardIds.HolyMecherel_BG20_401 ||\r\n\t\t\t\t\tentityBoard[i].cardId === CardIds.HolyMecherel_BG20_401_G)\r\n\t\t\t) {\r\n\t\t\t\tupdateDivineShield(entityBoard[i], entityBoard, true, allCards);\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.Gemsplitter_BG21_037) {\r\n\t\t\t\taddCardsInHand(entityBoardHero, entityBoard, allCards, spectator, [CardIds.BloodGem]);\r\n\t\t\t} else if (entityBoard[i].cardId === CardIds.Gemsplitter_BG21_037_G) {\r\n\t\t\t\taddCardsInHand(entityBoardHero, entityBoard, allCards, spectator, [CardIds.BloodGem, CardIds.BloodGem]);\r\n\t\t\t} else if (\r\n\t\t\t\tentityBoard[i].cardId === CardIds.CogworkCopter_BG24_008 ||\r\n\t\t\t\tentityBoard[i].cardId === CardIds.CogworkCopter_BG24_008_G\r\n\t\t\t) {\r\n\t\t\t\tconst buff = entityBoard[i].cardId === CardIds.CogworkCopter_BG24_008_G ? 2 : 1;\r\n\t\t\t\tgrantRandomStats(entityBoard[i], entityBoardHero.hand, buff, buff, null, true, allCards, null);\r\n\t\t\t}\r\n\r\n\t\t\t// So that self-buffs from Bolvar are taken into account\r\n\t\t\t// if (entityBoard[i].entityId === entity.entityId && entity.divineShield) {\r\n\t\t\t// \tupdateDivineShield(entityBoard[i], entityBoard, false, allCards);\r\n\t\t\t// }\r\n\t\t}\r\n\t\tconst greaseBots = entityBoard.filter((entity) => entity.cardId === CardIds.GreaseBot_BG21_024);\r\n\t\tconst greaseBotBattlegrounds = entityBoard.filter((entity) => entity.cardId === CardIds.GreaseBot_BG21_024_G);\r\n\t\tgreaseBots.forEach((bot) => {\r\n\t\t\tmodifyAttack(entity, 2, entityBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 2, entityBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(bot, entity, entityBoard);\r\n\t\t});\r\n\t\tgreaseBotBattlegrounds.forEach((bot) => {\r\n\t\t\tmodifyAttack(entity, 4, entityBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 4, entityBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(bot, entity, entityBoard);\r\n\t\t});\r\n\r\n\t\tspectator.registerDamageDealt(bumpInto, entity, 0, entityBoard);\r\n\t\treturn 0;\r\n\t\t// return entity;\r\n\t}\r\n\tentity.health = entity.health - (entity.damageMultiplier || 1) * bumpInto.attack;\r\n\r\n\tif (entity.cardId === CardIds.Bubblette_BG_TID_713 && bumpInto.attack === 1) {\r\n\t\tentity.definitelyDead = true;\r\n\t} else if (entity.cardId === CardIds.Bubblette_BG_TID_713_G && bumpInto.attack === 2) {\r\n\t\tentity.definitelyDead = true;\r\n\t}\r\n\r\n\t// Do it last, so that other effects are still processed\r\n\tif (bumpInto.poisonous) {\r\n\t\t// So that further buffs don't revive it\r\n\t\t// And we don't just set the health to avoid applying overkill effects\r\n\t\tentity.definitelyDead = true;\r\n\t}\r\n\tif (bumpInto.venomous) {\r\n\t\t// So that further buffs don't revive it\r\n\t\t// And we don't just set the health to avoid applying overkill effects\r\n\t\tentity.definitelyDead = true;\r\n\t\tbumpInto.venomous = false;\r\n\t}\r\n\t// FIXME: This will likely be incorrect in terms of timings, e.g. if the entity ends up\r\n\t// surviving following a buff like Spawn.\r\n\tspectator.registerDamageDealt(bumpInto, entity, (entity.damageMultiplier || 1) * bumpInto.attack, entityBoard);\r\n\tentity.lastAffectedByEntity = bumpInto;\r\n\tif (entity.frenzyChargesLeft > 0 && entity.health > 0 && !entity.definitelyDead) {\r\n\t\tapplyFrenzy(entity, entityBoard, entityBoardHero, allCards, cardsData, sharedState, spectator);\r\n\t\tentity.frenzyChargesLeft--;\r\n\t}\r\n\r\n\t// We spawn them here, because it says \"whenever\", and so happens right away\r\n\t// FIXME: there could be a bug here, if a Cleave attacks several IGB at the same time. The current\r\n\t// implementation could spawn minions above the max board size. Fringe case though, so leaving it\r\n\t// like this for now\r\n\tconst entitySpawns = getWheneverEntitySpawns(\r\n\t\tentity,\r\n\t\tentityBoard,\r\n\t\tentityBoardHero,\r\n\t\totherBoard,\r\n\t\totherHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\tif (!!entitySpawns?.length) {\r\n\t\tconst index = entityBoard.map((e) => e.entityId).indexOf(entity.entityId);\r\n\t\taddMinionsToBoard(\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherHero,\r\n\t\t\tindex,\r\n\t\t\tentitySpawns,\r\n\t\t\tallCards,\r\n\t\t\tspectator,\r\n\t\t\tsharedState,\r\n\t\t);\r\n\t\tspectator.registerMinionsSpawn(entity, entityBoard, entitySpawns);\r\n\t}\r\n\treturn bumpInto.attack;\r\n};\r\n\r\nconst getWheneverEntitySpawns = (\r\n\tentity: BoardEntity,\r\n\tentityBoard: BoardEntity[],\r\n\tentityBoardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): readonly BoardEntity[] => {\r\n\tif (entityBoard.length === 7) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\tif (entity.cardId === CardIds.ImpGangBoss_BRM_006) {\r\n\t\treturn spawnEntities(\r\n\t\t\tCardIds.ImpGangBoss_ImpToken_BRM_006t,\r\n\t\t\t1,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t} else if (entity.cardId === CardIds.ImpGangBoss_TB_BaconUps_030) {\r\n\t\treturn spawnEntities(\r\n\t\t\tCardIds.ImpGangBoss_ImpToken_TB_BaconUps_030t,\r\n\t\t\t1,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t} else if (entity.cardId === CardIds.ImpMama_BGS_044) {\r\n\t\treturn spawnEntities(\r\n\t\t\tcardsData.impMamaSpawns[Math.floor(Math.random() * cardsData.impMamaSpawns.length)],\r\n\t\t\t1,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t).map((entity) => ({ ...entity, taunt: true }));\r\n\t} else if (entity.cardId === CardIds.ImpMama_TB_BaconUps_116) {\r\n\t\treturn spawnEntities(\r\n\t\t\tcardsData.impMamaSpawns[Math.floor(Math.random() * cardsData.impMamaSpawns.length)],\r\n\t\t\t2,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t).map((entity) => ({ ...entity, taunt: true }));\r\n\t} else if (entity.cardId === CardIds.SecurityRover_BOT_218) {\r\n\t\treturn spawnEntities(\r\n\t\t\tCardIds.SecurityRover_GuardBotToken_BOT_218t,\r\n\t\t\t1,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t} else if (entity.cardId === CardIds.SecurityRover_TB_BaconUps_041) {\r\n\t\treturn spawnEntities(\r\n\t\t\tCardIds.SecurityRover_GuardBotToken_TB_BaconUps_041t,\r\n\t\t\t1,\r\n\t\t\tentityBoard,\r\n\t\t\tentityBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t\tentity.friendly,\r\n\t\t\ttrue,\r\n\t\t);\r\n\t}\r\n\treturn null;\r\n};\r\n\r\nexport const processMinionDeath = (\r\n\tboard1: BoardEntity[],\r\n\tboard1Hero: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tboard2Hero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// console.debug('processing minions death', stringifySimple(board1, allCards), stringifySimple(board2, allCards));\r\n\tconst [deadMinionIndexesFromRights1, deadEntities1] = makeMinionsDie(board1, board1Hero, allCards, spectator);\r\n\tconst [deadMinionIndexesFromRights2, deadEntities2] = makeMinionsDie(board2, board2Hero, allCards, spectator);\r\n\tspectator.registerDeadEntities(\r\n\t\tdeadMinionIndexesFromRights1,\r\n\t\tdeadEntities1,\r\n\t\tboard1,\r\n\t\tdeadMinionIndexesFromRights2,\r\n\t\tdeadEntities2,\r\n\t\tboard2,\r\n\t);\r\n\t// No death to process, we can return\r\n\tif (deadEntities1.length === 0 && deadEntities2.length === 0) {\r\n\t\treturn;\r\n\t\t// return [board1, board2];\r\n\t}\r\n\r\n\tsharedState.deaths.push(\r\n\t\t...deadEntities1.map((e) =>\r\n\t\t\taddImpliedMechanics({ ...e, health: e.maxHealth, definitelyDead: false }, cardsData),\r\n\t\t),\r\n\t);\r\n\tsharedState.deaths.push(\r\n\t\t...deadEntities2.map((e) =>\r\n\t\t\taddImpliedMechanics({ ...e, health: e.maxHealth, definitelyDead: false }, cardsData),\r\n\t\t),\r\n\t);\r\n\tboard1Hero.globalInfo.EternalKnightsDeadThisGame =\r\n\t\tboard1Hero.globalInfo.EternalKnightsDeadThisGame +\r\n\t\tdeadEntities1.filter(\r\n\t\t\t(e) => e.cardId === CardIds.EternalKnight_BG25_008 || e.cardId === CardIds.EternalKnight_BG25_008_G,\r\n\t\t).length;\r\n\tboard2Hero.globalInfo.EternalKnightsDeadThisGame =\r\n\t\tboard2Hero.globalInfo.EternalKnightsDeadThisGame +\r\n\t\tdeadEntities2.filter(\r\n\t\t\t(e) => e.cardId === CardIds.EternalKnight_BG25_008 || e.cardId === CardIds.EternalKnight_BG25_008_G,\r\n\t\t).length;\r\n\r\n\t// First process all DRs, then process the reborn\r\n\tif (Math.random() > 0.5) {\r\n\t\t// Now proceed to trigger all deathrattle effects on baord1\r\n\t\thandleDeathrattlesForFirstBoard(\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdeadMinionIndexesFromRights1,\r\n\t\t\tdeadEntities1,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// Now handle the other board's deathrattles\r\n\t\thandleDeathrattlesForFirstBoard(\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdeadMinionIndexesFromRights2,\r\n\t\t\tdeadEntities2,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else {\r\n\t\thandleDeathrattlesForFirstBoard(\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdeadMinionIndexesFromRights2,\r\n\t\t\tdeadEntities2,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\thandleDeathrattlesForFirstBoard(\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdeadMinionIndexesFromRights1,\r\n\t\t\tdeadEntities1,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\r\n\t// Now the reborn\r\n\tif (Math.random() > 0.5) {\r\n\t\t// Now proceed to trigger all deathrattle effects on baord1\r\n\t\thandleRebornForFirstBoard(\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdeadMinionIndexesFromRights1,\r\n\t\t\tdeadEntities1,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\t// Now handle the other board's deathrattles\r\n\t\thandleRebornForFirstBoard(\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdeadMinionIndexesFromRights2,\r\n\t\t\tdeadEntities2,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else {\r\n\t\thandleRebornForFirstBoard(\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdeadMinionIndexesFromRights2,\r\n\t\t\tdeadEntities2,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\thandleRebornForFirstBoard(\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdeadMinionIndexesFromRights1,\r\n\t\t\tdeadEntities1,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\r\n\tif (Math.random() > 0.5) {\r\n\t\thandleAfterDeathEffectsForFirstBoard(\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdeadMinionIndexesFromRights2,\r\n\t\t\tdeadEntities2,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\thandleAfterDeathEffectsForFirstBoard(\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdeadMinionIndexesFromRights1,\r\n\t\t\tdeadEntities1,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t} else {\r\n\t\thandleAfterDeathEffectsForFirstBoard(\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tdeadMinionIndexesFromRights1,\r\n\t\t\tdeadEntities1,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t\thandleAfterDeathEffectsForFirstBoard(\r\n\t\t\tboard2,\r\n\t\t\tboard2Hero,\r\n\t\t\tboard1,\r\n\t\t\tboard1Hero,\r\n\t\t\tdeadMinionIndexesFromRights2,\r\n\t\t\tdeadEntities2,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\r\n\t// If the fish dies (from Scallywag for instance), it doesn't remember the deathrattle\r\n\tboard1\r\n\t\t.filter((entity) => isFish(entity))\r\n\t\t.forEach((entity) => rememberDeathrattles(entity, deadEntities1, cardsData, allCards, sharedState));\r\n\tboard2\r\n\t\t.filter((entity) => isFish(entity))\r\n\t\t.forEach((entity) => rememberDeathrattles(entity, deadEntities2, cardsData, allCards, sharedState));\r\n\r\n\tboard1\r\n\t\t.filter(\r\n\t\t\t(entity) =>\r\n\t\t\t\tentity.cardId === CardIds.Monstrosity_BG20_HERO_282_Buddy ||\r\n\t\t\t\tentity.cardId === CardIds.Monstrosity_BG20_HERO_282_Buddy_G,\r\n\t\t)\r\n\t\t.forEach((entity) => applyMonstrosity(entity, deadEntities1, board1, allCards));\r\n\tboard2\r\n\t\t.filter(\r\n\t\t\t(entity) =>\r\n\t\t\t\tentity.cardId === CardIds.Monstrosity_BG20_HERO_282_Buddy ||\r\n\t\t\t\tentity.cardId === CardIds.Monstrosity_BG20_HERO_282_Buddy_G,\r\n\t\t)\r\n\t\t.forEach((entity) => applyMonstrosity(entity, deadEntities2, board2, allCards));\r\n\r\n\t// Make sure we only return when there are no more deaths to process\r\n\t// Make sure to do this right before the end of the process\r\n\t// FIXME: this will propagate the killer between rounds, which is incorrect. For instance,\r\n\t// if a dragon kills a Ghoul, then the Ghoul's deathrattle kills a Kaboom, the killer should\r\n\t// now be the ghoul. Then if the Kaboom kills someone, the killer should again change. You could\r\n\t// also have multiple killers, which is not taken into account here.\r\n\t// The current assumption is that it's a suffienctly fringe case to not matter too much\r\n\tprocessMinionDeath(board1, board1Hero, board2, board2Hero, allCards, cardsData, sharedState, spectator);\r\n\r\n\t// Apply \"after minion death\" effects\r\n\thandleAfterMinionsDeaths(\r\n\t\tboard1,\r\n\t\tdeadEntities1,\r\n\t\tboard1Hero,\r\n\t\tboard2,\r\n\t\tdeadEntities2,\r\n\t\tboard2Hero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n};\r\n\r\nconst handleAfterMinionsDeaths = (\r\n\tboard1: BoardEntity[],\r\n\tdeadEntities1: BoardEntity[],\r\n\theroEntity1: BgsPlayerEntity,\r\n\tboard2: BoardEntity[],\r\n\tdeadEntities2: BoardEntity[],\r\n\theroEntity2: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n) => {\r\n\tconst random = Math.random() > 0.5;\r\n\thandleAfterMinionsDeathsForBoard(\r\n\t\trandom ? board1 : board2,\r\n\t\trandom ? deadEntities1 : deadEntities2,\r\n\t\trandom ? heroEntity1 : heroEntity2,\r\n\t\trandom ? board2 : board1,\r\n\t\trandom ? deadEntities2 : deadEntities1,\r\n\t\trandom ? heroEntity2 : heroEntity1,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\thandleAfterMinionsDeathsForBoard(\r\n\t\t!random ? board1 : board2,\r\n\t\t!random ? deadEntities1 : deadEntities2,\r\n\t\t!random ? heroEntity1 : heroEntity2,\r\n\t\t!random ? board2 : board1,\r\n\t\t!random ? deadEntities2 : deadEntities1,\r\n\t\t!random ? heroEntity2 : heroEntity1,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n};\r\n\r\nconst handleAfterMinionsDeathsForBoard = (\r\n\tfriendlyBoard: BoardEntity[],\r\n\tfriendlyDeadEntities: BoardEntity[],\r\n\tfriendlyHeroEntity: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherDeadEntities: BoardEntity[],\r\n\totherHeroEntity: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n) => {\r\n\tfor (const deadEntity of friendlyDeadEntities) {\r\n\t\tconst killer = deadEntity.lastAffectedByEntity;\r\n\t\tif (!killer) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\t\t// Killed an enemy minion\r\n\t\tif (killer.friendly !== deadEntity.friendly) {\r\n\t\t\tif (otherHeroEntity.heroPowerId === CardIds.Rokara_GloryOfCombat) {\r\n\t\t\t\tmodifyAttack(killer, 1, otherBoard, allCards);\r\n\t\t\t\tafterStatsUpdate(killer, otherBoard, allCards);\r\n\t\t\t\t// Icesnarl the Mighty\r\n\t\t\t\totherBoard\r\n\t\t\t\t\t.filter(\r\n\t\t\t\t\t\t(e) =>\r\n\t\t\t\t\t\t\te.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy ||\r\n\t\t\t\t\t\t\te.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy_G,\r\n\t\t\t\t\t)\r\n\t\t\t\t\t.forEach((icesnarl) => {\r\n\t\t\t\t\t\tmodifyHealth(\r\n\t\t\t\t\t\t\ticesnarl,\r\n\t\t\t\t\t\t\ticesnarl.cardId === CardIds.IcesnarlTheMighty_BG20_HERO_100_Buddy_G ? 2 : 1,\r\n\t\t\t\t\t\t\tfriendlyBoard,\r\n\t\t\t\t\t\t\tallCards,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tafterStatsUpdate(icesnarl, friendlyBoard, allCards);\r\n\t\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst handleDeathrattlesForFirstBoard = (\r\n\tfirstBoard: BoardEntity[],\r\n\tfirstBoardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tdeadMinionIndexesFromRight: readonly number[],\r\n\tdeadEntities: readonly BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tfor (let i = 0; i < deadMinionIndexesFromRight.length; i++) {\r\n\t\tconst entity = deadEntities[i];\r\n\t\tconst indexFromRight = deadMinionIndexesFromRight[i];\r\n\t\tif (entity.health <= 0 || entity.definitelyDead) {\r\n\t\t\tbuildBoardAfterDeathrattleSpawns(\r\n\t\t\t\tfirstBoard,\r\n\t\t\t\tfirstBoardHero,\r\n\t\t\t\tentity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tdeadEntities,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t} else if (firstBoard.length > 0) {\r\n\t\t\t// const newBoardD = [...firstBoard];\r\n\t\t\tfirstBoard.splice(firstBoard.length - indexFromRight, 1, entity);\r\n\t\t\t// firstBoard = newBoardD;\r\n\t\t}\r\n\t}\r\n\t// return [firstBoard, otherBoard];\r\n};\r\n\r\nconst handleRebornForFirstBoard = (\r\n\tfirstBoard: BoardEntity[],\r\n\tfirstBoardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tdeadMinionIndexesFromRight: readonly number[],\r\n\tdeadEntities: readonly BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// console.log('will handle reborn', stringifySimple(firstBoard, allCards), deadMinionIndexesFromRight);\r\n\tfor (let i = deadMinionIndexesFromRight.length - 1; i >= 0; i--) {\r\n\t\tconst entity = deadEntities[i];\r\n\t\tconst indexFromRight = deadMinionIndexesFromRight[i];\r\n\t\tif (entity.health <= 0 || entity.definitelyDead) {\r\n\t\t\tif (!entity?.cardId) {\r\n\t\t\t\tconsole.error(\r\n\t\t\t\t\t'missing card id for entity that died',\r\n\t\t\t\t\tstringifySimpleCard(entity, allCards),\r\n\t\t\t\t\tentity,\r\n\t\t\t\t\tindexFromRight,\r\n\t\t\t\t\tdeadMinionIndexesFromRight,\r\n\t\t\t\t\tstringifySimple(firstBoard, allCards),\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t\t// console.log('dead entity', stringifySimpleCard(entity, allCards), indexFromRight);\r\n\t\t\tbuildBoardAfterRebornSpawns(\r\n\t\t\t\tfirstBoard,\r\n\t\t\t\tfirstBoardHero,\r\n\t\t\t\tentity,\r\n\t\t\t\tindexFromRight,\r\n\t\t\t\totherBoard,\r\n\t\t\t\totherBoardHero,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t\t// console.log('after rebord', stringifySimple(firstBoard, allCards));\r\n\t\t} else if (firstBoard.length > 0) {\r\n\t\t\t// const newBoardD = [...firstBoard];\r\n\t\t\tfirstBoard.splice(firstBoard.length - indexFromRight, 1, entity);\r\n\t\t\t// firstBoard = newBoardD;\r\n\t\t}\r\n\t}\r\n\t// return [firstBoard, otherBoard];\r\n};\r\n\r\nconst handleAfterDeathEffectsForFirstBoard = (\r\n\tfirstBoard: BoardEntity[],\r\n\tfirstBoardHero: BgsPlayerEntity,\r\n\totherBoard: BoardEntity[],\r\n\totherBoardHero: BgsPlayerEntity,\r\n\tdeadMinionIndexesFromRight: readonly number[],\r\n\tdeadEntities: readonly BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tfor (let i = 0; i < deadMinionIndexesFromRight.length; i++) {\r\n\t\tconst entity = deadEntities[i];\r\n\t\tconst indexFromRight = deadMinionIndexesFromRight[i];\r\n\t\tapplyAfterDeathEffects(\r\n\t\t\tentity,\r\n\t\t\tindexFromRight,\r\n\t\t\tfirstBoard,\r\n\t\t\tfirstBoardHero,\r\n\t\t\totherBoard,\r\n\t\t\totherBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n};\r\n\r\nexport const applyOnAttackBuffs = (\r\n\tattacker: BoardEntity,\r\n\tattackingBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (attacker.cardId === CardIds.GlyphGuardian_BGS_045) {\r\n\t\t// For now the utility method only works additively, so we hack around it\r\n\t\tmodifyAttack(attacker, 2 * attacker.attack - attacker.attack, attackingBoard, allCards);\r\n\t}\r\n\tif (attacker.cardId === CardIds.GlyphGuardian_TB_BaconUps_115) {\r\n\t\tmodifyAttack(attacker, 3 * attacker.attack - attacker.attack, attackingBoard, allCards);\r\n\t}\r\n\r\n\t// Ripsnarl Captain\r\n\tif (isCorrectTribe(allCards.getCard(attacker.cardId).races, Race.PIRATE)) {\r\n\t\tconst ripsnarls = attackingBoard.filter((e) => e.cardId === CardIds.RipsnarlCaptain_BGS_056);\r\n\t\tconst ripsnarlsTB = attackingBoard.filter(\r\n\t\t\t(entity) => entity.cardId === CardIds.RipsnarlCaptain_TB_BaconUps_139,\r\n\t\t);\r\n\t\tripsnarls.forEach((captain) => {\r\n\t\t\tmodifyAttack(attacker, 3, attackingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(captain, attacker, attackingBoard);\r\n\t\t});\r\n\t\tripsnarlsTB.forEach((captain) => {\r\n\t\t\tmodifyAttack(attacker, 6, attackingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(captain, attacker, attackingBoard);\r\n\t\t});\r\n\t}\r\n\r\n\t// Dread Admiral Eliza\r\n\tif (isCorrectTribe(allCards.getCard(attacker.cardId).races, Race.PIRATE)) {\r\n\t\tconst elizas = attackingBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.DreadAdmiralEliza_BGS_047 || e.cardId === CardIds.AdmiralElizaGoreblade_BG27_555,\r\n\t\t);\r\n\t\tconst elizasTB = attackingBoard.filter(\r\n\t\t\t(e) =>\r\n\t\t\t\te.cardId === CardIds.DreadAdmiralEliza_TB_BaconUps_134 ||\r\n\t\t\t\te.cardId === CardIds.AdmiralElizaGoreblade_BG27_555_G,\r\n\t\t);\r\n\r\n\t\telizas.forEach((eliza) => {\r\n\t\t\tattackingBoard.forEach((entity) => {\r\n\t\t\t\tmodifyAttack(entity, 3, attackingBoard, allCards);\r\n\t\t\t\tmodifyHealth(entity, 1, attackingBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(eliza, entity, attackingBoard);\r\n\t\t\t});\r\n\t\t});\r\n\t\telizasTB.forEach((eliza) => {\r\n\t\t\tattackingBoard.forEach((entity) => {\r\n\t\t\t\tmodifyAttack(entity, 4, attackingBoard, allCards);\r\n\t\t\t\tmodifyHealth(entity, 2, attackingBoard, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(eliza, entity, attackingBoard);\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n\tif (\r\n\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708 ||\r\n\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708_G\r\n\t) {\r\n\t\tattackingBoard\r\n\t\t\t.filter((e) => isCorrectTribe(allCards.getCard(e.cardId).races, Race.PIRATE))\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\tmodifyAttack(\r\n\t\t\t\t\te,\r\n\t\t\t\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708_G ? 4 : 2,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t);\r\n\t\t\t\tmodifyHealth(\r\n\t\t\t\t\te,\r\n\t\t\t\t\tattacker.cardId === CardIds.VanessaVancleef_BG24_708_G ? 4 : 2,\r\n\t\t\t\t\tattackingBoard,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t);\r\n\t\t\t\tspectator.registerPowerTarget(attacker, e, attackingBoard);\r\n\t\t\t});\r\n\t}\r\n\r\n\tconst eclipsion = attackingBoard.find(\r\n\t\t(e) =>\r\n\t\t\t[\r\n\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy,\r\n\t\t\t\tCardIds.EclipsionIllidari_TB_BaconShop_HERO_08_Buddy_G,\r\n\t\t\t].includes(e.cardId as CardIds) && e.abiityChargesLeft > 0,\r\n\t);\r\n\tif (!!eclipsion) {\r\n\t\tattacker.immuneWhenAttackCharges = 1;\r\n\t\teclipsion.abiityChargesLeft--;\r\n\t}\r\n};\r\n\r\nexport const applyOnBeingAttackedBuffs = (\r\n\tattackerEntity: BoardEntity,\r\n\tdefendingEntity: BoardEntity,\r\n\tdefendingBoard: BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tif (defendingEntity.taunt) {\r\n\t\tconst champions = defendingBoard.filter((entity) => entity.cardId === CardIds.ChampionOfYshaarj_BGS_111);\r\n\t\tconst goldenChampions = defendingBoard.filter(\r\n\t\t\t(entity) => entity.cardId === CardIds.ChampionOfYshaarj_TB_BaconUps_301,\r\n\t\t);\r\n\t\tchampions.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 1, defendingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 2, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(entity, entity, defendingBoard);\r\n\t\t});\r\n\t\tgoldenChampions.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 2, defendingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 4, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(entity, entity, defendingBoard);\r\n\t\t});\r\n\r\n\t\tconst arms = defendingBoard.filter((entity) => entity.cardId === CardIds.ArmOfTheEmpire_BGS_110);\r\n\t\tconst goldenArms = defendingBoard.filter((entity) => entity.cardId === CardIds.ArmOfTheEmpire_TB_BaconUps_302);\r\n\t\tarms.forEach((arm) => {\r\n\t\t\tmodifyAttack(defendingEntity, 2, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(arm, defendingEntity, defendingBoard);\r\n\t\t});\r\n\t\tgoldenArms.forEach((arm) => {\r\n\t\t\tmodifyAttack(defendingEntity, 4, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(arm, defendingEntity, defendingBoard);\r\n\t\t});\r\n\t}\r\n\r\n\t// Based on defending entity\r\n\tif (defendingEntity.cardId === CardIds.TormentedRitualist_BGS_201) {\r\n\t\tconst neighbours = getNeighbours(defendingBoard, defendingEntity);\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 1, defendingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 1, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(defendingEntity, entity, defendingBoard);\r\n\t\t});\r\n\t} else if (defendingEntity.cardId === CardIds.TormentedRitualist_TB_BaconUps_257) {\r\n\t\tconst neighbours = getNeighbours(defendingBoard, defendingEntity);\r\n\t\tneighbours.forEach((entity) => {\r\n\t\t\tmodifyAttack(entity, 2, defendingBoard, allCards);\r\n\t\t\tmodifyHealth(entity, 2, defendingBoard, allCards);\r\n\t\t\tspectator.registerPowerTarget(defendingEntity, entity, defendingBoard);\r\n\t\t});\r\n\t} else if (\r\n\t\tdefendingEntity.cardId === CardIds.DozyWhelp_BG24_300 ||\r\n\t\tdefendingEntity.cardId === CardIds.DozyWhelp_BG24_300_G\r\n\t) {\r\n\t\tmodifyAttack(\r\n\t\t\tdefendingEntity,\r\n\t\t\tdefendingEntity.cardId === CardIds.DozyWhelp_BG24_300_G ? 2 : 1,\r\n\t\t\tdefendingBoard,\r\n\t\t\tallCards,\r\n\t\t);\r\n\t\tspectator.registerPowerTarget(defendingEntity, defendingEntity, defendingBoard);\r\n\t} else if (\r\n\t\t[CardIds.AdaptableBarricade_BG27_022, CardIds.AdaptableBarricade_BG27_022_G].includes(\r\n\t\t\tdefendingEntity.cardId as CardIds,\r\n\t\t)\r\n\t) {\r\n\t\t// https://twitter.com/LoewenMitchell/status/1692225556559901031?s=20\r\n\t\tconst totalStats = defendingEntity.attack + defendingEntity.health;\r\n\t\tconst attackerAttack = attackerEntity.attack;\r\n\t\tif (defendingEntity.divineShield) {\r\n\t\t\tdefendingEntity.health = 1;\r\n\t\t\tdefendingEntity.attack = totalStats - defendingEntity.health;\r\n\t\t} else if (attackerEntity.venomous || attackerEntity.poisonous) {\r\n\t\t\t// Do nothing\r\n\t\t} else if (attackerAttack < totalStats) {\r\n\t\t\tdefendingEntity.health = attackerAttack + 1;\r\n\t\t\tdefendingEntity.attack = totalStats - defendingEntity.health;\r\n\t\t}\r\n\t} else if (\r\n\t\t[CardIds.GraniteGuardian_BG24_001, CardIds.GraniteGuardian_BG24_001_G].includes(\r\n\t\t\tdefendingEntity.cardId as CardIds,\r\n\t\t)\r\n\t) {\r\n\t\tattackerEntity.health = 1;\r\n\t}\r\n\r\n\t// Based on attacking entity\r\n\tif (\r\n\t\tattackerEntity.cardId === CardIds.SindoreiStraightShot_BG25_016 ||\r\n\t\tattackerEntity.cardId === CardIds.SindoreiStraightShot_BG25_016_G\r\n\t) {\r\n\t\tdefendingEntity.taunt = false;\r\n\t\tdefendingEntity.reborn = false;\r\n\t} else if (\r\n\t\t[CardIds.TransmutedBramblewitch_BG27_013, CardIds.TransmutedBramblewitch_BG27_013_G].includes(\r\n\t\t\tattackerEntity.cardId as CardIds,\r\n\t\t) &&\r\n\t\tattackerEntity.abiityChargesLeft > 0\r\n\t) {\r\n\t\tdefendingEntity.attack = 3;\r\n\t\tdefendingEntity.health = 3;\r\n\t\tattackerEntity.abiityChargesLeft--;\r\n\t}\r\n};\r\n\r\nconst makeMinionsDie = (\r\n\tboard: BoardEntity[],\r\n\tboardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tspectator: Spectator,\r\n): [number[], BoardEntity[]] => {\r\n\t// Because entities spawn to the left, so the right index is unchanged\r\n\tconst deadMinionIndexesFromRight: number[] = [];\r\n\tconst deadEntities: BoardEntity[] = [];\r\n\tfor (let i = 0; i < board.length; i++) {\r\n\t\tif (board[i].health <= 0 || board[i].definitelyDead) {\r\n\t\t\tdeadMinionIndexesFromRight.push(board.length - (i + 1));\r\n\t\t\tdeadEntities.push(board[i]);\r\n\t\t\tremoveMinionFromBoard(board, boardHero, i, allCards, spectator);\r\n\t\t\t// We modify the original array, so we need to update teh current index accordingly\r\n\t\t\ti--;\r\n\t\t}\r\n\t}\r\n\t// Treat all dead entities as a single block\r\n\tconst blockIndexesFromRight = [...deadMinionIndexesFromRight];\r\n\tfor (let i = deadMinionIndexesFromRight.length - 1; i >= 0; i--) {\r\n\t\tif (i === deadMinionIndexesFromRight.length - 1) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\t\tif (Math.abs(deadMinionIndexesFromRight[i] - deadMinionIndexesFromRight[i + 1]) <= 1) {\r\n\t\t\tblockIndexesFromRight[i] = blockIndexesFromRight[i + 1];\r\n\t\t} else {\r\n\t\t\t// blockIndexesFromRight[i] = blockIndexesFromRight[i];\r\n\t\t}\r\n\t}\r\n\treturn [blockIndexesFromRight, deadEntities];\r\n};\r\n\r\n// const handleKillEffects = (\r\n// \tboardWithKilledMinion: BoardEntity[],\r\n// \tkillerBoard: BoardEntity[],\r\n// \tdeadEntity: BoardEntity,\r\n// \tallCards: AllCardsService,\r\n// \tspectator: Spectator,\r\n// ): void => {\r\n// \tif (\r\n// \t\tdeadEntity.lastAffectedByEntity?.cardId &&\r\n// \t\tisCorrectTribe(allCards.getCard(deadEntity.lastAffectedByEntity.cardId).race, Race.DRAGON)\r\n// \t) {\r\n// \t\tfor (const entity of killerBoard) {\r\n// \t\t\tif (entity.cardId === CardIds.WaxriderTogwaggle2) {\r\n// \t\t\t\tmodifyAttack(entity, 2, killerBoard, allCards);\r\n// \t\t\t\tmodifyHealth(entity, 2, killerBoard, allCards);\r\n// \t\t\t\tafterStatsUpdate(entity, killerBoard, allCards);\r\n// \t\t\t\tspectator.registerPowerTarget(entity, entity, killerBoard);\r\n// \t\t\t} else if (entity.cardId === CardIds.WaxriderTogwaggleBattlegrounds) {\r\n// \t\t\t\tmodifyAttack(entity, 4, killerBoard, allCards);\r\n// \t\t\t\tmodifyHealth(entity, 4, killerBoard, allCards);\r\n// \t\t\t\tafterStatsUpdate(entity, killerBoard, allCards);\r\n// \t\t\t\tspectator.registerPowerTarget(entity, entity, killerBoard);\r\n// \t\t\t}\r\n// \t\t}\r\n// \t}\r\n// };\r\n\r\nexport const buildBoardAfterDeathrattleSpawns = (\r\n\tboardWithKilledMinion: BoardEntity[],\r\n\tboardWithKilledMinionHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tdeadMinionIndexFromRight2: number,\r\n\topponentBoard: BoardEntity[],\r\n\topponentBoardHero: BgsPlayerEntity,\r\n\tentitiesDeadThisAttack: readonly BoardEntity[],\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\t// TODO: don't apply this for FishOfNZoth\r\n\t// if (deadMinionIndex >= 0) {\r\n\t// \thandleKillEffects(boardWithKilledMinion, opponentBoard, deadEntity, allCards, spectator);\r\n\t// }\r\n\r\n\t// But Wildfire Element is applied first, before the DR spawns\r\n\tif (deadMinionIndexFromRight2 >= 0) {\r\n\t\tapplyMinionDeathEffect(\r\n\t\t\tdeadEntity,\r\n\t\t\tdeadMinionIndexFromRight2,\r\n\t\t\tboardWithKilledMinion,\r\n\t\t\tboardWithKilledMinionHero,\r\n\t\t\topponentBoard,\r\n\t\t\topponentBoardHero,\r\n\t\t\tallCards,\r\n\t\t\tcardsData,\r\n\t\t\tsharedState,\r\n\t\t\tspectator,\r\n\t\t);\r\n\t}\r\n\r\n\thandleDeathrattles(\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\tdeadEntity,\r\n\t\tdeadMinionIndexFromRight2,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tentitiesDeadThisAttack,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\r\n\t// TODO: check if Avenge effects should proc after deathrattles instead\r\n\t// They most certainly do, since the rat pack + avenge beast buffer works\r\n\tapplyAvengeEffects(\r\n\t\tdeadEntity,\r\n\t\tdeadMinionIndexFromRight2,\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\r\n\tconst entitiesFromAfterDeath: readonly BoardEntity[] = applyOnDeathEffects(\r\n\t\tdeadEntity,\r\n\t\tdeadMinionIndexFromRight2,\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\tperformEntitySpawns(\r\n\t\tentitiesFromAfterDeath,\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\tdeadEntity,\r\n\t\tdeadMinionIndexFromRight2,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\t// console.log('board after spawn', stringifySimple(boardWithKilledMinion, allCards));\r\n};\r\n\r\nconst buildBoardAfterRebornSpawns = (\r\n\tboardWithKilledMinion: BoardEntity[],\r\n\tboardWithKilledMinionHero: BgsPlayerEntity,\r\n\tdeadEntity: BoardEntity,\r\n\tdeadMinionIndexFromRight: number,\r\n\topponentBoard: BoardEntity[],\r\n\topponentBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): void => {\r\n\tconst numberOfReborns = 1;\r\n\t// Reborn happens after deathrattles\r\n\tif (!deadEntity.cardId) {\r\n\t\tconsole.error('missing card id for dead entity', stringifySimpleCard(deadEntity, allCards), deadEntity);\r\n\t}\r\n\tlet entityToSpawn: BoardEntity = null;\r\n\t// TODO: test\r\n\tif (\r\n\t\tdeadEntity.cardId === CardIds.SinrunnerBlanchy_BG24_005 ||\r\n\t\tdeadEntity.cardId === CardIds.SinrunnerBlanchy_BG24_005_G\r\n\t) {\r\n\t\tentityToSpawn = {\r\n\t\t\t...deadEntity,\r\n\t\t\thealth: deadEntity.maxHealth,\r\n\t\t\tdivineShield: deadEntity.hadDivineShield,\r\n\t\t\treborn: false,\r\n\t\t};\r\n\t}\r\n\tconst entitiesFromReborn: readonly BoardEntity[] =\r\n\t\tdeadEntity.reborn && deadMinionIndexFromRight >= 0\r\n\t\t\t? spawnEntities(\r\n\t\t\t\t\tdeadEntity.cardId,\r\n\t\t\t\t\tnumberOfReborns,\r\n\t\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\t\topponentBoard,\r\n\t\t\t\t\topponentBoardHero,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tcardsData,\r\n\t\t\t\t\tsharedState,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t\tdeadEntity.friendly,\r\n\t\t\t\t\tfalse,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t\tentityToSpawn,\r\n\t\t\t\t\tdeadEntity,\r\n\t\t\t )\r\n\t\t\t: [];\r\n\tconst entitiesThatWereReborn = performEntitySpawns(\r\n\t\tentitiesFromReborn,\r\n\t\tboardWithKilledMinion,\r\n\t\tboardWithKilledMinionHero,\r\n\t\tdeadEntity,\r\n\t\tdeadMinionIndexFromRight,\r\n\t\topponentBoard,\r\n\t\topponentBoardHero,\r\n\t\tallCards,\r\n\t\tcardsData,\r\n\t\tsharedState,\r\n\t\tspectator,\r\n\t);\r\n\r\n\tconst arfus = boardWithKilledMinion\r\n\t\t.filter((e) => e.cardId === CardIds.Arfus_TB_BaconShop_HERO_22_Buddy)\r\n\t\t.map((e) => e.attack)\r\n\t\t.reduce((a, b) => a + b, 0);\r\n\tconst goldenArfus = boardWithKilledMinion\r\n\t\t.filter((e) => e.cardId === CardIds.Arfus_TB_BaconShop_HERO_22_Buddy_G)\r\n\t\t.map((e) => 2 * e.attack)\r\n\t\t.reduce((a, b) => a + b, 0);\r\n\tif (arfus + goldenArfus > 0) {\r\n\t\tentitiesThatWereReborn.forEach((e) => {\r\n\t\t\tmodifyAttack(e, arfus + goldenArfus, boardWithKilledMinion, allCards);\r\n\t\t\tafterStatsUpdate(e, boardWithKilledMinion, allCards);\r\n\t\t});\r\n\t}\r\n\r\n\tconst numberOfTriggersForDeathwhisper = Math.min(entitiesFromReborn.length, 1);\r\n\tfor (let i = 0; i < numberOfTriggersForDeathwhisper; i++) {\r\n\t\tboardWithKilledMinion\r\n\t\t\t.filter(\r\n\t\t\t\t(e) =>\r\n\t\t\t\t\te.cardId === CardIds.SisterDeathwhisper_BG25_020 ||\r\n\t\t\t\t\te.cardId === CardIds.SisterDeathwhisper_BG25_020_G,\r\n\t\t\t)\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\tconst multiplier = e.cardId === CardIds.SisterDeathwhisper_BG25_020_G ? 2 : 1;\r\n\t\t\t\taddStatsToBoard(\r\n\t\t\t\t\te,\r\n\t\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\t\tmultiplier * 1,\r\n\t\t\t\t\tmultiplier * 3,\r\n\t\t\t\t\tallCards,\r\n\t\t\t\t\tspectator,\r\n\t\t\t\t\tRace[Race.UNDEAD],\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t\tboardWithKilledMinion\r\n\t\t\t.filter((e) => e.cardId === CardIds.JellyBelly_BG25_005 || e.cardId === CardIds.JellyBelly_BG25_005_G)\r\n\t\t\t.forEach((e) => {\r\n\t\t\t\tconst multiplier = e.cardId === CardIds.JellyBelly_BG25_005_G ? 2 : 1;\r\n\t\t\t\tmodifyAttack(e, multiplier * 3, boardWithKilledMinion, allCards);\r\n\t\t\t\tmodifyHealth(e, multiplier * 3, boardWithKilledMinion, allCards);\r\n\t\t\t\tafterStatsUpdate(e, boardWithKilledMinion, allCards);\r\n\t\t\t\tspectator.registerPowerTarget(e, e, boardWithKilledMinion);\r\n\t\t\t});\r\n\t}\r\n};\r\n\r\nexport const performEntitySpawns = (\r\n\tcandidateEntities: readonly BoardEntity[],\r\n\tboardWithKilledMinion: BoardEntity[],\r\n\tboardWithKilledMinionHero: BgsPlayerEntity,\r\n\tspawnSourceEntity: BoardEntity | BgsPlayerEntity,\r\n\tspawnSourceEntityIndexFromRight: number,\r\n\topponentBoard: BoardEntity[],\r\n\topponentBoardHero: BgsPlayerEntity,\r\n\tallCards: AllCardsService,\r\n\tcardsData: CardsData,\r\n\tsharedState: SharedState,\r\n\tspectator: Spectator,\r\n): readonly BoardEntity[] => {\r\n\tconst aliveEntites = candidateEntities.filter((entity) => entity.health > 0 && !entity.definitelyDead);\r\n\tconst spawnedEntities = [];\r\n\tfor (let i = 0; i < aliveEntites.length; i++) {\r\n\t\tconst newMinion = aliveEntites[i];\r\n\t\t// All entities have been spawned\r\n\t\tif (boardWithKilledMinion.length >= 7) {\r\n\t\t\tfor (let j = i; j < aliveEntites.length; j++) {\r\n\t\t\t\tif (aliveEntites[j]?.onCanceledSummon) {\r\n\t\t\t\t\taliveEntites[j].onCanceledSummon();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t// Avoid minions spawning backwards (we don't have this issue if we add all elements at\r\n\t\t// the same time, but here we want to be able to attack after each spawn, which in turn\r\n\t\t// means that the minion can die before the other one spawns)\r\n\t\t// In boardWithKilledMinion, the dead minion has already been removed\r\n\t\tconst indexToSpawnAt = boardWithKilledMinion.length - spawnSourceEntityIndexFromRight;\r\n\t\taddMinionToBoard(\r\n\t\t\tboardWithKilledMinion,\r\n\t\t\tboardWithKilledMinionHero,\r\n\t\t\topponentBoardHero,\r\n\t\t\tindexToSpawnAt,\r\n\t\t\tnewMinion,\r\n\t\t\tallCards,\r\n\t\t\tspectator,\r\n\t\t\tsharedState,\r\n\t\t);\r\n\t\tif (newMinion.attackImmediately) {\r\n\t\t\t// Whenever we are already in a combat phase, we need to first clean up the state\r\n\t\t\tsimulateAttack(\r\n\t\t\t\tboardWithKilledMinion,\r\n\t\t\t\tboardWithKilledMinionHero,\r\n\t\t\t\topponentBoard,\r\n\t\t\t\topponentBoardHero,\r\n\t\t\t\tnull,\r\n\t\t\t\tallCards,\r\n\t\t\t\tcardsData,\r\n\t\t\t\tsharedState,\r\n\t\t\t\tspectator,\r\n\t\t\t);\r\n\t\t}\r\n\t\tif (newMinion.health > 0 && !newMinion.definitelyDead) {\r\n\t\t\tspawnedEntities.push(newMinion);\r\n\t\t}\r\n\t}\r\n\r\n\tspectator.registerMinionsSpawn(spawnSourceEntity, boardWithKilledMinion, spawnedEntities);\r\n\treturn spawnedEntities;\r\n};\r\n"]}
|
package/dist/simulation/auras.js
CHANGED
|
@@ -60,7 +60,7 @@ const setMissingAura = (board, minionCardId, enchantmentCardId, attack, health,
|
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
const setImplicitDataHero = (hero, cardsData, isPlayer) => {
|
|
63
|
-
var _a, _b, _c, _d;
|
|
63
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
64
64
|
const avengeValue = cardsData.avengeValue(hero.heroPowerId);
|
|
65
65
|
if (avengeValue > 0) {
|
|
66
66
|
hero.avengeCurrent = avengeValue;
|
|
@@ -78,15 +78,14 @@ const setImplicitDataHero = (hero, cardsData, isPlayer) => {
|
|
|
78
78
|
hero.entityId = (_c = hero.entityId) !== null && _c !== void 0 ? _c : (isPlayer ? 999999998 : 999999999);
|
|
79
79
|
hero.hand = (_d = hero.hand) !== null && _d !== void 0 ? _d : [];
|
|
80
80
|
if (!hero.globalInfo) {
|
|
81
|
-
hero.globalInfo = {
|
|
82
|
-
EternalKnightsDeadThisGame: 0,
|
|
83
|
-
UndeadAttackBonus: 0,
|
|
84
|
-
FrostlingBonus: 0,
|
|
85
|
-
BloodGemAttackBonus: 0,
|
|
86
|
-
BloodGemHealthBonus: 0,
|
|
87
|
-
GoldrinnBuff: 0,
|
|
88
|
-
};
|
|
81
|
+
hero.globalInfo = {};
|
|
89
82
|
}
|
|
83
|
+
hero.globalInfo.EternalKnightsDeadThisGame = (_e = hero.globalInfo.EternalKnightsDeadThisGame) !== null && _e !== void 0 ? _e : 0;
|
|
84
|
+
hero.globalInfo.UndeadAttackBonus = (_f = hero.globalInfo.UndeadAttackBonus) !== null && _f !== void 0 ? _f : 0;
|
|
85
|
+
hero.globalInfo.FrostlingBonus = (_g = hero.globalInfo.FrostlingBonus) !== null && _g !== void 0 ? _g : 0;
|
|
86
|
+
hero.globalInfo.BloodGemAttackBonus = (_h = hero.globalInfo.BloodGemAttackBonus) !== null && _h !== void 0 ? _h : 0;
|
|
87
|
+
hero.globalInfo.BloodGemHealthBonus = (_j = hero.globalInfo.BloodGemHealthBonus) !== null && _j !== void 0 ? _j : 0;
|
|
88
|
+
hero.globalInfo.GoldrinnBuff = (_k = hero.globalInfo.GoldrinnBuff) !== null && _k !== void 0 ? _k : 0;
|
|
90
89
|
};
|
|
91
90
|
exports.setImplicitDataHero = setImplicitDataHero;
|
|
92
91
|
const clearStealthIfNeeded = (board, otherBoard) => {
|
|
@@ -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,KAAoB,EACpB,SAA0B,EAC1B,SAA0B,EACnB,EAAE;IAmBT,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,W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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\t// if (\r\n\t// \tboardHero.heroPowerId === CardIds.AllWillBurnBattlegrounds ||\r\n\t// \totherHero.heroPowerId === CardIds.AllWillBurnBattlegrounds\r\n\t// ) {\r\n\t// \tconst bonus =\r\n\t// \t\t(boardHero.heroPowerId === CardIds.AllWillBurnBattlegrounds ? 3 : 0) +\r\n\t// \t\t(otherHero.heroPowerId === CardIds.AllWillBurnBattlegrounds ? 3 : 0);\r\n\t// \tboard\r\n\t// \t\t.filter(\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.AllWillBurn_AllWillBurnEnchantmentBattlegrounds,\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 += bonus;\r\n\t// \t\t});\r\n\t// }\r\n\tif (boardHero.heroPowerId === CardIds.TheSmokingGun) {\r\n\t\tboard\r\n\t\t\t.filter(\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 = (hero: BgsPlayerEntity, cardsData: CardsData, isPlayer: boolean): void => {\r\n\tconst avengeValue = cardsData.avengeValue(hero.heroPowerId);\r\n\tif (avengeValue > 0) {\r\n\t\thero.avengeCurrent = avengeValue;\r\n\t\thero.avengeDefault = avengeValue;\r\n\t}\r\n\t// Backward compatibility\r\n\tif (!!hero.questRewards?.length && !Array.isArray(hero.questRewards)) {\r\n\t\thero.questRewards = [hero.questRewards as any];\r\n\t}\r\n\r\n\t// Because Denathrius can send a quest reward as its hero power (I think)\r\n\thero.questRewards = [...(hero.questRewards ?? []), hero.heroPowerId].filter((e) => !!e);\r\n\thero.questRewardEntities = hero.questRewards.map((reward) => ({\r\n\t\tcardId: reward,\r\n\t\tavengeCurrent: 0,\r\n\t\tavengeDefault: cardsData.avengeValue(reward),\r\n\t}));\r\n\thero.entityId = hero.entityId ?? (isPlayer ? 999_999_998 : 999_999_999);\r\n\thero.hand = hero.hand ?? [];\r\n\tif (!hero.globalInfo) {\r\n\t\thero.globalInfo = {\r\n\t\t\tEternalKnightsDeadThisGame: 0,\r\n\t\t\tUndeadAttackBonus: 0,\r\n\t\t\tFrostlingBonus: 0,\r\n\t\t\tBloodGemAttackBonus: 0,\r\n\t\t\tBloodGemHealthBonus: 0,\r\n\t\t\tGoldrinnBuff: 0,\r\n\t\t};\r\n\t}\r\n};\r\n\r\nexport const clearStealthIfNeeded = (board: BoardEntity[], otherBoard: BoardEntity[]): void => {\r\n\t// https://twitter.com/DCalkosz/status/1562194944688660481?s=20&t=100I8IVZmBKgYQWkdK8nIA\r\n\tif (board.every((entity) => entity.stealth && !entity.attack)) {\r\n\t\tboard.forEach((e) => (e.stealth = false));\r\n\t}\r\n\tif (otherBoard.every((entity) => entity.stealth && !entity.attack)) {\r\n\t\totherBoard.forEach((e) => (e.stealth = false));\r\n\t}\r\n\tif (board.every((e) => e.stealth) && otherBoard.every((e) => e.stealth)) {\r\n\t\tboard.forEach((e) => (e.stealth = false));\r\n\t\totherBoard.forEach((e) => (e.stealth = false));\r\n\t}\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"auras.js","sourceRoot":"","sources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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\t// if (\r\n\t// \tboardHero.heroPowerId === CardIds.AllWillBurnBattlegrounds ||\r\n\t// \totherHero.heroPowerId === CardIds.AllWillBurnBattlegrounds\r\n\t// ) {\r\n\t// \tconst bonus =\r\n\t// \t\t(boardHero.heroPowerId === CardIds.AllWillBurnBattlegrounds ? 3 : 0) +\r\n\t// \t\t(otherHero.heroPowerId === CardIds.AllWillBurnBattlegrounds ? 3 : 0);\r\n\t// \tboard\r\n\t// \t\t.filter(\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.AllWillBurn_AllWillBurnEnchantmentBattlegrounds,\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 += bonus;\r\n\t// \t\t});\r\n\t// }\r\n\tif (boardHero.heroPowerId === CardIds.TheSmokingGun) {\r\n\t\tboard\r\n\t\t\t.filter(\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 = (hero: BgsPlayerEntity, cardsData: CardsData, isPlayer: boolean): void => {\r\n\tconst avengeValue = cardsData.avengeValue(hero.heroPowerId);\r\n\tif (avengeValue > 0) {\r\n\t\thero.avengeCurrent = avengeValue;\r\n\t\thero.avengeDefault = avengeValue;\r\n\t}\r\n\t// Backward compatibility\r\n\tif (!!hero.questRewards?.length && !Array.isArray(hero.questRewards)) {\r\n\t\thero.questRewards = [hero.questRewards as any];\r\n\t}\r\n\r\n\t// Because Denathrius can send a quest reward as its hero power (I think)\r\n\thero.questRewards = [...(hero.questRewards ?? []), hero.heroPowerId].filter((e) => !!e);\r\n\thero.questRewardEntities = hero.questRewards.map((reward) => ({\r\n\t\tcardId: reward,\r\n\t\tavengeCurrent: 0,\r\n\t\tavengeDefault: cardsData.avengeValue(reward),\r\n\t}));\r\n\thero.entityId = hero.entityId ?? (isPlayer ? 999_999_998 : 999_999_999);\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.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.GoldrinnBuff = hero.globalInfo.GoldrinnBuff ?? 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"]}
|
|
@@ -112,7 +112,7 @@ class Spectator {
|
|
|
112
112
|
}
|
|
113
113
|
registerDamageDealt(damagingEntity, damagedEntity, damageTaken, damagedEntityBoard) {
|
|
114
114
|
if (!damagingEntity.entityId) {
|
|
115
|
-
console.error('missing damaging entity id', damagingEntity);
|
|
115
|
+
console.error('missing damaging entity id', damagingEntity.cardId);
|
|
116
116
|
}
|
|
117
117
|
const friendlyBoard = damagedEntityBoard.every((entity) => entity.friendly) ? damagedEntityBoard : null;
|
|
118
118
|
const opponentBoard = damagedEntityBoard.every((entity) => !entity.friendly) ? damagedEntityBoard : null;
|
|
@@ -135,7 +135,7 @@ class Spectator {
|
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
137
|
if (!sourceEntity.entityId && !sourceEntity.heroPowerId) {
|
|
138
|
-
console.error('missing damaging entity id', sourceEntity);
|
|
138
|
+
console.error('missing damaging entity id', sourceEntity.cardId);
|
|
139
139
|
}
|
|
140
140
|
const friendlyBoard = targetBoard.every((entity) => entity.friendly) ? targetBoard : null;
|
|
141
141
|
const opponentBoard = targetBoard.every((entity) => !entity.friendly) ? targetBoard : null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spectator.js","sourceRoot":"","sources":["../../../src/simulation/spectator/spectator.ts"],"names":[],"mappings":";;;AAKA,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,MAAa,SAAS;IAMrB,YACkB,YAAqB,EACrB,qBAA8B,EAC9B,cAAuB,EACvB,uBAAgC;QAHhC,iBAAY,GAAZ,YAAY,CAAS;QACrB,0BAAqB,GAArB,qBAAqB,CAAS;QAC9B,mBAAc,GAAd,cAAc,CAAS;QACvB,4BAAuB,GAAvB,uBAAuB,CAAS;QAEjD,IAAI,CAAC,uBAAuB,GAAG,EAAE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AW,GAAG,MAAM,CAAC,WAAW,CAAC;gBAC5C,UAAU,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC;aAChD;iBAAM;gBACN,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACpB;SACD;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAIO,QAAQ,CAAC,KAA6B;QAC7C,IAAI,CAAC,KAAK,EAAE;YACX,OAAO,SAAS,CAAC;SACjB;QACD,OAAO,KAAK,CAAC,GAAG,CACf,CAAC,MAAM,EAAE,EAAE,CACV,CAAC;YACA,GAAG,MAAM;YACT,YAAY,EAAE,SAAS;YACvB,UAAU,EAAE,SAAS;YACrB,gBAAgB,EAAE,SAAS;YAC3B,iBAAiB,EAAE,SAAS;YAC5B,cAAc,EAAE,SAAS;YACzB,oBAAoB,EAAE,SAAS;YAC/B,SAAS,EAAE,SAAS;SACJ,CAAA,CAClB,CAAC;IACH,CAAC;CACD;AA3UD,8BA2UC","sourcesContent":["import { BgsPlayerEntity } from 'src/bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\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\tconstructor(\r\n\t\tprivate readonly playerCardId?: string,\r\n\t\tprivate readonly playerHeroPowerCardId?: string,\r\n\t\tprivate readonly opponentCardId?: string,\r\n\t\tprivate readonly opponentHeroPowerCardId?: string,\r\n\t) {\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,\r\n\t\t\tlost: this.lostBattles,\r\n\t\t\ttied: this.tiedBattles,\r\n\t\t};\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\tswitch (result) {\r\n\t\t\tcase 'won':\r\n\t\t\t\tthis.wonBattles.push({\r\n\t\t\t\t\tactions: actionsForBattle,\r\n\t\t\t\t\tplayerCardId: this.playerCardId,\r\n\t\t\t\t\tplayerHeroPowerCardId: this.playerHeroPowerCardId,\r\n\t\t\t\t\topponentCardId: this.opponentCardId,\r\n\t\t\t\t\topponentHeroPowerCardId: this.opponentHeroPowerCardId,\r\n\t\t\t\t});\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'lost':\r\n\t\t\t\tthis.lostBattles.push({\r\n\t\t\t\t\tactions: actionsForBattle,\r\n\t\t\t\t\tplayerCardId: this.playerCardId,\r\n\t\t\t\t\tplayerHeroPowerCardId: this.playerHeroPowerCardId,\r\n\t\t\t\t\topponentCardId: this.opponentCardId,\r\n\t\t\t\t\topponentHeroPowerCardId: this.opponentHeroPowerCardId,\r\n\t\t\t\t});\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'tied':\r\n\t\t\t\tthis.tiedBattles.push({\r\n\t\t\t\t\tactions: actionsForBattle,\r\n\t\t\t\t\tplayerCardId: this.playerCardId,\r\n\t\t\t\t\tplayerHeroPowerCardId: this.playerHeroPowerCardId,\r\n\t\t\t\t\topponentCardId: this.opponentCardId,\r\n\t\t\t\t\topponentHeroPowerCardId: this.opponentHeroPowerCardId,\r\n\t\t\t\t});\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): void {\r\n\t\tconst friendlyBoard = attackingBoard.every((entity) => entity.friendly) ? attackingBoard : defendingBoard;\r\n\t\tconst opponentBoard = defendingBoard.every((entity) => entity.friendly) ? attackingBoard : defendingBoard;\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\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerStartOfCombat(friendlyBoard: readonly BoardEntity[], opponentBoard: readonly BoardEntity[]): void {\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};\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\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\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\tconsole.error('missing damaging entity id', damagingEntity);\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};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerPowerTarget(\r\n\t\tsourceEntity: BoardEntity | BgsPlayerEntity,\r\n\t\ttargetEntity: BoardEntity,\r\n\t\ttargetBoard: BoardEntity[],\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\tconsole.error('missing damaging entity id', sourceEntity);\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 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};\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};\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};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tprivate addAction(action: GameAction) {\r\n\t\tif (!this.actionsForCurrentBattle.length) {\r\n\t\t\tthis.actionsForCurrentBattle.push(action);\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst collapsed = this.collapseActions([\r\n\t\t\tthis.actionsForCurrentBattle[this.actionsForCurrentBattle.length - 1],\r\n\t\t\taction,\r\n\t\t]);\r\n\t\tthis.actionsForCurrentBattle.splice(this.actionsForCurrentBattle.length - 1, 1, ...collapsed);\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 = actions[i];\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\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} 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} 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} else {\r\n\t\t\t\tresult.push(action);\r\n\t\t\t}\r\n\t\t}\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\t...entity,\r\n\t\t\t\t\tenchantments: undefined,\r\n\t\t\t\t\tcantAttack: undefined,\r\n\t\t\t\t\tattacksPerformed: 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":";;;AAKA,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,MAAa,SAAS;IAMrB,YACkB,YAAqB,EACrB,qBAA8B,EAC9B,cAAuB,EACvB,uBAAgC;QAHhC,iBAAY,GAAZ,YAAY,CAAS;QACrB,0BAAqB,GAArB,qBAAqB,CAAS;QAC9B,mBAAc,GAAd,cAAc,CAAS;QACvB,4BAAuB,GAAvB,uBAAuB,CAAS;QAEj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G,MAAM,CAAC,eAAe,CAAC,CAAC;gBAI3D,UAAU,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;gBAC5C,UAAU,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC;aAChD;iBAAM;gBACN,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACpB;SACD;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAIO,QAAQ,CAAC,KAA6B;QAC7C,IAAI,CAAC,KAAK,EAAE;YACX,OAAO,SAAS,CAAC;SACjB;QACD,OAAO,KAAK,CAAC,GAAG,CACf,CAAC,MAAM,EAAE,EAAE,CACV,CAAC;YACA,GAAG,MAAM;YACT,YAAY,EAAE,SAAS;YACvB,UAAU,EAAE,SAAS;YACrB,gBAAgB,EAAE,SAAS;YAC3B,iBAAiB,EAAE,SAAS;YAC5B,cAAc,EAAE,SAAS;YACzB,oBAAoB,EAAE,SAAS;YAC/B,SAAS,EAAE,SAAS;SACJ,CAAA,CAClB,CAAC;IACH,CAAC;CACD;AA3UD,8BA2UC","sourcesContent":["import { BgsPlayerEntity } from 'src/bgs-player-entity';\r\nimport { BoardEntity } from '../../board-entity';\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\tconstructor(\r\n\t\tprivate readonly playerCardId?: string,\r\n\t\tprivate readonly playerHeroPowerCardId?: string,\r\n\t\tprivate readonly opponentCardId?: string,\r\n\t\tprivate readonly opponentHeroPowerCardId?: string,\r\n\t) {\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,\r\n\t\t\tlost: this.lostBattles,\r\n\t\t\ttied: this.tiedBattles,\r\n\t\t};\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\tswitch (result) {\r\n\t\t\tcase 'won':\r\n\t\t\t\tthis.wonBattles.push({\r\n\t\t\t\t\tactions: actionsForBattle,\r\n\t\t\t\t\tplayerCardId: this.playerCardId,\r\n\t\t\t\t\tplayerHeroPowerCardId: this.playerHeroPowerCardId,\r\n\t\t\t\t\topponentCardId: this.opponentCardId,\r\n\t\t\t\t\topponentHeroPowerCardId: this.opponentHeroPowerCardId,\r\n\t\t\t\t});\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'lost':\r\n\t\t\t\tthis.lostBattles.push({\r\n\t\t\t\t\tactions: actionsForBattle,\r\n\t\t\t\t\tplayerCardId: this.playerCardId,\r\n\t\t\t\t\tplayerHeroPowerCardId: this.playerHeroPowerCardId,\r\n\t\t\t\t\topponentCardId: this.opponentCardId,\r\n\t\t\t\t\topponentHeroPowerCardId: this.opponentHeroPowerCardId,\r\n\t\t\t\t});\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'tied':\r\n\t\t\t\tthis.tiedBattles.push({\r\n\t\t\t\t\tactions: actionsForBattle,\r\n\t\t\t\t\tplayerCardId: this.playerCardId,\r\n\t\t\t\t\tplayerHeroPowerCardId: this.playerHeroPowerCardId,\r\n\t\t\t\t\topponentCardId: this.opponentCardId,\r\n\t\t\t\t\topponentHeroPowerCardId: this.opponentHeroPowerCardId,\r\n\t\t\t\t});\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): void {\r\n\t\tconst friendlyBoard = attackingBoard.every((entity) => entity.friendly) ? attackingBoard : defendingBoard;\r\n\t\tconst opponentBoard = defendingBoard.every((entity) => entity.friendly) ? attackingBoard : defendingBoard;\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\topponentBoard: this.sanitize(opponentBoard),\r\n\t\t};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerStartOfCombat(friendlyBoard: readonly BoardEntity[], opponentBoard: readonly BoardEntity[]): void {\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};\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\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\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\tconsole.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};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tpublic registerPowerTarget(\r\n\t\tsourceEntity: BoardEntity | BgsPlayerEntity,\r\n\t\ttargetEntity: BoardEntity,\r\n\t\ttargetBoard: BoardEntity[],\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\tconsole.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 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};\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};\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};\r\n\t\tthis.addAction(action);\r\n\t}\r\n\r\n\tprivate addAction(action: GameAction) {\r\n\t\tif (!this.actionsForCurrentBattle.length) {\r\n\t\t\tthis.actionsForCurrentBattle.push(action);\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst collapsed = this.collapseActions([\r\n\t\t\tthis.actionsForCurrentBattle[this.actionsForCurrentBattle.length - 1],\r\n\t\t\taction,\r\n\t\t]);\r\n\t\tthis.actionsForCurrentBattle.splice(this.actionsForCurrentBattle.length - 1, 1, ...collapsed);\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 = actions[i];\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\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} 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} 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} else {\r\n\t\t\t\tresult.push(action);\r\n\t\t\t}\r\n\t\t}\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\t...entity,\r\n\t\t\t\t\tenchantments: undefined,\r\n\t\t\t\t\tcantAttack: undefined,\r\n\t\t\t\t\tattacksPerformed: 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"]}
|