feat: ajout d'un viewer rapide

This commit is contained in:
Kazhnuz 2024-08-06 21:00:05 +02:00
parent 8a9e2d7d66
commit ce3d8fda5c
3 changed files with 49 additions and 4 deletions

View file

@ -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

View file

@ -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)

32
view.lua Normal file
View file

@ -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