def game_loop():
    creatures = [
        Creature('Bat', 5, 5),
        Creature('Bat', 5, 5),
        Creature('Toad', 1, 1),
        Creature('Toad', 1, 1),
        Creature('Tiger', 12, 12),
        Creature('Tiger', 12, 12),
        Dragon('Black Dragon', 50, 50, scaliness=2, breaths_fire=False),
        Dragon('Red Dragon', 50, 50, scaliness=1, breaths_fire=True),
        Wizard('Evil wizard', 150, 150),
    ]

    hero = create_hero()

    while True:

        active_creature = random.choice(creatures)

        print('A {} of level {} appears 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)
                hero.level_up()
                hero.update_experience(active_creature)
                print("The wizard {} defeated {}".format(hero.name, active_creature.name))
            else:
                print("The wizard {} has been hurt by the powerful {}".format(hero.name, active_creature.name))
                if hero.health <= 0:
                    print("The hero {} has perished!".format(hero.name))
                    cmd = input('Do you wish to play again: [y]es or [no]?')
                    if cmd == 'y':
                        main()
                    else:
                        break
        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(" * {} 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()
示例#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 = [
        Creature('Bat', 5),
        Creature('Toad', 1),
        Creature('Tiger', 12),
        Dragon('Black Dragon', 50, scaliness=2, breathes_fire=False),
        Wizard('Evil Wizard', 1000)
    ]

    hero = Wizard('Gandalff', 75)

    while True:
        active_creature = random.choice(creatures)

        print(
            f'A {active_creature.name} of {active_creature.level} has arrived from the forest.'
        )
        selection = input(
            'What do you want to do? attack (a), run away (r), look around (l): '
        )

        if selection == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
                print(f'{hero.name} defeated {active_creature.name}.')
        elif selection == 'r':
            print(f'Wizard {hero.name} ran away safely.')
        elif selection == 'l':
            print(f'Wizard {hero.name} looks around and sees the following:')
            for c in creatures:
                print(c.name)
        else:
            print('Exiting the game....Bye')
            break
def game_loop():
    creatures = [
        Creature("Bat", 5),
        Creature("Toad", 1),
        Creature("Tiger", 12),
        Dragon("Dragon", 50, scaliness=2, breathes_fire=False),
        Wizard("Evil Wizard", 100),
    ]
    hero = Wizard("Gandolf", 75)
    while True:
        # randomly choose a creature
        active_creature = random.choice(creatures)
        print("A {} of level {} has appeared".format(active_creature.name,
                                                     active_creature.level))
        cmd = input("Do you [a] attack, [r]unaway, or [l]ook around? ")
        if cmd == "a":
            if hero.attack(active_creature):
                creatures.remove(active_creature)
                print("{} defeated the {}!".format(hero.name,
                                                   active_creature.name))
        elif cmd == "r":
            print("{} flees!".format(hero.name))
        elif cmd == "l":
            print("{} looks around and sees:".format(hero.name))
            for c in creature:
                print("* {} of level {}".format(c.name, c.level))
        else:
            print("Exiting game")
            break
        if not creatures:
            print("You've defeated all of the creatures")
            break
示例#5
0
def game_loop():

    creatures = [
        Dragon('Golden Dragon', 14, True),
        Creature('Hobbit', 1),
        Creature('Bat', 15),
        Creature('Evil Wizard', 100),
    ]

    hero = Wizard('James', 9)

    while True:

        active_creature = random.choice(creatures)
        print('A {} of level {} has appears'.format(active_creature.name,
                                                    active_creature.level))

        cmd = input('Do you [a]ttack, [r]un, or [c]heck? ')
        if cmd == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                time.sleep(5)
                print('Zzzzz you some how rest and recover from your injuries')
        elif cmd == 'r':
            print('run forest run')
        elif cmd == 'c':
            print('you look blindly around')
            for c in creatures:
                print(' A {} of level {}'.format(c.name, c.level))
        else:
            break
示例#6
0
def game_loop():
    player = Wizard('Wizardy Boy', 50)
    creatures = [
        SmallCreature('Rat', 1),
        Creature('Golem', 20),
        Dragon('Dragon (His name is Freddy)', 70, 20, True),
        Wizard('Evil Wizardy Boy', 200)
    ]
    current_enemy = random.choice(creatures)

    while True:
        print('You encounter a terrifying {}!'.format(current_enemy.name))
        action = input('Do you want to [A]ttack, [L]ook around or [R]un away?')
        action = action.lower()
        if action == 'a':
            result = player.attack(current_enemy)
            if result:
                print('You win buddy!')
                current_enemy = random.choice(creatures)
            else:
                print('You dead.')
                break

        elif action == 'l':
            print('You look around and see:')
            for c in creatures:
                print(c.name)

        elif action == 'r':
            print('You run away from the {}!'.format(current_enemy))
            current_enemy = random.choice(creatures)

        else:
            print('Bye forever!')
            break
示例#7
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
示例#8
0
def game_loop():
	creatures = [
		Creature('Bat', 5),
		Creature('Toad', 1),
		Creature('Tiger', 12),
		# based on the order, you could just said 2 after 50 but just to be safe,
		# define it directly
		Dragon('Black Dragon', 50, scaliness=2, breathes_fire=False),
		# WHY IN THE WORLD WOULD YOU MAKE A WIZARD THAT IS SO HIGH A LVL THAT IT'S IMPOSSIBLE TO BEAT??
		# Wizard('Evil Wizard(aka Merlin)', 1000)
		Wizard('Evil Wizard(aka Merlin)', 100)
	]

	hero = Wizard('Gandolf', 75)

	"""
	let's make the game loop a little forgiving because it's possible that
	because it's possible that someone will accidentally hit the wrong key, so give
	the player three chances to hit a playable key, it's a global variable because
	while the game may be forgiving, it tells you the playable commends during the 
	game loop so you only have so many non renewable chances
	"""

	miss_counter = 3

	while True:
		# randomly select an oppenent creature
		active_creature = random.choice(creatures)

		# READY TO PLAY A GAME??
		# let the oppenent know what their oppnent in the game is
		print('A {} of level {} has appeared from a dark and foggy forrest...\n'.format(active_creature.name, active_creature.level))

		# get the player's input commands to interact in the game
		cmd = input('Do you [a]ttack, [r]unaway, or [l]ook around?')
		# depending on the options, this is what you're going to do
		if cmd == 'a':
			if hero.attack(active_creature):
				creatures.remove(active_creature)
				print("The wizard has defeated {}".format(active_creature.name))
			else:
				print("The wizard has been defeated by the powerful {}".format(active_creature.name))
		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(" * {} of level {}".format(c.name,c.level))
		else:
			miss_counter-=1
			print('You have {} attempts left to input a valid command before the game exits.'.format(miss_counter))
			if miss_counter == 0:
				print("OK, exiting the game...bye!")
				break

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

		print()
示例#9
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()
示例#10
0
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
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
 def _setup_creatures(self):
     try:
         self.creatures = [
             Creature("Bat", 5),
             Creature("Toad", 1),
             Creature("Tiger", 12),
             Dragon("Black Dragon", 50, scaliness=2, breaths_fire=False),
             Wizard("Evil wizard", 1000),
         ]
     except TypeError as e:
         print(f"There was a problem creating the creatures")
         raise e
示例#13
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()
示例#14
0
def game_loop():
    creatures = [
        Creature('Bat', 5),
        Creature('Toad', 1),
        Creature('Tiger', 12),
        Dragon('Black Dragon', 50, scaliness=2, breathes_fire=False),
        Wizard('Evil Wizard', 1000),
    ]

    hero = Wizard("Gandalf", 75)

    while True:

        # Randomly choose a creature
        active_creature = random.choice(creatures)

        print(
            f"A {active_creature.name} of level {active_creature.level} has appeared from a dark and foggy forest..."
        )
        print()

        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)
                print(f'The wizard defeated {active_creature.name}')

            else:
                print("The wizard has been defeated...temporarily")

            print()

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

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

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

        if not creatures:
            print("You've defeated all the creatures, well done!")
            break
