diff --git a/.docs/jsdoc.publish.js b/.docs/jsdoc.publish.js new file mode 100644 index 0000000..6c9f4d0 --- /dev/null +++ b/.docs/jsdoc.publish.js @@ -0,0 +1,55 @@ +const fs = require('fs'); + +function getType(t){ + return (t?.type.names[0] || '').replace(/^Array\.\<(.*)\>$/, '$1*') +} + +function graft(childNodes, parentLongname) { + let result = ''; + childNodes.filter(({memberof}) => memberof === parentLongname) + .forEach(element => { + if (element.kind === 'function') { + result += `${getType(element.returns?.[0]) || 'void'} ${element.name}(${ element.params?.map(p=> + `/* ${p.description || ''} */ ${getType(p)} ${p.name}` + ).join(', ') || ''});\n`; + } + else if (element.kind === 'member') { + result += `/* ${element.description || ''} */ ${getType(element)} ${element.name};` + } + + else if (element.kind === 'class') { + result+= `/** ${element.classdesc || ''} */\nclass ${element.name}{\n public: \n`; + result += graft(childNodes, element.longname); + result+= '\n};\n'; + } + }); + return result; +} + +/** + @param {TAFFY} data + @param {object} opts + */ +exports.publish = (data, {destination, query}) => { + let docs; + + data({undocumented: true}).remove(); + docs = data().get(); // <-- an array of Doclet objects + + fs.promises.writeFile('./result.json', JSON.stringify(docs), {encoding:'utf-8'}) + + let result = graft(docs); + console.log(result) + + if (destination === 'console') { + if (query && query.format === 'xml') { + //console.log( xml.parse('xs:schema', root) ); + } + else { + //console.log( require('jsdoc/util/dumper').dump(root) ); + } + } + else { + console.log('This template only supports output to the console. Use the option "-d console" when you run JSDoc.'); + } +}; diff --git a/backend/app/bl/GamesManager.js b/backend/app/bl/GamesManager.js new file mode 100644 index 0000000..6bfcf24 --- /dev/null +++ b/backend/app/bl/GamesManager.js @@ -0,0 +1,102 @@ + +/** + * 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 } \ No newline at end of file diff --git a/backend/app/bl/RulesManager.js b/backend/app/bl/RulesManager.js new file mode 100644 index 0000000..744bf09 --- /dev/null +++ b/backend/app/bl/RulesManager.js @@ -0,0 +1,82 @@ + +/** + * Rules manager class + */ +class RulesManager{ + name = 'rules'; + + /** + * Class initializer + * @param {App} app Class initializer + */ + init(app){ + const {db} = app; + + /** + * Creates a new rule + * @param {Context} ctx Request context + * @param {Rule} data the rule + */ + this.create = async function(ctx, data){ + + } + + /** + * Reads rule by ID + * @param {Number} id rule ID + * @returns {Rule} + */ + this.read = async function(id){ + + } + + /** + * Updates rule + * @param {Context} ctx Request context + * @param {Rule} data the rule + */ + this.update = async function(ctx, data){ + + } + + /** + * Removes rule by ID + * @param {Number} id rule ID + */ + this.remove = async function(id){ + + } + + /** + * Returns a set of rules by given criteria + * @param {Query} query criteria + * @returns {Rule[]} + */ + this.list = async function(query){ + + } + + } + + /** + * Class starter + * @param {App} app The application + */ + async start(app){ + + } +} + +/** + * Rule entity + */ +class Rule { + /** + * Rule name + * @type string + */ + name = null; + +} + +export { RulesManager } \ No newline at end of file diff --git a/backend/app/bl/ScenariosManager.js b/backend/app/bl/ScenariosManager.js new file mode 100644 index 0000000..a3cd057 --- /dev/null +++ b/backend/app/bl/ScenariosManager.js @@ -0,0 +1,82 @@ + +/** + * Scenarios manager class + */ +class ScenariosManager{ + name = 'scenarios'; + + /** + * Class initializer + * @param {App} app Class initializer + */ + init(app){ + const {db} = app; + + /** + * Creates a new scenario + * @param {Context} ctx Request context + * @param {Scenario} data the scenario + */ + this.create = async function(ctx, data){ + + } + + /** + * Reads scenario by ID + * @param {Number} id scenario ID + * @returns {Scenario} + */ + this.read = async function(id){ + + } + + /** + * Updates scenario + * @param {Context} ctx Request context + * @param {Scenario} data the scenario + */ + this.update = async function(ctx, data){ + + } + + /** + * Removes scenario by ID + * @param {Number} id scenario ID + */ + this.remove = async function(id){ + + } + + /** + * Returns a set of scenarios by given criteria + * @param {Query} query criteria + * @returns {Scenario[]} + */ + this.list = async function(query){ + + } + + } + + /** + * Class starter + * @param {App} app The application + */ + async start(app){ + + } +} + +/** + * Scenario entity + */ +class Scenario { + /** + * Scenario name + * @type string + */ + name = null; + +} + +export { ScenariosManager } \ No newline at end of file diff --git a/backend/controllers/api/GamesController.js b/backend/controllers/api/GamesController.js new file mode 100644 index 0000000..842fbc5 --- /dev/null +++ b/backend/controllers/api/GamesController.js @@ -0,0 +1,13 @@ +import express from 'express'; + +class GamesController{ + + name = 'gamesApi' + route = '/api/game' + + init(app){ + const router = express.Router(); + } +} + +export { GamesController } \ No newline at end of file diff --git a/backend/controllers/api/RulesController.js b/backend/controllers/api/RulesController.js new file mode 100644 index 0000000..e69de29 diff --git a/backend/controllers/api/ScenariosController.js b/backend/controllers/api/ScenariosController.js new file mode 100644 index 0000000..e69de29 diff --git a/src/components/AppHeader.vue b/src/components/AppHeader.vue index 20e85d9..06c0df5 100644 --- a/src/components/AppHeader.vue +++ b/src/components/AppHeader.vue @@ -9,7 +9,7 @@ Нов игрови обект Нов сценарий - Нова игра + Нова игра @@ -24,7 +24,7 @@ - + diff --git a/src/pages/games/[[id]].vue b/src/pages/games/[[id]].vue new file mode 100644 index 0000000..8b00dca --- /dev/null +++ b/src/pages/games/[[id]].vue @@ -0,0 +1,9 @@ + + + \ No newline at end of file