Exemplo n.º 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
Exemplo n.º 2
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()
Exemplo n.º 3
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
Exemplo n.º 4
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
def game_loop():

    creatures = [
        Creature('Toad', 1),
        Creature('Tiger', 12),
        Creature('Bat', 3),
        Creature('Dragon', 50),
        Creature('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 runs and hides taking time to recover...')
                print('The wizard returns revitalized')
        elif cmd == 'r':
            print('runaway')
        elif cmd == 'l':
            print('lookaround')
        else:
            print('OK, exiting game...bye homie!')
            break
        print()
Exemplo n.º 6
0
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
Exemplo n.º 7
0
def game_loop():

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

    #print(creatures)
    hero=Wizard('Gandolf', 75)

    while True:

        active_creature = random.choice(creatures)

        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 wizard returns revitalized")
        elif cmd == 'r':
            print('runaway')
        elif cmd == 'l':
            print(" The wizard {} takes in the sourrondings and see: ".format(hero.name))
            for c in creatures:
                print(" * A {} of level {}".format(c.name, c.level))
        else:
            print('ok, bye')
            break
        print()
Exemplo n.º 8
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 _setup_hero(self):
     self.log.trace("Setting up Hero")
     try:
         self.hero = Wizard("Gandolf", 75)
     except TypeError as e:
         print(f"There was a problem creating the hero")
         self.log.error("Problem setting up hero!")
         raise e
Exemplo n.º 10
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()
Exemplo n.º 11
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()
Exemplo n.º 12
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
Exemplo n.º 13
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
Exemplo n.º 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('A {} of level {} has appeared from a dark and foggy forrest...'
              .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 of the creatures, well done!')
            break

        print()
Exemplo n.º 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', 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()
Exemplo n.º 16
0
def game_loop():
    creatures = [
        Creature(),
        Creature(),
        Creature(),
        Creature(),
        Creature(),
        Creature(),
        Creature(),
        Creature(),
    ]

    hero = Wizard()

    while True:

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

        if cmd == 'a':
            print('attack ')
        elif cmd == 'r':
            print('runaway ')
        elif cmd == 'l':
            print('Look Around ')
        else:
            print('OK, exiting the Game.... bye!')
            break
Exemplo n.º 17
0
def run_game_loop():

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

    wizard = Wizard('Dunder', 75)

    while True:

        for i in creatures:
            print('Creature import: {}'.format(i))

        cmd = input(
            'Wizard has 3 options: [l]ook around, [a]ttack, [r]un away!')

        if cmd == 'l':
            print('Wizard looked around...')
        elif cmd == 'a':
            print('Wizard attacked!')
        elif cmd == 'r':
            print('Wizard runs...')
        else:
            print('Wizard exits!')
            break
Exemplo n.º 18
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()
Exemplo n.º 19
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()
Exemplo n.º 20
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()
Exemplo n.º 21
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
Exemplo n.º 22
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
Exemplo n.º 23
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()
Exemplo n.º 24
0
def game_loop():
    creatures = [
        SmallAnimal('Toad', 1),
        Creatures('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50, 50, True),
        Creatures('Evil Wizard', 99)
    ]

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

        if cmd == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                print("The Wizard has been knock out !!!")
                # print('Game Over !!!')
                time.sleep(5)
                print("Wizard woke up and ready again")

        elif cmd == 'r':
            print('run away')
        elif cmd == 'l':
            print('the hero {} looks around and see others creatures to attack'.format(
                hero.name
            ))
            for c in creatures:
                print(' * A {} of level {}'.format(c.name, c.level))
        else:
            print('OK, we are exiting the game... bye bye')
            break

        if not creatures:
            print("The wizard has defeated all the creatures")
            break

        print()
Exemplo n.º 25
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()
Exemplo n.º 26
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()
Exemplo n.º 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
Exemplo n.º 28
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
Exemplo n.º 29
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()
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")
Exemplo n.º 31
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()
Exemplo n.º 32
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
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
Exemplo n.º 34
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:

        # Randomly choose a creature
        # random.choice will randomly choose a value from a collection object
        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):
                print("The wizard 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(" * {} level of {}".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()
Exemplo n.º 35
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]unaaway, or [l]ook around? ')
        if cmd == 'a':
            if hero.attack(active_creature):
                creatures.remove(active_creature)
            else:
                # print("Game over.")
                # break
                print("The wizard runs and hides taking time to recover.")
                time.sleep(5)
                print("The wizard returns revitalized!")
        elif cmd == 'r':
            print('The wizard is unsure of his powers and flees!!!')
        elif cmd == 'l':
            print('look around')
            print("The wizard {} takes in the surroundings and sees: ".format(hero.name))
            for i in creatures:
                print("{} of level {}".format(i.name, i.level))
        else:
            print('Exiting game....goodbye!')
            break

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

        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):
                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
                ))
        else:
            print("OK, exiting game... bye!")
            break

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

        print()
