コード例 #1
0
def game_loop():
    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50, 100, True),
        Creature('Evil Wizard', 1000)
    ]
    # print(creatures)
    hero = Wizard('Gandolf', 75)
    while True:
        active_creature = random.choice(creatures)
        cmd = input("Do you [a]ttack, [r]unaway, or [l]ook around?")

        if cmd == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print("The wizard runs and hides taking time to recover...")
                time.sleep(5)
                print("The wizard returns revitalized!")
        elif cmd == 'r':
            print('The wizard has become unsure of his power and flees!')
        elif cmd == 'l':
            print("The wizard {} takes in the surroundings and sees...".format(hero.name))
            for c in creatures:
                print("* A {} of level {}".format(c.name, c.level))
        else:
            print("Ok, Existing game.... Bye!!!!")
            break
        if not creatures:
            print("You've defeated all the wizards, well done!")
            break
コード例 #2
0
def game_loop(player_name):

    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50, scaliness=20, breaths_fire=True),
        Dragon('Blue Dragon', 50, scaliness=100, breaths_fire=False),
        Wizard('Evil Wizard', 1000)
    ]

    hero = Wizard(player_name, 75)

    while True:

        active_creature = random.choice(creatures)

        print()
        print('A level {} {} has appeared from a dark and foggy forest ...'.
              format(active_creature.level, active_creature.name))

        cmd = input(
            '[Level {}] Do you [a]ttack, [r]un away , [t]rain, [l]ook around, or E[x]it game: '
            .format(hero.level)).rstrip().lower()
        if cmd == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print('The wizard runs and hides taking time to recover ...')
                time.sleep(5)
                print('The wizard returns well rested.')
        elif cmd == 'r':
            print('The wizard {} has become unsure of his powers and flees'.
                  format(hero.name))
        elif cmd == 'l':
            print('The wizard {} takes in the surroundings and sees:'.format(
                hero.name))
            for c in creatures:
                print(' * A {} of level {}'.format(c.name, c.level))
        elif cmd == 't':
            print(
                'The wizard {} takes two sticks and waves them saying random phrases:'
                .format(hero.name))
            hero.train()
        elif cmd == 'x':
            print('OK exiting game ... goodbye!')
            break
        else:
            print('Try again, unknown command!')

        if not creatures:
            print()
            print('*************************************************')
            print('You have defeated all your enemies, well done {}'.format(
                hero.name))
            break
コード例 #3
0
def game_loop():

    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50, 75, True),
        Wizard('Evil Wizard', 1000),
        Creature('birb', 90),
    ]

    print(creatures)

    hero = Wizard('Gandalf', 75)

    while True:

        active_creature = random.choice(creatures)

        print(
            'A {} of f level {} has apppeared from a dark and foggy forest...'.
            format(active_creature.name, active_creature.level))
        print()

        cmd = input('Do you [a]ttack, [r]unaway or [l]ook around? ')
        cmd = cmd.lower()

        if cmd == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print('The wizard runs and hides taking time to recover...')
                time.sleep(5)
                print('The wizard returns revitalized!')
                # print("Game over.")
                # break
        elif cmd == 'r':
            print('The wizard flees!')
        elif cmd == 'l':
            print('The wizard {} takes in the surroundings and sees:'.format(
                hero.name))
            for c in creatures:
                print(' * A {} of level {}'.format(c.name, c.level))
        else:
            print('OK. Exiting game... bye!')
            break

        if not creatures:
            print('You defeated all the creatures!')
            break

        print()
コード例 #4
0
def game_loop():
    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50, 75, True),
        Wizard('Evil Wizard', 1000)
    ]

    hero = Wizard('Gandalf', 75)

    while True:

        active_creature = random.choice(creatures)
        print('A {} of level {} has appeared from a dark and foggy forest...'.
              format(active_creature.name, active_creature.level))
        print()

        cmd = input('Do you [a]ttack, [r]unaway, or [l]ook around? ')
        if cmd == 'a':
            # print('attack')
            # print()

            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print("The wizard runs and hides taking time to recover...")
                time.sleep(5)
                print("The wizard returns revitalized!")

        elif cmd == 'r':
            # print('runaway')
            # print()

            print("The wizard has become unsure of his power and leaves.")
        elif cmd == 'l':
            # print('look around')
            # print()

            print('The wizard {} takes in the surroundings and sees: '.format(
                hero.name))
            for c in creatures:
                print(' * A {} of level {}'.format(c.name, c.level))
        else:
            print("OK, exiting game....bye!")
            print()
            break

        if not creatures:
            print("You've defeated all the creatures, well done!")
            break
