預(yù)言家模塊
#為實(shí)現(xiàn)狼人殺游戲的python代碼
input('預(yù)言家行動時(shí)間,按下Enter以繼續(xù)') ?# 利用input函數(shù)的等待用戶輸入一特點(diǎn)避免其他角色查看
prophet_input()print('當(dāng)前存活的有:' + ' ?、'.join(su)) ?# su是一個(gè)列表,表示誰還存活。
print('你可以在這些人里選驗(yàn)一人。')
def prophet_input():
? ?try:
? ? ? ?a = int(input('請輸入他的編號'))
? ?except ValueError:
? ? ? ?print('請輸入一個(gè)數(shù)字')
? ? ? ?return prophet_input()
? ?else:
? ? ? ?if a not in su:
? ? ? ? ? ?print('你只能驗(yàn)存活之人')
? ? ? ? ? ?return prophet_input()
? ? ? ?with open('可以被查驗(yàn)的狼人庫', encoding='utf-8') as p:
? ? ? ? ? ?b = p.read()
? ? ? ?print('ta是狼人') if sfk[a - 1] in b else 'ta不是狼人'
? ? ? ?c='是狼人' if sfk[a - 1] in b else '不是狼人'
? ? ? ?note.append('預(yù)言家查驗(yàn)'+str(a)+'號,ta'+c) #計(jì)入筆記,以便復(fù)盤
prophet_input()
標(biāo)簽: