Rewrote the scoreboard class. Added ability to enter name for scoreboard.
This commit is contained in:
parent
5a791510ea
commit
4a15f951f0
11
__init__.py
11
__init__.py
@ -109,12 +109,9 @@ class Scoreboard:
|
||||
return i + 1
|
||||
return None
|
||||
|
||||
def add_high_score(self, name="Player"):
|
||||
def add_high_score(self):
|
||||
"""Add current score to high scores if it qualifies.
|
||||
|
||||
Args:
|
||||
name (str): Player name for high score entry
|
||||
|
||||
Returns:
|
||||
bool: True if score was added, False if not
|
||||
"""
|
||||
@ -122,6 +119,11 @@ class Scoreboard:
|
||||
if position is None:
|
||||
return False
|
||||
|
||||
# Prompt for name using get_input
|
||||
name = get_input("New high score! Enter your name:", "Player")
|
||||
if name is None: # User cancelled
|
||||
name = "Player"
|
||||
|
||||
# Insert new score at correct position
|
||||
self.highScores.insert(position - 1, {
|
||||
'name': name,
|
||||
@ -137,6 +139,7 @@ class Scoreboard:
|
||||
localConfig.set("scoreboard", f"name_{i+1}", entry['name'])
|
||||
|
||||
write_config()
|
||||
speak(f"Congratulations {name}! You got position {position} on the high score table!")
|
||||
return True
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user