|
|
|
@ -22,6 +22,39 @@ Function.prototype.inheritsFrom = function(parentObject)
|
|
|
|
|
/*Class*/ RadiumEngine = function()
|
|
|
|
|
{
|
|
|
|
|
this.version = "1.0";
|
|
|
|
|
var blah = "derp";
|
|
|
|
|
|
|
|
|
|
var /*Exception*/ Exception = this.Exception = function(message)
|
|
|
|
|
{
|
|
|
|
|
this.message = message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var /*Exception*/ ResourceException = this.ResourceException = function(message, resource, action)
|
|
|
|
|
{
|
|
|
|
|
this.resource = resource;
|
|
|
|
|
this.message = message;
|
|
|
|
|
this.action = action;
|
|
|
|
|
}
|
|
|
|
|
ResourceException.inheritsFrom(Exception);
|
|
|
|
|
|
|
|
|
|
var /*Class*/ Player = this.Player = function()
|
|
|
|
|
{
|
|
|
|
|
this.credits = 0; /* Integer */
|
|
|
|
|
this.health = 1; /* Fraction */
|
|
|
|
|
this.resources = {}; /* Associative array -> Integer */
|
|
|
|
|
|
|
|
|
|
this.TakeResource = function(resource, amount)
|
|
|
|
|
{
|
|
|
|
|
if(this.resources[resource])
|
|
|
|
|
{
|
|
|
|
|
this.resources[resource] -= amount;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw new ResourceException("This resource does not exist.", resource, "take");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var point_distance = this.point_distance = function(x1, y1, x2, y2)
|
|
|
|
|
{
|
|
|
|
|