Index: binaries/data/mods/public/gamesettings/attributes/Wonder.js =================================================================== --- binaries/data/mods/public/gamesettings/attributes/Wonder.js +++ binaries/data/mods/public/gamesettings/attributes/Wonder.js @@ -4,6 +4,7 @@ { this.available = false; this.duration = 0; + this.resetTimerOnDiploChange = false; this.settings.victoryConditions.watch(() => this.maybeUpdate(), ["active"]); this.settings.map.watch(() => this.onMapChange(), ["map"]); } @@ -11,13 +12,18 @@ toInitAttributes(attribs) { if (this.available) + { attribs.settings.WonderDuration = this.duration; + attribs.settings.WonderResetTimerOnDiploChange = this.getResetTimerOnDiploChange(); + } } fromInitAttributes(attribs) { if (this.getLegacySetting(attribs, "WonderDuration") !== undefined) this.setDuration(+this.getLegacySetting(attribs, "WonderDuration")); + if (this.getLegacySetting(attribs, "WonderResetTimerOnDiploChange") !== undefined) + this.setResetTimerOnDiploChange(this.getLegacySetting(attribs, "WonderResetTimerOnDiploChange")); } onMapChange() @@ -25,6 +31,12 @@ if (this.settings.map.type != "scenario") return; this.setDuration(+this.getMapSetting("WonderDuration") || 0); + this.setResetTimerOnDiploChange(this.getMapSetting("WonderResetTimerOnDiploChange") || false); + } + + getResetTimerOnDiploChange() + { + return this.resetTimerOnDiploChange && !g_GameSettings.lastManStanding.enabled && !g_GameSettings.lockedTeams.enabled; } setDuration(duration) @@ -33,6 +45,11 @@ this.duration = Math.round(duration); } + setResetTimerOnDiploChange(value) + { + this.resetTimerOnDiploChange = value; + } + maybeUpdate() { this.setDuration(this.duration); Index: binaries/data/mods/public/gui/common/gamedescription.js =================================================================== --- binaries/data/mods/public/gui/common/gamedescription.js +++ binaries/data/mods/public/gui/common/gamedescription.js @@ -195,7 +195,8 @@ continue; let title = translateVictoryCondition(victoryCondition.Name); - if (victoryCondition.Name == "wonder") + const isWonderVictory = victoryCondition.Name === "wonder"; + if (isWonderVictory) { let wonderDuration = Math.round(initAttributes.settings.WonderDuration); title = sprintf( @@ -227,6 +228,14 @@ "value": victoryCondition.Description }); + if (isWonderVictory) + titles.push({ + "label": translate("Wonder Timer Reset"), + "value": initAttributes.settings.WonderResetTimerOnDiploChange ? + translate("The timer will be reset when the Wonder is destroyed or captured, and when the alliances of the owner change.") : + translate("The timer will be reset only if the Wonder is destroyed or captured."), + }); + if (isCaptureTheRelic) titles.push({ "label": translate("Relic Count"), Index: binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingsLayout.js =================================================================== --- binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingsLayout.js +++ binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingsLayout.js @@ -44,6 +44,7 @@ "RelicDuration", "RegicideGarrison", "WonderDuration", + "WonderResetTimerOnDiploChange", "GameSpeed", "Ceasefire", "LockedTeams", Index: binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/WonderResetTimerOnDiploChange.js =================================================================== --- /dev/null +++ binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/WonderResetTimerOnDiploChange.js @@ -0,0 +1,45 @@ +GameSettingControls.WonderResetTimerOnDiploChange = class WonderResetTimerOnDiploChange extends GameSettingControlDropdown +{ + constructor(...args) + { + super(...args); + g_GameSettings.wonder.watch(() => this.render(), ["resetTimerOnDiploChange", "available"]); + g_GameSettings.map.watch(() => this.render(), ["type"]); + g_GameSettings.lastManStanding.watch(() => this.render(), ["enabled"]); + g_GameSettings.lockedTeams.watch(() => this.render(), ["enabled"]); + + this.dropdown.list = [this.WonderTimerResetOnDestructionCaption, this.WonderTimerResetAlsoOnDiploChange]; + this.dropdown.list_data = ["false", "true"]; + + this.render(); + } + + render() + { + this.setHidden(!g_GameSettings.wonder.available); + if (g_GameSettings.wonder.available) + { + const enabled = g_GameSettings.map.type != "scenario" && !g_GameSettings.lastManStanding.enabled && !g_GameSettings.lockedTeams.enabled; + this.setEnabled(enabled); + this.setSelectedValue(g_GameSettings.wonder.getResetTimerOnDiploChange()); + } + } + + onSelectionChange(itemIdx) + { + g_GameSettings.wonder.setResetTimerOnDiploChange(!!itemIdx); // 0 is 'no' which is false + this.gameSettingsController.setNetworkInitAttributes(); + } +}; + +GameSettingControls.WonderResetTimerOnDiploChange.prototype.TitleCaption = + translate("Wonder Timer Reset"); + +GameSettingControls.WonderResetTimerOnDiploChange.prototype.Tooltip = + translate("When allied victory is enabled, reset wonder timers if the diplomacy of the owner wonder changes."); + +GameSettingControls.WonderResetTimerOnDiploChange.prototype.WonderTimerResetOnDestructionCaption = + translate("Wonder capture/destruction"); + +GameSettingControls.WonderResetTimerOnDiploChange.prototype.WonderTimerResetAlsoOnDiploChange = + translate("Also on diplomacy change"); Index: binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/GameDescription.js =================================================================== --- binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/GameDescription.js +++ binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/GameDescription.js @@ -32,7 +32,7 @@ g_GameSettings.startingResources.watch(update, ["perPlayer", "resources"]); g_GameSettings.triggerDifficulty.watch(update, ["value"]); g_GameSettings.victoryConditions.watch(update, ["active"]); - g_GameSettings.wonder.watch(update, ["duration"]); + g_GameSettings.wonder.watch(update, ["duration", "resetTimerOnDiploChange"]); g_GameSettings.mapSize.watch(update, ["size"]); } Index: binaries/data/mods/public/maps/scripts/WonderVictory.js =================================================================== --- binaries/data/mods/public/maps/scripts/WonderVictory.js +++ binaries/data/mods/public/maps/scripts/WonderVictory.js @@ -26,7 +26,7 @@ Trigger.prototype.WonderVictoryDiplomacyChanged = function(data) { - if (!Engine.QueryInterface(SYSTEM_ENTITY, IID_EndGameManager).GetAlliedVictory()) + if (!Engine.QueryInterface(SYSTEM_ENTITY, IID_EndGameManager)?.GetGameSettings()?.wonderResetTimerOnDiploChange) return; for (let ent in this.wonderVictoryMessages) Index: binaries/data/mods/public/simulation/data/settings/victory_conditions/wonder.json =================================================================== --- binaries/data/mods/public/simulation/data/settings/victory_conditions/wonder.json +++ binaries/data/mods/public/simulation/data/settings/victory_conditions/wonder.json @@ -3,7 +3,7 @@ "Data": { "Title": "Wonder", - "Description": "Be the first to build or capture a Wonder and keep it for a certain time to win the game. The timer will be reset when the Wonder is destroyed or captured. If the allied victory mode is enabled, the timer will also be reset when the alliances of the owner change.", + "Description": "Be the first to build or capture a Wonder and keep it for a certain time to win the game.", "Scripts": [ "scripts/TriggerHelper.js", Index: binaries/data/mods/public/simulation/helpers/Setup.js =================================================================== --- binaries/data/mods/public/simulation/helpers/Setup.js +++ binaries/data/mods/public/simulation/helpers/Setup.js @@ -55,7 +55,10 @@ gameSettings.relicDuration = (settings.RelicDuration ?? 1) * 60 * 1000; } if (gameSettings.victoryConditions.indexOf("wonder") != -1) + { gameSettings.wonderDuration = (settings.WonderDuration ?? 1) * 60 * 1000; + gameSettings.wonderResetTimerOnDiploChange = settings.WonderResetTimerOnDiploChange || false; + } if (gameSettings.victoryConditions.indexOf("regicide") != -1) gameSettings.regicideGarrison = settings.RegicideGarrison; cmpEndGameManager.SetGameSettings(gameSettings);