python-谁是卧底小游戏

python游戏源码——谁是卧底小游戏

谁是卧底小游戏

一.游戏讲解

  1. 先是导入模块以便后面程序需要。
# 谁是卧底小游戏
import time #导入时间模块
import random #导入随机数模块
  1. 欢迎进入游戏
print("——————————————欢迎来到‘谁是卧底’———————————————")
print('你是4号哦')
print('当系统觉得不合理时会自动减票或加票')
  1. 创造需要的变量
lite = ['1', '2', '3']
obj = ["牛奶", '酸奶', '防晒霜', '牙膏']
p = 3
p_3 = 0
p_1 = 2
p_4 = 1
o = 1
o_1 = 2
suijishu = random.randint(0, 3)
shshsh = random.randint(0, 2)
suiji = random.randint(0, 1)
ggg = random.randint(0, 1)
pp = random.randint(0, 3)
sj = random.randint(0, 2)
ll = random.randint(0, o)
hshshs = random.randint(1, 3)
ppppp = random.randint(1, 3)
if ppppp == 1:
    pppp = 2
    pppppp = 3
elif ppppp == 2:
    pppp = 3
    pppppp = 1
else:
    pppp = 1
    pppppp = 2

  1. 创造时间延迟
def time_1(): #自定义时间函数
    time.sleep(1)
    print('3')
    time.sleep(1)
    print('2')
    time.sleep(1)
    print('1')
    time.sleep(1)
    print('投票结果如下')
  1. 输出玩家抽到的物品
print("你抽到的物品是" + obj[suijishu])
qbz = input("开始描述!")
  1. 当玩家是卧底时所看到的描述
if suijishu == 0 or suijishu == 1:
    if suiji == 0:
        if suijishu == 0:
            print(str(ppppp) + '号说:可以喝,健康饮品,来源发酵' + "\n" + str(pppp) + '号说:可以杀菌' + "\n" + str(pppppp) + '号说:易消化')
            a = input('你说:')
        else:
            print(str(ppppp) + '号说:可以喝,健康饮品' + "\n" + str(pppp) + '号说:可以美白' + "\n" + str(pppppp) + '号说:来源于牛')
            a = input('你说:')
  1. 开始讨论环节
 qp = input('开始讨论')
        print('2号说:我不知道')
        print('3号说:我认为肯定是' + str(pppppp) + '来源直觉')
        print('1号说:应该是4号')
        pq = input('请发言:')
        print(str(ppppp) + "说;???")
  1. 投票环节
print('开始投票')
        time_1()
        var_6 = ll + 1
        var_1 = p + 1
        var = ll + 1
        var_4 = int(p_3) + 1
        var_2 = p_1 + 1
        var_3 = p_4 + 1
        topi = input('请问你要投的是(输入1,2,3):')
        if topi == 1:
            var_6 = ll + 1
            print('1号票数是' + str(var_6))
        else:
            print('1号票数是' + str(sj))
        if sj == 0:
            o = o_1
            if topi == 2:
                var = ll + 1
                print('2号票数是' + str(var))
            else:
                print('2号票数是' + str(ll))
        else:
            o = o
            if topi == 2:
                var = ll + 1
                print('2号票数是' + str(var))
            else:
                print('2号票数是' + str(ll))
        if sj + ll == 0:
            if topi == 3:
                var_1 = p + 1
                print("3号票数是" + str(var_1))
            else:
                print("3号票数是" + str(p))
        elif sj + ll == 1:
            if topi == 3:
                var_2 = p_1 + 1
                print("3号票数是" + str(var_2))
            else:
                print("3号票数是" + str(p_1))
        elif sj + ll == 2:
            if topi == 3:
                var_3 = p_4 + 1
                print("3号票数是" + str(var_3))
            else:
                print("3号票数是" + str(p_4))
        else:
            if topi == 3:
                var_4 = p_3 + 1
                print('3号票数是' + str(var_4))
            else:
                print('3号票数是' + str(p_3))
        print('你的票数是' + str(pp))
  1. 揭秘环节
