Ticket #3970: lastmanstanding.patch

File lastmanstanding.patch, 6.2 KB (added by Sandarac, 8 years ago)

Adds check box in More Options

  • binaries/data/mods/public/gui/gamesetup/gamesetup.js

     
    353353        "optionExploreMap",
    354354        "optionDisableTreasures",
    355355        "optionLockTeams",
     356        "optionLastMan",
    356357        "optionCheats",
    357358        "optionRating",
    358359        "hideMoreOptions"
     
    508509        "ExploreMap": "exploreMap",
    509510        "DisableTreasures": "disableTreasures",
    510511        "LockTeams": "lockTeams",
     512        "disableAlliedVictory" : "disableAlliedVictory",
    511513        "CheatsEnabled": "enableCheats"
    512514    };
    513515
     
    525527        Engine.GetGUIObjectByName("lockTeams").enabled = !this.checked;
    526528        updateGameAttributes();
    527529    };
     530    Engine.GetGUIObjectByName("lockTeams").onPress = function() {
     531        g_GameAttributes.settings.LockTeams = this.checked;
     532        g_GameAttributes.settings.disableAlliedVictory = !this.checked;
     533        hideControl("disableAlliedVictory", "disableAlliedVictoryText", !g_GameAttributes.settings.LockTeams);
     534        updateGameAttributes();
     535    };
    528536}
    529537
    530538/**
     
    13711379    setGUIBoolean("exploreMap", "exploreMapText", !!mapSettings.ExploreMap);
    13721380    setGUIBoolean("revealMap", "revealMapText", !!mapSettings.RevealMap);
    13731381    setGUIBoolean("lockTeams", "lockTeamsText", !!mapSettings.LockTeams);
     1382    setGUIBoolean("disableAlliedVictory", "disableAlliedVictoryText", !!mapSettings.disableAlliedVictory);
    13741383    setGUIBoolean("enableRating", "enableRatingText", !!mapSettings.RatingEnabled);
    13751384
    13761385    Engine.GetGUIObjectByName("optionWonderDuration").hidden =
     
    13811390
    13821391    Engine.GetGUIObjectByName("enableCheats").enabled = !mapSettings.RatingEnabled;
    13831392    Engine.GetGUIObjectByName("lockTeams").enabled = !mapSettings.RatingEnabled;
     1393    Engine.GetGUIObjectByName("disableAlliedVictoryText").hidden = mapSettings.LockTeams;
    13841394
    13851395    // Mapsize completely hidden for non-random maps
    13861396    let isRandom = g_GameAttributes.mapType == "random";
     
    13951405                      "startingResources", "ceasefire", "revealMap",
    13961406                      "exploreMap", "disableTreasures", "lockTeams"])
    13971407        hideControl(ctrl, ctrl + "Text", notScenario);
     1408    hideControl("disableAlliedVictory", "disableAlliedVictoryText", !mapSettings.LockTeams && notScenario);
    13981409
    13991410    Engine.GetGUIObjectByName("civResetButton").hidden = !notScenario;
    14001411
  • binaries/data/mods/public/gui/gamesetup/gamesetup.xml

     
    385385                        <translatableAttribute id="tooltip">Toggle locked teams.</translatableAttribute>
    386386                    </object>
    387387                </object>
     388               
     389                <object name="optionLastMan" size="14 338 94% 366">
     390                    <object size="0 0 40% 28" type="text" style="ModernRightLabelText">
     391                        <translatableAttribute id="caption">Last Man Standing:</translatableAttribute>
     392                    </object>
     393                    <object name="disableAlliedVictoryText" size="40% 0 100% 28" type="text" style="ModernLeftLabelText"/>
     394                    <object name="disableAlliedVictory" size="40%+10 5 40%+30 100%-5" type="checkbox" style="ModernTickBox" hidden="true" tooltip_style="onscreenToolTip">
     395                        <translatableAttribute id="tooltip">Toggle the "Last Man Standing" option (only one player can win).</translatableAttribute>
     396                    </object>
     397                </object>
    388398
    389                 <object name="optionCheats" size="14 338 94% 366" hidden="true">
     399                <object name="optionCheats" size="14 368 94% 396" hidden="true">
    390400                    <object size="0 0 40% 28" type="text" style="ModernRightLabelText">
    391401                        <translatableAttribute id="caption">Cheats:</translatableAttribute>
    392402                    </object>
     
    396406                    </object>
    397407                </object>
    398408
    399                 <object name="optionRating" size="14 368 94% 396" hidden="true">
     409                <object name="optionRating" size="14 398 94% 426" hidden="true">
    400410                    <object size="0 0 40% 28" hidden="false" type="text" style="ModernRightLabelText">
    401411                        <translatableAttribute id="caption">Rated Game:</translatableAttribute>
    402412                    </object>
  • binaries/data/mods/public/simulation/components/EndGameManager.js

     
    1919    this.wonderDuration = 10 * 60 * 1000;
    2020
    2121    // Allied victory means allied players can win if victory conditions are met for each of them
    22     // Would be false for a "last man standing" game (when diplomacy is fully implemented)
     22    // False for a "last man standing" game (when diplomacy is fully implemented)
    2323    this.alliedVictory = true;
    2424};
    2525
     
    8181        return;
    8282
    8383    var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
     84    var cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);
    8485    var cmpPlayers = [];
    8586
    8687    var allies = [];
     
    100101            onlyAlliesLeft = false;
    101102    }
    102103
     104    if (!this.alliedVictory && onlyAlliesLeft)
     105        cmpGUIInterface.PushNotification({
     106            "players": [1,2,3,4,5,6,7,8],
     107            "message": markForTranslation("Last civilization remaining wins"),
     108            "translateMessage": true
     109        });
     110
    103111    // check if there are winners, or the game needs to continue
    104     if (!allies.length || !onlyAlliesLeft || !this.alliedVictory)
    105         return; 
     112    if (!allies.length || !onlyAlliesLeft || (!this.alliedVictory && cmpPlayers.filter(pData => pData.GetState() == "active").length != 1))
     113        return;
    106114
    107115    for (var p of allies)
    108116        cmpPlayers[p].SetState("won");
  • binaries/data/mods/public/simulation/helpers/Setup.js

     
    5151        cmpEndGameManager.SetGameType(settings.GameType);
    5252    if (settings.WonderDuration)
    5353        cmpEndGameManager.SetWonderDuration(settings.WonderDuration * 60 * 1000);
     54    if (settings.disableAlliedVictory)
     55        cmpEndGameManager.SetAlliedVictory(false);
    5456
    5557    if (settings.Garrison)
    5658    {