-
-
Notifications
You must be signed in to change notification settings - Fork 143
/
index.js
73 lines (70 loc) · 1.9 KB
/
index.js
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import Vue from "vue"
import Vuex from "vuex"
Vue.use(Vuex)
export default new Vuex.Store({
state: {
uiState: "start",
score: 0,
character: "",
characterChoices: ["baker", "mechanic", "artist"],
questionIndex: 0,
questions: [{
question: `What's your dog's name?`,
baker: "Woofgang Puck",
mechanic: "Alf",
artist: "Salvador Dogi",
},
{
question: `What's your favorite hobby?`,
baker: "Extreme ironing",
mechanic: "Bacon santa cosplay",
artist: "Mimosas",
},
{
question: `What's your favorite color?`,
baker: "turquoise",
mechanic: "yellow",
artist: "transparent",
},
{
question: `Is cereal soup?`,
baker: "You can't be serieal",
mechanic: "Yes, I am Jason Lengstorf",
artist: "wut",
},
{
question: `What’s the most imaginative insult you can come up with?`,
baker: "You're a substitute teacher with no lesson plan",
mechanic: "Yer face is a melted welly",
artist: "You eat buttons off the remote",
},
{
question: `If peanut butter wasn’t called peanut butter, what would it be called?`,
baker: "legoome",
mechanic: "brown paste",
artist: "groundnut smoosh",
},
],
},
mutations: {
updateCharacter(state, choice) {
state.character = choice
},
updateScore(state, amount) {
state.score = amount
},
updateUIState(state, uistate) {
state.uiState = uistate
},
pickQuestion(state, character) {
character === state.character ? (state.score += 13) : (state.score -= 13)
if (state.questionIndex < state.questions.length - 1) {
state.questionIndex++
} else {
Math.sign(state.score) > 0 ?
(state.uiState = "won") :
(state.uiState = "lost")
}
},
},
})