]> git.cworth.org Git - lmno.games/commitdiff
empires: Add a top-level static page for the Empires game
authorCarl Worth <cworth@cworth.org>
Sun, 17 May 2020 22:10:08 +0000 (15:10 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 19 May 2020 13:43:40 +0000 (06:43 -0700)
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 [new file with mode: 0644]
lmno.js

diff --git a/empires/index.html b/empires/index.html
new file mode 100644 (file)
index 0000000..b827e47
--- /dev/null
@@ -0,0 +1,98 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8"/>
+    <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
+
+    <title>The Game of Empires</title>
+
+    <link rel="stylesheet" href="/reset.css" type="text/css" />
+    <link rel="stylesheet" href="/style.css" type="text/css" />
+  </head>
+  <body>
+
+    <script src="/lmno.js"></script>
+
+    <div id="page">
+
+      <h1>The Game of Empires</h1>
+
+      <p>
+        Can you remember all the characters in the game? Can you guess
+        who is who?
+      </p>
+
+      <div id="message-area">
+      </div>
+
+      <form onsubmit="lmno_new('empires'); return false;">
+        <button type="submit">
+          Host a new game
+        </button>
+      </form>
+
+      <h2>What is Empires?</h2>
+
+      <p>
+        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.
+      </p>
+
+      <h2>What do we need to play?</h2>
+
+      <p>
+        This website will assist you in hosting a game of empires by
+        doing the following:
+
+        <ul>
+          <li>
+            Allowing players to secretly select a character name
+          </li>
+          <li>
+            Revealing the character names to all players
+          </li>
+          <li>
+            Keeping track of which players have still not had their
+            characters identified, (the empires remaining to be
+            captured)
+          </li>
+        </ul>
+      </p>
+
+      <p>
+        Meanwhile, you are responsible for providing the following:
+
+        <ul>
+          <li>
+            An internet-capable device for each player. This is only
+            needed for the player to select their player, so a number
+            of people in the same room can pass a device around fot
+            this part.
+          </li>
+          <li>
+            At least one view of the game that every player can
+            see. This can be on individual devices, or by the game
+            host sharing their screen in some fashion, (such as
+            through a video call).
+          </li>
+          <li>
+            Some means for all players to communicate. This could be a
+            video call or some chat room or something else. Of course,
+            it's also possible to play with people in the same room
+            together. If you have the luxury to do that, it's also
+            convenient to have captured players move to sit with their
+            new empires to make it clear which empires remain.
+          </li>
+        </ul>
+      </p>
+    </div>
+  </body>
+</html>
diff --git a/lmno.js b/lmno.js
index f1f9cd7f874a1f193382283a5a6a350deefc0b74..e4785a86d4fe8ae282ae2102a3c3bebaf2b8f414 100644 (file)
--- 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;
+}