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
+37 -37
View File
@@ -1,29 +1,29 @@
/**
* Scenarios manager class
* Scenarios manager class, контролен клас за управление на игрови сценарии
*/
class ScenariosManager{
name = 'scenarios';
/**
* Class initializer
* @param {App} app Class initializer
* 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
* 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
* Reads scenario by ID, извличане на сценарий по подаден идентификатор
* @param {Number} id scenario ID, идентификатор
* @returns {Scenario}
*/
this.read = async function(id){
@@ -31,8 +31,8 @@ class ScenariosManager{
}
/**
* Updates scenario
* @param {Context} ctx Request context
* Updates scenario, обновяване на сценарий
* @param {Context} ctx Request context, контекст на заявката
* @param {Scenario} data the scenario
*/
this.update = async function(ctx, data){
@@ -40,16 +40,16 @@ class ScenariosManager{
}
/**
* Removes scenario by ID
* @param {Number} id scenario ID
* 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 a set of scenarios by given criteria, търсене в игровите сценарии по зададени критерии
* @param {Query} query criteria, критерии - заявка към базата от данни
* @returns {Scenario[]}
*/
this.list = async function(query){
@@ -59,8 +59,8 @@ class ScenariosManager{
}
/**
* Class starter
* @param {App} app The application
* Class starter, стартиране на класа
* @param {App} app The application, основна апликация
*/
async start(app){
@@ -68,121 +68,121 @@ class ScenariosManager{
}
/**
* Scenario entity
* Scenario entity, обект - сценарий
*/
class Scenario {
/**
* Scenario name
* Scenario name, име на сценария
* @type {string}
*/
name = null;
/**
* Scenario levels
* Scenario levels, нива
* @type {Level[]}
*/
levels = [];
}
/**
* Game scenario level
* Game scenario level, ниво на игрови сценарий
*/
class Level {
/**
* Scenario name
* Level name, име на нивото
* @type {string}
*/
name = null;
/**
* Active objects
* Active objects, активни обекти
* @type {LevelObject[]}
*/
activeObjects = []
}
/**
* Game object associated to a level
* Game object associated to a level, игрови обекти, асоциирани към дадено ниво
*/
class LevelObject {
/**
* Associated game object
* Associated game object, асоцииран игрови обект
* @type {GameObject}
*/
gameObject = null;
/**
* Available actions
* Available actions, възможни действия
* @type {GameAction}
*/
actions = []
}
/**
* Action associated to game object
* Action associated to game object, действие, асоциирано към игрови обект
*/
class GameAction {
/**
* Scenario name
* Action name, име на действието
* @type {string}
*/
name = null;
/**
* Scenario name
* Action description, описание на действието
* @type {string}
*/
description = null;
/**
* Associated inventory item
* Associated inventory item, асоцииран инвентар
* @type {InventoryItem}
*/
inventoryItem = null;
/**
* Available outcomes from the action
* Available outcomes from the action, възможни резултати от действието
* @type {GameActionResult}
*/
results = []
}
/**
* Result associated to game action
* Result associated to game action, резултати, асоциирани към дадено игрово действие
*/
class GameActionResult{
/**
* Applied rules to the specific result
* Applied rules to the specific result, приложени игрови правила към даден резултат
* @type Rule[]
*/
rules = []
/**
* Scenario name
* Result name, име на резултата
* @type string
*/
name = null;
/**
* Scenario name
* Result description, описание на резултата
* @type string
*/
description = null;
}
/**
* Inventory item required to perform specific action
* Inventory item required to perform specific action, инвентар необходим за изпълнението на определено действие
*/
class InventoryItem {
/**
* Scenario name
* Inventory item name, име на елемент от инвентара
* @type string
*/
name = null;
/**
* Scenario name
* Inventory item description, описание на елемент от инвентара
* @type string
*/
description = null;