feat: add the wiring to handle item usage in battle

Fixes #44
Fixes #45
This commit is contained in:
Kazhnuz 2021-03-12 21:14:17 +01:00
parent 7b375bfed2
commit c6b04006da
6 changed files with 40 additions and 0 deletions

View file

@ -18,6 +18,15 @@ function EffectManager:applyEffects(character)
end
end
function EffectManager:applyEffectsBattle(battleTarget)
local character = battleTarget.abstract
for _, effect in ipairs(self.itemdata.effects) do
local effectInstance = self:getEffectObject(effect, character)
effectInstance:applyEffect()
effectInstance:battleCallback(battleTarget)
end
end
function EffectManager:getEffectStrings(character)
local returnString = "No Effect";
if (#self.itemdata.effects >= 1) then

View file

@ -13,4 +13,8 @@ function EffectParent:getText()
return "No effect"
end
function EffectParent:battleCallback(fighter)
end
return EffectParent

View file

@ -1,20 +1,29 @@
local ActionParent = require "scenes.battlesystem.controllers.fighters.systems.actions.parent"
local ItemAction = ActionParent:extend()
local EffectManager = require "game.loot.effectManager"
function ItemAction:new(fighter, category, item)
ItemAction.super.new(self, fighter)
print(item)
self.category = category
self.item = item
self.itemdata = game.loot:getItemData(category, item)
self.effectManager = EffectManager()
self.effectManager:getItemData(category, item)
end
function ItemAction:needTarget()
return (not self.itemdata.affectEverybody), (self.category == "wisps")
end
function ItemAction:useItemEffect()
self.effectManager:applyEffectsBattle(self.target)
end
function ItemAction:startAction()
core.debug:print("cbs/action", "Starting item action")
self:loadChoregraphy("useitem")
game.loot:removeItem(self.category, self.item, 1)
end
return ItemAction

View file

@ -66,6 +66,10 @@ function ChoregraphySystem:sendDamage(power, accuracy, isSpecial, isAerial)
end
end
function ChoregraphySystem:useItemEffect()
self.action:useItemEffect()
end
function ChoregraphySystem:endStep()
self.currentStep = nil
end

View file

@ -11,5 +11,6 @@ actions["sendDamage"] = require(baseURI .. "sendDamage")
actions["setAnimation"] = require(baseURI .. "setAnimation")
actions["wait"] = require(baseURI .. "wait")
actions["waitActorFinished"] = require(baseURI .. "waitActorFinished")
actions["useItemEffect"] = require(baseURI .. "useItemEffect")
return actions

View file

@ -0,0 +1,13 @@
local StepParent = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.step.parent"
local UseItemEffect = StepParent:extend()
function UseItemEffect:new(system, args)
UseItemEffect.super.new(self, system, args)
end
function UseItemEffect:start()
self.choregraphy:useItemEffect()
self:finish()
end
return UseItemEffect