コード例 #5
0
def game_loop():

    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50, random.randint(10, 50), random.choice([True, False])),
        Wizard('Evil Wizard', 1000), 
    ]

    hero = Hero('Gary', 76)

    while True:

        active_creature = random.choice(creatures)
        if active_creature.name == "Dragon":
            print('It is a DRAGON!')
            if active_creature.breathes_fire == True:
                print('It\'s breathing fire, look out!')
        else:
            print('A {} of level {} has appeared from the darkness!'.format(active_creature.name, active_creature.level))
        print("Gary is level {}!".format(hero.level))

        cmd = input('Do you [a]ttack, [r]un away, or [l]ook around? ').lower()
        if cmd == 'a':
            if hero.attack(active_creature):
                hero.level = hero.level + 150
                creatures.remove(active_creature)
            else:
                print("The wizard runs away to recover his strength...")
                time.sleep(5)
                print("The wizard has recovered")

        elif cmd == 'r':
            print('THE WIZARD BOOKS IT')

        elif cmd == 'l':
            print('The wizard looks around and sees:')
            for c in creatures:
                print(' * A {} of level {}'.format(c.name, c.level))
        else: 
            print('Exiting game...')
            break

        if not creatures:
            print("You've defeated the creatures! YOU WIN BUD")
            break

        print()
コード例 #6
0
def game_loop():
    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50, 75, True),
        Wizard('Evil Wizard', 1000)
    ]

    hero = Wizard('Gandolf', 75)

    while True:

        active_creature = random.choice(creatures)
        print(
            "A {} of level {} has appeared from a dark and foggy forest...\n".
            format(active_creature.name, active_creature.level))

        cmd = input(
            'Do you [a]ttack, [r]unaway or [l]ook around? \n').lower().strip()
        print()

        if cmd == 'a':
            # print('attack')
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print('The wizard runs and hides taking time to recover...')
                for sec in range(1, 6):
                    time.sleep(1)
                    print('{}... '.format(sec))
                print('The wizard returns revitalized!')
        elif cmd == 'r':
            print('The wizard has become unsure of his powers and flees!!!')
        elif cmd == 'l':
            print('The wizard {} takes in the surroundings and sees:'.format(
                hero.name))
            for c in creatures:
                print(' * A {} of level {}'.format(c.name, c.level))
        else:
            print('Ok, exiting game... bye!')
            break

        if not creatures:
            print('You defeated all the creatures, well done!')
            break

        print()
コード例 #7
0
ファイル: main.py プロジェクト: JoeDBee/simple_python
def game_loop():

    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50, 30, True),
        Wizard('Evil Wizard', 100)
    ]

    hero = Wizard('Gandalf', 75)

    while True:

        active_creature = random.choice(creatures)
        print(
            'A {} of level {} has appeared from a dark and spooky forest... \n'
            .format(active_creature.name, active_creature.level))

        cmd = input('Do you [a]ttack, [r]unaway, or [l]ook?')
        cmd = cmd.lower().strip()

        if cmd == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print("The wizard runs and hides taking time to recover...")
                time.sleep(3)
                print("The wizard returns revitalized!")

        elif cmd == 'r':
            print('The wizard runs away!')

        elif cmd == 'l':
            print('The wizard {} looks around and sees:'.format(hero.name))
            for creature in creatures:
                print(' * A {} of level {}'.format(creature.name,
                                                   creature.level))
        else:
            print('Exiting game...')
            break

        if not creatures:
            print('All creatures have been defeated!\n Exiting game...')
            break

        print()
