From eb208a7e2fd020ab5d07d11cc6d52d1e3dcfcc7c Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Sun, 17 Sep 2017 17:55:04 +0200 Subject: Add simulation mode framework Includes object states in the store (by tick), charting, and progress bars. --- src/reducers/construction-mode.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/reducers/construction-mode.js (limited to 'src/reducers/construction-mode.js') diff --git a/src/reducers/construction-mode.js b/src/reducers/construction-mode.js new file mode 100644 index 00000000..3e0b7542 --- /dev/null +++ b/src/reducers/construction-mode.js @@ -0,0 +1,35 @@ +import {combineReducers} from "redux"; +import { + CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED, + FINISH_NEW_ROOM_CONSTRUCTION, + START_NEW_ROOM_CONSTRUCTION_SUCCEEDED +} from "../actions/topology/building"; +import {START_RACK_CONSTRUCTION, STOP_RACK_CONSTRUCTION} from "../actions/topology/room"; + +export function currentRoomInConstruction(state = -1, action) { + switch (action.type) { + case START_NEW_ROOM_CONSTRUCTION_SUCCEEDED: + return action.roomId; + case CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED: + case FINISH_NEW_ROOM_CONSTRUCTION: + return -1; + default: + return state; + } +} + +export function inRackConstructionMode(state = false, action) { + switch (action.type) { + case START_RACK_CONSTRUCTION: + return true; + case STOP_RACK_CONSTRUCTION: + return false; + default: + return state; + } +} + +export const construction = combineReducers({ + currentRoomInConstruction, + inRackConstructionMode, +}); -- cgit v1.2.3