示例#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('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
示例#16
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()
示例#17
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()
示例#18
0
def game_loop():
    creatures = [
        Creature('Bat', 5),
        Creature('Toad', 1),
        Creature('Tiger', 12),
        Dragon('Black Dragon', 50, scaliness=2, breaths_fire=False),
        Wizard('Evil wizard', 1000),
    ]

    hero = Wizard('Gandolf', 75)

    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? ')

        try:
            if cmd == 'a':
                if hero.attack(active_creature):
                    creatures.remove(active_creature)
                    print("The wizard defeated {}".format(
                        active_creature.name))
                else:
                    print(
                        "The wizard has been defeat by the powerful {}".format(
                            active_creature.name))
            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(" * {} of level {}".format(c.name, c.level))
        except ValueError:
            print('Please enter "a", "r", or "l".')

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

        print()
示例#19
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('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()
示例#20
0
def game_loop():
    creatures = [
        SmallCreature('Toad', 1),
        Creature('Tiger', 12),
        SmallCreature('Bat', 3),
        Dragon(name='Dragon', level=50, scaliness=75, breathes_fire=True),
        Wizard('Evil Wizard', 250),
    ]

    hero = Wizard('Gandalf', 75)

    while True:
        active_creature = random.choice(creatures)
        print(f'A {active_creature.name} of level {active_creature.level} has appeared.')
        print()

        cmd = input(f'Does {hero.name} [A]ttack, [R]un away, or [L]ook around? ').upper()

        if cmd == 'A':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
                print(f'{hero.name} has bested the {active_creature.name}!')
                print()
            else:
                print(f'{hero.name} was defeated by the {active_creature.name}!')
                print(f'{hero.name} runs away to heal', end='')
                for _ in range(0, 5):
                    print('.', end='')
                    sleep(1)
                print(f' all rested up and ready for adventure!')
                print()

        elif cmd == 'R':
            print(f'{hero.name}, unsure of his powers, flees.')
            print()
        elif cmd == 'L':
            print(f'{hero.name} looks around and sees:')
            for c in creatures:
                print(f' * {c.name} of level {c.level}')
            print()
        else:
            print('Exiting...')
            break

        if not creatures:
            print('You have defeated all the creatures...bye!')
            break
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
示例#22
0
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()
示例#23
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()
示例#24
0
def game_loop():

    # Create Creature Objects
    creatures = [
        SmallCreature("Goblin", 3),
        Dragon("Ridgeback", 10, 20, True),
        Wizard("DeathEater", 12),
        Wizard("Voldemort", 19),
        Creature("Troll", 8)
    ]

    # Create Hero Object
    hero = Wizard("David", 1000)

    # Play the Game
    while True:

        # Random Encounter
        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()

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

        # Attack
        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 their 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("Thanks for playing!")
            break

        print()
示例#25
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
示例#26
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("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
示例#27
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
示例#28
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()
def game_loop():
    creatures = {[
        Creature('Bat', 5),
        Creature('Toad', 1),
        Creature('Tiger', 12),
        Dragon('Black Dragon', 50, scaliness=2, breaths_fire=False),
        Wizard('Evil wizard', 1000)
    ]}

    hero = Wizard('Gandolf', 75)

    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):
                print(f"The wizard defeated {active_creature.name}")
            else:
                print(
                    f"The wizard has been defeated by the powerful {active_creature.name}"
                )
        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(f" * {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()

        # ask use for action

    print("Good bye")
示例#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]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()