Exemplo n.º 1
0
enemy.stats()

# loop starts
running = True
while running:
    print("================")
    print(f"\t {player.name.upper()}")
    print("Choose your action: ")
    player.choose_action()
    choice_input = input("Choose a number >>> ")
    index = int(choice_input) - 1
    print(f"You chose {player.action[index]}")

    # physical attack
    if index == 0:
        dmg = player.generate_atk_damage()
        enemy.take_damage(dmg)
        print("================")
        print(f"You attacked and dealt to {enemy.name} {dmg} points of damage")
    elif index == 1:
        player.choose_magic()
        magic_choice = int(input("Choose your magic: "))
        magic_index = magic_choice - 1

        magic = player.magic[magic_index]

        # generate magical damage
        magic_damage = magic.generate_magic()
        magic_name = magic.name
        magic_cost = magic.mp_cost
Exemplo n.º 2
0
enemy.stats()
print("-----------------------------")
running = True
while running:
     #Player's turn
    print(player.name)
    print("Choose your action: ")
    player.choose_action()
    try:
    choice = int(input(">>>: "))
    except ValueError:
        print("Choose a number")
        continue
    action_index = choice - 1
    if action_index == 0:
        damage = player.generate_atk_damage()
        enemy.take_damage(damage)

        print("You attacked {} and dealt {} damage".format(enemy.name, damage))

    if action_index == 1:
        damage = player.choose_magic()
        magic_choice = int(input(">>>: "))
    else:
        print("Choose a correct number")
        continue

    #Enemy's turn

    enemy_choice = 0
    if enemy_choice == 0: