diff --git a/src/data/layers/aca/a.ts b/src/data/layers/aca/a.ts index a18fdab..cacf0c6 100644 --- a/src/data/layers/aca/a.ts +++ b/src/data/layers/aca/a.ts @@ -62,7 +62,7 @@ export default { maxRows: 3, rows: 2, cols: 2, - getStartData(cell: string) { + getStartState(cell: string) { return cell; }, getUnlocked() { @@ -73,11 +73,11 @@ export default { return player.points.eq(10); }, getStyle(cell) { - return { backgroundColor: "#" + ((Number((this[cell] as GridCell).data) * 1234) % 999999) }; + return { backgroundColor: "#" + ((Number((this[cell] as GridCell).state) * 1234) % 999999) }; }, click(cell) { // Don't forget onHold - (this[cell] as GridCell).data = ((this[cell] as GridCell).data as number) + 1; + (this[cell] as GridCell).state = ((this[cell] as GridCell).state as number) + 1; }, getTitle(cell) { let direction; @@ -95,7 +95,7 @@ export default { `; }, getDisplay(cell) { - return (this[cell] as GridCell).data; + return (this[cell] as GridCell).state; } } } diff --git a/src/game/layers.ts b/src/game/layers.ts index f9f1aaa..e941fcb 100644 --- a/src/game/layers.ts +++ b/src/game/layers.ts @@ -404,23 +404,23 @@ export function addLayer(layer: RawLayer, player?: Partial): void { setupFeatures, Grid>(layer.id, layer.grids); for (const id in layer.grids.data) { setDefault(player.layers[layer.id].grids, id, {}); - layer.grids.data[id].getData = function(cell): State { + layer.grids.data[id].getState = function(cell): State { if (playerProxy.layers[this.layer].grids[id][cell] != undefined) { return playerProxy.layers[this.layer].grids[id][cell]; } - if (isFunction(this.getStartData)) { - return (this.getStartData as (this: Grid, cell: string | number) => State)( + if (isFunction(this.getStartState)) { + return (this.getStartState as (this: Grid, cell: string | number) => State)( cell ); } - return this.getStartData; + return this.getStartState; }; - layer.grids.data[id].setData = function(cell, data) { - playerProxy.layers[this.layer].grids[id][cell] = data; + layer.grids.data[id].setState = function(cell, state) { + playerProxy.layers[this.layer].grids[id][cell] = state; }; setDefault(layer.grids.data[id], "getUnlocked", true, false); setDefault(layer.grids.data[id], "getCanClick", true, false); - setDefault(layer.grids.data[id], "getStartData", "", false); + setDefault(layer.grids.data[id], "getStartState", "", false); setDefault(layer.grids.data[id], "getStyle", undefined, false); setDefault(layer.grids.data[id], "click", undefined, false); setDefault(layer.grids.data[id], "hold", undefined, false); @@ -433,15 +433,15 @@ export function addLayer(layer: RawLayer, player?: Partial): void { for (const id in layer.boards.data) { setDefault(layer.boards.data[id], "width", "100%"); setDefault(layer.boards.data[id], "height", "400px"); - setDefault(layer.boards.data[id], "nodes", function() { + setDefault(layer.boards.data[id], "nodes", function(this: Board) { return playerProxy.layers[this.layer].boards[this.id].nodes; }); - setDefault(layer.boards.data[id], "selectedNode", function() { + setDefault(layer.boards.data[id], "selectedNode", function(this: Board) { return playerProxy.layers[this.layer].boards[this.id].nodes.find( node => node.id === playerProxy.layers[this.layer].boards[this.id].selectedNode ); }); - setDefault(layer.boards.data[id], "selectedAction", function() { + setDefault(layer.boards.data[id], "selectedAction", function(this: Board) { if (this.selectedNode == null) { return null; } @@ -460,11 +460,11 @@ export function addLayer(layer: RawLayer, player?: Partial): void { action.id === playerProxy.layers[this.layer].boards[this.id].selectedAction ); }); - setDefault(layer.boards.data[id], "links", function() { + setDefault(layer.boards.data[id], "links", function(this: Board) { if (this.selectedAction == null) { return null; } - if (this.selectedAction.links) { + if (this.selectedAction.links && this.selectedNode) { if (typeof this.selectedAction.links === "function") { return this.selectedAction.links(this.selectedNode); } diff --git a/src/typings/features/grid.d.ts b/src/typings/features/grid.d.ts index 61c4021..7ba6736 100644 --- a/src/typings/features/grid.d.ts +++ b/src/typings/features/grid.d.ts @@ -5,11 +5,11 @@ export interface Grid extends Feature { maxRows: number; rows: number; cols: number; - getData?: (cell: string | number) => State; - setData?: (cell: string | number, data: State) => void; + getState?: (cell: string | number) => State; + setState?: (cell: string | number, state: State) => void; getUnlocked: boolean | ((cell: string | number) => boolean); getCanClick: boolean | ((cell: string | number) => boolean); - getStartData: State | ((cell: string | number) => State); + getStartState: State | ((cell: string | number) => State); getStyle?: | Partial | ((cell: string | number) => Partial | undefined); @@ -20,8 +20,8 @@ export interface Grid extends Feature { } export interface GridCell extends Feature { - data: State; - dataSet: (data: State) => void; + state: State; + stateSet: (state: State) => void; effect?: State; unlocked: boolean; canClick: boolean; diff --git a/src/util/proxies.ts b/src/util/proxies.ts index 52b32ea..ae43ad8 100644 --- a/src/util/proxies.ts +++ b/src/util/proxies.ts @@ -151,7 +151,7 @@ function getCellHandler(id: string) { let prop = target[key]; if (isFunction(prop) && prop.forceCached === false) { - return () => prop.call(receiver, id, target.getData(id)); + return () => prop.call(receiver, id, target.getState(id)); } if (prop != undefined || key.slice == undefined) { return prop; @@ -160,14 +160,14 @@ function getCellHandler(id: string) { key = key.slice(0, 1).toUpperCase() + key.slice(1); prop = target[`get${key}`]; if (isFunction(prop)) { - return prop.call(receiver, id, target.getData(id)); + return prop.call(receiver, id, target.getState(id)); } else if (prop != undefined) { return prop; } prop = target[`on${key}`]; if (isFunction(prop)) { - return () => prop.call(receiver, id, target.getData(id)); + return () => prop.call(receiver, id, target.getState(id)); } else if (prop != undefined) { return prop; }