]> git.cworth.org Git - zombocom-ai/commitdiff
Add an error page if the user has no name set
authorCarl Worth <cworth@cworth.org>
Thu, 22 Dec 2022 03:53:29 +0000 (19:53 -0800)
committerCarl Worth <cworth@cworth.org>
Thu, 22 Dec 2022 03:54:34 +0000 (19:54 -0800)
Since we're keying off of the name to make sure everyone gets
different words, we need to force them to set a name before playing
the game.

index.js
tardis-error.html [new file with mode: 0644]

index 13ed7f6890a4bbd1a6d0fd5617b26c12aceaf705..cb46c203bb3f63e28f1c292bbee6726321c62398 100644 (file)
--- a/index.js
+++ b/index.js
@@ -133,7 +133,11 @@ app.get('/index.html', (req, res) => {
 });
 
 function tardis_app(req, res) {
-    res.sendFile(__dirname + '/tardis.html');
+    if (! req.session.name) {
+       res.sendFile(__dirname + '/tardis-error.html');
+    } else {
+       res.sendFile(__dirname + '/tardis.html');
+    }
 }
 
 app.get('/tardis', tardis_app);
diff --git a/tardis-error.html b/tardis-error.html
new file mode 100644 (file)
index 0000000..b374e81
--- /dev/null
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+  <title>ZOMBO</title>
+  <link href="/zombo.css" rel="stylesheet" type="text/css">
+  <meta name="viewport" content="width=device-width,initial-scale=1">
+  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+  <meta name="HandheldFriendly" content="true">
+</head>
+
+<body>
+  <div id="content">
+
+    <div>
+      <img src="/doctor-profile.png" style="float:left; max-width:150px">
+      <h1>Error</h1>
+
+      <p>
+       I'm sorry. I can't let a companion with no name enter the TARDIS.
+      </p>
+
+      <p>
+       But you can go <a href="/">back to the top</a> and then come
+       back here once you've named yourself.
+      </p>
+
+    </div>
+
+  </div>
+</body>
+</html>