OBJECTIVE
---------
To create a generic card playing java applet that communicates with a
card playing server. The first card game to be supported is Hearts.
FLOW
----
Client Server
-------------------------------------------------------------------
1) get applet <- send applet
2) get images <- send images
3) get user info
4) open socket to server -> allows connection
5) (1)applet send login -> wait for login
6) wait for command <- (A) show logins (4 times broadcast)
7) wait for command <- (B) display - 13 cards(4 per client)
8) wait for command (pass) <- (C) pass - how many and direction
(4 times broadcast)
9) (2) send card (pass) -> receive card
10) receive card <- (B) display - 3 cards
(different per client)
11) user confirmation?
12) wait for command <- (D) pick card - constraint 2C
(to only 1 client)
13) (2) send card (2C) -> receive card
(only 1 client)
14) wait for command <- (B) display - 2C (4 times broadcast)
15) wait for command <- (D) pick card - with constraints
(to only 1 client)
16) (2) send card -> receive card, if ok goto 15
else if bad card goto 17
17) wait for command <- (E) error, go to 16
18) wait for command <- (F) winner is (4 times broadcast)
19) wait for command <- (G) score is (4 times broadcast)
20) goto login goto login
MESSAGES
--------
Cards are two characters [rank][suit].
Ranks are A,2,3,4,5,6,7,8,9,T,J,Q,K
Suits are H,C,D,S
Names are alpha-numeric
Client Numbers are 1234
Locations are C(CENTER), S(SHOW), H(HAND)
Number of cards is numeric
Direction is L, R, A, N (none)
Constraints are ALL or list of cards by suit
(needs discussion)
Scores are numeric
Proposed Error codes: 000 - invalid message,
001 - bad format,
002 - unknown message,
003 - invalid card
Sounds are canned file names sound1.wav, sound2.wav, ...
Constraints are either 'M' for must send or 'N' not allowed
to send
Face is U, D, or C (clear)
The Header part should be HTTP/1.0 compliant with the url
/gamehandler. A sample header would be like
POST /gamehandler HTTP/1.0
Date: 11/3/97
Connection: Keep-Alive
Content-Length: 7
The content of the message is define as follows, ( without the double quotes " )
CLIENT
---------
1 = login
" 1[name]"
2 = send card(s)
" 2[rank][suit]...[rank][suit]"
3 = error
" 3[error code][text]"
4 = restart game
" 4[name]"
5 = display any text (optional) or play sound (optional)
to be broadcast by server
e.g. "Waiting for Jim..."
" 5[text][sound]"
6 = start robot players
" 6[client number]"
SERVER
------
A = login - other players join clockwise 1,2,3,4 and name
" A[client number]1[name, IF EXISTS]
2[name, IF EXISTS]3[name, IF
EXISTS]4[name, IF EXISTS]"
B = display - if face is 'C' then number of cards must be 0
which automatically mean no [rank][suit] pairs
if face is 'D' then [rank][suit] is optional
the number of cards must match the number of
[rank][suit] pairs
[location] = C(Center), S(Show), H(Hand)
[face] = C(Clear), D(Down), U(Up)
" B[client number][location][face]
[number of cards][rank][suit][rank][suit]
... "
C = pass - how many and direction
" C[number of cards][direction]"
D = pick card - number of cards and optional constraint and cards
" D[number of cards][constraint][rank][suit]
... "
E = error
" E[error code][text]"
F = winner of game
" F[client number]"
G = score
" G[score][score][score][score]"
H = who left game
" H[client number][text]"
I = display any text (optional) or play sound (optional)
e.g. "Waiting for Jim..."
" I[text][sound]"
J = winner of hand
" J[client number]"