Ticket #2160: regicide_garrison_option_v3.patch
File regicide_garrison_option_v3.patch, 13.2 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/gamesetup/gamesetup.js
498 498 "ExploreMap": "exploreMap", 499 499 "DisableTreasures": "disableTreasures", 500 500 "LockTeams": "lockTeams", 501 "LastManStanding" : "lastManStanding", 501 "LastManStanding": "lastManStanding", 502 "RegicideGarrison": "regicideGarrison", 502 503 "CheatsEnabled": "enableCheats" 503 504 }; 504 505 … … 1183 1184 { 1184 1185 delete g_GameAttributes.settings.WonderDuration; 1185 1186 delete g_GameAttributes.settings.LastManStanding; 1187 delete g_GameAttributes.settings.RegicideGarrison; 1186 1188 } 1187 1189 1188 1190 if (mapSettings.PlayerData) … … 1380 1382 setGUIBoolean("revealMap", "revealMapText", !!mapSettings.RevealMap); 1381 1383 setGUIBoolean("lockTeams", "lockTeamsText", !!mapSettings.LockTeams); 1382 1384 setGUIBoolean("lastManStanding", "lastManStandingText", !!mapSettings.LastManStanding); 1385 setGUIBoolean("regicideGarrison", "regicideGarrisonText", !!mapSettings.RegicideGarrison); 1383 1386 setGUIBoolean("enableRating", "enableRatingText", !!mapSettings.RatingEnabled); 1384 1387 1385 1388 Engine.GetGUIObjectByName("optionWonderDuration").hidden = … … 1386 1389 g_GameAttributes.settings.GameType && 1387 1390 g_GameAttributes.settings.GameType != "wonder"; 1388 1391 Engine.GetGUIObjectByName("optionLastManStanding").hidden = mapSettings.LockTeams; 1392 Engine.GetGUIObjectByName("optionRegicideGarrison").hidden = 1393 g_GameAttributes.settings.GameType && 1394 g_GameAttributes.settings.GameType != "regicide"; 1389 1395 1390 1396 Engine.GetGUIObjectByName("cheatWarningText").hidden = !g_IsNetworked || !mapSettings.CheatsEnabled; 1391 1397 … … 1403 1409 1404 1410 for (let ctrl of ["victoryCondition", "wonderDuration", "populationCap", 1405 1411 "startingResources", "ceasefire", "revealMap", 1406 "exploreMap", "disableTreasures", "lockTeams", "lastManStanding"]) 1412 "exploreMap", "disableTreasures", "lockTeams", 1413 "lastManStanding", "regicideGarrison"]) 1407 1414 hideControl(ctrl, ctrl + "Text", notScenario); 1408 1415 1409 1416 Engine.GetGUIObjectByName("civResetButton").hidden = !notScenario; -
binaries/data/mods/public/gui/gamesetup/gamesetup.xml
335 335 </object> 336 336 </object> 337 337 338 <object name="option PopulationCap" size="14 98 94% 126">338 <object name="optionRegicideGarrison" size="14 98 94% 126"> 339 339 <object size="0 0 40% 28" type="text" style="ModernRightLabelText"> 340 <translatableAttribute id="caption">Hero Garrison:</translatableAttribute> 341 </object> 342 <object name="regicideGarrisonText" size="40% 0 100% 28" type="text" style="ModernLeftLabelText"/> 343 <object name="regicideGarrison" size="40%+10 5 40%+30 100%-5" type="checkbox" style="ModernTickBox" hidden="true" tooltip_style="onscreenToolTip"> 344 <translatableAttribute id="tooltip">Toggle whether heroes can be garrisoned.</translatableAttribute> 345 </object> 346 </object> 347 348 <object name="optionPopulationCap" size="14 128 94% 156"> 349 <object size="0 0 40% 28" type="text" style="ModernRightLabelText"> 340 350 <translatableAttribute id="caption">Population Cap:</translatableAttribute> 341 351 </object> 342 352 <object name="populationCapText" size="40% 0 100% 100%" type="text" style="ModernLeftLabelText"/> … … 345 355 </object> 346 356 </object> 347 357 348 <object name="optionStartingResources" size="14 1 28 94% 156">358 <object name="optionStartingResources" size="14 158 94% 186"> 349 359 <object size="0 0 40% 28" type="text" style="ModernRightLabelText"> 350 360 <translatableAttribute id="caption">Starting Resources:</translatableAttribute> 351 361 </object> … … 355 365 </object> 356 366 </object> 357 367 358 <object name="optionCeasefire" size="14 1 58 94% 186">368 <object name="optionCeasefire" size="14 188 94% 216"> 359 369 <object size="0 0 40% 28" type="text" style="ModernRightLabelText"> 360 370 <translatableAttribute id="caption">Ceasefire:</translatableAttribute> 361 371 </object> … … 440 450 name="hideMoreOptions" 441 451 type="button" 442 452 style="StoneButton" 443 size="50%-70 4 28 50%+70 456"453 size="50%-70 458 50%+70 486" 444 454 tooltip_style="onscreenToolTip" 445 455 hotkey="cancel" 446 456 > -
binaries/data/mods/public/maps/scripts/Regicide.js
6 6 7 7 Trigger.prototype.InitRegicideGame = function(msg) 8 8 { 9 let cmpEndGameManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_EndGameManager); 10 this.regicideGarrison = cmpEndGameManager.GetGameTypeSettings().regicideGarrison; 11 9 12 let playersCivs = []; 10 13 for (let playerID = 1; playerID < TriggerHelper.GetNumberOfPlayers(); ++playerID) 11 14 playersCivs[playerID] = QueryPlayerIDInterface(playerID).GetCiv(); … … 30 33 31 34 if (heroTemplates[identity.Civ].indexOf(templateName) == -1) 32 35 heroTemplates[identity.Civ].push({ 33 "templateName": t emplateName,36 "templateName": this.regicideGarrison ? templateName : "regicide_hero_ungarrisonable|" + templateName, 34 37 "classes": classes 35 38 }); 36 39 } … … 104 107 105 108 let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); 106 109 cmpTrigger.regicideHeroes = []; 110 cmpTrigger.regicideGarrison = false; 107 111 cmpTrigger.DoAfterDelay(0, "InitRegicideGame", {}); 108 112 cmpTrigger.RegisterTrigger("OnOwnershipChanged", "CheckRegicideDefeat", { "enabled": true }); -
binaries/data/mods/public/simulation/components/GarrisonHolder.js
200 200 if (!cmpIdentity) 201 201 return false; 202 202 var entityClasses = cmpIdentity.GetClassesList(); 203 return MatchesClassList(entityClasses, this.template.List._string) ;203 return MatchesClassList(entityClasses, this.template.List._string) && cmpIdentity.GetCanGarrison(); 204 204 }; 205 205 206 206 /** -
binaries/data/mods/public/simulation/components/Identity.js
91 91 "<element name='RequiredTechnology' a:help='Optional name of a technology which must be researched before the entity can be produced'>" + 92 92 "<text/>" + 93 93 "</element>" + 94 "</optional>" + 95 "<optional>" + 96 "<element name='CanGarrison' a:help='If the entity can garrison'>" + 97 "<data type='boolean'/>" + 98 "</element>" + 94 99 "</optional>"; 95 100 96 101 … … 168 173 return this.template.GenericName; 169 174 }; 170 175 176 Identity.prototype.GetCanGarrison = function() 177 { 178 return this.template.CanGarrison == "true"; 179 }; 180 171 181 Engine.RegisterComponentType(IID_Identity, "Identity", Identity); -
binaries/data/mods/public/simulation/components/tests/test_GarrisonHolder.js
1 Engine.LoadHelperScript("Player.js"); 2 Engine.LoadHelperScript("ValueModification.js"); 3 Engine.LoadComponentScript("interfaces/GarrisonHolder.js"); 4 Engine.LoadComponentScript("interfaces/Health.js"); 5 Engine.LoadComponentScript("interfaces/Trigger.js"); 6 Engine.LoadComponentScript("interfaces/Player.js"); 7 Engine.LoadComponentScript("GarrisonHolder.js"); 8 Engine.LoadComponentScript("Identity.js"); 9 Engine.LoadComponentScript("Player.js"); 10 Engine.LoadComponentScript("PlayerManager.js"); 11 12 let garrisonEnt = 15; 13 let unitEnt = 33; 14 let entHP = 1000; 15 let playerEnt = 1; 16 17 AddMock(SYSTEM_ENTITY, IID_PlayerManager, { 18 "GetPlayerByID": (id) => playerEnt, 19 }); 20 21 AddMock(garrisonEnt, IID_Health, { 22 "GetHitpoints": () => entHP, 23 "Decrease": hp => { 24 entHP = Math.max(entHP - hp, 0); 25 }, 26 }); 27 28 AddMock(unitEnt, IID_Identity, { 29 "GetClassesList": () => ["Hero", "Infantry"], 30 "GetVisibleClassesList": () => ["Hero", "Infantry"], 31 "HasClass": () => true, 32 "GetCanGarrison": () => true, 33 }); 34 35 AddMock(garrisonEnt, IID_Ownership, { 36 "GetOwner": () => playerEnt, 37 }); 38 39 AddMock(playerEnt, IID_Ownership, { 40 "GetOwner": () => playerEnt, 41 }); 42 43 let cmpGarrisonHolder = ConstructComponent(garrisonEnt, "GarrisonHolder", { 44 "LoadingRange": "2.0", 45 "Max": "20", 46 "List": { "_string": "Support Infantry Cavalry"}, 47 "entity": garrisonEnt, 48 }); 49 50 let cmpPlayer = ConstructComponent(playerEnt, "Player") 51 52 TS_ASSERT_EQUALS(cmpGarrisonHolder.GetGarrisonedEntitiesCount(), 0); 53 TS_ASSERT_EQUALS(cmpGarrisonHolder.entities.length, 0); 54 TS_ASSERT_EQUALS(cmpGarrisonHolder.visibleGarrisonPoints.length, 0); 55 TS_ASSERT_EQUALS(+cmpGarrisonHolder.template.Max, 20); 56 TS_ASSERT_EQUALS(cmpGarrisonHolder.GetLoadingRange().max, 2.0); 57 TS_ASSERT_EQUALS(cmpGarrisonHolder.IsGarrisoningAllowed(), true); 58 TS_ASSERT_EQUALS(cmpGarrisonHolder.AllowedToGarrison(unitEnt), true); 59 TS_ASSERT(cmpGarrisonHolder.GetAllowedClasses().indexOf("Infantry") != -1); -
binaries/data/mods/public/simulation/components/tests/test_Identity.js
Property changes on: binaries/data/mods/public/simulation/components/tests/test_GarrisonHolder.js ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 Engine.LoadHelperScript("Player.js"); 2 Engine.LoadHelperScript("ValueModification.js"); 3 Engine.LoadComponentScript("interfaces/Health.js"); 4 Engine.LoadComponentScript("interfaces/Trigger.js"); 5 Engine.LoadComponentScript("interfaces/Player.js"); 6 Engine.LoadComponentScript("Identity.js"); 7 Engine.LoadComponentScript("Player.js"); 8 Engine.LoadComponentScript("PlayerManager.js"); 9 10 let unitEnt = 33; 11 let playerEnt = 1; 12 13 AddMock(SYSTEM_ENTITY, IID_PlayerManager, { 14 "GetPlayerByID": (id) => playerEnt, 15 }); 16 17 AddMock(playerEnt, IID_Ownership, { 18 "GetOwner": () => playerEnt, 19 }); 20 21 let cmpIdentity = ConstructComponent(unitEnt, "Identity", { 22 "Classes": "Infantry Champion", 23 "VisibleClasses": "Champion", 24 "Civ": "athen", 25 "entity": unitEnt, 26 "CanGarrison": "true", 27 }); 28 29 TS_ASSERT_EQUALS(cmpIdentity.GetCiv(), "athen"); 30 TS_ASSERT_EQUALS(cmpIdentity.GetGender(), "male"); 31 TS_ASSERT_EQUALS(cmpIdentity.GetLang(), "greek"); 32 TS_ASSERT_EQUALS(cmpIdentity.GetCanGarrison(), true); -
binaries/data/mods/public/simulation/helpers/Setup.js
Property changes on: binaries/data/mods/public/simulation/components/tests/test_Identity.js ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
47 47 let gameTypeSettings = {}; 48 48 if (settings.WonderDuration) 49 49 gameTypeSettings.wonderDuration = settings.WonderDuration * 60 * 1000; 50 if (settings.GameType == "regicide") 51 gameTypeSettings.regicideGarrison = settings.RegicideGarrison; 50 52 if (settings.GameType) 51 53 cmpEndGameManager.SetGameType(settings.GameType, gameTypeSettings); 52 54 -
binaries/data/mods/public/simulation/templates/special_filter/regicide_hero_ungarrisonable.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <Entity merge=""> 3 <Identity merge=""> 4 <CanGarrison>false</CanGarrison> 5 </Identity> 6 </Entity> -
binaries/data/mods/public/simulation/templates/template_unit.xml
Property changes on: binaries/data/mods/public/simulation/templates/special_filter/regicide_hero_ungarrisonable.xml ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
36 36 <Unhealable>false</Unhealable> 37 37 </Health> 38 38 <Identity> 39 <CanGarrison>true</CanGarrison> 39 40 <GenericName>Unit</GenericName> 40 41 <Classes datatype="tokens">Unit ConquestCritical</Classes> 41 42 <Formations datatype="tokens">