Ticket #638: Summary_v2.diff
File Summary_v2.diff, 32.0 KB (added by , 14 years ago) |
---|
-
binaries/data/mods/public/gui/page_summary.xml
5 5 <include>common/sprite1.xml</include> 6 6 <include>common/init.xml</include> 7 7 <include>summary/summary.xml</include> 8 <include>summary/sprites.xml</include> 8 9 <include>common/global.xml</include> 9 10 </page> -
binaries/data/mods/public/gui/session_new/session.js
114 114 stopMusic(); 115 115 endGame(); 116 116 117 Engine.SwitchGuiPage("page_summary.xml", { "gameResult" : gameResult }); 118 117 Engine.SwitchGuiPage("page_summary.xml", 118 { "gameResult" : gameResult, 119 "timeElapsed" : simState.timeElapsed, 120 "playerStates": simState.players 121 }); 119 122 } 120 123 121 124 // Return some data that we'll use when hotloading this file after changes -
binaries/data/mods/public/gui/summary/sprites.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 3 <sprites> 4 <sprite name="bgInfoHeading"> 5 <image backcolor="0 0 0 150" size="0 0 100% 100%" /> 6 </sprite> 7 8 <sprite name="bgInfoBox"> 9 <image backcolor="120 70 0 100" size="0 0 100% 100%" /> 10 </sprite> 11 </sprites> -
binaries/data/mods/public/gui/summary/summary.js
1 // Max player slots for any map (should read from config) 2 const MAX_SLOTS = 8; 3 4 var panelNames = [ 'unitsBuildingsPanel', 'resourcesPanel' ]; 5 var panelButtonNames = [ 'unitsBuildingsPanelButton', 'resourcesPanelButton' ]; 6 7 function /* string */ timeToString(/* int */ time /* in milliseconds */) 8 { 9 var hours = Math.floor(time / 1000 / 60 / 60); 10 var minutes = Math.floor(time / 1000 / 60) % 60; 11 var seconds = Math.floor(time / 1000) % 60; 12 return hours + ':' + (minutes < 10 ? '0' + minutes : minutes) + ':' + (seconds < 10 ? '0' + seconds : seconds); 13 } 14 15 function selectPanel(/*int*/ panelNumber) 16 { 17 for (var i = 0; i < panelNames.length; i++) 18 { 19 if (i != panelNumber) 20 { 21 getGUIObjectByName(panelNames[i]).hidden = true; 22 getGUIObjectByName(panelButtonNames[i]).sprite = "bgInfoHeading"; 23 } 24 else 25 { 26 getGUIObjectByName(panelNames[i]).hidden = false; 27 getGUIObjectByName(panelButtonNames[i]).sprite = "bgInfoBox"; 28 } 29 } 30 } 31 1 32 function init(data) 2 33 { 34 getGUIObjectByName("timeElapsed").caption = "Time elapsed: " + timeToString(data.timeElapsed); 35 3 36 getGUIObjectByName("summaryText").caption = data.gameResult; 37 38 //Space player boxes 39 var boxSpacing = 32; 40 for (var i = 0; i < panelNames.length; ++i) 41 for (var j = 0; j < MAX_SLOTS; ++j) 42 { 43 var box = getGUIObjectByName("playerBox"+i+"["+j+"]"); 44 var boxSize = box.size; 45 var h = boxSize.bottom - boxSize.top; 46 boxSize.top = j * boxSpacing; 47 boxSize.bottom = j * boxSpacing + h; 48 box.size = boxSize; 49 } 50 51 // TODO set mapPlayers as playerCounters.length 52 var maxPlayers = data.playerStates.length - 1; 53 54 // align headers 55 var left = 50; 56 var width = 100; 57 getGUIObjectByName("playerNameHeading").size = left + " 26 " + (left + width) + " 100%"; left += width; 58 getGUIObjectByName("unitsTrainedHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 59 getGUIObjectByName("unitsLostHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 60 getGUIObjectByName("enemyUnitsKilledHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 61 getGUIObjectByName("buildingsConstructedHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 62 getGUIObjectByName("buildingsLostHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 63 getGUIObjectByName("enemyBuildingsDestroyedHeading").size = left + " 6 " + (left + width) + " 100%"; left += width; 64 getGUIObjectByName("civCentresBuildHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 65 getGUIObjectByName("enemyCivCentresDestroyedHeading").size = left + " 6 " + (left + width) + " 100%"; left += width; 66 67 var left = 50; 68 getGUIObjectByName("playerName2Heading").size = left + " 26 " + (left + width) + " 100%"; left += width; 69 getGUIObjectByName("foodGatheredHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 70 getGUIObjectByName("vegetarianRatioHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 71 getGUIObjectByName("woodGatheredHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 72 getGUIObjectByName("metalGatheredHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 73 getGUIObjectByName("stoneGatheredHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 74 75 // Show counters 76 for (var i = 0; i < MAX_SLOTS; ++i) 77 { 78 if (i < maxPlayers) 79 { 80 var playerState = data.playerStates[i+1]; 81 82 for (var k = 0; k < panelNames.length; ++k) 83 { 84 var playerBox = getGUIObjectByName("playerBox"+k+"["+i+"]"); 85 playerBox.hidden = false; 86 87 var colourString = "colour: " + playerState.colour.r * 255 + " " + playerState.colour.g * 255 + " " + playerState.colour.b * 255; 88 playerBox.sprite = colourString + " 32"; 89 var playerColourBox = getGUIObjectByName("playerColourBox"+k+"["+i+"]"); 90 playerColourBox.sprite = colourString + " 255"; 91 92 var playerName = getGUIObjectByName("playerName"+k+"["+i+"]"); 93 playerName.caption = playerState.name; 94 } 95 96 var unitsTrained = getGUIObjectByName("unitsTrained["+i+"]"); 97 var unitsLost = getGUIObjectByName("unitsLost["+i+"]"); 98 var enemyUnitsKilled = getGUIObjectByName("enemyUnitsKilled["+i+"]"); 99 var buildingsConstructed = getGUIObjectByName("buildingsConstructed["+i+"]"); 100 var buildingsLost = getGUIObjectByName("buildingsLost["+i+"]"); 101 var enemyBuildingsDestroyed = getGUIObjectByName("enemyBuildingsDestroyed["+i+"]"); 102 var civCentresBuild = getGUIObjectByName("civCentresBuild["+i+"]"); 103 var enemyCivCentresDestroyed = getGUIObjectByName("enemyCivCentresDestroyed["+i+"]"); 104 105 var foodGathered = getGUIObjectByName("foodGathered["+i+"]"); 106 var vegetarianRatio = getGUIObjectByName("vegetarianRatio["+i+"]"); 107 var woodGathered = getGUIObjectByName("woodGathered["+i+"]"); 108 var metalGathered = getGUIObjectByName("metalGathered["+i+"]"); 109 var stoneGathered = getGUIObjectByName("stoneGathered["+i+"]"); 110 111 // align counters 112 113 var left = 140; 114 var width = 100; 115 unitsTrained.size = left + " 2 " + (left + width) + " 100%"; left += width; 116 unitsLost.size = left + " 2 " + (left + width) + " 100%"; left += width; 117 enemyUnitsKilled.size = left + " 2 " + (left + width) + " 100%"; left += width; 118 buildingsConstructed.size = left + " 2 " + (left + width) + " 100%"; left += width; 119 buildingsLost.size = left + " 2 " + (left + width) + " 100%"; left += width; 120 enemyBuildingsDestroyed.size = left + " 2 " + (left + width) + " 100%"; left += width; 121 civCentresBuild.size = left + " 2 " + (left + width) + " 100%"; left += width; 122 enemyCivCentresDestroyed.size = left + " 2 " + (left + width) + " 100%"; left += width; 123 var size = getGUIObjectByName("playerBox0["+i+"]").size; 124 size.right = left + 10; 125 getGUIObjectByName("playerBox0["+i+"]").size = size; 126 127 128 var left = 140; 129 foodGathered.size = left + " 2 " + (left + width) + " 100%"; left += width; 130 vegetarianRatio.size = left + " 2 " + (left + width) + " 100%"; left += width; 131 woodGathered.size = left + " 2 " + (left + width) + " 100%"; left += width; 132 metalGathered.size = left + " 2 " + (left + width) + " 100%"; left += width; 133 stoneGathered.size = left + " 2 " + (left + width) + " 100%"; left += width; 134 var size = getGUIObjectByName("playerBox1["+i+"]").size; 135 size.right = left + 10; 136 getGUIObjectByName("playerBox1["+i+"]").size = size; 137 138 // display counters 139 unitsTrained.caption = playerState.statistics.unitsTrained; 140 unitsLost.caption = playerState.statistics.unitsLost; 141 enemyUnitsKilled.caption = playerState.statistics.enemyUnitsKilled; 142 buildingsConstructed.caption = playerState.statistics.buildingsConstructed; 143 buildingsLost.caption = playerState.statistics.buildingsLost; 144 enemyBuildingsDestroyed.caption = playerState.statistics.enemyBuildingsDestroyed; 145 civCentresBuild.caption = playerState.statistics.civCentresBuild; 146 enemyCivCentresDestroyed.caption = playerState.statistics.enemyCivCentresDestroyed; 147 148 foodGathered.caption = playerState.statistics.resourcesGathered.food; 149 vegetarianRatio.caption = Math.floor(playerState.statistics.resourcesGathered.food > 0 ? 150 (playerState.statistics.resourcesGathered.vegetarianFood / playerState.statistics.resourcesGathered.food) * 100 : 0) + "%"; 151 woodGathered.caption = playerState.statistics.resourcesGathered.wood; 152 metalGathered.caption = playerState.statistics.resourcesGathered.metal; 153 stoneGathered.caption = playerState.statistics.resourcesGathered.stone; 154 } 155 else 156 { 157 // hide player boxes 158 for (var k = 0; k < panelNames.length; ++k) 159 { 160 var playerBox = getGUIObjectByName("playerBox"+k+"["+i+"]"); 161 playerBox.hidden = true; 162 } 163 } 164 } 4 165 } -
binaries/data/mods/public/gui/summary/summary.xml
11 11 <object type="image" sprite="bkFillBlack"> 12 12 13 13 <object type="image" 14 style="wheatWindow Granite"14 style="wheatWindow" 15 15 size="25 35 100%-25 100%-25" 16 16 > 17 17 <object type="button" style="wheatWindowTitleBar"> 18 18 Summary 19 19 </object> 20 20 21 <object name="summaryText" 22 type="text" 23 size="50 50 100%-50 100%-200" 24 font="serif-16" 25 text_align="center" 26 text_valign="center" 27 /> 21 <object type="image" sprite="bgInfoHeading" size="0 10 100% 40"> 22 <object 23 name="summaryText" 24 type="text" 25 size="50 0 100%-50 30" 26 font="serif-bold-18" 27 textcolor="255 255 255" 28 text_align="center" 29 /> 28 30 31 <object 32 name="timeElapsed" 33 type="text" 34 size="100%-200 0 100%-10 30" 35 font="serif-16" 36 textcolor="255 255 255" 37 text_align="center" 38 /> 39 </object> 40 41 42 <object name="unitsBuildingsPanelButton" type="button" sprite="bgInfoBox" text_align="center" size="10 75 160 101"> 43 <action on="Press">selectPanel(0);</action> 44 Units/buildings 45 </object> 46 <object name="resourcesPanelButton" type="button" sprite="bgInfoHeading" text_align="center" size="160 75 310 101"> 47 <action on="Press">selectPanel(1);</action> 48 Resources 49 </object> 50 <object name="unitsBuildingsPanel" type="image" sprite="bgInfoBox" size="10 100 100%-10 100%-50"> 51 52 <object size="0 0 100% 100%-50"> 53 <object name="playerNameHeading" type="text" text_align="left" font="serif-bold-14" > 54 Player name 55 </object> 56 <object name="unitsTrainedHeading" type="text" text_align="center" font="serif-bold-14" > 57 Units trained 58 </object> 59 <object name="unitsLostHeading" type="text" text_align="center" font="serif-bold-14" > 60 Units lost 61 </object> 62 <object name="enemyUnitsKilledHeading" type="text" text_align="center" font="serif-bold-14" > 63 Enemy units killed 64 </object> 65 <object name="buildingsConstructedHeading" type="text" text_align="center" font="serif-bold-14" > 66 Buildings constructed 67 </object> 68 <object name="buildingsLostHeading" type="text" text_align="center" font="serif-bold-14" > 69 Buildings lost 70 </object> 71 <object name="enemyBuildingsDestroyedHeading" type="text" text_align="center" font="serif-bold-14" > 72 Enemy buildings destroyed 73 </object> 74 <object name="civCentresBuildHeading" type="text" text_align="center" font="serif-bold-14" > 75 Civ centres build 76 </object> 77 <object name="enemyCivCentresDestroyedHeading" type="text" text_align="center" font="serif-bold-14" > 78 Enemy civ centres destroyed 79 </object> 80 81 </object> 82 83 <object size="0 65 100% 100%-50"> 84 <repeat count="8"> 85 <object type="image" name="playerBox0[n]" size="10 0 10 30" hidden="true"> 86 <object name="playerColourBox0[n]" type="image" size="10 4 30 24" /> 87 <object name="playerName0[n]" type="text" text_align="left" size="40 2 140 100%" /> 88 <object name="unitsTrained[n]" type="text" text_align="center" /> 89 <object name="unitsLost[n]" type="text" text_align="center" /> 90 <object name="enemyUnitsKilled[n]" type="text" text_align="center" /> 91 <object name="buildingsConstructed[n]" type="text" text_align="center" /> 92 <object name="buildingsLost[n]" type="text" text_align="center" /> 93 <object name="enemyBuildingsDestroyed[n]" type="text" text_align="center" /> 94 <object name="civCentresBuild[n]" type="text" text_align="center" /> 95 <object name="enemyCivCentresDestroyed[n]" type="text" text_align="center" /> 96 </object> 97 </repeat> 98 </object> 99 100 </object> 101 <object name="resourcesPanel" type="image" sprite="bgInfoBox" size="10 100 100%-10 100%-50" hidden="true"> 102 103 <object size="0 0 100% 100%-50"> 104 <object name="playerName2Heading" type="text" text_align="left" font="serif-bold-14" > 105 Player name 106 </object> 107 <object name="foodGatheredHeading" type="text" text_align="center" font="serif-bold-14" > 108 Food gathered 109 </object> 110 <object name="vegetarianRatioHeading" type="text" text_align="center" font="serif-bold-14" > 111 Vegetarian ratio 112 </object> 113 <object name="woodGatheredHeading" type="text" text_align="center" font="serif-bold-14" > 114 Wood gathered 115 </object> 116 <object name="metalGatheredHeading" type="text" text_align="center" font="serif-bold-14" > 117 Metal gathered 118 </object> 119 <object name="stoneGatheredHeading" type="text" text_align="center" font="serif-bold-14" > 120 Stone gathered 121 </object> 122 123 </object> 124 125 <object size="0 65 100% 100%-50"> 126 <repeat count="8"> 127 <object type="image" name="playerBox1[n]" size="10 0 10 30" hidden="true"> 128 <object name="playerColourBox1[n]" type="image" size="10 4 30 24" /> 129 <object name="playerName1[n]" type="text" text_align="left" size="40 2 140 100%" /> 130 <object name="foodGathered[n]" type="text" text_align="center" /> 131 <object name="vegetarianRatio[n]" type="text" text_align="center" /> 132 <object name="woodGathered[n]" type="text" text_align="center" /> 133 <object name="metalGathered[n]" type="text" text_align="center" /> 134 <object name="stoneGathered[n]" type="text" text_align="center" /> 135 </object> 136 </repeat> 137 </object> 138 139 </object> 140 29 141 <object type="button" style="wheatButton" size="100%-150 100%-40 100% 100%"> 30 142 Main menu 31 143 <action on="Press"><![CDATA[ -
binaries/data/mods/public/simulation/components/Armour.js
33 33 34 34 // Reduce health 35 35 var cmpHealth = Engine.QueryInterface(this.entity, IID_Health); 36 cmpHealth.Reduce(total);36 return cmpHealth.Reduce(total); 37 37 }; 38 38 39 39 Armour.prototype.GetArmourStrengths = function() -
binaries/data/mods/public/simulation/components/Attack.js
212 212 var cmpDamageReceiver = Engine.QueryInterface(data.target, IID_DamageReceiver); 213 213 if (!cmpDamageReceiver) 214 214 return; 215 cmpDamageReceiver.TakeDamage(strengths.hack, strengths.pierce, strengths.crush); 215 var targetState = cmpDamageReceiver.TakeDamage(strengths.hack, strengths.pierce, strengths.crush); 216 // if target killed pick up loot and credit experience 217 if (targetState.killed == true) 218 { 219 var cmpLooter = Engine.QueryInterface(SYSTEM_ENTITY, IID_Looter); 220 cmpLooter.TargetKilled(this.entity, data.target); 221 } 216 222 217 223 Engine.PostMessage(data.target, MT_Attacked, 218 224 { "attacker": this.entity, "target": data.target }); -
binaries/data/mods/public/simulation/components/Foundation.js
107 107 var cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); 108 108 var cmpBuildingOwnership = Engine.QueryInterface(building, IID_Ownership); 109 109 cmpBuildingOwnership.SetOwner(cmpOwnership.GetOwner()); 110 110 111 var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); 112 var playerEntityId = cmpPlayerManager.GetPlayerByID(cmpOwnership.GetOwner()); 113 var cmpPlayer = Engine.QueryInterface(playerEntityId, IID_Player); 114 cmpPlayer.IncreaseConstructedBuildingsCounter(); 115 116 var cmpIdentity = Engine.QueryInterface(building, IID_Identity); 117 if (cmpIdentity.GetClassesList().indexOf("CivCentre") != -1) cmpPlayer.IncreaseBuildCivCentresCounter(); 118 111 119 var cmpHealth = Engine.QueryInterface(this.entity, IID_Health); 112 120 var cmpBuildingHealth = Engine.QueryInterface(building, IID_Health); 113 121 cmpBuildingHealth.SetHitpoints(cmpHealth.GetHitpoints()); -
binaries/data/mods/public/simulation/components/GuiInterface.js
20 20 GuiInterface.prototype.GetSimulationState = function(player) 21 21 { 22 22 var ret = { 23 "players": [] 23 "players": [], 24 "timeElapsed": 0 24 25 }; 25 26 27 var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); 28 ret.timeElapsed = cmpTimer.GetTime(); 29 26 30 var cmpPlayerMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); 27 31 var n = cmpPlayerMan.GetNumPlayers(); 28 32 for (var i = 0; i < n; ++i) … … 41 45 "team": cmpPlayer.GetTeam(), 42 46 "diplomacy": cmpPlayer.GetDiplomacy(), 43 47 "phase": cmpPlayer.GetPhase(), 48 "statistics": cmpPlayer.GetStatistics() 44 49 }; 45 50 ret.players.push(playerData); 46 51 } -
binaries/data/mods/public/simulation/components/Health.js
79 79 80 80 Health.prototype.Reduce = function(amount) 81 81 { 82 var state = { "killed": false }; 82 83 if (amount >= this.hitpoints) 83 84 { 84 85 // If this is the first time we reached 0, then die. … … 86 87 // might get called multiple times) 87 88 if (this.hitpoints) 88 89 { 90 state.killed = true; 91 89 92 PlaySound("death", this.entity); 90 93 91 94 if (this.template.DeathType == "corpse") … … 121 124 122 125 Engine.PostMessage(this.entity, MT_HealthChanged, { "from": old, "to": this.hitpoints }); 123 126 } 127 return state; 124 128 }; 125 129 126 130 Health.prototype.Increase = function(amount) -
binaries/data/mods/public/simulation/components/Identity.js
73 73 "<value>Organic</value>" + 74 74 "<value>Structure</value>" + 75 75 "<value>Civic</value>" + 76 "<value>CivCentre</value>" + 76 77 "<value>Economic</value>" + 77 78 "<value>Defensive</value>" + 78 79 "<value>Village</value>" + -
binaries/data/mods/public/simulation/components/Looter.js
1 1 function Looter() {} 2 2 3 3 Looter.prototype.Schema = 4 "< empty/>";4 "<a:component type='system'/><empty/>"; 5 5 6 /* 7 * TODO: this all needs to be designed and implemented 8 */ 6 // called when some units kills something (another unit, building, animal etc) 7 // updating player statistics only for now 8 Looter.prototype.TargetKilled = function(killerEntity, targetEntity) 9 { 10 var cmpTargetIdentity = Engine.QueryInterface(targetEntity, IID_Identity); 11 if (cmpTargetIdentity) 12 { 13 var classes = cmpTargetIdentity.GetClassesList(); 14 // we want to deal only with real structures, not foundations 15 var cmpFoundation = Engine.QueryInterface(targetEntity, IID_Foundation); 16 var targetIsStructure = classes.indexOf("Structure") != -1 && cmpFoundation == null; 17 var targetIsUnit = classes.indexOf("Unit") != -1; 18 var targetIsCivCentre = classes.indexOf("CivCentre") != -1; 19 20 var cmpKillerOwnership = Engine.QueryInterface(killerEntity, IID_Ownership); 21 var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); 22 var killerPlayerEntityId = cmpPlayerManager.GetPlayerByID(cmpKillerOwnership.GetOwner()); 23 var cmpKillerPlayer = Engine.QueryInterface(killerPlayerEntityId, IID_Player); 24 25 var cmpTargetOwnership = Engine.QueryInterface(targetEntity, IID_Ownership); 26 27 // don't increase counters if target player is gaia (player 0) 28 if (cmpTargetOwnership.GetOwner() != 0) 29 { 30 if (targetIsUnit) cmpKillerPlayer.IncreaseEnemyUnitsKilledCounter(); 31 if (targetIsStructure) cmpKillerPlayer.IncreaseEnemyBuildingsDestroyedCounter(); 32 if (targetIsCivCentre) cmpKillerPlayer.IncreaseEnemyCivCentresDestroyedCounter(); 33 } 34 } 35 } 9 36 10 37 Engine.RegisterComponentType(IID_Looter, "Looter", Looter); 11 38 -
binaries/data/mods/public/simulation/components/Player.js
24 24 this.state = "active"; // game state - one of "active", "defeated", "won" 25 25 this.diplomacy = []; // array of diplomatic stances for this player with respect to other players (including self) 26 26 this.conquestCriticalEntitiesCount = 0; // number of owned units with ConquestCritical class 27 // statistics 28 // units 29 this.statistics = { 30 "unitsTrained" : 0, 31 "unitsLost" : 0, 32 "enemyUnitsKilled" : 0, 33 //buildings 34 "buildingsConstructed" : 0, 35 "buildingsLost" : 0, 36 "enemyBuildingsDestroyed" : 0, 37 // civ centres 38 "civCentresBuild" : 0, 39 "enemyCivCentresDestroyed" : 0, 40 // resources 41 "resourcesGathered" : { 42 "food": 0, 43 "wood": 0, 44 "metal": 0, 45 "stone": 0, 46 "vegetarianFood": 0 47 } 48 }; 27 49 this.phase = "village"; 28 50 }; 29 51 … … 121 143 return this.resourceCount; 122 144 }; 123 145 124 Player.prototype.AddResource = function(type, amount) 146 /* last param should be passed only from ResourceGatherer.PerformGather */ 147 Player.prototype.AddResource = function(type, amount, specificType) 125 148 { 126 149 this.resourceCount[type] += (+amount); 150 this.statistics.resourcesGathered[type] += amount; 151 152 if (type == "food" && (specificType == "fruit" || specificType == "grain")) 153 this.statistics.resourcesGathered["vegetarianFood"] += amount; 127 154 }; 128 155 129 156 Player.prototype.AddResources = function(amounts) 130 157 { 131 158 for (var type in amounts) 159 { 132 160 this.resourceCount[type] += (+amounts[type]); 161 } 133 162 }; 134 163 135 164 Player.prototype.TrySubtractResources = function(amounts) … … 177 206 return this.conquestCriticalEntitiesCount; 178 207 }; 179 208 209 180 210 Player.prototype.GetTeam = function() 181 211 { 182 212 return this.team; … … 207 237 this.phase = p; 208 238 }; 209 239 240 Player.prototype.GetStatistics = function() 241 { 242 return this.statistics; 243 }; 244 245 Player.prototype.IncreaseTrainedUnitsCounter = function() 246 { 247 return this.statistics.unitsTrained++; 248 }; 249 250 Player.prototype.IncreaseEnemyUnitsKilledCounter = function() 251 { 252 return this.statistics.enemyUnitsKilled++; 253 }; 254 255 Player.prototype.IncreaseConstructedBuildingsCounter = function() 256 { 257 return this.statistics.buildingsConstructed++; 258 }; 259 260 Player.prototype.IncreaseEnemyBuildingsDestroyedCounter = function() 261 { 262 return this.statistics.enemyBuildingsDestroyed++; 263 }; 264 265 Player.prototype.IncreaseBuildCivCentresCounter = function() 266 { 267 return this.statistics.civCentresBuild++; 268 }; 269 270 Player.prototype.IncreaseEnemyCivCentresDestroyedCounter = function() 271 { 272 return this.statistics.enemyCivCentresDestroyed++; 273 }; 274 210 275 // Keep track of population effects of all entities that 211 276 // become owned or unowned by this player 212 277 Player.prototype.OnGlobalOwnershipChanged = function(msg) 213 278 { 214 var classes = []; 279 var isConquestCritical = false; 280 var isStructure = false; 281 var isUnit = false; 215 282 216 283 // Load class list only if we're going to need it 217 284 if (msg.from == this.playerID || msg.to == this.playerID) 218 285 { 219 286 var cmpIdentity = Engine.QueryInterface(msg.entity, IID_Identity); 220 287 if (cmpIdentity) 221 classes = cmpIdentity.GetClassesList(); 288 { 289 var classes = cmpIdentity.GetClassesList(); 290 isConquestCritical = classes.indexOf("ConquestCritical") != -1; 291 // we want to count only real structures, not foundations 292 var cmpFoundation = Engine.QueryInterface(msg.entity, IID_Foundation); 293 isStructure = classes.indexOf("Structure") != -1 && cmpFoundation == null; 294 isUnit = classes.indexOf("Unit") != -1; 295 } 222 296 } 223 297 224 298 if (msg.from == this.playerID) 225 299 { 226 if (classes.indexOf("ConquestCritical") != -1) 227 this.conquestCriticalEntitiesCount--; 300 if (isConquestCritical) 301 this.conquestCriticalEntitiesCount--; 302 if (isStructure) 303 this.statistics.buildingsLost++; 304 if (isUnit) 305 this.statistics.unitsLost++; 228 306 229 307 var cost = Engine.QueryInterface(msg.entity, IID_Cost); 230 308 if (cost) … … 236 314 237 315 if (msg.to == this.playerID) 238 316 { 239 if ( classes.indexOf("ConquestCritical") != -1)317 if (isConquestCritical) 240 318 this.conquestCriticalEntitiesCount++; 241 319 242 320 var cost = Engine.QueryInterface(msg.entity, IID_Cost); 243 321 if (cost) 244 322 { -
binaries/data/mods/public/simulation/components/ResourceGatherer.js
74 74 var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); 75 75 var cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); 76 76 var cmpPlayer = Engine.QueryInterface(cmpPlayerManager.GetPlayerByID(cmpOwnership.GetOwner()), IID_Player); 77 cmpPlayer.AddResource(type.generic, status.amount );77 cmpPlayer.AddResource(type.generic, status.amount, type.specific); 78 78 79 79 // Tell the target we're gathering from it 80 80 Engine.PostMessage(target, MT_ResourceGather, -
binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
41 41 GetTeam: function() { return -1; }, 42 42 GetDiplomacy: function() { return []; }, 43 43 GetPhase: function() { return ""; }, 44 GetConquestCriticalEntitiesCount: function() { return 1; }, 45 GetUnitsTrained: function() { return 10; }, 46 GetUnitsLost: function() { return 9; }, 47 GetBuildingsConstructed: function() { return 5; }, 48 GetBuildingsLost: function() { return 4; }, 49 GetCivCentresBuild: function() { return 1; }, 50 GetResourcesGathered: function() { return { food: 100 }; }, 44 51 }); 45 52 46 53 AddMock(101, IID_Player, { … … 55 62 GetTeam: function() { return -1; }, 56 63 GetDiplomacy: function() { return [1]; }, 57 64 GetPhase: function() { return "village"; }, 65 GetConquestCriticalEntitiesCount: function() { return 1; }, 66 GetUnitsTrained: function() { return 10; }, 67 GetUnitsLost: function() { return 9; }, 68 GetBuildingsConstructed: function() { return 5; }, 69 GetBuildingsLost: function() { return 4; }, 70 GetCivCentresBuild: function() { return 1; }, 71 GetResourcesGathered: function() { return { food: 100 }; }, 58 72 }); 59 73 60 74 TS_ASSERT_UNEVAL_EQUALS(cmp.GetSimulationState(), { … … 71 85 team: -1, 72 86 diplomacy: [], 73 87 phase: "", 88 conquestCriticalEntitiesCount = 1; 89 unitsTrained = 10; 90 unitsLost = 9; 91 buildingsConstructed = 5; 92 buildingsLost = 4; 93 civCentresBuild = 1; 94 resourcesGathered = { 95 "food": 100, 96 "wood": 0, 97 "metal": 0, 98 "stone": 0 99 }, 74 100 }, 75 101 { 76 102 name: "Player 2", … … 84 110 team: -1, 85 111 diplomacy: [1], 86 112 phase: "village", 113 conquestCriticalEntitiesCount = 1; 114 unitsTrained = 10; 115 unitsLost = 9; 116 buildingsConstructed = 5; 117 buildingsLost = 4; 118 civCentresBuild = 1; 119 resourcesGathered = { 120 "food": 100, 121 "wood": 0, 122 "metal": 0, 123 "stone": 0 124 }, 87 125 } 88 126 ], 89 127 circularMap: false, -
binaries/data/mods/public/simulation/components/TrainingQueue.js
218 218 219 219 var cmpNewOwnership = Engine.QueryInterface(ent, IID_Ownership); 220 220 cmpNewOwnership.SetOwner(cmpOwnership.GetOwner()); 221 221 222 var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); 223 var playerEntityId = cmpPlayerManager.GetPlayerByID(cmpOwnership.GetOwner()); 224 var cmpPlayer = Engine.QueryInterface(playerEntityId, IID_Player); 225 cmpPlayer.IncreaseTrainedUnitsCounter(); 226 222 227 ents.push(ent); 223 228 224 229 // Play a sound, but only for the first in the batch (to avoid nasty phasing effects) -
binaries/data/mods/public/simulation/templates/template_structure_civic_civil_centre.xml
3 3 <Identity> 4 4 <GenericName>Civic Centre</GenericName> 5 5 <Tooltip>Build upon a settlement to capture territory.</Tooltip> 6 <Classes datatype="tokens">Village Defensive</Classes> 6 <Classes datatype="tokens"> 7 Village 8 Defensive 9 CivCentre 10 </Classes> 7 11 <Icon>structures/civic_centre.png</Icon> 8 12 </Identity> 9 13 <BuildRestrictions> -
source/simulation2/Simulation2.cpp
100 100 LOAD_SCRIPTED_COMPONENT("PlayerManager"); 101 101 LOAD_SCRIPTED_COMPONENT("Timer"); 102 102 LOAD_SCRIPTED_COMPONENT("EndGameManager"); 103 LOAD_SCRIPTED_COMPONENT("Looter"); 103 104 104 105 #undef LOAD_SCRIPTED_COMPONENT 105 106 }