1
0
forked from 0ad/0ad
0ad/binaries/data/mods/public/simulation/ai/jubot/resources.js
Jubal a6eccb1290 Here we go...
- Gather weights change over time
- Workers are occasionally moved (about once in every 400 turns, at
random, needs to be improved)
- Workers don't go and try hunting fish and snarl up the engine.

This was SVN commit r10318.
2011-09-25 21:15:26 +00:00

37 lines
589 B
JavaScript

var Resources = Class({
types: ["food", "wood", "stone", "metal"],
_init: function(amounts)
{
for each (var t in this.types)
this[t] = amounts[t] || 0;
},
canAfford: function(that)
{
for each (var t in this.types)
if (this[t] < that[t])
return false;
return true;
},
add: function(that)
{
for each (var t in this.types)
this[t] += that[t];
},
subtract: function(that)
{
for each (var t in this.types)
this[t] -= that[t];
},
multiply: function(n)
{
for each (var t in this.types)
this[t] *= n;
},
});