File: student/demo/gameplay/js/model/clientmodel.js
//STUDENT-EDITABLE-BEGIN
/**
This module contains the top-level client model class
@module catan.models
@namespace models
*/
var catan = catan || {};
catan.models = catan.models || {};
catan.models.ClientModel = (function clientModelNameSpace(){
/**
This the top-level client model class that contains the local player, map contents, etc.
@class ClientModel
@constructor
@param {integer} playerID The id of the local player, extracted from the cookie
*/
var ClientModel = (function ClientModelClass(){
function ClientModel(playerID){
}
/**
* This is called to fetch the game state from the server the very first time.
* It should: 1) fetch the game state JSON from the server, 2) update the client model with the
* returned data, 3) notify all client model listeners that the model has changed, and 4) invoke
* the success callback function with the object received from the server.
*
* @method initFromServer
* @param {function} success - A callback function that is called after the game state has been fetched from the server and the client model updated. This function is passed a single parameter which is the game state object received from the server.
* */
ClientModel.prototype.initFromServer = function(success){
// TODO: 1) fetch the game state from the server, 2) update the client model, 3) call the "success" function.
success();
}
return ClientModel;
}());
return ClientModel;
}());