This commit is contained in:
2024-12-16 16:51:46 +02:00
parent e264956831
commit 96fbfb60e8
16 changed files with 250 additions and 295 deletions
+2 -1
View File
@@ -1,4 +1,5 @@
const fs = require('fs'); const fs = require('fs');
const iconv = require('iconv-lite');
const typeMap = { const typeMap = {
string: 'std::string', string: 'std::string',
@@ -46,5 +47,5 @@ exports.publish = (data, {destination, query}) => {
let result = `#include <string>\n\n` + graft(docs); let result = `#include <string>\n\n` + graft(docs);
//console.log(result) //console.log(result)
fs.promises.writeFile(destination, result, {encoding:'utf-8'}); fs.promises.writeFile(destination, iconv.encode(result, 'win1251'), {encoding: 'binary'});
}; };
+5 -50
View File
@@ -5,9 +5,9 @@
<Inline template="General/Element Basic No Icon"/> <Inline template="General/Element Basic No Icon"/>
<!-- Stereotypes --> <!-- Stereotypes -->
<HasValueChecker property="stereotypes"> <!-- <HasValueChecker property="stereotypes">
<Reference template="General/Stereotypes"/> <Reference template="General/Stereotypes"/>
</HasValueChecker> </HasValueChecker> -->
<!-- Tagged Values --> <!-- Tagged Values -->
<HasValueChecker property="taggedValues"> <HasValueChecker property="taggedValues">
@@ -77,23 +77,22 @@
</HasChildElementChecker> </HasChildElementChecker>
<!-- Enumeration Literals (Summary) --> <!-- Enumeration Literals (Summary) -->
<HasChildElementChecker modelType="EnumerationLiteral"> <HasChildElementChecker modelType="EnumerationLiteral">
<Text style="@heading+">Enumeration Literals Summary</Text> <Text style="@heading+">Допустими стойности</Text>
<ParagraphBreak/> <ParagraphBreak/>
<TableBlock colWidths="20, 80" tableStyle="Summaries"> <TableBlock colWidths="20, 80" tableStyle="Summaries">
<TableRow> <TableRow>
<TableCell> <TableCell>
<Text>Name</Text> <Text>Име</Text>
</TableCell> </TableCell>
<TableCell> <TableCell>
<Text>Description</Text> <Text>Описание</Text>
</TableCell> </TableCell>
</TableRow> </TableRow>
<IterationBlock modelType="EnumerationLiteral"> <IterationBlock modelType="EnumerationLiteral">
<TableRow> <TableRow>
<TableCell> <TableCell>
<Icon/>
<Property property="name"/> <Property property="name"/>
</TableCell> </TableCell>
<TableCell> <TableCell>
@@ -131,50 +130,6 @@
</TableBlock> </TableBlock>
</HasChildElementChecker> </HasChildElementChecker>
<!-- Enumeration Literals (Detail) -->
<HasChildElementChecker modelType="EnumerationLiteral">
<Text style="@heading+">Enumeration Literals</Text>
<ParagraphBreak/>
<IterationBlock modelType="EnumerationLiteral">
<Inline template="Basic"/>
<TableBlock colWidths="20, 80" repeatTableHeader="false" tableStyle="Properties">
<TableRow>
<TableCell>
<Text>Specification</Text>
</TableCell>
<TableCell>
<ModelElementProperty property="specification">
<Property property="value"/>
</ModelElementProperty>
</TableCell>
</TableRow>
<TableRow>
<TableCell>
<Text>Slots</Text>
</TableCell>
<TableCell>
<ForEach property="slots">
<Property property="feature"/>
<Text> = </Text>
<ForEach ignoreLastSeparator="true" property="values">
<Property property="value"/>
<Text>, </Text>
</ForEach>
<ParagraphBreak/>
</ForEach>
</TableCell>
</TableRow>
</TableBlock>
</IterationBlock>
</HasChildElementChecker>
<!-- Sub Diagrams & References --> <!-- Sub Diagrams & References -->
<Reference template="General/Sub and Referenced Diagrams"/> <Reference template="General/Sub and Referenced Diagrams"/>
+1 -3
View File
@@ -1,4 +1,4 @@
# Server and Application Installation # ProNature Server and Application Installation
## Services to install ## Services to install
### [Mongo DB Community 8+ ](https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/) ### [Mongo DB Community 8+ ](https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/)
> sudo apt-get install gnupg curl > sudo apt-get install gnupg curl
@@ -28,8 +28,6 @@
4. SPHINX. Install in **/opt/sphinx**. Create a service using config in sphinx.service. Copy to sphinx bin/ folder and configure FTS indexes in [**sphinx.conf**](./sphinx.conf) template. Make sure all paths are available. **/opt/sphinx** should be owned by the nonroot user. 4. SPHINX. Install in **/opt/sphinx**. Create a service using config in sphinx.service. Copy to sphinx bin/ folder and configure FTS indexes in [**sphinx.conf**](./sphinx.conf) template. Make sure all paths are available. **/opt/sphinx** should be owned by the nonroot user.
## Tools to install ## Tools to install
1. NodeJS and NPM (currently Node v16, NPM v8)
1. [Mongo DB tools](https://www.mongodb.com/try/download/database-tools?tck=docs_databasetools)
1. Let's Encrypt CertBot, for certificates issuing and renewal. The certificate is installed using the following command: `certbot certonly -d your.server.name`. Use `--nginx` or `--apache` in order to have automatic renewal 1. Let's Encrypt CertBot, for certificates issuing and renewal. The certificate is installed using the following command: `certbot certonly -d your.server.name`. Use `--nginx` or `--apache` in order to have automatic renewal
1. ffmpeg - for converting video and audio content 1. ffmpeg - for converting video and audio content
1. ghostscript - for creating thumbnails for PDF files 1. ghostscript - for creating thumbnails for PDF files
+27 -27
View File
@@ -2,7 +2,7 @@ import path, { dirname } from 'path';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
/** /**
* Main backend application class * Main backend application class, апликация - основен клас на сървърното приложение
*/ */
class App{ class App{
constructor(){ constructor(){
@@ -11,13 +11,13 @@ class App{
} }
/** /**
* The plugins used by the application * The plugins used by the application, списък на плъгините, използвани в приложението
* @type {AppPlugin[]} * @type {AppPlugin[]}
*/ */
plugins = []; plugins = [];
/** /**
* Declaration of plugin usage * Declaration of plugin usage, деклариране на употреба на плъгин
* @param {AppPlugin} plugin The plugin to be used * @param {AppPlugin} plugin The plugin to be used
*/ */
async use(plugin){ async use(plugin){
@@ -27,7 +27,7 @@ class App{
} }
/** /**
* Initializes the application. All plugins are initialized at this stage * Initializes the application. All plugins are initialized at this stage, инициализация на приложението, на тази стъпка се инициализират всички регистрирани плъгини
*/ */
async init(){ async init(){
for (let p of this.plugins){ for (let p of this.plugins){
@@ -37,8 +37,8 @@ class App{
} }
/** /**
* Imports modules as plugins in the app by a given list * Imports modules as plugins in the app by a given list, импортиране на списък от модули, които да бъдат регистрирани като плъгини в приложението
* @param {Array} modules Modules to be imported * @param {Array} modules Modules to be imported, масив от модули
*/ */
async importModules(modules){ async importModules(modules){
const mods = {}; const mods = {};
@@ -52,8 +52,8 @@ class App{
} }
/** /**
* Replaces a plugin * Replaces a plugin, подмяна на плъгин
* @param {AppPlugin} p Plugin to be replaced * @param {AppPlugin} p Plugin to be replaced, плъгин, който да бъде подменен
*/ */
async replace(p){ async replace(p){
let old = this[p.name]; let old = this[p.name];
@@ -64,7 +64,7 @@ class App{
} }
/** /**
* Starts the application. All Plugins are started at this point * Starts the application. All Plugins are started at this point. Стартиране на приложението и всички негови плъгини
*/ */
async start(){ async start(){
for (let p of this.plugins){ for (let p of this.plugins){
@@ -78,89 +78,89 @@ class App{
/* The following are pseudo in order to keep documentation aligned to the code */ /* The following are pseudo in order to keep documentation aligned to the code */
/** /**
* The core application plugins * The core application plugins, основни плъгини на приложението
*/ */
class AppCore{ class AppCore{
/** /**
* The configuration plugin instance * The configuration plugin instance, конфигурационен плъгин
* @type Config * @type Config
*/ */
config = undefined; config = undefined;
/** /**
* The database plugin instance * The database plugin instance, плъгин към базата от данни
* @type Db * @type Db
*/ */
db = undefined; db = undefined;
/** /**
* The web server plugin instance * The web server plugin instance, уеб сървър плъгин
* @type WebServer * @type WebServer
*/ */
webServer = undefined; webServer = undefined;
} }
/** /**
* The main logical part application plugins * The main logical part application plugins, плъгини, свързани с логическия слой на приложението - контролни класове
*/ */
class AppManagement { class AppManagement {
/** /**
* Game objects manager plugin instance * Game objects manager plugin instance, управление на игрови обекти
* @type GameObjectsManager * @type GameObjectsManager
*/ */
gameObject = undefined; gameObject = undefined;
/** /**
* Games manager plugin instance * Games manager plugin instance, управление на игрови дефиниции
* @type GamesManager * @type GamesManager
*/ */
games = undefined; games = undefined;
/** /**
* Rules manager plugin instance * Rules manager plugin instance, управление на игрови правила
* @type RulesManager * @type RulesManager
*/ */
rules = undefined; rules = undefined;
/** /**
* Scenarios manager plugin instance * Scenarios manager plugin instance, управление на игрови сценарии
* @type ScenariosManager * @type ScenariosManager
*/ */
scenarios = undefined; scenarios = undefined;
} }
/** /**
* The main application controller plugin instances * The main application controller plugin instances, основни комуникационни (гранични) класове
*/ */
class AppControllerApi { class AppControllerApi {
/** /**
* Game objects controller plugin instance * Game objects controller plugin instance, контролер на игрови обекти
* @type GameObjectsController * @type GameObjectsController
*/ */
gameObjectsApi = undefined; gameObjectsApi = undefined;
/** /**
* Games controller plugin instance * Games controller plugin instance, контролер на игрови дефиниции
* @type GamesController * @type GamesController
*/ */
gamesApi = undefined; gamesApi = undefined;
/** /**
* Rules controller plugin instance * Rules controller plugin instance, контролер на игрови правила
* @type RulesController * @type RulesController
*/ */
rulesApi = undefined; rulesApi = undefined;
/** /**
* Scenarios controller plugin instance * Scenarios controller plugin instance, контролер на игрови сценарии
* @type ScenariosController * @type ScenariosController
*/ */
scenariosApi = undefined; scenariosApi = undefined;
/** /**
* Asset controller plugin instance * Asset controller plugin instance, контролер на игрови активи
* @type AssetController * @type AssetController
*/ */
assetApi = undefined; assetApi = undefined;
@@ -168,21 +168,21 @@ class AppControllerApi {
class AppConcrete { class AppConcrete {
/** /**
* Application core plugins * Application core plugins, плъгини - ядро на приложението
* @type AppCore * @type AppCore
* @memberof App * @memberof App
*/ */
core = undefined; core = undefined;
/** /**
* Application management plugins * Application management plugins, управление на приложението - логически класове
* @type AppManagement * @type AppManagement
* @memberof App * @memberof App
*/ */
management = undefined; management = undefined;
/** /**
* Application controller API plugins * Application controller API plugins, управление на граничните класове - контролери
* @type AppControllerApi * @type AppControllerApi
* @memberof App * @memberof App
*/ */
+23 -23
View File
@@ -1,18 +1,18 @@
import path from 'path' import path from 'path'
const pe = process.env; const pe = process.env;
/** /**
* Configuration class * Configuration class, конфигурационен клас
*/ */
class Config{ class Config{
name = 'config'; name = 'config';
/** /**
* @class File system options , repository setup * @class File system options, repository setup, настройки на файловата система и хранилището за обекти
* @alias FileSystemOptions * @alias FileSystemOptions
* @memberof Config * @memberof Config
*/ */
fs = { fs = {
/** Repository path /** Repository path, път към хранилището във файловата система
* @type {string} * @type {string}
* @memberof FileSystemOptions * @memberof FileSystemOptions
*/ */
@@ -20,18 +20,18 @@ class Config{
} }
/** /**
* @class Database options * @class Database options, опции за базата от данни
* @alias DatabaseOptions * @alias DatabaseOptions
* @memberof Config * @memberof Config
*/ */
db = { db = {
/** Database name /** Database name, име на базата от данни
* @type {string} * @type {string}
* @memberof DatabaseOptions * @memberof DatabaseOptions
*/ */
name:'pronature', name:'pronature',
/** Database connection string /** Database connection string, данни за свързване с базата от данни
* @type {string} * @type {string}
* @memberof DatabaseOptions * @memberof DatabaseOptions
*/ */
@@ -39,51 +39,51 @@ class Config{
} }
/** /**
* @class Web site endpoint options * @class Web site endpoint options, опции за уеб сайта
* @alias SiteOptions * @alias SiteOptions
* @memberof Config * @memberof Config
*/ */
site = { site = {
/** Host name /** Host name, име на хоста
* @type {string} * @type {string}
* @memberof SiteOptions * @memberof SiteOptions
*/ */
host:'https://localhost:5173', host:'https://localhost:5173',
/** Whether to use SSL /** Whether to use SSL, дали да използва сигурна връзка
* @type {boolean} * @type {boolean}
* @memberof SiteOptions * @memberof SiteOptions
*/ */
ssl: !!parseInt(pe.SRV_SSL), ssl: !!parseInt(pe.SRV_SSL),
/** Port to use /** Port to use, порт за достъп
* @type {Number} * @type {Number}
* @memberof SiteOptions * @memberof SiteOptions
*/ */
port: pe.SRV_PORT, port: pe.SRV_PORT,
/** /**
* @class Certificate data * @class Certificate data, данни за сертификат
* @alias CertificateOptions * @alias CertificateOptions
* @memberof SiteOptions * @memberof SiteOptions
*/ */
certificate: { certificate: {
/** /**
* Certificate private key * Certificate private key, частен ключ на сертификата
* @type {string} * @type {string}
* @memberof CertificateOptions * @memberof CertificateOptions
*/ */
key: './.cert/dev-key.pem', key: './.cert/dev-key.pem',
/** /**
* Certificate public key * Certificate public key, публичен ключ на сертификата
* @type {string} * @type {string}
* @memberof CertificateOptions * @memberof CertificateOptions
*/ */
cert: './.cert/dev-cert.pem', cert: './.cert/dev-cert.pem',
/** /**
* PK Passphrase * PK Passphrase, парола за частния ключ
* @type {string} * @type {string}
* @memberof CertificateOptions * @memberof CertificateOptions
*/ */
@@ -92,33 +92,33 @@ class Config{
} }
/** /**
* @class Access management options * @class Access management options, настройки за управление на достъпа
* @alias AccessManagementOptions * @alias AccessManagementOptions
* @memberof Config * @memberof Config
*/ */
am = { am = {
/** /**
* Salt, a string to be used in order to make a more complex password hash * Salt, a string to be used in order to make a more complex password hash, допълнителна защита при хеширане на паролите
* @type {string} * @type {string}
* @memberof AccessManagementOptions * @memberof AccessManagementOptions
*/ */
salt : 'P@ssSal7y!!', salt : 'P@ssSal7y!!',
/** /**
* @class Cookie options * @class Cookie options, опции за бисквитките
* @alias CookieOptions * @alias CookieOptions
* @memberof AccessManagementOptions * @memberof AccessManagementOptions
*/ */
cookie: { cookie: {
/** /**
* Cookie secret * Cookie secret, защита
* @type {string} * @type {string}
* @memberof CookieOptions * @memberof CookieOptions
*/ */
secret: 'S3cret4C00k!ie$', secret: 'S3cret4C00k!ie$',
/** /**
* Cookie max age (in seconds) * Cookie max age (in seconds), максимална възраст на бисквитка
* @type {Number} * @type {Number}
* @memberof CookieOptions * @memberof CookieOptions
*/ */
@@ -127,8 +127,8 @@ class Config{
} }
/** /**
* Initializes the configuration * Initializes the configuration, инициализация
* @param {App} app The application * @param {App} app The application, апликация
*/ */
async init(app){ async init(app){
if (!this.fs.repo){ if (!this.fs.repo){
@@ -137,8 +137,8 @@ class Config{
} }
/** /**
* Starts the configuration plugin * Starts the configuration plugin, стартиране
* @param {App} app the application instance * @param {App} app the application instance, апликация
*/ */
async start(app){ async start(app){
+40 -40
View File
@@ -4,22 +4,22 @@ let db;
let dbo; let dbo;
/** /**
* Manages database operations * Manages database operations, управление на операциите към базата от данни
*/ */
class Db { class Db {
name = 'db'; name = 'db';
/** /**
* Initializes the database plugin * Initializes the database plugin, инициализация
* @param {App} app The application instance * @param {App} app The application instance, апликация
*/ */
init(app){ init(app){
} }
/** /**
* Starts the database plugin * Starts the database plugin, стартиране
* @param {App} app The application instance * @param {App} app The application instance, апликация
*/ */
async start(app){ async start(app){
db = await MongoClient.connect(app.config.db.url, {maxPoolSize: 256}); db = await MongoClient.connect(app.config.db.url, {maxPoolSize: 256});
@@ -36,10 +36,10 @@ class Db {
} }
/** /**
* Inserts a record in a db collection * Inserts a record in a db collection, добавяне на запис в базата от данни
* @param {string} collection The name of the collection * @param {string} collection The name of the collection, име на колекцията, в която да бъде добавен записа
* @param {Object} value The object to insert * @param {Object} value The object to insert, стойност на записа
* @returns {ObjectId} Inserted Id * @returns {ObjectId} Inserted Id, идентификатор на новия запис
*/ */
async create(collection, value){ async create(collection, value){
try { try {
@@ -50,11 +50,11 @@ class Db {
} }
/** /**
* Loads a record from db collection * Loads a record from db collection, извличане на запис от базата от данни
* @param {string} collection The name of the collection * @param {string} collection The name of the collection, име на колекцията, съдържаща записа
* @param {Object} key Record identifier * @param {Object} key Record identifier, идентификатор на записа
* @param {Object} projection What data to take from the object * @param {Object} projection What data to take from the object, проекция на очаквания резултат
* @returns {Object} A record * @returns {Object} A record, запис
*/ */
async get(collection, key, projection){ async get(collection, key, projection){
try { try {
@@ -65,10 +65,10 @@ class Db {
} }
/** /**
* Performs a database query * Performs a database query, проста заявка за търсене в базата от данни
* @param {string} collection Collection name * @param {string} collection Collection name, име на колекция
* @param {Object} query A mongo db query * @param {Object} query A mongo db query, заявка
* @returns {Object[]} Array of records * @returns {Object[]} Array of records, масив от записи
*/ */
async list(collection, query){ async list(collection, query){
try { try {
@@ -84,10 +84,10 @@ class Db {
} }
/** /**
* Performs a database aggregation according to a given pipeline * Performs a database aggregation according to a given pipeline, сложна заявка (агрегираща) към базата от данни
* @param {string} collection Database collection name * @param {string} collection Database collection name, име на колекция
* @param {Object} specs aggregation definition (the pipeline) * @param {Object} specs aggregation definition (the pipeline), дефиниция на заявката
* @returns {Object[]} Array of records * @returns {Object[]} Array of records, списък от записи
*/ */
async aggregate(collection, specs){ async aggregate(collection, specs){
try { try {
@@ -100,11 +100,11 @@ class Db {
} }
/** /**
* Finds the distinct values for a specified field across a single collection * Finds the distinct values for a specified field across a single collection, извличане на списък от уникални записи в колекция по зададени критерии
* @param {string} collection Database collection name * @param {string} collection Database collection name, име на колекцията
* @param {Object} key The target field for the distinction * @param {Object} key The target field for the distinction, целеви атрибут, по който се търси уникалност
* @param {Object} query filter to be applied * @param {Object} query filter to be applied, филтър на записите в колекцията
* @returns {Object[]} * @returns {Object[]} Array of records, списък от записи
*/ */
async distinct(collection, key, query){ async distinct(collection, key, query){
try { try {
@@ -114,11 +114,11 @@ class Db {
} }
/** /**
* Updates a record in database by given key and value * Updates a record in database by given key and value, обновяване на запис в базата данни по дадени ключ и стойност
* @param {Object} collection DB collection * @param {Object} collection DB collection, име на колекцията
* @param {Object} key The key/query which identifies the record to be updated * @param {Object} key The key/query which identifies the record to be updated, ключ или заявка за идентификация на съществуващия запис
* @param {Object} value The new value for the record * @param {Object} value The new value for the record, нова стойност на записа
* @returns {Object} The result from the update operation * @returns {Object} The result from the update operation, резултат от операцията
*/ */
async update(collection, key, value){ async update(collection, key, value){
let r; let r;
@@ -131,11 +131,11 @@ class Db {
} }
/** /**
* Performs partial update on a record by given key and partial value * Performs partial update on a record by given key and partial value, частично обновяване на запис в базата от данни
* @param {Object} collection Database collection * @param {Object} collection Database collection, име на колекция
* @param {Object} key The key/query which identifies the record to be updated * @param {Object} key The key/query which identifies the record to be updated, ключ или заявка за идентификация на целевите обекти
* @param {Object} value The partial value to be updated * @param {Object} value The partial value to be updated, дефиниция на частичното обновяване
* @returns {Object} The result from the update operation * @returns {Object} The result from the update operation, резултат от операцията
*/ */
async updateSet(collection, key, value){ async updateSet(collection, key, value){
let r; let r;
@@ -147,9 +147,9 @@ class Db {
} }
/** /**
* Removes a record from the database by given key * Removes a record from the database by given key, изтриване на запис от базата от данни по зададен критерий
* @param {Object} collection Database collection * @param {Object} collection Database collection, име на колекцията
* @param {Object} key The key/query which identifies the record to be updated * @param {Object} key The key/query which identifies the record to be updated, ключ/заявка за идентификация на целевите записи
*/ */
async remove(collection, key){ async remove(collection, key){
try { try {
+5 -5
View File
@@ -9,14 +9,14 @@ import helmet from 'helmet';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
/** /**
* The Web Server class, manages all request from the web platform, manages the APIs * The Web Server class, manages all request from the web platform, manages the APIs, уеб сървър, управлява всички уеб заявки към платформата, агрегира всички комуникационни/гранични класове
*/ */
class WebServer { class WebServer {
name = 'webServer'; name = 'webServer';
/** /**
* Initializes the web server plugin * Initializes the web server plugin, инициализация
* @param {App} app The application instance * @param {App} app The application instance, апликация
*/ */
async init(app) { async init(app) {
const xapp = express(); const xapp = express();
@@ -69,8 +69,8 @@ class WebServer {
} }
/** /**
* Starts the web server plugin * Starts the web server plugin, стартиране на уеб сървъра
* @param {App} app The application instance * @param {App} app The application instance, апликация
*/ */
async start(app) { async start(app) {
+31 -30
View File
@@ -8,21 +8,21 @@ import path from 'path';
const collection = 'assets'; const collection = 'assets';
/** /**
* Game objects manager * Game objects manager, контролен клас за управление на игрови обекти
*/ */
class GameObjectsManager{ class GameObjectsManager{
name = 'gameObject'; name = 'gameObject';
/** /**
* Plugin initializer * Plugin initializer, инициализация на плъгин
* @param {App} app The Application * @param {App} app The Application, обект приложение
*/ */
init(app){ init(app){
const {db, config} = app; const {db, config} = app;
/** /**
* Gets last asset Id from database * Gets last asset Id from database, намира последния пореден идентификатор на обект в базата от данни
* @returns {Number} Last Asset Id * @returns {Number} Last Asset Id, последен (най-голям) идентификатор
*/ */
this.getLastId = async function(){ this.getLastId = async function(){
let ag = await db.aggregate(collection, [ let ag = await db.aggregate(collection, [
@@ -39,9 +39,9 @@ class GameObjectsManager{
} }
/** /**
* Creates a game object * Creates a game object, създаване на игрови обект
* @param {Context} ctx Request context * @param {Context} ctx Request context, контекст на заявката
* @param {GameObject} data Asset data * @param {GameObject} data Asset data, данни за игровия обект
*/ */
this.create = async function(ctx, data){ this.create = async function(ctx, data){
data.id = (await this.getLastId()) + 1; data.id = (await this.getLastId()) + 1;
@@ -55,9 +55,9 @@ class GameObjectsManager{
} }
/** /**
* Retrieves game object from database * Retrieves game object from database, прочитане на обект от базата от данни
* @param {Number} id Game object ID * @param {Number} id Game object ID, идентификатор на обекта
* @returns {GameObject} The game object * @returns {GameObject} The game object, игрови обект
*/ */
this.read = async function(id){ this.read = async function(id){
id = parseInt(id); id = parseInt(id);
@@ -65,9 +65,9 @@ class GameObjectsManager{
} }
/** /**
* Updates game object into the database * Updates game object into the database, обновяване на игрови обект
* @param {Context} ctx Request context * @param {Context} ctx Request context, контекст на заявката
* @param {GameObject} data Game object * @param {GameObject} data Game object, данни за игровия обект
*/ */
this.update = async function(ctx, data){ this.update = async function(ctx, data){
data.id = parseInt(data.id); data.id = parseInt(data.id);
@@ -85,8 +85,8 @@ class GameObjectsManager{
} }
/** /**
* Removes game object from database * Removes game object from database, изтриване на игрови обект от базата от данни
* @param {Number} id Game object ID * @param {Number} id Game object ID, идентификатор на игровия обект
*/ */
this.remove = async function(id){ this.remove = async function(id){
id = parseInt(id); id = parseInt(id);
@@ -94,9 +94,9 @@ class GameObjectsManager{
} }
/** /**
* Assigns a file to a game object * Assigns a file to a game object, закачване на файл към игрови обект
* @param {GameObject} object Game object * @param {GameObject} object Game object, игрови обект
* @param {File} tmpFile A file * @param {File} tmpFile A file, файл
*/ */
this.addFile = async function(object, tmpFile){ this.addFile = async function(object, tmpFile){
let i = tmpFile; let i = tmpFile;
@@ -124,9 +124,9 @@ class GameObjectsManager{
} }
/** /**
* Assigns a thumbnail to a game object * Assigns a thumbnail to a game object, закачане на представително изображение към игрови обект
* @param {GameObject} object Game object * @param {GameObject} object Game object, игрови обект
* @param {File} thumbSrc A thumbnail * @param {File} thumbSrc A thumbnail, представително изображение
*/ */
this.addThumb = async function(object, thumbSrc){ this.addThumb = async function(object, thumbSrc){
let dest = `${config.fs.repo}/thumb/${object.id}.webp`; let dest = `${config.fs.repo}/thumb/${object.id}.webp`;
@@ -135,9 +135,9 @@ class GameObjectsManager{
} }
/** /**
* Returns list of GameObjects * Returns list of GameObjects, търсене в игровите обекти по зададени критерии
* @param {Object} query Query to DB * @param {Object} query Query to DB, критерии - заявка към базата от данни
* @returns {GameObject[]} Array of game objects * @returns {GameObject[]} Array of game objects, масив от игрови обекти
*/ */
this.list = async function(query){ this.list = async function(query){
return await db.list(collection, { return await db.list(collection, {
@@ -148,8 +148,8 @@ class GameObjectsManager{
} }
/** /**
* Class starter * Class starter, стартиране на класа
* @param {App} app The application * @param {App} app The application, базова апликация
*/ */
async start(app){ async start(app){
@@ -158,22 +158,23 @@ class GameObjectsManager{
/** /**
* GameObject entity, can be: panorama picture, 3d environment, 3d object, 2d object (picture), a player (3d), audio or video asset * GameObject entity, can be: panorama picture, 3d environment, 3d object, 2d object (picture), a player (3d), audio or video asset
* Игрови обект, може да бъде панорамна снимка, триизмерна среда, обект или играч, двуизмерен обект, аудио или видео актив
*/ */
class GameObject { class GameObject {
/** /**
* Game object name * Game object name, име на игровия обект
* @type string * @type string
*/ */
name = null; name = null;
/** /**
* Game object type * Game object type, тип на игровия обект
* @type string * @type string
*/ */
type = null; type = null;
/** /**
* Associated file * Associated file, асоцииран файл
* @type File * @type File
*/ */
file = null; file = null;
+20 -20
View File
@@ -6,51 +6,51 @@ class GamesManager{
name = 'games'; name = 'games';
/** /**
* Class initializer * Class initializer, инициализация на плъгин
* @param {App} app Class initializer * @param {App} app Class initializer, основна апликация
*/ */
init(app){ init(app){
const {db} = app; const {db} = app;
/** /**
* Creates a new game definition * Creates a new game definition, създаване на нова игрова дефиниция
* @param {Context} ctx Request context * @param {Context} ctx Request context, контекст на заявката
* @param {Game} data the game description * @param {Game} data the game description, дефиниция на играта
*/ */
this.create = async function(ctx, data){ this.create = async function(ctx, data){
} }
/** /**
* Reads game definition by ID * Reads game definition by ID, извличане на игрова дефиниция от базата от данни по подаден идентификатор
* @param {Number} id game ID * @param {Number} id game ID, идентификатор на играта
* @returns {Game} the game * @returns {Game} the game, игрова дефиниция
*/ */
this.read = async function(id){ this.read = async function(id){
} }
/** /**
* Updates game definition * Updates game definition, обновяване на игрова дефиниция
* @param {Context} ctx Request context * @param {Context} ctx Request context, контекст на заявката
* @param {Game} data the game description * @param {Game} data the game description, игрова дефиниция
*/ */
this.update = async function(ctx, data){ this.update = async function(ctx, data){
} }
/** /**
* Removes game by ID * Removes game by ID, изтриване на игрова дефиниция по зададен идентификатор
* @param {Number} id game definition ID * @param {Number} id game definition ID, идентификатор на игровата дефиниция
*/ */
this.remove = async function(id){ this.remove = async function(id){
} }
/** /**
* Returns a set of games by given criteria * Returns a set of games by given criteria, търсене в игровите дефиниции по зададени критерии
* @param {Query} query criteria * @param {Query} query criteria, критерии за търсене - заявка към базата от данни
* @returns {Game[]} Array of games * @returns {Game[]} Array of games, масив от игрови дефиниции
*/ */
this.list = async function(query){ this.list = async function(query){
@@ -60,7 +60,7 @@ class GamesManager{
/** /**
* Class starter * Class starter
* @param {App} app The application * @param {App} app The application, основна апликация
*/ */
async start(app){ async start(app){
@@ -68,17 +68,17 @@ class GamesManager{
} }
/** /**
* Game entity * Game entity, игрова дефиниция - елемент
*/ */
class Game { class Game {
/** /**
* Game name * Game name, име на играта
* @type {string} * @type {string}
*/ */
name = null; name = null;
/** /**
* Game scenario * Game scenario, сценарий на играта
* @type { Scenario } * @type { Scenario }
*/ */
scenario = null; scenario = null;
+19 -19
View File
@@ -1,29 +1,29 @@
/** /**
* Rules manager class * Rules manager class, контролен клас за управление на игрови правила
*/ */
class RulesManager{ class RulesManager{
name = 'rules'; name = 'rules';
/** /**
* Class initializer * Class initializer, инициализация на плъгин
* @param {App} app Class initializer * @param {App} app Class initializer, основна апликация
*/ */
init(app){ init(app){
const {db} = app; const {db} = app;
/** /**
* Creates a new rule * Creates a new rule, създаване на ново правило
* @param {Context} ctx Request context * @param {Context} ctx Request context, контекст на заявката
* @param {Rule} data the rule * @param {Rule} data the rule, данни за правилото
*/ */
this.create = async function(ctx, data){ this.create = async function(ctx, data){
} }
/** /**
* Reads rule by ID * Reads rule by ID, извличане на игрово правило от базата от данни по подаден идентификатор
* @param {Number} id rule ID * @param {Number} id rule ID, идентификатор на правило
* @returns {Rule} * @returns {Rule}
*/ */
this.read = async function(id){ this.read = async function(id){
@@ -31,25 +31,25 @@ class RulesManager{
} }
/** /**
* Updates rule * Updates rule, обновяване на игрово правило
* @param {Context} ctx Request context * @param {Context} ctx Request context, контекст на заявката
* @param {Rule} data the rule * @param {Rule} data the rule, данни за правилото
*/ */
this.update = async function(ctx, data){ this.update = async function(ctx, data){
} }
/** /**
* Removes rule by ID * Removes rule by ID, изтриване на игрово правило по подаден идентификатор
* @param {Number} id rule ID * @param {Number} id rule ID, идентификатор на правилото
*/ */
this.remove = async function(id){ this.remove = async function(id){
} }
/** /**
* Returns a set of rules by given criteria * Returns a set of rules by given criteria, търсене в игровите правила по зададени критерии
* @param {Query} query criteria * @param {Query} query criteria, критерии, заявка към базата от данни
* @returns {Rule[]} * @returns {Rule[]}
*/ */
this.list = async function(query){ this.list = async function(query){
@@ -60,7 +60,7 @@ class RulesManager{
/** /**
* Class starter * Class starter
* @param {App} app The application * @param {App} app The application, основна апликация
*/ */
async start(app){ async start(app){
@@ -68,17 +68,17 @@ class RulesManager{
} }
/** /**
* Rule entity * Rule entity, игрово правило - елемент
*/ */
class Rule { class Rule {
/** /**
* Rule name * Rule name, име на правилото
* @type string * @type string
*/ */
name = null; name = null;
/** /**
* Rule definition * Rule definition, дефиниция на правилото
* @type Object * @type Object
*/ */
name = null; name = null;
+37 -37
View File
@@ -1,29 +1,29 @@
/** /**
* Scenarios manager class * Scenarios manager class, контролен клас за управление на игрови сценарии
*/ */
class ScenariosManager{ class ScenariosManager{
name = 'scenarios'; name = 'scenarios';
/** /**
* Class initializer * Class initializer, инициализация
* @param {App} app Class initializer * @param {App} app Class initializer, основна апликация
*/ */
init(app){ init(app){
const {db} = app; const {db} = app;
/** /**
* Creates a new scenario * Creates a new scenario, създаване на нов сценарий
* @param {Context} ctx Request context * @param {Context} ctx Request context, контекст на заявката
* @param {Scenario} data the scenario * @param {Scenario} data the scenario, данни за сценария
*/ */
this.create = async function(ctx, data){ this.create = async function(ctx, data){
} }
/** /**
* Reads scenario by ID * Reads scenario by ID, извличане на сценарий по подаден идентификатор
* @param {Number} id scenario ID * @param {Number} id scenario ID, идентификатор
* @returns {Scenario} * @returns {Scenario}
*/ */
this.read = async function(id){ this.read = async function(id){
@@ -31,8 +31,8 @@ class ScenariosManager{
} }
/** /**
* Updates scenario * Updates scenario, обновяване на сценарий
* @param {Context} ctx Request context * @param {Context} ctx Request context, контекст на заявката
* @param {Scenario} data the scenario * @param {Scenario} data the scenario
*/ */
this.update = async function(ctx, data){ this.update = async function(ctx, data){
@@ -40,16 +40,16 @@ class ScenariosManager{
} }
/** /**
* Removes scenario by ID * Removes scenario by ID, изтриване на сценарий по подаден идентификатор
* @param {Number} id scenario ID * @param {Number} id scenario ID, идентификатор на сценарий
*/ */
this.remove = async function(id){ this.remove = async function(id){
} }
/** /**
* Returns a set of scenarios by given criteria * Returns a set of scenarios by given criteria, търсене в игровите сценарии по зададени критерии
* @param {Query} query criteria * @param {Query} query criteria, критерии - заявка към базата от данни
* @returns {Scenario[]} * @returns {Scenario[]}
*/ */
this.list = async function(query){ this.list = async function(query){
@@ -59,8 +59,8 @@ class ScenariosManager{
} }
/** /**
* Class starter * Class starter, стартиране на класа
* @param {App} app The application * @param {App} app The application, основна апликация
*/ */
async start(app){ async start(app){
@@ -68,121 +68,121 @@ class ScenariosManager{
} }
/** /**
* Scenario entity * Scenario entity, обект - сценарий
*/ */
class Scenario { class Scenario {
/** /**
* Scenario name * Scenario name, име на сценария
* @type {string} * @type {string}
*/ */
name = null; name = null;
/** /**
* Scenario levels * Scenario levels, нива
* @type {Level[]} * @type {Level[]}
*/ */
levels = []; levels = [];
} }
/** /**
* Game scenario level * Game scenario level, ниво на игрови сценарий
*/ */
class Level { class Level {
/** /**
* Scenario name * Level name, име на нивото
* @type {string} * @type {string}
*/ */
name = null; name = null;
/** /**
* Active objects * Active objects, активни обекти
* @type {LevelObject[]} * @type {LevelObject[]}
*/ */
activeObjects = [] activeObjects = []
} }
/** /**
* Game object associated to a level * Game object associated to a level, игрови обекти, асоциирани към дадено ниво
*/ */
class LevelObject { class LevelObject {
/** /**
* Associated game object * Associated game object, асоцииран игрови обект
* @type {GameObject} * @type {GameObject}
*/ */
gameObject = null; gameObject = null;
/** /**
* Available actions * Available actions, възможни действия
* @type {GameAction} * @type {GameAction}
*/ */
actions = [] actions = []
} }
/** /**
* Action associated to game object * Action associated to game object, действие, асоциирано към игрови обект
*/ */
class GameAction { class GameAction {
/** /**
* Scenario name * Action name, име на действието
* @type {string} * @type {string}
*/ */
name = null; name = null;
/** /**
* Scenario name * Action description, описание на действието
* @type {string} * @type {string}
*/ */
description = null; description = null;
/** /**
* Associated inventory item * Associated inventory item, асоцииран инвентар
* @type {InventoryItem} * @type {InventoryItem}
*/ */
inventoryItem = null; inventoryItem = null;
/** /**
* Available outcomes from the action * Available outcomes from the action, възможни резултати от действието
* @type {GameActionResult} * @type {GameActionResult}
*/ */
results = [] results = []
} }
/** /**
* Result associated to game action * Result associated to game action, резултати, асоциирани към дадено игрово действие
*/ */
class GameActionResult{ class GameActionResult{
/** /**
* Applied rules to the specific result * Applied rules to the specific result, приложени игрови правила към даден резултат
* @type Rule[] * @type Rule[]
*/ */
rules = [] rules = []
/** /**
* Scenario name * Result name, име на резултата
* @type string * @type string
*/ */
name = null; name = null;
/** /**
* Scenario name * Result description, описание на резултата
* @type string * @type string
*/ */
description = null; description = null;
} }
/** /**
* Inventory item required to perform specific action * Inventory item required to perform specific action, инвентар необходим за изпълнението на определено действие
*/ */
class InventoryItem { class InventoryItem {
/** /**
* Scenario name * Inventory item name, име на елемент от инвентара
* @type string * @type string
*/ */
name = null; name = null;
/** /**
* Scenario name * Inventory item description, описание на елемент от инвентара
* @type string * @type string
*/ */
description = null; description = null;
+4 -4
View File
@@ -1,7 +1,7 @@
import express from 'express'; import express from 'express';
/** /**
* Asset controller plugin * Asset controller plugin, граничен клас за обработка на заявките към игрови активи
*/ */
class AssetController{ class AssetController{
@@ -9,15 +9,15 @@ class AssetController{
route = '/asset' route = '/asset'
/** /**
* Initializes the AssetController plugin * Initializes the AssetController plugin, инициализация
* @param {App} app The application instance * @param {App} app The application instance, апликация
*/ */
init(app){ init(app){
const router = express.Router(); const router = express.Router();
const {config} = app; const {config} = app;
/** /**
* API: GET /asset/:type/:id Retrieve asset by type and ID * API: GET /asset/:type/:id Retrieve asset by type and ID, извличане на актив по подаден идентификатор
* @function read * @function read
* @param {string} type Type can be "source", "default" or "thumb" * @param {string} type Type can be "source", "default" or "thumb"
* @param {string} id The name of the asset * @param {string} id The name of the asset
@@ -4,7 +4,7 @@ import multipart from 'connect-multiparty';
const multipartMiddleware = multipart(); const multipartMiddleware = multipart();
/** /**
* GameObjectsController. API for the game objects manager * GameObjectsController. API for the game objects manager, граничен клас за комуникация с модула за игрови обекти
*/ */
class GameObjectsController{ class GameObjectsController{
@@ -12,15 +12,15 @@ class GameObjectsController{
route = '/api/game-object' route = '/api/game-object'
/** /**
* Initializes the GameObjectsController plugin * Initializes the GameObjectsController plugin, инициализация
* @param {App} app The application instance * @param {App} app The application instance, апликация
*/ */
init(app){ init(app){
const { gameObject } = app; const { gameObject } = app;
const router = express.Router(); const router = express.Router();
/** /**
* API: PUT /api/game-object/ Create or update game object * API: PUT /api/game-object/ Create or update game object, създаване или обновяване на игрови обект
* @function createOrUpdate * @function createOrUpdate
* @memberof GameObjectsController * @memberof GameObjectsController
*/ */
@@ -36,7 +36,7 @@ class GameObjectsController{
}); });
/** /**
* API: POST /api/game-object/ List game objects by given criteria * API: POST /api/game-object/ List game objects by given criteria, търсене на обекти по критерии
* @function list * @function list
* @returns {GameObject[]} * @returns {GameObject[]}
* @memberof GameObjectsController * @memberof GameObjectsController
@@ -47,9 +47,9 @@ class GameObjectsController{
}) })
/** /**
* API: GET /api/game-object/:id Retrieve game object by ID * API: GET /api/game-object/:id Retrieve game object by ID, извличане на обект по идентификатор
* @function read * @function read
* @param {string} id The id of the game object * @param {string} id The id of the game object, идентификатор на обекта
* @returns {GameObject} * @returns {GameObject}
* @memberof GameObjectsController * @memberof GameObjectsController
*/ */
@@ -59,9 +59,9 @@ class GameObjectsController{
}) })
/** /**
* API: DELETE /api/game-object/:id Delete game object by ID * API: DELETE /api/game-object/:id Delete game object by ID, изтриване на обект по даден идентификатор
* @function remove * @function remove
* @param {string} id The id of the game object * @param {string} id The id of the game object, идентификатор на обекта
* @memberof GameObjectsController * @memberof GameObjectsController
*/ */
router.delete('/:id', async (req, res)=>{ router.delete('/:id', async (req, res)=>{
+9 -9
View File
@@ -1,7 +1,7 @@
import express from 'express'; import express from 'express';
/** /**
* GamesController. API for the games manager * GamesController. API for the games manager, граничен клас за комуникация с модула за игрови дефиниции
*/ */
class GamesController{ class GamesController{
@@ -9,15 +9,15 @@ class GamesController{
route = '/api/game' route = '/api/game'
/** /**
* Initializes the GamesController plugin * Initializes the GamesController plugin, инициализация
* @param {App} app The application instance * @param {App} app The application instance, апликация
*/ */
init(app){ init(app){
const router = express.Router(); const router = express.Router();
const { games } = app; const { games } = app;
/** /**
* API: PUT /api/game/ Create or update game * API: PUT /api/game/ Create or update game, създаване/обновяване на игрова дефиниция
* @function createOrUpdate * @function createOrUpdate
* @memberof GamesController * @memberof GamesController
*/ */
@@ -26,7 +26,7 @@ class GamesController{
}); });
/** /**
* API: POST /api/game/ List games by given criteria * API: POST /api/game/ List games by given criteria, търсене в игрови дефиниции
* @function list * @function list
* @returns {Game[]} * @returns {Game[]}
* @memberof GamesController * @memberof GamesController
@@ -35,9 +35,9 @@ class GamesController{
}) })
/** /**
* API: GET /api/game/:id Retrieve game by ID * API: GET /api/game/:id Retrieve game by ID, извличане на игрова дефиниция
* @function read * @function read
* @param {string} id The id of the game * @param {string} id The id of the game, идентификатор на дефиницията
* @returns {Game} * @returns {Game}
* @memberof GamesController * @memberof GamesController
*/ */
@@ -45,9 +45,9 @@ class GamesController{
}) })
/** /**
* API: DELETE /api/game/:id Delete game by ID * API: DELETE /api/game/:id Delete game by ID, изтриване на игрова дефиниция
* @function remove * @function remove
* @param {string} id The id of the game * @param {string} id The id of the game, идентификатор на дефиницията
* @memberof GamesController * @memberof GamesController
*/ */
router.delete('/:id', async (req, res)=>{ router.delete('/:id', async (req, res)=>{
+9 -9
View File
@@ -1,7 +1,7 @@
import express from 'express'; import express from 'express';
/** /**
* RulesController. API for the game rules manager * RulesController. API for the game rules manager, граничен клас за комуникация с модула за игрови правила
*/ */
class RulesController{ class RulesController{
@@ -9,15 +9,15 @@ class RulesController{
route = '/api/rule' route = '/api/rule'
/** /**
* Initializes the RulesController plugin * Initializes the RulesController plugin, инициализация
* @param {App} app The application instance * @param {App} app The application instance, апликация
*/ */
init(app){ init(app){
const router = express.Router(); const router = express.Router();
const { rules } = app; const { rules } = app;
/** /**
* API: PUT /api/rule/ Create or update rule * API: PUT /api/rule/ Create or update rule, създаване/обновяване на игрово правило
* @function createOrUpdate * @function createOrUpdate
* @memberof RulesController * @memberof RulesController
*/ */
@@ -26,7 +26,7 @@ class RulesController{
}); });
/** /**
* API: POST /api/rule/ List rules by given criteria * API: POST /api/rule/ List rules by given criteria, търсене в игровите правила
* @function list * @function list
* @returns {Rule[]} * @returns {Rule[]}
* @memberof RulesController * @memberof RulesController
@@ -35,9 +35,9 @@ class RulesController{
}) })
/** /**
* API: GET /api/rule/:id Retrieve rule by ID * API: GET /api/rule/:id Retrieve rule by ID, извличане на игрово правило
* @function read * @function read
* @param {string} id The id of the rule * @param {string} id The id of the rule, идентификатор
* @returns {Rule} * @returns {Rule}
* @memberof RulesController * @memberof RulesController
*/ */
@@ -45,9 +45,9 @@ class RulesController{
}) })
/** /**
* API: DELETE /api/rule/:id Delete rule by ID * API: DELETE /api/rule/:id Delete rule by ID, изтриване на игрово правило
* @function remove * @function remove
* @param {string} id The id of the rule * @param {string} id The id of the rule, идентификатор
* @memberof RulesController * @memberof RulesController
*/ */
router.delete('/:id', async (req, res)=>{ router.delete('/:id', async (req, res)=>{
@@ -1,7 +1,7 @@
import express from 'express'; import express from 'express';
/** /**
* ScenariosController. API for the scenarios manager * ScenariosController. API for the scenarios manager, граничен клас за комуникация с модула за игрови сценарии
*/ */
class ScenariosController{ class ScenariosController{
@@ -9,15 +9,15 @@ class ScenariosController{
route = '/api/scenario' route = '/api/scenario'
/** /**
* Initializes the ScenariosController plugin * Initializes the ScenariosController plugin, инициализация
* @param {App} app The application instance * @param {App} app The application instance, апликация
*/ */
init(app){ init(app){
const router = express.Router(); const router = express.Router();
const { scenarios } = app; const { scenarios } = app;
/** /**
* API: PUT /api/scenario/ Create or update scenario * API: PUT /api/scenario/ Create or update scenario, създаване/обновяване на игрови сценарий
* @function createOrUpdate * @function createOrUpdate
* @memberof ScenariosController * @memberof ScenariosController
*/ */
@@ -26,7 +26,7 @@ class ScenariosController{
}); });
/** /**
* API: POST /api/scenario/ List scenarios by given criteria * API: POST /api/scenario/ List scenarios by given criteria, търсене в игровите сценарии
* @function list * @function list
* @returns {Scenario[]} * @returns {Scenario[]}
* @memberof ScenariosController * @memberof ScenariosController
@@ -35,9 +35,9 @@ class ScenariosController{
}) })
/** /**
* API: GET /api/scenario/:id Retrieve scenario by ID * API: GET /api/scenario/:id Retrieve scenario by ID, извличане на игрови сценарий
* @function read * @function read
* @param {string} id The id of the scenario * @param {string} id The id of the scenario, идентификатор
* @returns {Scenario} * @returns {Scenario}
* @memberof ScenariosController * @memberof ScenariosController
*/ */
@@ -45,9 +45,9 @@ class ScenariosController{
}) })
/** /**
* API: DELETE /api/scenario/:id Delete scenario by ID * API: DELETE /api/scenario/:id Delete scenario by ID, изтриване на игрови сценарий
* @function remove * @function remove
* @param {string} id The id of the scenario * @param {string} id The id of the scenario, идентификатор
* @memberof ScenariosController * @memberof ScenariosController
*/ */
router.delete('/:id', async (req, res)=>{ router.delete('/:id', async (req, res)=>{