improvement(gameutils): improve map type validation
This commit is contained in:
parent
8e3cf5fb0b
commit
3fbaad2b2b
1 changed files with 14 additions and 1 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue