Added some extra garrison related functions. Fixes #1164.

This was SVN commit r11067.
This commit is contained in:
quantumstate
2012-02-13 22:41:15 +00:00
parent f3bde45c7b
commit b9e623a6d5
@@ -148,8 +148,6 @@ var EntityTemplate = Class({
return +this._template.ResourceSupply.Amount;
},
resourceGatherRates: function() {
if (!this._template.ResourceGatherer)
return undefined;
@@ -164,14 +162,21 @@ var EntityTemplate = Class({
return undefined;
return this._template.ResourceDropsite.Types.split(/\s+/);
},
garrisonableClasses: function() {
garrisonableClasses: function()
{
if (!this._template.GarrisonHolder)
return undefined;
return this._template.GarrisonHolder.List._string.split(/\s+/);
},
garrisonMax: function()
{
if (!this._template.GarrisonHolder)
return undefined;
return this._template.GarrisonHolder.Max;
},
/**
* Returns whether this is an animal that is too difficult to hunt.
@@ -326,13 +331,18 @@ var Entity = Class({
resourceSupplyAmount: function() { return this._entity.resourceSupplyAmount; },
resourceCarrying: function() { return this._entity.resourceCarrying; },
//Garrison related
garrisoned: function() { return new EntityCollection(this._ai, this._entity.garrisoned); },
garrisonSpaceAvailable: function()
{
return (this.garrisonMax() - this.garrisoned().length);
},
// TODO: visibility
move: function(x, z, queued) {
queued = queued || false;
Engine.PostCommand({"type": "walk", "entities": [this.id()], "x": x, "z": z, "queued": queued});