start of account system
authorxangelo <git@xangelo.ca>
Sat, 3 Jun 2023 09:24:56 +0000 (05:24 -0400)
committerxangelo <git@xangelo.ca>
Sat, 3 Jun 2023 09:24:56 +0000 (05:24 -0400)
This adds the auth table and two new columns on the players table to
track account_type (session/auth) and the creation_date.

migrations/20230602191259_auth.ts [new file with mode: 0644]
public/assets/css/game.css
public/index.html
src/client/index.ts
src/shared/auth.ts [new file with mode: 0644]
src/shared/player.ts

diff --git a/migrations/20230602191259_auth.ts b/migrations/20230602191259_auth.ts
new file mode 100644 (file)
index 0000000..a180de1
--- /dev/null
@@ -0,0 +1,25 @@
+import { Knex } from "knex";
+
+
+export async function up(knex: Knex): Promise<void> {
+  return knex.schema.createTable('auth', function(table) {
+    table.uuid('id').primary();
+    table.string('username').notNullable();
+    table.string('password').notNullable();
+    table.timestamp('create_date').defaultTo(knex.raw('NOW()'))
+  })
+  .alterTable('players', function(table) {
+    table.string('account_type').notNullable().defaultTo('session');
+    table.timestamp('create_date').defaultTo(knex.raw('NOW()'))
+  })
+}
+
+
+export async function down(knex: Knex): Promise<void> {
+  return knex.schema.dropTable('auth')
+                  .alterTable('players', function(table) {
+                    table.dropColumn('account_type')
+                    table.dropColumn('create_date')
+                  });
+}
+
index cd00b1a598272037311ed7c859d3aa53aeb134c0..07de4aa338c9508e824a69158785d7db7ae009ec 100644 (file)
@@ -29,6 +29,14 @@ section {
   background-color: #fff;
 }
 
+#announcements {
+  padding: 1rem;
+  line-height: 1.2rem;
+  border: solid 1px #000;
+  background-color: #fff;
+  margin-bottom: 1rem;
+}
+
 .alert {
   padding: 0.3rem;
   margin-bottom: 0.3rem;
index 21e59b31f4c79e1bbd23b70d7919d3bba0fe526d..a5eec8919ce6a63141108101f5bcca43bd5c2248 100644 (file)
@@ -29,6 +29,8 @@
         <li><a href="#" data-section="explore" data-container="main-nav">Explore</a></li>
       </nav>
 
+      <div id="announcements" class="hidden"></div>
+
       <div id="alerts"></div>
 
       <div id="main-nav">
index 500b3beb058974a144c80a715a0469fefa79bd10..e293f8e2d5e2d37fbbc97299c3d2570f11502d72 100644 (file)
@@ -70,6 +70,7 @@ function updatePlayer() {
   $('.maxHp').html(maxHp(player.constitution, player.level).toString());
   $('.expToLevel').html(expToLevel(player.level + 1).toString());
   $('.gold').html(player.gold.toLocaleString());
+
 }
 
 socket.on('connect', () => {
diff --git a/src/shared/auth.ts b/src/shared/auth.ts
new file mode 100644 (file)
index 0000000..cd3d8cc
--- /dev/null
@@ -0,0 +1,5 @@
+export type Auth = {
+  id: string;
+  username: string;
+  password: string;
+}
index 1cab5343d5e3f147cb1ec648923247de09095af1..3416c5ed4997c2112ec937d67ac82fbc1160d7f2 100644 (file)
@@ -1,5 +1,7 @@
 export type Player = {
   id: string,
+  account_type: 'session' | 'auth',
+  create_date: Date,
   profession: Profession,
   username: string,
   strength: number;