fix: re-add victory condition

This commit is contained in:
Kazhnuz 2020-07-25 12:15:50 +02:00
parent 40b362543a
commit 1acada1b51
2 changed files with 16 additions and 2 deletions

View file

@ -36,7 +36,7 @@ function TurnController:startBattle()
end end
function TurnController:finishBattle() function TurnController:finishBattle()
self.isBattleActive = false self.isActive = false
self.actionlist = {} self.actionlist = {}
self.hud:movePlayerHUD(false) self.hud:movePlayerHUD(false)
self.scene:finishBattle() self.scene:finishBattle()
@ -90,7 +90,10 @@ function TurnController:removeAllActionsFromFighter(fighterToRemove)
end end
function TurnController:applyDeath() function TurnController:applyDeath()
self.ennemies:applyDeath() local ennemiesAlive = self.ennemies:applyDeath()
if (ennemiesAlive == 0) then
self:finishBattle()
end
self.player:applyDeath() self.player:applyDeath()
end end

View file

@ -18,6 +18,16 @@ function FighterControllerParent:count()
return #self.list return #self.list
end end
function FighterControllerParent:countAlive()
local aliveCount = 0
for i, fighter in ipairs(self.list) do
if (fighter:canFight()) then
aliveCount = aliveCount + 1
end
end
return aliveCount
end
function FighterControllerParent:getTargets(onlyAlive) function FighterControllerParent:getTargets(onlyAlive)
local targetList = {} local targetList = {}
for i, fighter in ipairs(self.list) do for i, fighter in ipairs(self.list) do
@ -32,6 +42,7 @@ function FighterControllerParent:applyDeath()
for i, fighter in ipairs(self.list) do for i, fighter in ipairs(self.list) do
fighter:applyDeath() fighter:applyDeath()
end end
return self:countAlive()
end end
function FighterControllerParent:setActive(activeActor) function FighterControllerParent:setActive(activeActor)