Skip to content

Commit

Permalink
feat(UI-UX): add draw message and final playfield to endscreen [TTTK-83]
Browse files Browse the repository at this point in the history
  • Loading branch information
HOOK-Hawkins committed Mar 17, 2024
1 parent f44ea57 commit 0e8f804
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
23 changes: 16 additions & 7 deletions UI/endscreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,27 @@
#from .field_frame import Field

class EndScreen(base_frame):
def __init__(self, master, win:bool, *args, **kwargs):
def __init__(self, master, win:bool, winner, final_playfield, *args, **kwargs):
super().__init__(master)
self._create_widgets(win)
self._create_widgets(win, winner, final_playfield)
self._display_widgets()

def _create_widgets(self, win:bool):
message = "You won the game!" if win else "You lost the game!"
def _create_widgets(self, win:bool, winner, fp):
message = "You won the game!" if win else "It's a draw!\nThat's barely more than a loss." if winner == None else "You lost the game!"
self.lblWinner = tk.Label(self, width=20, height=5, bg="white", text=message)
#self.btnPlayAgain = tk.Button(self, width=20, height=5, text="Play Again", command=lambda: self.master.show(Field))
for i in range(3):
for j in range(3):
match fp[i][j]:
case 1:
fp[i][j] = "X"
case 2:
fp[i][j] = "O"
case _:
fp[i][j] = " "
self.lblPlayfield = tk.Label(self, width=20, height=5, bg="white", text=f'{fp[0][0]}|{fp[0][1]}|{fp[0][2]}\n_ _ _\n{fp[1][0]}|{fp[1][1]}|{fp[1][2]}\n_ _ _\n{fp[2][0]}|{fp[2][1]}|{fp[2][2]}')
self.btnMainMenu = tk.Button(self, text="Main Menu", width=20, height=5, command=lambda: self.master.show_menu())

def _display_widgets(self):
self.lblWinner.pack()
#self.btnPlayAgain.pack()
self.lblWinner.pack(fill=tk.X)
self.lblPlayfield.pack()
self.btnMainMenu.pack()
2 changes: 1 addition & 1 deletion UI/field_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def _menu(self):

def end(self, queue, *args):
root = self.view.master
root.show(EndScreen, queue['win'])
root.show(EndScreen, queue['win'], queue['winner'], queue['final_playfield'])

def error(self, queue, *args):
root = self.view.master
Expand Down

0 comments on commit 0e8f804

Please sign in to comment.