From 0fc5d709d3b00929bca8c41c4dc1e788fc0dd324 Mon Sep 17 00:00:00 2001 From: Siddharth Praveen Bharadwaj Date: Mon, 9 Dec 2024 20:14:28 +0530 Subject: [PATCH] Minor text fixes and added --mute flag --- ShadowDoom.py | 16 ++++++++-------- utils/audio.py | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ShadowDoom.py b/ShadowDoom.py index b935cc3..ce6f594 100644 --- a/ShadowDoom.py +++ b/ShadowDoom.py @@ -43,7 +43,7 @@ def __init__(self, _tui, _audio_manager): "Whoosh!", "Arghh!", "Paf!", "Slice!", "Wham!", "Bam!"] self.monsters_list = ["Ogre", "Orc", "Beast", "Demon", "Giant", "Golem", "Mummy", "Zombie", "Skeleton", "Witch", "Dragon", "Pirate", "Vampire"] - self.treasure_list = ["some Dust", "nothing", f"{random.randint(1, 200)} Gold", "An old rusty sword", + self.treasure_list = ["some Dust", "nothing", f"${random.randint(1, 200)}", "An old rusty sword", "a Mystery Liquid", "a healing potion", "a Colt Anaconda"] self.treasure_weights = [0.25, 0.2, 0.2, 0.2, 0.05, 0.05, 0.05] self.reset_player_state() @@ -271,8 +271,8 @@ def inventory(self): self.tui.decorative_header("You don't have any Weapons. Buy them in the Shop!", fore_color = "red") time.sleep(2) self.audio_manager.stop_audio() - self.home() + return self.tui.section_title("Equip a Weapon") @@ -604,11 +604,10 @@ def treasure(self): treasure = random.choice(random.choices(population = self.treasure_list, weights = self.treasure_weights)) self.tui.styled_print(f"{treasure}!", fore_color = "green", style = "bold") - if "Gold" in treasure: - amount = int(treasure.replace("Gold", "").strip()) + if "$" in treasure: + amount = int(treasure.replace("$", "").strip()) self.money += amount - self.money = max(self.money, 0) - self.tui.styled_print(f"Ka-Ching! You found {amount} Gold!", fore_color = "yellow") + self.tui.styled_print(f"Ka-Ching! You found ${amount}!", fore_color = "yellow") elif treasure == "An old rusty sword": self.tui.styled_print("You equip the sword.", fore_color = "cyan") self.rusty_sword = True @@ -927,8 +926,6 @@ def input(self, prompt=""): user_input = input(prompt).strip() if user_input.lower() == "m": self.audio_manager.muted = not self.audio_manager.muted - if self.audio_manager.muted: - self.audio_manager.stop_audio() else: return user_input @@ -945,6 +942,9 @@ def input(self, prompt=""): tui.styled_print("Exiting...", fore_color = "red") sys.exit(1) + if len(sys.argv) > 1 and sys.argv[1] == "--mute": + audio_manager.muted = True + try: Game(tui, audio_manager) except KeyboardInterrupt: diff --git a/utils/audio.py b/utils/audio.py index 8fbc800..38f4551 100644 --- a/utils/audio.py +++ b/utils/audio.py @@ -19,6 +19,7 @@ def muted(self): @muted.setter def muted(self, value): self.is_muted = value + pygame.mixer.music.set_volume(0 if value else 1) def play_audio(self, file, loop=True, stop_previous=False, volume=100, busy_check=False): if (not self.enabled or self.is_muted) or (busy_check and pygame.mixer.music.get_busy()):