Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesettings/attributes/PlayerName.js
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | GameSettings.prototype.Attributes.PlayerName = class PlayerName extends GameSetting | ||||
} | } | ||||
/** | /** | ||||
* Pick bot names. | * Pick bot names. | ||||
*/ | */ | ||||
pickRandomItems() | pickRandomItems() | ||||
{ | { | ||||
let picked = false; | let picked = false; | ||||
let hasValue = true; | |||||
for (let i in this.values) | for (let i in this.values) | ||||
{ | { | ||||
if (!!this.values[i] && | if (!!this.values[i] && | ||||
this.values[i] !== g_Settings.PlayerDefaults[+i + 1].Name) | this.values[i] !== g_Settings.PlayerDefaults[+i + 1].Name) | ||||
continue; | continue; | ||||
let ai = this.settings.playerAI.values[i]; | let ai = this.settings.playerAI.values[i]; | ||||
if (!ai) | if (!ai) | ||||
continue; | continue; | ||||
let civ = this.settings.playerCiv.values[i]; | let civ = this.settings.playerCiv.values[i]; | ||||
if (!civ || civ == "random") | if (!civ) | ||||
continue; | continue; | ||||
else if (civ == "random") | |||||
{ | |||||
hasValue = false; | |||||
continue; | |||||
} | |||||
picked = true; | picked = true; | ||||
// Pick one of the available botnames for the chosen civ | // Pick one of the available botnames for the chosen civ | ||||
// Determine botnames | // Determine botnames | ||||
let chosenName = pickRandom(this.settings.civData[civ].AINames); | let chosenName = pickRandom(this.settings.civData[civ].AINames); | ||||
if (!this.settings.isNetworked) | if (!this.settings.isNetworked) | ||||
chosenName = translate(chosenName); | chosenName = translate(chosenName); | ||||
// Count how many players use the chosenName | // Count how many players use the chosenName | ||||
let usedName = this.values.filter(oName => oName && oName.indexOf(chosenName) !== -1).length; | let usedName = this.values.filter(oName => oName && oName.indexOf(chosenName) !== -1).length; | ||||
this.values[i] = | this.values[i] = | ||||
usedName ? | usedName ? | ||||
sprintf(this.RomanLabel, { | sprintf(this.RomanLabel, { | ||||
"playerName": chosenName, | "playerName": chosenName, | ||||
"romanNumber": this.RomanNumbers[usedName + 1] | "romanNumber": this.RomanNumbers[usedName + 1] | ||||
}) : | }) : | ||||
chosenName; | chosenName; | ||||
} | } | ||||
if (picked) | if (picked) | ||||
this.trigger("values"); | this.trigger("values"); | ||||
return picked; | return { "picked": picked, "hasValue": hasValue }; | ||||
} | } | ||||
_getMapData(i) | _getMapData(i) | ||||
{ | { | ||||
let data = this.settings.map.data; | let data = this.settings.map.data; | ||||
if (!data || !data.settings || !data.settings.PlayerData) | if (!data || !data.settings || !data.settings.PlayerData) | ||||
return undefined; | return undefined; | ||||
if (data.settings.PlayerData.length <= i) | if (data.settings.PlayerData.length <= i) | ||||
Show All 16 Lines |
Wildfire Games · Phabricator