qp = input("")
       if pp < sj and pp < var_6 and pp < var and pp < float(
               ll) and pp < var_1 and pp < p and pp < var_2 and pp < p_1 and pp < var_3 and pp < p_4 and pp < var_4 and pp < p_3:
           print('你赢了,你是卧底')
           if suijishu == 0:
               print('其他人的词是' + obj[1])
           else:
               print('其他人的词是' + obj[0])
           print('游戏结束!!!')
       else:
           print('你输了,你是卧底')
           if suijishu == 0:
               print('其他人的词是' + obj[1])
           else:
               print('其他人的词是' + obj[0])
           print('游戏结束!!!')
  1. 第二种情况:玩家不是卧底
else:
        if suijishu == 0:
            print(str(ppppp) + '号说:可以喝,健康饮品' + "\n" + str(pppp) + '号说:可以杀菌' + "\n" + str(pppppp) + '号说:来源于牛')
            a = input('你说:')
        else:
            print(str(ppppp) + '号说:可以喝,健康饮品,来源于牛' + "\n" + str(pppp) + '号说:可以美白' + "\n" + str(pppppp) + '号说:易消化')
            a = input('你说:')
        qp = input('开始讨论')
        print('1号说:我觉得是' + str(pppppp) + '头像太傻逼了')
        print('2号说:我认为肯定是' + str(ppppp) + 'Ta没描述到主要')
        print('3号说:反正我是好人,我乱投!哈')
        pq = input('请发言:')
        print(str(pppppp) + "说;有一点有道理,但是还是猜测")
        print("开始投票")
        var_6 = ll + 1
        var_1 = p + 1
        var = ll + 1
        var_4 = int(p_3) + 1
        var_2 = p_1 + 1
        var_3 = p_4 + 1
        topi = input('请问你要投的是(输入1,2,3):')
        time_1()
        if topi == 1:
            var_6 = ll + 1
            print('号票数是' + str(var_6))
        else:
            print('1号票数是' + str(sj))
        if sj == 0:
            o = o_1
            if topi == 2:
                var = ll + 1
                print('2号票数是' + str(ll))
            else:
                print('2号票数是' + str(ll))
        else:
            o = o
            if topi == 2:
                var_1 = ll + 1
                print('2号票数是' + str(var_1))
            else:
                print('2号票数是' + str(ll))
        if sj + ll == 0:
            if topi == 3:
                var_1 = p + 1
                print("3号票数是" + str(var_1))
            else:
                print("3号票数是" + str(p))
        elif sj + ll == 1:
            if topi == 3:
                var_2 = p_1 + 1
                print("3号票数是" + str(var_2))
            else:
                print("3号票数是" + str(p_1))
        elif sj + ll == 2:
            if topi == 3:
                var_3 = p_4 + 1
                print("3号票数是" + str(var_3))
            else:
                print("3号票数是" + str(p_4))
        else:
            if topi == 3:
                var_4 = int(p_3) + 1
                print('3号票数是' + str(var_4))
            else:
                print('3号票数是' + str())
        print('你的票数是' + str(pp))
        if pp < sj and pp < var_6 and pp < var and pp < float(
                ll) and pp < var_1 and pp < p and pp < var_2 and pp < p_1 and pp < var_3 and pp < p_4 and pp < var_4 and pp < p_3:
            print('你赢了!你不是卧底,卧底是' + str(hshshs) + "号")
            if suijishu == 0:
                print('卧底的词是' + obj[1])
            else:
                print('卧底的词是' + obj[0])
            print('游戏结束!!!')
        else:
            print('你输了!你不是卧底,卧底是' + str(hshshs) + "号")
            if suijishu == 0:
                print('卧底的词是' + obj[1])
            else:
                print('卧底的词是' + obj[0])
            print('游戏结束!!!')
########
########
########
# elif suijishu == 2 or 3:

