Skip to content

Commit

Permalink
Modified to sound a fanfare when winning the game.
Browse files Browse the repository at this point in the history
  • Loading branch information
taKana671 committed Jul 27, 2021
1 parent d5c7b5d commit 7796aae
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions PlayingCards/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def create_card(self):
raise NotImplementedError()

def is_game_end(self):
"""Override this method in subclasses to sound a fanfare
when winning the game.
"""
pass

def get_image(self, file):
Expand Down
6 changes: 5 additions & 1 deletion PlayingCards/couple.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections import namedtuple
import os
import random
import tkinter as tk
from collections import namedtuple

from base import BaseBoard, BaseCard, CardFace
from Globals import BOARD_WIDTH, BOARD_HEIGHT, CARD_ROOT, MOVE_SPEED
Expand Down Expand Up @@ -211,6 +211,10 @@ def update_status(self):
text = ', '.join([f'{card.mark} {card.value}' for card in self.selected])
self.status_text.set(text)

def is_game_end(self):
if not [card for card in self.playing_cards.values() if not card.dele]:
self.sounds.fanfare.play()


if __name__ == '__main__':
application = tk.Tk()
Expand Down
4 changes: 4 additions & 0 deletions PlayingCards/fourleafclover.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ def update_status(self):
text = ', '.join(['{} {}'.format(card.mark, card.value) for card in self.selected])
self.status_text.set(text)

def is_game_end(self):
if not [card for card in self.playing_cards.values() if not card.dele]:
self.sounds.fanfare.play()


# if __name__ == '__main__':
# application = tk.Tk()
Expand Down
1 change: 0 additions & 1 deletion PlayingCards/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ def close(self, event=None):
"""


rules = {
PYRAMID.lower(): (PYRAMID, PYRAMID_RULES),
CLOVER.lower(): ('Four Leaf Clovers', CLOVERS_RULES),
Expand Down
1 change: 0 additions & 1 deletion PlayingCards/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def create_board(self):
container.pack(fill=tk.BOTH, expand=True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
# sounds = Sounds()
for name, module in zip((PYRAMID, CLOVER, KLONEDIKE, COUPLE),
(pyramid, fourleafclover, klonedike, couple)):
frame = tk.Frame(container)
Expand Down

0 comments on commit 7796aae

Please sign in to comment.