2020-07-24 19:12:37 +02:00
|
|
|
ChoregraphyUtils = {}
|
|
|
|
|
2020-07-31 20:06:35 +02:00
|
|
|
-- steps utils
|
|
|
|
|
2020-07-24 19:12:37 +02:00
|
|
|
function ChoregraphyUtils.getStepStructure(stepName)
|
|
|
|
local stepTypeList = require "game.utils.choregraphy.arguments"
|
|
|
|
return stepTypeList[stepName]
|
|
|
|
end
|
|
|
|
|
|
|
|
function ChoregraphyUtils.stepExists(stepName)
|
|
|
|
return (ChoregraphyUtils.getStepStructure(stepName) ~= nil)
|
|
|
|
end
|
|
|
|
|
2020-07-31 20:06:35 +02:00
|
|
|
function ChoregraphyUtils.validateStep(stepBaseDatas)
|
2020-07-24 19:12:37 +02:00
|
|
|
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]
|
|
|
|
|
2020-07-31 20:06:35 +02:00
|
|
|
if (ChoregraphyUtils.validateStep(stepBaseDatas)) then
|
2020-07-24 19:12:37 +02:00
|
|
|
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
|
|
|
|
|
2020-07-31 20:06:35 +02:00
|
|
|
-- QTE utils
|
|
|
|
|
|
|
|
function ChoregraphyUtils.getQteStructure(qteName)
|
|
|
|
local stepTypeList = require "game.utils.choregraphy.qte"
|
|
|
|
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
|
|
|
|
|
2020-07-24 19:12:37 +02:00
|
|
|
return ChoregraphyUtils
|