Ju_guan 2022-04-26 12:37
浏览 249
已结题

创建3个游戏人物,以及三个游戏场景,模拟游戏场景

class Game_person:
    def __init__(self,name,sex,age,fighting):
        self.G_name = name
        self.G_sex = sex
        self.G_age = age
        self.G_fighting = fighting
    def Game_scene1(self):
        self.G_fighting = self.G_fighting - 200
        return self.G_fighting
    def Game_scene2(self):
        self.G_fighting = self.G_fighting + 100
        return self.G_fighting
    def Game_scene3(self):
        self.G_fighting = self.G_fighting -500
        return self.G_fighting
player1 = Game_person('小A','女',18,1000)
player2 = Game_person('小B','男',20,1800)
player3 = Game_person('小C','女',19,2500)
print("-"*10 + "游戏开始" +"-"*10)
print("请选择游戏人物:")
print("1."+"小A,女,18,初始战斗力1000")
print("2."+"小B,男,20,初始战斗力1800")
print("3."+"小C,女,19,初始战斗力2500")
figure = int(input())
if figure == 1:
    print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
    scene1 = int(input())
    while scene1 == 1:
        player1.Game_scene1()
        print("战斗结束"+"\n",player1.G_name,player1.G_sex,player1.G_age,"剩余战斗力:",player1.G_fighting)
        if player1.G_fighting <=0 :
            print("战斗力小于0,游戏结束")
            break
        print("是否继续:1.继续 2.退出")
        continue1 = int(input())
        if continue1 == 1:
            print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
            scene1 = int(input())
            if scene1 == 2:
                player1.Game_scene2()
                print("修炼结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
                print("是否继续:1.继续 2.退出")
                continue2 = int(input())
                if continue2 == 1:
                    print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
                    scene1 = int(input())
                else : break
            if scene1 == 3:
                player1.Game_scene3()
                print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
            if scene1 == 2:
                player1.Game_scene2()
                print("修炼结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
            if scene1 == 1:
                player1.Game_scene1()
                print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
            print("是否继续:1.继续 2.退出")
            continue2 = int(input())
            if continue2 == 1:
                print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
                scene1 = int(input())
            else:
                    break
        else : break
    while scene1 == 2:
        player1.Game_scene2()
        print("修炼结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        print("是否继续:1.继续 2.退出")
        continue2 = int(input())
        if continue2 == 1:
            print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
            scene1 = int(input())
        else:
            break
        if scene1 == 3:
            player1.Game_scene3()
            print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        if scene1 == 2:
            player1.Game_scene2()
            print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        if scene1 == 1:
            player1.Game_scene1()
            print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        print("是否继续:1.继续 2.退出")
        continue2 = int(input())
        if continue2 == 1:
            print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
            scene1 = int(input())
        else:
            break
    while scene1 == 3:
        player1.Game_scene3()
        print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        print("是否继续:1.继续 2.退出")
        continue2 = int(input())
        if continue2 == 1:
            print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
            scene1 = int(input())
        else:
            break
        if scene1 == 3:
            player1.Game_scene3()
            print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        if scene1 == 2:
            player1.Game_scene2()
            print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        if scene1 == 3:
            player1.Game_scene3()
            print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        print("是否继续:1.继续 2.退出")
        continue2 = int(input())
        if continue2 == 1:
            print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
            scene1 = int(input())
        else:
            break
if figure == 2:
    print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
    scene1 = int(input())
    while scene1 == 1:
        player1.Game_scene1()
        print("战斗结束"+"\n",player1.G_name,player1.G_sex,player1.G_age,"剩余战斗力:",player1.G_fighting)
        if player1.G_fighting <=0 :
            print("战斗力小于0,游戏结束")
            break
        print("是否继续:1.继续 2.退出")
        continue1 = int(input())
        if continue1 == 1:
            print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
            scene1 = int(input())
            if scene1 == 2:
                player1.Game_scene2()
                print("修炼结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
                print("是否继续:1.继续 2.退出")
                continue2 = int(input())
                if continue2 == 1:
                    print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
                    scene1 = int(input())
                else : break
            if scene1 == 3:
                player1.Game_scene3()
                print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
            if scene1 == 2:
                player1.Game_scene2()
                print("修炼结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
            if scene1 == 1:
                player1.Game_scene1()
                print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
            print("是否继续:1.继续 2.退出")
            continue2 = int(input())
            if continue2 == 1:
                print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
                scene1 = int(input())
            else:
                    break
        else : break
    while scene1 == 2:
        player1.Game_scene2()
        print("修炼结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        print("是否继续:1.继续 2.退出")
        continue2 = int(input())
        if continue2 == 1:
            print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
            scene1 = int(input())
        else:
            break
        if scene1 == 3:
            player1.Game_scene3()
            print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        if scene1 == 2:
            player1.Game_scene2()
            print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        if scene1 == 1:
            player1.Game_scene1()
            print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        print("是否继续:1.继续 2.退出")
        continue2 = int(input())
        if continue2 == 1:
            print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
            scene1 = int(input())
        else:
            break
    while scene1 == 3:
        player1.Game_scene3()
        print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        print("是否继续:1.继续 2.退出")
        continue2 = int(input())
        if continue2 == 1:
            print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
            scene1 = int(input())
        else:
            break
        if scene1 == 3:
            player1.Game_scene3()
            print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        if scene1 == 2:
            player1.Game_scene2()
            print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        if scene1 == 3:
            player1.Game_scene3()
            print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        print("是否继续:1.继续 2.退出")
        continue2 = int(input())
        if continue2 == 1:
            print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
            scene1 = int(input())
        else:
            break
if figure == 3:
    print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
    scene1 = int(input())
    while scene1 == 1:
        player1.Game_scene1()
        print("战斗结束"+"\n",player1.G_name,player1.G_sex,player1.G_age,"剩余战斗力:",player1.G_fighting)
        if player1.G_fighting <=0 :
            print("战斗力小于0,游戏结束")
            break
        print("是否继续:1.继续 2.退出")
        continue1 = int(input())
        if continue1 == 1:
            print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
            scene1 = int(input())
            if scene1 == 2:
                player1.Game_scene2()
                print("修炼结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
                print("是否继续:1.继续 2.退出")
                continue2 = int(input())
                if continue2 == 1:
                    print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
                    scene1 = int(input())
                else : break
            if scene1 == 3:
                player1.Game_scene3()
                print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
            if scene1 == 2:
                player1.Game_scene2()
                print("修炼结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
            if scene1 == 1:
                player1.Game_scene1()
                print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
            print("是否继续:1.继续 2.退出")
            continue2 = int(input())
            if continue2 == 1:
                print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
                scene1 = int(input())
            else:
                    break
        else : break
    while scene1 == 2:
        player1.Game_scene2()
        print("修炼结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        print("是否继续:1.继续 2.退出")
        continue2 = int(input())
        if continue2 == 1:
            print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
            scene1 = int(input())
        else:
            break
        if scene1 == 3:
            player1.Game_scene3()
            print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        if scene1 == 2:
            player1.Game_scene2()
            print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        if scene1 == 1:
            player1.Game_scene1()
            print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        print("是否继续:1.继续 2.退出")
        continue2 = int(input())
        if continue2 == 1:
            print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
            scene1 = int(input())
        else:
            break
    while scene1 == 3:
        player1.Game_scene3()
        print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        print("是否继续:1.继续 2.退出")
        continue2 = int(input())
        if continue2 == 1:
            print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
            scene1 = int(input())
        else:
            break
        if scene1 == 3:
            player1.Game_scene3()
            print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        if scene1 == 2:
            player1.Game_scene2()
            print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        if scene1 == 3:
            player1.Game_scene3()
            print("游戏结束" + "\n", player1.G_name, player1.G_sex, player1.G_age, "剩余战斗力:", player1.G_fighting)
        print("是否继续:1.继续 2.退出")
        continue2 = int(input())
        if continue2 == 1:
            print("请选择游戏场景:(1.草丛战斗 2.自我修炼 3. 多人游戏)")
            scene1 = int(input())
        else:
            break

  • 写回答

1条回答 默认 最新

  • Ju_guan 2022-04-26 15:52
    关注

    有以下三个游戏人物有如下属性:
    姓名,性别,年龄,战斗力
    小A,女,18,1000
    小B,男,20,1800
    小C,女,19,2500
    选择游戏人物在以下三个游戏场景中模拟游戏:
    1.草丛战斗(-200战斗力)
    2.自我修炼(+100战斗力)
    3.多人游戏(-500战斗)

    评论

报告相同问题?

问题事件

  • 专家修改了标签 5月31日
  • 系统已结题 5月4日
  • 请详细说明问题背景 4月26日
  • 创建了问题 4月26日

悬赏问题

  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程