import random
# 身份機率轉盤
def spin_animal_wheel():
outcome = random.random() # 產生0到1之間的隨機數
if outcome < 0.7:
return "流浪狗"
else:
return "流浪貓"
# 個性機率轉盤
def spin_personality_wheel(animal):
if animal == "流浪狗":
outcome = random.random()
if outcome < 0.6:
return "膽小"
else:
return "大膽"
else:
outcome = random.random()
if outcome < 0.6:
return "大膽"
else:
return "膽小"
# 故事描述及選擇
def story_choice(animal, personality):
if animal == "流浪狗" and personality == "膽小":
print("故事一:餓了許多天,走著走著走進了一個校園...")
choice = input("你的選擇是 1『警戒!不吃!』還是 2『抵擋不住誘惑,吃一點點應該沒事吧』?")
if choice == '1':
print("你選擇警戒,默默離開,在轉角處發現垃圾堆,度過了這天。")
elif choice == '2':
print("唰!被抓住了!被抓去燉狗肉湯。")
else:
print("請輸入有效選項。")
elif animal == "流浪狗" and personality == "大膽":
print("故事二:某天,在一個風和日麗的上午...")
choice = input("你的選擇是 1『應該不是給我的,還是別吃吧』還是 2『看起來真香,吃一點點應該沒事吧』?")
if choice == '1':
print("無事發生,繼續踏上旅途。")
elif choice == '2':
print("吃到別人家狗的飼料了!因緣際會下被那戶人家收養了!")
else:
print("請輸入有效選項。")
elif animal == "流浪貓" and personality == "大膽":
print("故事三:餓了許多天,走著走著走進了一個校園...")
choice = input("你的選擇是 1『在他腳撒嬌,求收編』還是 2『還沒吃飽,尋找下一位學生』?")
if choice == '1':
print("撒嬌成功!從此不再流浪!!!")
elif choice == '2':
print("正逢寒假期間,校園裡人煙稀少,身體受不了冬天的冷風,冷死在路邊。")
else:
print("請輸入有效選項。")
elif animal == "流浪貓" and personality == "膽小":
print("故事四:餓了許多天,走著走著走進了一個校園...")
choice = input("你的選擇是 1『警戒!不吃!』還是 2『抵擋不住誘惑,吃一點點應該沒事吧』?")
if choice == '1':
print("你選擇警戒,默默離開,在轉角處發現垃圾堆,度過了這天。")
elif choice == '2':
print("唰!被抓住了!被抓去燉貓肉湯。")
else:
print("請輸入有效選項。")
else:
print("無效組合。")
# 玩家按下開始鍵
start = input("按下任意鍵開始轉盤:")
animal_result = spin_animal_wheel()
personality_result = spin_personality_wheel(animal_result)
# 輸出個性、身份組合結果
print(f"身份:{animal_result}")
print(f"個性:{personality_result}")
# 輸出故事描述及選擇
story_choice(animal_result, personality_result)