mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 11:50:42 +00:00
Some little HumansVsNations improvements before public games launch 🤖 (#2825)
## Description:
- Added `generateUniqueNationName()` to `NationCreation` because I saw a
duplicate name while spawning 300 nations on Pangaea 😄
- Switched HumansVsNations public game difficulty from hard to
impossible because I realized how crazy strong troop donations between
humans are (in an enzo HVN stream).
Maybe I have to make nations donate troops to each other, we will see...
Playtests won't tell the truth because the players attending these are
probably better than the usual OF player. I will try to check the HVN
winrate via API after launch
## 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:
@@ -69,9 +69,11 @@ export function createNationsForGame(
|
||||
|
||||
// If we need more nations than defined in manifest, create additional ones
|
||||
const nations: Nation[] = manifestNations.map(toNation);
|
||||
const usedNames = new Set(nations.map((n) => n.playerInfo.name));
|
||||
const additionalCount = targetNationCount - manifestNations.length;
|
||||
for (let i = 0; i < additionalCount; i++) {
|
||||
const name = generateNationName(random);
|
||||
const name = generateUniqueNationName(random, usedNames);
|
||||
usedNames.add(name);
|
||||
nations.push(
|
||||
new Nation(
|
||||
undefined,
|
||||
@@ -97,6 +99,45 @@ export function getCompactMapNationCount(
|
||||
return manifestNationCount;
|
||||
}
|
||||
|
||||
function generateUniqueNationName(
|
||||
random: PseudoRandom,
|
||||
usedNames: Set<string>,
|
||||
): string {
|
||||
for (let attempt = 0; attempt < 1000; attempt++) {
|
||||
const name = generateNationName(random);
|
||||
if (!usedNames.has(name)) {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
// Fallback if we can't generate unique name (extremely unlikely)
|
||||
// Append a number to ensure uniqueness
|
||||
let counter = 1;
|
||||
const baseName = generateNationName(random);
|
||||
while (usedNames.has(`${baseName} ${counter}`)) {
|
||||
counter++;
|
||||
}
|
||||
return `${baseName} ${counter}`;
|
||||
}
|
||||
|
||||
function generateNationName(random: PseudoRandom): string {
|
||||
const template = NAME_TEMPLATES[random.nextInt(0, NAME_TEMPLATES.length)];
|
||||
const noun = NOUNS[random.nextInt(0, NOUNS.length)];
|
||||
|
||||
const result: string[] = [];
|
||||
|
||||
for (const part of template) {
|
||||
if (part === PLURAL_NOUN) {
|
||||
result.push(pluralize(noun));
|
||||
} else if (part === NOUN) {
|
||||
result.push(noun);
|
||||
} else {
|
||||
result.push(part);
|
||||
}
|
||||
}
|
||||
|
||||
return result.join(" ");
|
||||
}
|
||||
|
||||
const PLURAL_NOUN = Symbol("plural!");
|
||||
const NOUN = Symbol("noun!");
|
||||
|
||||
@@ -290,25 +331,6 @@ const NOUNS = [
|
||||
"Penguin",
|
||||
];
|
||||
|
||||
function generateNationName(random: PseudoRandom): string {
|
||||
const template = NAME_TEMPLATES[random.nextInt(0, NAME_TEMPLATES.length)];
|
||||
const noun = NOUNS[random.nextInt(0, NOUNS.length)];
|
||||
|
||||
const result: string[] = [];
|
||||
|
||||
for (const part of template) {
|
||||
if (part === PLURAL_NOUN) {
|
||||
result.push(pluralize(noun));
|
||||
} else if (part === NOUN) {
|
||||
result.push(noun);
|
||||
} else {
|
||||
result.push(part);
|
||||
}
|
||||
}
|
||||
|
||||
return result.join(" ");
|
||||
}
|
||||
|
||||
// Words from NOUNS that need irregular "-oes" plural
|
||||
const O_TO_OES = new Set(["Potato", "Tomato"]);
|
||||
|
||||
|
||||
@@ -121,7 +121,9 @@ export class MapPlaylist {
|
||||
gameMapSize: isCompact ? GameMapSize.Compact : GameMapSize.Normal,
|
||||
publicGameModifiers: { isCompact, isRandomSpawn },
|
||||
difficulty:
|
||||
playerTeams === HumansVsNations ? Difficulty.Hard : Difficulty.Easy,
|
||||
playerTeams === HumansVsNations
|
||||
? Difficulty.Impossible
|
||||
: Difficulty.Easy,
|
||||
infiniteGold: false,
|
||||
infiniteTroops: false,
|
||||
maxTimerValue: undefined,
|
||||
|
||||
Reference in New Issue
Block a user