Index: binaries/data/mods/public/gui/session/session.js =================================================================== --- binaries/data/mods/public/gui/session/session.js +++ binaries/data/mods/public/gui/session/session.js @@ -159,7 +159,8 @@ /** * Unit classes to be checked for the idle-worker-hotkey. */ -var g_WorkerTypes = ["Female+Support", "Trader", "FishingBoat", "CitizenSoldier"]; +var g_WorkerTypes = ["SupportFemale", "Trader", "FishingBoat", "CitizenSoldier"]; + /** * Unit classes to be checked for the military-only-selection modifier and for the idle-warrior-hotkey. */ @@ -1379,7 +1380,7 @@ "total", "Infantry", "Worker", - "Female", + "SupportFemale", "Cavalry", "Champion", "Hero", Index: binaries/data/mods/public/gui/summary/counters.js =================================================================== --- binaries/data/mods/public/gui/summary/counters.js +++ binaries/data/mods/public/gui/summary/counters.js @@ -75,7 +75,7 @@ g_TeamHelperData[playerState.team] = { "food": 0, "vegetarianFood": 0, - "female": 0, + "supportFemale": 0, "worker": 0, "enemyUnitsKilled": 0, "unitsLost": 0, @@ -89,7 +89,7 @@ g_TeamHelperData[playerState.team].food += playerState.statistics.resourcesGathered.food; g_TeamHelperData[playerState.team].vegetarianFood += playerState.statistics.resourcesGathered.vegetarianFood; - g_TeamHelperData[playerState.team].female += playerState.statistics.unitsTrained.Female; + g_TeamHelperData[playerState.team].supportFemale += playerState.statistics.unitsTrained.SupportFemale; g_TeamHelperData[playerState.team].worker += playerState.statistics.unitsTrained.Worker; g_TeamHelperData[playerState.team].enemyUnitsKilled += playerState.statistics.enemyUnitsKilled.total; @@ -439,7 +439,7 @@ function calculateFeminization(playerState) { return formatPercent( - playerState.statistics.unitsTrained.Female, + playerState.statistics.unitsTrained.SupportFemale, playerState.statistics.unitsTrained.Worker); } @@ -479,7 +479,7 @@ if (w == 0) teamTotal = formatPercent(g_TeamHelperData[t].vegetarianFood, g_TeamHelperData[t].food); else if (w == 1) - teamTotal = formatPercent(g_TeamHelperData[t].female, g_TeamHelperData[t].worker); + teamTotal = formatPercent(g_TeamHelperData[t].supportFemale, g_TeamHelperData[t].worker); else if (w == 2) teamTotal = formatRatio(g_TeamHelperData[t].enemyUnitsKilled, g_TeamHelperData[t].unitsLost); else if (w == 3) Index: binaries/data/mods/public/maps/random/survivalofthefittest_triggers.js =================================================================== --- binaries/data/mods/public/maps/random/survivalofthefittest_triggers.js +++ binaries/data/mods/public/maps/random/survivalofthefittest_triggers.js @@ -171,7 +171,7 @@ { if (TriggerHelper.EntityHasClass(entity, "CivilCentre")) this.playerCivicCenter[i] = entity; - else if (TriggerHelper.EntityHasClass(entity, "Female")) + else if (TriggerHelper.EntityHasClass(entity, "SupportFemale")) { let cmpDamageReceiver = Engine.QueryInterface(entity, IID_DamageReceiver); cmpDamageReceiver.SetInvulnerability(true); Index: binaries/data/mods/public/simulation/ai/petra/attackPlan.js =================================================================== --- binaries/data/mods/public/simulation/ai/petra/attackPlan.js +++ binaries/data/mods/public/simulation/ai/petra/attackPlan.js @@ -1374,7 +1374,7 @@ else if (target.hasClass("Ship") && !ent.hasClass("Ship")) maybeUpdate = true; else if (!ent.hasClass("Cavalry") && !ent.hasClass("Ranged") && - target.hasClass("Female") && target.unitAIState().split(".")[1] == "FLEEING") + target.hasClass("SupportFemale") && target.unitAIState().split(".")[1] == "FLEEING") maybeUpdate = true; } @@ -1467,7 +1467,7 @@ return false; if (enemy.hasClass("Animal")) return false; - if (nearby && enemy.hasClass("Female") && enemy.unitAIState().split(".")[1] == "FLEEING") + if (nearby && enemy.hasClass("SupportFemale") && enemy.unitAIState().split(".")[1] == "FLEEING") return false; let dist = API3.SquareVectorDistance(enemy.position(), ent.position()); if (dist > range) Index: binaries/data/mods/public/simulation/ai/petra/baseManager.js =================================================================== --- binaries/data/mods/public/simulation/ai/petra/baseManager.js +++ binaries/data/mods/public/simulation/ai/petra/baseManager.js @@ -611,8 +611,8 @@ if (lessNeed.type === "food" && gatherers.filter(API3.Filters.byClass("CitizenSoldier")).hasEntities()) only = "CitizenSoldier"; else if ((lessNeed.type === "stone" || lessNeed.type === "metal") && moreNeed.type !== "stone" && moreNeed.type !== "metal" && - gatherers.filter(API3.Filters.byClass("Female")).hasEntities()) - only = "Female"; + gatherers.filter(API3.Filters.byClass("SupportFemale")).hasEntities()) + only = "SupportFemale"; gatherers.forEach( function (ent) { if (!ent.canGather(moreNeed.type)) Index: binaries/data/mods/public/simulation/components/Identity.js =================================================================== --- binaries/data/mods/public/simulation/components/Identity.js +++ binaries/data/mods/public/simulation/components/Identity.js @@ -54,7 +54,7 @@ "" + "" + "" + - "" + + "" + "" + "tokens" + "" + Index: binaries/data/mods/public/simulation/components/StatisticsTracker.js =================================================================== --- binaries/data/mods/public/simulation/components/StatisticsTracker.js +++ binaries/data/mods/public/simulation/components/StatisticsTracker.js @@ -8,7 +8,7 @@ this.unitsClasses = [ "Infantry", "Worker", - "Female", + "SupportFemale", "Cavalry", "Champion", "Hero", @@ -19,7 +19,7 @@ this.unitsTrained = { "Infantry": 0, "Worker": 0, - "Female": 0, + "SupportFemale": 0, "Cavalry": 0, "Champion": 0, "Hero": 0, @@ -31,7 +31,7 @@ this.unitsLost = { "Infantry": 0, "Worker": 0, - "Female": 0, + "SupportFemale": 0, "Cavalry": 0, "Champion": 0, "Hero": 0, @@ -44,7 +44,7 @@ this.enemyUnitsKilled = { "Infantry": 0, "Worker": 0, - "Female": 0, + "SupportFemale": 0, "Cavalry": 0, "Champion": 0, "Hero": 0, @@ -57,7 +57,7 @@ this.unitsCaptured = { "Infantry": 0, "Worker": 0, - "Female": 0, + "SupportFemale": 0, "Cavalry": 0, "Champion": 0, "Hero": 0, Index: binaries/data/mods/public/simulation/components/TechnologyManager.js =================================================================== --- binaries/data/mods/public/simulation/components/TechnologyManager.js +++ binaries/data/mods/public/simulation/components/TechnologyManager.js @@ -26,7 +26,7 @@ // This stores the modifications to unit stats from researched technologies // Example data: {"ResourceGatherer/Rates/food.grain": [ - // {"multiply": 1.15, "affects": ["Female", "Infantry Swordsman"]}, + // {"multiply": 1.15, "affects": ["SupportFemale", "Infantry Swordsman"]}, // {"add": 2} // ]} this.modifications = {}; Index: binaries/data/mods/public/simulation/components/TrainingRestrictions.js =================================================================== --- binaries/data/mods/public/simulation/components/TrainingRestrictions.js +++ binaries/data/mods/public/simulation/components/TrainingRestrictions.js @@ -7,7 +7,7 @@ "Hero" + "" + "" + - "" + + "" + "" + ""; Index: binaries/data/mods/public/simulation/components/tests/test_Pack.js =================================================================== --- /dev/null +++ binaries/data/mods/public/simulation/components/tests/test_Pack.js @@ -0,0 +1,156 @@ +Engine.LoadHelperScript("Player.js"); +Engine.LoadHelperScript("Sound.js"); +Engine.LoadHelperScript("Transform.js"); +Engine.LoadHelperScript("ValueModification.js"); +Engine.LoadComponentScript("interfaces/TechnologyManager.js"); +Engine.LoadComponentScript("interfaces/AuraManager.js"); +Engine.LoadComponentScript("interfaces/Capturable.js"); +Engine.LoadComponentScript("interfaces/GarrisonHolder.js"); +Engine.LoadComponentScript("interfaces/Guard.js"); +Engine.LoadComponentScript("interfaces/Health.js"); +Engine.LoadComponentScript("interfaces/Pack.js"); +Engine.LoadComponentScript("interfaces/Player.js"); +Engine.LoadComponentScript("interfaces/Sound.js"); +Engine.LoadComponentScript("interfaces/Timer.js"); +Engine.LoadComponentScript("interfaces/UnitAI.js"); +Engine.LoadComponentScript("Pack.js"); +Engine.RegisterGlobal("MT_EntityRenamed", "entityRenamed"); + +const ent = 170; +const newEnt = 171; +let timerActivated = false; + +AddMock(ent, IID_Visual, { + "SelectAnimation": (name, once, speed, soundgroup) => name +}); + +AddMock(ent, IID_Ownership, { + "GetOwner": () => 1 +}); + +AddMock(SYSTEM_ENTITY, IID_PlayerManager, { + "GetPlayerByID": id => 11 +}); + +AddMock(11, IID_Player, { + "GetCheatTimeMultiplier": () => 1 +}); + +AddMock(ent, IID_Sound, { + "PlaySoundGroup": name => {} +}); + +AddMock(SYSTEM_ENTITY, IID_Timer, { + "CancelTimer": id => { timerActivated = false; return; }, + "SetInterval": (ent, iid, funcname, time, repeattime, data) => { timerActivated = true; return 7; } +}); + +Engine.AddEntity = function(template) { + TS_ASSERT_EQUALS(template, "finalTemplate"); + return true; +}; + +// Test Packing + +let template = { + "Entity": "finalTemplate", + "Time": "2000", + "State": "unpacked" +}; +let cmpPack = ConstructComponent(ent, "Pack", template); + +// Check internals +TS_ASSERT(!cmpPack.packed); +TS_ASSERT(!cmpPack.packing); +TS_ASSERT_EQUALS(cmpPack.elapsedTime, 0); +TS_ASSERT_EQUALS(cmpPack.timer, undefined); + +TS_ASSERT(!cmpPack.IsPacked()); +TS_ASSERT(!cmpPack.IsPacking()); +TS_ASSERT_EQUALS(cmpPack.GetProgress(), 0); + +// Pack +cmpPack.Pack(); +TS_ASSERT_EQUALS(cmpPack.timer, 7); +TS_ASSERT(cmpPack.IsPacking()); + +// Listen to destroy message +cmpPack.OnDestroy(); +TS_ASSERT(!timerActivated); + +// Test UnPacking + +template = { + "Entity": "finalTemplate", + "Time": "2000", + "State": "packed" +}; + +cmpPack = ConstructComponent(ent, "Pack", template); + +// Check internals +TS_ASSERT(cmpPack.packed); +TS_ASSERT(!cmpPack.packing); +TS_ASSERT_EQUALS(cmpPack.elapsedTime, 0); +TS_ASSERT_EQUALS(cmpPack.timer, undefined); + +TS_ASSERT(cmpPack.IsPacked()); +TS_ASSERT(!cmpPack.IsPacking()); +TS_ASSERT_EQUALS(cmpPack.GetProgress(), 0); + +// Unpack +cmpPack.Unpack(); +TS_ASSERT(cmpPack.IsPacking()); +TS_ASSERT_EQUALS(cmpPack.timer, 7); + +// Unpack progress +cmpPack.elapsedTime = 400; +cmpPack.PackProgress({}, 100); + +TS_ASSERT(cmpPack.IsPacking()); +TS_ASSERT_EQUALS(cmpPack.GetElapsedTime(), 400 + 100 + 250); +TS_ASSERT_EQUALS(cmpPack.GetProgress(), (400 + 100 + 250) / 2000); + +// Try to Pack or Unpack while packing, nothing happen +cmpPack.elapsedTime = 400; + +cmpPack.Unpack(); +TS_ASSERT(cmpPack.IsPacking()); +TS_ASSERT_EQUALS(cmpPack.GetElapsedTime(), 400); +TS_ASSERT_EQUALS(cmpPack.timer, 7); +TS_ASSERT(timerActivated); + +cmpPack.Pack(); +TS_ASSERT(cmpPack.IsPacking()); +TS_ASSERT_EQUALS(cmpPack.GetElapsedTime(), 400); +TS_ASSERT_EQUALS(cmpPack.timer, 7); +TS_ASSERT(timerActivated); + +// Cancel +cmpPack.CancelPack(); + +TS_ASSERT(!cmpPack.IsPacking()); +TS_ASSERT_EQUALS(cmpPack.GetElapsedTime(), 0) +TS_ASSERT_EQUALS(cmpPack.GetProgress(), 0); +TS_ASSERT_EQUALS(cmpPack.timer, undefined); +TS_ASSERT(!timerActivated); + +// Progress until completing +cmpPack.Unpack(); +cmpPack.elapsedTime = 1800; +cmpPack.PackProgress({}, 100); + +TS_ASSERT(cmpPack.IsPacking()); +TS_ASSERT_EQUALS(cmpPack.GetElapsedTime(), 1800 + 100 + 250); +TS_ASSERT_EQUALS(cmpPack.GetProgress(), (1800 + 100 + 250) / 2000); // Shouldn't we cap at 1? +TS_ASSERT_EQUALS(cmpPack.timer, 7); +TS_ASSERT(timerActivated); + +// Unpack completing +cmpPack.Unpack(); +cmpPack.elapsedTime = 2100; +cmpPack.PackProgress({}, 100); + +TS_ASSERT(cmpPack.IsPacking()); // It should be reset? (See StatusBars) +TS_ASSERT(!cmpPack.timer); +TS_ASSERT(!timerActivated); Index: binaries/data/mods/public/simulation/templates/template_structure_wonder.xml =================================================================== --- binaries/data/mods/public/simulation/templates/template_structure_wonder.xml +++ binaries/data/mods/public/simulation/templates/template_structure_wonder.xml @@ -66,6 +66,15 @@ pop_wonder + + + 1 + 1 + 1 + 1 + + 2000 + Index: binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_bireme.xml =================================================================== --- binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_bireme.xml +++ binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_bireme.xml @@ -35,7 +35,7 @@ 20 0 - Female Infantry Dog + SupportFemale Infantry Dog Support Infantry Cavalry Dog 0 10 Index: binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_fishing.xml =================================================================== --- binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_fishing.xml +++ binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_fishing.xml @@ -22,7 +22,7 @@ 1 0 - Female Infantry + SupportFemale Infantry Support Infantry 0 10 Index: binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_merchant.xml =================================================================== --- binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_merchant.xml +++ binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_merchant.xml @@ -14,7 +14,7 @@ 15 0 - Female Infantry Dog + SupportFemale Infantry Dog Support Infantry Cavalry Dog 0 10 Index: binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_quinquereme.xml =================================================================== --- binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_quinquereme.xml +++ binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_quinquereme.xml @@ -44,7 +44,7 @@ 50 0 - Female Infantry Dog + SupportFemale Infantry Dog Support Infantry Cavalry Dog Siege Elephant 0 10 Index: binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_trireme.xml =================================================================== --- binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_trireme.xml +++ binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_trireme.xml @@ -35,7 +35,7 @@ 30 0 - Female Infantry Dog + SupportFemale Infantry Dog Support Infantry Cavalry Dog Siege Elephant 0 10 Index: binaries/data/mods/public/simulation/templates/template_unit_support_female_citizen.xml =================================================================== --- binaries/data/mods/public/simulation/templates/template_unit_support_female_citizen.xml +++ binaries/data/mods/public/simulation/templates/template_unit_support_female_citizen.xml @@ -43,7 +43,7 @@ Female Citizen female Women in the ancient world took on a variety of roles - from leadership (Celts) to servant (Greeks). Women are hard workers, the economic backbone of any civilization. In history, it was typical when all the males (capable of fighting) were killed for the females, children, and elderly to be sold as slaves. - Female + SupportFemale Citizen Worker Index: binaries/data/mods/public/simulation/templates/units/brit_hero_boudicca.xml =================================================================== --- binaries/data/mods/public/simulation/templates/units/brit_hero_boudicca.xml +++ binaries/data/mods/public/simulation/templates/units/brit_hero_boudicca.xml @@ -7,7 +7,7 @@ brit - Female Chariot + Chariot Boudicca (Chariot) Boadicea female