make the carcadr level an _actual_ carcadr level
All checks were successful
continuous-integration/drone Build is passing
All checks were successful
continuous-integration/drone Build is passing
This commit is contained in:
parent
826cf14cfb
commit
9f0ccd188c
@ -35,7 +35,7 @@ export class TheAbstractionEngine {
|
||||
|
||||
[
|
||||
new Modal(),
|
||||
new Level(LevelNames.LevelSelection),
|
||||
new Level(LevelNames.CarCadr),
|
||||
inputSystem,
|
||||
facingDirectionSystem,
|
||||
new Grid(
|
||||
|
@ -30,8 +30,9 @@ import {
|
||||
interpret,
|
||||
} from "../../interpreter";
|
||||
|
||||
const APPLICATION_RESULTS: Record<string, (gridPosition: Coord2D) => Entity> = {
|
||||
const APPLICATION_RESULTS: Record<string, (gridPosition: Coord2D) => null | Entity> = {
|
||||
_KEY: (gridPosition: Coord2D) => new Key(gridPosition),
|
||||
_EMPTY: (_gridPosition: Coord2D) => null,
|
||||
};
|
||||
|
||||
export class FunctionApplication extends Entity {
|
||||
@ -177,7 +178,8 @@ export class FunctionApplication extends Entity {
|
||||
const { name } = data;
|
||||
const entityFactory = APPLICATION_RESULTS[name];
|
||||
if (entityFactory) {
|
||||
game.addEntity(entityFactory(nextPosition));
|
||||
const entity = entityFactory(nextPosition)
|
||||
entity && game.addEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,21 +38,39 @@ export class CarCadr extends Level {
|
||||
const entities = [
|
||||
...grasses,
|
||||
new Player({ x: 9, y: 5 }),
|
||||
new Wall({ x: 4, y: 3 }),
|
||||
new Wall({ x: 4, y: 4 }),
|
||||
new LambdaFactory({ x: 6, y: 4 }, "(\\ (x) . x)", 1),
|
||||
new FunctionApplication({ x: 5, y: 5 }, "(_INPUT _KEY)"),
|
||||
// Cadr
|
||||
new Wall({ x: 2, y: 3 }),
|
||||
new Wall({ x: 2, y: 4 }),
|
||||
new Wall({ x: 5, y: 3 }),
|
||||
new LambdaFactory({ x: 4, y: 4 }, "(\\ (x) . x)", 1),
|
||||
new FunctionApplication({ x: 3, y: 5 }, "(_INPUT _KEY)"),
|
||||
new Wall({ x: 2, y: 5 }),
|
||||
new Wall({ x: 4, y: 5 }),
|
||||
new Wall({ x: 6, y: 5 }),
|
||||
new FunctionApplication({ x: 4, y: 6 }, "(_INPUT _NULL)"),
|
||||
new Wall({ x: 6, y: 7 }),
|
||||
new Wall({ x: 5, y: 7 }),
|
||||
new FunctionApplication({ x: 2, y: 6 }, "(_INPUT _EMPTY)"),
|
||||
new Wall({ x: 4, y: 7 }),
|
||||
new LockedDoor({ x: 3, y: 8 }),
|
||||
new Curry({ x: 3, y: 9 }),
|
||||
new Wall({ x: 2, y: 9 }),
|
||||
new Wall({ x: 4, y: 9 }),
|
||||
new Wall({ x: 3, y: 10 }),
|
||||
new Wall({ x: 3, y: 7 }),
|
||||
new Wall({ x: 2, y: 7 }),
|
||||
new Wall({ x: 9, y: 3 }),
|
||||
// Car
|
||||
new LambdaFactory({ x: 10, y: 4 }, "(\\ (x) . x)", 1),
|
||||
new Wall({ x: 12, y: 4 }),
|
||||
new FunctionApplication({ x: 11, y: 5 }, "(_INPUT _EMPTY)"),
|
||||
new Wall({ x: 10, y: 5 }),
|
||||
new Wall({ x: 12, y: 5 }),
|
||||
new Wall({ x: 12, y: 3 }),
|
||||
new FunctionApplication({ x: 12, y: 6 }, "(_INPUT _KEY)"),
|
||||
new Wall({ x: 10, y: 7 }),
|
||||
new Wall({ x: 11, y: 7 }),
|
||||
new Wall({ x: 12, y: 7 }),
|
||||
// solve!
|
||||
new LockedDoor({ x: 7, y: 8 }),
|
||||
new LockedDoor({ x: 7, y: 9 }),
|
||||
new Curry({ x: 7, y: 10 }),
|
||||
new Wall({ x: 6, y: 9 }),
|
||||
new Wall({ x: 8, y: 9 }),
|
||||
new Wall({ x: 6, y: 10 }),
|
||||
new Wall({ x: 8, y: 10 }),
|
||||
new Wall({ x: 7, y: 11 }),
|
||||
];
|
||||
|
||||
entities.forEach((entity) => game.addEntity(entity));
|
||||
|
@ -54,7 +54,7 @@ export class CodeEditorInstance {
|
||||
initCode: string,
|
||||
codeConsumer: CodeEditorState["codeConsumer"],
|
||||
readonly: boolean = false,
|
||||
initResult: { data?: string; error?: string } = {},
|
||||
initResult: { data?: string; error?: string } = {}
|
||||
) {
|
||||
if (this.codeEditorState) {
|
||||
throw new Error("code editor instance is already owned.");
|
||||
@ -163,7 +163,9 @@ export class CodeEditorInstance {
|
||||
}
|
||||
|
||||
private setResult(result: { data?: string; error?: string }) {
|
||||
if (!this.codeEditorState) return;
|
||||
if (!this.codeEditorState) {
|
||||
return;
|
||||
}
|
||||
this.codeEditorState.resultElement.innerText = result.data ?? "";
|
||||
this.codeEditorState.errorElement.innerText = result.error ?? "";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user