示例#1
0
enemy = Person(1200, 65, 45, 25, [], [])

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.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 + "\n Not enough MP" + bcolors.ENDC)
示例#2
0
      bgcolor.ENDC)
print("====================================")

running = True
i = 0

# Game Starts
while running:
    player.choose_action()
    choice = int(input("Enter your Move no: "))
    choice -= 1
    current_mp = player.get_mp()
    # power attacks
    if choice == 0:
        dmg = player.get_atk_damage()
        enemy.take_damage(dmg)
        print("You attacked the enemy with", dmg, " points")

    # magic attacks
    elif choice == 1:
        player.choose_magic()
        magic_move = int(input("Enter your Choice no: "))
        magic_move -= 1
        spell = player.magic[magic_move]
        spell_name = spell.name

        if current_mp >= spell.cost:
            dmg = spell.get_spell_damage()
            if spell.type == "attack":
                enemy.take_damage(dmg)
                print("You attacked the enemy with", spell_name, " for ", dmg,
示例#3
0
player_items = [potion, hipotion, superpotion, elixer, hielixer]
#instantiate people
player = Person(460, 65, 60, 34, player_spells, player_items)
enemy = Person(1200, 65, 45, 25, [], [])
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")
    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 + "\n Not enough MP \n" + Bcolors.ENDC)
            continue
        player.reduce_mp(spell.cost)
        if spell.type == "white":
                player.mp = player.maxhp
                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.take_damage(magic_dmg)
    #    print(bcolors.OKBLUE + "\n" + spell.name + "deals", str(magic_dmg), "points of damage" + bcolors.ENDC)


    enemy_choice = 1



    enemy_dmg = enemy.generate_damage()
    player1.take_damage(enemy_dmg)
    print("enemy attacks for ", enemy_dmg, "Player HP:")

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

#    print("Your hp :", bcolors.OKGREEN + str(player.get_max_hp()) + "/" + str(player.get_hp())+ bcolors.ENDC)
#    print("your mp:", bcolors.OKBLUE + str(player.get_mp()) + "/" + str(player.get_max_mp())+ 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