[GUI] Remove Roman numerals from bot names
To avoid the appearance of two Roman numerals at the end of bot names (e.g. "Artaxshasha II II -> here "Artaxshasha II" was the name itself and the second "II" was added when the name was chosen for the second time), remove the addition of Roman numerals entirely. Instead, if possible, a new name is chosen for each bot. If not, the suffix "(n)" is added counting the duplicates and warning is displayed. AINames are added to the Iberians, Gauls, and Mauryas bringing their totel to at least 8 each in order avoid any duplicates in regular 8-player games. Credit to Norse_Harold for changing the condition for reusing names to not use a hardcoded assumption about the maximum number of player slots Patch by @Vantha Accepted by @phosit, @wowgetoffyourcellphone Differential Revision: https://code.wildfiregames.com/D5256 This was SVN commit r28082.
This commit is contained in:
parent
99cb6b03c5
commit
7c8c9fd59b
@ -62,10 +62,11 @@ GameSettings.prototype.Attributes.PlayerName = class PlayerName extends GameSett
|
||||
}
|
||||
|
||||
/**
|
||||
* Pick bot names.
|
||||
* Pick AI names.
|
||||
*/
|
||||
pickRandomItems()
|
||||
{
|
||||
const AIPlayerNamesList = [];
|
||||
let picked = false;
|
||||
for (let i in this.values)
|
||||
{
|
||||
@ -82,22 +83,29 @@ GameSettings.prototype.Attributes.PlayerName = class PlayerName extends GameSett
|
||||
continue;
|
||||
|
||||
picked = true;
|
||||
// Pick one of the available botnames for the chosen civ
|
||||
// Determine botnames
|
||||
let chosenName = pickRandom(this.settings.civData[civ].AINames);
|
||||
if (!this.settings.isNetworked)
|
||||
chosenName = translate(chosenName);
|
||||
|
||||
// Count how many players use the chosenName
|
||||
let usedName = this.values.filter(oName => oName && oName.indexOf(chosenName) !== -1).length;
|
||||
const names = this.settings.civData[civ].AINames;
|
||||
const remainingNames = names.filter(name => !AIPlayerNamesList.includes(name));
|
||||
const chosenName = pickRandom(remainingNames.length ? remainingNames : names);
|
||||
|
||||
// Avoid translating AI names if the game is networked, so all players see and refer to
|
||||
// English names instead of names in the language of the host.
|
||||
const translatedCountLabel = this.settings.isNetworked ? this.CountLabel : translate(this.CountLabel);
|
||||
const translatedChosenName = this.settings.isNetworked ? chosenName : translate(chosenName);
|
||||
|
||||
this.values[i] =
|
||||
usedName ?
|
||||
sprintf(this.RomanLabel, {
|
||||
"playerName": chosenName,
|
||||
"romanNumber": this.RomanNumbers[usedName + 1]
|
||||
}) :
|
||||
chosenName;
|
||||
const duplicateNameCount = AIPlayerNamesList.reduce((count, name) => {
|
||||
if (name == chosenName)
|
||||
count++;
|
||||
return count;
|
||||
}, 0);
|
||||
|
||||
AIPlayerNamesList.push(chosenName);
|
||||
|
||||
this.values[i] = !duplicateNameCount ? translatedChosenName :
|
||||
sprintf(translatedCountLabel, {
|
||||
"playerName": translatedChosenName,
|
||||
"nameCount": duplicateNameCount + 1
|
||||
});
|
||||
}
|
||||
if (picked)
|
||||
this.trigger("values");
|
||||
@ -128,9 +136,8 @@ GameSettings.prototype.Attributes.PlayerName = class PlayerName extends GameSett
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
GameSettings.prototype.Attributes.PlayerName.prototype.RomanLabel =
|
||||
translate("%(playerName)s %(romanNumber)s");
|
||||
|
||||
GameSettings.prototype.Attributes.PlayerName.prototype.RomanNumbers =
|
||||
[undefined, "I", "II", "III", "IV", "V", "VI", "VII", "VIII"];
|
||||
/** Translation: This is a template (sprintf format specifier) for the name of
|
||||
* an AI-controlled player and a unique number for each of the players with
|
||||
* that same name. Example: Perseus (2)
|
||||
*/
|
||||
GameSettings.prototype.Attributes.PlayerName.prototype.CountLabel = markForTranslation("%(playerName)s (%(nameCount)i)");
|
||||
|
@ -290,6 +290,7 @@
|
||||
{ "nick": "tpearson", "name": "Timothy Pearson" },
|
||||
{ "nick": "user1", "name": "A. C." },
|
||||
{ "nick": "usey11" },
|
||||
{ "nick": "Vantha"},
|
||||
{ "nick": "vincent_c", "name": "Vincent Cheng" },
|
||||
{ "nick": "vinhig", "name": "Vincent Higginson" },
|
||||
{ "nick": "vladislavbelov", "name": "Vladislav Belov" },
|
||||
|
@ -64,6 +64,7 @@
|
||||
"Divico",
|
||||
"Ambiorix",
|
||||
"Liscus",
|
||||
"Orgetorix",
|
||||
"Valetiacus",
|
||||
"Viridovix"
|
||||
],
|
||||
|
@ -61,8 +61,12 @@
|
||||
],
|
||||
"AINames": [
|
||||
"Audax",
|
||||
"Calcus",
|
||||
"Ditalcus",
|
||||
"Minurus",
|
||||
"Olyndicus",
|
||||
"Orison",
|
||||
"Tanginus",
|
||||
"Tautalus"
|
||||
],
|
||||
"SkirmishReplacements": {
|
||||
|
@ -55,12 +55,14 @@
|
||||
],
|
||||
"AINames": [
|
||||
"Bindusara Maurya",
|
||||
"Brihadratha Maurya",
|
||||
"Dasharatha Maurya",
|
||||
"Devavarman Maurya",
|
||||
"Kunala Maurya",
|
||||
"Samprati Maurya",
|
||||
"Shalishuka Maurya",
|
||||
"Devavarman Maurya",
|
||||
"Shatadhanvan Maurya",
|
||||
"Brihadratha Maurya"
|
||||
"Tivala Maurya"
|
||||
],
|
||||
"SkirmishReplacements": {
|
||||
"skirmish/units/default_infantry_ranged_b": "units/maur/infantry_archer_b",
|
||||
|
Loading…
Reference in New Issue
Block a user