Replace map system

This commit is contained in:
2025-02-09 22:37:33 -08:00
parent 2361b880eb
commit 841031573c
32 changed files with 888 additions and 1043 deletions

View File

@ -84,6 +84,14 @@ export class Size {
add(other: Size) {
return new Size(this.w + other.w, this.h + other.h);
}
equals(other: Size) {
return this.w == other.w && this.h == other.h;
}
toString(): string {
return `${this.w}x${this.h}`
}
}
export class Rect {
@ -121,6 +129,18 @@ export class Grid<T> {
}
}
static createGridFromMultilineString(multiline: string): Grid<string> {
let lines = []
for (let line of multiline.split("\n")) {
let trimmedLine = line.trim();
if (trimmedLine == "") {
continue;
}
lines.push(trimmedLine)
}
return this.createGridFromStringArray(lines);
}
static createGridFromStringArray(ary: Array<string>): Grid<string> {
let w = 0;
let h = ary.length;