def promote(self, piece): done = False # freeze normal execution (in main), wait for player to decide which piece take while not done: pressed, events = Interface.run() # display everything Board.display() self.menu.display() self.ChessGame.display() self.pmenu.display() self.pmenu.react_events(events, pressed) if self.pmenu.state == 'done': done = True piece_name = self.pmenu.piece_name self.pmenu.state = 'wait' # create new piece if piece_name == 'queen': new_piece = Queen(piece.coord, piece.color) elif piece_name == 'bishop': new_piece = Bishop(piece.coord, piece.color) elif piece_name == 'rock': new_piece = Rock(piece.coord, piece.color) elif piece_name == 'knight': new_piece = Knight(piece.coord, piece.color) # remove pawn self.player.pieces.remove(piece) # add new piece self.player.pieces.append(new_piece) Interface.add_resizable_objs([new_piece])
def react_events(self, events, pressed): if self.state == 'start': if self.button_start.pushed(events): self.state = 'run' self.ChessGame.set_players() # re-add pieces Interface.add_resizable_objs( self.ChessGame.players['white'].pieces) Interface.add_resizable_objs( self.ChessGame.players['black'].pieces)
}, { 'name': 'rock', 'coord': (6, 0), 'c': 'black' }, { 'name': 'rock', 'coord': (7, 0), 'c': 'black' }, ] ChessGame.set_players() #white_config=white_conf, black_config=black_conf) Interface.add_resizable_objs(ChessGame.players['white'].pieces) Interface.add_resizable_objs(ChessGame.players['black'].pieces) LivePlay.ChessGame = ChessGame LivePlay.menu = menu # agent_white = bruteforce.Agent('white', ChessGame) # agent_black = bruteforce.Agent('black', ChessGame) ChessGame.set_control_methods(LivePlay('white'), LivePlay('black')) # Tests.run(ChessGame) while Interface.running: pressed, events = Interface.run() Board.display()
from interface import Interface Interface.setup((3000, 1600), 'GUI Editor') from menu import Menu #from testfile import Testfile menu = Menu() from editor import Editor Interface.add_resizable_objs([Editor]) #tf = Testfile((100,100)) while Interface.running: pressed, events = Interface.run() # #tf.display() # menu.run(events, pressed) if menu.state == 'end': Interface.running = False