記錄#
- 今天繼續沒有新的知識點,還是綜合練習。
- 今天的練習有點繞繞,還好寫出來了。
CODE#
import os
import time
import random
again = "y"
vuser = {}
vuser["zs"] = {"shengao": 180, "tizhong": 180, "meili": 230, "zhishang": 100}
vuser["ls"] = {"shengao": 120, "tizhong": 190, "meili": 50, "zhishang": 180}
vuser["ww"] = {"shengao": 111, "tizhong": 243, "meili": 76, "zhishang": 10}
vuser["em"] = {"shengao": 90, "tizhong": 90, "meili": 90, "zhishang": 90}
def userprint():
i = 1
for key in vuser.keys():
print(f"{i} : {key}")
i += 1
while again == "y":
time.sleep(1)
os.system("clear")
print("🌟Top Trumps🌟")
print()
print(
"歡迎來到「最帥計算機老師」Top Trumps模擬器")
userprint()
userselect = input("請輸入你想要的卡片: ")
while userselect not in vuser.keys():
print(f"輸入錯誤,{userselect} 不在卡片中")
userselect = input("請重新輸入你想要的卡片: ")
aiselect = random.choice(list(vuser.keys()))
while aiselect == userselect:
aiselect = random.choice(list(vuser.keys()))
print(f"系統選擇了 {aiselect}")
print()
userinfo = input("請輸入你想要對戰的功能: \nshengao\ntizhong\nmeili\nzhishang\n")
while userinfo not in vuser[userselect].keys():
print(f"輸入錯誤,{userinfo} 不是有效的選擇")
userinfo = input("請重新輸入你想要對戰的功能: \nshengao\ntizhong\nmeili\nzhishang\n")
if vuser[userselect][userinfo] > vuser[aiselect][userinfo]:
print("你勝利")
elif vuser[userselect][userinfo] < vuser[aiselect][userinfo]:
print("系統勝利")
else:
print("平局")
again = input("再玩一次? y / n > ")