Game
+diff --git a/app.lua b/app.lua index 36da22a..8d4cb87 100644 --- a/app.lua +++ b/app.lua @@ -24,6 +24,7 @@ end) app:get("/", function(self) self.text = say.hello() + self.isPopulated = mapFunc:mapExists(map) return {render = "index", } @@ -35,6 +36,9 @@ app:match("/map/render", function(self) self.tiles[h] = {} for i=1,10 do self.tiles[h][i] = map:find({x = h, y = i}) + -- The map database has floor_stone and wall_floor instead of simple ASCII characters + -- So we run mapFunc:mapDecrypt to convert it back to the desired characters for visual display + self.tiles[h][i].occupied_by_type = mapFunc:mapDecrypt(self.tiles[h][i].occupied_by_type) end end return {render = "map", layout = false} diff --git a/database.sqlite3 b/database.sqlite3 index a3ee411..9b1bdcc 100644 Binary files a/database.sqlite3 and b/database.sqlite3 differ diff --git a/lua_scripts/map.lua b/lua_scripts/map.lua index 1a9ac38..4ad34d8 100644 --- a/lua_scripts/map.lua +++ b/lua_scripts/map.lua @@ -11,13 +11,27 @@ local map = { {"-", "-", "w", "-", "-", "-", "-", "w", "w", "-"}, {"-", "-", "w", "-", "-", "-", "-", "-", "w", "-"} }, + mapCrypt = function(self, tile) + if tile == "-" then + return "floor_stone" + elseif tile == "w" then + return "wall_stone" + end + end, + mapDecrypt = function(self, tile) + if tile == "floor_stone" then + return "-" + elseif tile == "wall_stone" then + return "w" + end + end, populate = function(self, map) - for h=1,10 do + for h=1,10 do for i=1,10 do local tile = map:create({ x = h, y = i, - occupied_by_type = self.map_tiles[h][i], + occupied_by_type = self:mapCrypt(self.map_tiles[h][i]), occupied_by_id = "" }) end @@ -48,3 +62,4 @@ return map + diff --git a/views/index.etlua b/views/index.etlua index 8f9270b..5641aea 100644 --- a/views/index.etlua +++ b/views/index.etlua @@ -1,10 +1,15 @@ +<% if not isPopulated then %>
Game
+