Verified Commit 90cb75eb authored by Lars Mitsem Selbekk's avatar Lars Mitsem Selbekk Committed by Mathias O. Myklebust
Browse files

Fix units not dying from spells

parent f0715abc
......@@ -166,7 +166,7 @@ class BattleController(
val spellsIterator = activeSpells.iterator()
while (spellsIterator.hasNext()) {
val spell = spellsIterator.next()
spell.apply(battle)
applySpell(spell)
if (spell.finished) {
spellsIterator.remove()
}
......@@ -258,7 +258,7 @@ class BattleController(
}
}
battle.activeSpells.second += activeSpell
activeSpell.apply(battle)
applySpell(activeSpell)
}
private fun doAction(action: ActionData) {
......@@ -306,8 +306,8 @@ class BattleController(
)
}
battle.activeSpells.first += activeSpell
activeSpell.apply(battle)
doAction(ActionData.CastSpell(playerID, spellData))
applySpell(activeSpell)
}
}
......@@ -391,4 +391,10 @@ class BattleController(
endTurn()
}
}
private fun applySpell(activeSpell: ActiveSpell<*>) {
activeSpell.apply(battle)
battleMapController.checkForDeadUnits()
battle.getCurrentOutcome()?.let(::resolveGame)
}
}
......@@ -313,6 +313,12 @@ class BattleMapController(
attackUnit(attackingController, targetController)
}
fun checkForDeadUnits() {
unitControllers.values
.filter { it.unitModel.isDead() }
.forEach(::removeUnit)
}
override fun update(dt: Float) {
for (tRow in tileControllers) {
for (tc in tRow) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment