chore: make the datas utils a part of birb
This commit is contained in:
parent
1991b5005f
commit
33d854ffd4
6 changed files with 23 additions and 30 deletions
|
@ -31,4 +31,5 @@ return {
|
|||
table = require(cwd .. "table"),
|
||||
string = require(cwd .. "string"),
|
||||
time = require(cwd .. "time"),
|
||||
datas = require(cwd .. "datas")
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
local BattleUtils = {}
|
||||
|
||||
local datasutils = require "game.utils.datas"
|
||||
|
||||
local DIR = "battles"
|
||||
|
||||
function BattleUtils.getBaseDirectory(lua)
|
||||
return datasutils.concatDataFolder(DIR, lua)
|
||||
return utils.datas.concatDataFolder(DIR, lua)
|
||||
end
|
||||
|
||||
function BattleUtils.listCategories()
|
||||
|
@ -14,7 +12,7 @@ end
|
|||
|
||||
function BattleUtils.getCategoryDirectory(directory, lua)
|
||||
local baseDir = BattleUtils.getBaseDirectory(lua)
|
||||
return datasutils.concatFolder(baseDir, directory, lua)
|
||||
return utils.datas.concatFolder(baseDir, directory, lua)
|
||||
end
|
||||
|
||||
function BattleUtils.getDirectoryLuaStyle(directory)
|
||||
|
@ -23,12 +21,12 @@ end
|
|||
|
||||
function BattleUtils.getBattleFromCategory(directory)
|
||||
local folder = BattleUtils.getCategoryDirectory(directory, false)
|
||||
return datasutils.luaFileListToModuleList(love.filesystem.getDirectoryItems(folder))
|
||||
return utils.datas.luaFileListToModuleList(love.filesystem.getDirectoryItems(folder))
|
||||
end
|
||||
|
||||
function BattleUtils.getBattleData(directory, battlename)
|
||||
local categoryDir = BattleUtils.getCategoryDirectory(directory, true)
|
||||
return datasutils.require(categoryDir, battlename)
|
||||
return utils.datas.require(categoryDir, battlename)
|
||||
end
|
||||
|
||||
-- ENNEMY FUNCTIONS
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
local CharUtils = {}
|
||||
|
||||
local datasutils = require "game.utils.datas"
|
||||
|
||||
local CONST = {}
|
||||
CONST.EXP_MULTIPLICATOR = 4
|
||||
CONST.EXP_RATIO = 5
|
||||
|
@ -18,12 +16,12 @@ CONST.MULT_MP = 1.5
|
|||
local DIR = "characters"
|
||||
|
||||
function CharUtils.getBaseDirectory(lua)
|
||||
return datasutils.concatDataFolder(DIR, lua)
|
||||
return utils.datas.concatDataFolder(DIR, lua)
|
||||
end
|
||||
|
||||
function CharUtils.getCharacterDirectory(name, lua)
|
||||
local baseDirectory = CharUtils.getBaseDirectory(lua)
|
||||
return datasutils.concatFolder(baseDirectory, name, lua)
|
||||
return utils.datas.concatFolder(baseDirectory, name, lua)
|
||||
end
|
||||
|
||||
|
||||
|
@ -64,10 +62,10 @@ end
|
|||
function CharUtils.getCharacterData(charname)
|
||||
-- va eprmettre de récupérer les données d'un personnage
|
||||
local charfolder = CharUtils.getCharacterDirectory(charname, true)
|
||||
local character = datasutils.copy(charfolder)
|
||||
character.stats = datasutils.copyDataset(charfolder, "stats")
|
||||
character.inventory = datasutils.copyDataset(charfolder, "inventory")
|
||||
character.skills = datasutils.copyDataset(charfolder, "skills")
|
||||
local character = utils.datas.copy(charfolder)
|
||||
character.stats = utils.datas.copyDataset(charfolder, "stats")
|
||||
character.inventory = utils.datas.copyDataset(charfolder, "inventory")
|
||||
character.skills = utils.datas.copyDataset(charfolder, "skills")
|
||||
|
||||
return character
|
||||
end
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
local EnnemyUtils = {}
|
||||
|
||||
local datasutils = require "game.utils.datas"
|
||||
|
||||
local DIR = "ennemies"
|
||||
|
||||
function EnnemyUtils.getBaseDirectory(lua)
|
||||
return datasutils.concatDataFolder(DIR, lua)
|
||||
return utils.datas.concatDataFolder(DIR, lua)
|
||||
end
|
||||
|
||||
function EnnemyUtils.listCategories()
|
||||
|
@ -13,12 +11,12 @@ function EnnemyUtils.listCategories()
|
|||
end
|
||||
|
||||
function EnnemyUtils.getCategoryDirectory(directory, lua)
|
||||
return datasutils.concatFolder(EnnemyUtils.getBaseDirectory(lua), directory, lua)
|
||||
return utils.datas.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)
|
||||
return utils.datas.concatFolder(categoryDirectory, ennemy, lua)
|
||||
end
|
||||
|
||||
function EnnemyUtils.getEnnemiesFromCategory(directory)
|
||||
|
@ -27,7 +25,7 @@ function EnnemyUtils.getEnnemiesFromCategory(directory)
|
|||
end
|
||||
|
||||
function EnnemyUtils.dataExists(directory, name)
|
||||
local dir = datasutils.concatFolder(EnnemyUtils.getEnnemyFolder(directory, name, false), "init.lua", false)
|
||||
local dir = utils.datas.concatFolder(EnnemyUtils.getEnnemyFolder(directory, name, false), "init.lua", false)
|
||||
local fileinfo = love.filesystem.getInfo(dir)
|
||||
return (fileinfo ~= nil)
|
||||
end
|
||||
|
@ -35,9 +33,9 @@ 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")
|
||||
local ennemy = utils.datas.copy(folder)
|
||||
ennemy.stats = utils.datas.copyDataset(folder, "stats")
|
||||
ennemy.skills = utils.datas.copyDataset(folder, "skills")
|
||||
|
||||
return ennemy
|
||||
end
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
local ItemUtils = {}
|
||||
|
||||
local datasutils = require "game.utils.datas"
|
||||
|
||||
local DIR = "items"
|
||||
|
||||
function ItemUtils.getBaseDirectory(lua)
|
||||
return datasutils.concatDataFolder(DIR, lua)
|
||||
return utils.datas.concatDataFolder(DIR, lua)
|
||||
end
|
||||
|
||||
function ItemUtils.listCategories()
|
||||
|
@ -13,18 +11,18 @@ function ItemUtils.listCategories()
|
|||
end
|
||||
|
||||
function ItemUtils.getCategoryDirectory(directory, lua)
|
||||
return datasutils.concatFolder(ItemUtils.getBaseDirectory(lua), directory, lua)
|
||||
return utils.datas.concatFolder(ItemUtils.getBaseDirectory(lua), directory, lua)
|
||||
end
|
||||
|
||||
function ItemUtils.getItemsFromCategory(directory)
|
||||
local folder = ItemUtils.getCategoryDirectory(directory, false)
|
||||
local baseTable = love.filesystem.getDirectoryItems(folder)
|
||||
return datasutils.luaFileListToModuleList(baseTable)
|
||||
return utils.datas.luaFileListToModuleList(baseTable)
|
||||
end
|
||||
|
||||
function ItemUtils.getItemFile(category, item, lua)
|
||||
local dir = ItemUtils.getCategoryDirectory(category, lua)
|
||||
local path = datasutils.concatFolder(dir, item, lua)
|
||||
local path = utils.datas.concatFolder(dir, item, lua)
|
||||
if (not lua) then
|
||||
path = path .. ".lua"
|
||||
end
|
||||
|
@ -39,7 +37,7 @@ end
|
|||
|
||||
function ItemUtils.getItemData(category, item)
|
||||
local path = ItemUtils.getItemFile(category, item, true)
|
||||
return datasutils.copy(path)
|
||||
return utils.datas.copy(path)
|
||||
end
|
||||
|
||||
-- VALIDATION FUNCTIONS
|
||||
|
|
Loading…
Reference in a new issue