Compare commits

..

10 commits

Author SHA1 Message Date
Kazhnuz
bd5a68c2a7 wip: premier jet de loup 2024-08-06 22:41:40 +02:00
Kazhnuz
158da18b0a feat: implémentation du modulo 2024-08-06 22:25:27 +02:00
Kazhnuz
ce9c4ee89f chore: correction affichage viewer 2024-08-06 22:25:19 +02:00
Kazhnuz
6d2d3103c6 feat: ajoute un niveau 2024-08-06 22:22:43 +02:00
Kazhnuz
2c726beb79 fix: adapt le viewer 2024-08-06 21:12:28 +02:00
Kazhnuz
34e7f0d97a feat: ameliore la structure 2024-08-06 21:09:49 +02:00
Kazhnuz
ce3d8fda5c feat: ajout d'un viewer rapide 2024-08-06 21:00:05 +02:00
Kazhnuz
8a9e2d7d66 fix: some fixes to structure 2024-08-06 20:59:46 +02:00
Kazhnuz
c71703227e feat(types): ajout des non-biologique 2024-08-06 19:57:05 +02:00
Kazhnuz
de7eb8eac6 feat(types): ajout des types biologiques 2024-08-06 19:50:09 +02:00
20 changed files with 196 additions and 35 deletions

View file

@ -3,10 +3,10 @@ local DataList = require "classes.datalist"
local parseFile = require "libs.filereader" local parseFile = require "libs.filereader"
function BeastFile:new(folder, name) function BeastFile:new(folder, name, forceLevel)
self.filepath = folder .. "/" .. name self.filepath = folder .. "/" .. name
print("Loading " .. self.filepath) print("Loading " .. self.filepath)
self.datas = DataList() self.datas = DataList(forceLevel)
self:readLines() self:readLines()
end end
@ -44,4 +44,10 @@ 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

View file

@ -11,7 +11,10 @@ function StatHolder:applyCommand(command, args)
end end
function StatHolder:reduce(level) function StatHolder:reduce(level)
return self.commands.base + ((self.commands.lvl or 0) * level) + (self.commands.add or 0) + (self.commands.bonus or 0) local stat = 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

View file

@ -60,7 +60,8 @@ function DataList.getHolder(key, value)
return SimpleHolder(key, value) return SimpleHolder(key, value)
end end
function DataList:new() function DataList:new(forceLevel)
self.forceLevel = forceLevel
self.list = {} self.list = {}
self.holders = {} self.holders = {}
self.reducedList = {} self.reducedList = {}
@ -84,6 +85,10 @@ 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)
@ -91,10 +96,33 @@ 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
--TODO if (self.forceLevel ~= nil) then
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)

View file

@ -1,5 +1,43 @@
name;Loup name;Loup
atk.base;60 level;4
competence;morsure type;bete
competence;griffure
competence;dechirement | 10 atk.base;50
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;

5
data/types/aerien.beast Normal file
View file

@ -0,0 +1,5 @@
nomType;aerien
categorie;biologique
faiblesse;air
resistance;terre
skill;Vol;Peut voler

View file

@ -0,0 +1,5 @@
nomType;aquatique
categorie;biologique
faiblesse;foudre
resistance;eau
skill;Aquatique;N'a pas de malus dans l'eau

3
data/types/bete.beast Normal file
View file

@ -0,0 +1,3 @@
nomType;bête
categorie;biologique
faiblesse;metal

View file

@ -0,0 +1,5 @@
nomType;feufolet
categorie;non-biologique
faiblesse;eau
faiblesse;terre
resistance;glace

View file

@ -0,0 +1,6 @@
nomType;gelatineux
categorie;non-biologique
faiblesse;metal
faiblesse;son
resistance;force
resistance;eau

4
data/types/glace.beast Normal file
View file

@ -0,0 +1,4 @@
nomType;créature de glace
categorie;non-biologique
faiblesse;feu
resistance;glace

View file

@ -0,0 +1,2 @@
nomType;humanoïde
categorie;biologique