else:
    if suiji == 0:
        if suijishu == 2:
            print(str(ppppp) + '号说:很白,我晚上快睡觉时经常用,' + "\n" + str(pppp) + '号说:可以美白' + "\n" + str(pppppp) + '号说:罐装的')
            a = input('你说:')
        else:
            print(str(ppppp) + '号说:出门时会用' + "\n" + str(pppp) + '号说:可以美白' + "\n" + str(pppppp) + '号说:我家有好多呢')
            a = input('你说:')
        print('开始发言')
        print('1号说:我觉得是' + str(pppp) + '很描述不清楚呀,很可疑')
        print('2号说:我反手投4号,因为Ta描述 ' + a + ' 分明是在乱讲')
        print('3号说:我心中有数了')
        pq = input('请发言:')
        print(str(pppp) + "说;我就听你继续狡辩")
        print('开始投票')
        topi = input('请问你要投的是(输入1,2,3):')
        time_1()
        var_6 = ll + 1
        var_1 = p + 1
        var = ll + 1
        var_4 = int(p_3) + 1
        var_2 = p_1 + 1
        var_3 = p_4 + 1
        if topi == 1:
            var_6 = ll + 1
            print('号票数是' + str(var_6))
        else:
            print('1号票数是' + str(sj))
        if sj == 0:
            o = o_1
            if topi == 2:
                var = ll + 1
                print('2号票数是' + str(var))
            else:
                print('2号票数是' + str(ll))
        else:
            o = o
            if topi == 2:
                var = ll + 1
                print('2号票数是' + str(var))
            else:
                print('2号票数是' + str(ll))
        if sj + ll == 0:
            if topi == 3:
                var_1 = p + 1
                print("3号票数是" + str(var_1))
            else:
                print("3号票数是" + str(p))
        elif sj + ll == 1:
            if topi == 3:
                var_2 = p_1 + 1
                print("3号票数是" + str(var_2))
            else:
                print("3号票数是" + str(p_1))
        elif sj + ll == 2:
            if topi == 3:
                var_3 = p_4 + 1
                print("3号票数是" + str(var_3))
            else:
                print("3号票数是" + str(p_4))
        else:
            if topi == 3:
                var_4 = p_3 + 1
                print('3号票数是' + str(var_4))
            else:
                print('3号票数是' + str(p_3))
        print('你的票数是' + str(pp))
        if pp < sj and pp < var_6 and pp < var and pp < float(
                ll) and pp < var_1 and pp < p and pp < var_2 and pp < p_1 and pp < var_3 and pp < p_4 and pp < var_4 and pp < p_3:
            print('你赢了,你是卧底')
            if suijishu == 2:
                print('其他人的词是' + obj[3])
            else:
                print('其他人的词是' + obj[2])
            print('游戏结束!!!')
        else:
            print('你输了!你是卧底')
            if suijishu == 2:
                print('其他人的词是' + obj[3])
            else:
                print('其他人的词是' + obj[2])
            print('游戏结束!!!')
    else:
        if suijishu == 2:
            print(str(ppppp) + '号说:最近下雨没有用' + "\n" + str(pppp) + '号说:我们男人一般都不用' + "\n" + str(pppppp) + '号说:有些十分的贵')
            a = input('你说:')
        else:
            print(str(ppppp) + '号说:早晚都用' + "\n" + str(pppp) + '号说:可以美白' + "\n" + str(pppppp) + '号说:有许多味')
            a = input('你说:')
        qp = input('开始讨论')
        print('1号说:我觉得' + str(pppppp) + '号是.......因为......没有因为')
        print('2号说:4号的发言  ' + a + '  太假了')
        print('3号说:我是名侦探柯南,真相只有一个就是' + str(pppp) + '首先Ta考虑很久,证明Ta在想借口,其次是Ta错别字多,证明Ta太紧张')
        pq = input('请发言:')
        print(str(ppppp) + "说;有道理")
        print('开始投票')
        topi = input('请问你要投的是(输入1,2,3):')
        time_1()
        var_6 = ll + 1
        var = ll + 1
        var_4 = int(p_3) + 1
        var_1 = p + 1
        var_2 = p_1 + 1
        var_3 = p_4 + 1
        if topi == 1:
            var_6 = ll + 1
            print('号票数是' + str(var_6))
        else:
            var_6 = ll + 1
            print('1号票数是' + str(sj))
        if sj == 0:
            o = o_1
            if topi == 2:
                var = ll + 1
                print('2号票数是' + str(ll))
            else:
                print('2号票数是' + str(ll))
        else:
            o = o
            if topi == 2:
                var_1 = ll + 1
                print('2号票数是' + str(var_1))
            else:
                print('2号票数是' + str(ll))
        if sj + ll == 0:
            if topi == 3:
                var_2 = p + 1
                print("3号票数是" + str(var_2))
            else:
                print("3号票数是" + str(p))
        elif sj + ll == 1:
            if topi == 3:
                var_2 = p_1 + 1
                print("3号票数是" + str(var_2))
            else:
                print("3号票数是" + str(p_1))
        elif sj + ll == 2:
            if topi == 3:
                var_3 = p_4 + 1
                print("3号票数是" + str(var_3))
            else:
                print("3号票数是" + str(p_4))
        else:
            if topi == 3:
                var_4 = int(p_3) + 1
                print('3号票数是' + str(var_4))
            else:
                print('3号票数是' + str(var_3))
        print('你的票数是' + str(pp))
        if pp >= sj and pp >= var_6 and (pp >= var or pp >= float(ll)) and (pp >= var_1 or pp >= p) and (
                pp >= var_2 or pp >= p_1) and (pp >= var_3 or pp >= p_4) and (pp >= var_4 or pp >= p_3 ):
            print('你输了!你不是卧底,卧底是' + str(hshshs) + "号")
            if suijishu == 2:
                print('卧底的词是' + obj[3])
            else:
                print('卧底的词是' + obj[2])
        else:
            print('你赢了!你不是卧底,卧底是' + str(hshshs) + "号")
            if suijishu == 2:
                print('卧底的词是' + obj[3])
            else:
                print('卧底的词是' + obj[2])
        print('游戏结束!!!')

