2023-06-08 16:02:55 +02:00
|
|
|
from board import Board
|
2023-06-09 22:48:38 +02:00
|
|
|
from move import Move
|
2023-06-08 16:02:55 +02:00
|
|
|
class Game:
|
|
|
|
def __init__(self):
|
|
|
|
self.board = Board()
|
2023-06-08 21:37:15 +02:00
|
|
|
def printBoard(self):
|
2023-06-08 16:02:55 +02:00
|
|
|
self.b = []
|
|
|
|
for row in range(8):
|
2023-06-19 20:11:22 +02:00
|
|
|
if row == 0: self.b.append('0')
|
2023-06-08 16:02:55 +02:00
|
|
|
if row == 1: self.b.append('1')
|
2023-06-19 20:11:22 +02:00
|
|
|
if row == 2: self.b.append('2')
|
2023-06-08 16:02:55 +02:00
|
|
|
if row == 3: self.b.append('3')
|
2023-06-19 20:11:22 +02:00
|
|
|
if row == 4: self.b.append('4')
|
2023-06-08 16:02:55 +02:00
|
|
|
if row == 5: self.b.append('5')
|
2023-06-19 20:11:22 +02:00
|
|
|
if row == 6: self.b.append('6')
|
2023-06-08 16:02:55 +02:00
|
|
|
if row == 7: self.b.append('7')
|
|
|
|
for column in range(8):
|
|
|
|
if self.board.boardlist[row][column].has_piece():
|
|
|
|
self.piece = self.board.boardlist[row][column].piece.name
|
|
|
|
self.color=self.board.boardlist[row][column].piece.color
|
|
|
|
if self.piece == 'rook':
|
2023-06-19 20:11:22 +02:00
|
|
|
if self.color =='white':
|
2023-06-08 16:02:55 +02:00
|
|
|
self.b.append('r')
|
|
|
|
else: self.b.append('R')
|
|
|
|
elif self.piece == 'pawn':
|
2023-06-19 20:11:22 +02:00
|
|
|
if self.color =='white':
|
2023-06-08 16:02:55 +02:00
|
|
|
self.b.append('p')
|
|
|
|
else:
|
|
|
|
self.b.append('P')
|
|
|
|
elif self.piece == 'knight':
|
2023-06-19 20:11:22 +02:00
|
|
|
if self.color =='white':
|
2023-06-08 16:02:55 +02:00
|
|
|
self.b.append('h')
|
|
|
|
else:
|
|
|
|
self.b.append('H')
|
|
|
|
elif self.piece == 'bishop':
|
2023-06-19 20:11:22 +02:00
|
|
|
if self.color =='white':
|
2023-06-08 16:02:55 +02:00
|
|
|
self.b.append('b')
|
|
|
|
else:
|
|
|
|
self.b.append('B')
|
|
|
|
elif self.piece == 'queen':
|
2023-06-19 20:11:22 +02:00
|
|
|
if self.color =='white':
|
2023-06-08 16:02:55 +02:00
|
|
|
self.b.append('q')
|
|
|
|
else:
|
|
|
|
self.b.append('Q')
|
|
|
|
elif self.piece == 'king':
|
2023-06-19 20:11:22 +02:00
|
|
|
if self.color =='white':
|
2023-06-08 16:02:55 +02:00
|
|
|
self.b.append('k')
|
|
|
|
else:
|
|
|
|
self.b.append('K')
|
|
|
|
else:
|
|
|
|
self.b.append(' ')
|
|
|
|
print(self.b)
|
|
|
|
self.b = []
|
|
|
|
self.b.append(' ')
|
2023-06-09 17:28:57 +02:00
|
|
|
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')
|
2023-06-08 16:02:55 +02:00
|
|
|
print(self.b)
|
2023-06-09 00:22:01 +02:00
|
|
|
print('')
|
2023-06-09 17:28:57 +02:00
|
|
|
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
|
2023-06-13 00:08:24 +02:00
|
|
|
Move.calc_moves(self, self.piece, row, column)
|
2023-06-08 21:37:15 +02:00
|
|
|
def nextMove(self, ruch):
|
2023-06-09 17:28:57 +02:00
|
|
|
self.currently_available_moves()
|
|
|
|
if ruch == None:
|
2023-06-09 22:48:38 +02:00
|
|
|
return Move.move_boot(self, 'black')
|
2023-06-08 21:37:15 +02:00
|
|
|
else:
|
2023-06-09 23:16:08 +02:00
|
|
|
self.color = Move.move_rival(self, ruch)
|
2023-06-15 16:22:32 +02:00
|
|
|
self.currently_available_moves()
|
2023-06-19 20:11:22 +02:00
|
|
|
return Move.move_boot(self, self.color)
|