class Labotory:
def __init__(self, name, number, origin):
self.name = name
self.number = number
self.origin = origin
def __str__(self):
return f'My name is {self.name} and from {self.origin}'
Labomen1 = Labotory("Okabe_rintarou", "001", "Japan")
Labomen2 = Labotory("Shiina_Mayuuri", "002", "Japan")
Labomen3 = Labotory("Hashida_itarrum", "003", "Japan")
Labomen4 = Labotory("Makise_Kurisu","004", "America" )
Labomen5 = Labotory("Kiryu_moeka", "005", "Spoiler")
Labomen6 = Labotory("Urushibara_ruka","006", "Japan")
Labomen7 = Labotory("Feiris_nyannyan","007","Japan")
Labomen8 = Labotory("Amane_Suzuha","008", "Spoiler")
Labomen9 = Labotory("Hiyajou_maho","009","Spoiler")
#이렇게 설정 함으로써, print(Labomen1) 은 자기 소개를 할거에요!
lab_members = [Labomen1, Labomen2, Labomen3, Labomen4, Labomen5, Labomen6, Labomen7, Labomen8, Labomen9]
#언제사용할지 모르는 Labomen 들을 일단 리스트에 넣어둡니다.
class Microwave:
def __init__(self):
self.is_on = False
self.messages = []
def turn_on(self):
self.is_on = True
print("Microwave is now on")
def turn_off(self):
self.is_on = False
print("Microwave is now off")
def receive_message(self, lab, message):
if self.is_on:
print(f"Microwave received message from {lab.name}: {message}")
self.messages.append(message)
else:
print("Nothing has happened")
def message_inbox(self):
self.messages
#전화레인지 가칭을 만들어줄게요!
class CrtTv:
def __init__(self):
self.is_on = False
self.turn_on_count = 0
def turn_on(self):
self.is_on = True
self.turn_on_count +=1
print("The CRT TV is now on")
#What if TV is too much repeatly on
if self.turn_on_count >= 5 :
print("Someone is mad, and he turned off the TV")
self.turn_off()
def turn_off(self):
self.is_on = False
print("The CRT TV is now off")
def negotiation(self):
print("Someone made a negotiation with him")
self.turn_on_count = 0
#그리고 TV를 만들어줍니다
class DivergenceMeter:
def __init__(self):
self.current_divergent_value = 0.571040
self.divergent_value_log = [self.current_divergent_value]
def status(self):
print(self.current_divergent_value)
def change_value(self):
self.current_divergent_value += 0.003
print(f"Divergence Meter changed to {self.current_divergent_value}")
self.divergent_value_log.append(self.current_divergent_value)
#이제 게임 스토리를 만들 차례에요
class GameStory:
def __init__(self, lab_members, microwave, crt_tv, divergence_meter):
self.lab_members = lab_members
self.microwave = microwave
self.crt_tv = crt_tv
self.divergence_meter = divergence_meter
def send_message_to_change_divergence_meter(self, messages):
if self.microwave.is_on and self.crt_tv.is_on:
for sender, message in messages.items():
print(f"{sender.name}: {message}")
self.microwave.receive_message(sender, message)
self.divergence_meter.change_value()
else:
print("Seems like nothing has changed.....")
def show_the_divergence_meter_history(self):
print("Divergence meter history:")
print(f'History: {self.divergence_meter.current_divergent_value}')
for value in self.divergence_meter.divergent_value_log:
print(value)
#각 객체의 특성을 받는 것을 만듬
microwave = Microwave()
crt_tv = CrtTv()
divergence_meter = DivergenceMeter()
game_story = GameStory(lab_members, microwave, crt_tv, divergence_meter)
while True:
print("Options")
print("1. Send a message through the microwave")
print("2. Turn on/off the TV")
print("3. Turn on/off the Microwave")
print("4. Check Divergent Meter")
print("5. Exit Game")
choice = input("What will I do next? ")
if choice == '1':
print("To whom?")
lab_choice = int(input("Enter the number of the lab member: "))
if 1 <= lab_choice <= len(lab_members):
selected_lab_member = lab_members[lab_choice - 1]
if selected_lab_member.origin == 'Spoiler':
print("Sorry, you cannot choose a lab member with origin 'Spoiler'.")
else:
print(selected_lab_member)
else:
print("Invalid lab member choice")
elif choice == '2':
if crt_tv.is_on:
crt_tv.turn_off()
else:
crt_tv.turn_on()
elif choice == '3':
if microwave.is_on:
microwave.turn_off()
else:
microwave.turn_on()
elif choice == '4':
divergence_meter.status()
user_input = input("Would you like to see the previous log? (Y/N): ")
if user_input.upper() == 'Y':
print(divergence_meter.divergent_value_log)
else:
print("Unfortunate!")
elif choice == '5':
print("Exiting the game.")
break
else:
print("That's not an option")