3
data/types/insecte.beast Normal file
View file

@ -0,0 +1,3 @@
nomType;insecte
categorie;biologique
faiblesse;feu

5
data/types/machine.beast Normal file
View file

@ -0,0 +1,5 @@
nomType;machine
categorie;non-biologique
immunite;poison
faiblesse;foudre
faiblesse;eau

View file

@ -0,0 +1,4 @@
nomType;mineraloïde
categorie;non-biologique
resistance;poison
resistance;feu

3
data/types/reptile.beast Normal file
View file

@ -0,0 +1,3 @@
nomType;reptile
categorie;biologique
faiblesse;glace

4
data/types/vegetal.beast Normal file
View file

@ -0,0 +1,4 @@
nomType;vegetal
categorie;biologique
faiblesse;feu
resistance;vegetal

5
data/types/volute.beast Normal file
View file

@ -0,0 +1,5 @@
nomType;volute
categorie;non-biologique
faiblesse;air
resistance;terre
resistance;metal

View file

@ -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, 0) addCommands(name .. ".lvl", name, value.lvl or 0)
addCommands(name .. ".add", name, 0) addCommands(name .. ".add", name, 0)
addCommands(name .. ".bonus", name, 0) addCommands(name .. ".bonus", name, 0)
end end

View file

@ -1,29 +1,29 @@
return { return {
name={contentType = "string", preParse = true}, name={contentType = "string", preParse = true, to="name"},
nomType={contentType = "string"}, nomType={contentType = "string", to="type"},
categorie={contentType = "string"}, categorie={contentType = "string", to="categorie"},
faiblesses={contentType = "string"}, faiblesse={contentType = "list", args=1},
resistences={contentType = "string"}, resistence={contentType = "list", args=1},
immunites={contentType = "string"}, immunite={contentType = "list", args=1},
level={contentType = "number", default = 0, preParse = true}, level={contentType = "number", default = 0, preParse = true},
atk= {dataType= "stat", modulo= 5, default= 50, max=255, min=10}, pression={contentType = "number", default = 5},
con= {dataType= "stat", modulo= 5, default= 50, max=255, min=10}, atk= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.for"},
hab= {dataType= "stat", modulo= 5, default= 50, max=255, min=10}, con= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.con"},
int= {dataType= "stat", modulo= 5, default= 50, max=255, min=10}, hab= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.hab"},
sag= {dataType= "stat", modulo= 5, default= 50, max=255, min=10}, int= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.int"},
vol= {dataType= "stat", modulo= 5, default= 50, max=255, min=10}, sag= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.sag"},
cha= {dataType= "stat", modulo= 5, default= 50, max=255, min=10}, vol= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.vol"},
dis= {dataType= "stat", modulo= 5, default= 50, max=255, min=10}, cha= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.cha"},
rel= {dataType= "stat", modulo= 5, default= 50, max=255, min=10}, dis= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.dis"},
per= {dataType= "stat", modulo= 5, default= 50, max=255, min=10}, rel= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.rel"},
pv= {dataType= "stat", modulo= 1, default= 12, max=9999999, min=1}, per= {dataType= "stat", modulo= 5, default= 50, max=255, min=10, to="stats.per"},
pe= {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},
eclat= {dataType= "stat", modulo= 1, default= 10, max=200, min=1}, pe= {dataType= "stat", modulo= 1, default= 12, max=9999999, min=1, to="vita.pe", lvl=3},
armurephy= {dataType= "stat", modulo= 1, default= 0, max=9999999, min=0}, eclat= {dataType= "stat", modulo= 1, default= 10, max=200, min=1, to="vita.eclat"},
armurepsy= {dataType= "stat", modulo= 1, default= 0, max=9999999, min=0}, armurephy= {dataType= "stat", modulo= 1, default= 0, max=9999999, min=0, to="armure.phy"},
armurespe= {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, 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}, -- on va le gérer différemment comme du code lol sinon c'est trop relou skill= {dataType= "list", args=2},
armes= {dataType= "list", args=1},
} }

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["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