Fix invalid index

This commit is contained in:
Matt Soucy 2019-11-24 16:54:09 -05:00
parent 80a5203c4b
commit e9f4b367a6

View File

@ -58,7 +58,7 @@ class Engine(private vararg val creatures : Pair<Creature, Int>) {
private fun getTargetList(target : Target, selected : Int) : List<Int> { private fun getTargetList(target : Target, selected : Int) : List<Int> {
return when(target) { return when(target) {
Target.Self -> listOf(currentCreature) Target.Self -> listOf(currentCreature)
Target.Selected -> listOf(selected) Target.Selected -> if (selected == -1) { listOf() } else { listOf(selected) }
Target.Others -> creatures.indices.filter { it != currentCreature } Target.Others -> creatures.indices.filter { it != currentCreature }
Target.Opponents -> creatures.indices.filter { creatures[it].second != creatures[currentCreature].second } Target.Opponents -> creatures.indices.filter { creatures[it].second != creatures[currentCreature].second }
Target.All -> creatures.indices.toList() Target.All -> creatures.indices.toList()