This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Changeset 9659 for ps


Ignore:
Timestamp:
06/25/11 02:47:46 (14 years ago)
Author:
ben
Message:

Enforces max population limit, cleans up population variables in Player component. See #862
Max population defaults to 200

Location:
ps/trunk/binaries/data/mods/public
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/binaries/data/mods/public/gui/session/session.xml

    r9631 r9659  
    361361
    362362            <!-- Population -->
    363             <object size="374 0 464 100%" type="image" style="resourceCounter" tooltip="Population (current / maximum)" tooltip_style="sessionToolTipBold">
     363            <object size="374 0 464 100%" type="image" style="resourceCounter" tooltip="Population (current / limit)" tooltip_style="sessionToolTipBold">
    364364                <object size="-2 0 30 28" type="image" style="resourceIcon" cell_id="4"/>
    365365                <object size="32 0 100% 100%-2" type="text" style="resourceText" name="resourcePop"/>
  • ps/trunk/binaries/data/mods/public/simulation/components/Player.js

    r9623 r9659  
    1010    this.civ = undefined;
    1111    this.colour = { "r": 0.0, "g": 0.0, "b": 0.0, "a": 1.0 };
    12     this.popUsed = 0; // population of units owned by this player
    13     this.popReserved = 0; // population of units currently being trained
    14     this.popLimit = 0; // maximum population
     12    this.popUsed = 0; // population of units owned or trained by this player
     13    this.popBonuses = 0; // sum of population bonuses of player's entities
     14    this.maxPop = 200; // maximum population
    1515    this.trainingQueueBlocked = false; // indicates whether any training queue is currently blocked
    1616    this.resourceCount = {
     
    7171Player.prototype.TryReservePopulationSlots = function(num)
    7272{
    73     if (num > this.GetPopulationLimit() - this.GetPopulationCount())
     73    if (num > (this.GetPopulationLimit() - this.GetPopulationCount()))
    7474        return false;
    7575
    76     this.popReserved += num;
     76    this.popUsed += num;
    7777    return true;
    7878};
     
    8080Player.prototype.UnReservePopulationSlots = function(num)
    8181{
    82     this.popReserved -= num;
     82    this.popUsed -= num;
    8383};
    8484
    8585Player.prototype.GetPopulationCount = function()
    8686{
    87     return this.popUsed + this.popReserved;
    88 };
    89 
    90 Player.prototype.SetPopulationLimit = function(limit)
    91 {
    92     this.popLimit = limit;
     87    return this.popUsed;
    9388};
    9489
    9590Player.prototype.GetPopulationLimit = function()
    9691{
    97     return this.popLimit;
     92    return Math.min(this.maxPop, this.popBonuses);
     93};
     94
     95Player.prototype.SetMaxPopulation = function(max)
     96{
     97    this.maxPop = max;
     98};
     99
     100Player.prototype.GetMaxPopulation = function()
     101{
     102    return this.maxPop;
    98103};
    99104
     
    275280        {
    276281            this.popUsed -= cost.GetPopCost();
    277             this.popLimit -= cost.GetPopBonus();
     282            this.popBonuses -= cost.GetPopBonus();
    278283        }
    279284    }
     
    288293        {
    289294            this.popUsed += cost.GetPopCost();
    290             this.popLimit += cost.GetPopBonus();
     295            this.popBonuses += cost.GetPopBonus();
    291296        }
    292297    }
  • ps/trunk/binaries/data/mods/public/simulation/helpers/Player.js

    r9623 r9659  
    9393            if (getSetting(pData, pDefs, "PopulationLimit") !== undefined)
    9494            {
    95                 player.SetPopulationLimit(getSetting(pData, pDefs, "PopulationLimit"));
     95                player.SetMaxPopulation(getSetting(pData, pDefs, "PopulationLimit"));
    9696            }
    9797           
Note: See TracChangeset for help on using the changeset viewer.