2020-11-02 14:06:09 +00:00
|
|
|
/* istanbul ignore file */
|
2020-10-16 07:58:42 +00:00
|
|
|
"use strict";
|
2020-10-02 12:01:51 +00:00
|
|
|
|
2020-12-03 10:34:33 +00:00
|
|
|
// Core modules
|
|
|
|
const {tmpdir} = require("os");
|
|
|
|
const {join} = require("path");
|
|
|
|
|
2020-11-01 20:56:12 +00:00
|
|
|
// Public modules from npm
|
2020-10-21 13:31:11 +00:00
|
|
|
const log4js = require("log4js");
|
|
|
|
|
2020-12-26 14:23:52 +00:00
|
|
|
// Modules from file
|
|
|
|
const Session = require("./classes/session");
|
|
|
|
|
2020-10-01 19:13:23 +00:00
|
|
|
/**
|
|
|
|
* Class containing variables shared between modules.
|
|
|
|
*/
|
|
|
|
class Shared {
|
2020-10-29 21:14:40 +00:00
|
|
|
//#region Properties
|
2020-11-01 20:56:12 +00:00
|
|
|
/**
|
|
|
|
* Indicates whether a user is logged in to the F95Zone platform or not.
|
|
|
|
* @type Boolean
|
|
|
|
*/
|
|
|
|
static #_isLogged = false;
|
|
|
|
/**
|
|
|
|
* List of possible game engines used for development.
|
2020-12-03 10:34:33 +00:00
|
|
|
* @type Object<number,string>
|
2020-11-01 20:56:12 +00:00
|
|
|
*/
|
2020-12-03 10:34:33 +00:00
|
|
|
static #_engines = {};
|
2020-11-01 20:56:12 +00:00
|
|
|
/**
|
|
|
|
* List of possible development statuses that a game can assume.
|
2020-12-03 10:34:33 +00:00
|
|
|
* @type Object<number,string>
|
|
|
|
*/
|
|
|
|
static #_statuses = {};
|
|
|
|
/**
|
|
|
|
* List of other prefixes that a game can assume.
|
|
|
|
* @type Object<number,string>
|
2020-11-01 20:56:12 +00:00
|
|
|
*/
|
2020-12-03 10:34:33 +00:00
|
|
|
static #_others = {};
|
|
|
|
/**
|
|
|
|
* List of possible tags that a game can assume.
|
|
|
|
* @type Object<number,string>
|
|
|
|
*/
|
|
|
|
static #_tags = {};
|
2020-11-01 20:56:12 +00:00
|
|
|
/**
|
|
|
|
* Logger object used to write to both file and console.
|
|
|
|
* @type log4js.Logger
|
|
|
|
*/
|
|
|
|
static #_logger = log4js.getLogger();
|
2020-12-26 14:23:52 +00:00
|
|
|
/**
|
|
|
|
* Session on the F95Zone platform.
|
|
|
|
*/
|
|
|
|
static #_session = new Session(join(tmpdir(), "f95session.json"));
|
2020-11-01 20:56:12 +00:00
|
|
|
//#endregion Properties
|
2020-10-01 19:13:23 +00:00
|
|
|
|
2020-11-01 20:56:12 +00:00
|
|
|
//#region Getters
|
|
|
|
/**
|
2020-12-03 10:34:33 +00:00
|
|
|
* Indicates whether a user is logged in to the F95Zone platform or not.
|
|
|
|
* @returns {Boolean}
|
|
|
|
*/
|
2020-11-01 20:56:12 +00:00
|
|
|
static get isLogged() {
|
|
|
|
return this.#_isLogged;
|
|
|
|
}
|
|
|
|
/**
|
2020-12-03 10:34:33 +00:00
|
|
|
* List of possible game engines used for development.
|
|
|
|
* @returns @returns {Object<number, string>}
|
|
|
|
*/
|
2020-11-01 20:56:12 +00:00
|
|
|
static get engines() {
|
|
|
|
return this.#_engines;
|
|
|
|
}
|
|
|
|
/**
|
2020-12-03 10:34:33 +00:00
|
|
|
* List of possible development states that a game can assume.
|
|
|
|
* @returns {Object<number, string>}
|
|
|
|
*/
|
2020-11-01 20:56:12 +00:00
|
|
|
static get statuses() {
|
|
|
|
return this.#_statuses;
|
|
|
|
}
|
|
|
|
/**
|
2020-12-03 10:34:33 +00:00
|
|
|
* List of other prefixes that a game can assume.
|
|
|
|
* @returns {Object<number, string>}
|
|
|
|
*/
|
|
|
|
static get others() {
|
|
|
|
return this.#_others;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* List of possible tags that a game can assume.
|
|
|
|
* @returns {Object<number, string>}
|
|
|
|
*/
|
|
|
|
static get tags() {
|
|
|
|
return this.#_tags;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Logger object used to write to both file and console.
|
|
|
|
* @returns {log4js.Logger}
|
|
|
|
*/
|
2020-11-01 20:56:12 +00:00
|
|
|
static get logger() {
|
|
|
|
return this.#_logger;
|
|
|
|
}
|
2020-12-03 10:34:33 +00:00
|
|
|
/**
|
|
|
|
* Path to the cache used by this module wich contains engines, statuses, tags...
|
|
|
|
*/
|
|
|
|
static get cachePath() {
|
|
|
|
return join(tmpdir(), "f95cache.json");
|
|
|
|
}
|
2020-12-26 14:23:52 +00:00
|
|
|
/**
|
|
|
|
* Session on the F95Zone platform.
|
|
|
|
*/
|
|
|
|
static get session() {
|
|
|
|
return this.#_session;
|
|
|
|
}
|
2020-11-01 20:56:12 +00:00
|
|
|
//#endregion Getters
|
2020-10-02 12:01:51 +00:00
|
|
|
|
2020-11-01 20:56:12 +00:00
|
|
|
//#region Setters
|
|
|
|
static set engines(val) {
|
|
|
|
this.#_engines = val;
|
|
|
|
}
|
2020-10-02 12:01:51 +00:00
|
|
|
|
2020-11-01 20:56:12 +00:00
|
|
|
static set statuses(val) {
|
|
|
|
this.#_statuses = val;
|
|
|
|
}
|
2020-10-02 12:01:51 +00:00
|
|
|
|
2020-12-03 10:34:33 +00:00
|
|
|
static set tags(val) {
|
|
|
|
this.#_tags = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static set others(val) {
|
|
|
|
this.#_others = val;
|
|
|
|
}
|
|
|
|
|
2020-11-01 20:56:12 +00:00
|
|
|
static set isLogged(val) {
|
|
|
|
this.#_isLogged = val;
|
|
|
|
}
|
|
|
|
//#endregion Setters
|
2020-10-01 19:13:23 +00:00
|
|
|
}
|
|
|
|
|
2020-10-08 21:09:05 +00:00
|
|
|
module.exports = Shared;
|