forked from marrerom/Web-Teaching
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessages.js
76 lines (66 loc) · 2.13 KB
/
messages.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
74
75
76
(function(exports){
/*
* Client to server: game is complete, the winner is ...
*/
exports.T_GAME_WON_BY = "GAME-WON-BY";
exports.O_GAME_WON_BY = {
type: exports.T_GAME_WON_BY,
data: null
};
/*
* Server to client: abort game (e.g. if second player exited the game)
*/
exports.O_GAME_ABORTED = {
type: "GAME-ABORTED"
};
exports.S_GAME_ABORTED = JSON.stringify(exports.O_GAME_ABORTED);
/*
* Server to client: choose target word
*/
exports.O_CHOOSE = { type: "CHOOSE-WORD" };
exports.S_CHOOSE = JSON.stringify(exports.O_CHOOSE);
/*
* Server to client: set as player A
*/
exports.T_PLAYER_TYPE = "PLAYER-TYPE";
exports.O_PLAYER_A = {
type: exports.T_PLAYER_TYPE,
data: "A"
};
exports.S_PLAYER_A = JSON.stringify(exports.O_PLAYER_A);
/*
* Server to client: set as player B
*/
exports.O_PLAYER_B = {
type: exports.T_PLAYER_TYPE,
data: "B"
};
exports.S_PLAYER_B = JSON.stringify(exports.O_PLAYER_B);
/*
* Player A to server OR server to Player B: this is the target word
*/
exports.T_TARGET_WORD = "SET-TARGET-WORD";
exports.O_TARGET_WORD = {
type: exports.T_TARGET_WORD,
data: null
};
//exports.S_TARGET_WORD does not exist, as we always need to fill the data property
/*
* Player B to server OR server to Player A: guessed character
*/
exports.T_MAKE_A_GUESS = "MAKE-A-GUESS";
exports.O_MAKE_A_GUESS = {
type: exports.T_MAKE_A_GUESS,
data: null
};
//exports.S_MAKE_A_GUESS does not exist, as data needs to be set
/*
* Server to Player A & B: game over with result won/loss
*/
exports.T_GAME_OVER = "GAME-OVER";
exports.O_GAME_OVER = {
type: exports.T_GAME_OVER,
data: null
};
}(typeof exports === "undefined" ? this.Messages = {} : exports));
//if exports is undefined, we are on the client; else the server