-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathENDPOINTS.txt
222 lines (174 loc) · 7.98 KB
/
ENDPOINTS.txt
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
**** ****
**** DailyBurn Hackathon 2015 ****
*** Team Winning - Luke A. Chris S. Kevin S. ***
**** ****
**** ****
Theme: Valentines!
Project: Text-Based Game
==========================================================================================================
DATA IDEAS
Player
:name (string)
:password (md5)
:sessionid (simple guid)
:age (int)
:eyecolor (string)
:haircolor (string)
:hearts (int)
:perfumes (int)
:roses (int)
:chocolates (int)
:silks (int)
:jewels (int)
:current_town (string)
:valentine (string)
:admin (bool)
Town
:name (string)
:links (string of array?)
Npc
:name (string)
:age (int)
:eyecolor (string)
:haircolor (string)
:requirements (array string)
:trades (array string)
:buy back ratio (number)
:current_town (string)
**********************************************************************************************************
END POINTS
- these are all of the end points the client will be hitting using AJAX (polling)
==========================================================================================================
POST /user/login
:username string
:password string
EXPECTED RETURN
:status string {ok|error}
:message string {"Invalid password" | "No user by this name"}
:sessionid string {hash set in cookie}
DESCRIPTION
The user attempts to login with a username/password combination. The Javascript automatically converts
the password to MD5 format. The server then checks if the user exists, if the MD5 matches the username's
hash. If not, return an error. If so, return ok, no message, and generate a session id which is used
for every other call rather than the password.
==========================================================================================================
POST /user/create
:username string
:password string
:age int
:eyecolor string
:haircolor string
EXPECTED RETURN
:status string {ok|error}
:message string {"Username already taken" | "Invalid password" | "Something went wrong... stack dump"}
:sessionid string {hash set in cookie}
DESCRIPTION
The user is creating a new login. The client will do password/confirm password, and send an MD5 to the
server so we don't actually log any real passwords :) If no other users exist with this username, the
age is not something crazy like negative, etc. etc., we send back an ok, no message, and the same
generate session id we had before.
==========================================================================================================
POST /travel
:username string
:sessionid string
EXPECT RETURN
:current_location string
:valid_destinations array {["B","D"]}
DESCRIPTION
The user is requesting to travel. The server should know which town the user is currently in, and have
a quick check to tell the user which towns they can travel to. This could technically be client-side, but
making it server makes this easier.
==========================================================================================================
POST /travel/:id
:username string
:sessionid string
EXPECT RETURN
:status string {ok|error}
:message string {"Invalid destination" | "You were robbed by heart bandits and lost X hearts"}
DESCRIPTION
The user is attempting to travel to another town. First, check to make sure the user can even do this
based on the user's current location. Next, randomly apply an action to the user's stats, this includes
removing candy hearts, adding items, etc. etc. All actual events according to our travel table are done
on the back-end. Now, send the message corresponding to the action up to the user, and the front-end will
take care of displaying this message. If everything went well, update the user's location to the new town.
==========================================================================================================
POST /talk
:username string
:sessionid string
EXPECT RETURN
:npcs array {["John","Bob","Gary"],["Mary","Sean","Bob"]}
DESCRIPTION
The user is requesting all npcs in the current town they are in. Get the list of NPCs associated with
this town, thats all we need.
==========================================================================================================
POST /talk/requirements/:id
:username string
:sessionid string
EXPECT RETURN
:status string {ok|error}
:message string {"Invalid user" | "age:32;eyecolor:blue,haircolor:brown,perfume:30;roses:2;chocolates:10"}
DESCRIPTION
The user is asking for a specific npc's requirements. Make sure the NPC is in the same town as the
user who is requesting it, and if all is good, send the requirements.
** NOTE ** If the user can match this NPC, also attach to the message that they can now ask to be
the NPC's valentine. "canValentine:1"
==========================================================================================================
POST /talk/trading/:id
:username string
:sessionid string
EXPECT RETURN
:status string {ok|error}
:message string {"Invalid user" | "buy:{perfume:0.25,roses:0.15},sell:{perfume:0.10,roses:0.10}"}
DESCRIPTION
The user is asking for the specific npc's trading numbers. Make sure the NPC is in the same town as
the user who is requesting it, if all is good, send the trading numbers.
==========================================================================================================
POST /talk/buy/:id
:username string
:sessionid string
:type string
:amount int
EXPECT RETURN
:status string {ok|error}
:message string {"Invalid user" | "Purchased"}
DESCRIPTION
The user is requesting to buy a specific type of item. Verify the NPC is in the same town as the user.
Next, verify the type is a valid type we can buy from an NPC, then check to amount against that NPC's
trading number. Finally, make sure the user has enough cash to actually complete this transaction. If so,
transfer over X number of units to the user's account, reduce the user's money by XX.XX hearts (USD
currency based), and return "Purchased"
==========================================================================================================
POST /talk/sell/:id
:username string
:sessionid string
:type string
:amount int
EXPECT RETURN
:status string {ok|error}
:message string {"Invalid user" | "Sold"}
DESCRIPTION
The user is requesting to sell a specific type of item. Verify the NPC is in the same town as the user.
Next, verify the type is a valid type we can sell from an NPC, then check to amount against that player's
actual amount. If the user has enough of that amount, check the NPC's trading value for selling (buy-back
* trade), subtract the number of inventory items and add the number of candy hearts equivalent to the trade.
==========================================================================================================
POST /talk/valentines/:id
:username string
:sessionid string
EXPECT RETURN
:status string {ok|error}
:message string {"Invalid user" | "Not enough requirements" | "Success"}
DESCRIPTION
The user is attempting to win the game! Verify the NPC is valid and in the same town as the user. Next,
check the user's current inventory against the NPC's requirements. If every attribute is equal to or greater
than the NPCs, then this NPC is their valentines! Set the player's valentine attribute to this player.
==========================================================================================================
POST /stat
:username string
:sessionid string
EXPECT RETURN
:stats string {"town:e,hearts:500,perfume:30,chocolates:3,valentine:''"}
DESCRIPTION
The user is requesting their own stats. This includes what town they are in, their candy hearts, their
inventory stats, and whether or not they currently have a valentines.
==========================================================================================================