Exemplo n.º 37
0
def game_loop():

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

    ]

    hero = Wizard('Gandolf', 75)


    while True:

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

        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 his time to recover...")
                time.sleep(5)
                print("The wizard returns, healed and rested")

        elif cmd == 'r':
            print('The wizard becomes nervous and flees')
        elif cmd == 'l':
            print('The wizard scans the surroundings finding : ')
            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 of the creatures")
            break

        print()
Exemplo n.º 38
0
def game_loop():
    creatures = [
        SmallAnimal('Toad', 1),
        Creature('Tiger', 12),
        SmallAnimal('Bat', 3),
        Dragon('Dragon', 50, 75, True),
        Creature('Evil Wizard', 1000)
    ]

    hero = Wizard('Gandolf', 84)
    # print(creatures)

    while True:

        active_creature = random.choice(creatures)
        print('A {} from level {} has appeared from a dark and steamy forest.'.format(active_creature.name, active_creature.level))
        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)
            else:
                print('The wizard runs and hides to recuperate.')
                time.sleep(1)
                print('The wizard returns revitalized!')
        elif cmd == 'r':
            print('The wizard is unsure 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
                ))
            print()
        else:
            print('OK, exiting game.')
            break
            
        if not creatures:
            print('You have defeated all!')
            break
Exemplo n.º 39
0
def game_loop():
    # Vi laver en liste med uhyrer/væsner af klassen Creature
    # Bemærk at de skal INSTANTIERES - vi kalder her deres constructor metode - og giver dem unikke egenskaber
    # Dvs nedenfor laver vi både et array med Creatures - og vi instantierer dem med forskellige egenskaber (kalder deres constructor metode)

    creatures = [
        Creature('Tudse', 1),
        Creature('Tiger', 12),
        Creature('Flagermus', 3),
        Creature('Drage', 50),
        Creature('Ond troldmand', 1000)
    ]

    # Og så laver vi også en tom helt...
    hero = Wizard('Gandalf', 75)

    # Debugging: Prøv at sætte et breakpoint her og køre programmet i debugmode
    while True:

        # Vi starter altid med at et eller andet væsen dukker op
        # Vi importerer random - og bruger random.choice til at vælge et creature fra vores creature-array

        active_creature = random.choice(creatures)

        print("En {} med level {} er kommet ud af en mørk og tåget skov...".format(
            active_creature.name, active_creature.level
            )
        )

        cmd = input('Vil du angribe[a], løbe din vej[l] eller bare kigge dig omkring[k]?')
        if cmd == 'a':
            print ('Angriber')
            hero.attack(active_creature)
        elif cmd == 'l':
            print ('Løber væk')
        elif cmd == 'l':
            print ('Kigger...')
        else:
            print('Exit')
            break
Exemplo n.º 40
0
def game_loop():
    creatures = [
        SmallAnimal('Toad', 1),
        SmallAnimal('Bat', 3),
        Creature('Tiger', 12),
        Dragon('Dragon', 50, 25, True),
        Wizard('Evil Wizard', 100)
    ]

    hero = Wizard('Gandolf', 75)

    while True:

        active_creature = random.choice(creatures)
        print('A {} of level {} appears out of a dark and foggy forest'.format(
            active_creature.name, active_creature.level))
        cmd = input('Do you [l]ook around, [a]ttack, or [r]unaway?').lower()
        if cmd == 'l':
            print('As the hero looks around, he sees: ')
            for c in creatures:
                print(' * ', c)
            print()
        elif cmd == 'a':
            if hero.attack(active_creature):
                print('The hero has triumphed over the nasty {}'.format(active_creature.name))
                creatures.remove(active_creature)
            else:
                print('The hero has been defeated and needs time to recover')
                time.sleep(5)
        elif cmd == 'r':
            print("The hero's confidence waivers, and he flees")
        else:
            print('okay, exiting game ... goodbye!')
            break

        if not creatures:
            print('you have defeated all of the monsters!')
            break