二.游戏全代码

代码如下

# 谁是卧底
print("——————————————欢迎来到‘谁是卧底’———————————————")
print('你是4号哦')
print('当系统觉得不合理时会自动减票或加票')
lite = ['1', '2', '3']
obj = ["牛奶", '酸奶', '防晒霜', '牙膏']
p = 3
p_3 = 0
p_1 = 2
p_4 = 1
o = 1
o_1 = 2
suijishu = random.randint(0, 3)
shshsh = random.randint(0, 2)
suiji = random.randint(0, 1)
ggg = random.randint(0, 1)
pp = random.randint(0, 3)
sj = random.randint(0, 2)
ll = random.randint(0, o)
hshshs = random.randint(1, 3)
ppppp = random.randint(1, 3)
if ppppp == 1:
    pppp = 2
    pppppp = 3
elif ppppp == 2:
    pppp = 3
    pppppp = 1
else:
    pppp = 1
    pppppp = 2

def time_1(): #自定义时间函数
    time.sleep(1)
    print('3')
    time.sleep(1)
    print('2')
    time.sleep(1)
    print('1')
    time.sleep(1)
    print('投票结果如下')

print("你抽到的物品是" + obj[suijishu])
qbz = input("开始描述!")
if suijishu == 0 or suijishu == 1:
    if suiji == 0:
        if suijishu == 0:
            print(str(ppppp) + '号说:可以喝,健康饮品,来源发酵' + "\n" + str(pppp) + '号说:可以杀菌' + "\n" + str(pppppp) + '号说:易消化')
            a = input('你说:')
        else:
            print(str(ppppp) + '号说:可以喝,健康饮品' + "\n" + str(pppp) + '号说:可以美白' + "\n" + str(pppppp) + '号说:来源于牛')
            a = input('你说:')
        qp = input('开始讨论')
        print('2号说:我不知道')
        print('3号说:我认为肯定是' + str(pppppp) + '来源直觉')
        print('1号说:应该是4号')
        pq = input('请发言:')
        print(str(ppppp) + "说;???")
        print('开始投票')
        time_1()
        var_6 = ll + 1
        var_1 = p + 1
        var = ll + 1
        var_4 = int(p_3) + 1
        var_2 = p_1 + 1
        var_3 = p_4 + 1
        topi = input('请问你要投的是(输入1,2,3):')
        if topi == 1:
            var_6 = ll + 1
            print('1号票数是' + str(var_6))
        else:
            print('1号票数是' + str(sj))
        if sj == 0:
            o = o_1
            if topi == 2:
                var = ll + 1
                print('2号票数是' + str(var))
            else:
                print('2号票数是' + str(ll))
        else:
            o = o
            if topi == 2:
                var = ll + 1
                print('2号票数是' + str(var))
            else:
                print('2号票数是' + str(ll))
        if sj + ll == 0:
            if topi == 3:
                var_1 = p + 1
                print("3号票数是" + str(var_1))
            else:
                print("3号票数是" + str(p))
        elif sj + ll == 1:
            if topi == 3:
                var_2 = p_1 + 1
                print("3号票数是" + str(var_2))
            else:
                print("3号票数是" + str(p_1))
        elif sj + ll == 2:
            if topi == 3:
                var_3 = p_4 + 1
                print("3号票数是" + str(var_3))
            else:
                print("3号票数是" + str(p_4))
        else:
            if topi == 3:
                var_4 = p_3 + 1
                print('3号票数是' + str(var_4))
            else:
                print('3号票数是' + str(p_3))
        print('你的票数是' + str(pp))
        qp = input("")
        if pp < sj and pp < var_6 and pp < var and pp < float(
                ll) and pp < var_1 and pp < p and pp < var_2 and pp < p_1 and pp < var_3 and pp < p_4 and pp < var_4 and pp < p_3:
            print('你赢了,你是卧底')
            if suijishu == 0:
                print('其他人的词是' + obj[1])
            else:
                print('其他人的词是' + obj[0])
            print('游戏结束!!!')
        else:
            print('你输了,你是卧底')
            if suijishu == 0:
                print('其他人的词是' + obj[1])
            else:
                print('其他人的词是' + obj[0])
            print('游戏结束!!!')
    else:
        if suijishu == 0:
            print(str(ppppp) + '号说:可以喝,健康饮品' + "\n" + str(pppp) + '号说:可以杀菌' + "\n" + str(pppppp) + '号说:来源于牛')
            a = input('你说:')
        else:
            print(str(ppppp) + '号说:可以喝,健康饮品,来源于牛' + "\n" + str(pppp) + '号说:可以美白' + "\n" + str(pppppp) + '号说:易消化')
            a = input('你说:')
        qp = input('开始讨论')
        print('1号说:我觉得是' + str(pppppp) + '头像太傻逼了')
        print('2号说:我认为肯定是' + str(ppppp) + 'Ta没描述到主要')
        print('3号说:反正我是好人,我乱投!哈')
        pq = input('请发言:')
        print(str(pppppp) + "说;有一点有道理,但是还是猜测")
        print("开始投票")
        var_6 = ll + 1
        var_1 = p + 1
        var = ll + 1
        var_4 = int(p_3) + 1
        var_2 = p_1 + 1
        var_3 = p_4 + 1
        topi = input('请问你要投的是(输入1,2,3):')
        time_1()
        if topi == 1:
            var_6 = ll + 1
            print('号票数是' + str(var_6))
        else:
            print('1号票数是' + str(sj))
        if sj == 0:
            o = o_1
            if topi == 2:
                var = ll + 1
                print('2号票数是' + str(ll))
            else:
                print('2号票数是' + str(ll))
        else:
            o = o
            if topi == 2:
                var_1 = ll + 1
                print('2号票数是' + str(var_1))
            else:
                print('2号票数是' + str(ll))
        if sj + ll == 0:
            if topi == 3:
                var_1 = p + 1
                print("3号票数是" + str(var_1))
            else:
                print("3号票数是" + str(p))
        elif sj + ll == 1:
            if topi == 3:
                var_2 = p_1 + 1
                print("3号票数是" + str(var_2))
            else:
                print("3号票数是" + str(p_1))
        elif sj + ll == 2:
            if topi == 3:
                var_3 = p_4 + 1
                print("3号票数是" + str(var_3))
            else:
                print("3号票数是" + str(p_4))
        else:
            if topi == 3:
                var_4 = int(p_3) + 1
                print('3号票数是' + str(var_4))
            else:
                print('3号票数是' + str())
        print('你的票数是' + str(pp))
        if pp < sj and pp < var_6 and pp < var and pp < float(
                ll) and pp < var_1 and pp < p and pp < var_2 and pp < p_1 and pp < var_3 and pp < p_4 and pp < var_4 and pp < p_3:
            print('你赢了!你不是卧底,卧底是' + str(hshshs) + "号")
            if suijishu == 0:
                print('卧底的词是' + obj[1])
            else:
                print('卧底的词是' + obj[0])
            print('游戏结束!!!')
        else:
            print('你输了!你不是卧底,卧底是' + str(hshshs) + "号")
            if suijishu == 0:
                print('卧底的词是' + obj[1])
            else:
                print('卧底的词是' + obj[0])
            print('游戏结束!!!')
########
########
########
# elif suijishu == 2 or 3:

else:
    if suiji == 0:
        if suijishu == 2:
            print(str(ppppp) + '号说:很白,我晚上快睡觉时经常用,' + "\n" + str(pppp) + '号说:可以美白' + "\n" + str(pppppp) + '号说:罐装的')
            a = input('你说:')
        else:
            print(str(ppppp) + '号说:出门时会用' + "\n" + str(pppp) + '号说:可以美白' + "\n" + str(pppppp) + '号说:我家有好多呢')
            a = input('你说:')
        print('开始发言')
        print('1号说:我觉得是' + str(pppp) + '很描述不清楚呀,很可疑')
        print('2号说:我反手投4号,因为Ta描述 ' + a + ' 分明是在乱讲')
        print('3号说:我心中有数了')
        pq = input('请发言:')
        print(str(pppp) + "说;我就听你继续狡辩")
        print('开始投票')
        topi = input('请问你要投的是(输入1,2,3):')
        time_1()
        var_6 = ll + 1
        var_1 = p + 1
        var = ll + 1
        var_4 = int(p_3) + 1
        var_2 = p_1 + 1
        var_3 = p_4 + 1
        if topi == 1:
            var_6 = ll + 1
            print('号票数是' + str(var_6))
        else:
            print('1号票数是' + str(sj))
        if sj == 0:
            o = o_1
            if topi == 2:
                var = ll + 1
                print('2号票数是' + str(var))
            else:
                print('2号票数是' + str(ll))
        else:
            o = o
            if topi == 2:
                var = ll + 1
                print('2号票数是' + str(var))
            else:
                print('2号票数是' + str(ll))
        if sj + ll == 0:
            if topi == 3:
                var_1 = p + 1
                print("3号票数是" + str(var_1))
            else:
                print("3号票数是" + str(p))
        elif sj + ll == 1:
            if topi == 3:
                var_2 = p_1 + 1
                print("3号票数是" + str(var_2))
            else:
                print("3号票数是" + str(p_1))
        elif sj + ll == 2:
            if topi == 3:
                var_3 = p_4 + 1
                print("3号票数是" + str(var_3))
            else:
                print("3号票数是" + str(p_4))
        else:
            if topi == 3:
                var_4 = p_3 + 1
                print('3号票数是' + str(var_4))
            else:
                print('3号票数是' + str(p_3))
        print('你的票数是' + str(pp))
        if pp < sj and pp < var_6 and pp < var and pp < float(
                ll) and pp < var_1 and pp < p and pp < var_2 and pp < p_1 and pp < var_3 and pp < p_4 and pp < var_4 and pp < p_3:
            print('你赢了,你是卧底')
            if suijishu == 2:
                print('其他人的词是' + obj[3])
            else:
                print('其他人的词是' + obj[2])
            print('游戏结束!!!')
        else:
            print('你输了!你是卧底')
            if suijishu == 2:
                print('其他人的词是' + obj[3])
            else:
                print('其他人的词是' + obj[2])
            print('游戏结束!!!')
    else:
        if suijishu == 2:
            print(str(ppppp) + '号说:最近下雨没有用' + "\n" + str(pppp) + '号说:我们男人一般都不用' + "\n" + str(pppppp) + '号说:有些十分的贵')
            a = input('你说:')
        else:
            print(str(ppppp) + '号说:早晚都用' + "\n" + str(pppp) + '号说:可以美白' + "\n" + str(pppppp) + '号说:有许多味')
            a = input('你说:')
        qp = input('开始讨论')
        print('1号说:我觉得' + str(pppppp) + '号是.......因为......没有因为')
        print('2号说:4号的发言  ' + a + '  太假了')
        print('3号说:我是名侦探柯南,真相只有一个就是' + str(pppp) + '首先Ta考虑很久,证明Ta在想借口,其次是Ta错别字多,证明Ta太紧张')
        pq = input('请发言:')
        print(str(ppppp) + "说;有道理")
        print('开始投票')
        topi = input('请问你要投的是(输入1,2,3):')
        time_1()
        var_6 = ll + 1
        var = ll + 1
        var_4 = int(p_3) + 1
        var_1 = p + 1
        var_2 = p_1 + 1
        var_3 = p_4 + 1
        if topi == 1:
            var_6 = ll + 1
            print('号票数是' + str(var_6))
        else:
            var_6 = ll + 1
            print('1号票数是' + str(sj))
        if sj == 0:
            o = o_1
            if topi == 2:
                var = ll + 1
                print('2号票数是' + str(ll))
            else:
                print('2号票数是' + str(ll))
        else:
            o = o
            if topi == 2:
                var_1 = ll + 1
                print('2号票数是' + str(var_1))
            else:
                print('2号票数是' + str(ll))
        if sj + ll == 0:
            if topi == 3:
                var_2 = p + 1
                print("3号票数是" + str(var_2))
            else:
                print("3号票数是" + str(p))
        elif sj + ll == 1:
            if topi == 3:
                var_2 = p_1 + 1
                print("3号票数是" + str(var_2))
            else:
                print("3号票数是" + str(p_1))
        elif sj + ll == 2:
            if topi == 3:
                var_3 = p_4 + 1
                print("3号票数是" + str(var_3))
            else:
                print("3号票数是" + str(p_4))
        else:
            if topi == 3:
                var_4 = int(p_3) + 1
                print('3号票数是' + str(var_4))
            else:
                print('3号票数是' + str(var_3))
        print('你的票数是' + str(pp))
        if pp >= sj and pp >= var_6 and (pp >= var or pp >= float(ll)) and (pp >= var_1 or pp >= p) and (
                pp >= var_2 or pp >= p_1) and (pp >= var_3 or pp >= p_4) and (pp >= var_4 or pp >= p_3 ):
            print('你输了!你不是卧底,卧底是' + str(hshshs) + "号")
            if suijishu == 2:
                print('卧底的词是' + obj[3])
            else:
                print('卧底的词是' + obj[2])
        else:
            print('你赢了!你不是卧底,卧底是' + str(hshshs) + "号")
            if suijishu == 2:
                print('卧底的词是' + obj[3])
            else:
                print('卧底的词是' + obj[2])
        print('游戏结束!!!')

三.作者说明

文章快到末尾了,小编想跟大家说一下一些事情。

  1. 由于作者知识有限,本篇python游戏是不简洁的,并且可能有bug,希望读者见谅,并且希望python大佬们帮忙修改、优化并及时提出,我一定会认真吸取意见。
  2. 最近好长一段日子没有发表文章,因为作者本人要继续能力有限,需要边学习边发表,所以我对读者表示道歉
  3. 本篇为作者原创,可复制参考
上一篇:疯狂python讲义学习日志10——文件IO


下一篇:php中转菜刀脚本过狗免杀