-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame_369.py
More file actions
35 lines (26 loc) Β· 1.34 KB
/
game_369.py
File metadata and controls
35 lines (26 loc) Β· 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import random
def play_369_game(players, user_name):
print("\n--- π² 369 κ²μμ μμν©λλ€! ---")
total_players = len(players)
for number in range(1, 51):
current_player_index = (number - 1) % total_players
current_player = players[current_player_index]
s_number = str(number)
clap_count = s_number.count('3') + s_number.count('6') + s_number.count('9')
correct_answer = "μ§" * clap_count if clap_count > 0 else s_number
if current_player['name'] == user_name:
user_input = input(f"λΉμ μ μ°¨λ‘ | -> ")
if user_input != correct_answer:
print(f"\nλ‘! νλ Έμ΅λλ€. μ λ΅μ '{correct_answer}' μ
λλ€.")
print(f"λκ° μ μ λ§μ
~ {user_name}μ΄κ° μ μ λ§μ
~")
return user_name
else:
print(f"{current_player['name']} : {correct_answer}")
print("\nμ΄ κ²μ λκ°νμ΄ ~ μ΄ κ²μ λκ°νμ΄ ~")
print("μ¬μ©μκ° μλ²½νκ² μ±κ³΅νμΌλ―λ‘ μ»΄ν¨ν°κ° λμ λ§μλλ€!")
computer_players = [p for p in players if p['name'] != user_name]
if not computer_players:
return None
loser = random.choice(computer_players)
print(f"λκ° μ μ λ§μ
~ {loser['name']}μ΄κ° μ μ λ§μ
~")
return loser['name']