diff --git a/classes/beastfile.lua b/classes/beastfile.lua index 6fd77cb..c5d34bd 100644 --- a/classes/beastfile.lua +++ b/classes/beastfile.lua @@ -3,10 +3,10 @@ local DataList = require "classes.datalist" local parseFile = require "libs.filereader" -function BeastFile:new(folder, name) +function BeastFile:new(folder, name, forceLevel) self.filepath = folder .. "/" .. name print("Loading " .. self.filepath) - self.datas = DataList() + self.datas = DataList(forceLevel) self:readLines() end @@ -44,4 +44,10 @@ function BeastFile:prepareJson(simplercreatures, creatures, parent) self.datas:prepareJson(simplercreatures, creatures, parent) end +function BeastFile:getRawData() + local content = {} + self.datas:prepareJson({}, content, "Nothing") + return content[1] +end + return BeastFile \ No newline at end of file diff --git a/classes/datalist.lua b/classes/datalist.lua index cdaf20d..96c81cb 100644 --- a/classes/datalist.lua +++ b/classes/datalist.lua @@ -60,7 +60,8 @@ function DataList.getHolder(key, value) return SimpleHolder(key, value) end -function DataList:new() +function DataList:new(forceLevel) + self.forceLevel = forceLevel self.list = {} self.holders = {} self.reducedList = {} @@ -84,6 +85,10 @@ function DataList:reduce() end end + if (self.forceLevel ~= nil) then + level = self.forceLevel + end + for _, rawdata in ipairs(self.list) do if (rawdata:canBeUsed(level)) then self.holders[rawdata:getKey()]:applyCommand(rawdata:getCommand(), rawdata.arguments) @@ -94,7 +99,9 @@ function DataList:reduce() self.reducedList[key] = holder:reduce(level) end - --TODO + if (self.forceLevel ~= nil) then + self.reducedList["level"] = self.forceLevel + end end function DataList:prepareJson(simplercreatures, creatures, parent) diff --git a/view.lua b/view.lua new file mode 100644 index 0000000..114a0d0 --- /dev/null +++ b/view.lua @@ -0,0 +1,32 @@ +require "libs" +local config = require "config" +local BeastFile = require "classes.beastfile" + +local beast = BeastFile("data", arg[1] .. ".beast", tonumber(arg[2])) + +local creature = beast:getRawData() + +print(creature.name, "Lvl:" .. creature.level, "Pression:" .. creature.pression, creature.nomType, creature.categorie) +print(" ", "------") +print("FOR:" .. creature.atk, "INT:" .. creature.int, "CHA:" .. creature.cha) +print("CON:" .. creature.con, "SAG:" .. creature.sag, "DIS:" .. creature.dis) +print("HAB:" .. creature.hab, "VOL:" .. creature.vol, "REL:" .. creature.rel) +print(" ", "PER:" .. creature.per) +print(" ", "------") +print("PV:" .. creature.pv, "PE:" .. creature.pe, "Eclat : " .. creature.eclat) +print("Armure", "Phy:" .. creature.armurephy, "Psy:" .. creature.armurepsy, "Spe:" .. creature.armurespe) +print(" ", "------") +print("Armes:") +for key, value in ipairs(creature.armes) do + print(value[1], value[2]) +end +print(" ", "------") +print("Competences:") +for key, value in ipairs(creature.competence) do + print(value.name, value.value) +end +print(" ", "------") +print("Skills:") +for key, value in ipairs(creature.skill) do + print(value[1], value[2]) +end \ No newline at end of file