From ce9a2a08d3a6e42c6a2a693c4e4d9214f24e1db5 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Wed, 28 Mar 2018 23:18:51 +0200 Subject: Some menu additions --- client.js | 23 +++++++++++++++++++++-- 1 file 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); }); -- cgit v1.2.3-70-g09d2