@firestone-hs/simulate-bgs-battle 1.1.736 → 1.1.737
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.
|
@@ -80,6 +80,9 @@ const handleRebornForEntity = (boardWithKilledMinion, boardWithKilledMinionHero,
|
|
|
80
80
|
});
|
|
81
81
|
for (const rebornEntity of entitiesThatWereReborn) {
|
|
82
82
|
for (const entity of boardWithKilledMinion) {
|
|
83
|
+
if (entitiesThatWereReborn.includes(entity)) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
83
86
|
const rebornImpl = _card_mappings_1.cardMappings[entity.cardId];
|
|
84
87
|
if ((0, card_interface_1.hasAfterReborn)(rebornImpl)) {
|
|
85
88
|
rebornImpl.afterReborn(entity, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reborn.js","sourceRoot":"","sources":["../../src/simulation/reborn.ts"],"names":[],"mappings":";;;AAEA,4DAKiC;AACjC,iEAA4D;AAC5D,oFAAmF;AACnF,8EAA+G;AAE/G,oCAA2C;AAC3C,6DAAqD;AAErD,qCAA+C;AAExC,MAAM,qBAAqB,GAAG,CACpC,qBAAoC,EACpC,yBAA0C,EAC1C,UAAuB,EACvB,wBAAgC,EAChC,aAA4B,EAC5B,iBAAkC,EAClC,SAAwB,EACjB,EAAE;;IACT,MAAM,eAAe,GAAG,CAAC,CAAC;IAC1B,IAAI,aAAa,GAAgB,IAAI,CAAC;IACtC,IACC,IAAA,sCAAkB,EAAC,UAAU,CAAC,MAAM,CAAC;QACrC,IAAA,uCAAmB,EAAC,UAAU,CAAC;SAC/B,MAAA,UAAU,CAAC,YAAY,0CAAE,IAAI,CAC5B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,wBAAuE,CACtF,CAAA,EACA;QACD,aAAa,GAAG,IAAA,qDAAiC,EAAC,UAAU,CAAC,CAAC;KAC9D;IAED,MAAM,UAAU,GAAG,6BAAY,CAAC,UAAU,C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T,CAAC;QACH,CAAC,CAAC,CAAC;KACJ;AACF,CAAC,CAAC;AAnKW,QAAA,qBAAqB,yBAmKhC","sourcesContent":["import { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport {\r\n\thasAfterReborn,\r\n\thasBeforeRebornSelfEffect,\r\n\thasRebornEffect,\r\n\thasRebornSelfEffect,\r\n} from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { hasPersistingHorror } from '../cards/impl/enchantments/persisting-horror';\r\nimport { buildSinrunnerBlanchyRebornEntity, isSinrunnerBlanchy } from '../cards/impl/minion/sinrunner-blanchy';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { addStatsToBoard } from '../utils';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { performEntitySpawns } from './spawns';\r\n\r\nexport const handleRebornForEntity = (\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\tgameState: FullGameState,\r\n): void => {\r\n\tconst numberOfReborns = 1;\r\n\tlet entityToSpawn: BoardEntity = null;\r\n\tif (\r\n\t\tisSinrunnerBlanchy(deadEntity.cardId) ||\r\n\t\thasPersistingHorror(deadEntity) ||\r\n\t\tdeadEntity.enchantments?.some(\r\n\t\t\t(e) => e.cardId === CardIds.UltraCapacitor_UltraCapacitorEnchantment_BG31_HERO_801ptje,\r\n\t\t)\r\n\t) {\r\n\t\tentityToSpawn = buildSinrunnerBlanchyRebornEntity(deadEntity);\r\n\t}\r\n\r\n\tconst rebornImpl = cardMappings[deadEntity.cardId];\r\n\tif (hasBeforeRebornSelfEffect(rebornImpl)) {\r\n\t\trebornImpl.beforeRebornSelfEffect(deadEntity, {\r\n\t\t\trebornEntity: deadEntity,\r\n\t\t\tboardWithKilledMinion,\r\n\t\t\tboardWithKilledMinionHero,\r\n\t\t\topponentBoard,\r\n\t\t\topponentBoardHero,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t}\r\n\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\tgameState,\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\tif (!entitiesFromReborn.length) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (\r\n\t\tdeadEntity.cardId === CardIds.WannabeGargoyle_BG30_109 ||\r\n\t\tdeadEntity.cardId === CardIds.WannabeGargoyle_BG30_109_G\r\n\t) {\r\n\t\tentitiesFromReborn.forEach((e) => {\r\n\t\t\tconst attack = deadEntity.maxAttack;\r\n\t\t\tconst health = deadEntity.cardId === CardIds.WannabeGargoyle_BG30_109_G ? deadEntity.maxHealth : 1;\r\n\t\t\te.attack = attack;\r\n\t\t\te.health = health;\r\n\t\t});\r\n\t}\r\n\r\n\tfor (const entity of entitiesFromReborn) {\r\n\t\tconst rebornImpl = cardMappings[entity.cardId];\r\n\t\tif (hasRebornSelfEffect(rebornImpl)) {\r\n\t\t\trebornImpl.rebornSelfEffect(entity, {\r\n\t\t\t\trebornEntity: deadEntity,\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\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const entity of boardWithKilledMinion) {\r\n\t\tconst rebornImpl = cardMappings[entity.cardId];\r\n\t\tif (hasRebornEffect(rebornImpl)) {\r\n\t\t\trebornImpl.rebornEffect(entity, {\r\n\t\t\t\trebornEntity: deadEntity,\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\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\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\tgameState,\r\n\t);\r\n\tentitiesThatWereReborn.forEach((e) => (e.rebornFromEntityId = deadEntity.entityId));\r\n\tconst entityRightToSpawns =\r\n\t\tdeadMinionIndexFromRight === 0\r\n\t\t\t? null\r\n\t\t\t: boardWithKilledMinion[boardWithKilledMinion.length - deadMinionIndexFromRight];\r\n\tentitiesThatWereReborn.forEach((entity) => {\r\n\t\tentity.hasAttacked = deadEntity.hasAttacked > 1 ? 1 : entityRightToSpawns?.hasAttacked ?? undefined;\r\n\t});\r\n\r\n\tfor (const rebornEntity of entitiesThatWereReborn) {\r\n\t\tfor (const entity of boardWithKilledMinion) {\r\n\t\t\tconst rebornImpl = cardMappings[entity.cardId];\r\n\t\t\tif (hasAfterReborn(rebornImpl)) {\r\n\t\t\t\trebornImpl.afterReborn(entity, {\r\n\t\t\t\t\trebornEntity: rebornEntity,\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\tgameState,\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t\tfor (const trinket of boardWithKilledMinionHero.trinkets ?? []) {\r\n\t\t\tconst rebornImpl = cardMappings[trinket.cardId];\r\n\t\t\tif (hasAfterReborn(rebornImpl)) {\r\n\t\t\t\trebornImpl.afterReborn(trinket, {\r\n\t\t\t\t\trebornEntity: rebornEntity,\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\tgameState,\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tconst numberOfTriggersForDeathwhisper = Math.min(entitiesThatWereReborn.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\tboardWithKilledMinionHero,\r\n\t\t\t\t\tmultiplier * 1,\r\n\t\t\t\t\tmultiplier * 3,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t}\r\n};\r\n\r\nexport interface RebornEffectInput {\r\n\treadonly rebornEntity: BoardEntity;\r\n\treadonly boardWithKilledMinion: BoardEntity[];\r\n\treadonly boardWithKilledMinionHero: BgsPlayerEntity;\r\n\treadonly opponentBoard: BoardEntity[];\r\n\treadonly opponentBoardHero: BgsPlayerEntity;\r\n\treadonly gameState: FullGameState;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"reborn.js","sourceRoot":"","sources":["../../src/simulation/reborn.ts"],"names":[],"mappings":";;;AAEA,4DAKiC;AACjC,iEAA4D;AAC5D,oFAAmF;AACnF,8EAA+G;AAE/G,oCAA2C;AAC3C,6DAAqD;AAErD,qCAA+C;AAExC,MAAM,qBAAqB,GAAG,CACpC,qBAAoC,EACpC,yBAA0C,EAC1C,UAAuB,EACvB,wBAAgC,EAChC,aAA4B,EAC5B,iBAAkC,EAClC,SAAwB,EACjB,EAAE;;IACT,MAAM,eAAe,GAAG,CAAC,CAAC;IAC1B,IAAI,aAAa,GAAgB,IAAI,CAAC;IACtC,IACC,IAAA,sCAAkB,EAAC,UAAU,CAAC,MAAM,CAAC;QACrC,IAAA,uCAAmB,EAAC,UAAU,CAAC;SAC/B,MAAA,UAAU,CAAC,YAAY,0CAAE,IAAI,CAC5B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,wBAAuE,CACtF,CAAA,EACA;QACD,aAAa,GAAG,IAAA,qDAAiC,EAAC,UAAU,CAAC,CAAC;KAC9D;IAED,MAAM,UAAU,GAAG,6BAAY,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACnD,IAAI,IAAA,0CAAyB,EAAC,UAAU,CAAC,EAAE;QAC1C,UAAU,CAAC,sBAAsB,CAAC,UAAU,EAAE;YAC7C,YAAY,EAAE,UAAU;YACxB,qBAAqB;YACrB,yBAAyB;YACzB,aAAa;YACb,iBAAiB;YACjB,SAAS;SACT,CAAC,CAAC;KACH;IAED,MAAM,kBAAkB,GACvB,UAAU,CAAC,MAAM,IAAI,wBAAwB,IAAI,CAAC;QACjD,CAAC,CAAC,IAAA,kCAAa,EACb,UAAU,CAAC,MAAM,EACjB,eAAe,EACf,qBAAqB,EACrB,yBAAyB,EACzB,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,UAAU,CAAC,QAAQ,EACnB,KAAK,EACL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AAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAChD,IAAI,IAAA,+BAAc,EAAC,UAAU,CAAC,EAAE;gBAC/B,UAAU,CAAC,WAAW,CAAC,OAAO,EAAE;oBAC/B,YAAY,EAAE,YAAY;oBAC1B,qBAAqB;oBACrB,yBAAyB;oBACzB,aAAa;oBACb,iBAAiB;oBACjB,SAAS;iBACT,CAAC,CAAC;aACH;SACD;KACD;IAED,MAAM,+BAA+B,GAAG,IAAI,CAAC,GAAG,CAAC,sBAAsB,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACnF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,+BAA+B,EAAE,CAAC,EAAE,EAAE;QACzD,qBAAqB;aACnB,MAAM,CACN,CAAC,CAAC,EAAE,EAAE,CACL,CAAC,CAAC,MAAM,eAAwC;YAChD,CAAC,CAAC,MAAM,iBAA0C,CACnD;aACA,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACd,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,iBAA0C,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9E,IAAA,uBAAe,EACd,CAAC,EACD,qBAAqB,EACrB,yBAAyB,EACzB,UAAU,GAAG,CAAC,EACd,UAAU,GAAG,CAAC,EACd,SAAS,CACT,CAAC;QACH,CAAC,CAAC,CAAC;KACJ;AACF,CAAC,CAAC;AAvKW,QAAA,qBAAqB,yBAuKhC","sourcesContent":["import { BgsPlayerEntity } from '../bgs-player-entity';\r\nimport { BoardEntity } from '../board-entity';\r\nimport {\r\n\thasAfterReborn,\r\n\thasBeforeRebornSelfEffect,\r\n\thasRebornEffect,\r\n\thasRebornSelfEffect,\r\n} from '../cards/card.interface';\r\nimport { cardMappings } from '../cards/impl/_card-mappings';\r\nimport { hasPersistingHorror } from '../cards/impl/enchantments/persisting-horror';\r\nimport { buildSinrunnerBlanchyRebornEntity, isSinrunnerBlanchy } from '../cards/impl/minion/sinrunner-blanchy';\r\nimport { CardIds } from '../services/card-ids';\r\nimport { addStatsToBoard } from '../utils';\r\nimport { spawnEntities } from './deathrattle-spawns';\r\nimport { FullGameState } from './internal-game-state';\r\nimport { performEntitySpawns } from './spawns';\r\n\r\nexport const handleRebornForEntity = (\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\tgameState: FullGameState,\r\n): void => {\r\n\tconst numberOfReborns = 1;\r\n\tlet entityToSpawn: BoardEntity = null;\r\n\tif (\r\n\t\tisSinrunnerBlanchy(deadEntity.cardId) ||\r\n\t\thasPersistingHorror(deadEntity) ||\r\n\t\tdeadEntity.enchantments?.some(\r\n\t\t\t(e) => e.cardId === CardIds.UltraCapacitor_UltraCapacitorEnchantment_BG31_HERO_801ptje,\r\n\t\t)\r\n\t) {\r\n\t\tentityToSpawn = buildSinrunnerBlanchyRebornEntity(deadEntity);\r\n\t}\r\n\r\n\tconst rebornImpl = cardMappings[deadEntity.cardId];\r\n\tif (hasBeforeRebornSelfEffect(rebornImpl)) {\r\n\t\trebornImpl.beforeRebornSelfEffect(deadEntity, {\r\n\t\t\trebornEntity: deadEntity,\r\n\t\t\tboardWithKilledMinion,\r\n\t\t\tboardWithKilledMinionHero,\r\n\t\t\topponentBoard,\r\n\t\t\topponentBoardHero,\r\n\t\t\tgameState,\r\n\t\t});\r\n\t}\r\n\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\tgameState,\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\tif (!entitiesFromReborn.length) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (\r\n\t\tdeadEntity.cardId === CardIds.WannabeGargoyle_BG30_109 ||\r\n\t\tdeadEntity.cardId === CardIds.WannabeGargoyle_BG30_109_G\r\n\t) {\r\n\t\tentitiesFromReborn.forEach((e) => {\r\n\t\t\tconst attack = deadEntity.maxAttack;\r\n\t\t\tconst health = deadEntity.cardId === CardIds.WannabeGargoyle_BG30_109_G ? deadEntity.maxHealth : 1;\r\n\t\t\te.attack = attack;\r\n\t\t\te.health = health;\r\n\t\t});\r\n\t}\r\n\r\n\tfor (const entity of entitiesFromReborn) {\r\n\t\tconst rebornImpl = cardMappings[entity.cardId];\r\n\t\tif (hasRebornSelfEffect(rebornImpl)) {\r\n\t\t\trebornImpl.rebornSelfEffect(entity, {\r\n\t\t\t\trebornEntity: deadEntity,\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\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tfor (const entity of boardWithKilledMinion) {\r\n\t\tconst rebornImpl = cardMappings[entity.cardId];\r\n\t\tif (hasRebornEffect(rebornImpl)) {\r\n\t\t\trebornImpl.rebornEffect(entity, {\r\n\t\t\t\trebornEntity: deadEntity,\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\tgameState,\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\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\tgameState,\r\n\t);\r\n\tentitiesThatWereReborn.forEach((e) => (e.rebornFromEntityId = deadEntity.entityId));\r\n\tconst entityRightToSpawns =\r\n\t\tdeadMinionIndexFromRight === 0\r\n\t\t\t? null\r\n\t\t\t: boardWithKilledMinion[boardWithKilledMinion.length - deadMinionIndexFromRight];\r\n\tentitiesThatWereReborn.forEach((entity) => {\r\n\t\tentity.hasAttacked = deadEntity.hasAttacked > 1 ? 1 : entityRightToSpawns?.hasAttacked ?? undefined;\r\n\t});\r\n\r\n\tfor (const rebornEntity of entitiesThatWereReborn) {\r\n\t\tfor (const entity of boardWithKilledMinion) {\r\n\t\t\t// The entity was not there when the minion died, so we don't trigger its effect\r\n\t\t\tif (entitiesThatWereReborn.includes(entity)) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tconst rebornImpl = cardMappings[entity.cardId];\r\n\t\t\tif (hasAfterReborn(rebornImpl)) {\r\n\t\t\t\trebornImpl.afterReborn(entity, {\r\n\t\t\t\t\trebornEntity: rebornEntity,\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\tgameState,\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t\tfor (const trinket of boardWithKilledMinionHero.trinkets ?? []) {\r\n\t\t\tconst rebornImpl = cardMappings[trinket.cardId];\r\n\t\t\tif (hasAfterReborn(rebornImpl)) {\r\n\t\t\t\trebornImpl.afterReborn(trinket, {\r\n\t\t\t\t\trebornEntity: rebornEntity,\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\tgameState,\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tconst numberOfTriggersForDeathwhisper = Math.min(entitiesThatWereReborn.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\tboardWithKilledMinionHero,\r\n\t\t\t\t\tmultiplier * 1,\r\n\t\t\t\t\tmultiplier * 3,\r\n\t\t\t\t\tgameState,\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t}\r\n};\r\n\r\nexport interface RebornEffectInput {\r\n\treadonly rebornEntity: BoardEntity;\r\n\treadonly boardWithKilledMinion: BoardEntity[];\r\n\treadonly boardWithKilledMinionHero: BgsPlayerEntity;\r\n\treadonly opponentBoard: BoardEntity[];\r\n\treadonly opponentBoardHero: BgsPlayerEntity;\r\n\treadonly gameState: FullGameState;\r\n}\r\n"]}
|