Draw when two trons reach the same spot
This commit is contained in:
parent
f692e6c8f2
commit
9d7f7c356f
13
tron/game.py
13
tron/game.py
|
@ -187,14 +187,21 @@ class Game:
|
|||
|
||||
self.next_frame(window)
|
||||
|
||||
for (index, pp) in enumerate(self.pps):
|
||||
for pp in self.pps:
|
||||
if pp.alive:
|
||||
alive_count += 1
|
||||
alive = index
|
||||
alive = pp.id
|
||||
|
||||
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
|
||||
|
||||
if window:
|
||||
|
|
Loading…
Reference in New Issue