Replace map system
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user