feat: add the wiring to handle item usage in battle
Fixes #44 Fixes #45
This commit is contained in:
parent
7b375bfed2
commit
c6b04006da
6 changed files with 40 additions and 0 deletions
|
@ -18,6 +18,15 @@ function EffectManager:applyEffects(character)
|
||||||
end
|
end
|
||||||
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)
|
function EffectManager:getEffectStrings(character)
|
||||||
local returnString = "No Effect";
|
local returnString = "No Effect";
|
||||||
if (#self.itemdata.effects >= 1) then
|
if (#self.itemdata.effects >= 1) then
|
||||||
|
|
|
@ -13,4 +13,8 @@ function EffectParent:getText()
|
||||||
return "No effect"
|
return "No effect"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function EffectParent:battleCallback(fighter)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
return EffectParent
|
return EffectParent
|
||||||
|
|
|
@ -1,20 +1,29 @@
|
||||||
local ActionParent = require "scenes.battlesystem.controllers.fighters.systems.actions.parent"
|
local ActionParent = require "scenes.battlesystem.controllers.fighters.systems.actions.parent"
|
||||||
local ItemAction = ActionParent:extend()
|
local ItemAction = ActionParent:extend()
|
||||||
|
local EffectManager = require "game.loot.effectManager"
|
||||||
|
|
||||||
function ItemAction:new(fighter, category, item)
|
function ItemAction:new(fighter, category, item)
|
||||||
ItemAction.super.new(self, fighter)
|
ItemAction.super.new(self, fighter)
|
||||||
print(item)
|
print(item)
|
||||||
self.category = category
|
self.category = category
|
||||||
|
self.item = item
|
||||||
self.itemdata = game.loot:getItemData(category, item)
|
self.itemdata = game.loot:getItemData(category, item)
|
||||||
|
self.effectManager = EffectManager()
|
||||||
|
self.effectManager:getItemData(category, item)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ItemAction:needTarget()
|
function ItemAction:needTarget()
|
||||||
return (not self.itemdata.affectEverybody), (self.category == "wisps")
|
return (not self.itemdata.affectEverybody), (self.category == "wisps")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ItemAction:useItemEffect()
|
||||||
|
self.effectManager:applyEffectsBattle(self.target)
|
||||||
|
end
|
||||||
|
|
||||||
function ItemAction:startAction()
|
function ItemAction:startAction()
|
||||||
core.debug:print("cbs/action", "Starting item action")
|
core.debug:print("cbs/action", "Starting item action")
|
||||||
self:loadChoregraphy("useitem")
|
self:loadChoregraphy("useitem")
|
||||||
|
game.loot:removeItem(self.category, self.item, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
return ItemAction
|
return ItemAction
|
||||||
|
|
|
@ -66,6 +66,10 @@ function ChoregraphySystem:sendDamage(power, accuracy, isSpecial, isAerial)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ChoregraphySystem:useItemEffect()
|
||||||
|
self.action:useItemEffect()
|
||||||
|
end
|
||||||
|
|
||||||
function ChoregraphySystem:endStep()
|
function ChoregraphySystem:endStep()
|
||||||
self.currentStep = nil
|
self.currentStep = nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,5 +11,6 @@ actions["sendDamage"] = require(baseURI .. "sendDamage")
|
||||||
actions["setAnimation"] = require(baseURI .. "setAnimation")
|
actions["setAnimation"] = require(baseURI .. "setAnimation")
|
||||||
actions["wait"] = require(baseURI .. "wait")
|
actions["wait"] = require(baseURI .. "wait")
|
||||||
actions["waitActorFinished"] = require(baseURI .. "waitActorFinished")
|
actions["waitActorFinished"] = require(baseURI .. "waitActorFinished")
|
||||||
|
actions["useItemEffect"] = require(baseURI .. "useItemEffect")
|
||||||
|
|
||||||
return actions
|
return actions
|
||||||
|
|
|
@ -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
|
Loading…
Reference in a new issue