summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xclient.js23
1 files changed, 21 insertions, 2 deletions
diff --git a/client.js b/client.js
index d4282ea..46fc0eb 100755
--- a/client.js
+++ b/client.js
@@ -73,6 +73,7 @@ async function mainMenu() {
"Create a room",
"Join an existing room",
"Search for rooms",
+ "Quit",
];
switch (await showMenu(title, options)) {
@@ -114,6 +115,9 @@ async function mainMenu() {
}
break;
}
+
+ case 3:
+ return 1;
}
return 0;
}
@@ -124,15 +128,17 @@ async function roomMenu() {
"Room " + currentRoom.name +
" (" + currentRoom.players.map(p => p.nick).join(", ") + ")";
const options = [
- "Start a game",
+ "Start a game (not fully implemented)",
"Send room chat message",
"Invite a player into this room",
"Kick a player from the room",
"Leave the room",
+ "Quit",
];
switch (await showMenu(title, options)) {
case 0: {
+ const reply = await conn.send(new protocol.Message("start"));
break;
}
@@ -144,11 +150,18 @@ async function roomMenu() {
}
case 2: {
+ const name = await keyboard.prompt("Player name to invite: ");
+ const reply = await conn.send(new protocol.Message("invite-player", name));
+ if (reply.err) {
+ console.log(err);
+ } else {
+ console.log("Player successfully invited.");
+ }
break;
}
case 3: {
- const name = await keyboard.prompt("Player name: ");
+ const name = await keyboard.prompt("Player name to kick: ");
const reply = await conn.send(new protocol.Message("kick-player", name));
if (reply.err) {
console.log(err);
@@ -163,6 +176,9 @@ async function roomMenu() {
if (reply.err) fatalError(reply.err);
return 2;
}
+
+ case 5:
+ return 1;
}
}
@@ -210,4 +226,7 @@ conn.conn.on("connect", async () => {
} catch(e) {
console.log(e);
}
+
+ conn.end();
+ process.exit(0);
});