From 514d4ebf407e17862e78b6c2bf3bdb424b8e0968 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 21 Mar 2024 17:12:42 -0500 Subject: [PATCH] no longer allows duplicate or empty playernames --- app.lua | 61 ++++++++++++++++++++++++++++++++++++++++------- database.sqlite3 | Bin 28672 -> 28672 bytes 2 files changed, 53 insertions(+), 8 deletions(-) diff --git a/app.lua b/app.lua index d353f97..f9dff04 100644 --- a/app.lua +++ b/app.lua @@ -40,14 +40,30 @@ app:get("/game", function(self) end) app:post("/character-create", function(self) - self.text = "Created new player" - self.game = games:create({ - player_id = self.params.playername - }) - self.session.gameref = self.game - return { - self.text, layout = false - } + if self.params.playername == "" then + self.text = "Player name must not be nil. Try again." + return { + self.text, layout = false + } + end + local player_exists = games:find({player_id = self.params.playername}) + if player_exists then + self.text = "Player name already exists. Try again." + return { + self.text, layout = false + } + end + if not player_exists then + self.text = "Created new player." + self.game = games:create({ + player_id = self.params.playername + }) + self.session.gameref = self.game.id + self.link = " Play Now" + return { + self.text, self.link, layout = false + } + end end) app:match("/map/render", function(self) @@ -84,3 +100,32 @@ return app + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/database.sqlite3 b/database.sqlite3 index 8ae02752a44eb68cbc12a31ed3e270754df856ca..a1896368c241c466ca7e2c444e89b9af0cc5472e 100644 GIT binary patch delta 32 lcmZp8z}WDBae_1>>qHr6M%Il9OZXSF7$|`7W)_1#@&K;M3LXFe literal 28672 zcmeI2O>h%c9Kd(`wcoq6%Qj#|Qn1?E7Mi9>nhHvQ6f12hB`6gnh9<>Anv^6J%Xn#T zI2_a)7e{BDQE!X~^`MS74h|Q`(Tn4O@xqLZ<3)yx<9q4;llPB<4vrT)|4cuU-@bkO ze!thy*`X(nPcBw+!G&UJDN_lCr7e;yO9z5MNs=zGPlbKLqm?~rffww%EIfbE(+kp` zdD&t|+sscSXU6`+9<#1lyV(nRPys4H1*iZOpaN8Y3Qz$mKn4D>K(S2;balyVkxJ%V zKDV6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