def promptUserForSetup() -> othello_logic.OthelloGamestate: """This method prompts the user to enter the board size, the piece that moves first, the position of the starting pieces, and the win condition of the game""" print("FULL") row = int(input("")) col = int(input("")) first_move = input("") position = input("") win_condition = input("") oth = othello_logic.OthelloGamestate(row, col, first_move, position, win_condition) return oth
def _setup_game(self): launcher = LaunchScreen() launcher.show() if launcher._started: self._game = othello_logic.OthelloGamestate( launcher.num_rows(), launcher.num_col(), launcher.first_move(), launcher.left_corner(), launcher.win_condition()) self._num_rows = self._game.get_num_row() self._num_col = self._game.get_num_col() self._new_game() if (self._game.win_condition == ">"): self._win_label.config( text="Win condition: color with the most pieces wins") else: self._win_label.config( text="Win condition: color with the least pieces wins") self._draw_board()
def _setup_game(self) -> None: '''shows the launch screen when the settings button is clicked. Creates a new othello game with the inputs that the user entered''' launcher = LaunchScreen() launcher.show() if launcher._started: self._game = othello_logic.OthelloGamestate( launcher.num_rows(), launcher.num_col(), launcher.first_move(), launcher.left_corner(), launcher.win_condition()) self._num_rows = self._game.get_num_row() self._num_col = self._game.get_num_col() self._new_game() if (self._game.win_condition == ">"): self._win_label.config( text="Win condition: color with the most pieces wins") else: self._win_label.config( text="Win condition: color with the least pieces wins") self._draw_board()
def __init__(self): '''Sets up the initial state of the game. If the user does not choose to alter the game settings, the board defautls to a 4 x 4 gameboard''' self._game = othello_logic.OthelloGamestate(4, 4, "B", "B", ">") self._num_rows = self._game.get_num_row() self._num_col = self._game.get_num_col() self._root_window = tkinter.Tk() # Create and grid all the LABELS for the game game_label = tkinter.Label(master=self._root_window, text="Othello Game Full", font=("Helvetica", 24)) game_label.grid( row=0, column=0, padx=10, pady=10, columnspan=4, ) self._win_label = tkinter.Label( master=self._root_window, text="Win condition: color with the most pieces wins", font=("Helvetica", 16)) self._win_label.grid( row=1, column=0, padx=10, pady=10, columnspan=4, ) self._score_label = tkinter.Label(master=self._root_window, text="Black: 2 White: 2", font=("Helvetica", 16)) self._score_label.grid(row=2, column=0, padx=10, pady=10) self._turn_label = tkinter.Label(master=self._root_window, text="Turn: {}".format( self._game.get_current_color()), font=("Helvetica", 16)) self._turn_label.grid(row=2, column=1, padx=10, pady=10) # Create and grid the settings and clear board buttons setup_button = tkinter.Button( master=self._root_window, text="Settings", font=("Helvetica", 16), command=self._setup_game, ) setup_button.grid(row=2, column=2, padx=10, pady=10) new_game_button = tkinter.Button( master=self._root_window, text="Clear Board", font=("Helvetica", 16), command=self._new_game, ) new_game_button.grid(row=2, column=3, padx=10, pady=10) # creates and grids the canvas, which draws the game board self._canvas = tkinter.Canvas(master=self._root_window, width=600, height=600, background="#FFFFFF") self._canvas.grid(row=3, column=0, columnspan=4, padx=10, pady=10, sticky=tkinter.N + tkinter.S + tkinter.E + tkinter.W) # configures the rows and columns to resize accordingly. self._root_window.rowconfigure(3, weight=1) self._root_window.columnconfigure(0, weight=1) self._root_window.columnconfigure(1, weight=1) self._root_window.columnconfigure(2, weight=1) self._root_window.columnconfigure(3, weight=1) self._canvas.bind('<Configure>', self._canvas_resized) self._canvas.bind('<Button-1>', self._canvas_clicked) self._root_window.update() self._draw_board()
def __init__(self): self._game = othello_logic.OthelloGamestate(10, 10, "B", "B", ">") self._num_rows = self._game.get_num_row() self._num_col = self._game.get_num_col() self._root_window = tkinter.Tk() game_label = tkinter.Label(master=self._root_window, text="Othello Game Full", font=("Helvetica", 24)) game_label.grid( row=0, column=0, padx=10, pady=10, columnspan=4, ) self._win_label = tkinter.Label( master=self._root_window, text="Win condition: color with the most pieces wins", font=("Helvetica", 16)) self._win_label.grid( row=1, column=0, padx=10, pady=10, columnspan=4, ) self._score_label = tkinter.Label(master=self._root_window, text="Black: 2 White: 2", font=("Helvetica", 16)) self._score_label.grid(row=2, column=0, padx=10, pady=10) self._turn_label = tkinter.Label(master=self._root_window, text="Turn: {}".format( self._game.get_current_color()), font=("Helvetica", 16)) self._turn_label.grid(row=2, column=1, padx=10, pady=10) setup_button = tkinter.Button( master=self._root_window, text="Settings", font=("Helvetica", 16), command=self._setup_game, ) setup_button.grid(row=2, column=2, padx=10, pady=10) new_game_button = tkinter.Button( master=self._root_window, text="Clear Board", font=("Helvetica", 16), command=self._new_game, ) new_game_button.grid(row=2, column=3, padx=10, pady=10) self._canvas = tkinter.Canvas(master=self._root_window, width=600, height=600, background="#FFFFFF") self._canvas.grid(row=3, column=0, columnspan=4, padx=10, pady=10, sticky=tkinter.N + tkinter.S + tkinter.E + tkinter.W) self._canvas.bind('<Configure>', self._canvas_resized) self._canvas.bind('<Button-1>', self._canvas_clicked) self._root_window.update() self._draw_board()