Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 1x 1x 1x 1x | import { Observable, ObservableInterface, ObserverInterface } from "@jga/patterns";
import { Console, HTMLConsoleRenderer } from "../console/index";
import { DisplayInterface } from "../display/index";
import { World, Entity, Player } from "../engine/index";
import { InputDataInterface, ScreenInterface } from "./interface";
import { ScreenObserver } from "./observer";
export abstract class Screen extends Observable implements ObservableInterface, ScreenInterface {
protected observers: ObserverInterface[] = [];
protected name: string;
protected engine: World;
protected display: DisplayInterface;
public constructor(name: string, engine: World, display: DisplayInterface) {
super();
this.name = name;
this.engine = engine;
this.display = display;
const console = new Console(new HTMLConsoleRenderer());
const observer = new ScreenObserver(console);
this.attach(observer);
}
public enter(): void {
return this.notify(`Enter ${this.name} screen`);
}
public exit(): void {
return this.notify(`Exit ${this.name} screen`);
}
public getObservers(): ObserverInterface[] {
return this.observers;
}
public abstract render(entities?: Entity[], player?: Player): void;
public abstract handleInput(inputType?: string, inputData?: InputDataInterface): string | null;
}
|