def enter(the_player): the_player.location = 'Foreman Ave' the_player.directions = ['Junction','Commercial Building', 'Car barricade'] glass = random.randint(1,4) print "\nLocation:", the_player.location print "-" * 30 if the_player.location in the_player.visited: print "You're back at %s." % the_player.location print "There are waste containers on the side" print "of the road." print "Building with broken shop window is next to them." else: the_player.visited.append(the_player.location) print "You come to wide street with various shops" print "on each side and garbage everywhere." print "There are seven green waste containers on the right" print "side of the road that are stuffed" print "with various things." print "You see a commercial building, probably a shop" print "with broken front shop window." print "The street ends with a huge barricade made out of" print "cars." while True: action = prompt.standard(the_player) if action == "junction": return 'Junction' elif 'waste' in action or 'container' in action: container(the_player) elif 'window' in action or 'commercial' in action or 'building' in action: if glass == 1: death.type(12,the_player) else: print "You lose balance while stepping to the shop," print "you almost impale yourself on glass shrapnel." print "Don't try that again!" score.calculate(the_player,'glass') elif 'cars' in action or 'barricade' in action or 'car' in action: print "You try to climb the car barricade but" print "you fail, falling to the ground." if 'car barricade' not in the_player.visited: encounter = fight.Encounter(the_player,'random') print "Somehow, a zombie crawls from one of the cars." custom_error.errortype(4) encounter.start(the_player) the_player.visited.append('car barricade') else: pass else: custom_error.errortype(3)
def enter(the_player): the_player.location = 'Harrington River' the_player.directions = ['March Street', 'Marina', 'Bridge'] print "\nLocation:", the_player.location print "-" * 30 if the_player.location in the_player.visited: print "You're back at %s." % the_player.location else: the_player.visited.append(the_player.location) print "The March Street ends abruptly with a large" print "parking lot in front of Harrington River." print "There is a wooden bridge that overarches the river" print "so you can keep going." print "A narrow stairwell-like path leads to river's" print "edge where small marina is located along" print "with couple of boats." while True: action = prompt.standard(the_player) if "bridge" in action: print "You step on the bridge and hear loud" print "cracking beneath your feet." bridge_prompt = raw_input("Continue? Y/N > ").lower() if bridge_prompt == "y": death.type(11, the_player) else: pass elif 'stairs' in action or 'path' in action or 'marina' in action: return 'Marina' elif action == "march street": return 'March Street' else: custom_error.errortype(3)
def move(self): if self.the_player.age >= 100: death.type(1) elif self.the_player.age <= 3: death.type(2) else: pass current_map = Maps.map_dict.get(self.start_map) while True: get_next_map = current_map.enter(self.the_player) current_map = Maps.map_dict.get(get_next_map) if get_next_map == None: pass else: pass
def enemy_attack(self, the_player, the_enemy): chance_of_missing = random.randint(0,5) chance_of_infection = random.randint(1,50) if chance_of_missing == 0: randomize_enemy_attack = 0 else: randomize_enemy_attack = the_enemy.enemy_attack * random.uniform(0.0,1.0) the_player.hitpoints = the_player.hitpoints - randomize_enemy_attack if chance_of_infection == 50: death.type(7,the_player) else: pass if randomize_enemy_attack <= 0: print "\n%s misses!" % the_enemy.enemy_name else: print "\n%s hits you for %.2f. You have %.2f hitpoints left." % (the_enemy.enemy_name, randomize_enemy_attack, the_player.hitpoints) if the_player.hitpoints <= 0: death.type(6, the_player) else: pass
def enter(the_player): the_player.location = 'Old Building' the_player.directions = ['March Street','Old Building (first floor)'] print "\nLocation:", the_player.location print "-" * 30 num_of_tries = 4 if the_player.location in the_player.visited and 'flashlight' in the_player.inventory.keys(): print "You turn on the flashlight. Suddenly you can see all" print "the dead bodies in the room." if 'first time flash light' in the_player.visited: print "You see the trunk." else: the_player.visited.append('first time flash light') score.calculate(the_player,'turn on lights') print "Apart from the horrendous scene you notice a large trunk" print "in the back of the room." print "You come closer to open it but discover that" print "it has a mechanical lock on it with three" print "cylinders with number on them." print "The trunk has letters 'AK' crudely painted on it." if 'Wanda' in the_player.visited: print "\nWanda: 'That trunk is where our stuff should be.'" elif the_player.location in the_player.visited: print "You are at the lobby of %s again. It's dark here." % the_player.location else: the_player.visited.append(the_player.location) print "It's very dark inside and the smell is horrible." print "You can't see anything but you see a little" print "light coming from the other side of the lobby." print "You see some stairs leading up to first floor." if 'Wanda' in the_player.visited: print "\nWanda: 'This is it, this is the building. The stuff" print "must be somewhere here.'" while True: action = prompt.standard(the_player) if action == "march street" or 'out' in action: return 'March Street' elif action == "stairs" or action == "first floor": return 'Old Building (first floor)' elif action == "trunk" and not 'map' in the_player.inventory.keys(): if 'Wanda' in the_player.visited: print "\n'The code is 498 but be careful" print "because you only have few tries." print "There's a special poison needle" print "to avoid hassling with the lock'" else: pass while True: if num_of_tries != 0: try: passcode = int(raw_input("Enter three digits, '000' to go away > ")) num_of_tries = num_of_tries - 1 except ValueError: print "Put three numbers only" if passcode == 000: break elif passcode == 498: the_player.inventory['boat key'] = 1 score.calculate(the_player, 'key') print "You find some junk inside but most importantly," print "the key for the boat is there. It is squared-shaped" print "and kind of unique." if 'Wanda' in the_player.visited: print "Wanda: 'We got the key! Let's go.'" else: pass break else: print "It's still locked." else: death.type(9, the_player) else: custom_error.errortype(3) pass
def enter(the_player): the_player.location = 'Old Building (second floor)' the_player.directions = ['Old Building (first floor)'] print "\nLocation:", the_player.location print "-" * 30 if the_player.location in the_player.visited: charlie_greets = [ 'looking good','missed you',"haven't seen you for a while", 'nice ass','nice outside?'] print "You come back to %s." % the_player.location print "'Hey there %s, %s!' Charlie screams." % (the_player.name, random.choice(charlie_greets)) if 'Wanda' in the_player.visited: print "Good day to you too, Wanda. Sorry about Dave." else: the_player.visited.append(the_player.location) print "You slowly and carefully climb to second" print "floor. You see the source of light now." print "It's a small candle under the window." print "You see sleeping bag near it and" print "empty food cans around." print "Someone lives here, evidently." custom_error.errortype(4) if 'Wanda' in the_player.visited: print "Old grey man appears out of nowhere." print "'Wanda, wh-wh-what you doin here?' he says." print "'I came here to get our stuff' she replies." print "\n'Me and Dave were here few days earlier" print "and we had a plan to get out of Welton.'" print "Old man looks into the ground, his eyes" print "fixed on his feet." custom_error.errortype(4) print "'Listen... sorry if you feel offended, I just" print "wanted to keep Dave around, in case something..." print "I don't know... changed.'" print "\nWanda: 'It's okay Charlie. Don't sweat it..." print "We ended it. Just few moments ago. I know" print "he wouldn't want a life like that'" print "Charlie: 'Oh.. OK. You can stay for today" print "if you need the rest':" while True: rest = str(raw_input("Y/N > ")).lower() the_player.visited.append('charlie sleepover') if rest == "y": the_player.hitpoints = the_player.max_hitpoints print "You feel good after good rest. You have %.1f hitpoints now." % the_player.hitpoints break elif rest == "n": break else: custom_error.errortype(5) custom_error.errortype(4) print "Charlie: 'OK, your stuff is down in the lobby." print "I think you're gonna need this.'" print "He handles you a flashlight." if 'flashlight' in the_player.inventory.keys(): pass else: the_player.inventory['flashlight'] = 1 else: charlie_check = random.randint(0,1) if charlie_check == 0: print "You feel something hard landing on your head" print "and almost lose conscience." charlie_hit = random.uniform(0.1,1.0) the_player.hitpoints = the_player.hitpoints - charlie_hit if the_player.hitpoints <= 0: death.type(6) else: print "You lose %.1f hitpoints." % charlie_hit custom_error.errortype(4) elif charlie_check == 1: print "You see something approaching fast in" print "your peripheral vision." print "You manage to roll a feet away and stand" print "on your feet." score.calculate(the_player, 'charlie hit') print "You see old grey man in front of you." print "He was definitely hiding in the dark corner" print "across the candle." print "'Howdy there, I'm awfully sorry for that!" print "I thought it was Dave, he snapped that" print "rope last week and I had to fight him.'" end_conversation = False while end_conversation == False: print "\n'Heard some noise, is he allright?'\n" print "1. Yes" print "2. No" answer = prompt.conversation() if answer == 1: print "'Good, good, he's a good boy." print "He used to work for me in my restaurant." print "I know he's different now...." print "But I keep him around, as a warning" print "and to keep me safe." print "I know it's strange, don't judge me.'" break elif answer == 2: while end_conversation == False: print "'No? What did you do to him?!'" print "1. The rope snapped, I just defended myself." print "2. I killed that f****r!" answer2 = prompt.conversation() if answer2 == 1: print "'Oh...' Looks like old man is about to cry." print "I kind of got attached to him, even when" print "he became different, y'know..." print "Nevermind...'" end_conversation = True elif answer2 == 2: print "'What!!! You... I'm gonna f****n ~#^@#$...'" print "Old man pulls a huge shotgun out of his" print "coat." death.type(8, the_player) else: custom_error.errortype(1) else: custom_error.errortype(1) print "'Hey there, my name's Charlie. What's yours?'" custom_error.errortype(4) print "'%s' you mumble." % the_player.name print "\nYou hear Charlie's story, about his pizza place" print "and life he had before." print "You talked for a while and he offered you to stay" print "for the night: 'I saw a pack of 'em from the window." print "Wouldn't be safe for you to wander around at night.'\n" print "You agree and wake up late next day." custom_error.errortype(4) hp_to_heal = the_player.max_hitpoints - the_player.hitpoints the_player.hitpoints = the_player.hitpoints + hp_to_heal the_player.visited.append('charlie sleepover') print "You gain %.1f hitpoints from good night sleep.\n" % hp_to_heal print "'Listen, %s, by the way you wouldn't have some candy" % the_player.name print "on you or something?'" print "I might have a flashlight to trade...'" while True: action = prompt.standard(the_player) if "first floor" in action: return 'Old Building (first floor)' elif "chocolate" in action and 'Wanda' in the_player.visited: print "Charlie: 'No thanks.'" elif action == "chocolate" and 'flashlight' in the_player.inventory.keys() or action == "chocolate bar" and 'flashlight' in the_player.inventory.keys(): print "Sorry, I don't have anything else to trade." elif action == "chocolate" or action == "chocolate bar" and the_player.inventory['chocolate bar'] >= 1: the_player.inventory['chocolate bar'] = the_player.inventory['chocolate bar'] - 1 the_player.inventory['flashlight'] = 1 print "Charlie: 'Great! Here you go, you might have a good use for it!'" print "He gives you working flashlight" score.calculate(the_player, 'flashlight') elif action == "chocolate" or action == "chocolate bar" and the_player.inventory['chocolate bar'] == 0: print "You don't have any chocolate bar to give to Charlie." else: custom_error.errortype(3)
def enter(the_player): the_player.location = 'Old Building' the_player.directions = ['March Street', 'Old Building (first floor)'] print "\nLocation:", the_player.location print "-" * 30 num_of_tries = 4 if the_player.location in the_player.visited and 'flashlight' in the_player.inventory.keys( ): print "You turn on the flashlight. Suddenly you can see all" print "the dead bodies in the room." if 'first time flash light' in the_player.visited: print "You see the trunk." else: the_player.visited.append('first time flash light') score.calculate(the_player, 'turn on lights') print "Apart from the horrendous scene you notice a large trunk" print "in the back of the room." print "You come closer to open it but discover that" print "it has a mechanical lock on it with three" print "cylinders with number on them." print "The trunk has letters 'AK' crudely painted on it." if 'Wanda' in the_player.visited: print "\nWanda: 'That trunk is where our stuff should be.'" elif the_player.location in the_player.visited: print "You are at the lobby of %s again. It's dark here." % the_player.location else: the_player.visited.append(the_player.location) print "It's very dark inside and the smell is horrible." print "You can't see anything but you see a little" print "light coming from the other side of the lobby." print "You see some stairs leading up to first floor." if 'Wanda' in the_player.visited: print "\nWanda: 'This is it, this is the building. The stuff" print "must be somewhere here.'" while True: action = prompt.standard(the_player) if action == "march street" or 'out' in action: return 'March Street' elif action == "stairs" or action == "first floor": return 'Old Building (first floor)' elif action == "trunk" and not 'map' in the_player.inventory.keys(): if 'Wanda' in the_player.visited: print "\n'The code is 498 but be careful" print "because you only have few tries." print "There's a special poison needle" print "to avoid hassling with the lock'" else: pass while True: if num_of_tries != 0: try: passcode = int( raw_input( "Enter three digits, '000' to go away > ")) num_of_tries = num_of_tries - 1 except ValueError: print "Put three numbers only" if passcode == 000: break elif passcode == 498: the_player.inventory['boat key'] = 1 score.calculate(the_player, 'key') print "You find some junk inside but most importantly," print "the key for the boat is there. It is squared-shaped" print "and kind of unique." if 'Wanda' in the_player.visited: print "Wanda: 'We got the key! Let's go.'" else: pass break else: print "It's still locked." else: death.type(9, the_player) else: custom_error.errortype(3) pass
def enter(the_player): the_player.location = 'Old Building (second floor)' the_player.directions = ['Old Building (first floor)'] print "\nLocation:", the_player.location print "-" * 30 if the_player.location in the_player.visited: charlie_greets = [ 'looking good', 'missed you', "haven't seen you for a while", 'nice ass', 'nice outside?' ] print "You come back to %s." % the_player.location print "'Hey there %s, %s!' Charlie screams." % ( the_player.name, random.choice(charlie_greets)) if 'Wanda' in the_player.visited: print "Good day to you too, Wanda. Sorry about Dave." else: the_player.visited.append(the_player.location) print "You slowly and carefully climb to second" print "floor. You see the source of light now." print "It's a small candle under the window." print "You see sleeping bag near it and" print "empty food cans around." print "Someone lives here, evidently." custom_error.errortype(4) if 'Wanda' in the_player.visited: print "Old grey man appears out of nowhere." print "'Wanda, wh-wh-what you doin here?' he says." print "'I came here to get our stuff' she replies." print "\n'Me and Dave were here few days earlier" print "and we had a plan to get out of Welton.'" print "Old man looks into the ground, his eyes" print "fixed on his feet." custom_error.errortype(4) print "'Listen... sorry if you feel offended, I just" print "wanted to keep Dave around, in case something..." print "I don't know... changed.'" print "\nWanda: 'It's okay Charlie. Don't sweat it..." print "We ended it. Just few moments ago. I know" print "he wouldn't want a life like that'" print "Charlie: 'Oh.. OK. You can stay for today" print "if you need the rest':" while True: rest = str(raw_input("Y/N > ")).lower() the_player.visited.append('charlie sleepover') if rest == "y": the_player.hitpoints = the_player.max_hitpoints print "You feel good after good rest. You have %.1f hitpoints now." % the_player.hitpoints break elif rest == "n": break else: custom_error.errortype(5) custom_error.errortype(4) print "Charlie: 'OK, your stuff is down in the lobby." print "I think you're gonna need this.'" print "He handles you a flashlight." if 'flashlight' in the_player.inventory.keys(): pass else: the_player.inventory['flashlight'] = 1 else: charlie_check = random.randint(0, 1) if charlie_check == 0: print "You feel something hard landing on your head" print "and almost lose conscience." charlie_hit = random.uniform(0.1, 1.0) the_player.hitpoints = the_player.hitpoints - charlie_hit if the_player.hitpoints <= 0: death.type(6) else: print "You lose %.1f hitpoints." % charlie_hit custom_error.errortype(4) elif charlie_check == 1: print "You see something approaching fast in" print "your peripheral vision." print "You manage to roll a feet away and stand" print "on your feet." score.calculate(the_player, 'charlie hit') print "You see old grey man in front of you." print "He was definitely hiding in the dark corner" print "across the candle." print "'Howdy there, I'm awfully sorry for that!" print "I thought it was Dave, he snapped that" print "rope last week and I had to fight him.'" end_conversation = False while end_conversation == False: print "\n'Heard some noise, is he allright?'\n" print "1. Yes" print "2. No" answer = prompt.conversation() if answer == 1: print "'Good, good, he's a good boy." print "He used to work for me in my restaurant." print "I know he's different now...." print "But I keep him around, as a warning" print "and to keep me safe." print "I know it's strange, don't judge me.'" break elif answer == 2: while end_conversation == False: print "'No? What did you do to him?!'" print "1. The rope snapped, I just defended myself." print "2. I killed that f****r!" answer2 = prompt.conversation() if answer2 == 1: print "'Oh...' Looks like old man is about to cry." print "I kind of got attached to him, even when" print "he became different, y'know..." print "Nevermind...'" end_conversation = True elif answer2 == 2: print "'What!!! You... I'm gonna f****n ~#^@#$...'" print "Old man pulls a huge shotgun out of his" print "coat." death.type(8, the_player) else: custom_error.errortype(1) else: custom_error.errortype(1) print "'Hey there, my name's Charlie. What's yours?'" custom_error.errortype(4) print "'%s' you mumble." % the_player.name print "\nYou hear Charlie's story, about his pizza place" print "and life he had before." print "You talked for a while and he offered you to stay" print "for the night: 'I saw a pack of 'em from the window." print "Wouldn't be safe for you to wander around at night.'\n" print "You agree and wake up late next day." custom_error.errortype(4) hp_to_heal = the_player.max_hitpoints - the_player.hitpoints the_player.hitpoints = the_player.hitpoints + hp_to_heal the_player.visited.append('charlie sleepover') print "You gain %.1f hitpoints from good night sleep.\n" % hp_to_heal print "'Listen, %s, by the way you wouldn't have some candy" % the_player.name print "on you or something?'" print "I might have a flashlight to trade...'" while True: action = prompt.standard(the_player) if "first floor" in action: return 'Old Building (first floor)' elif "chocolate" in action and 'Wanda' in the_player.visited: print "Charlie: 'No thanks.'" elif action == "chocolate" and 'flashlight' in the_player.inventory.keys( ) or action == "chocolate bar" and 'flashlight' in the_player.inventory.keys( ): print "Sorry, I don't have anything else to trade." elif action == "chocolate" or action == "chocolate bar" and the_player.inventory[ 'chocolate bar'] >= 1: the_player.inventory[ 'chocolate bar'] = the_player.inventory['chocolate bar'] - 1 the_player.inventory['flashlight'] = 1 print "Charlie: 'Great! Here you go, you might have a good use for it!'" print "He gives you working flashlight" score.calculate(the_player, 'flashlight') elif action == "chocolate" or action == "chocolate bar" and the_player.inventory[ 'chocolate bar'] == 0: print "You don't have any chocolate bar to give to Charlie." else: custom_error.errortype(3)
def enter(the_player): the_player.location = 'Wanda\'s house' if 'Wanda' in the_player.visited: the_player.directions = ['Wanda\'s house street'] else: the_player.directions = ['Street with large mansion'] print "\nLocation:", the_player.location print "-" * 30 if the_player.location in the_player.visited: print "You've come back to %s." % the_player.location print "Alfie greets you by jumping at you." else: the_player.visited.append(the_player.location) print "The door were not locked but as soon" print "as you got inside you see the dog" print "that was making all the noise." print "The dog is a large dachshund with" print "really threatening look." print "It's growling at you..." custom_error.errortype(4) print "Suddenly you hear 'Alfie!' and" print "the dog runs up the wooden stairs." print "There you see a young woman aiming" print "small revolver at you." print "She says: 'Now I'm going" print "to ask you some questions and you're'" print "gonna answer.'" custom_error.errortype(4) end_conversation = False while end_conversation == False: print "'Are you gonna hurt me?'" print "1. Yes" print "2. No\n" answer_hurt = prompt.conversation() if answer_hurt == 1: death.type(10, the_player) elif answer_hurt == 2: print "'Good, good." print "Why did you come here?'" while end_conversation == False: print "1. I was looking for a shelter." print "2. I heard the dog barking." print "3. I need to get out of this town.\n" answer_come = prompt.conversation() if answer_come == 2: print "'Hmm. Alfie's been tense lately'" print "and this is exactly what I was worried" print "about. That the barking would attract more" print "deads or not-so-friendly types.'\n" pass elif answer_come == 1: print "Well... you can't expect me to offer you" print "a place to crash. You're a stranger!\n" pass elif answer_come == 3: end_conversation = True else: custom_error.errortype(1) print "'Well.. that makes two of us... name's Wanda by the way.'" print "'%s' you say." % the_player.name print "'Nice to meet you.'" custom_error.errortype(4) print "'Listen, I have a plan, sort of. Me and my boyfriend" print "were staying at this building on March St. We were" print "preparing to get outta town." print "We had everything - supplies, ammo and a ride..." print "but then a horde of deads heard us and started to" print "crawl into the lobby.'" custom_error.errortype(4) print "Well I managed to escape and still.. a herd of them" print "were following me for days. Then I found this place" print "and I have been here since." print "I couldn't get back... I was so scared and I'm not sure" print "I'll even see Dave again..." if 'Dave is dead' in the_player.visited: print "You: 'Listen, Wanda..'" print "'I know what happened to Dave.'" print "Wanda: 'You saw him?!'" print "'Yeah.. he turned, I had to kill him,' you replied." print "Wanda explodes in tears, you try to comfort her" print "but it's useless" custom_error.errortype(4) print "Few hours later she calms down a bit." print "'Hey.. I can't stay here. I gotta get away." print "let's get back to what I was trying to say...'" else: pass print "\n'The really bad thing is we had a perfect way out." print "We managed to fix one of the boats on Harrington River" print "but it had a broken motor.'" print "\n'So we got found a new one in a shop on Curling Street.'" print "You: 'Yeah that's where my place is.'" print "'Cool. But it gets worse. The keys for the boat" print "are somewhere in the building on March St., the place" print "where I saw Dave for last time.'" custom_error.errortype(4) print "'There should be a trunk with lock on it, I have the" print "password.'" print "\n'Let's get the motor and the key and get out of this" print "hellhole." print "We'll get going tomorrow morning.'" custom_error.errortype(4) hp_to_heal = the_player.max_hitpoints - the_player.hitpoints the_player.hitpoints = the_player.hitpoints + hp_to_heal print "You gain %.1f hitpoints from good night sleep.\n" % hp_to_heal print "'Hey %s here you go. It's a bandage that'll" % the_player.name print "heal you but it takes time to apply so you" print "need to use it outside of battle.'" print "\n*** Type HEAL outside of battle to heal yourself. ***\n" the_player.inventory['bandage'] = 2 print "You get %d bandages." % the_player.inventory['bandage'] print "Let's go! Alfie you need to stay here for now." the_player.visited.append('Wanda') while True: action = prompt.standard(the_player) if action == "street with large mansion" or 'out' in action or 'street' in action: return 'Cherry trees' else: custom_error.errortype(3)
def standard(the_player): push_ups = 1 while True: user_input = str(raw_input("> ")).lower() if user_input == "save": handler.save(the_player) elif user_input == "inventory" or user_input == "inv": print "Inventory:" for key, item in the_player.inventory.items(): condition = item if condition > 0 and condition <= 5: print_condition = "weak" elif condition > 5 and condition <= 15: print_condition = "OK" else: print_condition = "fine" if key == 'knife' or key == 'baseball bat': print "- %s (%s)" % (key, print_condition) elif key == 'gun': print "- %s (%d bullets left)" % (key, item) elif item > 0: print "- %s (%d)" % (key, item) elif item <= 0: pass elif user_input == "char": print "\n---", the_player.name, "---" print "Age:", the_player.age print "Is male?:", the_player.male print "Hitpoints: %.1f" % the_player.hitpoints, "/ %.1f" % the_player.max_hitpoints print "Current location:", the_player.location print "Score:", the_player.score, "points","\n" elif user_input == "help": game_help() elif user_input == "look": print "You can go to:", ", ".join(the_player.directions) elif user_input == "hint": print "Hint:", hint.location(the_player.location) # EASTER EGG elif user_input == "push up" and the_player.age > 90: death.type(4, the_player) elif user_input == "push up" and push_ups > 18: death.type(5, the_player) elif user_input == "push up": push_up = score.calculate(the_player, 'push up') print "You've done %d sets of push ups." % push_ups push_ups = push_ups + 1 elif user_input == "heal": if 'bandage' not in the_player.inventory.keys() or the_player.inventory['bandage'] == 0: print "You do not have bandage." elif the_player.hitpoints >= the_player.max_hitpoints: print "You don't need to heal yourself." elif the_player.inventory['bandage'] > 0: healed_hp = random.uniform(11.0,15.0) the_player.hitpoints = the_player.hitpoints + healed_hp the_player.inventory['bandage'] = the_player.inventory['bandage'] - 1 if the_player.hitpoints > the_player.max_hitpoints: over_hp = the_player.hitpoints - the_player.max_hitpoints the_player.hitpoints = the_player.max_hitpoints healed_hp = healed_hp - over_hp else: pass print "\nYou heal %.1f hitpoints. (Now: %.1f/%.1f HP). %d bandages left." % (healed_hp, the_player.hitpoints, the_player.max_hitpoints, the_player.inventory['bandage']) else: pass elif user_input == "map": if 'map' in the_player.inventory.keys(): print """ WELTON SUBURBS MAP Left____Another St.____Longer St.____Row of H. | | Suburbs...Very long st.____Small h.___Junction____Mansion | | Right____Regular St.____Shorter St.____St. w/ tree """ else: print "You don't have a map." elif user_input == "visited": print the_player.visited elif user_input == "killed": print the_player.killed elif user_input == "quit": print "Are you sure? Y/N" while True: to_quit = str(raw_input("> ")).lower() if to_quit == "y": break elif to_quit == "n": return '' else: custom_error.errortype(5) print "Do you want to save? Y/N" while True: save_input = str(raw_input("> ")).lower() if save_input == "y": handler.save(the_player) break elif save_input == "n": break else: custom_error.errortype(5) exit(1) else: return user_input
def enter(the_player): the_player.location = 'Foreman Ave' the_player.directions = [ 'Junction', 'Commercial Building', 'Car barricade' ] glass = random.randint(1, 4) print "\nLocation:", the_player.location print "-" * 30 if the_player.location in the_player.visited: print "You're back at %s." % the_player.location print "There are waste containers on the side" print "of the road." print "Building with broken shop window is next to them." else: the_player.visited.append(the_player.location) print "You come to wide street with various shops" print "on each side and garbage everywhere." print "There are seven green waste containers on the right" print "side of the road that are stuffed" print "with various things." print "You see a commercial building, probably a shop" print "with broken front shop window." print "The street ends with a huge barricade made out of" print "cars." while True: action = prompt.standard(the_player) if action == "junction": return 'Junction' elif 'waste' in action or 'container' in action: container(the_player) elif 'window' in action or 'commercial' in action or 'building' in action: if glass == 1: death.type(12, the_player) else: print "You lose balance while stepping to the shop," print "you almost impale yourself on glass shrapnel." print "Don't try that again!" score.calculate(the_player, 'glass') elif 'cars' in action or 'barricade' in action or 'car' in action: print "You try to climb the car barricade but" print "you fail, falling to the ground." if 'car barricade' not in the_player.visited: encounter = fight.Encounter(the_player, 'random') print "Somehow, a zombie crawls from one of the cars." custom_error.errortype(4) encounter.start(the_player) the_player.visited.append('car barricade') else: pass else: custom_error.errortype(3)
def enter(the_player): the_player.location = 'Curling Street' the_player.directions = ['Apartment','Junction'] print "\nLocation:", the_player.location print "-" * 30 if the_player.location in the_player.visited and 'charlie sleepover' in the_player.visited and 'Wanda' in the_player.visited: print "\nThe whole Curling St. is swarmed with a herd of zombies." print "Wanda: 'Tss.. be careful." print "Here's the plan: I'm gonna sneak onto other side" print "and distract them." print "Meanwhile get in the shop and look for the motor - it should" print "have label 'K5-22TS' on it. It's pretty heavy so you might need" print "something to move it around." print "We'll meet back at Junction once you're done but be quick!'" score.calculate(the_player,'wanda decoy') print "\nWanda sneaks behind the cars and gets about 30m away from you." print "'Come on, you fuckers!' she screams. The herd starts moving towards" print "her. You hope she'll be fine." print "'B&D Motors' is ahead, you carefully sneak into the shop..." custom_error.errortype(4) return 'Motor Shop' elif the_player.location in the_player.visited and 'charlie sleepover' in the_player.visited: print "You try to step carefully, hiding behind close by dumpster." print "Unfortunately you step on broken glass and the" print "swarm starts to navigate towards you..." custom_error.errortype(4) while True: encounter = fight.Encounter(the_player, 'zombie male') encounter.start(the_player) print "As you finished one zombie, another one approaches." print "Time to get ready..." custom_error.errortype(4) elif 'motor' in the_player.inventory.keys() and 'Wanda' in the_player.visited: print "Wanda: 'We already got what we need, let's just go" print "the herd might move back here again.'" return 'Junction' elif the_player.location in the_player.visited: if 'gun' in the_player.inventory.keys(): pass else: print "There is still a policeman lying on the floor." pass print "You're in %s again." % the_player.location print "You've been here before." pass else: the_player.visited.append(the_player.location) print "You walk out of your apartment." print "You are on %s, it's a large street" % the_player.location print "with junction at the end." print "There are corpses everywhere, all of them" print "are dead and didn't turn." print "Most of them probably commited suicide." print "You notice a corpse of policeman few meters from you." while True: if the_player.hitpoints <= 0: death.type(3, the_player) else: pass action = prompt.standard(the_player) if action == "apartment": return the_player.directions[0] break elif action == "policeman" and not 'gun' in the_player.inventory.keys(): bullets = random.randint(5,10) the_player.inventory['gun'] = bullets print "You take the gun which has %d bullets in it." % bullets get_score = score.calculate(the_player, 'gun') elif action == "policeman": print "You already searched the policeman." elif action == "junction": return 'Junction' else: custom_error.errortype(3)
def enter(the_player): the_player.location = 'Curling Street' the_player.directions = ['Apartment', 'Junction'] print "\nLocation:", the_player.location print "-" * 30 if the_player.location in the_player.visited and 'charlie sleepover' in the_player.visited and 'Wanda' in the_player.visited: print "\nThe whole Curling St. is swarmed with a herd of zombies." print "Wanda: 'Tss.. be careful." print "Here's the plan: I'm gonna sneak onto other side" print "and distract them." print "Meanwhile get in the shop and look for the motor - it should" print "have label 'K5-22TS' on it. It's pretty heavy so you might need" print "something to move it around." print "We'll meet back at Junction once you're done but be quick!'" score.calculate(the_player, 'wanda decoy') print "\nWanda sneaks behind the cars and gets about 30m away from you." print "'Come on, you fuckers!' she screams. The herd starts moving towards" print "her. You hope she'll be fine." print "'B&D Motors' is ahead, you carefully sneak into the shop..." custom_error.errortype(4) return 'Motor Shop' elif the_player.location in the_player.visited and 'charlie sleepover' in the_player.visited: print "You try to step carefully, hiding behind close by dumpster." print "Unfortunately you step on broken glass and the" print "swarm starts to navigate towards you..." custom_error.errortype(4) while True: encounter = fight.Encounter(the_player, 'zombie male') encounter.start(the_player) print "As you finished one zombie, another one approaches." print "Time to get ready..." custom_error.errortype(4) elif 'motor' in the_player.inventory.keys( ) and 'Wanda' in the_player.visited: print "Wanda: 'We already got what we need, let's just go" print "the herd might move back here again.'" return 'Junction' elif the_player.location in the_player.visited: if 'gun' in the_player.inventory.keys(): pass else: print "There is still a policeman lying on the floor." pass print "You're in %s again." % the_player.location print "You've been here before." pass else: the_player.visited.append(the_player.location) print "You walk out of your apartment." print "You are on %s, it's a large street" % the_player.location print "with junction at the end." print "There are corpses everywhere, all of them" print "are dead and didn't turn." print "Most of them probably commited suicide." print "You notice a corpse of policeman few meters from you." while True: if the_player.hitpoints <= 0: death.type(3, the_player) else: pass action = prompt.standard(the_player) if action == "apartment": return the_player.directions[0] break elif action == "policeman" and not 'gun' in the_player.inventory.keys( ): bullets = random.randint(5, 10) the_player.inventory['gun'] = bullets print "You take the gun which has %d bullets in it." % bullets get_score = score.calculate(the_player, 'gun') elif action == "policeman": print "You already searched the policeman." elif action == "junction": return 'Junction' else: custom_error.errortype(3)
def standard(the_player): push_ups = 1 while True: user_input = str(raw_input("> ")).lower() if user_input == "save": handler.save(the_player) elif user_input == "inventory" or user_input == "inv": print "Inventory:" for key, item in the_player.inventory.items(): condition = item if condition > 0 and condition <= 5: print_condition = "weak" elif condition > 5 and condition <= 15: print_condition = "OK" else: print_condition = "fine" if key == 'knife' or key == 'baseball bat': print "- %s (%s)" % (key, print_condition) elif key == 'gun': print "- %s (%d bullets left)" % (key, item) elif item > 0: print "- %s (%d)" % (key, item) elif item <= 0: pass elif user_input == "char": print "\n---", the_player.name, "---" print "Age:", the_player.age print "Is male?:", the_player.male print "Hitpoints: %.1f" % the_player.hitpoints, "/ %.1f" % the_player.max_hitpoints print "Current location:", the_player.location print "Score:", the_player.score, "points", "\n" elif user_input == "help": game_help() elif user_input == "look": print "You can go to:", ", ".join(the_player.directions) elif user_input == "hint": print "Hint:", hint.location(the_player.location) # EASTER EGG elif user_input == "push up" and the_player.age > 90: death.type(4, the_player) elif user_input == "push up" and push_ups > 18: death.type(5, the_player) elif user_input == "push up": push_up = score.calculate(the_player, 'push up') print "You've done %d sets of push ups." % push_ups push_ups = push_ups + 1 elif user_input == "heal": if 'bandage' not in the_player.inventory.keys( ) or the_player.inventory['bandage'] == 0: print "You do not have bandage." elif the_player.hitpoints >= the_player.max_hitpoints: print "You don't need to heal yourself." elif the_player.inventory['bandage'] > 0: healed_hp = random.uniform(11.0, 15.0) the_player.hitpoints = the_player.hitpoints + healed_hp the_player.inventory[ 'bandage'] = the_player.inventory['bandage'] - 1 if the_player.hitpoints > the_player.max_hitpoints: over_hp = the_player.hitpoints - the_player.max_hitpoints the_player.hitpoints = the_player.max_hitpoints healed_hp = healed_hp - over_hp else: pass print "\nYou heal %.1f hitpoints. (Now: %.1f/%.1f HP). %d bandages left." % ( healed_hp, the_player.hitpoints, the_player.max_hitpoints, the_player.inventory['bandage']) else: pass elif user_input == "map": if 'map' in the_player.inventory.keys(): print """ WELTON SUBURBS MAP Left____Another St.____Longer St.____Row of H. | | Suburbs...Very long st.____Small h.___Junction____Mansion | | Right____Regular St.____Shorter St.____St. w/ tree """ else: print "You don't have a map." elif user_input == "visited": print the_player.visited elif user_input == "killed": print the_player.killed elif user_input == "quit": print "Are you sure? Y/N" while True: to_quit = str(raw_input("> ")).lower() if to_quit == "y": break elif to_quit == "n": return '' else: custom_error.errortype(5) print "Do you want to save? Y/N" while True: save_input = str(raw_input("> ")).lower() if save_input == "y": handler.save(the_player) break elif save_input == "n": break else: custom_error.errortype(5) exit(1) else: return user_input