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 8ae0275..a189636 100644 Binary files a/database.sqlite3 and b/database.sqlite3 differ