Skip to content

Commit

Permalink
fixes bug in pawn
Browse files Browse the repository at this point in the history
  • Loading branch information
fearsd committed Jul 11, 2020
1 parent cd01607 commit c37988d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
3 changes: 1 addition & 2 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from models.gamefield import GameField
from models.player import Player, Computer
from models import Player, Computer, GameField

def game_init():
chess = GameField()
Expand Down
22 changes: 22 additions & 0 deletions models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from .basefigure import BaseFigure
from .bishop import Bishop
from .gamefield import GameField
from .king import King
from .knight import Knight
from .pawn import Pawn
from .player import Player, Computer
from .queen import Queen
from .rook import Rook

__all__ = [
'BaseFigure',
'Bishop',
'GameField',
'King',
'Knight',
'Pawn',
'Player',
'Queen',
'Rook',
'Computer'
]
10 changes: 10 additions & 0 deletions models/pawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,15 @@ def _available_moves(self, field):
moves.append(str(int(self.coord[0]) - 1) + chr(ord(self.coord[1]) - 1))
except KeyError:
pass

i = 0
while i <= len(moves) - 1:
if isinstance(field.field[moves[i]], field.figures):
if field.field[moves[i]].team == self.team:
del moves[i]
else:
i += 1
else:
i += 1

return moves
Empty file removed tests/__init__.py
Empty file.

0 comments on commit c37988d

Please sign in to comment.