예제 #1
0
while running:
    print("===================================================")
    player.choose_action()
    choice = input("Choose action: ")
    index = int(choice) - 1
    #action process
    if index == 0:
        dmg = player.hit_damage()
        enemy.take_damage(dmg)
        print("You hit for", dmg, "points!")

        enemy_dmg = enemy.hit_damage()
        player.take_damage(enemy_dmg)
        print("Enemy hit for", enemy_dmg, "points!")
        print("\nEnemy's hp: ", bcolors.FAIL,
              str(enemy.get_hp()) + "/" + str(enemy.get_maxhp()), bcolors.ENDC)
        print("\nYour hp: ", bcolors.OKGREEEN,
              str(player.get_hp()) + "/" + str(player.get_maxhp()),
              bcolors.ENDC)
        print("Your mp: ", bcolors.OKBLUE,
              str(player.get_mp()) + "/" + str(player.get_maxmp()),
              bcolors.ENDC)
        print("===================================================")
    #magic process
    elif index == 1:
        player.choose_magic()
        magic_choice = int(input("Choose magic: ")) - 1
        #method 1 starts here
        cost = magic[magic_choice]["cost"]
        current_mp = player.get_mp()
        if cost > current_mp:
예제 #2
0
파일: main.py 프로젝트: pedrolmr/rpgbattle
player = Person(460, 65, 60, 34, magic)
enemy = Person(1200, 65, 45, 25, magic)

running = True
i = 0

print(bcolors.FAIL + bcolors.BOLD + "AN ENEMY ATTACKS" + bcolors.ENDC)
while running:
    print("======================")
    player.choose_action()
    choice = input("Choose action:")
    index = int(choice) - 1
    if index == 0:
        dmg = player.generate_damage()
        enemy.take_damage(dmg)
        print("you attacked for", dmg, "points of damage. enemy HP:",
              enemy.get_hp())

    enemy_choice = 1

    enemy_dmg = enemy.generate_damage()
    player.take_damage(enemy_dmg)
    print("Enemy attacks for", enemy_dmg, "player HP", player.get_hp())

    if enemy.get_hp() == 0:
        print(bcolors.OKGREEN + "You win" + bcolors.ENDC)
        running = False
    elif player.get_hp() == 0:
        print(bcolors.FAIL + "Your enemy has defeated you" + bcolors.ENDC)
        running = False
예제 #3
0
                print(
                    bcolors.OKGREEN + "\n" + item.name + "heals for" +
                    str(item.prop), "HP" + bcolors.ENDC)
            elif item.type == "elixer":
                player.hp = player.maxhp
                player.mp = player.maxmp
                print(bcolors.OKGREEN + "\n" + item.name +
                      "fully restores HP/MP" + bcolors.ENDC)
            elif item.type == "attack":
                enemy.take_damage(item.prop)
                print(bcolors.FAIL + "\n" + item.name + "deals",
                      str(item.prop), "points of damage" + bcolors.ENDC)

    enemy_choice = 1

    enemy_dmg = enemy.generate_damage()
    player1.take_damage(enemy_dmg)
    print("Enemy attacks for", enemy_dmg)

    print("---------------")
    print(
        "Enemy HP: ", bcolors.FAIL + str(enemy.get_hp()) + "/" +
        str(enemy.get_max_hp()) + bcolors.ENDC + "\n")

    if enemy.get_hp() == 0:
        print(bcolors.OKGREEN + "You win!" + bcolors.ENDC)
        running = False
    elif player.get_hp() == 0:
        print(bcolors.FAIL + "Your enemy has defeated you!" + bcolors.ENDC)
        running = False
예제 #4
0
        player.get_stats()

    print("\n")

    for player in players:
        enemy.get_enemy_stats()

        player.choose_action()
        choice = input("    Choose action:")
        index = int(choice) - 1

        if index == 0:
            dmg = player.generate_damage()
            enemy.take_damage(dmg)
            print("You attacked for", dmg, "points of damage. Enemy HP:",
                  enemy.get_hp())
        elif index == 1:
            player.choose_magic()
            magic_choice = int(input("    Choose magic:")) - 1

            if magic_choice == -1:
                continue

            spell = player.magic[magic_choice]
            magic_dmg = spell.generate_damage()

            current_mp = player.get_mp()

            if spell.cost > current_mp:
                print(bcolors.FAIL + "\nNot enough MP" + bcolors.ENDC)
                continue