118. One easy way to fix problems like these in general is to cap the amount of times the while loop can run for. So we can introduce a variable called runs
which starts at 0 and goes up by 1 with every iteration of the while loop. If it reaches a certain value, like say 1000, then we'll exit out of the loop no matter if the other condition has been met or not. This looks like this:
function Director:setEnemySpawnsForThisRound()
...
-- Find enemies
local runs = 0
local enemy_list = {}
while points > 0 and runs < 1000 do
...
runs = runs + 1
end
...
end
For the purposes of this game, 1000 is a good number because it's unlikely that we'll run this while loop 1000 times naturally, so it must be the case that if it gets that high then it's stuck in a situation like the one described in the question.