2020-07-20 12:24:26 +02:00
|
|
|
local ActionParent = require "scenes.battlesystem.controllers.fighters.systems.actions.parent"
|
|
|
|
local ItemAction = ActionParent:extend()
|
2021-03-12 21:14:17 +01:00
|
|
|
local EffectManager = require "game.loot.effectManager"
|
2020-07-20 12:24:26 +02:00
|
|
|
|
2020-08-22 23:10:22 +02:00
|
|
|
function ItemAction:new(fighter, category, item)
|
2020-07-20 12:24:26 +02:00
|
|
|
ItemAction.super.new(self, fighter)
|
2020-08-22 23:10:22 +02:00
|
|
|
print(item)
|
|
|
|
self.category = category
|
2021-03-12 21:14:17 +01:00
|
|
|
self.item = item
|
2020-08-22 23:10:22 +02:00
|
|
|
self.itemdata = game.loot:getItemData(category, item)
|
2021-03-12 21:14:17 +01:00
|
|
|
self.effectManager = EffectManager()
|
|
|
|
self.effectManager:getItemData(category, item)
|
2020-07-20 12:24:26 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function ItemAction:needTarget()
|
2020-08-22 23:10:22 +02:00
|
|
|
return (not self.itemdata.affectEverybody), (self.category == "wisps")
|
2020-07-20 12:24:26 +02:00
|
|
|
end
|
|
|
|
|
2021-03-12 21:14:17 +01:00
|
|
|
function ItemAction:useItemEffect()
|
|
|
|
self.effectManager:applyEffectsBattle(self.target)
|
|
|
|
end
|
|
|
|
|
2020-07-20 12:24:26 +02:00
|
|
|
function ItemAction:startAction()
|
2020-08-22 23:10:22 +02:00
|
|
|
core.debug:print("cbs/action", "Starting item action")
|
|
|
|
self:loadChoregraphy("useitem")
|
2021-03-12 21:14:17 +01:00
|
|
|
game.loot:removeItem(self.category, self.item, 1)
|
2020-07-20 12:24:26 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return ItemAction
|