From c36a4b4e607b8b23d2bc89eeb03f83f53fd34ed2 Mon Sep 17 00:00:00 2001 From: Restart2008 Date: Thu, 23 Oct 2025 15:02:29 -0700 Subject: [PATCH] Update DefaultConfig.ts Simplified threshold logic using a lookup table --- src/core/configuration/DefaultConfig.ts | 59 +++++++++++-------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/src/core/configuration/DefaultConfig.ts b/src/core/configuration/DefaultConfig.ts index bf5772ec4..b1ea004c2 100644 --- a/src/core/configuration/DefaultConfig.ts +++ b/src/core/configuration/DefaultConfig.ts @@ -623,42 +623,37 @@ export class DefaultConfig implements Config { ? this.pastelThemeDark : this.pastelTheme; } + largeAttackerSpeedThresholdDebuff(attacker: Player, totalLandTiles: number): number { const territoryPercentage = (attacker.numTilesOwned() / totalLandTiles) * 100; - if (territoryPercentage < 10) { - return 1.0; - } else if (territoryPercentage < 15) { - return 0.50; - } else if (territoryPercentage < 20) { - return 0.38; - } else if (territoryPercentage < 25) { - return 0.28; - } else if (territoryPercentage < 30) { - return 0.20; - } else if (territoryPercentage < 35) { - return 0.14; - } else if (territoryPercentage < 40) { - return 0.10; - } else if (territoryPercentage < 45) { - return 0.07; - } else if (territoryPercentage < 50) { - return 0.05; - } else if (territoryPercentage < 55) { - return 0.04; - } else if (territoryPercentage < 60) { - return 0.03; - } else if (territoryPercentage < 65) { - return 0.02; - } else if (territoryPercentage < 70) { - return 0.015; - } else if (territoryPercentage < 75) { - return 0.01; - } else if (territoryPercentage < 80) { - return 0.007; - } else { - return 0.005; + const thresholds: Array<{ max: number; value: number }> = [ + { max: 10, value: 1.0 }, + { max: 15, value: 0.50 }, + { max: 20, value: 0.38 }, + { max: 25, value: 0.28 }, + { max: 30, value: 0.20 }, + { max: 35, value: 0.14 }, + { max: 40, value: 0.10 }, + { max: 45, value: 0.07 }, + { max: 50, value: 0.05 }, + { max: 55, value: 0.04 }, + { max: 60, value: 0.03 }, + { max: 65, value: 0.02 }, + { max: 70, value: 0.015 }, + { max: 75, value: 0.01 }, + { max: 80, value: 0.007 }, + ]; + + for (const threshold of thresholds) { + if (territoryPercentage < threshold.max) { + return threshold.value; + } } + + return 0.005; +} + } attackLogic( gm: Game,