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 | |
package com.buckosoft.fibs.net; |
190 | |
|
191 | |
import java.util.Iterator; |
192 | |
import java.util.LinkedList; |
193 | |
import java.util.regex.Pattern; |
194 | |
|
195 | |
|
196 | |
|
197 | |
|
198 | |
|
199 | |
|
200 | |
|
201 | |
|
202 | |
|
203 | |
|
204 | |
|
205 | 3 | public class CookieMonster implements FIBSMessages { |
206 | |
private final static boolean DEBUG = false; |
207 | |
private ClientConnection clientConnection; |
208 | |
|
209 | 1260 | private class CookieDough { |
210 | 630 | public Pattern regex = null; |
211 | 630 | public int message = 0; |
212 | |
} |
213 | |
|
214 | 3 | private final int FIBS_UNINITIALIZED = 1, |
215 | |
FIBS_LOGIN = 2, |
216 | |
FIBS_MOTD = 3, |
217 | |
FIBS_RUN = 4, |
218 | |
FIBS_LOGOUT = 5, |
219 | |
FIBS_REGISTER = 6; |
220 | |
|
221 | 3 | private int messageState = FIBS_UNINITIALIZED; |
222 | |
|
223 | |
private LinkedList<CookieDough> alphaBatch; |
224 | |
private LinkedList<CookieDough> starsBatch; |
225 | |
private LinkedList<CookieDough> numericBatch; |
226 | |
private LinkedList<CookieDough> loginBatch; |
227 | |
private LinkedList<CookieDough> registerBatch; |
228 | |
private LinkedList<CookieDough> motdBatch; |
229 | |
|
230 | |
public void setClientConnection(ClientConnection clientConnection) { |
231 | 0 | this.clientConnection = clientConnection; |
232 | 0 | } |
233 | |
|
234 | |
|
235 | |
|
236 | |
|
237 | |
|
238 | |
public int fIBSCookie(String message) { |
239 | 16 | if (messageState == FIBS_UNINITIALIZED) { |
240 | 1 | prepareBatches(); |
241 | |
} |
242 | 16 | int result = FIBS_Unknown; |
243 | |
Iterator<CookieMonster.CookieDough> iter; |
244 | 16 | CookieDough ptr = null; |
245 | |
|
246 | 16 | switch (messageState) { |
247 | |
case FIBS_UNINITIALIZED: |
248 | 0 | return(FIBS_BAD_COOKIE); |
249 | |
case FIBS_RUN: |
250 | 6 | if (message.length() == 0) |
251 | 1 | return(FIBS_Empty); |
252 | 5 | char ch = message.charAt(0); |
253 | 5 | if (ch >= '0' && ch <= '9') { |
254 | 2 | iter = numericBatch.iterator(); |
255 | 22 | while (iter.hasNext()) { |
256 | 22 | ptr = iter.next(); |
257 | |
|
258 | 22 | if (ptr.regex.matcher(message).find()) { |
259 | 2 | result = ptr.message; |
260 | 2 | break; |
261 | |
} |
262 | |
} |
263 | 3 | } else if (ch == '*') { |
264 | 2 | iter = starsBatch.iterator(); |
265 | 135 | while (iter.hasNext()) { |
266 | 135 | ptr = iter.next(); |
267 | 135 | if (ptr.regex.matcher(message).find()) { |
268 | 2 | result = ptr.message; |
269 | 2 | break; |
270 | |
} |
271 | |
} |
272 | |
} else { |
273 | 1 | iter = alphaBatch.iterator(); |
274 | 53 | while (iter.hasNext()) { |
275 | 53 | ptr = iter.next(); |
276 | 53 | if (ptr.regex.matcher(message).find()) { |
277 | 1 | result = ptr.message; |
278 | 1 | break; |
279 | |
} |
280 | |
} |
281 | |
} |
282 | 5 | if (result == FIBS_Goodbye) |
283 | 0 | messageState = FIBS_LOGOUT; |
284 | |
break; |
285 | |
case FIBS_LOGIN: |
286 | 7 | result = FIBS_PreLogin; |
287 | 7 | iter = loginBatch.iterator(); |
288 | 31 | while (iter.hasNext()) { |
289 | 28 | ptr = iter.next(); |
290 | 28 | if (ptr.regex.matcher(message).find()) { |
291 | 4 | result = ptr.message; |
292 | 4 | break; |
293 | |
} |
294 | |
} |
295 | 7 | if (result == CLIP_MOTD_BEGIN) |
296 | 1 | messageState = FIBS_MOTD; |
297 | 7 | if (result == FIBS_WelcomeToFibs) |
298 | 0 | messageState = FIBS_REGISTER; |
299 | |
break; |
300 | |
case FIBS_MOTD: |
301 | 3 | result = FIBS_MOTD; |
302 | 3 | iter = motdBatch.iterator(); |
303 | 5 | while (iter.hasNext()) { |
304 | 3 | ptr = iter.next(); |
305 | 3 | if (ptr.regex.matcher(message).find()) { |
306 | 1 | result = ptr.message; |
307 | 1 | break; |
308 | |
} |
309 | |
} |
310 | 3 | if (result == CLIP_MOTD_END) |
311 | 1 | messageState = FIBS_RUN; |
312 | |
break; |
313 | |
case FIBS_REGISTER: |
314 | 0 | result = FIBS_MOTD; |
315 | 0 | iter = registerBatch.iterator(); |
316 | 0 | while (iter.hasNext()) { |
317 | 0 | ptr = iter.next(); |
318 | 0 | if (ptr.regex.matcher(message).find()) { |
319 | 0 | result = ptr.message; |
320 | 0 | break; |
321 | |
} |
322 | |
} |
323 | |
break; |
324 | |
case FIBS_LOGOUT: |
325 | 0 | return(FIBS_PostGoodbye); |
326 | |
} |
327 | 15 | if (result == FIBS_Unknown) |
328 | 0 | return(FIBS_Unknown); |
329 | 15 | String[] ss = ptr.regex.split(message, 2); |
330 | 15 | if (ss.length > 1 && ss[1].length() > 0) { |
331 | |
if (DEBUG) { |
332 | |
System.out.println("cookie = " + result); |
333 | |
System.out.println("message = '" + message + "'"); |
334 | |
System.out.println("Leftover = '" + ss[1] + "'"); |
335 | |
} |
336 | 0 | clientConnection.pushBack(ss[1]); |
337 | |
} |
338 | 15 | return(result); |
339 | |
} |
340 | |
|
341 | |
|
342 | |
|
343 | |
|
344 | |
|
345 | |
|
346 | |
|
347 | |
|
348 | |
|
349 | |
|
350 | |
public void reset() |
351 | |
{ |
352 | 1 | if (messageState == FIBS_UNINITIALIZED) |
353 | 1 | prepareBatches(); |
354 | |
else |
355 | 0 | messageState = FIBS_LOGIN; |
356 | 1 | } |
357 | |
|
358 | |
|
359 | |
LinkedList<CookieDough> currentBatchBuild; |
360 | |
|
361 | |
private void addDough(int msg, String re) { |
362 | 630 | CookieDough newDough = new CookieDough(); |
363 | |
|
364 | 630 | newDough.regex = Pattern.compile(re); |
365 | 630 | newDough.message = msg; |
366 | 630 | currentBatchBuild.add(newDough); |
367 | |
|
368 | 630 | } |
369 | |
|
370 | 1 | private static String PL = "[a-zA-Z0-9_<>]+"; |
371 | |
|
372 | |
private void prepareBatches() { |
373 | 2 | currentBatchBuild = new LinkedList<CookieDough>(); |
374 | |
|
375 | |
|
376 | 2 | addDough(FIBS_Board, "^board:" + PL + ":" + PL + "(:\\-*[0-9]+){49}:[0-9]"); |
377 | |
|
378 | 2 | addDough(FIBS_YouRoll, "^You roll [1-6] and [1-6]\\."); |
379 | 2 | addDough(FIBS_PlayerRolls, "^" + PL + " rolls [1-6] and [1-6]\\."); |
380 | |
|
381 | 2 | addDough(FIBS_RollOrDouble, "^It's your turn to roll or double\\.?"); |
382 | 2 | addDough(FIBS_RollOrDouble, "^It's your turn\\. Please roll or double\\.?"); |
383 | 2 | addDough(FIBS_AcceptRejectDouble, "doubles\\. Type 'accept' or 'reject'\\."); |
384 | 2 | addDough(FIBS_Doubles, "^" + PL + " doubles\\."); |
385 | 2 | addDough(FIBS_PlayerAcceptsDouble, "accepts the double\\. The cube shows [0-9]+\\."); |
386 | 2 | addDough(FIBS_PleaseMove, "^Please move [1-4] pieces?\\."); |
387 | |
|
388 | 2 | addDough(FIBS_PlayerMoves, "^" + PL + " moves .*\\. ?"); |
389 | 2 | addDough(FIBS_PlayerMoves, "^" + PL + " moves .*$"); |
390 | |
|
391 | 2 | addDough(FIBS_BearingOff, "^Bearing off: [0-9]+ o [0-9]+ o [0-9]+ o [0-9]+ o "); |
392 | 2 | addDough(FIBS_BearingOff, "^Bearing off: [0-9]+ o [0-9]+ o [0-9]+ o "); |
393 | 2 | addDough(FIBS_BearingOff, "^Bearing off: [0-9]+ o [0-9]+ o "); |
394 | 2 | addDough(FIBS_BearingOff, "^Bearing off: [0-9]+ o "); |
395 | 2 | addDough(FIBS_YouReject, "^You reject\\. The game continues\\."); |
396 | 2 | addDough(FIBS_YouStopWatching, "You're not watching anymore\\."); |
397 | 2 | addDough(FIBS_OpponentLogsOut, "The game was saved\\."); |
398 | 2 | addDough(FIBS_GameWasSaved, "Your game with " + PL + " was saved\\."); |
399 | 2 | addDough(FIBS_OnlyPossibleMove, "^The only possible move is .* \\."); |
400 | 2 | addDough(FIBS_FirstRoll, "" + PL + " rolled [1-6].+rolled [1-6]"); |
401 | 2 | addDough(FIBS_MakesFirstMove, " makes the first move\\."); |
402 | 2 | addDough(FIBS_YouDouble, "^You double\\. Please wait for " + PL + " to accept or reject\\."); |
403 | 2 | addDough(FIBS_PlayerWantsToResign, "^" + PL + " wants to resign\\. You will win [0-9]+ points?\\. Type 'accept' or 'reject'\\."); |
404 | 2 | addDough(FIBS_WatchResign, "^" + PL + " wants to resign\\. " + PL + " will win [0-9]+ points?\\."); |
405 | 2 | addDough(FIBS_YouResign, "^You want to resign\\. " + PL + " will win [0-9]+ points?\\."); |
406 | 2 | addDough(FIBS_ResumeMatchAck5, "^You are now playing with " + PL + "\\. Your running match was loaded\\."); |
407 | 2 | addDough(FIBS_JoinNextGame, "^Type 'join' if you want to play the next game, type 'leave' if you don't\\."); |
408 | 2 | addDough(FIBS_NewMatchRequest, "^" + PL + " wants to play a [0-9]+ point match with you\\."); |
409 | 2 | addDough(FIBS_WARNINGSavedMatch, "^WARNING: Don't accept if you want to continue .* match\\!"); |
410 | 2 | addDough(FIBS_ResignRefused, "rejects\\. The game continues\\."); |
411 | 2 | addDough(FIBS_MatchLength, "^match length: [0-9]+"); |
412 | 2 | addDough(FIBS_TypeJoin, "^Type 'join " + PL + "' to accept\\."); |
413 | 2 | addDough(FIBS_YouAreWatching, "^You're now watching " + PL + "\\."); |
414 | 2 | addDough(FIBS_YouStopWatching, "^You stop watching " + PL + "\\."); |
415 | 2 | addDough(FIBS_PlayerStartsWatching, "" + PL + " starts watching " + PL + "\\."); |
416 | 2 | addDough(FIBS_PlayerStartsWatching, "" + PL + " is watching you\\."); |
417 | 2 | addDough(FIBS_PlayerStopsWatching, "" + PL + " stops watching " + PL + "\\."); |
418 | 2 | addDough(FIBS_PlayerIsWatching, "" + PL + " is watching "); |
419 | 2 | addDough(FIBS_NotInteresting, "" + PL + " is not doing anything interesting\\."); |
420 | |
|
421 | 2 | addDough(FIBS_ResignWins, "^" + PL + " gives up\\. " + PL + " wins [0-9]+ points?\\."); |
422 | 2 | addDough(FIBS_ResignYouWin, "^" + PL + " gives up\\. You win [0-9]+ points?\\."); |
423 | 2 | addDough(FIBS_YouAcceptAndWin, "^You accept and win [0-9]+ points?\\."); |
424 | 2 | addDough(FIBS_AcceptWins, "^" + PL + " accepts and wins [0-9]+ points?\\."); |
425 | 2 | addDough(FIBS_PlayersStartingMatch, "^" + PL + " and " + PL + " start a [0-9]+ point match\\."); |
426 | 2 | addDough(FIBS_StartingNewGame, "^Starting a new game with " + PL + "\\."); |
427 | 2 | addDough(FIBS_StartingNewGameInMatch,"^Starting a new game in the match\\."); |
428 | 2 | addDough(FIBS_YouGiveUp, "^You give up\\. " + PL + " wins [0-9]+ points?\\."); |
429 | 2 | addDough(FIBS_YouWinMatch, "^You win the [0-9]+ point match [0-9]+-[0-9]+ \\."); |
430 | 2 | addDough(FIBS_PlayerWinsMatch, "^" + PL + " wins the [0-9]+ point match [0-9]+-[0-9]+ \\."); |
431 | 2 | addDough(FIBS_ResumingUnlimitedMatch,"^" + PL + " and " + PL + " are resuming their unlimited match\\."); |
432 | 2 | addDough(FIBS_ResumingLimitedMatch, "^" + PL + " and " + PL + " are resuming their [0-9]+-point match\\."); |
433 | 2 | addDough(FIBS_MatchResult, "^" + PL + " wins a [0-9]+ point match against " + PL + " [0-9]+-[0-9]+ \\."); |
434 | 2 | addDough(FIBS_PlayerWantsToResign, "wants to resign\\."); |
435 | |
|
436 | |
|
437 | 2 | addDough(FIBS_YouAcceptDouble, "^You accept the double\\. The cube shows [0-9]+\\."); |
438 | 2 | addDough(FIBS_PlayerAcceptsDouble, "^" + PL + " accepts the double\\. The cube shows [0-9]+\\."); |
439 | 2 | addDough(FIBS_PlayerAcceptsDouble, "^" + PL + " accepts the double\\."); |
440 | 2 | addDough(FIBS_ResumeMatchRequest, "^" + PL + " wants to resume a saved match with you\\."); |
441 | 2 | addDough(FIBS_ResumeMatchAck0, "has joined you\\. Your running match was loaded\\."); |
442 | 2 | addDough(FIBS_YouWinGame, "^You win the game and get [0-9]+ points?\\. Congratulations\\!"); |
443 | 2 | addDough(FIBS_UnlimitedInvite, "^" + PL + " wants to play an unlimted match with you\\."); |
444 | 2 | addDough(FIBS_PlayerWinsGame, "^" + PL + " wins the game and gets [0-9]+ points?. Sorry."); |
445 | 2 | addDough(FIBS_PlayerWinsGame, "^" + PL + " wins the game and gets [0-9]+ points?. "); |
446 | |
|
447 | 2 | addDough(FIBS_PlayersStartingUnlimitedMatch, "start an unlimited match\\."); |
448 | 2 | addDough(FIBS_ReportLimitedMatch, "^" + PL + " +- +" + PL + " .+ point match"); |
449 | 2 | addDough(FIBS_ReportUnlimitedMatch, "^" + PL + " +- +" + PL + " \\(unlimited"); |
450 | 2 | addDough(FIBS_ShowMovesStart, "^" + PL + " is X - " + PL + " is O"); |
451 | 2 | addDough(FIBS_ShowMovesRoll, "^[XO]: \\([1-6]"); |
452 | 2 | addDough(FIBS_ShowMovesWins, "^[XO]: wins"); |
453 | 2 | addDough(FIBS_ShowMovesDoubles, "^[XO]: doubles"); |
454 | 2 | addDough(FIBS_ShowMovesAccepts, "^[XO]: accepts"); |
455 | 2 | addDough(FIBS_ShowMovesRejects, "^[XO]: rejects"); |
456 | 2 | addDough(FIBS_ShowMovesOther, "^[XO]:"); |
457 | 2 | addDough(FIBS_ScoreUpdate, "^score in [0-9]+ point match: " + PL + "-[0-9]+ " + PL + "-[0-9]+"); |
458 | 2 | addDough(FIBS_MatchStart, "^Score is [0-9]+-[0-9]+ in a [0-9]+ point match\\."); |
459 | 2 | addDough(FIBS_Settings, "^Settings of variables:"); |
460 | 2 | addDough(FIBS_Turn, "^turn: " + PL + "\\."); |
461 | 2 | addDough(FIBS_Boardstyle, "^boardstyle:"); |
462 | 2 | addDough(FIBS_Linelength, "^linelength:"); |
463 | 2 | addDough(FIBS_Pagelength, "^pagelength:"); |
464 | 2 | addDough(FIBS_Redoubles, "^redoubles:"); |
465 | 2 | addDough(FIBS_Sortwho, "^sortwho:"); |
466 | 2 | addDough(FIBS_Timezone, "^timezone:"); |
467 | 2 | addDough(FIBS_YouCantMove, "^You can't move\\."); |
468 | 2 | addDough(FIBS_CantMove, "^" + PL + " can't move\\."); |
469 | 2 | addDough(FIBS_ListOfGames, "^List of games:"); |
470 | 2 | addDough(FIBS_PlayerInfoStart, "^Information about " + PL + ":"); |
471 | 2 | addDough(FIBS_EmailAddress, "^ Email address:.*"); |
472 | 2 | addDough(FIBS_NoEmail, "^ No email address\\."); |
473 | 2 | addDough(FIBS_WavesAgain, "^" + PL + " waves goodbye again\\."); |
474 | 2 | addDough(FIBS_Waves, "waves goodbye\\."); |
475 | 2 | addDough(FIBS_Waves, "^You wave goodbye\\."); |
476 | 2 | addDough(FIBS_WavesAgain, "^You wave goodbye again and log out\\."); |
477 | 2 | addDough(FIBS_NoSavedGames, "^no saved games\\."); |
478 | 2 | addDough(FIBS_HasSavedGames, "^" + PL + " has [0-9]+ saved games?\\."); |
479 | 2 | addDough(FIBS_HasNoSavedGames, "^" + PL + " has no saved games\\."); |
480 | 2 | addDough(FIBS_TypeBack, "^You're away\\. Please type 'back'"); |
481 | 2 | addDough(FIBS_SavedMatch, "^ " + PL + " +[0-9]+ +[0-9]+ +- +[0-9]+"); |
482 | 2 | addDough(FIBS_SavedMatchPlaying, "^ \\*" + PL + " +[0-9]+ +[0-9]+ +- +[0-9]+"); |
483 | |
|
484 | 2 | addDough(FIBS_PlayerIsWaitingForYou,"^" + PL + " is waiting for you to log in\\."); |
485 | 2 | addDough(FIBS_IsAway, "^" + PL + " is away: .*"); |
486 | 2 | addDough(FIBS_AllowpipTrue, "^allowpip +YES"); |
487 | 2 | addDough(FIBS_AllowpipFalse, "^allowpip +NO"); |
488 | 2 | addDough(FIBS_AutoboardTrue, "^autoboard +YES"); |
489 | 2 | addDough(FIBS_AutoboardFalse, "^autoboard +NO"); |
490 | 2 | addDough(FIBS_AutodoubleTrue, "^autodouble +YES"); |
491 | 2 | addDough(FIBS_AutodoubleFalse, "^autodouble +NO"); |
492 | 2 | addDough(FIBS_AutomoveTrue, "^automove +YES"); |
493 | 2 | addDough(FIBS_AutomoveFalse, "^automove +NO"); |
494 | 2 | addDough(FIBS_BellTrue, "^bell +YES"); |
495 | 2 | addDough(FIBS_BellFalse, "^bell +NO"); |
496 | 2 | addDough(FIBS_CrawfordTrue, "^crawford +YES"); |
497 | 2 | addDough(FIBS_CrawfordFalse, "^crawford +NO"); |
498 | 2 | addDough(FIBS_DoubleTrue, "^double +YES"); |
499 | 2 | addDough(FIBS_DoubleFalse, "^double +NO"); |
500 | 2 | addDough(FIBS_MoreboardsTrue, "^moreboards +YES"); |
501 | 2 | addDough(FIBS_MoreboardsFalse, "^moreboards +NO"); |
502 | 2 | addDough(FIBS_MovesTrue, "^moves +YES"); |
503 | 2 | addDough(FIBS_MovesFalse, "^moves +NO"); |
504 | 2 | addDough(FIBS_GreedyTrue, "^greedy +YES"); |
505 | 2 | addDough(FIBS_GreedyFalse, "^greedy +NO"); |
506 | 2 | addDough(FIBS_NotifyTrue, "^notify +YES"); |
507 | 2 | addDough(FIBS_NotifyFalse, "^notify +NO"); |
508 | 2 | addDough(FIBS_RatingsTrue, "^ratings +YES"); |
509 | 2 | addDough(FIBS_RatingsFalse, "^ratings +NO"); |
510 | 2 | addDough(FIBS_ReadyTrue, "^ready +YES"); |
511 | 2 | addDough(FIBS_ReadyFalse, "^ready +NO"); |
512 | 2 | addDough(FIBS_ReportTrue, "^report +YES"); |
513 | 2 | addDough(FIBS_ReportFalse, "^report +NO"); |
514 | 2 | addDough(FIBS_SilentTrue, "^silent +YES"); |
515 | 2 | addDough(FIBS_SilentFalse, "^silent +NO"); |
516 | 2 | addDough(FIBS_TelnetTrue, "^telnet +YES"); |
517 | 2 | addDough(FIBS_TelnetFalse, "^telnet +NO"); |
518 | 2 | addDough(FIBS_WrapTrue, "^wrap +YES"); |
519 | 2 | addDough(FIBS_WrapFalse, "^wrap +NO"); |
520 | 2 | addDough(FIBS_Junk, "^Closed old connection with user"); |
521 | 2 | addDough(FIBS_Done, "^Done\\."); |
522 | 2 | addDough(FIBS_YourTurnToMove, "^It's your turn to move\\."); |
523 | 2 | addDough(FIBS_SavedMatchesHeader, "^ opponent matchlength score \\(your points first\\)"); |
524 | 2 | addDough(FIBS_MessagesForYou, "^There are messages for you:"); |
525 | 2 | addDough(FIBS_RedoublesSetTo, "^Value of 'redoubles' set to [0-9]+\\."); |
526 | 2 | addDough(FIBS_BoardstyleSetTo, "^Value of 'boardstyle' set to [0-9]+\\."); |
527 | 2 | addDough(FIBS_DoublingCubeNow, "^The number on the doubling cube is now [0-9]+"); |
528 | 2 | addDough(FIBS_FailedLogin, "^> [0-9]+"); |
529 | 2 | addDough(FIBS_Average, "^Time (UTC) average min max"); |
530 | 2 | addDough(FIBS_DiceTest, "^[nST]: "); |
531 | 2 | addDough(FIBS_LastLogout, "^ Last logout:.*"); |
532 | 2 | addDough(FIBS_RatingCalcStart, "^rating calculation:"); |
533 | 2 | addDough(FIBS_RatingCalcInfo, "^Probability that underdog wins:"); |
534 | 2 | addDough(FIBS_RatingCalcInfo, "is 1-Pu if underdog wins"); |
535 | 2 | addDough(FIBS_RatingCalcInfo, "^Experience: "); |
536 | 2 | addDough(FIBS_RatingCalcInfo, "^K=max\\(1"); |
537 | 2 | addDough(FIBS_RatingCalcInfo, "^rating difference"); |
538 | 2 | addDough(FIBS_RatingCalcInfo, "^change for"); |
539 | 2 | addDough(FIBS_RatingCalcInfo, "^match length "); |
540 | 2 | addDough(FIBS_WatchingHeader, "^Watching players:"); |
541 | 2 | addDough(FIBS_SettingsHeader, "^The current settings are:"); |
542 | 2 | addDough(FIBS_AwayListHeader, "^The following users are away:"); |
543 | 2 | addDough(FIBS_RatingExperience, "^ Rating: +[0-9]+\\..*Experience: [0-9]+"); |
544 | 2 | addDough(FIBS_ReadyWatchingPlaying, "^ " + PL + ".* playing\\."); |
545 | 2 | addDough(FIBS_PlayerLeftGame, PL + " has left the game with " + PL + "\\."); |
546 | |
|
547 | 2 | addDough(FIBS_NotLoggedIn, "^ Not logged in right now\\."); |
548 | 2 | addDough(FIBS_IsPlayingWith, "is playing with " + PL + "\\."); |
549 | 2 | addDough(FIBS_SavedScoreHeader, "^opponent +matchlength"); |
550 | 2 | addDough(FIBS_StillLoggedIn, "^ Still logged in\\. .* idle\\."); |
551 | 2 | addDough(FIBS_NoOneIsAway, "^None of the users is away\\."); |
552 | 2 | addDough(FIBS_PlayerListHeader, "^No S username rating exp login idle from"); |
553 | 2 | addDough(FIBS_RatingsHeader, "^ rank name rating Experience"); |
554 | 2 | addDough(FIBS_ClearScreen, "^.\\[;H.\\[2J"); |
555 | 2 | addDough(FIBS_Timeout, "^Connection timed out\\."); |
556 | 2 | addDough(FIBS_Goodbye, " Goodbye\\."); |
557 | 2 | addDough(FIBS_LastLogin, "^ Last login: .*"); |
558 | 2 | addDough(FIBS_NoInfo, "^No information found on user"); |
559 | 2 | addDough(FIBS_PointsFor, "^points for " + PL + ": [0-9]+"); |
560 | 2 | addDough(FIBS_YouBannedWatch, "^" + PL + " bans you from watching\\."); |
561 | 2 | addDough(FIBS_PlayerBannedWatch, "^" + PL + " bans " + PL + " from watching\\."); |
562 | 2 | addDough(FIBS_YourEmailChanged, "^Your email address is .*"); |
563 | |
|
564 | 2 | this.alphaBatch = this.currentBatchBuild; |
565 | |
|
566 | |
|
567 | 2 | currentBatchBuild = new LinkedList<CookieDough>(); |
568 | 2 | addDough(CLIP_WHO_INFO, "^5 [^ ]+ - - [01].*"); |
569 | 2 | addDough(CLIP_WHO_INFO, "^5 [^ ]+ [^ ]+ - [01].*"); |
570 | 2 | addDough(CLIP_WHO_INFO, "^5 [^ ]+ - [^ ]+ [01].*"); |
571 | |
|
572 | 2 | addDough(FIBS_Average, "^[0-9][0-9]:[0-9][0-9]-"); |
573 | 2 | addDough(FIBS_DiceTest, "^[1-6]-1 [0-9]"); |
574 | 2 | addDough(FIBS_DiceTest, "^[1-6]: [0-9]"); |
575 | 2 | addDough(FIBS_Stat, "^[0-9]+ bytes"); |
576 | 2 | addDough(FIBS_Stat, "^[0-9]+ accounts"); |
577 | 2 | addDough(FIBS_Stat, "^[0-9]+ ratings saved. reset log"); |
578 | 2 | addDough(FIBS_Stat, "^[0-9]+ registered users."); |
579 | 2 | addDough(FIBS_Stat, "^[0-9]+\\([0-9]+\\) saved games check by cron"); |
580 | |
|
581 | 2 | addDough(CLIP_WHO_END, "^6.*$"); |
582 | 2 | addDough(CLIP_SHOUTS, "^13 " + PL + " .*"); |
583 | 2 | addDough(CLIP_SAYS, "^12 " + PL + " .*"); |
584 | 2 | addDough(CLIP_WHISPERS, "^14 " + PL + " .*"); |
585 | 2 | addDough(CLIP_KIBITZES, "^15 " + PL + " .*"); |
586 | 2 | addDough(CLIP_YOU_SAY, "^16 " + PL + " .*"); |
587 | 2 | addDough(CLIP_YOU_SHOUT, "^17 .*"); |
588 | 2 | addDough(CLIP_YOU_WHISPER, "^18 .*"); |
589 | 2 | addDough(CLIP_YOU_KIBITZ, "^19 .*"); |
590 | 2 | addDough(CLIP_LOGIN, "^7 " + PL + " " + PL + " logs in\\."); |
591 | 2 | addDough(CLIP_LOGIN, "^7 " + PL + " " + PL + " logs in again\\."); |
592 | 2 | addDough(CLIP_LOGIN, "^7 " + PL + " " + PL + " just registered and logs in\\."); |
593 | 2 | addDough(CLIP_LOGOUT, "^8 " + PL + " .*"); |
594 | 2 | addDough(CLIP_LOGOUT, "^8 " + PL + " .*"); |
595 | 2 | addDough(CLIP_MESSAGE, "^9 " + PL + " [0-9]+ .*"); |
596 | 2 | addDough(CLIP_MESSAGE_DELIVERED, "^10 " + PL + "$"); |
597 | 2 | addDough(CLIP_MESSAGE_SAVED, "^11 " + PL + "$"); |
598 | 2 | this.numericBatch = this.currentBatchBuild; |
599 | |
|
600 | |
|
601 | 2 | currentBatchBuild = new LinkedList<CookieDough>(); |
602 | 2 | addDough(FIBS_Username, "^\\*\\* User"); |
603 | 2 | addDough(FIBS_Junk, "^\\*\\* You tell "); |
604 | 2 | addDough(FIBS_YouGag, "^\\*\\* You gag"); |
605 | 2 | addDough(FIBS_YouUngag, "^\\*\\* You ungag"); |
606 | 2 | addDough(FIBS_YouBlind, "^\\*\\* You blind"); |
607 | 2 | addDough(FIBS_YouUnblind, "^\\*\\* You unblind"); |
608 | 2 | addDough(FIBS_UseToggleReady, "^\\*\\* Use 'toggle ready' first"); |
609 | 2 | addDough(FIBS_NewMatchAck9, "^\\*\\* You are now playing an unlimited match with "); |
610 | 2 | addDough(FIBS_NewMatchAck10, "^\\*\\* You are now playing a [0-9]+ point match with " + PL); |
611 | 2 | addDough(FIBS_NewMatchAck2, "^\\*\\* Player " + PL + " has joined you for a [0-9]+ point match\\."); |
612 | 2 | addDough(FIBS_YouTerminated, "^\\*\\* You terminated the game"); |
613 | 2 | addDough(FIBS_OpponentLeftGame, "^\\*\\* Player " + PL + " has left the game. The game was saved\\."); |
614 | 2 | addDough(FIBS_YouInvited, "^\\*\\* You invited .* match\\."); |
615 | 2 | addDough(FIBS_YourLastLogin, "^\\*\\* Last login:"); |
616 | 2 | addDough(FIBS_NoOne, "^\\*\\* There is no one called " + PL + "\\."); |
617 | 2 | addDough(FIBS_AllowpipFalse, "^\\*\\* You don't allow the use of the server's 'pip' command\\."); |
618 | 2 | addDough(FIBS_AllowpipTrue, "^\\*\\* You allow the use the server's 'pip' command\\."); |
619 | 2 | addDough(FIBS_AutoboardFalse, "^\\*\\* The board won't be refreshed"); |
620 | 2 | addDough(FIBS_AutoboardTrue, "^\\*\\* The board will be refreshed"); |
621 | 2 | addDough(FIBS_AutodoubleTrue, "^\\*\\* You agree that doublets"); |
622 | 2 | addDough(FIBS_AutodoubleFalse, "^\\*\\* You don't agree that doublets"); |
623 | 2 | addDough(FIBS_AutomoveFalse, "^\\*\\* Forced moves won't"); |
624 | 2 | addDough(FIBS_AutomoveTrue, "^\\*\\* Forced moves will"); |
625 | 2 | addDough(FIBS_BellFalse, "^\\*\\* Your terminal won't ring"); |
626 | 2 | addDough(FIBS_BellTrue, "^\\*\\* Your terminal will ring"); |
627 | 2 | addDough(FIBS_CrawfordFalse, "^\\*\\* You would like to play without using the Crawford rule\\."); |
628 | 2 | addDough(FIBS_CrawfordTrue, "^\\*\\* You insist on playing with the Crawford rule\\."); |
629 | 2 | addDough(FIBS_DoubleFalse, "^\\*\\* You won't be asked if you want to double\\."); |
630 | 2 | addDough(FIBS_DoubleTrue, "^\\*\\* You will be asked if you want to double\\."); |
631 | 2 | addDough(FIBS_GreedyTrue, "^\\*\\* Will use automatic greedy bearoffs\\."); |
632 | 2 | addDough(FIBS_GreedyFalse, "^\\*\\* Won't use automatic greedy bearoffs\\."); |
633 | 2 | addDough(FIBS_MoreboardsTrue, "^\\*\\* Will send rawboards after rolling\\."); |
634 | 2 | addDough(FIBS_MoreboardsFalse, "^\\*\\* Won't send rawboards after rolling\\."); |
635 | 2 | addDough(FIBS_MovesTrue, "^\\*\\* You want a list of moves after this game\\."); |
636 | 2 | addDough(FIBS_MovesFalse, "^\\*\\* You won't see a list of moves after this game\\."); |
637 | 2 | addDough(FIBS_NotifyFalse, "^\\*\\* You won't be notified"); |
638 | 2 | addDough(FIBS_NotifyTrue, "^\\*\\* You'll be notified"); |
639 | 2 | addDough(FIBS_RatingsTrue, "^\\*\\* You'll see how the rating changes are calculated\\."); |
640 | 2 | addDough(FIBS_RatingsFalse, "^\\*\\* You won't see how the rating changes are calculated\\."); |
641 | 2 | addDough(FIBS_ReadyTrue, "^\\*\\* You're now ready to invite or join someone\\."); |
642 | 2 | addDough(FIBS_ReadyFalse, "^\\*\\* You're now refusing to play with someone\\."); |
643 | 2 | addDough(FIBS_ReportFalse, "^\\*\\* You won't be informed"); |
644 | 2 | addDough(FIBS_ReportTrue, "^\\*\\* You will be informed"); |
645 | 2 | addDough(FIBS_SilentTrue, "^\\*\\* You won't hear what other players shout\\."); |
646 | 2 | addDough(FIBS_SilentFalse, "^\\*\\* You will hear what other players shout\\."); |
647 | 2 | addDough(FIBS_TelnetFalse, "^\\*\\* You use a client program"); |
648 | 2 | addDough(FIBS_TelnetTrue, "^\\*\\* You use telnet"); |
649 | 2 | addDough(FIBS_WrapFalse, "^\\*\\* The server will wrap"); |
650 | 2 | addDough(FIBS_WrapTrue, "^\\*\\* Your terminal knows how to wrap"); |
651 | 2 | addDough(FIBS_PlayerRefusingGames, "^\\*\\* " + PL + " is refusing games\\."); |
652 | 2 | addDough(FIBS_NotWatching, "^\\*\\* You're not watching\\."); |
653 | 2 | addDough(FIBS_NotWatchingPlaying, "^\\*\\* You're not watching or playing\\."); |
654 | 2 | addDough(FIBS_NotPlaying, "^\\*\\* You're not playing\\."); |
655 | 2 | addDough(FIBS_EchoJunk, "^\\*\\* You're not playing, so you can't give up\\."); |
656 | 2 | addDough(FIBS_EchoJunk, "^\\*\\* You can't say nothing\\."); |
657 | |
|
658 | 2 | addDough(FIBS_NoUser, "^\\*\\* There is no one called " + PL); |
659 | 2 | addDough(FIBS_AlreadyPlaying, "is already playing with .*\\."); |
660 | 2 | addDough(FIBS_BadMove, "^\\*\\* You can't remove this piece"); |
661 | 2 | addDough(FIBS_YouAlreadyPlaying, "^\\*\\* You are already playing\\."); |
662 | 2 | addDough(FIBS_YouAlreadyRolled, "^\\*\\* You did already roll the dice\\."); |
663 | 2 | addDough(FIBS_DidntInvite, "^\\*\\* " + PL + " didn't invite you\\."); |
664 | 2 | addDough(FIBS_BadMove, "^\\*\\* You can't remove this piece"); |
665 | 2 | addDough(FIBS_CantMoveFirstMove, "^\\*\\* You can't move .*move\\."); |
666 | 2 | addDough(FIBS_CantShout, "^\\*\\* Please type 'toggle silent' again before you shout\\."); |
667 | 2 | addDough(FIBS_MustMove, "^\\*\\* You must give [1-4] moves\\."); |
668 | 2 | addDough(FIBS_MustComeIn, "^\\*\\* You have to remove pieces from the bar in your first move\\."); |
669 | 2 | addDough(FIBS_UsersHeardYou, "^\\*\\* [0-9]+ users? heard you\\."); |
670 | 2 | addDough(FIBS_PleaseWaitForJoin, "^\\*\\* Please wait for " + PL + " to join too\\."); |
671 | 2 | addDough(FIBS_SavedMatchReady, "^\\*\\*" + PL + " +[0-9]+ +[0-9]+ +- +[0-9]+"); |
672 | 2 | addDough(FIBS_NotYourTurnToRoll, "^\\*\\* It's not your turn to roll the dice\\."); |
673 | 2 | addDough(FIBS_NotYourTurnToMove, "^\\*\\* It's not your turn to move\\."); |
674 | 2 | addDough(FIBS_YouStopWatching, "^\\*\\* You stop watching " + PL + "\\."); |
675 | 2 | addDough(FIBS_UnknownCommand, "^\\*\\* Unknown command: .*"); |
676 | 2 | addDough(FIBS_CantWatch, "^\\*\\* You can't watch another game while you're playing\\."); |
677 | 2 | addDough(FIBS_CantInviteSelf, "^\\*\\* You can't invite yourself\\."); |
678 | 2 | addDough(FIBS_DontKnowUser, "^\\*\\* Don't know user"); |
679 | 2 | addDough(FIBS_MessageUsage, "^\\*\\* usage: message <user> <text>"); |
680 | 2 | addDough(FIBS_PlayerNotPlaying, "^\\*\\* " + PL + " is not playing\\."); |
681 | 2 | addDough(FIBS_CantTalk, "^\\*\\* You can't talk if you won't listen\\."); |
682 | 2 | addDough(FIBS_WontListen, "^\\*\\* " + PL + " won't listen to you\\."); |
683 | 2 | addDough(FIBS_Why, "Why would you want to do that"); |
684 | 2 | addDough(FIBS_Ratings, "^\\* *[0-9]+ +" + PL + " +[0-9]+\\.[0-9]+ +[0-9]+"); |
685 | 2 | addDough(FIBS_NoSavedMatch, "^\\*\\* There's no saved match with .* length\\."); |
686 | 2 | addDough(FIBS_WARNINGSavedMatch, "^\\*\\* WARNING: Don't accept if you want to continue"); |
687 | 2 | addDough(FIBS_CantGagYourself, "^\\*\\* You talk too much, don't you\\?"); |
688 | 2 | addDough(FIBS_CantBlindYourself, "^\\*\\* You can't read this message now, can you\\?"); |
689 | 2 | addDough(FIBS_RollBeforeMove, "^\\*\\* You have to roll the dice before moving\\."); |
690 | 2 | addDough(FIBS_ATTENTION, "^\007\\*\\*\\* ATTENTION \\!.*"); |
691 | 2 | addDough(FIBS_ShuttingDown, "^\\*\\* System administrator causes shutdown\\. FIBS is terminating\\."); |
692 | 2 | addDough(FIBS_Rebooting, "^\\*\\* It will be back when the computer is rebooted."); |
693 | 2 | addDough(FIBS_GamesWillBeSaved, "^\\*\\* All running games will be saved\\."); |
694 | 2 | addDough(FIBS_DoesntWantYouToWatch, "^\\*\\* " + PL + " doesn't want you to watch\\."); |
695 | 2 | addDough(FIBS_WaitForLastInvitation,"^\\*\\* Wait until " + PL + " accepted or rejected your resign\\."); |
696 | 2 | addDough(FIBS_WaitForAcceptResign, "^\\*\\* Please wait for your last invitation to be accepted\\."); |
697 | 2 | addDough(FIBS_WantedToResign, "^\\*\\* " + PL + " wanted to resign\\. Type 'accept' or 'reject'\\."); |
698 | 2 | addDough(FIBS_DidntDoubleOrResign, "^\\*\\* " + PL + " didn't double or resign\\."); |
699 | 2 | addDough(FIBS_NobodyHeardYou, "^\\*\\* But nobody heard you\\."); |
700 | 2 | addDough(FIBS_CantWatchSelf, "^\\*\\* Use a mirror to do that\\."); |
701 | |
|
702 | |
|
703 | 2 | this.starsBatch = this.currentBatchBuild; |
704 | |
|
705 | 2 | currentBatchBuild = new LinkedList<CookieDough>(); |
706 | 2 | addDough(FIBS_LoginPrompt, "^login:.*"); |
707 | 2 | addDough(CLIP_WELCOME, "^1 " + PL + " [0-9]+ .*"); |
708 | 2 | addDough(CLIP_OWN_INFO, "^2 " + PL + " [01] [01] .*"); |
709 | 2 | addDough(CLIP_MOTD_BEGIN, "^3$"); |
710 | 2 | addDough(FIBS_FailedLogin, "^> [0-9]+"); |
711 | 2 | addDough(FIBS_WelcomeToFibs, "^Welcome to \\w+\\.\\s*You just logged in as guest\\."); |
712 | 2 | this.loginBatch = this.currentBatchBuild; |
713 | |
|
714 | 2 | currentBatchBuild = new LinkedList<CookieDough>(); |
715 | 2 | addDough(FIBS_OneUserPerPerson, "^\\s*ONE USERNAME PER PERSON ONLY\\!\\!\\!"); |
716 | 2 | addDough(FIBS_GivePassword, "^Please give your password: "); |
717 | 2 | addDough(FIBS_RetypePassword, "^Please retype your password: "); |
718 | 2 | addDough(FIBS_YouAreRegistered, "^You are registered\\."); |
719 | 2 | addDough(FIBS_UseAnotherName, "^\\*\\* Please use another name\\."); |
720 | 2 | this.registerBatch = this.currentBatchBuild; |
721 | |
|
722 | |
|
723 | 2 | currentBatchBuild = new LinkedList<CookieDough>(); |
724 | 2 | addDough(CLIP_MOTD_END, "^4$"); |
725 | 2 | this.motdBatch = this.currentBatchBuild; |
726 | |
|
727 | 2 | messageState = FIBS_LOGIN; |
728 | |
|
729 | 2 | } |
730 | |
} |