From c2b3628fe854407ea6782e8c736df16b9c6719dc Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sun, 17 May 2020 15:10:08 -0700 Subject: [PATCH] empires: Add a top-level static page for the Empires game This has a basic description of the game along with a button to host a new instance of the game. There is a tiny bit of JavaScript added to support the new button, (simply calling the server API to generate a new game and then redirecting to the new game ID or else generating an error message). --- empires/index.html | 98 ++++++++++++++++++++++++++++++++++++++++++++++ lmno.js | 23 +++++++++++ 2 files changed, 121 insertions(+) create mode 100644 empires/index.html diff --git a/empires/index.html b/empires/index.html new file mode 100644 index 0000000..b827e47 --- /dev/null +++ b/empires/index.html @@ -0,0 +1,98 @@ + + + + + + + The Game of Empires + + + + + + + + +
+ +

The Game of Empires

+ +

+ Can you remember all the characters in the game? Can you guess + who is who? +

+ +
+
+ +
+ +
+ +

What is Empires?

+ +

+ Empires is a simple yet surprisingly entertaining party game + that will test your memory. Each player in the game secretly + chooses a "character" that they will play as. Once all players + have chosen their characters, each character name will be + revealed to all players who will have to try to memorize every + character. Gameplay consists of guessing the character name + that other plays chose. Successful guesses bring the guessed + player (and their entire "empire") into your own "empire". The + game will end with everyone in a single empire under the one + player whose character was never correctly guessed. +

+ +

What do we need to play?

+ +

+ This website will assist you in hosting a game of empires by + doing the following: + +

+

+ +

+ Meanwhile, you are responsible for providing the following: + +

+

+
+ + diff --git a/lmno.js b/lmno.js index f1f9cd7..e4785a8 100644 --- a/lmno.js +++ b/lmno.js @@ -30,3 +30,26 @@ function lmno_join(form) { form.reset(); } + +function new_loadend() { + if (this.status == 200) { + /* Response contains the game ID which we simply point the browser to. */ + const game_id = JSON.parse(this.response); + window.location.href = ('/' + game_id); + return; + } + + add_message("danger", `An error occured creating a new game (${this.status}).`); +} + +function lmno_new(engine) { + console.log("In lmno_new"); + const request = new XMLHttpRequest(); + request.addEventListener("loadend", new_loadend); + + request.open("POST", "/new/" + engine); + request.setRequestHeader("Content-Type", "application/json; charset=UTF-8"); + request.send(); + + return false; +} -- 2.43.0