mirror of
https://github.com/thepaperpilot/Planar-Pioneers.git
synced 2024-11-28 19:11:42 +00:00
Renamed grid data -> state
This commit is contained in:
parent
2eeb96a66f
commit
7c0f93b7ad
4 changed files with 24 additions and 24 deletions
|
@ -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 {
|
|||
</tooltip>`;
|
||||
},
|
||||
getDisplay(cell) {
|
||||
return (this[cell] as GridCell).data;
|
||||
return (this[cell] as GridCell).state;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -404,23 +404,23 @@ export function addLayer(layer: RawLayer, player?: Partial<PlayerData>): void {
|
|||
setupFeatures<NonNullable<RawLayer["grids"]>, 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<PlayerData>): 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<PlayerData>): 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);
|
||||
}
|
||||
|
|
10
src/typings/features/grid.d.ts
vendored
10
src/typings/features/grid.d.ts
vendored
|
@ -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<CSSStyleDeclaration>
|
||||
| ((cell: string | number) => Partial<CSSStyleDeclaration> | 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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue