Compare commits
No commits in common. "bd5a68c2a7c40ad4c1cafb9569d775e19601c5ca" and "d7e721f49ac8943f0e9706a8646eca3e65b78651" have entirely different histories.
bd5a68c2a7
...
d7e721f49a
20 changed files with 35 additions and 196 deletions
|
@ -3,10 +3,10 @@ local DataList = require "classes.datalist"
|
||||||
|
|
||||||
local parseFile = require "libs.filereader"
|
local parseFile = require "libs.filereader"
|
||||||
|
|
||||||
function BeastFile:new(folder, name, forceLevel)
|
function BeastFile:new(folder, name)
|
||||||
self.filepath = folder .. "/" .. name
|
self.filepath = folder .. "/" .. name
|
||||||
print("Loading " .. self.filepath)
|
print("Loading " .. self.filepath)
|
||||||
self.datas = DataList(forceLevel)
|
self.datas = DataList()
|
||||||
|
|
||||||
self:readLines()
|
self:readLines()
|
||||||
end
|
end
|
||||||
|
@ -44,10 +44,4 @@ function BeastFile:prepareJson(simplercreatures, creatures, parent)
|
||||||
self.datas:prepareJson(simplercreatures, creatures, parent)
|
self.datas:prepareJson(simplercreatures, creatures, parent)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BeastFile:getRawData()
|
|
||||||
local content = {}
|
|
||||||
self.datas:prepareJson({}, content, "Nothing")
|
|
||||||
return content[1]
|
|
||||||
end
|
|
||||||
|
|
||||||
return BeastFile
|
return BeastFile
|
|
@ -11,10 +11,7 @@ function StatHolder:applyCommand(command, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
function StatHolder:reduce(level)
|
function StatHolder:reduce(level)
|
||||||
local stat = self.commands.base + ((self.commands.lvl or 0) * level) + (self.commands.add or 0) + (self.commands.bonus or 0)
|
return self.commands.base + ((self.commands.lvl or 0) * level) + (self.commands.add or 0) + (self.commands.bonus or 0)
|
||||||
local modulo = commands.structs[self.key].modulo or 1
|
|
||||||
stat = math.floor(stat / modulo) * modulo
|
|
||||||
return stat
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return StatHolder
|
return StatHolder
|
|
@ -60,8 +60,7 @@ function DataList.getHolder(key, value)
|
||||||
return SimpleHolder(key, value)
|
return SimpleHolder(key, value)
|
||||||
end
|
end
|
||||||
|
|
||||||
function DataList:new(forceLevel)
|
function DataList:new()
|
||||||
self.forceLevel = forceLevel
|
|
||||||
self.list = {}
|
self.list = {}
|
||||||
self.holders = {}
|
self.holders = {}
|
||||||
self.reducedList = {}
|
self.reducedList = {}
|
||||||
|
@ -85,10 +84,6 @@ function DataList:reduce()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self.forceLevel ~= nil) then
|
|
||||||
level = self.forceLevel
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, rawdata in ipairs(self.list) do
|
for _, rawdata in ipairs(self.list) do
|
||||||
if (rawdata:canBeUsed(level)) then
|
if (rawdata:canBeUsed(level)) then
|
||||||
self.holders[rawdata:getKey()]:applyCommand(rawdata:getCommand(), rawdata.arguments)
|
self.holders[rawdata:getKey()]:applyCommand(rawdata:getCommand(), rawdata.arguments)
|
||||||
|
@ -96,33 +91,10 @@ function DataList:reduce()
|
||||||
end
|
end
|
||||||
|
|
||||||
for key, holder in pairs(self.holders) do
|
for key, holder in pairs(self.holders) do
|
||||||
--self.reducedList[key] = holder:reduce(level)
|
self.reducedList[key] = holder:reduce(level)
|
||||||
self:addToReducedList(key, holder:reduce(level))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self.forceLevel ~= nil) then
|
--TODO
|
||||||
self.reducedList["level"] = self.forceLevel
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function DataList:addToReducedList(key, data)
|
|
||||||
local to = commands.structs[key].to or key
|
|
||||||
local toSplited = utils.split(to, ".", true)
|
|
||||||
if (#toSplited == 1) then
|
|
||||||
self.reducedList[to] = data
|
|
||||||
else
|
|
||||||
local list = self.reducedList
|
|
||||||
for i, toPart in ipairs(toSplited) do
|
|
||||||
if (i == #toSplited) then
|
|
||||||
list[toPart] = data
|
|
||||||
else
|
|
||||||
if (list[toPart] == nil) then
|
|
||||||
list[toPart] = {}
|
|
||||||
end
|
|
||||||
list = list[toPart]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function DataList:prepareJson(simplercreatures, creatures, parent)
|
function DataList:prepareJson(simplercreatures, creatures, parent)
|
||||||
|
|
|
@ -1,43 +1,5 @@
|
||||||
name;Loup
|
name;Loup
|
||||||
level;4
|
atk.base;60
|
||||||
type;bete
|
competence;morsure
|
||||||
|
competence;griffure
|
||||||
atk.base;50
|
competence;dechirement | 10
|
||||||
hab.base;70
|
|
||||||
int.base;35
|
|
||||||
sag.base;40
|
|
||||||
vol.base;60
|
|
||||||
cha.base;60
|
|
||||||
dis.base;60
|
|
||||||
per.base;70
|
|
||||||
|
|
||||||
atk.lvl;4
|
|
||||||
hab.lvl;5
|
|
||||||
dis.lvl;3
|
|
||||||
con.lvl;3
|
|
||||||
|
|
||||||
pv.lvl;5
|
|
||||||
pe.lvl;1
|
|
||||||
|
|
||||||
armurephy.base;3 | 5
|
|
||||||
armurepsy.base;0 | 5
|
|
||||||
armurespe.base;1 | 5
|
|
||||||
|
|
||||||
armurephy.base;6 | 10
|
|
||||||
armurepsy.base;1 | 10
|
|
||||||
armurespe.base;2 | 10
|
|
||||||
|
|
||||||
armurephy.base;9 | 15
|
|
||||||
armurepsy.base;2 | 15
|
|
||||||
armurespe.base;3 | 15
|
|
||||||
|
|
||||||
competence;Chasse;10;
|
|
||||||
competence.lvl;Chasse;5;
|
|
||||||
competence;Pistage;10;
|
|
||||||
competence.lvl;Pistage;5;
|
|
||||||
|
|
||||||
armes;Griffe;2;
|
|
||||||
armes;Croc;3;
|
|
||||||
|
|
||||||
skill;Morsure;Une attaque qui utilise les crocs et fait 1 blessure;
|
|
||||||
skill;Griffure;Fait deux attaques à -30% de chance d'échouer;
|
|
|
@ -1,5 +0,0 @@
|
||||||
nomType;aerien
|
|
||||||
categorie;biologique
|
|
||||||
faiblesse;air
|
|
||||||
resistance;terre
|
|
||||||
skill;Vol;Peut voler
|
|
|
@ -1,5 +0,0 @@
|
||||||
nomType;aquatique
|
|
||||||
categorie;biologique
|
|
||||||
faiblesse;foudre
|
|
||||||
resistance;eau
|
|
||||||
skill;Aquatique;N'a pas de malus dans l'eau
|
|
|
@ -1,3 +0,0 @@
|
||||||
nomType;bête
|
|
||||||
categorie;biologique
|
|
||||||
faiblesse;metal
|
|
|
@ -1,5 +0,0 @@
|
||||||
nomType;feufolet
|
|
||||||
categorie;non-biologique
|
|
||||||
faiblesse;eau
|
|
||||||
faiblesse;terre
|
|
||||||
resistance;glace
|
|
|
@ -1,6 +0,0 @@
|
||||||
nomType;gelatineux
|
|
||||||
categorie;non-biologique
|
|
||||||
faiblesse;metal
|
|
||||||
faiblesse;son
|
|
||||||
resistance;force
|
|
||||||
resistance;eau
|
|
|
@ -1,4 +0,0 @@
|
||||||
nomType;créature de glace
|
|
||||||
categorie;non-biologique
|
|
||||||
faiblesse;feu
|
|
||||||
resistance;glace
|
|
|
@ -1,2 +0,0 @@
|
||||||
nomType;humanoïde
|
|
||||||
categorie;biologique
|
|
|
@ -1,3 +0,0 @@
|
||||||
nomType;insecte
|
|
||||||
categorie;biologique
|
|
||||||
faiblesse;feu
|
|
|
@ -1,5 +0,0 @@
|
||||||
nomType;machine
|
|
||||||
categorie;non-biologique
|
|
||||||
immunite;poison
|
|
||||||
faiblesse;foudre
|
|
||||||
faiblesse;eau
|
|
|
@ -1,4 +0,0 @@
|
||||||
nomType;mineraloïde
|
|
||||||
categorie;non-biologique
|
|
||||||
resistance;poison
|
|
||||||
resistance;feu
|
|
|
@ -1,3 +0,0 @@
|
||||||
nomType;reptile
|
|
||||||
categorie;biologique
|
|
||||||
faiblesse;glace
|
|
|
@ -1,4 +0,0 @@
|
||||||
nomType;vegetal
|
|
||||||
categorie;biologique
|
|
||||||
faiblesse;feu
|
|
||||||
resistance;vegetal
|
|
|
@ -1,5 +0,0 @@
|
||||||
nomType;volute
|
|
||||||
categorie;non-biologique
|
|
||||||
faiblesse;air
|
|
||||||
resistance;terre
|
|
||||||
resistance;metal
|
|
|
@ -15,7 +15,7 @@ end
|
||||||
|
|
||||||
local function addStatCommands(name, value)
|
local function addStatCommands(name, value)
|
||||||
addCommands(name .. ".base", name, value.default)
|
addCommands(name .. ".base", name, value.default)
|
||||||
addCommands(name .. ".lvl", name, value.lvl or 0)
|
addCommands(name .. ".lvl", name, 0)
|
||||||
addCommands(name .. ".add", name, 0)
|
addCommands(name .. ".add", name, 0)
|
||||||
addCommands(name .. ".bonus", name, 0)
|
addCommands(name .. ".bonus", name, 0)
|
||||||
end
|
end
|
||||||
|
|
48
struct.lua
48
struct.lua
|
@ -1,29 +1,29 @@
|
||||||
return {
|
return {
|
||||||
name={contentType = "string", preParse = true, to="name"},
|
name={contentType = "string", preParse = true},
|
||||||
nomType={contentType = "string", to="type"},
|
nomType={contentType = "string"},
|
||||||
categorie={contentType = "string", to="categorie"},
|
categorie={contentType = "string"},
|
||||||
faiblesse={contentType = "list", args=1},
|
faiblesses={contentType = "string"},
|
||||||
resistence={contentType = "list", args=1},
|
resistences={contentType = "string"},
|
||||||
immunite={contentType = "list", args=1},
|
immunites={contentType = "string"},
|
||||||
level={contentType = "number", default = 0, preParse = true},
|
level={contentType = "number", default = 0, preParse = true},
|
||||||
pression={contentType = "number", default = 5},
|
atk= {dataType= "stat", modulo= 5, default= 50, max=255, min=10},
|
||||||
atk= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.for"},
|
con= {dataType= "stat", modulo= 5, default= 50, max=255, min=10},
|
||||||
con= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.con"},
|
hab= {dataType= "stat", modulo= 5, default= 50, max=255, min=10},
|
||||||
hab= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.hab"},
|
int= {dataType= "stat", modulo= 5, default= 50, max=255, min=10},
|
||||||
int= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.int"},
|
sag= {dataType= "stat", modulo= 5, default= 50, max=255, min=10},
|
||||||
sag= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.sag"},
|
vol= {dataType= "stat", modulo= 5, default= 50, max=255, min=10},
|
||||||
vol= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.vol"},
|
cha= {dataType= "stat", modulo= 5, default= 50, max=255, min=10},
|
||||||
cha= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.cha"},
|
dis= {dataType= "stat", modulo= 5, default= 50, max=255, min=10},
|
||||||
dis= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.dis"},
|
rel= {dataType= "stat", modulo= 5, default= 50, max=255, min=10},
|
||||||
rel= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.rel"},
|
per= {dataType= "stat", modulo= 5, default= 50, max=255, min=10},
|
||||||
per= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.per"},
|
pv= {dataType= "stat", modulo= 1, default= 12, max=9999999, min=1},
|
||||||
pv= {dataType= "stat", modulo= 1, default= 12, max=9999999, min=1, to="vita.pv", lvl=3},
|
pe= {dataType= "stat", modulo= 1, default= 12, max=9999999, min=1},
|
||||||
pe= {dataType= "stat", modulo= 1, default= 12, max=9999999, min=1, to="vita.pe", lvl=3},
|
eclat= {dataType= "stat", modulo= 1, default= 10, max=200, min=1},
|
||||||
eclat= {dataType= "stat", modulo= 1, default= 10, max=200, min=1, to="vita.eclat"},
|
armurephy= {dataType= "stat", modulo= 1, default= 0, max=9999999, min=0},
|
||||||
armurephy= {dataType= "stat", modulo= 1, default= 0, max=9999999, min=0, to="armure.phy"},
|
armurepsy= {dataType= "stat", modulo= 1, default= 0, max=9999999, min=0},
|
||||||
armurepsy= {dataType= "stat", modulo= 1, default= 0, max=9999999, min=0, to="armure.psy"},
|
armurespe= {dataType= "stat", modulo= 1, default= 0, max=9999999, min=0},
|
||||||
armurespe= {dataType= "stat", modulo= 1, default= 0, max=9999999, min=0, to="armure.spe"},
|
|
||||||
armes= {dataType= "list", args=2},
|
armes= {dataType= "list", args=2},
|
||||||
competence= {dataType= "comp", args=3}, -- on va le gérer différemment comme du code lol sinon c'est trop relou
|
competence= {dataType= "comp", args=3}, -- on va le gérer différemment comme du code lol sinon c'est trop relou
|
||||||
skill= {dataType= "list", args=2},
|
skill= {dataType= "list", args=2}, -- on va le gérer différemment comme du code lol sinon c'est trop relou
|
||||||
|
armes= {dataType= "list", args=1},
|
||||||
}
|
}
|
32
view.lua
32
view.lua
|
@ -1,32 +0,0 @@
|
||||||
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["type"], creature.categorie)
|
|
||||||
print(" ", "------")
|
|
||||||
print("FOR:" .. creature.stats["for"], "INT:" .. creature.stats.int, "CHA:" .. creature.stats.cha)
|
|
||||||
print("CON:" .. creature.stats.con, "SAG:" .. creature.stats.sag, "DIS:" .. creature.stats.dis)
|
|
||||||
print("HAB:" .. creature.stats.hab, "VOL:" .. creature.stats.vol, "REL:" .. creature.stats.rel)
|
|
||||||
print(" ", "PER:" .. creature.stats.per)
|
|
||||||
print(" ", "------")
|
|
||||||
print("PV:" .. creature.vita.pv, "PE:" .. creature.vita.pe, "Eclat:" .. creature.vita.eclat)
|
|
||||||
print("Armure", "Phy:" .. creature.armure.phy, "Psy:" .. creature.armure.psy, "Spe:" .. creature.armure.spe)
|
|
||||||
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
|
|
Loading…
Reference in a new issue