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()
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()
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
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()
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()
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()
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 = [ 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()
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) hero.wake_up() while True: active_creature = random.choice(creatures) print('A {} of level {} has appear from a dark and foggy forest...' .format(active_creature.name, active_creature.level)) print() cmd = input('Do you [a]ttack, [r]unaway, or [l]ook around? ') if cmd == 'a': if hero.attack(active_creature): creatures.remove(active_creature) else: print("The wizard 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've defeated all the creatures, well done!") break print()
def game_loop(): creatures = [ SmallAnimal('Toad', 1), Creature('Tiger', 12), SmallAnimal('Bat', 3), Dragon('Dragon', 50, 75, True), Wizard('Evil Wizard', 1000) ] hero = Wizard('Gandolf', 75) while True: active_creature = random.choice(creatures) print( 'A {} of level {} has appeared from a dark and foggy forest... \n'. format(active_creature.name, active_creature.level)) cmd = input('Do you [a]ttack, [r]un away, or [l]ook around? ') if cmd == 'a': if hero.attack(active_creature): creatures.remove(active_creature) else: print("The wizard rests to regain strength...") time.sleep(5) print("The wizard returns...") elif cmd == 'r': print('The wizard has become unsure of his power and flees.') elif cmd == 'l': print('The wizard {} takes in the surroundings and sees:'.format( hero.name)) for c in creatures: print('* A {} of level {}'.format(c.name, c.level)) else: print('Ok, exiting game... bye!') break if not creatures: print('You defeated all the creatures') break
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()
def game_loop(): creatures = [ SmallAnimal('Toad', 1), Creature('Fox', 5), SmallAnimal('Deadly Snake', 12), Dragon('Dragon', 100, 25, True), Wizard('Evil Wizard', 500), ] hero = Wizard('Gandolf', 75) while True: active_creature = random.choice(creatures) print( 'A {} of Level {} has appeared out of a dark and foggy forest...'. format(active_creature.name, active_creature.level)) cmd = input('Do you [a]ttack, [r]unaway, or [l]ook around?') cmd = cmd.lower() if cmd == 'a': if hero.attack(active_creature): creatures.remove(active_creature) else: print("The Wizard runs and take time to recover.") time.sleep(5) print("The Wizard returns revitalized") elif cmd == 'r': print('The Wizard {} has become unsure of his powers and flees.'. format(hero.name)) elif cmd == 'l': for c in creatures: print("The wizard {} look around and a {} of level {}.".format( hero.name, c.name, c.level)) else: print('OK, exiting game... bye!') break if not creatures: print('You have defeated all the creatures!!') break print()
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 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
def game_loop(): creatures = [ SmallAnimal("Toad", 1), Creature("Tiger", 12), SmallAnimal("Bat", 3), Dragon("Dragon", 50, scaliness=75, breathes_fire=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]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 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 have defeated all the creatures, well done!") break print()
def game_loop(): creatures = [ SmallAnimal('Toad', 1), Creature('Tiger', 12), SmallAnimal('Bat', 3), Dragon('Dragon', 50, 75, True), Wizard('Evil Wizard', 1000), ] hero = Wizard('Gandalf', 1075) while True: if not creatures: print("You defeated all the creatures, well done!") break active_creature = random.choice(creatures) print('A {} of level {} has appeared from a dark and foggy forest'. format(active_creature.name, active_creature.level)) cmd = input("Do you [a]ttack [r]un or [l]ook around ") if cmd == 'a': if hero.attack(active_creature): creatures.remove(active_creature) else: print("Game Over") exit() elif cmd == 'r': print('The wizard is unsure of his power and flees!!') elif cmd == 'l': print('The wizard {} takes in the surroundings and sees:'.format( hero.name)) for c in creatures: print(' * A {} of level {}'.format(c.name, c.level)) else: if not creatures: print("You defeated all the creatures, well done!") break print('OK, exiting game') break
def game_loop(): creatures = [ SmallAnimal('Toad', 1), Creature('Tiger', 12), SmallAnimal('Bat', 3), Dragon('Dragon', 50, scaliness=75, breaths_fire=True), 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)) 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 hides to recover') time.sleep(5) print('The wizard have recovered his health') elif cmd == 'r': print('The wizard {} took the decision to run away'.format( hero.name)) elif cmd == 'l': print('The wizard {} sees the surroundings 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('')
def game_loop(): creatures = [ SmallAnimal('Toad', 1), Creature('Tiger', 12), SmallAnimal('Bat', 3), Dragon('Dragon', 50, 10), Wizard('Evil Wizard', 200) ] hero = Wizard('Gandolf', 100) timeout = 3 while True: active_creature = random.choice(creatures) print(active_creature) 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 ({} secs)…' .format(timeout)) time.sleep(timeout) 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 surroundings and sees: '.format( hero.name)) for c in creatures: print('* A {} of level {}'.format(c.name, c.level)) else: print('Ok, exiting game… bye!') break if not creatures: print('You have deffeted all creatures 💪!') break
def game_loop(): creatures = [ Creature('Bat', 5), Creature('Toad', 1), Creature('Tiger', 12), Dragon('Red Dragon', 50, 10, True), Wizard('Evil Wizard', 1000), ] print(creatures) hero = Wizard('Gandolf', 75) while True: active_creature = random.choice(creatures) print(f'A {active_creature.name} of level {active_creature.level} has appear from a dark and foggy forest...') print() cmd = input('Do you [a]ttack, [r]unaway, or [l]ook around? ').lower() if cmd == 'a': if hero.attack(active_creature): creatures.remove(active_creature) print(f'The Wizard defeated {active_creature.name}') else: print(f'The Wizard has been defeated by the powerfull {active_creature.name}') elif cmd == 'r': print('The wizard has become unsure of his power and flees!!!') elif cmd == 'l': print(f'The wizard {hero.name} takes in the surroundings and sees:') for c in sorted(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()
def game_loop(): creatures = [ SmallAnimal('Toad', 1), Creature('Tiger', 12), SmallAnimal('Bat', 3), Dragon('Dragon', 50, scaliness=20, breathes_fire=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 forest...'. format(active_creature.name, active_creature.level)) cmd = input('Do you [a]ttack, [r]un away, or [l]ook around? ') if cmd == 'a': if hero.attack(active_creature): creatures.remove(active_creature) else: print('The wizard runs and hides taking time to recover') time.sleep(5) print('The wizard returns revitalized!') elif cmd == 'r': print('The wizard is unsure of its powers and flees away...') elif cmd == '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('OK, exiting game...') break if not creatures: print('You have defeated all the creatures, well done!') break
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('Gandalf', 75) while True: # randomly choose a creature 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 = 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 {} has eliminated the {}'.format(hero.name, active_creature.name)) print('There are {} creatures to defeat.'.format(len(creatures))) else: print('The wizard has been defeated by a powerful a {}.'.format(active_creature.name)) 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('* {} of level {}.'.format(c.name, c.level)) print('--\n') else: print('OK, exiting game....bye!') if not creatures: print('You have defeated all the creatures, well done!') break
def game_loop(): creatures = [ Creatures('Toad', 1), Creatures('Tiger', 12), Creatures('Bat', 3), Creatures('Dragon', 50), Creatures('Evil Wizard', 1000) ] hero = Wizard('Mike', 1000) while True: active_creature = random.choice(creatures) print("A {} of level {} has appeared from a dark and foggy forest....".format(active_creature.name, active_creature.level)) cmd = input("Do you [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 healthy!") elif cmd == 'r': print('runaway') 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
def game_loop(): creatures = [ Creature(name='Tree', level=1), Dragon(name='Dragon'), FierceFighter(name='John'), SmallAnimal(name='Rat', level=3), SmallAnimal(name='Boar', level=5), Wizard(name='Evil Wizard', level=1000), ] hero = Wizard('Bob', level=75) while True: if not creatures: print_endgame() break creature = choice(creatures) print() print('A {} of level {} appear.'.format(creature.name, creature.level)) action = ask_for_action() print() if action == 'a': if hero.attack(creature): creatures.remove(creature) else: print('I need more energy.') sleep(5) print('Ok I\'m back.') elif action == 'r': print('The wizard {} runs away!'.format(hero.name)) elif action == 'l': look_around(creatures) else: print('OK leaving the game') break
def game_loop(): creatures = [ Creature('Todaa', 1), Creature('Tiger', 12), Creature('Bat', 3), Creature('Draggon', 50), Creature('Evil Wizard', 1000) ] # print(creatures) hero = Wizard('Gandeoof', 75) while True: active_creature = random.choice(creatures) print('A {} of level {} has appeared from a 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 for recovery ") time.sleep(5) print("The wizard Returns ") elif cmd == 'r': print('runaway') 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 the game') break print()
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
def game_loop(): creatures = [ SmallAnimal('Toad', 1), SmallAnimal('Bat', 3), Dragon('Dragon', 50, 75, True), Wizard('Evil Wizard', 1000) ] hero = Wizard('Gandolf', 75) while True: active_creature = random.choice(creatures) print( f'A {active_creature.name} of level {active_creature.level} has appeared from the dark and foggy forest' ) 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 time to recover") time.sleep(5) print("The wizard is revitalized") elif cmd == 'r': print('the wizard is unsure and runs away') elif cmd == 'l': print("The wizard stops and looks around and sees") for c in creatures: print(f'* {c.name} with a level of {c.level}') else: print('bye') break if not creatures: print('you have defeated all the creatures') break
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( f'A {active_creature.name} of level {active_creature.level} has apper from a dark and foggy forest...' ) cmd = input('Do you [a]ttack, [r]unaway or [l]ook around? \n') if cmd == 'a': if hero.attack(active_creature): print(f'The Wizard won and killed {active_creature.name}.') creatures.remove(active_creature) else: print(f'{active_creature.name} won.') print('The Wizard runs and hides taking time to recover...') time.sleep(5) print('The Wizard returns revitalized!') elif cmd == 'r': print('The Wizard has become unsure of his power and flees!!!') elif cmd == 'l': print( f'The Wizard {hero.name} takes in the surroundings and sees:') for c in creatures: print(f'* A {c.name} of level {c.level}') else: print('OK, exiting game...bye!') break
def game_loop(): creatures = [ SmallAnimal('Toad', 1), Creature('Tiger', 12), SmallAnimal('Bat', 3), Dragon('Dragon', 50, 75, True), Wizard('Evil Wizard', 100) ] 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)) 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 to take time to recover...") time.sleep(5) print("The wizard returns") elif cmd == 'r': print('The wizard becomes scared and runs away.') elif cmd == 'l': print('The wizard looks around and sees:') for creature in creatures: print(' * A {} of level {}'.format(creature.name, creature.level)) else: print("OK, exiting game... bye!") break if not creatures: print("You defeated all of the creatures") break
def game_loop(): creatures = [ Creature('bat', 1), Creature('toad', 5), Creature('tiger', 12), Creature('Dragon', 50), Creature('Evil Wizard', 1000) ] hero = Wizard('Krondor', 75) #print(creatures) while True: baddy = random.choice(creatures) print("A level {} {} has appeared".format(baddy.level, baddy.name)) cmd = input('Would you like to [a]ttack, [l]ook around, or [r]unaway?') cmd = cmd.lower() if cmd == 'a': if hero.attack(baddy): creatures.remove(baddy) else: print("The wizard must meditate.") time.sleep(3) print("The wizard recovers.") elif cmd == 'l': print('looking around') elif cmd == 'r': print('running away') else: print('Exiting') break print()
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
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("{} has appeared from dark and foggy forest" .format(active_creature)) 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 flies!!!!") elif cmd == 'l': print("The wizard takes in the surroundings and sees:") for c in creatures: print(" * A {} of level {}".format(c.name, c.level)) else: print("Ok exiting game... bye") break if not creatures: print("You`ve defeated all the creatures, well done")
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: creature = random.choice(creatures) print('The wizard {} sees a {}'.format(hero.name, creature.name)) print() cmd = input('Do you [a]ttack, [r]unaway, or [l]ook around? ') if cmd == 'a': if hero.attack(creature): creatures.remove(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 {} runs away!'.format(hero.name)) elif cmd == 'l': print('The wizard {} looks around and sees:'.format(hero.name)) for c in creatures: print('* A level {} {}'.format(c.level, c.name)) else: print('OK, exiting game... Bye!') break if not creatures: print("You've defeated all the creatures, well done!") break print()
def game_loop(): creatures = [ Creature('Toad', 1), Creature('Tiger', 3), Creature('Bat', 3), Creature('Dragon', 50), Creature('Evil Wizard', 1000), ] hero = Wizard('Gandalf', 75) while True: active_creature = random.choice(creatures) print() 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("Wizard hides...") time.sleep(5) print("wizard returns!") elif cmd == 'r': print('runaway') elif cmd == 'l': print('The wizard {} looks around:'.format(hero.name)) for c in creatures: print(f' * A {c.name} of level {c.level}') else: print('OK, exiting game...bye!') 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) while True: active_create = random.choice(creatures) print("A {} of level {} has appear from a dark and foggy forest...".format(active_create.name, active_create.level)) print() cmd = input("Do you [a]ttack, [r]unaway, or [l]ook around? ") if cmd == "a": if hero.attack(active_create): creatures.remove(active_create) else: print("Game Over") break elif cmd == "r": print("The wizard has become unsure of his power and flees!!!!") elif cmd == "l": print("The wizard {} takes in the surroundings and sees:".format(hero.name)) for c in creatures: print(" * A {} of level {}".format(c.name, c.level)) else: print("OK, exiting game... bye!") break if not creatures: print("You have defeated all creatures, YOU WIN!!!") return
def game_loop(): creatures = [ Creature('Rabbit', 1), Creature('Kobold', 7), Creature('Wyrm', 22), Creature('Bandit', 18), Creature('Evil Sorcerer', 100) ] hero = Wizard('Bryce', 5) while True: active_creature = random.choice(creatures) print('A {}, lvl {} has appeared!'.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( 'You slowly crawl away and hide, taking time to recover.') time.sleep(5) print('The wizard return revitalized!') elif cmd == 'r': print('run away') 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
def game_loop(): creatures = [ SmallAnimal('Toad', 1), Creature('Tiger', 12), SmallAnimal('Bat', 3), Dragon('Dragon', 50, 75, True), Creature('Evil Wizard', 1000), Creature('Vermicious Knid', 13), ] hero = Wizard('Wizrobe', 75) while True: active_creature = random.choice(creatures) print( f'A {active_creature.name} of level {active_creature.level} has appeared from a dark and foggy forest...' ) 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(f'{hero.name} runs and hides taking time to recover.') time.sleep(2) print(f'{hero.name} has been revitalized!') elif cmd == 'r': print(f'\n{hero.name} runs away!') elif cmd == 'l': print(f'\n{hero.name} looks around and sees:') for c in creatures: print(f'* A level {c.level} {c.name}') else: print('OK, exiting game... bye!') break
def game_loop(name): # manually initialize creatures as objects of a class; # creature(name, level, luck); # TODO add MP and tricks; # TODO expand, automate and randomize types, levels etc creatures = [ Creature('Toad', random.randint(1, 3), random.randint(1, 10)), Creature('Spider', 2 * random.randint(1, 3), random.randint(1, 10)), Creature('Snake', 3 * random.randint(1, 3), random.randint(1, 10)), Creature('Bat', 2 + random.randint(1, 3), random.randint(1, 10)), Creature('Tiger', 10 + random.randint(1, 10), random.randint(1, 10)), Creature('Dragon', 30 + random.randint(1, 10), random.randint(1, 10)), Creature('Evil Wizard', 50 + random.randint(1, 10), random.randint(1, 10)), Creature('Fairy', None, None) # increases your luck points ] hero = Wizard(name, 3, 0, random.randint(1, 10)) # initialize one single object for the class Wizard; # Wizard(name, level, XP, luck); # TODO add MP and tricks (signs which consume MP and potions) while True: # every turn: the hero attacks a creature by surprise # TODO elaborate situations and choices active_creature = random.choice(creatures) if active_creature.name == 'Fairy': # only good creature here; could be in a proper class # with other good beings print("A Fairy has appeared!") print('''\n"Hello, dear {}, I'm your Luck Fairy. Be careful in your path! Here you receive my blessing!"\n '''.format(name)) if hero.luck < 10: if random.random() < 0.6: hero.luck += 1 print("Your luck has increased! Now it is {}.".format(hero.luck)) input("Press enter to continue...") else: print("\nA {} of level {} has appeared from a " "dark and foggy forest...".format(active_creature.name, active_creature.level)) print() print("Your stats are: level {}, xp {}, luck {}".format( hero.level, hero.xp, hero.luck)) cmd = input("Do you [a]ttack or [r]unaway? ").lower() # hero.level = 100 if cmd == 'a': if hero.attack(active_creature): hero.increase(active_creature) creatures.remove(active_creature) # it's not necessary to remove a creature after one single bout else: print( "The wizard runs and hides taking time to recover...") print(".") time.sleep(1) print(".") time.sleep(1) print(".") time.sleep(1) input("Press enter to continue...") # TODO we need serious consequences here! elif cmd == 'r': print("{} has become unsure of his power and flees.".format( hero.name)) # TODO more consequences ... input("Press enter to continue...") else: cmd = input('Do you really wnat exit the game? (y/n): ') if cmd == 'y': print('OK, exiting game.') break
def game_loop(): life_count = 3 hero = Wizard("Zilden", 50) creatures = [ Creatures("Bat", 1), Creatures("Slime", 10), Creatures("Golem", 30), Creatures("Dragon", 50), Creatures("Evil Wizard", 1000) ] while True: active_creature = random.choice(creatures) print("A {} of level {} has been summoned\n".format( active_creature.name, active_creature.level)) cmd = input("What do you want to do? \n" + "[a]ttack\n" + "[r]un away\n" + "[l]ookaround\n" + "[t]raining\n" + "[s]tatus\n") if cmd == "a": if hero.attack(active_creature): print('\nThe wizard has vanquished the {}'.format( active_creature.name)) creatures.remove(active_creature) else: print('\nThe wizard has been DEFEATED') life_count = life_count - 1 if life_count < 1: print("\n{} the wizard has been VANQUISHED... Game Over". format(hero.name)) break else: print( '\nHe flees to heal his wounds, wait until the wizard uses his healing power...\n' ) time.sleep(5) print( "\nThe wizard has returned to battle with {} life points left\n" .format(life_count)) elif cmd == "r": print("{} the wizard flees from the battle".format(hero.name)) elif cmd == "l": for creature in creatures: print("A {} of level {}".format(creature.name, creature.level)) elif cmd == "t": print("The wizard practices new abilities to gain power") life_count = hero.training(life_count) if life_count < 1: print( "\n{} the wizard has been VANQUISHED... Game Over".format( hero.name)) break elif cmd == "s": print("{} level: {}".format(hero.name, hero.level)) print("{} life points: {}\n".format(hero.name, life_count)) else: print("Ok, exiting the game... bye") break
class Game: def __init__(self): self._setup_creatures() self._setup_hero() 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 def _setup_hero(self): try: self.hero = Wizard("Gandolf", 75) except TypeError as e: print(f"There was a problem creating the hero") raise e @staticmethod def print_header(): print("---------------------------------") print(" WIZARD GAME") print("---------------------------------") print() def handle_command(self, cmd): if cmd == "a": if self.hero.attack(self.active_creature): print("The wizard defeated {}".format( self.active_creature.name)) self.creatures.remove(self.active_creature) else: print("The wizard has been defeated by the powerful {}".format( self.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( self.hero.name)) for c in self.creatures: print(" * {} of level {}".format(c.name, c.level)) else: raise ValueError(cmd) def loop(self): while True: self.active_creature = random.choice(self.creatures) print( "A {} of level {} has appear from a dark and foggy forest...". format(self.active_creature.name, self.active_creature.level)) print() while True: try: self.handle_command( input( "Do you [a]ttack, [r]unaway, or [l]ook around? ")) break except ValueError as e: print(f"Invalid command {e}. Try again") if not self.creatures: print("You've defeated all the creatures, well done!") break print()
def game_loop(Hero_name): # de eindbaas is een Evil Wizard creatures = [ Wizard(1000, 50, 'Evil Wizard', random.randint(500, 1500), 8, random.randint(1, 8)) ] # de lijst met creatures aanvullen tot 5 met random gekozen creatures uit de lijst met alle mogelijkheden creatures = choice_creature(creatures, count=5) # de start waardes voor de Hero. hero_power = 500 hero_strengt = 10 money_bag = 5 while hero_power >= 1: # zolang de Hero leeft. hero = Wizard(1, hero_strengt, Hero_name, hero_power, 1, money_bag) # hero zijn waardes doorgeven active_creature = random.choice(creatures) # actieve creature kiezen surprise_mode = SURPRISE_MODE.get(active_creature.behaviour, None) if isinstance( active_creature, Dragon ): # draken komen altijd uit de lucht en spugen wel of geen vuur. print('A {}{} of level {} with a strengt of {} '.format( ('Firebreathing ' if active_creature.breaths_fire else ''), active_creature.name, active_creature.level, active_creature.strengt)) else: # is het geen draak, dan wordt er nu gekeken hoe de creature tevoorschijn komt. print( 'A {} of level {} with a strengt of {} {} .'.format( active_creature.name, active_creature.level, active_creature.strengt, surprise_mode) ) # printen van het creature dat op welke manier tevoorschijn komt. print() cmd = True while cmd != "x": cmd = input( 'Do you [A]ttack, [R]unaway and look for additional targets, [L]ook around and change target, go to the [S]hop or [X] to exit? ' .format( hero_power, hero_strengt)) # vragen wat we met het monster gaan doen. cmd = cmd.lower().strip() Header.print_header( title= 'Your Hero is: {} with {} strengt and an health of: {} and owns {} Gold' .format(hero.name, hero_strengt, hero_power, money_bag), bar='=') # header printen met daarin onze waardes if cmd == 'a': # aanval aanroepen in de actors module. fightstatus = hero.attack( active_creature ) # als we winnen wordt er win terug gegeven if fightstatus.result == Wizard.get_fight_status("win"): money_bag += active_creature.loot print('you have found {} Gold on {} You now have {} Gold'. format(active_creature.loot, active_creature.name, money_bag)) creatures.remove(active_creature) if active_creature.bonus == 1: # bonus bekijken en toekennen hero_power += 10 print( 'Your hero gains 10 health and now has {}'.format( hero_power)) elif active_creature.bonus == 5: hero_strengt += 5 print( 'Your hero gains 5 strengt and now has {}'.format( hero_strengt)) else: hero_power += 100 print( 'Your hero gains 100 health and now has {}'.format( hero_power)) break elif fightstatus.result == Wizard.get_fight_status("killed"): money_bag += active_creature.loot print('you have found {} Gold on {} You now have {} Gold'. format(active_creature.loot, active_creature.name, money_bag)) creatures.remove(active_creature) hero_power -= fightstatus.damage # we hebben verloren, de aanval wordt van onze healt afgetrokken if hero_power >= 1: # overleven we de aanval verstoppen we ons en hebben we 5 sec nodig om te recoveren print('{} runs and hides taking time to recover..'. format(hero.name)) time.sleep(5) print('{} returns with a healt of {}'.format( hero.name, hero_power)) else: # we zijn dood, Game Over print('your level is to low to fight, GAME OVER') break elif fightstatus.result == Wizard.get_fight_status("flee"): creatures.remove(active_creature) break else: hero_power -= fightstatus.damage # we hebben verloren, de aanval wordt van onze healt afgetrokken if hero_power >= 1: # overleven we de aanval verstoppen we ons en hebben we 5 sec nodig om te recoveren print('{} runs and hides taking time to recover..'. format(hero.name)) time.sleep(5) print('{} returns with a healt of {}'.format( hero.name, hero_power)) else: # we zijn dood, Game Over print('your level is to low to fight, GAME OVER') break elif cmd == 'r': # we rennen weg voor het monster of gaan opzoek naar nieuwe monsters om onze lijst aan te vullen. print( "The wizard has become unsure of his power and run's away to look for new creatures !!!" ) for c in range(len(creatures), 5): # aanvullen van de lijst creatures = choice_creature(creatures, count=5) break elif cmd == 'l': # printen van alle monsters en nieuw doel kiezen print('{} takes a look in the surroundings and sees a '.format( hero.name)) for c in creatures: print('* A {} of level {} with a strengt of {}'.format( c.name, c.level, c.strengt)) break elif cmd == 's': shop = 9 while shop != 0: Header.print_header( title='Welkom in the shop you own {} Gold'.format( money_bag), bar='$') print('1) 10 healt kost 5 gold') print('2) 25 healt kost 10 gold') print('3) 100 healt kost 30 gold') print() print('4) 5 strengt kost 5 gold') print('5) 10 strengt kost 8 gold') print('6) 25 strengt kost 18 gold') print() print('to exit the shop press 0') print() shop = int(input('please give the number of you choise')) if shop == 1: if money_bag - 5 < 0: print('sorry you do not have enough Gold') shop = 8 hero_power += 10 money_bag -= 5 elif shop == 2: if money_bag - 10 < 0: print('sorry you do not have enough Gold') shop = 8 hero_power += 25 money_bag -= 10 elif shop == 3: if money_bag - 30 < 0: print('sorry you do not have enough Gold') shop = 8 hero_power += 100 money_bag -= 30 elif shop == 4: if money_bag - 5 < 0: print('sorry you do not have enough Gold') shop = 8 hero_strengt += 5 money_bag -= 5 elif shop == 5: if money_bag - 8 < 0: print('sorry you do not have enough Gold') shop = 8 hero_strengt += 10 money_bag -= 8 elif shop == 6: if money_bag - 18 <= 0: print('sorry you do not have enough Gold') shop = 8 hero_strengt += 25 money_bag -= 18 else: print('OK, exiting game.... bye!' ) # we hebben niets gekozen dus exit return hero, creatures if not creatures: # als alle monsters zijn verslagen dus ook de eindbaas dan hebben we gewonnen print("You've defeated all the creatures, well done!") break print()