summaryrefslogtreecommitdiff
path: root/src/actions/interaction-level.js
blob: 2003f45ef4abd259b6841de9a6f4454fa9d90b65 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
export const GO_FROM_BUILDING_TO_ROOM = "GO_FROM_BUILDING_TO_ROOM";
export const GO_FROM_ROOM_TO_RACK = "GO_FROM_ROOM_TO_RACK";
export const GO_FROM_RACK_TO_MACHINE = "GO_FROM_RACK_TO_MACHINE";
export const GO_DOWN_ONE_INTERACTION_LEVEL = "GO_DOWN_ONE_INTERACTION_LEVEL";

export function goFromBuildingToRoom(roomId) {
    return (dispatch, getState) => {
        const {interactionLevel} = getState();
        if (interactionLevel.mode !== "BUILDING") {
            return;
        }

        dispatch({
            type: GO_FROM_BUILDING_TO_ROOM,
            roomId
        });
    };
}

export function goFromRoomToRack(tileId) {
    return (dispatch, getState) => {
        const {interactionLevel} = getState();
        if (interactionLevel.mode !== "ROOM") {
            return;
        }
        dispatch({
            type: GO_FROM_ROOM_TO_RACK,
            tileId
        });
    };
}

export function goFromRackToMachine(position) {
    return (dispatch, getState) => {
        const {interactionLevel} = getState();
        if (interactionLevel.mode !== "RACK") {
            return;
        }
        dispatch({
            type: GO_FROM_RACK_TO_MACHINE,
            position
        });
    };
}

export function goDownOneInteractionLevel() {
    return {
        type: GO_DOWN_ONE_INTERACTION_LEVEL
    };
}