-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
64 lines (57 loc) · 1.49 KB
/
index.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
var GameMode = {CREATIVE: 'GameModeCreative', SAVETHEWORLD: 'GameModeStw', BATTLEROYALE: 'GameModeBr', LOBBY: 'GameModeLobby'};
var FWorld = {
pawnList: [],
damage: true,
state: 'disengaged', // 'engaged' or 'disengaged' or 'inProgress'
game_mode: GameMode.LOBBY,
inDebugMode: false
}
function sendDebugMessage(message) {
if(FWorld.inDebugMode) {
console.log('[DBG] RetroFlex | ' + message);
}
}
class Pawn {
username = '';
uid = '';
constructor(username, uid) {
this.username = username;
this.uid = uid;
}
move(x, y, z) {
sendDebugMessage('Pawn#MOVE not implemented.');
}
costume(skin) {
sendDebugMessage('Pawn#COSTUME not implemented.');
}
kill() {
sendDebugMessage('Pawn#KILL not implemented.');
}
}
export default {
PAWN,
FWorld,
GameMode,
sendDebugMessage,
getProperty: (prop = "") => {
if (prop) {
// return the specified property
return FWorld[prop];
} else {
// return all properties
return FWorld;
}
},
setProperty: (prop, value) => {
// set the specified property
FWorld[prop] = value;
},
getPawnList: () => {
// return the list of all pawns
return FWorld.pawnList;
},
getPawnByUsername: (username) => {
// return the pawn with the specified username
return FWorld.pawnList.find((pawn) => pawn.username === username);
}
};