コード例 #8
0
def game_loop():

    creatures = [
        SmallAnimal('Toad', 'croaks', 1, 3, "the pool skimmer"),
        Creature('Tiger', 'growls', 12, 20),
        SmallAnimal('Bat', 'squeaks', 3, 9, "a cave"),
        Dragon('Dragon', 'roars', 3, True, 50, 150, "it's mountainous lair"),
        Wizard('Evil Wizard', 'yells', 500, 550, "a spooky castle"),
    ]

    hero = Wizard("Gandalf", 750)

    while True:

        active_creature = random.choice(creatures)
        print("\nA {} has appeared from {} and {} at you.\n".format(
            active_creature, active_creature.domain, active_creature.sound))

        cmd = str.lower(
            input("Do you [a]ttack, [r]unaway, [l]ook around, or [q]uit?"))

        if cmd == "a":
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print("{} runs and hides taking time to recover...".format(
                    hero.name))
                time.sleep(3)
                print("{} has returned revitalized".format(hero.name))

        elif cmd == "r":
            print("{} has become unsure and flees".format(hero.name))

        elif cmd == "l":
            print("Creatures Left:")
            for c in creatures:
                print("A {}".format(c))

        elif cmd == "q":
            print("Goodbye")
            break
        else:
            print("I don't understand the command {}".format(cmd))

        if not creatures:
            print("You defeated all of the creatures and won the game!")
            break
コード例 #9
0
ファイル: program.py プロジェクト: gth158a/wizard_battle
def game_loop():

    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50, 75, True),
        Wizard('Evil Wizard', 1000),
    ]
    #print(creatures)

    hero = Wizard('Gandolf', 75)

    while True:

        active_creature = random.choice(creatures)
        print("A {} of level {} has appeared from a dark and foggy forest".
              format(active_creature.name, active_creature.level))
        print()

        cmd = input('Do you [a]ttack, [r]unaway, or [l]ook around? ')

        if cmd == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print("The wizard run and hides taking time to recover...")
                time.sleep(5)
                print('The wizard returns revitalized!')

        elif cmd == 'r':
            print('{} decided to run away'.format(hero.name))

        elif cmd == 'l':
            print('The wizard {} takes in the surroundings and sees: '.format(
                hero.name))
            for c in creatures:
                print(" * A {} of level {}".format(c.name, c.level))
        else:
            print("Good Bye!!")
            break

        if not creatures:
            print("You've defeated all the creatures, well done!")
            break

        print()
コード例 #10
0
def game_loop():
    creatures = [
        SmallAnimal('Toad', 1),
        # Predator('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Red Dragon', 50, 75, True),
        Dragon('Blue Dragon', 50, 50, False),
        Wizard('Evil Wizard', 1000),
    ]

    hero = Wizard('Usidore', 75)

    while True:

        active_creature = random.choice(creatures)
        print("A {} of level {} has appeared from a dark and foggy forest...".
              format(active_creature.name, active_creature.level))

        print()

        cmd = input("Do you [a]ttack, [r]un, or [l]ook around? ")

        if cmd == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print("The wizard runs and hides taking time to recover...")
                time.sleep(5)
                print("The wizard returns revitalized!")

        elif cmd == 'r':
            print("The wizard {} has become unsure of his power and flees".
                  format(hero.name))
        elif cmd == 'l':
            print('The wizard {} takes in the surroundings and sees:'.format(
                hero.name))
            for c in creatures:
                print(' * A {} of level {}'.format(c.name, c.level))
        else:
            print("OK, exiting game, goodbye!")
            break

        if not creatures:
            print("You defeated all of the creatures!  Well done!")
            break

        print()
コード例 #11
0
def game_loop():

    creatures =[
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50,75,True),
        Wizard('Evil Wizard',1000)

    ]

    hero = Wizard('Gandolf',75)




    while True:

        active_creature = random.choice(creatures)
        print("A {} of level {} has appeared from a dark and foggy forest".format(active_creature.name, active_creature.level))
        print()
        cmd = input("Do you [a]ttack, [r]un away, or [l]ook around? ").lower()
        if cmd =='a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print("The wizard runs and hides to recover...")
                time.sleep(5)
                print("The wizard returns revitalized")


        elif cmd =='r':
            print('The wizard is unsure of his power and runs away')
        elif cmd == 'l':
            print("the wizard, {}, takes in the surrondings and sees:".format(hero.name))
            for c in creatures:
                print(" * A {} of level {}".format(c.name,c.level))
        else:
            print("ok, exiting game...bye!")
            break

        if not creatures:
            print("You have defeated all the creatures")
            break

        print()
