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

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

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

 

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/737791.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-28
下一篇 2022-04-28

发表评论

登录后才能评论

评论列表(0条)

保存