This commit is contained in:
Kim Ravn Hansen
2025-10-16 18:51:21 +02:00
parent 0ee62edb6c
commit 6f0e564dfd
2 changed files with 16 additions and 14 deletions

View File

@@ -106,7 +106,6 @@ export class TileMap {
for (let y = 0; y < this.height; y++) {
for (let x = 0; x < this.width; x++) {
const tile = this.tiles[y][x];
console.log(tile);
errorCount += tile[charType] === undefined;
result += tile[charType] ?? undefinedCharPlaceholder;
}

View File

@@ -171,9 +171,7 @@ export class Tile {
const other = shallowCopy(TileTypes[this.disguiseAs]);
for (const [pKey, pVal] of Object.entries(other)) {
if (this.key !== undefined) {
this[pKey] = pVal;
}
this[pKey] ??= pVal;
}
}
@@ -193,9 +191,7 @@ export class Tile {
//
const other = shallowCopy(TileTypes[this.is]);
for (const [pKey, pVal] of Object.entries(other)) {
if (this.key !== undefined) {
this[pKey] = pVal;
}
this[pKey] ??= pVal;
}
}
@@ -229,8 +225,14 @@ export class Tile {
mustBe(this.portalTargetId, "number", "string");
}
this.minimapChar ??= this.typeId;
this.revealedMinimapChar ??= this.minimapChar;
if (this.minimapChar === undefined) {
console.debug("minimap = typeid", { ...this });
this.minimapChar = this.typeId;
}
if (this.revealedMinimapChar === undefined) {
console.debug("reveaked = minimap", { ...this });
this.revealedMinimapChar = this.minimapChar;
}
}
/** @returns {Tile} */
@@ -279,20 +281,21 @@ export class Tile {
}
let optionPos = 0;
const creationArgs = {};
const properties = {};
const getOption = (name) => options.getValue(name, optionPos++);
for (let [key, val] of Object.entries(prototype)) {
properties[key] = val;
//
const fetchFromOption = typeof val === "symbol" && val.description.startsWith("REQUIRED_");
const fetchOption = typeof val === "symbol" && val.description.startsWith("REQUIRED_");
creationArgs[key] = fetchFromOption ? getOption(key) : shallowCopy(val);
properties[key] = fetchOption ? getOption(key) : shallowCopy(val);
}
return new Tile(typeId, creationArgs);
return new Tile(typeId, properties);
}
clone() {
return new Tile(this.typeId, this);
return new Tile(this.typeId, { ...this });
}
isWallLike() {