コード例 #12
0
def game_loop():
    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50, 75, True),
        Wizard('Evil Wizard', 1000),
    ]

    wizard_name = input('What is your name Wizard?')
    hero = Wizard(wizard_name, 75)
    print('Hello wizard {}'.format(wizard_name))

    while True:

        active_creature = random.choice(creatures)
        print('A {} of level {} has appeared from a dark and foggy forest... '
              .format(active_creature.name, active_creature.level))
        print()

        cmd = input('Do you [a]ttack, [r]unaway, or [l]ook around?')
        if cmd == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print("The wizard {} runs and hides taking time to recover..."
                      .format(hero.name))
                time.sleep(5)
                print("The wizard {} returns revitalized!"
                      .format(hero.name))
        elif cmd == 'r':
            print('The wizard {} has become unsure of his power and flees.'
                  .format(hero.name))
        elif cmd == 'l':
            print("The wizard {} takes in the surroundings and sees:"
                  .format(hero.name))
            for c in creatures:
                print(' * A {} of level {}'.format(c.name, c.level))
        else:
            print('Ok Exiting game. Bye.')
            break

        if not creatures:
            print("You defeated all the creatures!")

        print()
コード例 #13
0
ファイル: program.py プロジェクト: GoranAviani/wizard
def game_loop():

    creatures = [
        SmallAnimal("Toad", 1),
        Creature("Tiger", 12),
        SmallAnimal("Bat", 3),
        Dragon("Dragon", 50, 30, True),
        Wizard("Evil Wizard", 1000),
    ]

    hero = Wizard("Gandols", 75)

    print(creatures)

    while True:
        active_creature = random.choice(creatures)
        print("{} of level {} has appeared from the forrest\n".format(
            active_creature.name, active_creature.level))

        userInput = input("Do you [A]ttack, [R]un away or [L]ook around: ")
        userInput = userInput.upper()

        if userInput == "A":
            heroWon = hero.attack(active_creature)
            if heroWon:
                creatures.remove(active_creature)
            else:
                print("{} is knocked down and needs time to recover".format(
                    hero.name))
                time.sleep(5)
                print("The {} returns..".format(hero.name))

        elif userInput == "R":
            print("Print the wizard has become unsure of him and flees....")
        elif userInput == "L":
            print("The wizard {} looks around and sees: ".format(hero.name))
            for c in creatures:
                print("*** A {} of level {} ***".format(c.name, c.level))

        else:
            print("Exiting game....")
            break

        if not creatures:
            print(" You defeated all the creatures.")
            break
コード例 #14
0
def game_loop():

    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50, 75, True),
        Wizard('Evil Wizard', 1000),
    ]

    # print(creatures)

    hero = Wizard('Gandalf', 75)

    while True:

        active_creature = random.choice(creatures)
        print(f'A {active_creature.name} of level {active_creature.level} '
              f'has appeared from a dark and foggy forest...')

        cmd = input('Do you [a]ttack, [r]unaway or [l]ookaround? ')
        if cmd == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print(f'The Wizard runs and hides taking time to recover....')
                time.sleep(5)
                print(f'The Wizard returns revitalized')

        elif cmd == 'l':
            print(
                f'The Wizard {hero.name} takes in the surroundings and sees: ')
            for c in creatures:
                print(f' * A {c.name} of level {c.level}')

        elif cmd == 'r':
            print('The Wizard has become unsure of its power and flees....')
        else:
            print('OK... exiting game')
            break

        if not creatures:
            print(f'You have defeated all the creatures, well done!')
            break

        print()
コード例 #15
0
def game_loop():

    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50, 75, True),
        Wizard('Evil Wizard', 1000)
    ]

    hero = Wizard('Gandolf', 27)

    while True:

        active_creature = random.choice(creatures)
        print(
            "A {} of level {} has appeared from the dark and foggy forest ...".
            format(active_creature.name, active_creature.level))
        print("")

        cmd = raw_input(
            "Do you want to [a]ttack, [r]un away, or [l]ook around? ")
        if cmd == 'a':

            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print("The wizard runs and hides to take time to recover...")
                time.sleep(5)
                print("The wizard returns revitalized!")

        elif cmd == 'r':
            print("The wizard has been unsure of his powers and runs away")

        elif cmd == 'l':
            print("Wizard {} takes in the surroundings and sees: ".format(
                hero.name))
            for i in creatures:
                print("* A {} of level {}".format(i.name, i.level))
        else:
            print("OK. Exiting game....bye")
            break

        if not creatures:
            print("You've defeated all the creatures")
            break
