chore: port to parser system

This commit is contained in:
Kazhnuz 2021-05-15 22:48:25 +02:00
parent aa9140406f
commit c10d58e604
13 changed files with 57 additions and 257 deletions

View file

@ -1,4 +1,6 @@
return {
headings = {"name", "condition"},
argumentLists = {
["wait"] = {"duration"},
["addGFX"] = {'sprite', "origin", "x", "y", "affectedByDirection", 'blockProcess'},
["playSFX"] = {"sfx"},
@ -12,6 +14,8 @@ return {
["addQTE"] = {"qteData", "origin", "blockProcess"},
["useItemEffect"] = {},
--[name] = {args},
},
argumentWrapper = "arguments",
}
-- The "origin" argument can have the different values

View file

@ -1,5 +1,9 @@
return {
headings = {"type"},
argumentLists = {
["normal"] = {"category", "name", "number"},
["boss"] = {"category", "name", "pvFactor", "statFactor", "cheapEffect"},
["rival"] = {"character", "level", "pvFactor"}
},
argumentWrapper = "",
}

View file

@ -1,4 +1,6 @@
return {
headings = {"name", "condition"},
argumentLists = {
["wait"] = {"duration"},
["simpleMessage"] = {"message"},
["dialogBox"] = {"message", "title", "avatar"},
@ -9,6 +11,8 @@ return {
["teleport"] = {"area", "x", "y", "charDir"},
["showGFX"] = {"x", "y", "spritename"}
--[name] = {args...},
},
argumentWrapper = "arguments",
}
-- The "origin" argument can have the different values

View file

@ -1,6 +1,10 @@
return {
headings = {"type"},
argumentLists = {
["heal"] = {"healType", "computationMode", "value"},
["setStatus"] = {"status", "set"},
["protectElement"] = {"element"},
["blockStatus"] = {"blockWhat"},
},
argumentWrapper = "",
}

View file

@ -1,3 +1,7 @@
return {
headings = {"name"},
argumentLists = {
["simplePrompt"] = {"key", "duration"}
},
argumentWrapper = "arguments",
}

View file

@ -1,7 +1,6 @@
local EventManager = Object:extend()
local stepObjectList = require "game.events.event"
local eventUtils = require "game.events.utils"
local Conditions = require "game.events.conditions"
@ -73,7 +72,7 @@ end
function EventManager:switchStep()
if self:haveNextStep() then
self.currentStepId = self.currentStepId + 1
local stepData = eventUtils.getStepDatas(self.stepList[self.currentStepId])
local stepData = core.datas:parse("eventstep", self.stepList[self.currentStepId])
core.debug:print("event", "Starting step " .. stepData.name)
if (not self:testCondition(stepData.condition)) then
self:switchStep()

View file

@ -1,45 +0,0 @@
local EventUtils = {}
-- steps utils
function EventUtils.getStepStructure(stepName)
local stepTypeList = require "datas.parsers.eventstep"
return stepTypeList[stepName]
end
function EventUtils.stepExists(stepName)
return (EventUtils.getStepStructure(stepName) ~= nil)
end
function EventUtils.validateStep(stepBaseDatas)
local structure = EventUtils.getStepStructure(stepBaseDatas[1])
if (structure == nil) then
return false
else
return ((#structure + 2) == #stepBaseDatas)
end
end
function EventUtils.getStepDatas(stepBaseDatas)
local stepData = {}
stepData.name = stepBaseDatas[1]
if (EventUtils.validateStep(stepBaseDatas)) then
stepData.condition = stepBaseDatas[2]
local structure = EventUtils.getStepStructure(stepData.name)
stepData.arguments = {}
for i, argumentName in ipairs(structure) do
local argumentContent = stepBaseDatas[i + 2]
stepData.arguments[argumentName] = argumentContent
end
return stepData
else
error("L'étape " .. stepData.name .. " à un nbr d'argument incorrect")
end
end
return EventUtils

View file

@ -1,6 +1,5 @@
local EffectManager = Object:extend()
local itemutils = require "game.utils.items"
local effectList = require "game.loot.effects"
function EffectManager:new()
@ -45,7 +44,7 @@ function EffectManager:getEffectStrings(character)
end
function EffectManager:getEffectObject(rawEffectData, character, duration)
local effect = itemutils.getItemEffectData(rawEffectData)
local effect = core.datas:parse("itemeffects", rawEffectData)
if (effectList[effect.type] ~= nil) then
return effectList[effect.type](effect, character, duration)
else

View file

@ -1,43 +1,3 @@
local BattleUtils = {}
-- ENNEMY FUNCTIONS
function BattleUtils.getEnnemyTypeStructure(type)
local typeList = require "datas.parsers.ennemytype"
return typeList[type]
end
function BattleUtils.ennemyTypeExists(type)
return (BattleUtils.getEnnemyTypeStructure(type) ~= nil)
end
function BattleUtils.validateEnnemyType(ennemyBaseData)
local structure = BattleUtils.getEnnemyTypeStructure(ennemyBaseData[1])
if (structure == nil) then
return false
else
return ((#structure + 1) == #ennemyBaseData)
end
end
function BattleUtils.getEnnemyData(ennemyBaseData)
local ennemyData = {}
ennemyData.type = ennemyBaseData[1]
if (BattleUtils.validateEnnemyType(ennemyBaseData)) then
local structure = BattleUtils.getEnnemyTypeStructure(ennemyData.type)
for i, argumentName in ipairs(structure) do
local argumentContent = ennemyBaseData[i + 1]
ennemyData[argumentName] = argumentContent
end
return ennemyData
else
error("Le type d'ennemy " .. ennemyData.type .. " à un nbr d'argument incorrect")
end
end
return BattleUtils

View file

@ -1,89 +0,0 @@
local ChoregraphyUtils = {}
-- steps utils
function ChoregraphyUtils.getStepStructure(stepName)
local stepTypeList = require "datas.parsers.choregraphystep"
return stepTypeList[stepName]
end
function ChoregraphyUtils.stepExists(stepName)
return (ChoregraphyUtils.getStepStructure(stepName) ~= nil)
end
function ChoregraphyUtils.validateStep(stepBaseDatas)
local structure = ChoregraphyUtils.getStepStructure(stepBaseDatas[1])
if (structure == nil) then
return false
else
return ((#structure + 2) == #stepBaseDatas)
end
end
function ChoregraphyUtils.getStepDatas(stepBaseDatas)
local stepData = {}
stepData.name = stepBaseDatas[1]
if (ChoregraphyUtils.validateStep(stepBaseDatas)) then
stepData.condition = stepBaseDatas[2]
local structure = ChoregraphyUtils.getStepStructure(stepData.name)
stepData.arguments = {}
for i, argumentName in ipairs(structure) do
local argumentContent = stepBaseDatas[i + 2]
stepData.arguments[argumentName] = argumentContent
end
return stepData
else
error("L'étape " .. stepData.name .. " à un nbr d'argument incorrect")
end
end
-- QTE utils
function ChoregraphyUtils.getQteStructure(qteName)
local stepTypeList = require "datas.parsers.qtesteps"
return stepTypeList[qteName]
end
function ChoregraphyUtils.qteExists(qteName)
return (ChoregraphyUtils.getQteStructure(qteName) ~= nil)
end
function ChoregraphyUtils.validateQte(qteBaseDatas)
local structure = ChoregraphyUtils.getQteStructure(qteBaseDatas[1])
if (structure == nil) then
return false
else
return ((#structure + 1) == #qteBaseDatas)
end
end
function ChoregraphyUtils.getQteDatas(qteBaseDatas)
local qteData = {}
qteData.name = qteBaseDatas[1]
if (ChoregraphyUtils.validateQte(qteBaseDatas)) then
local structure = ChoregraphyUtils.getQteStructure(qteData.name)
qteData.arguments = {}
for i, argumentName in ipairs(structure) do
local argumentContent = qteBaseDatas[i + 1]
qteData.arguments[argumentName] = argumentContent
end
return qteData
else
error("Le QTE " .. qteData.name .. " à un nbr d'argument incorrect")
end
end
return ChoregraphyUtils

View file

@ -1,41 +0,0 @@
local ItemUtils = {}
-- VALIDATION FUNCTIONS
function ItemUtils.getItemEffectStructure(type)
local typeList = require "datas.parsers.itemeffects"
return typeList[type]
end
function ItemUtils.itemEffectExists(type)
return (ItemUtils.getItemEffectStructure(type) ~= nil)
end
function ItemUtils.validateItemEffect(effectBaseData)
local structure = ItemUtils.getItemEffectStructure(effectBaseData[1])
if (structure == nil) then
return false
else
return ((#structure + 1) == #effectBaseData)
end
end
function ItemUtils.getItemEffectData(effectBaseData)
local effectData = {}
effectData.type = effectBaseData[1]
if (ItemUtils.validateItemEffect(effectBaseData)) then
local structure = ItemUtils.getItemEffectStructure(effectData.type)
for i, argumentName in ipairs(structure) do
local argumentContent = effectBaseData[i + 1]
effectData[argumentName] = argumentContent
end
return effectData
else
error("Le type d'effet d'objet " .. effectData.type .. " à un nbr d'argument incorrect")
end
end
return ItemUtils

View file

@ -3,8 +3,6 @@ local EnnemyController = FighterControllerParent:extend()
local Villain = require "scenes.battlesystem.controllers.fighters.villain"
local battleutils = require "game.utils.battle"
function EnnemyController:new(owner, battleData)
self.super.new(self, owner)
self:initVillains(battleData)
@ -12,7 +10,7 @@ end
function EnnemyController:initVillains(battleData)
for i,ennemyBaseData in ipairs(battleData.ennemies) do
local ennData = battleutils.getEnnemyData(ennemyBaseData)
local ennData = core.datas:parse("ennemytype", ennemyBaseData)
if (ennData.type == "normal") then
self:addVillain(ennData)
elseif (ennData.type == "boss") then

View file

@ -1,6 +1,5 @@
local ChoregraphySystem = Object:extend()
local choregraphyUtils = require "game.utils.choregraphy"
local stepObjectList = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.step"
local qteObjectList = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.qte"
@ -38,7 +37,7 @@ end
function ChoregraphySystem:switchStep()
if self:haveNextStep() then
self.currentStepId = self.currentStepId + 1
local stepData = choregraphyUtils.getStepDatas(self.stepList[self.currentStepId])
local stepData = core.datas:parse("choregraphystep", self.stepList[self.currentStepId])
core.debug:print("cbs/choregraphy", "Starting step " .. stepData.name)
if (stepObjectList[stepData.name] ~= nil and self:checkCondition(stepData.condition)) then
self.currentStep = stepObjectList[stepData.name](self, stepData.arguments)
@ -58,7 +57,7 @@ function ChoregraphySystem:checkCondition(condition)
end
function ChoregraphySystem:addQTE(action, origin, qteBaseData, blockProcess)
local qteData = choregraphyUtils.getQteDatas(qteBaseData)
local qteData = core.datas:parse("qtesteps", qteBaseData)
if (qteObjectList[qteData.name] ~= nil) then
core.debug:print("cbs/choregraphy", "Starting qte " .. qteData.name)
self.qte.current = qteObjectList[qteData.name](self, qteData.arguments, 0, 0)