diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/conditions.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/conditions.lua new file mode 100644 index 0000000..a25f4bb --- /dev/null +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/conditions.lua @@ -0,0 +1,18 @@ +local Conditions = {} + +function Conditions.sentDamage(cond, predicate, asker) + return asker.haveSentDamage +end + +function Conditions.qteSuccess(cond, predicate, asker) + return asker:isQteSuccess(tonumber(cond[2])) +end + +function Conditions.qteFailure(cond, predicate, asker) + return (Conditions.isQteSuccess(cond, predicate, asker) == false) +end +function Conditions.none(cond, predicate, asker) + return true +end + +return Conditions \ No newline at end of file diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/init.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/init.lua index 75108fb..721c54a 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/init.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/init.lua @@ -3,6 +3,9 @@ local ChoregraphySystem = Object:extend() local stepObjectList = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.step" local qteObjectList = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.qte" +local Predicate = require "birb.classes.predicate" +local Conditions = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.conditions" + local ACTION_STARTED = 1 local ACTION_FINISHED = 2 @@ -68,18 +71,8 @@ function ChoregraphySystem:parseStep(step) end function ChoregraphySystem:checkCondition(condition) - local conditionArgs = utils.string.split(condition, ":") - local success = true - - if (conditionArgs[1] == "sentDamage" and (not self.haveSentDamage)) then - success = false - elseif (conditionArgs[1] == "qteSuccess" and (not self.qte.list[tonumber(conditionArgs[2])])) then - success = false - elseif (conditionArgs[1] == "qteFailure" and (self.qte.list[tonumber(conditionArgs[2])])) then - success = false - end - - return success + local predicate = Predicate.createPredicate(condition, Conditions, self) + return predicate:solve() end function ChoregraphySystem:addQTE(action, origin, qteBaseData, blockProcess, tag) @@ -93,6 +86,10 @@ function ChoregraphySystem:addQTE(action, origin, qteBaseData, blockProcess, tag end end +function ChoregraphySystem:isQteSuccess(qteID) + return self.qte.list[qteID] +end + function ChoregraphySystem:endQte(success) self.qte.current = nil self.qte.wasSuccess = success