Fixed a few bugs in console commands.

This commit is contained in:
Storm Dragon
2025-09-26 13:42:17 -04:00
parent 1d39ff0ca7
commit 10f859136b

View File

@@ -36,6 +36,9 @@ class WickedQuest:
# Console system - no longer needed since we use get_input directly
# Level tracking for proper progression
self.currentLevelNum = 1
def initialize_pack_sounds(self):
"""Initialize pack-specific sound system after game selection."""
if self.currentGame:
@@ -212,8 +215,20 @@ class WickedQuest:
# Extract level number from choice
levelNum = int(choice.split()[-1])
# Stop all sounds and music before warping
pygame.mixer.stop()
try:
pygame.mixer.music.stop()
except:
pass
# Clear events for clean transition
pygame.event.clear()
# Load the selected level
if self.load_level(levelNum):
# Update the current level counter for proper progression
self.currentLevelNum = levelNum
speak(f"Warped to level {levelNum}")
else:
speak(f"Failed to load level {levelNum}")
@@ -222,6 +237,9 @@ class WickedQuest:
"""Open the console for input and process the command."""
from libstormgames import get_input
# Clear events before opening console for PyInstaller compatibility
pygame.event.clear()
# Get console input using libstormgames text input
command = get_input("Enter console command:")
@@ -552,7 +570,7 @@ class WickedQuest:
"""Main game loop handling updates and state changes."""
clock = pygame.time.Clock()
levelStartTime = pygame.time.get_ticks()
currentLevelNum = startingLevelNum
self.currentLevelNum = startingLevelNum
while True:
currentTime = pygame.time.get_ticks()
@@ -631,7 +649,7 @@ class WickedQuest:
else:
pygame.mixer.stop()
self.currentLevel.player._health = self.currentLevel.player._maxHealth
self.load_level(currentLevelNum)
self.load_level(self.currentLevelNum)
levelStartTime = pygame.time.get_ticks() # Reset level timer
continue
@@ -641,8 +659,8 @@ class WickedQuest:
levelTime = pygame.time.get_ticks() - levelStartTime
self.display_level_stats(levelTime)
currentLevelNum += 1
if self.load_level(currentLevelNum):
self.currentLevelNum += 1
if self.load_level(self.currentLevelNum):
# Auto save at the beginning of new level if conditions are met
self.auto_save()
levelStartTime = pygame.time.get_ticks() # Reset level timer for new level