-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalcoholGame.py
More file actions
212 lines (181 loc) · 8.72 KB
/
alcoholGame.py
File metadata and controls
212 lines (181 loc) · 8.72 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
import random
from strawberry_game import strawberry_game
from three69_game import game_369
from korean_game import korean_game
from market_game import market_game
from subway_game import subway_game
class Person:
def __init__(self, name, life):
self.name = name
self.life = life
self.count = 0
def get_name(self):
return self.name
def get_life(self):
return self.life
def set_count(self, value):
self.count = value
def get_count(self):
return self.count
def __str__(self):
return f"이름: {self.name}, 주량: {self.life}잔"
def decrease_life(self):
if self.life > 0:
self.life -= 1
def is_alive(self):
return self.life > 0
people_list = [
Person("은서", 2),
Person("예진", 8),
Person("헌도", 6),
Person("연서", 4),
]
def init_setting():
print("게임을 시작합니다!")
print("~" * 120)
print(r"""
██████ ██████ ██ ███ ██ ██ ██ ██ ███ ██ ██████ ██████ █████ ███ ███ ███████
██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ████ ████ ██
██ ██ ██████ ██ ██ ██ ██ █████ ██ ██ ██ ██ ██ ███ ██ ███ ███████ ██ ████ ██ █████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██████ ██ ██ ██ ██ ████ ██ ██ ██ ██ ████ ██████ ██████ ██ ██ ██ ██ ███████
""")
print("~~~~~~~~~~~~~~~~~~~~~마시면서 배우는 술게임~ 마시면서 배우는 술게임~ 안주 먹을 시간이 없써요~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print(r"☆*: .。. o(≧▽≦)o .。.:*☆" + " 안주 먹을 🍗 시간이 ❌ 없어요 ❌ 마시면서 배우는 술게임🏠🍺" + "☆*: .。. o(≧▽≦)o .。.:*☆")
print("~" * 120 + "\n")
try:
player_name = input("오늘 거하게 취해볼 당신의 이름은? : ")
print("~~~~~~~~~~~~~~~~🍺 소주 기준 당신의 주량은? 🍺~~~~~~~~~~~~~~~~")
print(" 🍺 1. 소주 반 병 (2잔) ")
print(" 🍺 2. 소주 반 병에서 한 병 (4잔) ")
print(" 🍺 3. 소주 한 병에서 한 병 반 (6잔) ")
print(" 🍺 4. 소주 한 병에서 두 병 (8잔) ")
print(" 🍺 5. 소주 두 병 이상 (10잔) ")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
while True:
try:
player_life_temp = input(
"당신의 치사량 (주량)은 얼마만큼인가요 ? (1~5을 선택해주세요) : "
).strip()
match player_life_temp:
case "1":
player_life = 2
case "2":
player_life = 4
case "3":
player_life = 6
case "4":
player_life = 8
case "5":
player_life = 10
case _:
print("1~5 중에서 골라주세요.")
continue
break
except Exception as e:
print("입력 오류:", e)
return Person(player_name, player_life)
except ValueError as e:
print(e)
def play_setting():
while True:
try:
number = input(
"함께 취할 친구들은 얼마나 필요하신가요? (사회적 거리두기로 인해 최대 3명까지 초대할 수 있습니다!) : "
).strip()
match number:
case "1":
game_people_list = random.sample(people_list, k=1)
print("\n🍺 한 명이 초대되었습니다!")
case "2":
game_people_list = random.sample(people_list, k=2)
print("\n🍺 두 명이 초대되었습니다!")
case "3":
game_people_list = random.sample(people_list, k=3)
print("\n🍺 세 명이 초대되었습니다!")
case _:
print("1~3 중에서 선택해주세요.")
continue
for person in game_people_list:
print(f"- {person}")
return game_people_list
except Exception as e:
print(e)
def play_game(player, game_people_list):
turn = 0
while True:
current_player = game_people_list[turn % len(game_people_list)]
if current_player.get_life() <= 0:
print("GAME OVER!")
print(
f"{current_player.get_name()}이 (가) 전사했습니다...꿈나라에서는 편히 쉬시길...zzz"
)
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print(" 🍺 다음에 술마시면 또 불러주세요~안녕! 🍺")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
break
for person in game_people_list:
print(
f"{person.get_name()}은 (는) 지금까지 {person.get_count()}🍺 : 치사량까지 {person.get_life()}"
)
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print("~~~~~~~~~~~~~~~~~🍺 오늘의 Alcohol Game 🍺~~~~~~~~~~~~~~~~~~~")
print(" 🍺 1. 369 게임 ")
print(" 🍺 2. 지하철 게임 ")
print(" 🍺 3. 딸기 게임 ")
print(" 🍺 4. 시장 게임 ")
print(" 🍺 5. 훈민정음 게임 ")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
user_input = input(
f"\n술게임 진행 중! {current_player.get_name()}님의 턴입니다.\n그만하고 싶으면 'exit'을, 계속하려면 Enter를 눌러주세요: "
)
print()
if user_input.strip().lower() == "exit":
print("🍺 게임을 종료합니다. 🍺")
break
try:
choice = input(
f"{current_player.get_name()}님이 선택할 게임 번호는? (1~5): "
).strip()
match choice:
case "1":
game_369(player,current_player,game_people_list)
case "2":
subway_game(game_people_list)
case "3":
strawberry_game(player,current_player,game_people_list)
case "4":
market_game(player,game_people_list)
case "5":
korean_game(player, game_people_list) #tofu_game에서 korean_game으로 수정. 함수 파라미터 추가
case _:
print("올바른 게임 번호를 골라주세요!")
if current_player.get_life() <= 0:
print("GAME OVER!")
print(
f"{current_player.get_name()}이 (가) 전사했습니다...꿈나라에서는 편히 쉬시길...zzz"
)
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print(" 🍺 다음에 술마시면 또 불러주세요~안녕! 🍺")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
break
except Exception as e:
print(e)
turn += 1
# 메인 루프
while True:
choice = input("게임을 진행할까요? (y/n): ").strip().lower()
try:
match choice:
case "y":
player = init_setting()
game_people_list = play_setting()
game_people_list.append(player)
play_game(player, game_people_list)
case "n":
print("게임을 종료합니다.")
break
case _:
raise ValueError("잘못된 입력입니다. y 또는 n을 입력하세요.")
except ValueError as e:
print(e)