This commit is contained in:
Agata Halik 2023-06-09 17:28:57 +02:00
parent 4ec8af3fd7
commit dbc0363aa5
16 changed files with 29 additions and 52 deletions

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

54
game.py
View File

@ -24,64 +24,57 @@ class Game:
if self.color=='white':
self.b.append('r')
else: self.b.append('R')
self.board.calc_moves(self.board.boardlist[row][column].piece, row, column)
elif self.piece == 'pawn':
if self.color=='white':
self.b.append('p')
else:
self.b.append('P')
self.board.calc_moves(self.board.boardlist[row][column].piece, row, column)
elif self.piece == 'knight':
if self.color=='white':
self.b.append('h')
else:
self.b.append('H')
self.board.calc_moves(self.board.boardlist[row][column].piece, row, column)
elif self.piece == 'bishop':
if self.color=='white':
self.b.append('b')
else:
self.b.append('B')
self.board.calc_moves(self.board.boardlist[row][column].piece, row, column)
elif self.piece == 'queen':
if self.color=='white':
self.b.append('q')
else:
self.b.append('Q')
self.board.calc_moves(self.board.boardlist[row][column].piece, row, column)
elif self.piece == 'king':
if self.color=='white':
self.b.append('k')
else:
self.b.append('K')
self.board.calc_moves(self.board.boardlist[row][column].piece, row, column)
else:
# wyswietla puste miejsca
self.b.append(' ')
print(self.b)
self.b = []
self.b.append(' ')
self.b.append('0')
self.b.append('1')
self.b.append('2')
self.b.append('3')
self.b.append('4')
self.b.append('5')
self.b.append('6')
self.b.append('7')
self.b.append('A')
self.b.append('B')
self.b.append('C')
self.b.append('D')
self.b.append('E')
self.b.append('F')
self.b.append('G')
self.b.append('H')
print(self.b)
print('')
# sprawdzenie
# H
# self.board.calc_moves(self.board.boardlist[7][6].piece, 7, 6)
# print(self.board.boardlist[7][6].piece.valid_moves)
# P
# print(self.board.boardlist[6][0].piece.valid_moves)
# R
#print(self.board.boardlist[5][1].piece.color)
#print(self.board.boardlist[5][1].piece.valid_moves)
def currently_available_moves(self):
for row in range(8):
for column in range(8):
if self.board.boardlist[row][column].has_piece():
self.piece = self.board.boardlist[row][column].piece
self.board.calc_moves(self.board.boardlist[row][column].piece, row, column)
def nextMove(self, ruch):
if ruch == 'noone':
self.currently_available_moves()
if ruch == None:
return Board.move_boot(self, 'black')
else:
@ -92,14 +85,3 @@ class Game:
self.color = Board.move_rival(self, self.from_row, self.from_column, self.to_row, self.to_column)
return Board.move_boot(self, self.color)
"""
def make_move_rival(self):
self.przeciwnik = input(str('Podaj ruch: '))
self.from_row = int(self.przeciwnik[0])
self.from_column = int(self.przeciwnik[1])
self.to_row = int(self.przeciwnik[3])
self.to_column = int(self.przeciwnik[4])
return Board.move_rival(self, self.from_row, self.from_column, self.to_row, self.to_column)
def make_move_boot(self, color):
return Board.move_boot(self, color)
"""

11
main.py
View File

@ -1,20 +1,11 @@
from game import Game
#def mainloop(self):
# game = self.game
game = Game()
game2 = Game()
game.printBoard()
print('')
game2.printBoard()
print('')
boot_color = 'white'
#11 21
a=0
ruch='noone'
ruch=None
while True:
print(ruch)
ruch = game.nextMove(ruch)
game.printBoard()
print(ruch)
ruch = game2.nextMove(ruch)
game2.printBoard()

View File

@ -4,8 +4,6 @@ class Piece:
self.color = color
self.valid_moves = []
self.moved = False
# kierunek pionkow, czarne w górę, białe w dół
if color == 'white':
self.pawn_direction = -1
else:

View File

@ -15,13 +15,13 @@ class Square:
if self.has_piece() is True and self.piece.color != color:
return True
def empty_or_rival(self, color): # sprawdz
if self.has_piece() is False or self.is_rival(color): # 1 has piece (color)
def empty_or_rival(self, color):
if self.has_piece() is False or self.is_rival(color):
return True
else:
return False
def empty_or_rival_knight(self, color): # sprawdz
if self.has_piece() is False or self.is_rival(color): # 1 has piece (color)
def empty_or_rival_knight(self, color):
if self.has_piece() is False or self.is_rival(color):
return True
else:
return False