其他分享
首页 > 其他分享> > 简易狼人杀

简易狼人杀

作者:互联网

import random
import time

card = ["预言家", '狼人', '女巫', '猎人', '村民', '狼人', '狼人', '村民', '村民']
identy = random.sample(card, 9)
name_1, name_2, name_3, name_4, name_5, name_6, name_7, name_8, name_9 = identy
dic = {'a': name_1, 'name_b': name_2, 'name_c': name_3,
       'name_d': name_4, 'name_e': name_5, 'name_f': name_6,
       'name_g': name_7, 'name_h': name_8, 'name_i': name_9, }
print('天黑请闭眼')
while True:
    while True:  # 预言家 狼人
        god = [k for k, v in dic.items() if v == '预言家']
        print(god)

        god_i = input('选择你要查验的对象')
        god_c = dic.get(god_i)
        if god_c == '狼人':
            print(god_i, '他的身份是狼人')
            break
        else:
            print(god_i, '他是好人')
            break

    while True:
        print('还活着的人为', [i for i in dic.keys()])  # 白天活着的人
        wolf = [k for k, v in dic.items() if v == '狼人']
        print(wolf, '你们是狼队友')


        def wolf_fun(n):
            wolf_c = []
            for i in wolf:
                wolf_ic = input('选择你们今晚要袭击的目标')
                wolf_c.append(wolf_ic)
            return wolf_c


        n = wolf_fun(0)
        print(n)


        def fun(Li):
            temp = 0
            for i in Li:
                if Li.count(i) > temp:
                    max_str = i
                    temp = Li.count(i)
                    print(max_str)
            return max_str


        while True:
            w_die = fun(n)  # 狼夜晚杀的人
            ww = input('请选择你要救{}吗?y or n,'
                       '请问你要使用毒药吗y or n?'.format(w_die))  # 女巫回合
            if ww == 'y':
                print('平安夜')
                break
            else:
                light = dic.pop(w_die)
                print(w_die, '昨晚死了')
                break

        print('还活着的人为', [i for i in dic.keys()])  # 白天活着的人


        def light_fun(n):  # 白天投票
            light = []
            for j in [i for i in dic.keys()]:
                Light_c = input('选择你们怀疑的对象')
                light.append(Light_c)
            return light


        m = light_fun(0)
        # break
        #
        # for j in [i for i in dic.keys()]:
        #     print(j)
        #     Light_s = input('投票')


        def fun(Li):  # 白天投票出局
            temp = 0
            for i in Li:
                if Li.count(i) > temp:
                    max_str = i
                    temp = Li.count(i)
                    print(max_str)
            return max_str


        print(fun(m), '被公投出局')

        print('第一天结束,天黑请闭眼')
        break

标签:name,god,狼人,dic,简易,wolf,print,Li
来源: https://www.cnblogs.com/libragyf/p/12193558.html