コード例 #16
0
def game_loop():

    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50, scaliness=50, breaths_fire=True),
        Wizard('Evil Wizard', 1000)
    ]

    hero = Wizard('Gandolf', 75)

    while True:

        active_creature = random.choice(creatures)
        print('-----------------------------------------------------------')
        print('A {} with level {} has appeared.'.format(
            active_creature.name, active_creature.level))
        print()

        selection = input('Do you [a]ttack, [r]un-away, or [l]ook around? ')

        if selection == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print("The wizard now hides to recover.")
                time.sleep(5)
                print("The wizard returns now")
        elif selection == 'r':
            print("The wizard flees...")
            print()

        elif selection == 'l':
            print("The wizard looks around and notices;")
            for i, creature in enumerate(creatures):
                print('  ({}) {}'.format(i + 1, creature))
            print()

        else:
            print('Exiting game...')
            break

        if not creatures:
            print("You defeated all the creatures.  Exiting the game!")
            break
コード例 #17
0
def game_loop():

    creatures = [  # Instantiate our creatures
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50, 75, True),
        Wizard('Evil Wizard', 250)
    ]

    # print(creatures)  # we can do this because we created the __repr__ method in class Creatures

    hero = Wizard('Gandolf', 75)  # Instantiate our hero

    while True:

        active_creature = random.choice(creatures)
        print('A {} of level {} has appeared from a dark and foggy forest ...'.
              format(active_creature.name, active_creature.level))
        print('')

        cmd = input('Do you [a]ttack, [r]unaway, or [l]ook around?')
        if cmd == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print('The wizard runs and hides taking time to recover ...')
                time.sleep(5)
                print('The wizard returns revitalized!')
        elif cmd == 'r':
            print('The wizard has become unsure of his power and flees!')
        elif cmd == 'l':
            print('The wizard {} takes in the surroundings and sees:'.format(
                hero.name))
            for c in creatures:
                print(' * A {} of level {}'.format(c.name, c.level))
        else:
            print('ok, exiting game ... bye')
            break

        if not creatures:
            print('You defeated all the creatures, well done!!')
            break

        print("")
コード例 #18
0
ファイル: wizard-game.py プロジェクト: ramitch91/rmtest_repo
def game_loop():
    creatures = [
        SmallAnimal('Toad', 1),
        SmallAnimal('Bat', 5),
        Creature('Tiger', 10),
        Dragon('Red Dragon', 100, 50, True),
        Dragon('Green Dragon', 75, 50, False),
        Dragon('Black Dragon', 150, 75, True),
        Wizard('Evil Wizard', 1000)
    ]
    #    for creature in creatures:
    #        print(f"{creature.name}: Level {creature.level}")

    hero = Wizard('Gandolf', 250)
    #    print(f"{hero.name} is level {hero.level}")

    while True:
        active_creature = random.choice(creatures)
        print(f"A {active_creature.name} of level {active_creature.level} "
              f"comes out of a foggy forest...")
        print()
        cmd = input("Do you [a] attack, [r] run away, [l] look around: ")
        if cmd.lower() == 'a':
            if hero.attack(active_creature):
                hero.level = hero.level + (active_creature.level * 5)
                creatures.remove(active_creature)
            else:
                print("The wizard runs and hides taking time to recover.... ")
                time.sleep(5)
                print()
                print("The wizard is back and revitalized")

        elif cmd.lower() == 'r':
            print(f'The wizard is unsure of his power and flees.')
        elif cmd.lower() == 'l':
            print(f"The wizard looks to see what creatures may be around.")
            for c in creatures:
                print(f"* A {c.name} at level {c.level}")
        else:
            print('OK, goodbye.....exiting game')
            break

        if len(creatures) == 0:
            print(f"{hero.name} has defeated all of the creatures.")
            break
