1
0
mirror of https://github.com/exane/not-gwent-online synced 2024-10-31 10:36:53 +00:00
not-gwent-online/server/Field.js
2015-06-14 16:01:25 +02:00

47 lines
777 B
JavaScript

var Field = (function(){
var Field = function(){
if(!(this instanceof Field)){
return (new Field());
}
/**
* constructor here
*/
this._cards = [];
};
var r = Field.prototype;
/**
* methods && properties here
* r.property = null;
* r.getProperty = function() {...}
*/
r._cards = null;
r._score = 0;
r.add = function(card) {
this._cards.push(card);
this.updateScore();
}
r.get = function() {
return this._cards;
}
r.getScore = function() {
return this._score;
}
r.updateScore = function() {
this._score = 0;
for(var i=0; i<this._cards.length; i++) {
var card = this._cards[i];
this._score += card.getPower();
}
}
return Field;
})();
module.exports = Field;