Skip to content

Commit be923e6

Browse files
Merge pull request #1684 from Facelessism/number
fix hardcoded difficulty selection
2 parents ab418fa + 2b95f01 commit be923e6

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

games/Number-Guessing-Game/Number-Guessing-Game.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
MIN_NUMBER = 1
1818
MAX_NUMBER = 100
1919

20+
# Difficulty configuration
21+
DIFFICULTY_ATTEMPTS = {
22+
"1": 15,
23+
"2": 10,
24+
"3": 5,
25+
}
26+
2027
# Proximity hint thresholds
2128
VERY_CLOSE_THRESHOLD = 3
2229
CLOSE_THRESHOLD = 10
@@ -39,12 +46,7 @@ def main() -> None:
3946
error_invalid="⚠️ Invalid selection. Please enter 1, 2 or 3."
4047
)
4148

42-
if choice == "1":
43-
max_attempts = 15
44-
elif choice == "3":
45-
max_attempts = 5
46-
else:
47-
max_attempts = 10
49+
max_attempts = DIFFICULTY_ATTEMPTS[choice]
4850

4951
number = random.randint(MIN_NUMBER, MAX_NUMBER)
5052
attempts = 0
@@ -118,4 +120,4 @@ def main() -> None:
118120
if __name__ == "__main__":
119121
if len(sys.argv) > 1:
120122
random.seed(int(sys.argv[1]))
121-
main()
123+
main()

0 commit comments

Comments
 (0)