diff options
Diffstat (limited to 'src/engine/entities/FunctionApplication.ts')
-rw-r--r-- | src/engine/entities/FunctionApplication.ts | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/engine/entities/FunctionApplication.ts b/src/engine/entities/FunctionApplication.ts index ac07f88..4d5729f 100644 --- a/src/engine/entities/FunctionApplication.ts +++ b/src/engine/entities/FunctionApplication.ts @@ -30,7 +30,10 @@ import { interpret, } from "../../interpreter"; -const APPLICATION_RESULTS: Record<string, (gridPosition: Coord2D) => null | Entity> = { +const APPLICATION_RESULTS: Record< + string, + (gridPosition: Coord2D) => null | Entity +> = { _KEY: (gridPosition: Coord2D) => new Key(gridPosition), _EMPTY: (_gridPosition: Coord2D) => null, }; @@ -59,8 +62,8 @@ export class FunctionApplication extends Entity { y: 0, }, dimension, - 0 - ) + 0, + ), ); this.addComponent(new Grid(gridPosition)); @@ -73,14 +76,14 @@ export class FunctionApplication extends Entity { { x: 0, y: 0 }, dimension, FunctionApplication.spriteSpec.msPerFrame, - FunctionApplication.spriteSpec.frames - ) + FunctionApplication.spriteSpec.frames, + ), ); this.addComponent(new Colliding(this.handleCollision.bind(this))); this.addComponent( - new Highlight(this.onHighlight.bind(this), this.onUnhighlight.bind(this)) + new Highlight(this.onHighlight.bind(this), this.onUnhighlight.bind(this)), ); } @@ -94,7 +97,7 @@ export class FunctionApplication extends Entity { return { consumed: true }; }; const { last, code } = this.getComponent<LambdaTerm>( - ComponentNames.LambdaTerm + ComponentNames.LambdaTerm, ); this.addComponent( new Modal({ @@ -108,7 +111,7 @@ export class FunctionApplication extends Entity { data: last?.data && `Last Result: ${emitNamed(last.data)}`, }, }, - }) + }), ); } @@ -132,7 +135,7 @@ export class FunctionApplication extends Entity { const gridSystem = game.getSystem<GridSystem>(SystemNames.Grid); const fail = () => { entityGrid.movingDirection = gridSystem.oppositeDirection( - entityGrid.previousDirection + entityGrid.previousDirection, ); entity.addComponent(entityGrid); @@ -141,10 +144,10 @@ export class FunctionApplication extends Entity { }; const applicationTerm = this.getComponent<LambdaTerm>( - ComponentNames.LambdaTerm + ComponentNames.LambdaTerm, ); const functionTerm = entity.getComponent<LambdaTerm>( - ComponentNames.LambdaTerm + ComponentNames.LambdaTerm, ); const newCode = applicationTerm.code.replace("_INPUT", functionTerm.code); @@ -158,7 +161,7 @@ export class FunctionApplication extends Entity { const nextPosition = gridSystem.getNewGridPosition( grid.gridPosition, - entityGrid.previousDirection + entityGrid.previousDirection, ); let applicationResultingEntity: Entity | null = null; // this should be its own function @@ -167,7 +170,7 @@ export class FunctionApplication extends Entity { // if we get an application that means we didn't interpret correctly. // this should "not" happen and should be fatal. throw new InvalidLambdaTermError( - "produced term should not be an application" + "produced term should not be an application", ); } if ("abstraction" in data) { @@ -178,7 +181,7 @@ export class FunctionApplication extends Entity { const { name } = data; const entityFactory = APPLICATION_RESULTS[name]; if (entityFactory) { - const entity = entityFactory(nextPosition) + const entity = entityFactory(nextPosition); entity && game.addEntity(entity); } } @@ -186,7 +189,7 @@ export class FunctionApplication extends Entity { game.removeEntity(entity.id); if (applicationResultingEntity) { const grid = applicationResultingEntity.getComponent<Grid>( - ComponentNames.Grid + ComponentNames.Grid, ); grid.movingDirection = entityGrid.previousDirection; applicationResultingEntity.addComponent(grid); |