From 63ca7ad672b13e9eeb194c538ba79b869e21b6f6 Mon Sep 17 00:00:00 2001 From: bb Date: Wed, 6 Sep 2017 08:44:26 +0000 Subject: [PATCH] Split VictoryDuration in RelicDuration and WonderDuration As proposed by leper in 35377c51a7 refs #4014 Reviewed By: elexis Differential Revision: https://code.wildfiregames.com/D874 This was SVN commit r20122. --- .../mods/public/gui/common/gamedescription.js | 8 ++-- .../mods/public/gui/gamesetup/gamesetup.js | 37 +++++++++++++------ .../public/maps/scripts/CaptureTheRelic.js | 2 +- .../mods/public/maps/scripts/WonderVictory.js | 2 +- .../components/tests/test_EndGameManager.js | 6 +-- .../mods/public/simulation/helpers/Setup.js | 6 ++- 6 files changed, 39 insertions(+), 22 deletions(-) diff --git a/binaries/data/mods/public/gui/common/gamedescription.js b/binaries/data/mods/public/gui/common/gamedescription.js index b13b61a01c..5b5abd4f7b 100644 --- a/binaries/data/mods/public/gui/common/gamedescription.js +++ b/binaries/data/mods/public/gui/common/gamedescription.js @@ -233,9 +233,9 @@ function getGameDescription(extended = false) "victory condition", "Wonder (%(min)s minute)", "Wonder (%(min)s minutes)", - g_GameAttributes.settings.VictoryDuration + g_GameAttributes.settings.WonderDuration ), - { "min": g_GameAttributes.settings.VictoryDuration } + { "min": g_GameAttributes.settings.WonderDuration } ); let isCaptureTheRelic = g_VictoryConditions.Name[victoryIdx] == "capture_the_relic"; @@ -245,9 +245,9 @@ function getGameDescription(extended = false) "victory condition", "Capture the Relic (%(min)s minute)", "Capture the Relic (%(min)s minutes)", - g_GameAttributes.settings.VictoryDuration + g_GameAttributes.settings.RelicDuration ), - { "min": g_GameAttributes.settings.VictoryDuration } + { "min": g_GameAttributes.settings.RelicDuration } ); titles.push({ diff --git a/binaries/data/mods/public/gui/gamesetup/gamesetup.js b/binaries/data/mods/public/gui/gamesetup/gamesetup.js index 6d9364afc1..8a302969b6 100644 --- a/binaries/data/mods/public/gui/gamesetup/gamesetup.js +++ b/binaries/data/mods/public/gui/gamesetup/gamesetup.js @@ -360,7 +360,8 @@ var g_OptionOrderGUI = { "gameSpeed", "victoryCondition", "relicCount", - "victoryDuration", + "relicDuration", + "wonderDuration", "populationCap", "startingResources", "ceasefire", @@ -598,20 +599,33 @@ var g_Dropdowns = { "enabled": () => g_GameAttributes.mapType != "scenario", "initOrder": 1000 }, - "victoryDuration": { - "title": () => translate("Victory Duration"), - "tooltip": (hoverIdx) => translate("Number of minutes until the player has won."), + "relicDuration": { + "title": () => translate("Relic Duration"), + "tooltip": (hoverIdx) => translate("Minutes until the player has achieved Relic Victory."), "labels": () => g_VictoryDurations.Title, "ids": () => g_VictoryDurations.Duration, "default": () => g_VictoryDurations.Default, - "defined": () => g_GameAttributes.settings.VictoryDuration !== undefined, - "get": () => g_GameAttributes.settings.VictoryDuration, + "defined": () => g_GameAttributes.settings.RelicDuration !== undefined, + "get": () => g_GameAttributes.settings.RelicDuration, "select": (idx) => { - g_GameAttributes.settings.VictoryDuration = g_VictoryDurations.Duration[idx]; + g_GameAttributes.settings.RelicDuration = g_VictoryDurations.Duration[idx]; }, - "hidden": () => - g_GameAttributes.settings.GameType != "wonder" && - g_GameAttributes.settings.GameType != "capture_the_relic", + "hidden": () => g_GameAttributes.settings.GameType != "capture_the_relic", + "enabled": () => g_GameAttributes.mapType != "scenario", + "initOrder": 1000 + }, + "wonderDuration": { + "title": () => translate("Wonder Duration"), + "tooltip": (hoverIdx) => translate("Minutes until the player has achieved Wonder Victory."), + "labels": () => g_VictoryDurations.Title, + "ids": () => g_VictoryDurations.Duration, + "default": () => g_VictoryDurations.Default, + "defined": () => g_GameAttributes.settings.WonderDuration !== undefined, + "get": () => g_GameAttributes.settings.WonderDuration, + "select": (idx) => { + g_GameAttributes.settings.WonderDuration = g_VictoryDurations.Duration[idx]; + }, + "hidden": () => g_GameAttributes.settings.GameType != "wonder", "enabled": () => g_GameAttributes.mapType != "scenario", "initOrder": 1000 }, @@ -1729,7 +1743,8 @@ function selectMap(name) if (g_GameAttributes.mapType == "scenario") { - delete g_GameAttributes.settings.VictoryDuration; + delete g_GameAttributes.settings.RelicDuration; + delete g_GameAttributes.settings.WonderDuration; delete g_GameAttributes.settings.LastManStanding; delete g_GameAttributes.settings.RegicideGarrison; } diff --git a/binaries/data/mods/public/maps/scripts/CaptureTheRelic.js b/binaries/data/mods/public/maps/scripts/CaptureTheRelic.js index e323b9ad4d..845c8efb1b 100644 --- a/binaries/data/mods/public/maps/scripts/CaptureTheRelic.js +++ b/binaries/data/mods/public/maps/scripts/CaptureTheRelic.js @@ -122,7 +122,7 @@ Trigger.prototype.StartCaptureTheRelicCountdown = function(playerAndAllies) let cmpPlayer = QueryOwnerInterface(this.relics[0], IID_Player); let cmpEndGameManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_EndGameManager); - let captureTheRelicDuration = cmpEndGameManager.GetGameTypeSettings().victoryDuration || 0; + let captureTheRelicDuration = cmpEndGameManager.GetGameTypeSettings().relicDuration; let isTeam = playerAndAllies.length > 1; this.ownRelicsVictoryMessage = cmpGuiInterface.AddTimeNotification({ diff --git a/binaries/data/mods/public/maps/scripts/WonderVictory.js b/binaries/data/mods/public/maps/scripts/WonderVictory.js index 1da712b776..0d171b1268 100644 --- a/binaries/data/mods/public/maps/scripts/WonderVictory.js +++ b/binaries/data/mods/public/maps/scripts/WonderVictory.js @@ -38,7 +38,7 @@ Trigger.prototype.CheckWonderVictory = function(data) let cmpPlayer = QueryOwnerInterface(ent, IID_Player); let cmpEndGameManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_EndGameManager); - let wonderDuration = cmpEndGameManager.GetGameTypeSettings().victoryDuration || 0; + let wonderDuration = cmpEndGameManager.GetGameTypeSettings().wonderDuration; messages.otherMessage = cmpGuiInterface.AddTimeNotification({ "message": markForTranslation("%(_player_)s will win in %(time)s."), diff --git a/binaries/data/mods/public/simulation/components/tests/test_EndGameManager.js b/binaries/data/mods/public/simulation/components/tests/test_EndGameManager.js index be3aad97ac..dca3e2bb6a 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_EndGameManager.js +++ b/binaries/data/mods/public/simulation/components/tests/test_EndGameManager.js @@ -4,7 +4,7 @@ Engine.LoadComponentScript("EndGameManager.js"); let cmpEndGameManager = ConstructComponent(SYSTEM_ENTITY, "EndGameManager"); let playerEnt1 = 1; -let victoryDuration = 2 * 60 * 1000; +let wonderDuration = 2 * 60 * 1000; AddMock(SYSTEM_ENTITY, IID_PlayerManager, { "GetNumPlayers": () => 4 @@ -23,7 +23,7 @@ AddMock(playerEnt1, IID_Player, { TS_ASSERT_EQUALS(cmpEndGameManager.skipAlliedVictoryCheck, true); cmpEndGameManager.SetAlliedVictory(true); TS_ASSERT_EQUALS(cmpEndGameManager.GetAlliedVictory(), true); -cmpEndGameManager.SetGameType("wonder", { "victoryDuration": victoryDuration }); +cmpEndGameManager.SetGameType("wonder", { "wonderDuration": wonderDuration }); TS_ASSERT_EQUALS(cmpEndGameManager.skipAlliedVictoryCheck, false); TS_ASSERT(cmpEndGameManager.GetGameType() == "wonder"); -TS_ASSERT_EQUALS(cmpEndGameManager.GetGameTypeSettings().victoryDuration, victoryDuration); +TS_ASSERT_EQUALS(cmpEndGameManager.GetGameTypeSettings().wonderDuration, wonderDuration); diff --git a/binaries/data/mods/public/simulation/helpers/Setup.js b/binaries/data/mods/public/simulation/helpers/Setup.js index 25ed354cfe..85a25c2238 100644 --- a/binaries/data/mods/public/simulation/helpers/Setup.js +++ b/binaries/data/mods/public/simulation/helpers/Setup.js @@ -47,8 +47,10 @@ function LoadMapSettings(settings) let gameTypeSettings = {}; if (settings.GameType && settings.GameType == "capture_the_relic") gameTypeSettings.relicCount = settings.RelicCount; - if (settings.VictoryDuration) - gameTypeSettings.victoryDuration = settings.VictoryDuration * 60 * 1000; + if (settings.GameType && settings.GameType == "capture_the_relic") + gameTypeSettings.relicDuration = settings.RelicDuration * 60 * 1000; + if (settings.GameType && settings.GameType == "wonder") + gameTypeSettings.wonderDuration = settings.WonderDuration * 60 * 1000; if (settings.GameType && settings.GameType == "regicide") gameTypeSettings.regicideGarrison = settings.RegicideGarrison; if (settings.GameType)