feat: support multiple target for skills

This commit is contained in:
Kazhnuz 2021-08-08 11:34:54 +02:00
parent 91dda9fa87
commit 8b785eb0a3
2 changed files with 24 additions and 3 deletions

View file

@ -76,6 +76,20 @@ function FighterParent:haveProtecType(type)
return self.abstract:haveProtecType(type) return self.abstract:haveProtecType(type)
end end
function FighterParent:sendDamageToAll(listTarget, value, type, element, isSpecial)
for _, target in ipairs(listTarget) do
self:sendDamage(target, value, type, element, isSpecial)
end
end
function FighterParent:getTargets(ourSide)
if (self.isHero == ourSide) then
return self.turnSystem.player:getTargets(true)
else
return self.turnSystem.ennemies:getTargets(true)
end
end
function FighterParent:sendDamage(target, value, type, element, isSpecial) function FighterParent:sendDamage(target, value, type, element, isSpecial)
local damage = battleutils.computeLaunchingDamages(value, self, isSpecial) local damage = battleutils.computeLaunchingDamages(value, self, isSpecial)

View file

@ -13,6 +13,11 @@ end
function InfosMixin:initTargets(target) function InfosMixin:initTargets(target)
self.target = target self.target = target
self.haveSentDamage = false self.haveSentDamage = false
if (self.target == nil) then
local _, targetEnnemies = self.action:needTarget()
self.targetList = self.fighter:getTargets(targetEnnemies == false)
end
end end
function InfosMixin:getActor(name) function InfosMixin:getActor(name)
@ -30,12 +35,14 @@ function InfosMixin:getTargetActor()
end end
function InfosMixin:sendDamage(power, type, element, isSpecial) function InfosMixin:sendDamage(power, type, element, isSpecial)
if (self.target ~= nil) then if (self.fighter.isAlive) then
if (self.fighter.isAlive) then if (self.target ~= nil) then
self.haveSentDamage = self.fighter:sendDamage(self.target, power, type, element, isSpecial) self.haveSentDamage = self.fighter:sendDamage(self.target, power, type, element, isSpecial)
else else
self.haveSentDamage = false self.haveSentDamage = self.fighter:sendDamageToAll(self.targetList, power, type, element, isSpecial)
end end
else
self.haveSentDamage = false
end end
end end