Differential D4703 Diff 20493 ps/trunk/binaries/data/mods/public/gamesettings/attributes/PlayerCiv.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gamesettings/attributes/PlayerCiv.js
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | GameSettings.prototype.Attributes.PlayerCiv = class PlayerCiv extends GameSetting | ||||
{ | { | ||||
this._resize(this.settings.playerCount.nbPlayers); | this._resize(this.settings.playerCount.nbPlayers); | ||||
this.values.forEach((c, i) => this._set(i, c)); | this.values.forEach((c, i) => this._set(i, c)); | ||||
this.trigger("values"); | this.trigger("values"); | ||||
} | } | ||||
pickRandomItems() | pickRandomItems() | ||||
{ | { | ||||
// Get a unique array of selectable cultures | const civs = Object.keys(this.settings.civData).filter(civ => this.settings.civData[civ].SelectableInGameSetup); | ||||
let cultures = Object.keys(this.settings.civData).filter(civ => this.settings.civData[civ].SelectableInGameSetup).map(civ => this.settings.civData[civ].Culture); | |||||
cultures = cultures.filter((culture, index) => cultures.indexOf(culture) === index); | |||||
let picked = false; | let picked = false; | ||||
for (let i in this.values) | for (let i in this.values) | ||||
{ | { | ||||
if (this.values[i] != "random") | if (this.values[i] != "random") | ||||
continue; | continue; | ||||
picked = true; | picked = true; | ||||
this.values[i] = pickRandom(civs); | |||||
// Pick a random civ of a random culture | |||||
let culture = pickRandom(cultures); | |||||
this.values[i] = pickRandom(Object.keys(this.settings.civData).filter(civ => | |||||
this.settings.civData[civ].Culture == culture && this.settings.civData[civ].SelectableInGameSetup)); | |||||
} | } | ||||
if (picked) | if (picked) | ||||
this.trigger("values"); | this.trigger("values"); | ||||
return picked; | return picked; | ||||
} | } | ||||
_getMapData(i) | _getMapData(i) | ||||
Show All 37 Lines |
Wildfire Games · Phabricator