this is a commit.

it contains changes.
they are not atomic.
they do not maintain the code in a working state.
it is sloppy.
yay.
This commit is contained in:
Kim Ravn Hansen
2025-10-16 13:47:47 +02:00
parent 218eee1df2
commit 0ee62edb6c
2 changed files with 25 additions and 11 deletions

View File

@@ -25,7 +25,7 @@ import { Vector2i } from "./ascii_types.js";
* @readonly @constant @enum {string}
*/
export const CharType = {
SYSTEM: "typeId",
TYPE_ID: "typeId",
MINIMAP: "minimapChar",
MINIMAP_REVEALED: "revealedMinimapChar",
};
@@ -98,17 +98,25 @@ export class TileMap {
* @param {CharType} charType
* @returns {string}
*/
toString(charType = CharType.SYSTEM) {
toString(charType = CharType.TYPE_ID) {
const undefinedCharPlaceholder = "?";
let result = "";
let errorCount = 0;
for (let y = 0; y < this.height; y++) {
for (let x = 0; x < this.width; x++) {
const tile = this.tiles[y][x];
result += tile[charType] ?? "Ø";
console.log(tile);
errorCount += tile[charType] === undefined;
result += tile[charType] ?? undefinedCharPlaceholder;
}
result += "\n";
}
if (errorCount > 0) {
console.warn("Could not convert map to string", { errorCount });
}
return result;
}