-
Notifications
You must be signed in to change notification settings - Fork 0
/
testfile.html
122 lines (112 loc) · 3.49 KB
/
testfile.html
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<script>
var graph =
{"NONE":
{"DonationTrade": {nextVertex: "donationTradeStarted", f: function() {
var stateVariables = {state: "", cause: "", alignment: ""}
setTyping(sender, "on")
setTimeout(function(){
quickReplies(sender,
"Hello. Care to do a donation trade?",
["Yes", "No", "Huh?"],
"donationTradeStarted")
setTyping(sender, "off")
}, 100
)
stateVariables.state = "donationTradeStarted"
return stateVariables
}}
},
"donationTradeStarted":
{"Yes": {nextVertex: "CauseSelection", f: function() {
redisClient.set("MoralTrade:test", "it works!")
setTyping(sender, "on")
setTimeout(function(){
quickReplies(sender,
"Fantastic. Now choose the cause you care most about. And do be honest",
["Gun Rights", "Abortion Rights"],
"CauseSelection")
setTyping(sender, "off")
}, 100
)
state = "CauseSelection"
}},
"No": {nextVertex: "XXXX", f: function() {
sendTextMessage(sender, "No1")
}},
"Huh?": {nextVertex: "XXXX", f: function() {
sendTextMessage(sender, "Huh?")
}}
},
"CauseSelection":
{"Gun Rights": {nextVertex: "CauseSelected", f: function() {
setTyping(sender, "on")
setTimeout(function(){
quickReplies(sender,
"Extraordinary choice. Tell me, how do you really feel about it?",
["Very For", "Neutral", "Very Against"],
"CauseSelected"
)
setTyping(sender, "off")
}, 100
)
state = "CauseSelected"
cause = "Gun Rights" // ie cause = answer
}},
"Abortion Rights": {nextVertex: "XXXX", f: function() {
sendTextMessage(sender, "Abortion Rights")
}}
},
"CauseSelected":
{"Very For": {nextVertex: "AlignmentSelected", f: function() {
setTyping(sender, "on")
setTimeout(function(){
sendTextMessage(sender, "Very good. Lets proceed.")
sendButtons(sender,
"Confirm Trade",
"Do you want to post the trade?",
["Yes", "No"],
"AlignmentSelected"
)
setTyping(sender, "off")
}, 100
)
state = "AlignmentSelected"
alignment = "Very For" // ie alignment = answer
}},
"Neutral": {nextVertex: "XXXX", f: function() {
sendTextMessage(sender, "Neutral")
}},
"Very Against": {nextVertex: "XXXX", f: function() {
sendTextMessage(sender, "Very Against")
}}
},
"AlignmentSelected":
{"Yes": {nextVertex: "XXXX", f: function() {
redisClient.lpush(["MoralTrade:awaitingMatches", JSON.stringify({name: sender, cause: cause, alignment: alignment})])
sendTextMessage(sender, "♞♚♝♛♟♜Trade Posted♞♚♝♛♟♜")
state = "" //Should be MatchFinding
cause = ""
alignment = ""
// The next state will be match finding and then after that finances...
}}
},
"CATCHALLSTATE":
{"CATCHALLANSWER": {nextVertex: "XXXX", f: function() {}}
}
}
// Object.keys(graph) gets all states
// Object.keys(graph.vertex) gets all the edges for that vertex
function inList(list, el) {
i = 0
while (i < list.length) {
if (list[i] === el) {
return true
}
i += 1
}
return false
};
state = "CauseSelection"
answer = "Gun Rights"
graph.donationTradeStarted.Yes.f()
</script>