Draw when two trons reach the same spot

This commit is contained in:
Thomas Forgione 2019-03-13 22:32:11 +01:00
parent f692e6c8f2
commit 9d7f7c356f
No known key found for this signature in database
GPG Key ID: BFD17A2D71B3B5E7

View File

@ -187,14 +187,21 @@ class Game:
self.next_frame(window) self.next_frame(window)
for (index, pp) in enumerate(self.pps): for pp in self.pps:
if pp.alive: if pp.alive:
alive_count += 1 alive_count += 1
alive = index alive = pp.id
if alive_count <= 1: if alive_count <= 1:
if alive_count == 1: if alive_count == 1:
self.winner = alive + 1 # If player one and two share the same position, it will
# mean that they reached the same tile at the same
# moment, so it's really a draw.
if self.pps[0].position[0] != self.pps[1].position[0] or \
self.pps[0].position[1] != self.pps[1].position[1]:
# Otherwise, the winner is the player that is still alive.
self.winner = alive
break break
if window: if window: