| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- /** This class represents room. */
- export class room {
- #id;
- #name;
- #description;
- #texture;
- /**
- * This create new room from the config object.
- *
- * @param {string} id - ID of the room
- * @param {object} config - Config from the assets
- * @return {room} - New room from the config
- */
- constructor(id, config) {
- this.#id = id;
- this.#name = this.#save_get("name", config);
- this.#description = this.#save_get("description", config);
- this.#texture = this.#save_get("texture", config);
- }
- /**
- * @return {string} - Name of the room
- */
- get name() {
- return this.#name;
- }
- /**
- * @return {string} - ID of the room
- */
- get id() {
- return this.#id;
- }
- /**
- * @return {string} - Description of the room
- */
- get description() {
- return this.#description;
- }
- /**
- * @return {string} - Link to the texture file
- */
- get texture() {
- return this.#texture;
- }
- /**
- * This function return property of the object, if it exists. When it no
- * exists, the return null.
- *
- * @param {string} property - Property to get from object
- * @param {object} source - Source object to get property from
- * @return Property of the object or null
- */
- #save_get(property, source) {
- if (!source.hasOwnProperty(property)) {
- return null;
- }
- return source[property];
- }
- }
|