Skip to content

Commit

Permalink
Minor text fixes and added --mute flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Sid110307 committed Dec 9, 2024
1 parent ee1d5b7 commit 0fc5d70
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
16 changes: 8 additions & 8 deletions ShadowDoom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions utils/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()):
Expand Down

0 comments on commit 0fc5d70

Please sign in to comment.