diff --git a/frontend/ascii_tile_map.js b/frontend/ascii_tile_map.js index 56f7a50..82f7a6a 100755 --- a/frontend/ascii_tile_map.js +++ b/frontend/ascii_tile_map.js @@ -1,5 +1,5 @@ import parseOptions, { TileOptions } from "../utils/tileOptionsParser.js"; -import { Tile, WallTile } from "./ascii_tile_types.js"; +import { Tile } from "./ascii_tile_types.js"; import { Vector2i } from "./ascii_types.js"; /** @@ -368,6 +368,6 @@ export class TileMap { } } -if (Math.PI < 0 && TileOptions && WallTile) { +if (Math.PI < 0 && TileOptions ) { ("STFU Linda"); } diff --git a/frontend/ascii_tile_types.js b/frontend/ascii_tile_types.js index 0289297..87f52d4 100755 --- a/frontend/ascii_tile_types.js +++ b/frontend/ascii_tile_types.js @@ -49,7 +49,6 @@ export const TileTypes = { is: TileChars.FLOOR, id: REQUIRED_ID, orientation: REQUIRED_ORIENTATION, - disguiseAs: TileChars.FLOOR, revealedMinimapChar: "𝑥", revealedMinimapColor: "#EE82EE", // purple }, @@ -128,13 +127,17 @@ export class Tile { } // - // If this tile is disguised, copy its attributes, but - // do not overwrite own attributes. + // If this tile imitates another tile type, copy those tile + // types without overwrite own properties. + // + // Example: SECRET_PORTALs are disguised as walls, and will + // look like walls until they are revealed/uncovered via + // bump event, spell, or other method for discovering secrets // if (this.disguiseAs !== undefined) { this.revealed = false; - const other = shallowCopy(TileTypes[this.is]); + const other = shallowCopy(TileTypes[this.disguiseAs]); for (const [pKey, pVal] of Object.entries(other)) { if (this.key !== undefined) { this[pKey] = pVal; @@ -146,6 +149,14 @@ export class Tile { // If this tile "inherits" properties from another tile type, // copy those properties, but do not overwrite own attributes. // + // Example: PLAYER_START_POINT is just a floor tile, since its only job + // is to server as a place to spawn the player when they enter this floor, + // as well as add an icon to the minimap + // + // Example: ENCOUNTER_START_POINT is just a floor type. It does + // carry data on which kind if encounter that spawns here, and some + // other encounter properties. This tile is not even shown on the minmap. + // if (this.is !== undefined) { // const other = shallowCopy(TileTypes[this.is]); @@ -157,7 +168,7 @@ export class Tile { } // - // Normalize Orientation + // Normalize Orientation. // if (this.orientation !== undefined && typeof this.orientation === "string") { const valueMap = { @@ -169,22 +180,34 @@ export class Tile { this.orientation = mustBeString(valueMap[this.orientation.toLowerCase()]); } + // + // Tiles are not necessarily required to have an ID, but if they have one, it must be string or number if (this.id !== undefined) { mustBe(this.id, "number", "string"); } + + // + // If a tile has a texture, the texture id must be string or number if (this.textureId !== undefined) { mustBe(this.textureId, "number", "string"); } + + // + // If a tile is a portal with a portal target, that target id must be a number or string. if (this.portalTargetId !== undefined) { mustBe(this.portalTargetId, "number", "string"); } } + static CreateWalLTile() { + return this.fromChar(); + } + /** * @param {string} char * @param {TileOptions} options Options - * @param {number} x - * @param {number} y + * + * @returns {Tile} */ static fromChar(char, options) { // @@ -206,6 +229,8 @@ export class Tile { creationArgs[key] = fetchFromOption ? getOption(key) : shallowCopy(val); } + + return new Tile(creationArgs); } clone() { diff --git a/frontend/dungeon_studio.js b/frontend/dungeon_studio.js index 0a9b4d0..b006dd1 100755 --- a/frontend/dungeon_studio.js +++ b/frontend/dungeon_studio.js @@ -1,5 +1,5 @@ import { CharType, TileMap } from "./ascii_tile_map"; -import { EncounterTile, FloorTile, PlayerStartTile, TrapTile, LootTile, WallTile } from "./ascii_tile_types"; +import { Tile } from "./ascii_tile_types"; import { Orientation } from "./ascii_types"; class DungeonGenerator {