コード例 #19
0
def game_loop():
    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50, 20, True),
        Wizard('Evil Wizard', 1000)
    ]

    hero = Wizard('Gandolf', 75)

    # print(creatures)

    while True:

        active_creature = random.choice(creatures)
        print()
        print('A {} of level {} has appear from a dark and foggy forest...'.
              format(active_creature.name, active_creature.level))
        print()

        cmd = input('Do you [a]ttack, [r]unaway or [l]ook around? ')
        if cmd == 'a':
            if hero.attack(active_creature):
                creatures.remove(
                    active_creature
                )  # if creature is defeated, it should be removed from active creatures
            else:
                print("The wizard runs and hides taking time to recover...")
                time.sleep(5)  # delay 5 seconds
                print("The wizard returns revitalized!")
        elif cmd == 'r':
            print('The wizard has become unsure of his powers and flees!!!')
        elif cmd == 'l':
            print('The wizard {} takes in the sorroundings and sees:'.format(
                hero.name))
            for c in creatures:
                print(' * A {} of level {}'.format(c.name, c.level))
        else:
            print('OK, exiting game... bye!')
            break

        if not creatures:  # This is 'activated' if creatures-list is empty
            print("You've defeated all the creatures, well done!")
            break
コード例 #20
0
def game_loop():

    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50, 50, True),
        Wizards('Evil Wizard', 1000)
    ]

    hero = Wizards('Gandolf', 75)

    while True:

        active_creature = random.choice(creatures)
        print('A {} of level {} has appeared from a dark and foggy forest...'
              .format(active_creature.name, active_creature.level))
        print()

        cmd = input("Do you want to [a]ttack, [r]unaway, or [l]ook around? ")

        if cmd == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print('The wizard runs and hides to recover...')
                time.sleep(5)
                print('The wizards health has returned...')

        elif cmd == 'r':
            print('The wizard feels unsure of his chances and flees...')
        elif cmd == 'l':
            print('The wizard {} take a moment to check his surroundings and sees: '.format(hero.name))
            for c in creatures:
                print(' * A {} of level {}'. format(c.name, c.level))
        else:
            print('Ok, exiting the game... bye!')
            break

        if not creatures:
            print('Well Done. You defeated all the evils of the forest!')
            break

        print()
コード例 #21
0
ファイル: wizardApp.py プロジェクト: osbornetunde/wizardApp
def game_loop():

    creatures = [
        SmallAnimal("Toad", 1),
        Creature("Tiger", 12),
        SmallAnimal("Bat", 3),
        Dragon("Dragon", 50, 75, True),
        Wizard("Evil wixard", 1000),
    ]

    hero = Wizard("Gandolf", 75)

    while True:

        active_creature = random.choice(creatures)
        print(active_creature)
        #print("A {} of level {} has appear from a dark and foggy forest....".format
        #(active_creature.name, active_creature.level))
        print()

        cmd = input("Do you want to [a]ttack, [r]unaway, or [l]ook around? ")
        if cmd == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print("The wizard runs and hides taking time to recover...")
                time.sleep(5)
                print("The wizard returns revitalized!")
        elif cmd == 'r':
            print("The wizard has become unsure of his powers and flees!!!!")
        elif cmd == 'l':
            print('The wizard {} takes in the surroundings and sees:'.format(
                hero.name))
            for c in creatures:
                print(" * A {} of level {}".format(c.name, c.level))
        else:
            print("OK, exiting game... bye!")
            break

        if not creatures:
            print("You've defeated all the creatures, well done!")
            break

        print()
コード例 #22
0
def game_loop():
    creatures = [
        SmallAnimal("Toad", 1),
        Creature("Tiger", 12),
        SmallAnimal("Bat", 3),
        Dragon("Dragon", 50, 30, True),
        Wizard("Evil Wizard", 1000),
    ]

    hero = Wizard("Gandalf", 75)

    while True:

        active_creature = random.choice(creatures)
        print("A {} of level {} has appeared from a dark and foggy forest...".
              format(active_creature.name, active_creature.level))

        cmd = input(
            "Do you want to [a]ttack, [r]unaway, [l]ook around or e[x]it?  ")
        if cmd == "a":
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                # print("Game over!")
                print("The wizard hides taking time to recover...")
                time.sleep(5)
                print("The wizard returns revitalized!")
        elif cmd == "r":
            print("The wizard has become unsure of his power and flees!!!")
        elif cmd == "l":
            print("The wizard {} takes in the surroundings and sees:".format(
                hero.name))
            for creature in creatures:
                print(" * A {} of level {}".format(creature.name,
                                                   creature.level))
        elif cmd == "x":
            print("exiting the game... bye!")
            break
        else:
            print("I dont understand that, please try again.")

        if not creatures:
            print("You defeated all the creatures!!")
            break
