Files
pronature-platform/backend/app/bl/ScenariosManager.js
T
2024-11-27 18:10:09 +02:00

191 lines
3.1 KiB
JavaScript

/**
* 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;
/**
* Scenario levels
* @type {Level[]}
*/
levels = [];
}
/**
* Game scenario level
*/
class Level {
/**
* Scenario name
* @type {string}
*/
name = null;
/**
* Active objects
* @type {LevelObject[]}
*/
activeObjects = []
}
/**
* Game object associated to a level
*/
class LevelObject {
/**
* Associated game object
* @type {GameObject}
*/
gameObject = null;
/**
* Available actions
* @type {GameAction}
*/
actions = []
}
/**
* Action associated to game object
*/
class GameAction {
/**
* Scenario name
* @type {string}
*/
name = null;
/**
* Scenario name
* @type {string}
*/
description = null;
/**
* Associated inventory item
* @type {InventoryItem}
*/
inventoryItem = null;
/**
* Available outcomes from the action
* @type {GameActionResult}
*/
results = []
}
/**
* Result associated to game action
*/
class GameActionResult{
/**
* Applied rules to the specific result
* @type Rule[]
*/
rules = []
/**
* Scenario name
* @type string
*/
name = null;
/**
* Scenario name
* @type string
*/
description = null;
}
/**
* Inventory item required to perform specific action
*/
class InventoryItem {
/**
* Scenario name
* @type string
*/
name = null;
/**
* Scenario name
* @type string
*/
description = null;
}
export { ScenariosManager }