Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import characters as char
- import items as item
- import random as ran
- import time
- class Room(object):
- def __init__(self, name, description, north, south, east, west):
- self.name = name
- self.desc = description
- self.north = north
- self.south = south
- self.east = east
- self.west = west
- def move(self, direction):
- global current
- current = globals()[getattr(self, direction)]
- print(current.name + '\n' + current.desc)
- # Extra Variables
- wait = time.sleep
- _low = str.lower
- _isi = isinstance
- _nil = []
- mid_hall_desc = "You see a light at the end of the hallway."
- corner_desc = "You are at the end of the hallway. There is a way in every direction."
- s_bridge_desc = "You are at the start of a bridge."
- elevator_desc = "You step into the elevator, but upon stepping into it, you feel very unstable."
- e_bridge_desc = "You are at the end of the bridge."
- auth_desc = "You are in front of a small military building."
- in_desc = "You are inside of the small military building."
- cam_desc = "Numerous amounts of screens, viewing every room that you've been in.\nEven the one you're in right now ..."
- pain_desc = "смерть неизбежна"
- # Room Instantiation
- # West Map
- light_room = Room("Light Room", "You are in a room with a dimly lit light above.", None, None, None, "hallway")
- hallway = Room("Hallway", "You are in a dark hallway.", None, "mid_hallway", "light_room", "elevator")
- mid_hallway = Room("Hallway", mid_hall_desc, "hallway", "corner", "dark_room2", "lift")
- elevator = Room("Elevator", elevator_desc, None, None, "hallway", None)
- dark_room = Room("Dark Room", "You are in a room with no light.", None, None, "mid_hallway", None)
- dark_room2 = Room("Dark Room", "You are in a room with no light.", None, None, None, "mid_hallway")
- corner = Room("End of Hallway", corner_desc, "mid_hallway", "stairs", "start_bridge", "closet")
- # Intersection
- closet = Room("Closet", "You enter a small closet.", None, None, "corner", None)
- # South Map
- lounge = Room("Lounge Area", "You are in, what seems like, a hangout spot.", "stairs", None, "hole", "bar")
- bar = Room("Bar", "You are in a small bar.", None, None, "lounge", None)
- hole = Room("Hole", "You are in front of a deeply dug hole.", "pit", None, "in_hole", None)
- in_hole = Room("Inside of Hole", "You are in a pile of rotten screech corpses.", None, None, None, "hole")
- pit = Room("Pit of Garbage", "You are in front of a pit of garbage.", "start_bridge", "hole", "in_pit", None)
- in_pit = Room("Inside of Pit", "You step into the pile of trash.", None, None, None, "pit")
- # Middle Map
- start_bridge = Room("Start of Bridge", s_bridge_desc, None, "pit", "bridge", "corner")
- bridge = Room("Bridge", "You are at the middle of the bridge.", None, None, "end_bridge", "start_bridge")
- end_bridge = Room("End of Bridge", e_bridge_desc, None, None, "authority", "bridge")
- # East Map
- authority = Room("Front of Military Building", auth_desc, "alley", "cliff", "inside", "end_bridge")
- alley = Room("Alley Way", "You are in a dark alley way.", None, "authority", "cliff", None)
- inside = Room("Inside of Military Building", in_desc, "camera", "locker", "hatch", "authority")
- camera = Room("Camera Room", cam_desc, "pain", inside, None, None)
- pain = Room("боль", pain_desc, None, "camera", None, None)
- locker = Room("Locker Room", "You are in a locker room, with 5 different rows.", "inside", "row1", None, None)
- row1 = Room("Row One", "You are in the first row in the locker room.", "locker", "row2", None, None)
- row2 = Room("Row Two", "You are in the second row in the locker room.", "row1", "row3", None, None)
- row3 = Room("Row Three", "You are in the third row in the locker room.", "row2", "row4", None, None)
- row4 = Room("Row Four", "You are in the fourth row in the locker room.", "row3", "row5", None, None)
- row5 = Room("Row Five", "You are in the fifth row in the locker room.", "row4", None, None, None)
- hatch = Room("Hatch Room", "You are in a small room with only a hatch on the floor", None, None, None, "inside")
- # Item Instantiation
- expired_beans = item.BadFood("Expired Beans", "A can of expired beans.", light_room, False, 15, 10)
- water_bottle = item.Beverage("Water Bottle", "A clear bottle of water.", light_room, False, 25)
- rusty_nail = item.BadMelee("Rusty Nail", "A short, bent, rusty nail.", light_room, False, 15, 15, False)
- plastic_bag = item.Bag("Plastic Bag", "A tiny plastic bag used for storage.", light_room, False, 5, False)
- # Enemy Items
- s_body1 = item.BadFood("Screech Arm", "A skinny arm, with bloody white meat.", mid_hallway, True, 20, 25)
- s_body2 = item.BadFood("Screech Leg", "A skinny leg, with bloody white meat.", lounge, True, 25, 30)
- item_list = [expired_beans, water_bottle, rusty_nail, plastic_bag, s_body1, s_body2]
- # Enemy Instantiation
- screech = char.Enemy("Screech", "A limping humanoid with a gaping mouth.", 50, mid_hallway, s_body1)
- screech2 = char.Enemy("Screech", "A limping humanoid with a gaping mouth.", 50, lounge, s_body2)
- enemy_list = [screech, screech2]
- def put(__item):
- item_list.remove(_item)
- item_list.append(__item)
- # Player Variables
- health = 100
- hunger = 50
- thirst = 50
- room = 5
- starving = False
- thirsty = False
- inventory = []
- current = light_room
- weapon = None
- backpack = None
- # Functions
- def eat(command, _item, hp, hg):
- if _low(_item.name) in command:
- if _isi(_item, item.BadFood):
- hp -= _item.health
- hg += _item.hunger
- print("You ate the %s, but it didn't taste so good." % _item.name)
- elif _isi(_item, item.Food):
- hg += _item.hunger
- print("You ate the %s." % _item.name)
- def take(command, _item):
- _b = item.BadMelee
- _m = item.Melee
- _bg = item.Bag
- _bp = item.Backpack
- _hbp = item.HeavyBackpack
- if _low(_item.name) in command and _item.room is current and not _item.pick:
- item_list.remove(_item)
- inventory.append(_item)
- _item.pick = True
- if _isi(_item, _b) or _isi(_item, _m) or _isi(_item, _bg) or _isi(_item, _bp) or _isi(_item, _hbp):
- print("You took the %s, but you need to equip it before you can use it." % _low(_item.name))
- else:
- print("You took the %s" % _low(_item.name))
- def drop(command, _item):
- if _low(_item.name) in command and _item.pick:
- inventory.remove(_item)
- item_list.append(_item)
- _item.pick = False
- print("You dropped the %s" % _low(_item.name))
- def view_room():
- items = False
- print(current.name + '\n' + current.desc)
- for __item in item_list:
- if __item.room is current:
- items = True
- if items:
- print("There are items in the room.")
- def view_items(_item):
- if _item.room is current:
- print(' - ' + _item.name)
- def use(command, _item):
- if _low(_item.name) in command:
- if not _item.used:
- if _isi(_item, item.BadMelee) or _isi(_item, item.Melee):
- _item.used = True
- print("You equipped the %s" % _low(_item.name))
- elif _isi(_item, item.Bag) or _isi(_item, item.Backpack) or _isi(_item, item.HeavyBackpack):
- _item.used = True
- print("You wore the %s" % _low(_item.name))
- else:
- print("You cannot do that now.")
- def remove(command, _item):
- if _low(_item.name) in command:
- if _item.used:
- _item.used = False
- print("You removed the %s" % _low(_item.name))
- else:
- print("You cannot remove that")
- def view_statistics():
- print("Your current health is %d\nYour current hunger is %d" % (health, hunger))
- print("Your current thirst is %d\nYour current inventory space is %d" % (thirst, room))
- if backpack is not None:
- print("Your current backpack is : %s" % backpack.name)
- if weapon is not None:
- print("Your current weapon is : %s" % weapon.name)
- def view_inventory(_item):
- if _item.used:
- print(' - ' + _item.name + ' [USING]')
- else:
- print(' - ' + _item.name)
- directions = ['north', 'south', 'east', 'west']
- short = ['n', 's', 'e', 'w']
- def move(direction):
- try:
- current.move(direction)
- except KeyError:
- print("You can't move that way.")
- def attack(command, health, plr_weapon):
- accuracy = ran.randint(0, 2)
- if _low(enemy.name) in command and enemy.room is current:
- if weapon is not None and accuracy > 0:
- enemy.health -= weapon.damage
- print("You attacked %s." % enemy.name)
- elif accuracy is 0:
- print("You missed!\nThe %s took advantage and attacked you." % _low(enemy.name))
- health -= ran.randint(10, 20)
- elif weapon is None:
- print("You have no weapon to attack with, so you freeze out of fear.")
- wait(1)
- print("The %s sees your fear, and takes advantage." % _low(enemy.name))
- wait(1)
- print("The %s cracked your skull open." % _low(enemy.name))
- health -= health
- if enemy.health <= 0:
- print("You killed %s with your %s" % (_low(enemy.name), _low(plr_weapon.name)))
- while True:
- if hunger is 0:
- health -= 5
- if thirst is 0:
- health -= 5
- attack_accuracy = ran.randint(0, 2)
- cmd = _low(input('> ')).strip()
- if cmd in directions:
- if hunger < 0:
- hunger = 0
- if thirst < 0:
- thirst = 0
- move(cmd)
- if cmd == 'quit':
- quit(0)
- elif cmd in short:
- pos = short.index(cmd)
- move(directions[pos])
- elif cmd == 'look' or cmd == 'room':
- view_room()
- elif cmd == 'inventory':
- for _item in inventory:
- view_inventory(_item)
- elif cmd == "items":
- for _item in item_list:
- view_items(_item)
- elif cmd == 'stats' or cmd == 'statistics':
- view_statistics()
- elif 'take' in cmd:
- for _item in item_list:
- take(cmd, _item)
- elif 'drop' in cmd:
- for _item in inventory:
- drop(cmd, _item)
- elif 'eat' in cmd:
- for _item in inventory:
- eat(cmd, _item, health, hunger)
- elif 'use' in cmd:
- w = weapon
- b = backpack
- for _item in inventory:
- if _isi(_item, item.BadMelee) or _isi(_item, item.Melee):
- use(cmd, _item)
- elif _isi(_item, item.Bag) or _isi(_item, item.Backpack) or _isi(_item, item.HeavyBackpack):
- use(cmd, _item)
- elif 'remove' in cmd:
- w = weapon
- b = backpack
- bm = item.BadMelee
- m = item.Melee
- bg = item.Bag
- bp = item.Backpack
- hbp = item.HeavyBackpack
- for _item in inventory:
- if _isi(_item, bm) or _isi(_item, m) or _isi(_item, bg) or _isi(_item, bp) or _isi(_item, hbp):
- remove(cmd, _item)
- elif 'attack' in cmd:
- for enemy in enemy_list:
- if enemy.room is current:
- hp = health
- attack(cmd, hp, weapon)
- if health is 0:
- print("Too much damage has been inflicted on you.")
- wait(1)
- print("You are dead.")
- break
Add Comment
Please, Sign In to add comment