Add tribe name themes system with custom tribes support 🏰 (#4647)

## Description:

Adds a theme system for bot tribe names that maps can customize via
their info.json. Instead of all bots using the same global name pool,
maps can now specify one or more themed name sets and define custom
tribe names with higher priority.

Key changes:
- New `src/core/execution/utils/tribeNameThemes.json` containing 17
themed name sets (default, north_america, south_america, europe, africa,
asia, oceania, space, fantasy, war, western, under_ocean, tournament,
funny, scary, weird, vs). The default theme preserves the original
`TribeNames.ts` values. **Mappers are encouraged to change that json
file, the new themes just serve as an example and are currently not used
by any map.**
- Maps can specify `"themes": ["europe", "war"]` in info.json to merge
prefixes/suffixes from multiple themes into one name pool.
- Maps can specify `"custom_tribes": ["Holy Roman Empire", "Kalmar
Union"]` for exact tribe names that take priority over theme-generated
names. Custom tribes are used first (random selection, no duplicates
until exhausted), then theme-based prefix+suffix combos.
- `TribeNameResolver` resolves themes per-map at runtime, with fallback
to the default theme and a console warning for unknown theme names.
- Go codegen (`codegen.go`) updated to propagate `themes` and
`custom_tribes` from info.json to Maps.gen.ts.
- Germany map now has 404 custom tribes (all German Landkreise and
kreisfreie Städte) to showcase the new feature.
- Fixed a bug where tribe bots could inherit nation flags if their
random name coincidentally matched a nation name (name-based cosmetics
lookup now only applies to actual Nations, not Bots).

## 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

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

FloPinguin
This commit is contained in:
FloPinguin
2026-07-19 18:46:51 -07:00
committed by GitHub
parent 9c14ab04e0
commit d9976babbd
12 changed files with 3132 additions and 262 deletions
+6 -1
View File
@@ -3,6 +3,7 @@ import {
Cell,
GameUpdates,
PlayerID,
PlayerType,
TerrainType,
TerraNullius,
Tick,
@@ -376,8 +377,12 @@ export class GameView implements GameMap {
pu,
gu.playerNameViewData?.[pu.id],
// First check human by clientID, then check nation by name.
// Only match by name for actual Nations — not Bots (tribes) whose
// random names may coincidentally match a nation name.
this._cosmetics.get(pu.clientID ?? "") ??
this._cosmetics.get(pu.name!) ??
(pu.playerType === PlayerType.Nation
? this._cosmetics.get(pu.name!)
: undefined) ??
{},
);
this._players.set(pu.id, player);
+5 -9
View File
@@ -13,10 +13,7 @@ import {
Winner,
} from "./Schemas";
import {
TRIBE_NAME_PREFIXES,
TRIBE_NAME_SUFFIXES,
} from "./execution/utils/TribeNames";
import { resolveTribeNameData } from "./execution/utils/TribeNames";
export function manhattanDistWrapped(
c1: Cell,
@@ -366,13 +363,12 @@ export function createRandomName(
): string | null {
let randomName: string | null = null;
if (playerType === PlayerType.Human) {
const { prefixes, suffixes } = resolveTribeNameData();
const hash = simpleHash(name);
const prefixIndex = hash % TRIBE_NAME_PREFIXES.length;
const suffixIndex =
Math.floor(hash / TRIBE_NAME_PREFIXES.length) %
TRIBE_NAME_SUFFIXES.length;
const prefixIndex = hash % prefixes.length;
const suffixIndex = Math.floor(hash / prefixes.length) % suffixes.length;
randomName = `👤 ${TRIBE_NAME_PREFIXES[prefixIndex]} ${TRIBE_NAME_SUFFIXES[suffixIndex]}`;
randomName = `👤 ${prefixes[prefixIndex]} ${suffixes[suffixIndex]}`;
}
return randomName;
}
+23 -4
View File
@@ -3,10 +3,12 @@ import { PseudoRandom } from "../PseudoRandom";
import { GameID } from "../Schemas";
import { simpleHash } from "../Util";
import { SpawnExecution } from "./SpawnExecution";
import { TRIBE_NAME_PREFIXES, TRIBE_NAME_SUFFIXES } from "./utils/TribeNames";
import { type TribeNameData, resolveTribeNameData } from "./utils/TribeNames";
export class TribeSpawner {
private random: PseudoRandom;
private tribeNameData: TribeNameData;
private usedCustomTribes: Set<string> = new Set();
constructor(
private gs: Game,
@@ -15,6 +17,7 @@ export class TribeSpawner {
// Use a different seed than createGameRunner (which uses simpleHash(gameID))
// to avoid tribe IDs colliding with nation/human IDs from the same PRNG sequence.
this.random = new PseudoRandom(simpleHash(gameID) + 2);
this.tribeNameData = resolveTribeNameData(gs.config().gameConfig().gameMap);
}
spawnTribes(numTribes: number): SpawnExecution[] {
@@ -33,8 +36,24 @@ export class TribeSpawner {
}
private randomTribeName(): string {
const prefixIndex = this.random.nextInt(0, TRIBE_NAME_PREFIXES.length);
const suffixIndex = this.random.nextInt(0, TRIBE_NAME_SUFFIXES.length);
return `${TRIBE_NAME_PREFIXES[prefixIndex]} ${TRIBE_NAME_SUFFIXES[suffixIndex]}`;
const { customTribes, prefixes, suffixes } = this.tribeNameData;
// Use custom tribes first (random selection, no duplicates until exhausted).
if (customTribes !== undefined) {
const available = customTribes.filter(
(name) => !this.usedCustomTribes.has(name),
);
if (available.length > 0) {
const index = this.random.nextInt(0, available.length);
const chosen = available[index];
this.usedCustomTribes.add(chosen);
return chosen;
}
}
// Fall back to theme-based prefix + suffix names.
const prefixIndex = this.random.nextInt(0, prefixes.length);
const suffixIndex = this.random.nextInt(0, suffixes.length);
return `${prefixes[prefixIndex]} ${suffixes[suffixIndex]}`;
}
}
+88 -248
View File
@@ -1,248 +1,88 @@
export const TRIBE_NAME_PREFIXES = [
"Akkadian",
"Babylonian",
"Sumerian",
"Hittite",
"Phoenician",
"Canaanite",
"Minoan",
"Mycenaean",
"Etruscan",
"Scythian",
"Thracian",
"Dacian",
"Illyrian",
"Median",
"Chaldean",
"Roman",
"Greek",
"Byzantine",
"Persian",
"Parthian",
"Seleucid",
"Ptolemaic",
"Palmyrene",
"Macedonian",
"Carthaginian",
"Ming",
"Tang",
"Song",
"Yuan",
"Mauryan",
"Kushan",
"Rajput",
"Mughal",
"Satavahana",
"Vijayanagara",
"Egyptian",
"Nubian",
"Kushite",
"Aksumite",
"Ethiopian",
"Songhai",
"Malian",
"Ghanaian",
"Benin",
"Ashanti",
"Zulu",
"Tuareg",
"Berber",
"Kanem-Bornu",
"Buganda",
"Mossi",
"Swahili",
"Somali",
"Wolof",
"Umayyad",
"Abbasid",
"Ayyubid",
"Fatimid",
"Mamluk",
"Seljuk",
"Safavid",
"Ottoman",
"Almoravid",
"Almohad",
"Rashidun",
"Ziyarid",
"Frankish",
"Visigothic",
"Ostrogothic",
"Viking",
"Norman",
"Saxon",
"Anglo-Saxon",
"Celtic",
"Gaulish",
"Carolingian",
"Merovingian",
"Capetian",
"Plantagenet",
"Tudor",
"Stuart",
"Habsburg",
"Romanov",
"Lancaster",
"York",
"Bourbon",
"Napoleonic",
"British",
"French",
"Spanish",
"Portuguese",
"Dutch",
"Russian",
"German",
"Italian",
"Swedish",
"Norwegian",
"Danish",
"Polish",
"Hungarian",
"Austrian",
"Swiss",
"Czech",
"Slovak",
"Serbian",
"Croatian",
"Bosnian",
"Montenegrin",
"Bulgarian",
"Romanian",
"Apache",
"Sioux",
"Cherokee",
"Navajo",
"Iroquois",
"Inuit",
"Arawak",
"Carib",
"Taino",
"Aztec",
"Mayan",
"Incan",
"Mapuche",
"Guarani",
"Tupi",
"Yanomami",
"Zuni",
"Hopi",
"Kiowa",
"Comanche",
"Shoshone",
"Japanese",
"Ryukyu",
"Ainu",
"Cham",
"Khmer",
"Thai",
"Vietnamese",
"Burmese",
"Balinese",
"Malay",
"Filipino",
"Mongolian",
"Korean",
"Tibetan",
"Manchu",
"Uyghur",
"Hmong",
"Karen",
"Pyu",
"Hawaiian",
"Fijian",
"Tongan",
"Samoan",
"Maori",
"Micronesian",
"Hebrew",
"Armenian",
"Circassian",
"Georgian",
"Kurdish",
"Turkic",
"Kazakh",
"Uzbek",
"Kyrgyz",
"Tajik",
"Uighur",
"Pashtun",
"Baloch",
"Afghan",
"Kenyan",
"Ugandan",
"Bhutanese",
"Latin",
"Moldovan",
"Militant",
"Spartan",
];
export const TRIBE_NAME_SUFFIXES = [
"Empire",
"Dynasty",
"Kingdom",
"Queendom",
"Sultanate",
"Confederation",
"Union",
"Republic",
"Caliphate",
"Dominion",
"Realm",
"State",
"Federation",
"Territory",
"Commonwealth",
"League",
"Duchy",
"Province",
"Protectorate",
"Colony",
"Mandate",
"Free State",
"Canton",
"Region",
"Nation",
"Assembly",
"Hierarchy",
"Archduchy",
"Grand Duchy",
"Metropolis",
"Cluster",
"Alliance",
"Tribunal",
"Council",
"Confederacy",
"Order",
"Regime",
"Syndicate",
"Guild",
"Corporation",
"Patriarchy",
"Matriarchy",
"Legion",
"Horde",
"Clan",
"Brotherhood",
"Sisterhood",
"Ascendancy",
"Supremacy",
"Tribe",
"Republics",
"Army",
"Dictatorship",
"Country",
"Oligarchy",
"Monkdom",
"Throng",
"Host",
"Area",
"District",
"Fief",
"Wilderness",
"Settlement",
"Parliament",
"Anarchy",
"Democracy",
"Autocracy",
];
import tribeNameThemesData from "resources/tribeNameThemes.json";
import { GameMapType, type MapInfo, maps } from "../../game/Maps.gen";
export interface TribeNameData {
prefixes: string[];
suffixes: string[];
customTribes?: string[];
}
interface TribeNameTheme {
prefixes: string[];
suffixes: string[];
}
const tribeNameThemes: Record<string, TribeNameTheme> = tribeNameThemesData;
/** Look up MapInfo by GameMapType. */
function getMapInfo(mapType: GameMapType): MapInfo | undefined {
return maps.find((m) => m.type === mapType);
}
/**
* Resolve tribe name data for a given map type.
*
* Priority:
* 1. Custom tribes from the map's info.json (used as-is, no prefix/suffix)
* 2. Theme-based names (prefix + suffix) from the referenced theme
* 3. Default theme if no theme is specified or the referenced theme is missing
*/
export function resolveTribeNameData(mapType?: GameMapType): TribeNameData {
if (mapType !== undefined) {
const mapInfo = getMapInfo(mapType);
if (mapInfo !== undefined) {
const themeNames =
mapInfo.themes !== undefined && mapInfo.themes.length > 0
? mapInfo.themes
: ["default"];
const mergedPrefixes: string[] = [];
const mergedSuffixes: string[] = [];
for (const themeName of themeNames) {
const theme = tribeNameThemes[themeName];
if (theme === undefined) {
console.warn(
`[TribeNames] Map "${mapType}" references unknown tribe name theme "${themeName}". Skipping.`,
);
continue;
}
mergedPrefixes.push(...theme.prefixes);
mergedSuffixes.push(...theme.suffixes);
}
// If all themes were unknown, fall back to default.
if (mergedPrefixes.length === 0 || mergedSuffixes.length === 0) {
const defaultTheme = tribeNameThemes["default"];
if (defaultTheme === undefined) {
throw new Error(
"[TribeNames] Default theme is missing from tribeNameThemes.json",
);
}
mergedPrefixes.push(...defaultTheme.prefixes);
mergedSuffixes.push(...defaultTheme.suffixes);
}
return {
prefixes: mergedPrefixes,
suffixes: mergedSuffixes,
customTribes:
mapInfo.customTribes !== undefined && mapInfo.customTribes.length > 0
? mapInfo.customTribes
: undefined,
};
}
}
// No map type or map not found — use default theme.
const defaultTheme = tribeNameThemes["default"];
if (defaultTheme === undefined) {
throw new Error(
"[TribeNames] Default theme is missing from tribeNameThemes.json",
);
}
return {
prefixes: defaultTheme.prefixes,
suffixes: defaultTheme.suffixes,
};
}
+414
View File
@@ -167,6 +167,10 @@ export interface MapInfo {
featuredRank?: number;
/** Preferred team count in team/special games (see MapPlaylist). */
specialTeamCount?: number;
/** Tribe name theme(s) (keys in tribeNameThemes.json). */
themes?: string[];
/** Custom tribe names with priority over theme-generated names. */
customTribes?: string[];
}
export const maps: readonly MapInfo[] = [
@@ -469,6 +473,416 @@ export const maps: readonly MapInfo[] = [
translationKey: "map.germany",
categories: ["europe", "new"],
multiplayerFrequency: 5,
customTribes: [
"Aachen, Städteregion",
"Ahrweiler",
"Aichach-Friedberg",
"Alb-Donau-Kreis",
"Altenburger Land",
"Altenkirchen (Westerwald)",
"Altmarkkreis Salzwedel",
"Altötting",
"Alzey-Worms",
"Amberg-Sulzbach",
"Ammerland",
"Anhalt-Bitterfeld",
"Ansbach",
"Aschaffenburg",
"Augsburg",
"Aurich",
"Bad Dürkheim",
"Bad Kissingen",
"Bad Kreuznach",
"Bad Tölz-Wolfratshausen",
"Bamberg",
"Barnim",
"Bautzen",
"Bayreuth",
"Berchtesgadener Land",
"Bergstraße",
"Bernkastel-Wittlich",
"Biberach",
"Birkenfeld",
"Böblingen",
"Bodenseekreis",
"Börde",
"Borken",
"Breisgau-Hochschwarzwald",
"Burgenlandkreis",
"Calw",
"Celle",
"Cham",
"Cloppenburg",
"Coburg",
"Cochem-Zell",
"Coesfeld",
"Cuxhaven",
"Dachau",
"Dahme-Spreewald",
"Darmstadt-Dieburg",
"Deggendorf",
"Diepholz",
"Dillingen an der Donau",
"Dingolfing-Landau",
"Dithmarschen",
"Donau-Ries",
"Donnersbergkreis",
"Düren",
"Ebersberg",
"Eichsfeld",
"Eichstätt",
"Eifelkreis Bitburg-Prüm",
"Elbe-Elster",
"Emmendingen",
"Emsland",
"Ennepe-Ruhr-Kreis",
"Enzkreis",
"Erding",
"Erlangen-Höchstadt",
"Erzgebirgskreis",
"Esslingen",
"Euskirchen",
"Forchheim",
"Freising",
"Freudenstadt",
"Freyung-Grafenau",
"Friesland",
"Fulda",
"Fürstenfeldbruck",
"Fürth",
"Garmisch-Partenkirchen",
"Germersheim",
"Gießen",
"Gifhorn",
"Göppingen",
"Görlitz",
"Goslar",
"Gotha",
"Göttingen",
"Grafschaft Bentheim",
"Greiz",
"Groß-Gerau",
"Günzburg",
"Gütersloh",
"Hameln-Pyrmont",
"Hannover, Region",
"Harburg",
"Harz",
"Haßberge",
"Havelland",
"Heidekreis",
"Heidenheim",
"Heilbronn",
"Heinsberg",
"Helmstedt",
"Herford",
"Hersfeld-Rotenburg",
"Herzogtum Lauenburg",
"Hildburghausen",
"Hildesheim",
"Hochsauerlandkreis",
"Hochtaunuskreis",
"Hof",
"Hohenlohekreis",
"Holzminden",
"Höxter",
"Ilm-Kreis",
"Jerichower Land",
"Kaiserslautern",
"Karlsruhe",
"Kassel",
"Kelheim",
"Kitzingen",
"Kleve",
"Konstanz",
"Kronach",
"Kulmbach",
"Kusel",
"Kyffhäuserkreis",
"Lahn-Dill-Kreis",
"Landsberg am Lech",
"Landshut",
"Leer",
"Leipzig",
"Lichtenfels",
"Limburg-Weilburg",
"Lindau (Bodensee)",
"Lippe",
"Lörrach",
"Lüchow-Dannenberg",
"Ludwigsburg",
"Ludwigslust-Parchim",
"Lüneburg",
"Main-Kinzig-Kreis",
"Main-Spessart",
"Main-Tauber-Kreis",
"Main-Taunus-Kreis",
"Mainz-Bingen",
"Mansfeld-Südharz",
"Marburg-Biedenkopf",
"Märkischer Kreis",
"Märkisch-Oderland",
"Mayen-Koblenz",
"Mecklenburgische Seenplatte",
"Meißen",
"Merzig-Wadern",
"Mettmann",
"Miesbach",
"Miltenberg",
"Minden-Lübbecke",
"Mittelsachsen",
"Mühldorf am Inn",
"München",
"Neckar-Odenwald-Kreis",
"Neu-Ulm",
"Neuburg-Schrobenhausen",
"Neumarkt in der Oberpfalz",
"Neunkirchen",
"Neustadt an der Aisch-Bad Windsheim",
"Neustadt an der Waldnaab",
"Neuwied",
"Nienburg/Weser",
"Nordfriesland",
"Nordhausen",
"Nordsachsen",
"Nordwestmecklenburg",
"Northeim",
"Nürnberger Land",
"Oberallgäu",
"Oberbergischer Kreis",
"Oberhavel",
"Oberspreewald-Lausitz",
"Odenwaldkreis",
"Oder-Spree",
"Offenbach",
"Oldenburg",
"Olpe",
"Ortenaukreis",
"Osnabrück",
"Ostalbkreis",
"Ostallgäu",
"Osterholz",
"Ostholstein",
"Ostprignitz-Ruppin",
"Paderborn",
"Passau",
"Peine",
"Pfaffenhofen an der Ilm",
"Pinneberg",
"Plön",
"Potsdam-Mittelmark",
"Prignitz",
"Rastatt",
"Ravensburg",
"Recklinghausen",
"Regen",
"Regensburg",
"Rems-Murr-Kreis",
"Rendsburg-Eckernförde",
"Reutlingen",
"Rhein-Erft-Kreis",
"Rheingau-Taunus-Kreis",
"Rhein-Hunsrück-Kreis",
"Rheinisch-Bergischer Kreis",
"Rhein-Kreis Neuss",
"Rhein-Lahn-Kreis",
"Rhein-Neckar-Kreis",
"Rhein-Pfalz-Kreis",
"Rhein-Sieg-Kreis",
"Rhön-Grabfeld",
"Rosenheim",
"Rostock",
"Rotenburg (Wümme)",
"Roth",
"Rottal-Inn",
"Rottweil",
"Saale-Holzland-Kreis",
"Saalekreis",
"Saale-Orla-Kreis",
"Saalfeld-Rudolstadt",
"Saarbrücken, Regionalverband",
"Saarlouis",
"Saarpfalz-Kreis",
"Sächsische Schweiz-Osterzgebirge",
"Salzlandkreis",
"Schaumburg",
"Schleswig-Flensburg",
"Schmalkalden-Meiningen",
"Schwäbisch Hall",
"Schwalm-Eder-Kreis",
"Schwandorf",
"Schwarzwald-Baar-Kreis",
"Schweinfurt",
"Segeberg",
"Siegen-Wittgenstein",
"Sigmaringen",
"Soest",
"Sömmerda",
"Sonneberg",
"Spree-Neiße",
"St. Wendel",
"Stade",
"Starnberg",
"Steinburg",
"Steinfurt",
"Stendal",
"Stormarn",
"Straubing-Bogen",
"Südliche Weinstraße",
"Südwestpfalz",
"Teltow-Fläming",
"Tirschenreuth",
"Traunstein",
"Trier-Saarburg",
"Tübingen",
"Tuttlingen",
"Uckermark",
"Uelzen",
"Unna",
"Unstrut-Hainich-Kreis",
"Unterallgäu",
"Vechta",
"Verden",
"Viersen",
"Vogelsbergkreis",
"Vogtlandkreis",
"Vorpommern-Greifswald",
"Vorpommern-Rügen",
"Vulkaneifel",
"Waldeck-Frankenberg",
"Waldshut",
"Warendorf",
"Wartburgkreis",
"Weilheim-Schongau",
"Weimarer Land",
"Weißenburg-Gunzenhausen",
"Werra-Meißner-Kreis",
"Wesel",
"Wesermarsch",
"Westerwaldkreis",
"Wetteraukreis",
"Wittenberg",
"Wittmund",
"Wolfenbüttel",
"Wunsiedel im Fichtelgebirge",
"Würzburg",
"Zollernalbkreis",
"Zwickau",
"Aachen",
"Amberg",
"Baden-Baden",
"Bielefeld",
"Bochum",
"Bonn",
"Bottrop",
"Brandenburg an der Havel",
"Braunschweig",
"Bremerhaven",
"Chemnitz",
"Cottbus",
"Darmstadt",
"Delmenhorst",
"Dessau-Roßlau",
"Dortmund",
"Dresden",
"Duisburg",
"Düsseldorf",
"Emden",
"Erfurt",
"Erlangen",
"Essen",
"Flensburg",
"Frankenthal (Pfalz)",
"Frankfurt (Oder)",
"Frankfurt am Main",
"Freiburg im Breisgau",
"Gelsenkirchen",
"Gera",
"Hagen",
"Halle (Saale)",
"Hamm",
"Hanau",
"Hannover",
"Heidelberg",
"Herne",
"Ingolstadt",
"Jena",
"Kaufbeuren",
"Kempten (Allgäu)",
"Kiel",
"Koblenz",
"Köln",
"Krefeld",
"Landau in der Pfalz",
"Leverkusen",
"Lübeck",
"Ludwigshafen am Rhein",
"Magdeburg",
"Mainz",
"Mannheim",
"Memmingen",
"Mönchengladbach",
"Mülheim an der Ruhr",
"Münster",
"Neumünster",
"Neustadt an der Weinstraße",
"Nürnberg",
"Oberhausen",
"Offenbach am Main",
"Oldenburg (Oldb)",
"Pforzheim",
"Pirmasens",
"Potsdam",
"Remscheid",
"Salzgitter",
"Schwabach",
"Schwerin",
"Solingen",
"Speyer",
"Straubing",
"Stuttgart",
"Suhl",
"Trier",
"Ulm",
"Weiden in der Oberpfalz",
"Weimar",
"Wiesbaden",
"Wilhelmshaven",
"Wolfsburg",
"Worms",
"Wuppertal",
"Zweibrücken",
"Preußen",
"Schwaben",
"Franken",
"Rheinland",
"Westfalen",
"Pommern",
"Schleswig",
"Holstein",
"Anhalt",
"Lausitz",
"Elsass",
"Deutscher Orden",
"Nassau",
"Kurpfalz",
"Berg",
"Jülich",
"Lothringen",
"Harzgau",
"Wetterau",
"Ruhrgebiet",
"Allgäu",
"Schwarzwald",
"Spreewald",
"Altmühltal",
"Spessart",
"Odenwald",
"Eifel",
"Sauerland",
"Westerwald",
"Pfalz",
],
},
{
id: "GiantWorldMap",