summaryrefslogtreecommitdiff
path: root/src/reducers/construction.js
blob: 3348584216a15698b17026b63185a5cb21200299 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import {combineReducers} from "redux";
import {
    CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED,
    FINISH_NEW_ROOM_CONSTRUCTION,
    START_NEW_ROOM_CONSTRUCTION_SUCCEEDED,
    START_OBJECT_CONSTRUCTION,
    STOP_OBJECT_CONSTRUCTION
} from "../actions/topology";

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 inObjectConstructionMode(state = false, action) {
    switch (action.type) {
        case START_OBJECT_CONSTRUCTION:
            return true;
        case STOP_OBJECT_CONSTRUCTION:
            return false;
        default:
            return state;
    }
}

export const construction = combineReducers({
    currentRoomInConstruction,
    inObjectConstructionMode,
});