-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fix card placement bug and celebrations
Signed-off-by: Namit Arjaria <[email protected]>
- Loading branch information
Showing
3 changed files
with
59 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import tkinter as tk | ||
from tkinter import messagebox | ||
|
||
|
||
class WinCelebration: | ||
def __init__(self, game): | ||
self.game = game | ||
|
||
def show_celebration(self, move_count): | ||
message = ( | ||
f"Excellent work! You have beaten Patience.\n\n" | ||
f"You took {move_count} moves to complete this game.\n\n" | ||
f"Click 'Redeal' if you would like to better your score, \n" | ||
f"'Yay!' if you want to close this window, or\n" | ||
f"'Clear Board' if you would like to start afresh." | ||
) | ||
|
||
result = messagebox.askquestion( | ||
"Congratulations!", message, type="yesnocancel", icon="info", default="yes" | ||
) | ||
|
||
if result == "yes": # Redeal | ||
self.game.redeal_cards() | ||
elif result == "no": # Yay! (close window) | ||
pass # Dialog will close automatically | ||
else: # Clear Board | ||
self.game.clear_board() | ||
|
||
|
||
def create_win_celebration(game): | ||
return WinCelebration(game) |