improvement(gameutils): improve map type validation

This commit is contained in:
Kazhnuz 2019-07-27 11:05:54 +02:00
parent 8e3cf5fb0b
commit 3fbaad2b2b

View file

@ -8,11 +8,24 @@ function gameutils.getMapPath(maptype, mapname)
end end
function gameutils.getMapDirectory(maptype, mapname) function gameutils.getMapDirectory(maptype, mapname)
if (maptype ~= "battle") and (maptype ~= "sti") then if not gameutils.validateMapType(maptype) then
error("Map type " .. maptype .. " doesn't exist.") error("Map type " .. maptype .. " doesn't exist.")
end end
return "datas/gamedata/maps/" .. maptype .. "/" .. mapname .. "/" return "datas/gamedata/maps/" .. maptype .. "/" .. mapname .. "/"
end end
function gameutils.validateMapType(maptype)
local types = {"battle", "sti"}
local validated = false
for i, type in ipairs(types) do
if (type == maptype) then
validated = true
end
end
return validated
end
return gameutils return gameutils