Ykkrosh
c8c10a4871
Add various GUI pieces (exit button, resource counts, unit details). Clean up implementation of button panels. Split some content out of 'common' and into page-specific files. Delete some obsolete content. This was SVN commit r7337.
32 lines
526 B
JavaScript
32 lines
526 B
JavaScript
function Health() {}
|
|
|
|
Health.prototype.Init = function()
|
|
{
|
|
this.hitpoints = this.GetMaxHitpoints();
|
|
};
|
|
|
|
Health.prototype.GetHitpoints = function()
|
|
{
|
|
return this.hitpoints;
|
|
};
|
|
|
|
Health.prototype.GetMaxHitpoints = function()
|
|
{
|
|
return +this.template.Max;
|
|
};
|
|
|
|
Health.prototype.Reduce = function(amount)
|
|
{
|
|
if (amount >= this.hitpoints)
|
|
{
|
|
this.hitpoints = 0;
|
|
// TODO: need to destroy this entity, set up a corpse, etc
|
|
}
|
|
else
|
|
{
|
|
this.hitpoints -= amount;
|
|
}
|
|
}
|
|
|
|
Engine.RegisterComponentType(IID_Health, "Health", Health);
|