45 lines
1.4 KiB
Lua
45 lines
1.4 KiB
Lua
local EnnemyUtils = {}
|
|
|
|
local datasutils = require "game.utils.datas"
|
|
|
|
local DIR = "ennemies"
|
|
|
|
function EnnemyUtils.getBaseDirectory(lua)
|
|
return datasutils.concatDataFolder(DIR, lua)
|
|
end
|
|
|
|
function EnnemyUtils.listCategories()
|
|
return require(EnnemyUtils.getBaseDirectory(true))
|
|
end
|
|
|
|
function EnnemyUtils.getCategoryDirectory(directory, lua)
|
|
return datasutils.concatFolder(EnnemyUtils.getBaseDirectory(lua), directory, lua)
|
|
end
|
|
|
|
function EnnemyUtils.getEnnemyFolder(directory, ennemy, lua)
|
|
local categoryDirectory = EnnemyUtils.getCategoryDirectory(directory, lua)
|
|
return datasutils.concatFolder(categoryDirectory, ennemy, lua)
|
|
end
|
|
|
|
function EnnemyUtils.getEnnemiesFromCategory(directory)
|
|
local folder = EnnemyUtils.getCategoryDirectory(directory, false)
|
|
return love.filesystem.getDirectoryItems(folder)
|
|
end
|
|
|
|
function EnnemyUtils.dataExists(directory, name)
|
|
local dir = datasutils.concatFolder(EnnemyUtils.getEnnemyFolder(directory, name, false), "init.lua", false)
|
|
local fileinfo = love.filesystem.getInfo(dir)
|
|
return (fileinfo ~= nil)
|
|
end
|
|
|
|
function EnnemyUtils.getData(directory, name)
|
|
-- va eprmettre de récupérer les données d'un personnage
|
|
local folder = EnnemyUtils.getEnnemyFolder(directory, name, true)
|
|
local ennemy = datasutils.copy(folder)
|
|
ennemy.stats = datasutils.copyDataset(folder, "stats")
|
|
ennemy.skills = datasutils.copyDataset(folder, "skills")
|
|
|
|
return ennemy
|
|
end
|
|
|
|
return EnnemyUtils
|