def BattleLoop(): # Name, lvl, ac, strength, intel, att_die Tak = player.Character(player.name, 1, 10, 10, 10, player.att_die) # Name lvl, health, ac, strength, intel, att_die goblin1 = goblin.Goblin("The gobblin", 1, 4, 1, 2, 2, 4) print( "\n\t\t" + player.name + ", you enter a swamp when a foul smelling\n\t\tgoblin jumps out at you!\n\n " ) def get_input(): command = input( "\nWhat do you want to do? [hit] [examine] [run] [say]\n\nCommand >> " ).split() verb_word = command[0] run = False if verb_word == "clear": util.cls() if verb_word == "run": # Exit game and run away run = util.yesOrNo("\nYou want to " + verb_word + ".\nAre you sure? (Y/N) >> ") if run == True: print("\n\t\tYou run away!\n") return True else: return False elif verb_word in verb_dict: verb = verb_dict[verb_word] else: print("Unknown verb {}".format(verb_word)) return False if len(command) >= 2: noun_word = command[1] print(verb(noun_word)) else: print(verb("nothing")) if goblin1.health <= 0: run = True print( "\n\t\tYou win the battle!\n\n-------------------------------------------------\n" ) return run elif Tak.health <= 0: run = True print("You lost the battle!") return run return run def say(noun): return '''\nYou said "{}" and the creatures grunt in return.\n -------------------------------------------------\n'''.format(noun) def examine(noun): if noun in gameobjects.GameObject.objects: return gameobjects.GameObject.objects[noun].get_desc() else: return "\nThere is no {} here.\n\n-------------------------------------------------\n".format( noun) def hit(noun): if noun in gameobjects.GameObject.objects: thing = gameobjects.GameObject.objects[noun] def win(char1, char2): if (char1.health > char2.health): winner = char1.name not_winner = char2.name else: winner = char2.name not_winner = char1.name print("%s has killed" % winner) print("%s!" % not_winner) def fight(Char1, Char2): y = 0 z = 0 z = Char2.damage(Char1.attack()) # Player attack time.sleep(0.5) if z != 1: y = Char1.damage(Char2.attack()) # Enemy attack time.sleep(0.5) if y == 1 or z == 1: win(Char1, Char2) if Tak == thing: msg = "\nLife is too short to end it this early!\nCannot attack yourself\n\n-------------------------------------------------" elif Tak.health > 0 and thing.health > 0: msg = "\n-------------------------------------------------" fight(Tak, thing) # Start fight sequence elif thing.health <= 0: msg = run = "\n%s is dead!\n\n-------------------------------------------------" % ( thing.name) else: msg = "%s dead!\n\n-------------------------------------------------" % ( Tak.name) else: msg = "\nThere is no {} here\n\n-------------------------------------------------".format( noun) return msg verb_dict = { "say": say, "examine": examine, "hit": hit, } end = False while end == False: end = get_input() if Tak.health > 0 and goblin1.health <= 0: return True else: return False
def BattleLoop(): # Name, exp, lvl, ac, strength, intel, att_die Tak = player.Character(player.name, player.exp, player.lvl, 5, 10, 8, player.weap1, player.att_die1, "none", 0) # Name lvl, health, ac, strength, intel, att_die dog1 = dog.Dog("The rabid dog", 1, 4, 1, 2, 2, 4) print("\n\t\t" + player.name + ", you enter a swamp when a rabid\n\t\tdog jumps out at you!\n\n ") print("\n\n" +"-"*90 + "\n\n") def get_input(): command = input("\nWhat do you want to do? [hit] [examine] [run] [say]\n\nCommand >> ").split() verb_word = command[0] run = False if verb_word == "run": # Exit game and run away run = util.yesOrNo("\nYou want to " + verb_word + ".\nAre you sure? (Y/N) >> ") if run == True: print("\n\t\tYou run away!\n") return True else: return False elif verb_word in verb_dict: verb = verb_dict[verb_word] else: print("Unknown verb {}" .format(verb_word)) return False if len(command) >= 2: noun_word = command[1] print (verb(noun_word)) else: print(verb("nothing")) if dog1.health <= 0: run = True print("\n\t\t\tYou win the battle!") print("\t\tYou have gained 5 experience ponts") exp = 5 player.lvl = get_object.Level(exp) print("\n\n" + "-"*90 + "\n") return run elif Tak.health <= 0: run = True print("You lost the battle!") return run return run def say(noun): return '\nYou said "{}" and the creature growls in return.'.format(noun) + "\n\n" + "-"*90 + "\n\n" def examine(noun): if noun in gameobjects.GameObject.objects: return gameobjects.GameObject.objects[noun].get_desc() else: return "\nThere is no {} here.\n\n" + "-"*90 + "\n\n".format(noun) def hit(noun): if noun in gameobjects.GameObject.objects: thing = gameobjects.GameObject.objects[noun] def win(char1, char2): if(char1.health > char2.health): winner = char1.name not_winner = char2.name else: winner = char2.name not_winner = char1.name print("%s has killed" % winner) print("%s!" % not_winner) def fight(Char1, Char2): y = 0 z = 0 z = Char2.damage(Char1.attack()) # Player attack time.sleep(0.5) if z != 1: y = Char1.damage(Char2.attack()) # Enemy attack time.sleep(0.5) if y == 1 or z == 1: win(Char1,Char2) if Tak == thing: msg = "\nLife is too short to end it this early!\nCannot attack yourself\n\n-------------------------------------------------" elif Tak.health > 0 and thing.health > 0: msg = "\n\n" + "-"*90 + "\n\n" fight(Tak,thing) # Start fight sequence elif thing.health <= 0: msg = run = "\n%s is dead!\n\n"% (thing.name) + "-"*90 + "\n\n" else: msg = "%s dead!\n\n"(Tak.name) + "-"*90 + "\n\n" else: msg ="\nThere is no {} here\n\n".format(noun) + "-"*90 + "\n\n" return msg verb_dict = { "say":say, "examine":examine, "hit":hit, } end = False while end == False: end = get_input() if Tak.health > 0 and dog1.health <= 0: return True else: return False
def BattleLoop(): # Name, lvl, ac, strength, intel, att_die Tak = player.Character(player.name, 5, 15, 16, 10, player.att_die) # Name lvl, health, ac, strength, intel, att_die goblin1 = goblin.Goblin("The gobblin", 1, 4, 4, 4, 2, 4) # Name lvl, health, ac, strength, intel, att_die orc1 = orc.Orc("The orc", 1, 8, 6, 6, 4, 6) print("\n\t\t" + player.name + ", You enter the forest when a foul smelling\n\t\tgoblin and an ugly orc jump out at you!\n\n """) def get_input(): command = input("\nWhat do you want to do? [hit] [examine] [run] [say]\n\nCommand >> ").split() verb_word = command[0] run = False if verb_word == "run": # Exit game and run away run = util.yesOrNo("\nYou want to " + verb_word + ".\nAre you sure? (Y/N) >> ") if run == True: print("\n\t\tYou run away!\n") return True else: return False elif verb_word in verb_dict: verb = verb_dict[verb_word] else: print("Unknown verb {}" .format(verb_word)) return False if len(command) >= 2: noun_word = command[1] print (verb(noun_word)) else: print(verb("nothing")) if goblin1.health <= 0 and orc1.health <=0: run = True print("\n\t\tYou win the battle!") return run elif Tak.health <= 0: run = True print("You lost the battle!") return run return run def say(noun): return '''\nYou said "{}" and the creatures grunt in return.\n -------------------------------------------------\n'''.format(noun) def examine(noun): if noun in gameobjects.GameObject.objects: return gameobjects.GameObject.objects[noun].get_desc() else: return "\nThere is no {} here.\n\n-------------------------------------------------\n".format(noun) def go(thing1, thing2): def win(char1, char2, char3): if char1.health > char2.health: winner = char1.name not_winner = char2.name elif char1.health > char3.health: winner = char1.name not_winner = char3.name else: winner = char2.name +" and "+ char3.name not_winner = char1.name print("%s has killed" % winner) print("%s!" % not_winner) def fight(Char1, Char2, Char3): x = 0 y = 0 z = 0 z = Char2.damage(Char1.attack()) # Player attack time.sleep(0.5) if Char2.health > 0: x = Char1.damage(Char2.attack()) # First Enemy attack time.sleep(0.5) if Char3.health > 0: z = Char1.damage(Char3.attack()) # Second Enemy attack time.sleep(0.5) if x == 1 or y == 1 or z == 1: win(Char1,Char2,Char3) if Tak == thing1: msg = "\nLife is too short to end it this early!\nCannot attack yourself\n\n-------------------------------------------------" elif Tak.health > 0 and (thing1.health > 0 or thing2.health > 0): msg = "\n-------------------------------------------------" fight(Tak,thing1,thing2) # Start fight sequence elif thing1.health <= 0 and thing2.health <= 0: msg = "The enemy's are dead!\n\n-------------------------------------------------" else: msg = "%s dead!\n\n-------------------------------------------------"% (Tak.name) return msg def hit(noun): if noun in gameobjects.GameObject.objects and noun == "goblin": thing1 = gameobjects.GameObject.objects[noun] thing2 = gameobjects.GameObject.objects["orc"] msg = go(thing1, thing2) elif noun in gameobjects.GameObject.objects and noun == "orc": thing1 = gameobjects.GameObject.objects[noun] thing2 = gameobjects.GameObject.objects["goblin"] msg = go(thing1, thing2) else: msg ="\nThere is no {} here\n\n-------------------------------------------------".format(noun) return msg verb_dict = { "say":say, "examine":examine, "hit":hit, } end = False while end == False: end = get_input() if Tak.health > 0 and goblin1.health < 0 and orc1.health < 0: return True else: return False
def getWeapon(): player.name = "..." player.exp = 0 player.lvl = 1 # Name, exp, lvl, ac, strength, intel, weap1, att_die1, weap2, att_die2 Tak = player.Character(player.name, player.exp, player.lvl, 10, 10, 10, "none", 0, "none", 0) # Quest Name, LtlBell = quest_log.Little_Bell("Little Bell") LtlBell.active = False pause = 1.5 pause2 = 1.25 exp = 0 print("\t\t\t\tBOOK ONE - EARTH\n\n") # Opening Chapter time.sleep(3) def print1(): # set parameters for printing opening paraghraph line = 0 while line < 8: print(line_dict1[line]) time.sleep(pause) line = line + 1 line_dict1 = [ "\n\tSlowly and painfully you open your eyse, you wake up in a daze...", #0 "\tYour head hurts... You taste copper in your mouth...", #1 "\tThere is a strong smell of blood in the air...", #2 "\tYou are having a hard time remembering who you are...", #3 "\tAnd where you are...\n", #4 '\n\t"W... What... What is my name?" you ask yourself...', #5 "\tA name slowly works its way into your mind...", #6 "\tWas it Takezo?... \n\n\n" + "-" * 90 + "\n", #7 ] #sets users name into util file for future use print1() Takezo = util.yesOrNo("Do you want to use the name Takezo? (Y/N) >> " ) #uses yesOrNo in utilities file to get user input if Takezo: player.name = "Takezo" #If "Yes" - Player name is "Takezo" else: player.name = get_name.getName( ) #If "No" - get_name.getName file will get user input and collect name print("\n\n" + "-" * 90 + "\n\n") # prints 90 "-" on sereen for a line break def print2(): # set parameters for printing second paraghraph line = 0 while line < 14: print(line_dict2[line]) time.sleep(pause2) line = line + 1 line_dict2 = [ "\n\tYou have a horrible headake...", #0 "\tYour memory is still a little foggy...", #1 "\tYet you are able to remember that your name is... " + player.name, #2 "\n\t" + player.name + ", You manage to lift your head a little.", #3 "\tYou take a look around...", #4 "\tLow dark clouds float accross the ominous sky...", #5 "\tThere are dead horses and dead [bodies] everywhere...", #6 "\tThousands of them...", #7 "\tYou look down at your[self] and at the [ground]...", #8 "\tThere is blood everywhere...", #9 "\tHow long have I been here?...", #10 '\t"Was I in a battle? How am I still alive?" You ask yourself...\n', #11 "\tIs the battle still going on?...", #12 #"\t", "\t" + player.name + ", You realise that you may still be in danger and need a weapon...\n\n" + "-" * 90 + "\n" #13 ] print2() def get_input(): player.att_die1 = 0 player.weap1 = "none" command = input( "\nWhat do you want to do? [search] [examine] [say]\n\nCommand >> " ).split() verb_word = command[0] end = False if verb_word == "hit": verb = verb_word print("There is nothing here to hit") return False elif verb_word in verb_dict1: verb = verb_dict1[verb_word] else: print("Unknown verb {}".format(verb_word)) return False if len(command) >= 2: noun_word = command[1] if noun_word == "bodies" and LtlBell.active == True: print("\n\t\tYou already searched the bodies.") else: print(verb(noun_word)) else: print(verb("nothing")) if player.att_die1 > 0: # Did the player equip a weapon? end = True else: end = False return end def say(noun): return '\nYou said "{}".\n'.format(noun) + "-" * 90 + "\n\n" def examine(noun): if noun == "ground": return """\n\n\tThe ground is covered in bodies, and blood... \tThere are flies buzzing around everywhere \tIt looks like there might be something else here... \tIf you [search] closer....\n\n""" elif noun == "bodies": return """\n\n\tThe bodies smell foul and look even worse...\n\n""" elif noun == "self": return """\n\n\tYour head still hurts and you are covered in blood...\n\n""" elif noun == "sky": return "\n\n\tNow is not the time for cloud watching...\n\n" else: return "\n\nThere is no {} here.\n\n\n" + "-" * 90 + "\n".format( noun) def search(noun): if noun == "bodies": LtlBell.log = "Battlefield bodies did not have wapons... Currious." LtlBell.active = True exp = 1 player.lvl = get_object.Level(exp) return """\n\n\tThat's strange... There are no weapons here... \tThese warriors should have weapons!\n\tYou gain 1 experience point\n\n""" if noun == "sky": return "\n\n\tYou look to the gods for answers and find none...\n\n" elif noun == "ground": yes = util.yesOrNo( "\n\nYou find a stick on the ground,\nDo you want to use it as a weapon? (Y/N) >> " ) if yes: weapon = get_object.gameWeapon("stick") if not weapon: return "\n\n" + "-" * 90 + "\n\n" else: player.att_die1 = weapon player.weap1 = "stick" exp = 6 player.lvl = get_object.Level(exp) return "\n\nI guess this stick will have to do for now.\n\t\tYou gain 6 experience ponts\n\n" + "-" * 90 + "\n" else: yes = util.yesOrNo( "\nDo you want to use your fists as a weapon? (Y/N) >> ") if yes: weapon = get_object.gameWeapon("fist") if not weapon: return "\n\n" + "-" * 90 + "\n\n" else: player.att_die1 = weapon player.weap1 = "fist" exp = 5 player.lvl = get_object.level(exp) return "\n\nI guess i'll have to use my fists for now.\n\t\tYou gain 5 experience points\n\n-" + "-" * 90 + "\n" else: return "\n\n" + "-" * 90 + "\n\n" else: player.att_die = 0 return '\n\nYou cannot search "{}" \n\n'.format( noun) + "-" * 90 + "\n" #Set verb dictionary verb_dict1 = { "say": say, "examine": examine, "search": search, } end = False while end == False: end = get_input() else: return False
def BattleLoop(): # Name, ,exp, lvl, ac, strength, intel, att_die Tak = player.Character( player.name, player.exp, player.lvl, 8, 10, 10, player.weap1, player.att_die1, "none", 0, ) # Name lvl, health, ac, strength, intel, att_die dog1 = dog.Dog("The rabid dog", 1, 4, 4, 4, 2, 4) # Name lvl, health, ac, strength, intel, att_die wolf1 = wolf.Wolf("The hungry wolf", 1, 6, 4, 6, 3, 6) print( "\n\t\t" + player.name + ", You enter the forest when a hungry\n\t\twolf and a rabid dog jump out at you!\n\n " "") print("\n\n" + "-" * 90 + "\n\n") def get_input(): command = input( "\nWhat do you want to do? [hit] [examine] [run] [say]\n\nCommand >> " ).split() verb_word = command[0] run = False if verb_word == "run": # Exit game and run away run = util.yesOrNo("\nYou want to " + verb_word + ".\nAre you sure? (Y/N) >> ") if run == True: print("\n\t\tYou run away!\n") return True else: return False elif verb_word in verb_dict: verb = verb_dict[verb_word] else: print("Unknown verb {}".format(verb_word)) return False if len(command) >= 2: noun_word = command[1] print(verb(noun_word)) else: print(verb("nothing")) if dog1.health <= 0 and wolf1.health <= 0: run = True print("\n\t\t\tYou win the battle!") print("\t\tYou have gained 10 experience points") exp = 10 player.lvl = get_object.Level(exp) print("\n\n" + "-" * 90 + "\n") return run elif Tak.health <= 0: run = True print("\n\t\t\tYou lost the battle!") return run return run def say(noun): return '\nYou said "{}" and the creatures grunt in return.\n\n'.format( noun) + "-" * 90 + "\n\n" def examine(noun): if noun in gameobjects.GameObject.objects: return gameobjects.GameObject.objects[noun].get_desc() else: return "\nThere is no {} here.\n\n".format( noun) + "-" * 90 + "\n\n" def go(thing1, thing2): def win(char1, char2, char3): if char1.health > char2.health: winner = char1.name not_winner = char2.name elif char1.health > char3.health: winner = char1.name not_winner = char3.name else: winner = char2.name + " and " + char3.name not_winner = char1.name print("%s has killed" % winner) print("%s!" % not_winner) def fight(Char1, Char2, Char3): x = 0 y = 0 z = 0 z = Char2.damage(Char1.attack()) # Player attack time.sleep(0.5) if Char2.health > 0: x = Char1.damage(Char2.attack()) # First Enemy attack time.sleep(0.5) if Char3.health > 0: z = Char1.damage(Char3.attack()) # Second Enemy attack time.sleep(0.5) if x == 1 or y == 1 or z == 1: win(Char1, Char2, Char3) if Tak == thing1: msg = "\nLife is too short to end it this early!\nCannot attack yourself\n\n-------------------------------------------------" elif Tak.health > 0 and (thing1.health > 0 or thing2.health > 0): msg = "\n\n" + "-" * 90 + "\n\n" fight(Tak, thing1, thing2) # Start fight sequence elif thing1.health <= 0 and thing2.health <= 0: msg = "The enemy's are dead!\n\n" + "-" * 90 + "\n\n" else: msg = "%s dead!\n\n" % (Tak.name) + "-" * 90 + "\n\n" return msg def hit(noun): if noun in gameobjects.GameObject.objects and noun == "dog": thing1 = gameobjects.GameObject.objects[noun] thing2 = gameobjects.GameObject.objects["wolf"] msg = go(thing1, thing2) elif noun in gameobjects.GameObject.objects and noun == "wolf": thing1 = gameobjects.GameObject.objects[noun] thing2 = gameobjects.GameObject.objects["dog"] msg = go(thing1, thing2) else: msg = "\nThere is no {} here\n\n".format(noun) + "-" * 90 + "\n\n" return msg verb_dict = { "say": say, "examine": examine, "hit": hit, } end = False while end == False: end = get_input() if Tak.health > 0 and dog1.health < 0 and wolf1.health < 0: return True else: return False
def BattleLoop(): # Name, exp, lvl, ac, strength, intel, att_die Tak = player.Character(player.name, player.exp, player.lvl, 5, 10, 8, player.weap1, player.att_die1, "none", 0) # Name lvl, health, ac, strength, intel, att_die dog1 = dog.Dog("The rabid dog", 1, 4, 1, 2, 2, 4) pause = 1.5 pause2 = 1.25 def print1(): line = 0 while line < 6: print(line_dict1[line]) time.sleep(pause) line = line +1 line_dict1 = [ "\n\t" + player.name + ", as you look around searching through the bodies,",#0 "\tYou remember... you were with someone... a friend... ",#1 "\tMatusashi!! You start to fanticaly search for your friend",#2 "\tYou barely get started looking for Matusashi when you hear an animal growl...",#3 "\tYou Turn and look... staring at you strait in the eyse is an angry dog who is foaming at the mouth...",#4 "\n\n" +"-"*90 + "\n\n",#5 ] print1() def get_input(): command = input("\nWhat do you want to do? [hit] [examine] [run] [say]\n\nCommand >> ").split() verb_word = command[0] run = False if verb_word == "run": # Exit game and run away run = util.yesOrNo("\nYou want to " + verb_word + ".\nAre you sure? (Y/N) >> ") if run == True: print("\n\t\tYou run away!\n") return True else: return False elif verb_word in verb_dict: verb = verb_dict[verb_word] else: print("Unknown verb {}" .format(verb_word)) return False if len(command) >= 2: noun_word = command[1] print (verb(noun_word)) else: print(verb("nothing")) if dog1.health <= 0: run = True print("\n\t\t\tYou win the battle!") print("\t\tYou have gained 5 experience ponts") exp = 5 player.lvl = get_object.Level(exp) print("\n\n" + "-"*90 + "\n") return run elif Tak.health <= 0: run = True print("You lost the battle!") return run return run def say(noun): return '\nYou said "{}" and the creature growls in return.'.format(noun) + "\n\n" + "-"*90 + "\n\n" def examine(noun): if noun in gameobjects.GameObject.objects: return gameobjects.GameObject.objects[noun].get_desc() else: return "\nThere is no {} here.\n\n" + "-"*90 + "\n\n".format(noun) def hit(noun): if noun in gameobjects.GameObject.objects: thing = gameobjects.GameObject.objects[noun] def win(char1, char2): if(char1.health > char2.health): winner = char1.name not_winner = char2.name else: winner = char2.name not_winner = char1.name print("%s has killed" % winner) print("%s!" % not_winner) def fight(Char1, Char2): y = 0 z = 0 z = Char2.damage(Char1.attack()) # Player attack time.sleep(0.5) if z != 1: y = Char1.damage(Char2.attack()) # Enemy attack time.sleep(0.5) if y == 1 or z == 1: win(Char1,Char2) if Tak == thing: msg = "\nLife is too short to end it this early!\nCannot attack yourself\n\n-------------------------------------------------" elif Tak.health > 0 and thing.health > 0: msg = "\n\n" + "-"*90 + "\n\n" fight(Tak,thing) # Start fight sequence elif thing.health <= 0: msg = run = "\n%s is dead!\n\n"% (thing.name) + "-"*90 + "\n\n" else: msg = "%s dead!\n\n"(Tak.name) + "-"*90 + "\n\n" else: msg ="\nThere is no {} here\n\n".format(noun) + "-"*90 + "\n\n" return msg verb_dict = { "say":say, "examine":examine, "hit":hit, } end = False while end == False: end = get_input() if Tak.health > 0 and dog1.health <= 0: return True else: return False