improvement: port battlesystem to predicate
This commit is contained in:
parent
4445fec8d2
commit
deda8a7a76
2 changed files with 27 additions and 12 deletions
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue