Jubal
a6eccb1290
- 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.
37 lines
589 B
JavaScript
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;
|
|
},
|
|
});
|