Cleanup nations (Part 1) 🧹 (#2637)

## Description:

1. Using the wording `"Nation"`, `"FakeHuman"` and `"NPC"` at the same
time is confusing.
So I renamed every mention of `"FakeHuman"` and `"NPC"` in the entire
project to `"Nation"`. Just like they are called ingame.

2. `BotBehavior.ts` was originally intended for sharing the logic
between nations and bots.
But at the moment, the logic there isn't really shared and it's
basically just about attacking.
So I renamed `BotBehavior.ts` to `AiAttackBehavior.ts`. I use "Ai" to
indicate that this file is used by bots AND nations.

3. Moved `execuction/utils/AllianceBehavior.ts` to
`execuction/nation/NationAllianceBehavior.ts` to make sure everybody
understands that this file is not about alliances in general. It's just
about nations and how they handle alliances.

4. Removed `difficultyModifier` from `DefaultConfig`. It's unused and I
think we usually want to finetune the difficulty instead of using that
method.

5. Added `assertNever` in all `switch (difficulty)` default cases.

## Please complete the following:

- [X] I have added screenshots for all UI updates
- [X] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [X] I have added relevant tests to the test directory
- [X] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:

FloPinguin
This commit is contained in:
FloPinguin
2025-12-18 16:20:23 -08:00
committed by GitHub
parent f60aef65e1
commit 4d5bb7a835
26 changed files with 290 additions and 278 deletions
+1 -3
View File
@@ -1,7 +1,6 @@
import { Colord } from "colord";
import { JWK } from "jose";
import {
Difficulty,
Game,
GameMapType,
GameMode,
@@ -82,7 +81,7 @@ export interface Config {
theme(): Theme;
percentageTilesOwnedToWin(): number;
numBots(): number;
spawnNPCs(): boolean;
spawnNations(): boolean;
isUnitDisabled(unitType: UnitType): boolean;
bots(): number;
infiniteGold(): boolean;
@@ -159,7 +158,6 @@ export interface Config {
defensePostDefenseBonus(): number;
defensePostSpeedBonus(): number;
falloutDefenseModifier(percentOfFallout: number): number;
difficultyModifier(difficulty: Difficulty): number;
warshipPatrolRange(): number;
warshipShellAttackRate(): number;
warshipTargettingRange(): number;
+13 -20
View File
@@ -287,19 +287,6 @@ export class DefaultConfig implements Config {
return this._userSettings;
}
difficultyModifier(difficulty: Difficulty): number {
switch (difficulty) {
case Difficulty.Easy:
return 1;
case Difficulty.Medium:
return 3;
case Difficulty.Hard:
return 9;
case Difficulty.Impossible:
return 18;
}
}
cityTroopIncrease(): number {
return 250_000;
}
@@ -332,8 +319,8 @@ export class DefaultConfig implements Config {
return this._gameConfig.playerTeams ?? 0;
}
spawnNPCs(): boolean {
return !this._gameConfig.disableNPCs;
spawnNations(): boolean {
return !this._gameConfig.disableNations;
}
isUnitDisabled(unitType: UnitType): boolean {
@@ -712,7 +699,7 @@ export class DefaultConfig implements Config {
mag *= 0.8;
}
if (
attacker.type() === PlayerType.FakeHuman &&
attacker.type() === PlayerType.Nation &&
defender.type() === PlayerType.Bot
) {
mag *= 0.8;
@@ -816,9 +803,9 @@ export class DefaultConfig implements Config {
}
useNationStrengthForStartManpower(): boolean {
// Currently disabled: FakeHumans became harder to play against due to AI improvements
// Currently disabled: Nations became harder to play against due to AI improvements
// nation strength multiplier was unintentionally disabled during those AI improvements (playerInfo.nation was undefined),
// Re-enabling this without rebalancing FakeHuman difficulty elsewhere may make them overpowered
// Re-enabling this without rebalancing Nation difficulty elsewhere may make them overpowered
return false;
}
@@ -826,7 +813,7 @@ export class DefaultConfig implements Config {
if (playerInfo.playerType === PlayerType.Bot) {
return 10_000;
}
if (playerInfo.playerType === PlayerType.FakeHuman) {
if (playerInfo.playerType === PlayerType.Nation) {
const strength = this.useNationStrengthForStartManpower()
? (playerInfo.nationStrength ?? 1)
: 1;
@@ -840,6 +827,8 @@ export class DefaultConfig implements Config {
return 31_250 * strength;
case Difficulty.Impossible:
return 37_500 * strength;
default:
assertNever(this._gameConfig.difficulty);
}
}
return this.infiniteTroops() ? 1_000_000 : 25_000;
@@ -873,6 +862,8 @@ export class DefaultConfig implements Config {
return maxTroops * 1.25;
case Difficulty.Impossible:
return maxTroops * 1.5;
default:
assertNever(this._gameConfig.difficulty);
}
}
@@ -888,7 +879,7 @@ export class DefaultConfig implements Config {
toAdd *= 0.6;
}
if (player.type() === PlayerType.FakeHuman) {
if (player.type() === PlayerType.Nation) {
switch (this._gameConfig.difficulty) {
case Difficulty.Easy:
toAdd *= 0.95;
@@ -902,6 +893,8 @@ export class DefaultConfig implements Config {
case Difficulty.Impossible:
toAdd *= 1.1;
break;
default:
assertNever(this._gameConfig.difficulty);
}
}