Differential D4319 Diff 19038 binaries/data/mods/public/gui/gamesettings/attributes/CaptureTheWonder.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesettings/attributes/CaptureTheWonder.js
GameSettings.prototype.Attributes.CaptureTheWonder = class CaptureTheWonder extends GameSetting | |||||
{ | |||||
init() | |||||
{ | |||||
this.available = false; | |||||
this.duration = 0; | |||||
this.settings.victoryConditions.watch(() => this.maybeUpdate(), ["active","hidden"]); | |||||
this.settings.map.watch(() => this.onMapChange(), ["map"]); | |||||
} | |||||
toInitAttributes(attribs) | |||||
{ | |||||
if (this.available) | |||||
attribs.settings.CaptureTheWonderDuration = this.duration; | |||||
} | |||||
fromInitAttributes(attribs) | |||||
{ | |||||
if (this.getLegacySetting(attribs, "CaptureTheWonderDuration") !== undefined) | |||||
this.setDuration(+this.getLegacySetting(attribs, "CaptureTheWonderDuration")); | |||||
} | |||||
onMapChange() | |||||
{ | |||||
this.setDuration(+this.getMapSetting("CaptureTheWonderDuration") || 0); | |||||
} | |||||
setDuration(duration) | |||||
{ | |||||
Freagarach: Because one cannot disable a victory condition this way? Setting it disabled only removes it… | |||||
Done Inline ActionsThis is a copy of the wonder game, with the names changed for this one. I just left this as is a copy&modify and the workings are the same for the two modes. nani: This is a copy of the wonder game, with the names changed for this one. I just left this as is… | |||||
Done Inline ActionsSorry, the comment above is wrong, was thinking of another part of the code. So, you know of any other way to make it work? I remember I tried many things from which none worked. nani: Sorry, the comment above is wrong, was thinking of another part of the code.
So, you know of… | |||||
const victoryConditions = this.settings.victoryConditions | |||||
this.available = victoryConditions.active.has("capture_the_wonder") && | |||||
!victoryConditions.hidden.has("capture_the_wonder"); | |||||
this.duration = Math.round(duration); | |||||
} | |||||
maybeUpdate() | |||||
{ | |||||
this.setDuration(this.duration); | |||||
} | |||||
}; |
Wildfire Games · Phabricator
Because one cannot disable a victory condition this way? Setting it disabled only removes it from the enabled list. Disabling is done with DisabledWhenChecked. But that seems like something of a flaw, I guess.