summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2018-03-28 23:18:51 +0200
committerTom Smeding <tom.smeding@gmail.com>2018-03-28 23:18:51 +0200
commitce9a2a08d3a6e42c6a2a693c4e4d9214f24e1db5 (patch)
tree0ec0d859852f345b29b858d18e6aed755ad87703
parent4ab4d924d9919ec4f5bfac81023e365b72fad8b7 (diff)
Some menu additions
-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);
});