diff --git a/app.lua b/app.lua index 16dc4d9..d353f97 100644 --- a/app.lua +++ b/app.lua @@ -8,6 +8,7 @@ local db = require("lapis.db") local Model = require("lapis.db.model").Model local map = Model:extend('map') +local games = Model:extend('games') app:enable("etlua") app.layout = require "views.layout" @@ -38,6 +39,17 @@ 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 + } +end) + app:match("/map/render", function(self) self.tiles = {} for h = 1, 10 do @@ -53,3 +65,22 @@ app:match("/map/render", function(self) end) return app + + + + + + + + + + + + + + + + + + + diff --git a/config.lua b/config.lua index 0f958a8..8d86a35 100644 --- a/config.lua +++ b/config.lua @@ -4,6 +4,7 @@ config("development", { server = "nginx", code_cache = "off", num_workers = "1", + secret = "M2KisAmerican", sqlite = { database = "database.sqlite3", -- open_flags = ... diff --git a/database.sqlite3 b/database.sqlite3 index 2096b11..8ae0275 100644 Binary files a/database.sqlite3 and b/database.sqlite3 differ diff --git a/lua_scripts/map.lua b/lua_scripts/map.lua index 6a48e05..9da9245 100644 --- a/lua_scripts/map.lua +++ b/lua_scripts/map.lua @@ -16,22 +16,15 @@ local map = { db = { "floor_stone,", "floor_wood", "wall_stone", "wall_wood" } }, mapCrypt = function(self, tile) + -- stores tiles as detailed names within the DB for i=1, #self.tileset.display do if self.tileset.display[i] == tile then return self.tileset.db[i] end end - --if tile == "-" then - -- return "floor_stone" - --elseif tile == "_" then - -- return "floor_wood" - --elseif tile == "w" then - -- return "wall_stone" - --end end, mapDecrypt = function(self, tile) - -- TODO: Rework function so it returns both char and mat type - -- This introduces breaking changes + -- Decodes tiles into their type (represented by char) and their material local tileset = {} if string.find(tile, "wall") then tileset.char = "w" @@ -44,12 +37,6 @@ local map = { tileset.material = "wood" end return tileset - - -- if tile == "floor_stone" then - -- return "-" - -- elseif tile == "wall_stone" then - -- return "w" - -- end end, -- Map Populate / check if map exists populate = function(self, map, game) diff --git a/setup_db b/setup_db index 0bc4302..982216f 100755 --- a/setup_db +++ b/setup_db @@ -25,7 +25,7 @@ sqlite3 database.sqlite3 " ); CREATE TABLE IF NOT EXISTS games ( id INTEGER PRIMARY KEY AUTOINCREMENT, - player_id INTEGER + player_id TEXT ); CREATE TABLE IF NOT EXISTS players ( id INTEGER PRIMARY KEY AUTOINCREMENT, diff --git a/static/incertitude.css b/static/incertitude.css index 65c7ed1..4f393f3 100644 --- a/static/incertitude.css +++ b/static/incertitude.css @@ -5,3 +5,7 @@ .stone { color: gray; } + +h1 { + --pico-font-family: Pacifico, cursive; +} diff --git a/views/game.etlua b/views/game.etlua index dd5d26c..6def7a1 100644 --- a/views/game.etlua +++ b/views/game.etlua @@ -5,7 +5,11 @@ <% end %> -
+

Game

+
+
+ <% render("views.player_ui") %> +
diff --git a/views/index.etlua b/views/index.etlua index 8b4de5e..59709e6 100644 --- a/views/index.etlua +++ b/views/index.etlua @@ -1,4 +1,5 @@ + <% if not isPopulated then %>
@@ -6,15 +7,21 @@
<% end %> -Play Now +
+

Log In / Create Game

+

Player will be created if player name does not already exist.

+
+
+ + +
+
+
+

+
+
+Play Now - + diff --git a/views/layout.etlua b/views/layout.etlua index 98883e8..cc55ba4 100644 --- a/views/layout.etlua +++ b/views/layout.etlua @@ -5,10 +5,11 @@ <%= page_title or "My Page" %> + -

Peradventure

+

Peradventure

<% content_for("inner") %> diff --git a/views/player_ui.etlua b/views/player_ui.etlua new file mode 100644 index 0000000..70af281 --- /dev/null +++ b/views/player_ui.etlua @@ -0,0 +1,3 @@ + + +

Look at me!