From a477b0b584d63ac089ddfbb71e0573bc65c7d69b Mon Sep 17 00:00:00 2001 From: Dev Date: Mon, 23 Sep 2024 22:56:22 +0100 Subject: [PATCH] Added labs to pmc conversion system --- project/assets/configs/pmc.json | 26 ++++-------------------- project/src/controllers/BotController.ts | 6 +++++- project/src/helpers/BotHelper.ts | 13 ++++++++++-- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/project/assets/configs/pmc.json b/project/assets/configs/pmc.json index 2adf4fbe..33b7ab53 100644 --- a/project/assets/configs/pmc.json +++ b/project/assets/configs/pmc.json @@ -778,30 +778,12 @@ "assault": { "min": 10, "max": 15 - }, - "cursedassault": { - "min": 15, - "max": 30 - }, + } + }, + "laboratory":{ "pmcbot": { - "min": 5, - "max": 10 - }, - "exusec": { - "min": 5, + "min": 1, "max": 5 - }, - "arenafighter": { - "min": 0, - "max": 0 - }, - "arenafighterevent": { - "min": 0, - "max": 0 - }, - "crazyassaultevent": { - "min": 0, - "max": 0 } } }, diff --git a/project/src/controllers/BotController.ts b/project/src/controllers/BotController.ts index cb2df740..a3f6baf5 100644 --- a/project/src/controllers/BotController.ts +++ b/project/src/controllers/BotController.ts @@ -397,7 +397,11 @@ export class BotController { const botConvertRateMinMax = this.getPmcConversionMinMaxForLocation(requestedBot.Role, raidSettings?.location); if (botConvertRateMinMax) { // Should bot become PMC - const convertToPmc = this.botHelper.rollChanceToBePmc(requestedBot.Role, botConvertRateMinMax); + const convertToPmc = this.botHelper.rollChanceToBePmc( + requestedBot.Role, + botConvertRateMinMax, + raidSettings?.location, + ); if (convertToPmc) { botGenerationDetails.isPmc = true; botGenerationDetails.role = this.botHelper.getRandomizedPmcRole(); diff --git a/project/src/helpers/BotHelper.ts b/project/src/helpers/BotHelper.ts index 5683db57..5138cb5f 100644 --- a/project/src/helpers/BotHelper.ts +++ b/project/src/helpers/BotHelper.ts @@ -92,13 +92,22 @@ export class BotHelper { } } - public rollChanceToBePmc(role: string, botConvertMinMax: MinMax): boolean { + public rollChanceToBePmc(role: string, botConvertMinMax: MinMax, location: string): boolean { return ( - role.toLowerCase() in this.pmcConfig.convertIntoPmcChance && + role.toLowerCase() in this.getPmcConversionValuesForLocation(location) && this.randomUtil.getChance100(this.randomUtil.getInt(botConvertMinMax.min, botConvertMinMax.max)) ); } + protected getPmcConversionValuesForLocation(location: string) { + const result = this.pmcConfig.convertIntoPmcChance[location.toLowerCase()]; + if (!result) { + this.pmcConfig.convertIntoPmcChance.default; + } + + return result; + } + /** * is the provided role a PMC, case-agnostic * @param botRole Role to check