102 lines
1.9 KiB
JavaScript
102 lines
1.9 KiB
JavaScript
|
|
/**
|
|
* Games manager class
|
|
*/
|
|
class GamesManager{
|
|
name = 'games';
|
|
|
|
/**
|
|
* Class initializer
|
|
* @param {App} app Class initializer
|
|
*/
|
|
init(app){
|
|
const {db} = app;
|
|
|
|
/**
|
|
* Creates a new game definition
|
|
* @param {Context} ctx Request context
|
|
* @param {Game} data the game description
|
|
*/
|
|
this.create = async function(ctx, data){
|
|
|
|
}
|
|
|
|
/**
|
|
* Reads game definition by ID
|
|
* @param {Number} id game ID
|
|
* @returns {Game}
|
|
*/
|
|
this.read = async function(id){
|
|
|
|
}
|
|
|
|
/**
|
|
* Updates game definition
|
|
* @param {Context} ctx Request context
|
|
* @param {Game} data the game description
|
|
*/
|
|
this.update = async function(ctx, data){
|
|
|
|
}
|
|
|
|
/**
|
|
* Removes game by ID
|
|
* @param {Number} id game definition ID
|
|
*/
|
|
this.remove = async function(id){
|
|
|
|
}
|
|
|
|
/**
|
|
* Returns a set of games by given criteria
|
|
* @param {Query} query criteria
|
|
* @returns {Game[]}
|
|
*/
|
|
this.list = async function(query){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* Class starter
|
|
* @param {App} app The application
|
|
*/
|
|
async start(app){
|
|
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Game entity
|
|
*/
|
|
class Game {
|
|
/**
|
|
* Game name
|
|
* @type string
|
|
*/
|
|
name = null;
|
|
|
|
/**
|
|
* Game formal description
|
|
* @type GameDefinition
|
|
*/
|
|
definition = {
|
|
/**
|
|
*
|
|
*/
|
|
levels:[
|
|
{
|
|
name: 'Level 1',
|
|
environment: null,
|
|
objects:[
|
|
{
|
|
id: 15
|
|
}
|
|
]
|
|
}
|
|
]
|
|
};
|
|
}
|
|
|
|
export { GamesManager } |