Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesettings/attributes/Seeds.js
GameSettings.prototype.Attributes.Seeds = class Seeds extends GameSetting | GameSettings.prototype.Attributes.Seeds = class Seeds extends GameSetting | ||||
{ | { | ||||
init() | init() | ||||
{ | { | ||||
this.seed = 0; | this.seed = "random"; | ||||
this.AIseed = 0; | this.AIseed = "random"; | ||||
} | } | ||||
toInitAttributes(attribs) | toInitAttributes(attribs) | ||||
{ | { | ||||
// Seed is used for map generation and simulation. | attribs.settings.Seed = this.seed == "random" ? this.seed : +this.seed; | ||||
attribs.settings.Seed = this.seed; | attribs.settings.AISeed = this.AIseed == "random" ? this.AIseed : +this.AIseed; | ||||
attribs.settings.AISeed = this.AIseed; | |||||
} | } | ||||
fromInitAttributes(attribs) | fromInitAttributes(attribs) | ||||
{ | { | ||||
// Seed is used for map generation and simulation. | |||||
if (this.getLegacySetting(attribs, "Seed") !== undefined) | if (this.getLegacySetting(attribs, "Seed") !== undefined) | ||||
this.seed = this.getLegacySetting(attribs, "Seed"); | this.seed = this.getLegacySetting(attribs, "Seed"); | ||||
if (this.getLegacySetting(attribs, "AISeed") !== undefined) | if (this.getLegacySetting(attribs, "AISeed") !== undefined) | ||||
this.AIseed = this.getLegacySetting(attribs, "AISeed"); | this.AIseed = this.getLegacySetting(attribs, "AISeed"); | ||||
} | } | ||||
pickRandomItems() | pickRandomItems() | ||||
{ | { | ||||
let picked = false; | |||||
if (this.seed === "random") | |||||
{ | |||||
this.seed = randIntExclusive(0, Math.pow(2, 32)); | this.seed = randIntExclusive(0, Math.pow(2, 32)); | ||||
picked = true; | |||||
} | |||||
if (this.AIseed === "random") | |||||
{ | |||||
this.AIseed = randIntExclusive(0, Math.pow(2, 32)); | this.AIseed = randIntExclusive(0, Math.pow(2, 32)); | ||||
picked = true; | |||||
} | |||||
return picked; | |||||
} | } | ||||
}; | }; |
Wildfire Games · Phabricator