我不大会写注释,大佬们应该也能看懂。
耗时5小时
#狼人杀 ver3.0~~~
#你知道我加入这个存档文件有多不容易吗
#我不会写注释别让我写注释
from random import randint,choice
from time import sleep
import json
print("欢迎来到狼人杀!")
try:
fs=open("shengli.dat")
fs.close()
except FileNotFoundError:
lll={"l":0,
"p":0,
"114514":0,
"all":0,
"jsfs":0,
"ch":[],
"yy":0
}
with open("shengli.dat","w") as f_obj:
json.dump(lll,f_obj)
else:
with open("shengli.dat") as f_obj:
lll=json.load(f_obj)
print("狼人胜场:",lll["l"])
print("好人胜场:",lll["p"])
print("你死的次数:",lll["114514"])
print("总场次:",lll["all"])
print("识破的狼人数量:",lll["yy"])
if len(lll["ch"])!=0:
print("称号:"+",".join(lll["ch"]))
sleep(0.3)
a=["平民 ","平民","狼人","女巫"]#身份,用列表表示(用元组也行)
xing=("王","李","张","刘","徐","冯","袁","邓","韩","杜","朴","金","逄")
zhongjian=("既","海","若","树","丽","虎","涵")
zuihou=("羽","生","茵","芹","乔","智","丽")
disi=("玺","霍","获","岚","吾","乐","空","阵")
p1=choice(xing)+choice(zhongjian)
p2=choice(xing)+choice(zhongjian)+choice(zuihou)
p3=choice(xing)+choice(zhongjian)+choice(zuihou)+choice(disi)
wanjianame=[p1,p2,p3]
pl=["0","1","2","3"]#玩家
player0=choice(a)#设置玩家身份
ar=a.index(player0)
print("等待玩家进入游戏中...")
sleep(randint(0,3))
print("玩家1"+"("+p1+")加入游戏")
sleep(randint(0,3))
print("玩家2"+"("+p2+")加入游戏")
sleep(randint(0,3))
print("玩家3"+"("+p3+")加入游戏")
print("玩家已全齐,开始游戏倒计时")
timer=3
for i in range(3):
print(timer,end=" ")
timer-=1
sleep(1)
player1=choice(a)
ae=a.index(player1)
player2=choice(a)
ac=a.index(player2)
player3=choice(a)
ad=a.index(player3)
while ae==ar or ae==ac or ae==ad or ad==ac or ad==ar or ac==ar:
player1=choice(a)
ae=a.index(player1)
player2=choice(a)