def action(self) -> Action:
return DeathAction()
-class DeadTile(Tile):
+class DeadTile(SnakeTile):
def char(self) -> str:
return 'X'
- def action(self) -> Action:
- return DeathAction()
-
class FruitTile(Tile):
def __init__(self, life):
self.life = life
if any(snake.segments[-1] == s.segments[-1] for s in actions if snake is not s):
actions[snake] = DeathAction()
for snake in actions:
- r, c = snake.segments[-1]
+ if snake.turbo:
+ snake.turbo -= 1
+ for snake in actions:
action = actions[snake]
- if action.is_turbo():
- snake.turbo = 100
if not action.is_score():
r0, c0 = snake.segments[0]
self.tiles[r0][c0] = EmptyTile()
snake.shrink()
+ for snake in actions:
+ r, c = snake.segments[-1]
+ action = actions[snake]
self.tiles[r][c] = SnakeTile(snake)
+ if action.is_turbo():
+ snake.turbo = 100
if action.is_teleport():
self.tiles[r][c] = EmptyTile()
r, c = snake.segments[-1] = action.row, action.column
if action.is_death():
- self.tiles[r][c] = DeadTile()
+ self.tiles[r][c] = DeadTile(snake)
snake.alive = False
if not any(snake.alive for snake in self.snakes):
self.game_over()
- if snake.turbo:
- snake.turbo -= 1
if self.score() > self.highscore:
self.highscore = self.score()
self.write_highscore()