Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wellsousaaa
GitHub Repository: wellsousaaa/Five-Nights-at-Freddys-Web
Path: blob/main/src/reducers/configReducer.js
270 views
1
const originalState = {
2
hour: 0,
3
isPlaying: true,
4
energy: 100,
5
time: 7000,
6
blackout: false,
7
jumpscare: false,
8
gameOver: false,
9
cameraButtonDisappear: false,
10
};
11
12
export default function config(state = originalState, action) {
13
switch (action.type) {
14
case "CHANGE_HOUR":
15
if (state.jumpscare || state.gameOver) return state;
16
return { ...state, hour: state.hour + 1 };
17
case "CHANGE_ENERGY":
18
if (state.hour === 6) return state;
19
return { ...state, energy: state.energy - 1 };
20
case "CHANGE_TIME":
21
return { ...state, time: action.content };
22
case "CHANGE_BLACKOUT":
23
return { ...state, blackout: true };
24
case "CHANGE_IS_PLAYING":
25
return { ...state, isPlaying: action.content };
26
case "CHANGE_JUMPSCARE":
27
return { ...state, jumpscare: action.animatronic };
28
case "CHANGE_CAMERA_BUTTON":
29
return { ...state, cameraButtonDisappear: true };
30
case "SET_GAME_OVER":
31
return { ...state, gameOver: true };
32
default:
33
return state;
34
}
35
}
36
37