Ajout des derniers développement #1
5 changed files with 46 additions and 38 deletions
|
@ -14,7 +14,6 @@ end
|
||||||
|
|
||||||
function Battler:destroy()
|
function Battler:destroy()
|
||||||
Battler.super.destroy(self)
|
Battler.super.destroy(self)
|
||||||
self.world:destroyBattler(self)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Battler:setActive()
|
function Battler:setActive()
|
||||||
|
@ -39,40 +38,4 @@ function Battler:validateAction()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Battler:sendDamage(x, y, value, accuracy, isSpecial, isAerial)
|
|
||||||
local stats = self:getStats()
|
|
||||||
local value = value / 10
|
|
||||||
|
|
||||||
if (isSpecial) then
|
|
||||||
value = value * stats.power
|
|
||||||
else
|
|
||||||
value = value * stats.attack
|
|
||||||
end
|
|
||||||
core.debug:print("battler", "sending " .. value .." damage at position <" .. x .. ";" .. y .. ">")
|
|
||||||
|
|
||||||
local fromEnnemy = self.isEnnemy
|
|
||||||
|
|
||||||
local other = self.world:getActorInCase(x, y, self)
|
|
||||||
if (other ~= nil) then
|
|
||||||
core.debug:print("battler", "sending damage to actor at position <" .. x .. ";" .. y .. ">")
|
|
||||||
other:receiveDamage(value, accuracy, isSpecial, isAerial, fromWho)
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Battler:receiveDamage(value, accuracy, isSpecial, isAerial)
|
|
||||||
local stats = self:getStats()
|
|
||||||
if (fromEnnemy ~= self.isEnnemy) then
|
|
||||||
if (isSpecial) then
|
|
||||||
value = value / stats.mind
|
|
||||||
else
|
|
||||||
value = value / stats.defense
|
|
||||||
end
|
|
||||||
core.debug:print("battler", "taken " .. value .. " damage" )
|
|
||||||
self:setHP(value * -1, true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return Battler
|
return Battler
|
||||||
|
|
|
@ -31,7 +31,7 @@ function FighterParent:setPP(value, relative)
|
||||||
end
|
end
|
||||||
|
|
||||||
function FighterParent:applyDeath()
|
function FighterParent:applyDeath()
|
||||||
if (self.hp <= 0 and self.isAlive) then
|
if (self.abstract.hp <= 0 and self.isAlive) then
|
||||||
self:die()
|
self:die()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -40,6 +40,34 @@ function FighterParent:die()
|
||||||
self.isAlive = false
|
self.isAlive = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function FighterParent:sendDamage(target, value, accuracy, isSpecial, isAerial)
|
||||||
|
local stats = self:getStats()
|
||||||
|
local value = value / 10
|
||||||
|
|
||||||
|
if (isSpecial) then
|
||||||
|
value = value * stats.power
|
||||||
|
else
|
||||||
|
value = value * stats.attack
|
||||||
|
end
|
||||||
|
|
||||||
|
core.debug:print("cbs/battler", "Sending " .. value .." damage at " .. target.name)
|
||||||
|
|
||||||
|
target:receiveDamage(value, accuracy, isSpecial, isAerial, fromWho)
|
||||||
|
end
|
||||||
|
|
||||||
|
function FighterParent:receiveDamage(value, accuracy, isSpecial, isAerial)
|
||||||
|
local stats = self:getStats()
|
||||||
|
|
||||||
|
if (isSpecial) then
|
||||||
|
value = value / stats.mind
|
||||||
|
else
|
||||||
|
value = value / stats.defense
|
||||||
|
end
|
||||||
|
|
||||||
|
core.debug:print("cbs/fighter", "Taken " .. value .. " damage" )
|
||||||
|
self:setHP(value * -1, true)
|
||||||
|
end
|
||||||
|
|
||||||
function FighterParent:getAbstract()
|
function FighterParent:getAbstract()
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,6 +35,11 @@ function VillainFighter:endAction()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function FighterParent:die()
|
||||||
|
self.isAlive = false
|
||||||
|
self.actor:destroy()
|
||||||
|
end
|
||||||
|
|
||||||
-- LIFE FUNCTIONS
|
-- LIFE FUNCTIONS
|
||||||
function VillainFighter:setHP(value, relative)
|
function VillainFighter:setHP(value, relative)
|
||||||
VillainFighter.super.setHP(self, value, relative)
|
VillainFighter.super.setHP(self, value, relative)
|
||||||
|
|
|
@ -90,6 +90,12 @@ function TurnController:removeAllActionsFromFighter(fighterToRemove)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function TurnController:applyDeath()
|
||||||
|
self.ennemies:applyDeath()
|
||||||
|
self.player:applyDeath()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function TurnController:startAction()
|
function TurnController:startAction()
|
||||||
core.debug:print("cbs/turns", "Starting action " .. self.turns.current)
|
core.debug:print("cbs/turns", "Starting action " .. self.turns.current)
|
||||||
local nextAction = self.actionList[self.turns.current]
|
local nextAction = self.actionList[self.turns.current]
|
||||||
|
|
|
@ -18,6 +18,12 @@ function FighterControllerParent:count()
|
||||||
return #self.list
|
return #self.list
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function FighterControllerParent:applyDeath()
|
||||||
|
for i, fighter in ipairs(self.list) do
|
||||||
|
fighter:applyDeath()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function FighterControllerParent:setActive(activeActor)
|
function FighterControllerParent:setActive(activeActor)
|
||||||
self.activeActor = activeActor
|
self.activeActor = activeActor
|
||||||
activeActor:setActive()
|
activeActor:setActive()
|
||||||
|
|
Loading…
Reference in a new issue