示例#1
0
    "quantity": 5
}]

player = Person(500, 65, 60, 34, magic, items)
enemy = Person(1200, 65, 45, 25, magic, items)

running = True
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
示例#2
0
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:
        enemy_damage = enemy.generate_atk_damage()
示例#3
0
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
示例#4
0
        "NAME                 HP                                                    MP"
    )
    for player in players:
        player.get_stats()

    print("\n")

    for player in players:

        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)
        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\n" + bcolors.ENDC)
示例#5
0
    print("NAME                HP                                    MP")
    for player in players:
        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: