Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Столкновение игроков с нулевым шлейфом #323

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions paperio/local_runner/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def parse_json(value, default=None):
UP = 'up'
DOWN = 'down'

OPPOSITE_DIRECTION = {LEFT: RIGHT, RIGHT: LEFT, UP: DOWN, DOWN: UP, None: None}

SPEED = toint(os.getenv('SPEED'), 5)
WIDTH = toint(os.getenv('WIDTH'), 30) # должно делиться на 2
BONUS_CHANCE = toint(os.getenv('BONUS_CHANCE'), 500) # 1 из BONUS_CHANCE
Expand Down
9 changes: 8 additions & 1 deletion paperio/local_runner/game_objects/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from helpers import is_intersect
from constants import WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH, PLAYER_COLORS, MAX_TICK_COUNT, BONUS_CHANCE, \
BONUSES_MAX_COUNT, X_CELLS_COUNT, Y_CELLS_COUNT, SPEED, NEUTRAL_TERRITORY_SCORE, ENEMY_TERRITORY_SCORE, \
LINE_KILL_SCORE, SAW_KILL_SCORE, AVAILABLE_BONUSES, SAW_SCORE
LINE_KILL_SCORE, SAW_KILL_SCORE, AVAILABLE_BONUSES, SAW_SCORE, OPPOSITE_DIRECTION
from game_objects.player import Player
from game_objects.bonuses import Nitro, Slowdown, Bonus, Saw

Expand Down Expand Up @@ -134,6 +134,13 @@ def check_loss(self, player, players):
is_loss = True
self.append_event('faced with other player', player, p)
break
else:
zero_tail_opps = [opp for opp in players if opp != player and len(opp.lines) == 0]
for p in zero_tail_opps:
if is_intersect((player.x, player.y), (p.x, p.y)) and player.direction == OPPOSITE_DIRECTION[p.direction]:
is_loss = True
self.append_event('faced with other player', player, p)
break

if len(player.territory.points) == 0:
is_loss = True
Expand Down