47 lines
862 B
Python
47 lines
862 B
Python
from os import system
|
|
from dataclasses import dataclass
|
|
|
|
from board import Board
|
|
|
|
@dataclass
|
|
class Player:
|
|
name: str
|
|
color: str
|
|
|
|
class Chess:
|
|
|
|
def __init__(self, players):
|
|
self.players = players
|
|
|
|
def lose(self, player):
|
|
print(player.name, 'lost.')
|
|
exit(0)
|
|
|
|
def update(self):
|
|
system('clear')
|
|
board.selectPiece(players[0])
|
|
if board.checkCheckMate(players[1].color):
|
|
self.lose(players[1])
|
|
|
|
system('clear')
|
|
board.selectPiece(players[1])
|
|
if board.checkCheckMate(players[0].color):
|
|
self.lose(players[0])
|
|
|
|
def loop(self):
|
|
while True:
|
|
self.update()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
players = (
|
|
Player('Spiller 1', 'white'),
|
|
Player('Spiller 2', 'black'),
|
|
)
|
|
|
|
# game = Chess(('Spiller 1', 'Spiller 2'))
|
|
# game.loop()
|
|
board = Board()
|
|
print(board.selectPiece(players[0], centering=True))
|