fix: re-add victory condition
This commit is contained in:
parent
40b362543a
commit
1acada1b51
2 changed files with 16 additions and 2 deletions
|
@ -36,7 +36,7 @@ function TurnController:startBattle()
|
|||
end
|
||||
|
||||
function TurnController:finishBattle()
|
||||
self.isBattleActive = false
|
||||
self.isActive = false
|
||||
self.actionlist = {}
|
||||
self.hud:movePlayerHUD(false)
|
||||
self.scene:finishBattle()
|
||||
|
@ -90,7 +90,10 @@ function TurnController:removeAllActionsFromFighter(fighterToRemove)
|
|||
end
|
||||
|
||||
function TurnController:applyDeath()
|
||||
self.ennemies:applyDeath()
|
||||
local ennemiesAlive = self.ennemies:applyDeath()
|
||||
if (ennemiesAlive == 0) then
|
||||
self:finishBattle()
|
||||
end
|
||||
self.player:applyDeath()
|
||||
end
|
||||
|
||||
|
|
|
@ -18,6 +18,16 @@ function FighterControllerParent:count()
|
|||
return #self.list
|
||||
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)
|
||||
local targetList = {}
|
||||
for i, fighter in ipairs(self.list) do
|
||||
|
@ -32,6 +42,7 @@ function FighterControllerParent:applyDeath()
|
|||
for i, fighter in ipairs(self.list) do
|
||||
fighter:applyDeath()
|
||||
end
|
||||
return self:countAlive()
|
||||
end
|
||||
|
||||
function FighterControllerParent:setActive(activeActor)
|
||||
|
|
Loading…
Reference in a new issue