F95API/app/scripts/classes/game-info.js

126 lines
3.1 KiB
JavaScript
Raw Normal View History

"use strict";
2020-09-29 15:11:43 +00:00
class GameInfo {
2020-10-29 21:14:40 +00:00
constructor() {
2020-10-31 15:00:26 +00:00
//#region Properties
/**
* Game name
* @type String
*/
2020-10-29 21:14:40 +00:00
this.name = null;
/**
* Game author
* @type String
*/
2020-10-29 21:14:40 +00:00
this.author = null;
/**
* URL to the game's official conversation on the F95Zone portal
* @type String
*/
2020-10-31 15:00:26 +00:00
this.url = null;
2020-10-29 21:14:40 +00:00
/**
* Game description
* @type String
*/
2020-10-29 21:14:40 +00:00
this.overview = null;
/**
* Game language.
* @type String
*/
this.language = null;
/**
* List of supported OS.
* @type
*/
this.supportedOS = [];
/**
* Specify whether the game has censorship
* measures regarding NSFW scenes.
* @type Boolean
*/
this.censored = null;
/**
* List of tags associated with the game
* @type String[]
*/
2020-10-29 21:14:40 +00:00
this.tags = [];
/**
* Graphics engine used for game development
* @type String
*/
2020-10-29 21:14:40 +00:00
this.engine = null;
/**
* Development of the game
* @type String
*/
2020-10-29 21:14:40 +00:00
this.status = null;
/**
* Game description image URL
* @type String
*/
2020-10-31 15:00:26 +00:00
this.previewSrc = null;
2020-10-29 21:14:40 +00:00
/**
* Game version
* @type String
*/
2020-10-29 21:14:40 +00:00
this.version = null;
/**
* Last time the game underwent updates
* @type Date
*/
2020-10-29 21:14:40 +00:00
this.lastUpdate = null;
/**
* Specifies if the game is original or a mod
* @type Boolean
*/
2020-10-29 21:14:40 +00:00
this.isMod = false;
/**
* Changelog for the last version.
* @type String
*/
2020-10-29 21:14:40 +00:00
this.changelog = null;
2020-10-31 15:00:26 +00:00
//#endregion Properties
2020-10-29 21:14:40 +00:00
}
2020-09-29 15:11:43 +00:00
2020-10-29 21:14:40 +00:00
/**
2020-10-31 15:00:26 +00:00
* Converts the object to a dictionary used for JSON serialization.
*/
2020-10-29 21:14:40 +00:00
/* istanbul ignore next */
toJSON() {
return {
name: this.name,
author: this.author,
2020-10-31 15:00:26 +00:00
url: this.url,
2020-10-29 21:14:40 +00:00
overview: this.overview,
language: this.language,
supportedOS: this.supportedOS,
censored: this.censored,
2020-10-29 21:14:40 +00:00
engine: this.engine,
status: this.status,
2020-11-02 14:06:09 +00:00
tags: this.tags,
2020-10-31 15:00:26 +00:00
previewSrc: this.previewSrc,
2020-10-29 21:14:40 +00:00
version: this.version,
lastUpdate: this.lastUpdate,
lastPlayed: this.lastPlayed,
isMod: this.isMod,
changelog: this.changelog,
gameDir: this.gameDir,
};
}
2020-09-29 15:11:43 +00:00
2020-10-29 21:14:40 +00:00
/**
2020-10-31 15:00:26 +00:00
* Return a new GameInfo from a JSON string.
* @param {String} json JSON string used to create the new object
* @returns {GameInfo}
*/
2020-10-29 21:14:40 +00:00
static fromJSON(json) {
2020-11-02 14:06:09 +00:00
// Convert string
const temp = Object.assign(new GameInfo(), JSON.parse(json));
// JSON cannot transform a string to a date implicitly
temp.lastUpdate = new Date(temp.lastUpdate);
return temp;
2020-10-29 21:14:40 +00:00
}
2020-09-29 15:11:43 +00:00
}
module.exports = GameInfo;