Commit 91733a2c authored by Terence Martin's avatar Terence Martin

Add player property to Ball

This gives the Ball the ability to return what player owns it based on
its own type. This will be used during the score modifications to
determine who gets the points.
parent 9aed72e4
......@@ -2848,6 +2848,21 @@ var nurdz;
enumerable: true,
configurable: true
});
Object.defineProperty(Ball.prototype, "player", {
/**
* Return the type of player that owns this ball. This is derived from
* the current ball type, and is read-only.
*
* @returns {PlayerType} the type of player that owns this ball. ball.
*/
get: function () {
if (this._ballType == BallType.BALL_PLAYER)
return game.PlayerType.PLAYER_HUMAN;
return game.PlayerType.PLAYER_COMPUTER;
},
enumerable: true,
configurable: true
});
/**
* Set the visual state of the ball to idle; this is the normal state,
* in which the ball just sits there, looking pretty.
......
......@@ -158,6 +158,19 @@ module nurdz.game
get isHidden () : boolean
{ return this._hidden; }
/**
* Return the type of player that owns this ball. This is derived from
* the current ball type, and is read-only.
*
* @returns {PlayerType} the type of player that owns this ball. ball.
*/
get player () : PlayerType
{
if (this._ballType == BallType.BALL_PLAYER)
return PlayerType.PLAYER_HUMAN;
return PlayerType.PLAYER_COMPUTER;
}
/**
* Construct a new ball entity that will render on the stage provided.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment