fix: refonte des fichiers
Maintenant utilisation de plutôt deux fichier séparé, un contenant toutes les créatures et un autre contenant les bestiaires
This commit is contained in:
parent
7a972d4726
commit
9b1d92449e
5 changed files with 47 additions and 22 deletions
|
@ -38,8 +38,10 @@ function BeastFile:loadMixin(mixin)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function BeastFile:prepareJson()
|
function BeastFile:prepareJson(simplercreatures, creatures)
|
||||||
return self.datas:prepareJson()
|
assert(simplercreatures ~= nil)
|
||||||
|
assert(creatures ~= nil)
|
||||||
|
self.datas:prepareJson(simplercreatures, creatures)
|
||||||
end
|
end
|
||||||
|
|
||||||
return BeastFile
|
return BeastFile
|
|
@ -97,9 +97,11 @@ function DataList:reduce()
|
||||||
--TODO
|
--TODO
|
||||||
end
|
end
|
||||||
|
|
||||||
function DataList:prepareJson()
|
function DataList:prepareJson(simplercreatures, creatures)
|
||||||
self:reduce()
|
self:reduce()
|
||||||
return self.reducedList
|
|
||||||
|
table.insert(simplercreatures, {nom = self.reducedList.name, level = self.reducedList.level, nomType = self.reducedList.nomType, categorie = self.reducedList.categorie})
|
||||||
|
table.insert(creatures, self.reducedList)
|
||||||
end
|
end
|
||||||
|
|
||||||
return DataList
|
return DataList
|
|
@ -1,9 +1,9 @@
|
||||||
local FolderLoader = Object:extend()
|
local FolderLoader = Object:extend()
|
||||||
local BeastFile = require "classes.beastfile"
|
local BeastFile = require "classes.beastfile"
|
||||||
|
|
||||||
function FolderLoader.getAllDatas(value)
|
function FolderLoader.getAllDatas(value, bestiaires, creatures)
|
||||||
local folderLoader = FolderLoader(value)
|
local folderLoader = FolderLoader(value)
|
||||||
return folderLoader:getDatas()
|
folderLoader:getDatas(bestiaires, creatures)
|
||||||
end
|
end
|
||||||
|
|
||||||
function FolderLoader:new(value)
|
function FolderLoader:new(value)
|
||||||
|
@ -11,6 +11,8 @@ function FolderLoader:new(value)
|
||||||
|
|
||||||
self.data = {}
|
self.data = {}
|
||||||
self.data.nom = value.nom
|
self.data.nom = value.nom
|
||||||
|
self.data.description = value.description
|
||||||
|
self.data.folder = value.folder
|
||||||
self.data.list = {}
|
self.data.list = {}
|
||||||
|
|
||||||
self.files = {}
|
self.files = {}
|
||||||
|
@ -25,16 +27,26 @@ function FolderLoader:new(value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function FolderLoader:prepareJson()
|
function FolderLoader:prepareJson(simplercreatures, creatures)
|
||||||
for _, file in ipairs(self.files) do
|
for _, file in ipairs(self.files) do
|
||||||
table.insert(self.data.list, file:prepareJson())
|
file:prepareJson(simplercreatures, creatures)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function FolderLoader:getDatas()
|
function FolderLoader:getDatas(bestiaires, creatures)
|
||||||
self:prepareJson()
|
local simplercreatures = {}
|
||||||
return self.data
|
self:prepareJson(simplercreatures, creatures)
|
||||||
|
|
||||||
|
|
||||||
|
local bestiaire = {
|
||||||
|
nom = self.data.nom,
|
||||||
|
description = self.data.description,
|
||||||
|
folder = self.data.folder,
|
||||||
|
list = simplercreatures
|
||||||
|
}
|
||||||
|
|
||||||
|
table.insert(bestiaires, bestiaire)
|
||||||
end
|
end
|
||||||
|
|
||||||
return FolderLoader
|
return FolderLoader
|
|
@ -1,3 +1,3 @@
|
||||||
return {
|
return {
|
||||||
{nom = "Animaux", folder = "animaux"}
|
{nom = "Animaux", folder = "animaux", description = "Des animaux génériques et communs (ou moins communs)"}
|
||||||
}
|
}
|
23
main.lua
23
main.lua
|
@ -4,17 +4,26 @@ local FolderLoader = require "classes.folderloader"
|
||||||
|
|
||||||
local json = require "libs.json"
|
local json = require "libs.json"
|
||||||
|
|
||||||
for _, value in ipairs(config) do
|
print("Début de génération des fichiers .json")
|
||||||
print("Début de génération du fichier " .. value.folder .. ".json")
|
|
||||||
clock = os.clock()
|
clock = os.clock()
|
||||||
|
|
||||||
local datas = FolderLoader.getAllDatas(value)
|
local bestiaires = {}
|
||||||
|
local creatures = {}
|
||||||
|
|
||||||
local file = io.open("build/" .. value.folder .. ".json", "w")
|
for _, value in ipairs(config) do
|
||||||
|
print("Charagement de la catégorie " .. value.nom)
|
||||||
|
FolderLoader.getAllDatas(value, bestiaires, creatures)
|
||||||
|
end
|
||||||
|
|
||||||
|
local file = io.open("build/bestiaires.json", "w")
|
||||||
if (file ~= nil) then
|
if (file ~= nil) then
|
||||||
file:write(json.encode(datas))
|
file:write(json.encode(bestiaires))
|
||||||
|
end
|
||||||
|
|
||||||
|
local file2 = io.open("build/creatures.json", "w")
|
||||||
|
if (file2 ~= nil) then
|
||||||
|
file2:write(json.encode(creatures))
|
||||||
end
|
end
|
||||||
|
|
||||||
clock = os.clock() - clock
|
clock = os.clock() - clock
|
||||||
print("Génération du fichier " .. value.folder .. ".json en " .. clock .. " seconds")
|
print("Génération du fichier .json en " .. clock .. " seconds")
|
||||||
end
|
|
Loading…
Reference in a new issue