コード例 #23
0
def game_loop():

    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50),
        Wizard('Evil Wizard', 1000),
    ]

    hero = Wizard('Gandolf', 75)

    while True:

        active_creature = random.choice(creatures)
        print(f'A {active_creature.name} of level {active_creature.level} has '
              f'appeared from a dark and foggy forrest...\n')

        cmd = input(
            'Do you [a]ttack, [r]un away or [l]ook around? ').strip().lower()
        if cmd == 'a':
            # Assumption: only wizards can attack creatures. Creatures never initiate an attack.
            if hero.attack(active_creature):  # win
                creatures.remove(active_creature)
            else:
                print('The wizard runs and hides taking time to recover...')
                time.sleep(5)
                print('The wizard returns revitalized!')
        elif cmd == 'r':
            print('The wizard has become unsure of his power and flees!')
        elif cmd == 'l':
            print(
                f'The wizard {hero.name} takes in the surroundings and sees:')
            for c in creatures:
                print(f'  * A {c.name} of level {c.level}')
        else:
            print('OK, exiting the game... bye!')
            break

        if not creatures:
            print("You've defeated all the creatures, well done!")
            break

        print()
コード例 #24
0
def game_loop():
    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50, 20, False),
        Wizard('Evil Wizard', 100)
    ]
    hero = Wizard('Hero', random.randint(0, 100))

    while True:
        active_creature = random.choice(creatures)
        print("A {} of level {} has appear from the dark... ".format(
            active_creature.name, active_creature.level))

        cmd = input(
            'Do you [a]ttack, [r]unaway, or [l]ook around? Or you want to e[x]it? '
        )
        if cmd == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print(
                    'The wizard needs to recover. The wizard runs and hides... '
                )
                time.sleep(5)
                print('The wizard returns revitalized! ')

        elif cmd == 'r':
            print('The wizard')
        elif cmd == 'l':
            print('The wizard takes a look and sees... ')
            for creature in creatures:
                print(' * A {} of level {} * '.format(creature.name,
                                                      creature.level))
        elif cmd == 'x':
            print("It's sad to see you go. Bye ;( ...")
            break
        else:
            print('Unknown command. Try again.')

        if not creatures:
            print("CONGRATULATIONS!!! You've won the GAME!!!")
            break
コード例 #25
0
def game_loop():

    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50, 75, True),
        Wizard('Evil Wizard', 1000)
    ]

    hero = Wizard('Gandolf', 75)

    while True:

        active_creature = random.choice(creatures)

        print(
            'A {} of level {} has appeared from a dark and foggy forest... \n'.
            format(active_creature.name, active_creature.level))

        cmd = input('Do you [a]ttack, [r]un away, or [l]ook around? ')

        if cmd == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print("The wizard rests to regain strength...")
                time.sleep(5)
                print("The wizard returns...")
        elif cmd == 'r':
            print('The wizard has become unsure of his power and flees.')
        elif cmd == 'l':
            print('The wizard {} takes in the surroundings and sees:'.format(
                hero.name))
            for c in creatures:
                print('* A {} of level {}'.format(c.name, c.level))
        else:
            print('Ok, exiting game... bye!')
            break

        if not creatures:
            print('You defeated all the creatures')
            break
コード例 #26
0
ファイル: program.py プロジェクト: oskarmampe/PythonScripts
def game_loop():

    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50, 75, True),
        Wizard('Evil Wizard', 1000),
    ]

    hero = Wizard('Gandalf', 1075)

    while True:

        if not creatures:
            print("You defeated all the creatures, well done!")
            break

        active_creature = random.choice(creatures)
        print('A {} of level {} has appeared from a dark and foggy forest'.
              format(active_creature.name, active_creature.level))

        cmd = input("Do you [a]ttack [r]un or [l]ook around ")
        if cmd == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print("Game Over")
                exit()
        elif cmd == 'r':
            print('The wizard is unsure of his power and flees!!')
        elif cmd == 'l':
            print('The wizard {} takes in the surroundings and sees:'.format(
                hero.name))
            for c in creatures:
                print(' * A {} of level {}'.format(c.name, c.level))
        else:
            if not creatures:
                print("You defeated all the creatures, well done!")
                break
            print('OK, exiting game')
            break
