python编写多人对战小游戏

编写小游戏

开发中的类的继承
  • 灵活使用函数和函数的继承以及类class的实例
import time
import random


class WeGame(object):
    def __init__(self, username, sex, boold_num=2000, money=800, agg=0, pre=0):
        self.username = username
        self.sex = sex
        self.boold_num = boold_num
        self.money = money
        self.agg = agg
        self.pre = pre
        self.room = None
        self.Sword_info = []
        self.Sword()

    # def __new__(cls, *args, **kwargs):
    #     return cls.Come_game(cls)

    # 初始金币
    def Come_game(self):
        print("答题得金币,题号有【1、2、3】")
        _num = input("请输入你想答得题目(谨慎选择!!!):")
        if _num == '1':
            print("斐波拉契数列的第20位是多少?")
            tmp1 = input("你的答案:")
            if tmp1 == '6765':
                self.money += 600
            else:
                self.money += 0
                print("回答错误,答案是6765")
            print("你的金币为:", self.money)
            return self.Sword()

        elif _num == '2':
            print("英雄联盟中召唤师峡谷的战役中,双方都分有几个位置?")
            tmp2 = input("你的答案:")
            if tmp2 == '5':
                self.money += 600
            else:
                self.money += 0
                print("回答错误,答案是5")
            print("你的金币为:", self.money)
            return self.Sword()

        elif _num == '3':
            print("1+1等于几?")
            tmp3 = input("你的答案:")
            if tmp3 == '2':
                self.money += 600
            else:
                print("你没救了!")
                self.money -= 600
            print("你的金币为:", self.money)
            return self.Sword()

    # 武器装备信息
    def Sword(self):
        print('_' * 50)
        print('*' * 50)
        print</
评论 13
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值