nodegame-client
Advanced tools
Comparing version 0.1.3 to 0.1.4
{ | ||
"name": "nodegame-client" | ||
, "description": "nodeGame client for the browser and node.js" | ||
, "version": "0.1.3" | ||
, "version": "0.1.4" | ||
, "main" : "nodeGame.js" | ||
@@ -6,0 +6,0 @@ , "homepage": "http://www.nodegame.org" |
(function (exports, node) { | ||
/* | ||
* Holds information about the list of players. | ||
* | ||
*/ | ||
var JSUS = node.Utils; | ||
@@ -18,3 +13,19 @@ var NDDB = node.NDDB; | ||
/** | ||
* Transforms an array of array (of players) into an | ||
* array of PlayerList instances and returns it. | ||
* | ||
* The original array is modified. | ||
* | ||
*/ | ||
PlayerList.array2Groups = function (array) { | ||
if (!array) return; | ||
for (var i = 0; i < array.length; i++) { | ||
array[i] = new PlayerList({}, array[i]); | ||
}; | ||
return array; | ||
}; | ||
/** | ||
* PlayerList interface | ||
@@ -108,3 +119,3 @@ * | ||
if (this.exist(id)) { | ||
this.pl[id] = player; | ||
this.db[id] = player; | ||
@@ -130,3 +141,3 @@ return true; | ||
//node.log(this.pl); | ||
//node.log(this.db); | ||
@@ -233,2 +244,14 @@ this.select('id', '=', id).first().state = state; | ||
PlayerList.prototype.getNGroups = function (N) { | ||
if (!N) return; | ||
var groups = JSUS.getNGroups(this.db, N); | ||
return PlayerList.array2Groups(groups); | ||
}; | ||
PlayerList.prototype.getGroupsSizeN = function (N) { | ||
if (!N) return; | ||
var groups = JSUS.getGroupsSizeN(this.db, N); | ||
return PlayerList.array2Groups(groups); | ||
}; | ||
//Player | ||
@@ -292,5 +315,5 @@ | ||
// | ||
// for (var key in this.pl) { | ||
// if (this.pl.hasOwnProperty(key)) { | ||
// result.push(this.pl[key]); | ||
// for (var key in this.db) { | ||
// if (this.db.hasOwnProperty(key)) { | ||
// result.push(this.db[key]); | ||
// } | ||
@@ -297,0 +320,0 @@ // } |
Sorry, the diff of this file is not supported yet
64405
18
2065