コード例 #27
0
def game_loop():

    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50, False),
        Dragon('Dragon', 50, True),
        Creature('Evil Wizard', 1000)
    ]

    hero = Wizard('Gandolf', 75)

    while True:
        active_creature = random.choice(creatures)
        print(f'A {active_creature} has appear from a dark and a foggy forest...')
        command = input('Do you [a]ttack, [r]unaway, or [l]ook around? ')

        if command == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print('The wizard runs and hides taking time to recover')
                time.sleep(5)
                print('The wizard returns revitalized!')

        elif command == 'r':
            print('The wizard has becomes unsure of his power and flees!')

        elif command == 'l':
            print(f'The wizard {hero.name} takes in the surrounding and sees: ')
            for creature in creatures:
                print(creature)

        else:
            print('OK, exiting game..... bye!')
            break

        print()
        if not creatures:
            print('You defeated all creatures! you WON!')
            break
コード例 #28
0
def game_loop():

    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 20, 30, True),
        Wizard('Evil Wizard', 50)
    ]

    hero = Wizard('Gandolf', 40)

    while True:

        active_creature = random.choice(creatures)
        print('A {} of level {} has appear from a dark and foggy forest...'.
              format(active_creature.name, active_creature.level))
        print()

        cmd = input('Do you [a]ttack, [r]unaway, or [l]ook around?')
        if cmd == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print("The wizard run and hides taking time to recover...")
                time.sleep(5)
                print("The hero has returned revived.")
        elif cmd == 'r':
            print("The wizard has become unsure of his power and flees!!!")
        elif cmd == 'l':
            print('The wizard {} takes in the surroundings and sees:'.format(
                hero.name))
            for c in creatures:
                print(' * A {} of level {}'.format(c.name, c.level))
        else:
            print("Ok, exiting game..., bye!")
            break

        if not creatures:
            print(
                "You have defeated all the creatures and saved the kingdom from the Evil Wizard!"
            )
コード例 #29
0
ファイル: program.py プロジェクト: dsod/tptm_BuildTenApps
def game_loop():

    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Fox', 5),
        SmallAnimal('Deadly Snake', 12),
        Dragon('Dragon', 100, 25, True),
        Wizard('Evil Wizard', 500),
    ]

    hero = Wizard('Gandolf', 75)

    while True:

        active_creature = random.choice(creatures)
        print(
            'A {} of Level {} has appeared out of a dark and foggy forest...'.
            format(active_creature.name, active_creature.level))

        cmd = input('Do you [a]ttack, [r]unaway, or [l]ook around?')
        cmd = cmd.lower()
        if cmd == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print("The Wizard runs and take time to recover.")
                time.sleep(5)
                print("The Wizard returns revitalized")
        elif cmd == 'r':
            print('The Wizard {} has become unsure of his powers and flees.'.
                  format(hero.name))
        elif cmd == 'l':
            for c in creatures:
                print("The wizard {} look around and a {} of level {}.".format(
                    hero.name, c.name, c.level))
        else:
            print('OK, exiting game... bye!')
            break
        if not creatures:
            print('You have defeated all the creatures!!')
            break
        print()
コード例 #30
0
def game_loop():

    creatures = [
        SmallAnimal("Toad", 1),
        Creature("Tiger", 12),
        SmallAnimal("Bat", 3),
        Dragon("Dragon", 50, 75, True),
        Wizard("Evil Wizard", 1000)
    ]
    hero = Wizard("Gandolf", 75)

    while True:

        active_creature = random.choice(creatures)
        print("A {} of level {} has appeared from a dark and foggy forest...".
              format(active_creature.name, active_creature.level))
        print()

        cmd = input("Do you [a]ttack, [r]unaway, or [l}ook around?")
        if cmd == "a":
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print("The wizard runs and hides taking time to recover...")
                time.sleep(5)
                print("The wizard return revitalized")
        elif cmd == "r":
            print("The wizard is unsure about his power and flees")
        elif cmd == "l":
            print("The wizard {} takes in the surroundings an sees: ".format(
                hero.name))
            for c in creatures:
                print(" * A {} of level {}".format(c.name, c.level))
        else:
            print("exiting")
            break

        if not creatures:
            print("You`ve defeated all the creatures, well done!")
            break

        print()