This commit is contained in:
Scott Anderson
2025-04-14 17:58:38 -04:00
parent b38e6a845d
commit 5e9819a973
20 changed files with 161 additions and 145 deletions
+31 -27
View File
@@ -25,7 +25,7 @@ import { pastelThemeDark } from "./PastelThemeDark";
export abstract class DefaultServerConfig implements ServerConfig {
region(): string {
if (this.env() == GameEnv.Dev) {
if (this.env() === GameEnv.Dev) {
return "dev";
}
return process.env.REGION ?? "undefined";
@@ -104,7 +104,7 @@ export abstract class DefaultServerConfig implements ServerConfig {
return Math.random() < 0.2 ? 60 : 35;
}
// world belongs with the ~2 mils, but these amounts never made sense so I assume the insanity is intended.
if (map == GameMapType.World) {
if (map === GameMapType.World) {
return Math.random() < 0.2 ? 150 : 60;
}
// default return for non specified map
@@ -229,7 +229,7 @@ export class DefaultConfig implements Config {
case UnitType.Warship:
return {
cost: (p: Player) =>
p.type() == PlayerType.Human && this.infiniteGold()
p.type() === PlayerType.Human && this.infiniteGold()
? 0
: Math.min(
1_000_000,
@@ -253,7 +253,7 @@ export class DefaultConfig implements Config {
case UnitType.Port:
return {
cost: (p: Player) =>
p.type() == PlayerType.Human && this.infiniteGold()
p.type() === PlayerType.Human && this.infiniteGold()
? 0
: Math.min(
1_000_000,
@@ -268,19 +268,21 @@ export class DefaultConfig implements Config {
case UnitType.AtomBomb:
return {
cost: (p: Player) =>
p.type() == PlayerType.Human && this.infiniteGold() ? 0 : 750_000,
p.type() === PlayerType.Human && this.infiniteGold() ? 0 : 750_000,
territoryBound: false,
};
case UnitType.HydrogenBomb:
return {
cost: (p: Player) =>
p.type() == PlayerType.Human && this.infiniteGold() ? 0 : 5_000_000,
p.type() === PlayerType.Human && this.infiniteGold()
? 0
: 5_000_000,
territoryBound: false,
};
case UnitType.MIRV:
return {
cost: (p: Player) =>
p.type() == PlayerType.Human && this.infiniteGold()
p.type() === PlayerType.Human && this.infiniteGold()
? 0
: 25_000_000,
territoryBound: false,
@@ -298,14 +300,16 @@ export class DefaultConfig implements Config {
case UnitType.MissileSilo:
return {
cost: (p: Player) =>
p.type() == PlayerType.Human && this.infiniteGold() ? 0 : 1_000_000,
p.type() === PlayerType.Human && this.infiniteGold()
? 0
: 1_000_000,
territoryBound: true,
constructionDuration: this.instantBuild() ? 0 : 10 * 10,
};
case UnitType.DefensePost:
return {
cost: (p: Player) =>
p.type() == PlayerType.Human && this.infiniteGold()
p.type() === PlayerType.Human && this.infiniteGold()
? 0
: Math.min(
250_000,
@@ -319,7 +323,7 @@ export class DefaultConfig implements Config {
case UnitType.SAMLauncher:
return {
cost: (p: Player) =>
p.type() == PlayerType.Human && this.infiniteGold()
p.type() === PlayerType.Human && this.infiniteGold()
? 0
: Math.min(
1_500_000 * 3,
@@ -333,7 +337,7 @@ export class DefaultConfig implements Config {
case UnitType.City:
return {
cost: (p: Player) =>
p.type() == PlayerType.Human && this.infiniteGold()
p.type() === PlayerType.Human && this.infiniteGold()
? 0
: Math.min(
2_000_000,
@@ -379,7 +383,7 @@ export class DefaultConfig implements Config {
return 600 * 10; // 10 minutes.
}
percentageTilesOwnedToWin(): number {
if (this._gameConfig.gameMode == GameMode.Team) {
if (this._gameConfig.gameMode === GameMode.Team) {
return 95;
}
return 80;
@@ -388,7 +392,7 @@ export class DefaultConfig implements Config {
return 3;
}
numSpawnPhaseTurns(): number {
return this._gameConfig.gameType == GameType.Singleplayer ? 100 : 300;
return this._gameConfig.gameType === GameType.Singleplayer ? 100 : 300;
}
numBots(): number {
return this.bots();
@@ -433,7 +437,7 @@ export class DefaultConfig implements Config {
gm.config().defensePostRange(),
UnitType.DefensePost,
)) {
if (dp.unit.owner() == defender) {
if (dp.unit.owner() === defender) {
mag *= this.defensePostDefenseBonus();
speed *= this.defensePostDefenseBonus();
break;
@@ -449,14 +453,14 @@ export class DefaultConfig implements Config {
if (attacker.isPlayer() && defender.isPlayer()) {
if (
attacker.type() == PlayerType.Human &&
defender.type() == PlayerType.Bot
attacker.type() === PlayerType.Human &&
defender.type() === PlayerType.Bot
) {
mag *= 0.8;
}
if (
attacker.type() == PlayerType.FakeHuman &&
defender.type() == PlayerType.Bot
attacker.type() === PlayerType.FakeHuman &&
defender.type() === PlayerType.Bot
) {
mag *= 0.8;
}
@@ -489,7 +493,7 @@ export class DefaultConfig implements Config {
} else {
return {
attackerTroopLoss:
attacker.type() == PlayerType.Bot ? mag / 10 : mag / 5,
attacker.type() === PlayerType.Bot ? mag / 10 : mag / 5,
defenderTroopLoss: 0,
tilesPerTickUsed: within(
(2000 * Math.max(10, speed)) / attackTroops,
@@ -534,7 +538,7 @@ export class DefaultConfig implements Config {
}
attackAmount(attacker: Player, defender: Player | TerraNullius) {
if (attacker.type() == PlayerType.Bot) {
if (attacker.type() === PlayerType.Bot) {
return attacker.troops() / 20;
} else {
return attacker.troops() / 5;
@@ -542,10 +546,10 @@ export class DefaultConfig implements Config {
}
startManpower(playerInfo: PlayerInfo): number {
if (playerInfo.playerType == PlayerType.Bot) {
if (playerInfo.playerType === PlayerType.Bot) {
return 10_000;
}
if (playerInfo.playerType == PlayerType.FakeHuman) {
if (playerInfo.playerType === PlayerType.FakeHuman) {
switch (this._gameConfig.difficulty) {
case Difficulty.Easy:
return 2_500 * (playerInfo?.nation?.strength ?? 1);
@@ -562,16 +566,16 @@ export class DefaultConfig implements Config {
maxPopulation(player: Player | PlayerView): number {
const maxPop =
player.type() == PlayerType.Human && this.infiniteTroops()
player.type() === PlayerType.Human && this.infiniteTroops()
? 1_000_000_000
: 2 * (Math.pow(player.numTilesOwned(), 0.6) * 1000 + 50000) +
player.units(UnitType.City).length * this.cityPopulationIncrease();
if (player.type() == PlayerType.Bot) {
if (player.type() === PlayerType.Bot) {
return maxPop / 2;
}
if (player.type() == PlayerType.Human) {
if (player.type() === PlayerType.Human) {
return maxPop;
}
@@ -595,11 +599,11 @@ export class DefaultConfig implements Config {
const ratio = 1 - player.population() / max;
toAdd *= ratio;
if (player.type() == PlayerType.Bot) {
if (player.type() === PlayerType.Bot) {
toAdd *= 0.7;
}
if (player.type() == PlayerType.FakeHuman) {
if (player.type() === PlayerType.FakeHuman) {
switch (this._gameConfig.difficulty) {
case Difficulty.Easy:
toAdd *= 0.9;