def ShowInventory(self): Head = "head\t\t"+self.inv['head'].name+"\t"+str(self.inv['head'].stats)+"\n" Body = "body\t\t"+self.inv['body'].name+"\t"+str(self.inv['body'].stats)+"\n" Hand = "hand\t\t"+self.inv['hand'].name+"\t"+str(self.inv['hand'].stats)+"\n" OffHand = "off-hand\t"+self.inv['off-hand'].name+"\t"+str(self.inv['off-hand'].stats)+"\n" printT("INVENTORY: (\S)" + Head + Body + Hand + OffHand)
def Closing(): print("\nAnd so, the "+wincolour+"fate" +textcolour+ " of "+mapcolour+"McMaster" +textcolour+ " has been decided...") time.sleep(DELAY) print("Our hero has unlocked the "+wincolour+"secrets" +textcolour+ " of "+mapcolour+"McMaster University" +textcolour+ "") time.sleep(DELAY) print("and "+wincolour+"lived" +textcolour+ " to tell the tale.\n") time.sleep(DELAY) print("___________ __________.__") print("\_ _____/ " +red+ "THE_GREAT" +textcolour+ "_____ \______ \ |__ ___.__. ______") print(" | __)_ / \ / ___ > | ___/ | \ | |/ ___/") print(" | \ | \/ /_/ / | | | \___ |\___ \ ") print("/_______ /___| /\___ / |____| |___| / ____/____ >") print(" \/ \//_____/ " +red+ "TEXT ADVENTURE" +textcolour+ " \/\/ (v4.20) \/ \n") time.sleep(DELAY) print("Created by:\n"+red+"Brendan Fallon" +textcolour+ ", " +white+ "Tyler Kashak" +textcolour+ ", and " +lightblue+ "Mitchell Lemieux" +textcolour+ ". \n") time.sleep(DELAY) printT("" +lightmagenta+ "Special Thanks:" +textcolour+ "\n" +personcolour+ "Erik" +textcolour+ " and " +personcolour+ "Phil" +textcolour+ " our best " +indicatecolour+ "playtesters" +textcolour+ "! There are no " +wincolour+ "better quality checkers" +textcolour+ " than you guys. (\S)") time.sleep(DELAY/2) print("Also thanks to Eric, Brian, Liam, and Megan.\n") time.sleep(DELAY) print(" " + red + "A" + textcolour + "____ ________") print(" /_ H|\_____ \ ") print(" | O| ___| |") print(" | L| /___ <") print(" | L| ___\ |") print(" | Y| /W O O D|") print(" |___|/________/") print(" " + red + "Production." + textcolour + "") time.sleep(2) printT("This is a work of fiction. Names, characters, businesses, places, events, locales, and incidents are " "either the products of the author's imagination or used in a fictitious manner. Any resemblance to actual " "persons, living or dead, or actual events is purely coincidental. (\S)",72,0) time.sleep(DELAY) AsciiArt.ThanksForPlaying() time.sleep(DELAY)
def drop(self,Equip): # Equip is an object not a name drop = 0 if(Equip.name == self.inv[Equip.worn].name): self.inv[Equip.worn] = self.emptyinv[Equip.worn] printT(" (\S)You've dropped the " + Equip.colouredname +".") drop = Equip else: printT("Maybe you're still drunk?. You aren't carrying " + Equip.colouredname + ".") self.updateStats() return drop
def Drop(Item): # Item is a string not an object global MAPS global PLAYER global ITEMS global ENEMIES x = PLAYER.location[0] y = PLAYER.location[1] z = PLAYER.location[2] dim = PLAYER.location[3] Place = MAPS[x][y][z][dim] if Item in ITEMS and list(ITEMS[Item].location) == PLAYER.location: # TODO Redo this drop and equip structure. Is dumb and can cause duplicates/ghosting drop = PLAYER.drop(ITEMS[Item]) # the player drop method that will return the item dropped Place.placeItem(drop) # places the drop on the ground # Same as equip function. 'None' passed to function if item doesn't exist # other acceptations for weird requests elif Item in INTERACT and list(INTERACT[Item].location) == PLAYER.location: # Interacts printT("You probably shouldn't drop the " + str(INTERACT[Item].colouredname) + ". It might break.") elif Item in ENEMIES and list(ENEMIES[Item].location) == PLAYER.location and ENEMIES[Item].alive: # People printT("You drop " + ENEMIES[Item].colouredname + " but they were never yours, to begin with. (\S)Now you just have one less friend...") elif Item in ENEMIES and list(ENEMIES[Item].location) == PLAYER.location and not ENEMIES[Item].alive: # Dead People printT("You pick up " +deadpersoncolour+ ENEMIES[Item].name +textcolour+ "'s body and drop it. Do you get a kick out of this?") else: printT("Maybe you're still drunk?. You aren't carrying a " +itemcolour+ Item +textcolour+ ".")
def Inventory(): global PLAYER # Player inventory is a dictionary of objects so can access and print them out printT(" (\S){1}HEAD: " + PLAYER.inv['head'].colouredname,72,0.25) printT("{2}BODY: " + PLAYER.inv['body'].colouredname,72,0.25) printT("{3}HAND: " + PLAYER.inv['hand'].colouredname,72,0.25) printT("{4}OFF-HAND: " + PLAYER.inv['off-hand'].colouredname + " (\S)",72,0.25)
def Equip(Item): # Item is a string not an object global PLAYER global ITEMS global MAPS global INTERACT x = PLAYER.location[0] y = PLAYER.location[1] z = PLAYER.location[2] dim = PLAYER.location[3] Place = MAPS[x][y][z][dim] if Item in ITEMS and list(ITEMS[Item].location) == PLAYER.location: # if name of Item asked for in parser is in ITEMS dictionary # this is different than the equip method in the Character class for some reason # Makes sure the item is dropped at the current location # TODO Redo this drop and equip structure. Is dumb and can cause duplicates/ghosting drop = PLAYER.equip(ITEMS[Item]) # does the equip method on the player Place.removeItem(ITEMS[Item]) # removes that item from the invoirnment Place.placeItem(drop) # places the drop if there's something to drop ITEMS[Item].quest = True # quest/inspect flag is true # other acceptations for weird requests elif Item in INTERACT and list(INTERACT[Item].location) == PLAYER.location: # Interacts printT("Maybe if you were at your peak you could carry a " + str(INTERACT[Item].colouredname) + " but not with this migraine.") elif Item in ENEMIES and list(ENEMIES[Item].location) == PLAYER.location and ENEMIES[Item].alive: # People printT("You attempt to pick up " + ENEMIES[Item].colouredname + " but you're not that close... (\S)And now you're both really uncomfortable.") elif Item in ENEMIES and list(ENEMIES[Item].location) == PLAYER.location and not ENEMIES[Item].alive: # Dead People printT("That's pretty messed up. You probably shouldn't pick up " +deadpersoncolour+ ENEMIES[Item].name + textcolour+ "'s body.") else: printT(" (\S)You can't find a " +itemcolour+ Item +textcolour+ " around here. Maybe it's your hungover brain.")
def DisplayTime(value): # converts and displays the time given seconds, for speedrunning '''From seconds to Days;Hours:Minutes;Seconds;Milliseconds''' # Figured out there is an effecient way to do this using time module but whatev. valueD = (((value/24)/60)/60) Days = int (valueD) valueH = (value-Days*24*3600) Hours = int(valueH/3600) valueM = (valueH - Hours*3600) Minutes = int(valueM/60) valueS = (valueM - Minutes*60) Seconds = int(valueS) valueMS = (valueM - Seconds) Milliseconds = valueMS*1000 printT("Your run-time was: (\S)"+ str(Days) + " Days; " + str(Hours)+ " Hours; " + str(Minutes) + " Minutes; " + str(Seconds) + " Seconds; " + str(Milliseconds) + " Milliseconds")
def Combat(P,E): if E: #Speed PSpeed = P.stats[2] ESpeed = E.stats[2] #Determine who goes first if PSpeed>ESpeed: First = P Second = E elif PSpeed<ESpeed: First = E Second = P else: Combatants = [E,P] First = choice(Combatants) Combatants.remove(First) Second = Combatants[0] #Max damage each can deal FDamage = abs(First.stats[0])*First.stats[0]/(Second.stats[1]+1) SDamage = abs(Second.stats[0])*Second.stats[0]/(First.stats[1]+1) #Starting health FSHealth = First.health SSHealth = Second.health while (P.health and E.health): if First.health: Damage = int(uniform(0.7, 1)*FDamage) if GAMEINFO['devmode']: printT(First.name + " deals " + str(Damage) + " to " + Second.name) Second.health = max(0,Second.health - Damage) if GAMEINFO['devmode']: printT(Second.name + " health: " + str(Second.health)) if Second.health: Damage = int(uniform(0.7, 1)*SDamage) if GAMEINFO['devmode']: printT(Second.name + " deals " + str(Damage) + " to " + First.name) First.health = max(0,First.health - Damage) if GAMEINFO['devmode']: printT(First.name + " health: " + str(Second.health)) # TODO Re-implement combat and number with word ques instead of numbers. Also say: _ strikes first # if First == P: # print "\nYou attack dealing " + str(SSHealth - Second.health) + " damage.\n" + Second.name + " deals " + str(FSHealth - First.health) + " damage.\n" # print "You have " + str(First.health) + " health remaining.\n" + Second.name + " has " + str(Second.health) + " health remaining.\n" # else: # print "\n"+First.name + " dealt " + str(SSHealth - Second.health) + " damage.\n" + "You attack dealing " + str(FSHealth - First.health) + " damage.\n" # print "You have " + str(Second.health) + " health remaining.\n" + First.name + " has " + str(First.health) + " health remaining.\n" if P.health == 0: P.alive = False return 0 if E.health == 0: E.alive = False return 1
def drop_objects(self,Item,x,y,z,dim,MAPS,ITEMS,INTERACT,ENEMIES): # this is a general method to drop objects # THIS PARSING ONLY Works if all item keys are unique if INTERACT[Item].drop in list(ITEMS.keys()): # if it's an ITEM (in the item keys) MAPS[x][y][z][dim].placeItem(ITEMS[INTERACT[Item].drop]) printT("You see " + ITEMS[INTERACT[Item].drop].colouredname+ ". (\S)") elif INTERACT[Item].drop in list(ENEMIES.keys()): # if it's an Enemy MAPS[x][y][z][dim].placeEnemy(ENEMIES[INTERACT[Item].drop]) printT("You see " + ENEMIES[INTERACT[Item].drop].colouredname + ". (\S)") elif INTERACT[Item].drop in list(INTERACT.keys()): # if it's an Interactable MAPS[x][y][z][dim].placeInteract(INTERACT[INTERACT[Item].drop]) printT("You see " + INTERACT[INTERACT[Item].drop].colouredname + ". (\S)") # TODO Make this an option maybe so it doesn't have to remove itself MAPS[x][y][z][dim].removeInteract(INTERACT[Item]) # If it's an interactable place it's an upgrade/transform
if platform == "win32": try: GAMEINFO['savepath'] = os.path.join(os.getenv('APPDATA'), "EngPhysTextAdventure", "", "cache", "") # Used for hidden saves + logs GAMEINFO['datapath'] = os.path.join(os.getenv('APPDATA'), "EngPhysTextAdventure", "") # Used for setting file os.makedirs(GAMEINFO['savepath']) # gets the directory then makes the path if it's not there # CAN"T have last \ in the file path so have to use [:-1] to use all string but the last character # Not hiding individual files so can access and also will throw an error to access if files are hidden os.system("attrib +h " + GAMEINFO['savepath'][:-1]) # Makes cache file hidden except: printT(" (\S)") # does nothing if the path is already there elif platform == "linux" or platform == "linux2": # Linux try: GAMEINFO['savepath'] = os.path.join(os.getcwd(), "EngPhysTextAdventure", "", "cache", "") # Used for hidden saves + logs GAMEINFO['datapath'] = os.path.join(os.getcwd(), "EngPhysTextAdventure", "") # Used for setting file os.makedirs(GAMEINFO['savepath']) # gets the directory then makes the path if it's not there except: printT(" (\S)") # does nothing if the path is already there elif platform == "darwin": # OS X/MAC try: GAMEINFO['savepath'] = os.path.join(os.getcwd(), "EngPhysTextAdventure", "", "cache", "") # Used for hidden saves + logs GAMEINFO['datapath'] = os.path.join(os.getcwd(), "EngPhysTextAdventure", "") # Used for setting file os.makedirs(GAMEINFO['savepath']) # gets the directory then makes the path if it's not there except: printT(" (\S)") # does nothing if the path is already there
def equip(self,Equip): drop = 0 # You're already wearing the thing if self.inv[Equip.worn] == Equip: printT(" (\S)You realize this you already have a " + Equip.colouredname + " on you. It's okay, we all have tough days. (\S)",72,0.25) # if your inventory is empty elif (self.location == list(Equip.location) and self.inv[Equip.worn] == self.emptyinv[Equip.worn]): self.inv[Equip.worn] = Equip Equip.location = self.location printT(" (\S)" +Equip.info + " (\S)",72,0.25) printT("You've equipped the " + Equip.colouredname + ' to your ' + Equip.worn + ".",72,0.25) # If you have something on you that you're replacing elif(self.location == list(Equip.location)): drop = self.inv[Equip.worn] self.inv[Equip.worn] = Equip Equip.location = self.location printT(" (\S)"+ Equip.info + " (\S)") printT("You've equipped the " + Equip.colouredname + ' to your ' + Equip.worn + ', the ' + drop.colouredname + ' has been dropped.') else: printT(" (\S)You can't find a " + Equip.colouredname + " around here. Maybe it's your hungover brain.") self.updateStats() return drop
def search(self,MAPS,DIMENSIONS,GAMESETTINGS,Spawn=False): # Is passed MAPS dictionary so it can search area around it #also test the displays of things. [People], ~Places~, <Things>, /Interactables/ (put these next to descriptions) if Spawn: # this is the printout if you wake up in a location (say for example a load) printT("You wake up in " + self.colouredname + ". (\S)") printT(self.lore) elif self.travelled: printT("You enter " + self.colouredname + ". (\S)") printT(self.lore) description = "" # the main text description accumulator # setting the title description += " (\S)" +mapcolour+ "~" + self.name.upper() + "~" +textcolour+ " (\S)" length = len(self.items) # (\S) used for printT newline # Initialize the {shortkey} used with object,interact,enemy for quick commands. # Disabling shortkey printing for now but still exists in the game #shortkey = 5 # Starts at 5 because 1-4 are reserved for inventory quick commands shortkey = "" # This big if statement basically does a printout to account for single object/enemy in the area grammer if length: description += "You see" if length > 1: # If there's more than one item/interact in the area for i in range(length): if (i == length-1): if isinstance(self.items[i],Equipment): description = description +textcolour+" and a " + str(shortkey) + "" + "" + self.items[i].colouredname + "" + ".\n" #item highlight, checks to see if object is of class equipment and if not it's an interactable #shortkey += 1 # increments the shortkey else: description = description +textcolour+" and a " + str(shortkey) + "" + "" + self.items[i].colouredname + "" + ".\n" #inspectable highlight #shortkey += 1 # increments the shortkey else: if isinstance(self.items[i],Equipment): description = description +textcolour+ " a " + str(shortkey) + "" + "" + self.items[i].colouredname + "" + "," #shortkey += 1 # increments the shortkey else: description = description +textcolour+ " a " + str(shortkey) + "" + "" + self.items[i].colouredname + "" + "," #shortkey += 1 # increments the shortkey else: # if there's only 1 item/interact in the area if isinstance(self.items[0],Equipment): description = description +textcolour+ " a " + str(shortkey) + "" + "" + self.items[0].colouredname + "" + ".\n" # equipment highlight #shortkey += 1 # increments the shortkey else: description = description +textcolour+ " a " + str(shortkey) + "" + "" + self.items[0].colouredname + "" + ".\n" # inspectable highlight #shortkey += 1 # increments the shortkey if self.ENEMY: for enemy in self.ENEMY: if enemy.alive and enemy.location == (2,4,1,0): #if enermy is in JHE lobby they are playing eng phys text adventure lol (including yourself) description = description +textcolour+ " (\S)" + str(shortkey) + "" + "" + enemy.colouredname + "" + " is playing the Eng Phys Text Based Adventure. WAIT What!?" #shortkey += 1 # increments the shortkey elif enemy.alive: description = description +textcolour+ " (\S)" + str(shortkey) + "" + "" + enemy.colouredname + "" + " is " \ + choice(["standing in the corner","wandering around","reading a book","creating a grand unified field theory", "eating a frighteningly large burrito","playing RuneScape","browsing math memes", "taking a hit from a laser bong","laying down crying","watching the Big Lez show on full volume", "eating a Big Mac", "eating too much Lava Pizza", "contemplating how much Mayo is too much", "bathing in Mayonnaise", "in a sushi coma", "phasing in and out of this dimension", "drinking spicy Pho broth", "reading a book under a tree", "wondering how you can read their thoughts?", "playing 4D chess", "pondering necromancy", "unsuccessfully painting their Warhammer 40k miniature with milli", "Synthesizing Gold Nanoparticles", "creating an AI Dog", "petting a cat", "carrying a soccer ball", "playing football by themself", "balancing a tennis racket on their nose", "digging down in Minecraft", "catching a shiny Pikachu", "checking their Hearthstone Bot", "solving time travel", "watching Gilmore Girls", "computing the eigenvalue of the inverse Mobius strip", "watching Little House on the Prairie", "getting shot by an auto-turret in Rust", "trying to think of a capstone idea", "being watched","taking 3 mayo jars"]) + "." #shortkey += 1 # increments the shortkey else: description = description +textcolour+ "(\S)Oh look, its the " \ + choice(["decaying ", "broken ", "bloodied ", "mutilated ", "scrambled ", "soulless ", "degraded ", "decrepit ", "blank empty stare of the ", "mouldy "]) \ + choice(["corpse of ", "body of ", "cadaver of ", "hunk of meat that used to be ", "remains of ", "chalk outline of ", "snack that used to be "]) \ + "" + str(shortkey) + "" + deadpersoncolour + "" + enemy.name + "" +textcolour+ "." #shortkey += 1 # increments the shortkey # if self.interact: # for item in self.interact: # description = description + "/" + item.info + "/\n" if not self.ENEMY and not self.items: # if there's nothing in the location description += textcolour + " (\S)There isn't a whole lot to see." if GAMESETTINGS['HardcoreMode']: # if in hardcore mode it skips the auto descriptions pass else: # --- Auto Surrounding Descriptions --- # -- Finding the locations around current location -- location = self.location # gets coordinates tuple letterdirections = ['u', 'd', 'f', 'b', 'l', 'r'] # letter based list of directions to check against walls lettersthere = "" tupledirections = [(0,0,1,0), (0,0,-1,0), (0,1,0,0), (0,-1,0,0), (-1,0,0,0), (1,0,0,0)] # tuple based list of directions to add to current location surroundings = [""] * 6 # Name storage, defaulted to none. Order of: Left, right, Front, Back, Up, Down i = 0 # Counter for direction indexing for direction in letterdirections: # Looping through all the directions if direction not in self.walls: # seeing if the way you can go is in the walls # Gets tuple of requested adjacent spot by adding the direction in the right order dx, dy, dz, dim = tuple(map(operator.add,location,tupledirections[i])) if MAPS[dx][dy][dz][dim]: # if the map location exists surroundings[i] = MAPS[dx][dy][dz][dim].name # store the name into the surroundings variable lettersthere += direction + "," i += 1 # - Finding Interriors Via Links - if self.links: # if there's a link and therefore it links to an interrior for link in self.links: # loping through all links if link[4] != self.location[3]: # if you're not in the same dimension as the linked dimension displays the dimension name surroundings[letterdirections.index(link[0])] = DIMENSIONS[link[4]] lettersthere += link[0] + "," else: # this magic line replaces the surrounding name with the link name of the area surroundings[letterdirections.index(link[0])] = MAPS[link[1]][link[2]][link[3]][link[4]].name lettersthere += link[0] + "," # -- Reading out the Surroundings -- # TODO Add discovery mechanic where it prints locations as you see them # - Short Description - worddirections = ['[U] ','[D] ','[F] ','[B] ','[L] ','[R] '] description += "(\S) (\S)There are " + str(6 - surroundings.count("")) + " obvious exits: (\S)" # old description having letters in there #description += "(\S) (\S)There are " + str(6 - surroundings.count(None)) + " obvious exits: " + lettersthere + "(\S)" # TODO for even shorter/harder list only directions # - Aligning the Words by adding spaces - maxnamelength = max(len(x) for x in surroundings) for i in range(6): # Equalization of the spacing to the max spacing surroundings[i] = surroundings[i] + " "*( maxnamelength - len(surroundings[i]) ) for i in range(6): # use index to reference direction if surroundings[i].strip(): # if the direction is seen in there and it's not empty description += worddirections[i] +mapcolour+ surroundings[i] +textcolour+ "\t" # print the word direction + name if worddirections[i] == '[U] ' and not surroundings[i].strip() and surroundings[i+1].strip(): # if there's no U but D description += "[U] "+ " "*(maxnamelength) + "\t" # adding correct spacing elif worddirections[i] == '[U] ' and surroundings[i].strip() and not surroundings[i+1].strip(): # if there's U but no D description += "[D] (\S) " #adding newline if worddirections[i] == '[F] ' and not surroundings[i].strip() and surroundings[i+1].strip(): # if there's no F but B description += "[F] "+" "*(maxnamelength) + "\t" # adding correct spacing elif worddirections[i] == '[F] ' and surroundings[i].strip() and not surroundings[i+1].strip(): # if there's F but no B description += "[B] (\S) " #adding newline if (worddirections[i] == '[L] ') and (not surroundings[i].strip()) and surroundings[i+1].strip(): # if there's no L but R # Makes a hidden peroid there so spacing is correct because I'm a monkey and can't figure it out what's wrong #description += Style.DIM+backcolour+ "." +Style.RESET_ALL+textcolour+ " " # I DON"T KNOW WHY THIS WORKS BUT ITS 2:21 AM DAY OF RELEASE SO WERE GOIN WITH IT description += "[L] "+" "*(maxnamelength) + "\t" # adding correct spacing elif worddirections[i] == '[L] ' and surroundings[i].strip() and not surroundings[i+1].strip(): # if there's L but no R description += "[R] (\S) " #adding newline elif worddirections[i] in ['[D] ','[B] '] and surroundings[i].strip(): # If there's all spaces description += " (\S) " #TODO Add wordy description if self.travelled: # if haven't been here before printT(description, 72, 0.75) #prints the final descripton self.travelled = 0 else: # normal fast print printT(description, 72, 0) # prints final description fast
def Move(direction,DIRECTIONWORDS,DIRECTIONSHORTCUTS): global MAPS global PLAYER global ENEMIES global INTERACT global ITEMS bf = ENEMIES['brendan fallon'] x = PLAYER.location[0] y = PLAYER.location[1] z = PLAYER.location[2] dim = PLAYER.location[3] currentplace = MAPS[x][y][z][dim] # Saving your current map location to a variable place = 0 # Direction parsing and redefining so that it matches walls if direction in DIRECTIONSHORTCUTS: pass # Don't need to parse direction if a shortcut elif direction == 'up': direction = 'u' elif direction == 'down': direction = 'd' elif direction in ['front', 'forward', 'ahead','west']: direction = 'f' elif direction in ['back', 'backward','east']: direction = 'b' elif direction in ['left', 'south']: direction = 'l' elif direction in ['right','north']: direction = 'r' else: # if the direction isn't in the accepted directions printT("You stumble over not sure where you were trying to go. Your brain doesn't understand " + direction + ".") return if direction not in currentplace.walls: # TODO Make these direction additions transformations (matrix transforms) that add to a tuple # These are the direction parsing so it moves the desired coordinates if direction == 'u': z += 1 elif direction == 'd': z -= 1 elif direction == 'f': y += 1 elif direction == 'b': y -= 1 elif direction == 'l': x -= 1 elif direction == 'r': x += 1 else: # This is just a catch, shouldn't happen printT("You stumble over not sure where you were trying to go. Something went wrong in your brain") return # TODO This is where links come in which direct into interriors place = MAPS[x][y][z][dim] # place is new location requested # Interrior Links: If the spot has a link might be teliported/moved to that place for link in currentplace.links: # if there is links in it it will loop through if direction in link: # Searching all the links to see if any links refer to that direction if dim == 0 and link[4] != 0: printT("You go inside " +mapcolour+ DIMENSIONS[link[4]] +textcolour+ ".") # When going to non-Overworld it says going inside elif dim != 0 and link[4] == 0: # When going to overworld from non printT("You go outside.") elif dim != link[4]: # Leaving one interior and entering another printT("You leave " +mapcolour+ DIMENSIONS[dim] +textcolour+ " and enter " +mapcolour+ DIMENSIONS[link[4]] +textcolour+ ".") x = link[1] y = link[2] z = link[3] dim = link[4] place = MAPS[x][y][z][dim] # Overwrites place with the link location if place: PLAYER.location[0] = x PLAYER.location[1] = y PLAYER.location[2] = z PLAYER.location[3] = dim bfchance = 0.003 if PLAYER.inv['body'] == ITEMS['tony hawk shirt']: bfchance += 0.007 #bfchance += 0.50 # TODO Remove this before final build if bf.location != (None,None,None,None): MAPS[bf.location[0]][bf.location[1]][bf.location[2]][bf.location[3]].removeEnemy(bf) if random() <= bfchance: printT(" (\S)You see A " +wincolour+ "BRENDAN FALLON" +textcolour +".") MAPS[x][y][z][dim].placeEnemy(bf) # AsciiArt.Hero() # TODO Enable once Dynamic Ascii Art place.search(MAPS, DIMENSIONS,GAMESETTINGS) # searches and prints the place return place # idk why but this returns place and I'm keeping it here so yeah else: PLAYER.location[0] = currentplace.location[0] PLAYER.location[1] = currentplace.location[1] PLAYER.location[2] = currentplace.location[2] PLAYER.location[3] = currentplace.location[3] printT(" (\S)Your body " +losecolour+ "can't" +textcolour+ " go that way! (\S)") return currentplace
def StartScreen(): # These are all the global dictionaries/objects in the game. Anywhere where a loadgame happens you need all the global variables global PLAYER # The main character. player is an object instance of class character. global ITEMS # All the items. This a dictionary of objects of class equipment keyed by their lowcase equipment name (item.name). Remember the lowercase, may trip you up if referencing upercase version in the file. global MAPS # All the locations. A tuple of objects of class Map inxed by there x,y,z coordinate (MAPS[x][y][z]) global INTERACT # All the interactables (stationary things that need something). This a dictionary of objects of class Interact keyed by their lowcase name (interact.name). Remember the lowercase, may trip you up if referencing upercase version in the file. global QUESTS # Quest statuses. This is a dictionary of flags (1 or 0) for the status of the quest keyed by quest name. global ENEMIES # All the npcs. This a dictionary of objects of class Enemy keyed by their lowcase equipment name (item.name.lower()). Remember the lowercase, may trip you up if referencing upercase version in the file. global GAMEINFO # Miscellaneous game info. Dictionary of all sorts of variables global GAMESETTINGS # The game settings that are saved in the game # global keyword makes the variables inside the function reference the correct global scope variable when assigned in the function. # If not assignment within the function may lead to changes only in the local scope print(textcolour) # This sets all text color #print backgroundcolour # This sets the background colour #print weirdback if GAMEINFO['devmode']: pass # If in dev mode do nothing and skip intro # The pass statement in Python is used when a statement is required syntactically but you do not want code to execute. else: # If no Dev Mode do the blip intro print(CLEARSCREEN) audiopath = os.path.join(os.getcwd(), "MediaAssets","","EFXstartup.mp3") #points to the eddited star wars theme playsound.playsound(audiopath, False) # plays the startup sound with 'multi-threading' print(" " + red + "A" + textcolour + "____ ________") print(" /_ H|\_____ \ ") print(" | O| ___| |") print(" | L| /___ <") print(" | L| ___\ |") print(" | Y| /W O O D|") print(" |___|/________/") print(" " + red + "Production." + textcolour + "") time.sleep(3) # Delay for intro sound print(CLEARSCREEN) startmenu = True # startmenu is the variable that keeps you in the startmenu screen loop if GAMEINFO['devmode']: # If in DevMode it skips the loading screen startmenu = False # turning off loading screen while startmenu: print(" ___________ __________.__") print(" \_ _____/ _ _____ \______ \ |__ ___.__. ______") print(" | __)_ / \ / ___ > | ___/ | \ | |/ ___/") print(" | \ | \/ /_/ / | | | \___ |\___ \ ") print(" /_______ /___| /\___ / |____| |___| / ____/____ >") print(" \/ \//_____/ " + red + "TEXT ADVENTURE" + textcolour +" \/\/ \/ ") #print " Now with colour!" print(" Version " +str(GAMEINFO['versionname'])) print(" Release Date: " + GAMEINFO['releasedate'] + " \n\n") print("Play New Game[P] Load Game[L] Settings[S] Disclaimers[D] Exit[E]") choice = input('Choose what you want to do: ').lower() # Play new Game if choice in ['p', 'play new game','play']: startmenu = False print(CLEARSCREEN) # Loading Screen and Game # TODO Maybe add this loading screen to CreativeMode so you can load in-game elif choice in ['l', 'load game','load', 'loadgame']: loadscreen = True print(CLEARSCREEN) while loadscreen: print("Load Game\n") # print os.listdir(path) # Gives a list of all files in the directory # This Gets and save files in the cache and stores in lists loadnumber = 0 # The loadfile display incrementer loadnumberlist = [] # list to store loadnumbers loadnamelist = [] # list to store loadname # Iterates through display string which has all files in the directory for file in os.listdir(GAMEINFO['savepath']): filepath = os.path.join(GAMEINFO['savepath'], file) # gets exact file path so can check size # TODO Nice to have would be showing game playtime or progress if file == "SaveFile basegame.plp" or os.stat(filepath).st_size == 0: # ignores the basegame or the file is empty! next # Searches for the keyword in the files of the savefile directory elif fnmatch.fnmatch(file, 'SaveFile*'): # looks for files that have SaveFile in the Name loadnumber += 1 # Itterates the loadnumber for the next one # Saving load number as string so can compare Lchoice string later loadnumberlist.append(str(loadnumber)) # For some reason strip is being dumb and have to strip "SaveFile" and the " " separately loadnamelist.append(file.lstrip("SaveFile").strip().rstrip("plp").rstrip(".")) # strip is dumb and will keep stripping things if it contains the letters so needs to be done in steps # see https://stackoverflow.com/questions/46222645/string-rstrip-is-removing-extra-characters # Displays the save files was numbered list starting from 1 for i in range(loadnumber): print("[" + loadnumberlist[i] + "]" + loadnamelist[i]) print("[B]Back\n") Lchoice = input('Choose which game you want to load: ') if Lchoice in ['b', 'back', 'leave', 'exit']: # if you choose back the loop exits loadscreen = False elif Lchoice in loadnamelist: # if user enters loadname loadscreen = False startmenu = False MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS = load_game(Lchoice) # loads in the savefile global variables GAMEINFO['loadgame'] = 1 GAMEINFO['timestart'] = time.time() # reset local variable starttime to current time return MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS # Sets this loadgame flag so the rest of setup is skipped and goes to main print(CLEARSCREEN) elif Lchoice in loadnumberlist: # if user enters loadnumber has to lookup the load name loadscreen = False startmenu = False MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS = load_game(loadnamelist[int(Lchoice)-1]) # converts loadnumber to loadgame index GAMEINFO['timestart'] = time.time() # reset local variable starttime to current time GAMEINFO['loadgame'] = 1 return MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS # Sets this flag so the rest of setup is skipped and goes to main print(CLEARSCREEN) else: print(CLEARSCREEN) printT(" (\S)"+losecolour+"Please choose one of the options." + textcolour+"") # Setting Screen elif choice in ['s', 'settings','setting']: settingscreen = True print(CLEARSCREEN) while(settingscreen): # TODO Make a DEV mode that disables error catching and enables creative print("Settings\n*These may change if you load a previous game\n\n") print('[0]Disable Opening: ' + str(GAMESETTINGS['DisableOpening'])) print('[1]Speed Run: ' + str(GAMESETTINGS['SpeedRun'])) print('[2]Hardcore Mode: ' + str(GAMESETTINGS['HardcoreMode'])) # print '[3]Turn Colour Off: ' + str(GAMESETTINGS['ColourOff']) + " (Must restart client and start new game to take effect)" print('[B]Back\n ') Schoice = input('Choose which settings you want to toggle: ').lower() if Schoice in ['b', 'back', 'leave', 'exit']: print(CLEARSCREEN) settingscreen = False elif Schoice =='0': print(CLEARSCREEN) # Have to make sure the values toggle to 0 and 1 not true and false for saving GAMESETTINGS['DisableOpening'] = int(not(GAMESETTINGS['DisableOpening'])) # print "Hi I'm a dog" elif Schoice =='1': print(CLEARSCREEN) GAMESETTINGS['SpeedRun'] = int(not(GAMESETTINGS['SpeedRun'])) elif Schoice =='2': print(CLEARSCREEN) GAMESETTINGS['HardcoreMode'] = int(not(GAMESETTINGS['HardcoreMode'])) # elif Schoice == '3': # print CLEARSCREEN # GAMESETTINGS['ColourOff'] = int(not (GAMESETTINGS['ColourOff'])) elif Schoice == '/420e69': # Character that enables DevMode print(CLEARSCREEN) GAMEINFO['devmode'] = int(not(GAMEINFO['devmode'])) # Prints throw-off style text while still giving the stat print("\nPlease choose " + str(GAMEINFO['devmode']) + "one of the options.") else: print(CLEARSCREEN) printT(" (\S)"+losecolour+"Please choose one of the options." + textcolour+"") # Saving Settings Once out of the screen, These setting should be readable and changeable by a person settingpath = os.path.join(GAMEINFO['datapath'], "settings.ini") f = open(settingpath, "w+") for setting in GAMESETTINGS: # TODO Before release uncomment this line so DevMode isn't saved. DevMode in setting file is not for RELEASE #if setting == "DevMode": continue f.write(setting + "\n" + str(GAMESETTINGS[setting]) + "\n") f.close() # Disclaimer screen elif choice in ['d', 'disclaimers','disclaimer']: print(CLEARSCREEN) printT("Disclaimer (\S) (\S) This game is difficult, requires reading and focus on every piece of text, " "and awareness of small details in order to advance the game. We feel here that we're trying to " "provide an experience that's challenging but rewarding, not punishing. That being said we are " "always open to feedback.(\S) This game is a work in progress and there may be bugs. We do our best " "to avoid, catch, and fix errors promptly. If you do come across one however please submit them to " "our bug response form: https://goo.gl/forms/Jo6P7oMj86OiLvE63 (\S) This is a work of fiction. " "Names, characters, businesses, places, events, locales, and incidents are either the products of " "the author's imagination or used in a fictitious manner. Any resemblance to actual persons, living " "or dead, or actual events is purely coincidental. By playing this game you give up the right to" " any information or files uploaded to the developers for benevolent development of the game.",72,0) input("\nHit enter to continue") print(CLEARSCREEN) # Exiting elif choice in ['e', 'exit','leave']: exit() else: print(CLEARSCREEN) printT(" (\S)"+losecolour+"Please choose one of the starting options."+textcolour+"") return MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS
def Eat(Item): # Item is a string not an object global PLAYER global ITEMS global MAPS x = PLAYER.location[0] y = PLAYER.location[1] z = PLAYER.location[2] dim = PLAYER.location[3] if Item in ITEMS and list(ITEMS[Item].location) == PLAYER.location and not(GAMESETTINGS['HardcoreMode']): if Item == "jar of peanut butter" and (PLAYER.name in ["Mitchell Lemieux","Erik Reimers"]): printT("Oh NO! You're " + PLAYER.name + " ! Don't you remember? YOU'RE" +losecolour+" ALERGIC TO PEANUT BUTTER" +textcolour+"! You "+losecolour+"DIE" +textcolour+" due to your lack of responsibility.") PLAYER.health = 0 PLAYER.alive = False elif ITEMS[Item].health: PLAYER.health = PLAYER.health + ITEMS[Item].health PLAYER.health = min(PLAYER.maxhealth, PLAYER.health) #made the minimum of your added health and food so players health doesn't clip over PLAYER.health = max(PLAYER.health, 0) # prevents clipping bellow 0 printT(" (\S)You've eaten the " + ITEMS[Item].colouredname + ".") # TODO Reimplement health/food indicators with words if GAMEINFO['devmode']: printT(" (\S)HEALTH: "+ str(PLAYER.health)+ " (\S)") # if in DevMode can see stats if PLAYER.health == 0: PLAYER.alive = False ITEMS[Item].location = (None, None, None) #used to clear the item location if ITEMS[Item] == PLAYER.inv[ITEMS[Item].worn]: PLAYER.inv[ITEMS[Item].worn] = PLAYER.emptyinv[ITEMS[Item].worn] ITEMS[Item].location = (None, None, None) PLAYER.updateStats() printT("The " + ITEMS[Item].colouredname + " has been removed from your inventory. (\S)") else: MAPS[x][y][z][dim].removeItem(ITEMS[Item]) else: printT("You can't eat a " + ITEMS[Item].colouredname + "!") # other acceptations for weird requests elif Item in INTERACT and list(INTERACT[Item].location) == PLAYER.location: # Interacts printT("Hmm... You don't think a " + str(INTERACT[Item].colouredname) + " would taste good. Let alone be edible.") elif Item in ENEMIES and (list(ENEMIES[Item].location) == PLAYER.location): # If you attempt to eat someone if (ENEMIES[Item].alive): printT("You attempt to eat " + ENEMIES[Item].colouredname + "'s arm...(\S) (\S)They pull away ask you to politely 'Not'.") else: printT("OMG, WHAT'S WRONG WITH YOU. (\S)I know you're hungry but please find a more vegan option.") else: printT(" (\S)You can't find a " +itemcolour+ Item +textcolour+ " around here. Maybe it's your hungover brain.")
def Inspect(Item): #Item is the inspect item string not an object global MAPS global ITEMS global PLAYER global INTERACT x = PLAYER.location[0] y = PLAYER.location[1] z = PLAYER.location[2] dim = PLAYER.location[3] #If item in location if Item in ITEMS and list(ITEMS[Item].location) == PLAYER.location: #this is for item = equipment printT("" + itemcolour+ ITEMS[Item].colouredname.upper() +textcolour + "",72,0) printT(ITEMS[Item].info,72,0) # fast version for reading things ITEMS[Item].quest = True # sets the quest/inspected flag to true # TODO re-implement inspecting item with words instead of numbers deltaATK = ITEMS[Item].stats[0]-PLAYER.inv[ITEMS[Item].worn].stats[0] # " more powerful" deltaDEF = ITEMS[Item].stats[1]-PLAYER.inv[ITEMS[Item].worn].stats[1] # " better defended" deltaSPD = ITEMS[Item].stats[2]-PLAYER.inv[ITEMS[Item].worn].stats[2] # " faster" descriptornumbers = [5,10,25,50,100,1000] descriptors = ["Slightly", lightblack+"A good bit", lightblue+"A significant amount",red+"A very large amount", lightwhite+"A very very large amount", lightyellow +"AN UNGODLY amount"] #5 = a bit #10 = a lot #25 = a significant amount #50 = A TON #100 = a very large amount #1000 = AN UNGODLY amount if deltaATK > 4 or deltaDEF > 4 or deltaSPD > 4: # if any of these are different desc = " (\S)This looks like it would make me: (\S)" for i in range(len(descriptors)): # loops through descriptors if descriptornumbers[i] > deltaATK and deltaATK > 4: desc += descriptors[i-1] +textcolour+ " more powerful. (\S)" break for i in range(len(descriptors)): # loops through descriptors if descriptornumbers[i] > deltaDEF and deltaDEF > 4: desc += descriptors[i-1] +textcolour+ " better defended. (\S)" break for i in range(len(descriptors)): # loops through descriptors if descriptornumbers[i] > deltaSPD and deltaSPD > 4: desc += descriptors[i-1] +textcolour+ " faster. (\S)" break printT(desc) if GAMEINFO['devmode']: # If in devmode can see the stats printT("ATK : " + str(ITEMS[Item].stats[0]) + " " + "("+str(ITEMS[Item].stats[0]-PLAYER.inv[ITEMS[Item].worn].stats[0])+")") printT("DEF : " + str(ITEMS[Item].stats[1]) + " " + "("+str(ITEMS[Item].stats[1]-PLAYER.inv[ITEMS[Item].worn].stats[1])+")") printT("SPD : " + str(ITEMS[Item].stats[2]) + " " + "("+str(ITEMS[Item].stats[2]-PLAYER.inv[ITEMS[Item].worn].stats[2])+")") printT("WORN: " + str(ITEMS[Item].worn).upper()) printT("QUEST Flag: " + str(ITEMS[Item].quest)) if ITEMS[Item].health: #if edible it shows that health stat plus what your final health would be if eaten printT( "Eaten Health: " + str(ITEMS[Item].health) + " (\S)") #+ str(ITEMS[Item].health) + " (" + str(min(100,PLAYER.health + ITEMS[Item].health))+")" +"\n" else: print("") # If the entered item is an intractable and is at that location elif Item in INTERACT and list(INTERACT[Item].location) == PLAYER.location: # this is for item = interactable # TODO Have Interactables be able to use lists (to drop multiple things), tuples(to place unique objects) if INTERACT[Item].need and (PLAYER.inv[ITEMS[INTERACT[Item].need].worn]==ITEMS[INTERACT[Item].need] or ITEMS[INTERACT[Item].need] in MAPS[x][y][z][dim].items): #if you're wearing item.need or it's on the ground the interactable needs worn on your body if PLAYER.inv[ITEMS[INTERACT[Item].need].worn]==ITEMS[INTERACT[Item].need]: # if in the players hand PLAYER.inv[ITEMS[INTERACT[Item].need].worn] = PLAYER.emptyinv[ITEMS[INTERACT[Item].need].worn] elif ITEMS[INTERACT[Item].need] in MAPS[x][y][z][dim].items: # if around the area MAPS[x][y][z][dim].removeItem(ITEMS[INTERACT[Item].need]) ITEMS[INTERACT[Item].need].location = (None,None,None,None) INTERACT[Item].quest = True # this turns on the quest flag for the interactable once interacted with if you have the item printT("" +interactcolour+ INTERACT[Item].colouredname.upper() +textcolour+ "" ,72,0) # Due to the upper it removes the colour printT(INTERACT[Item].Sinfo + "(\S)",72,0) # special slow version PLAYER.updateStats() # TODO stats should automatically update whenver player state is changed ITEMS[INTERACT[Item].need].location=(None,None,None) # Brendan added this, used to clear the item location if INTERACT[Item].drop: INTERACT[Item].drop_objects(Item,x,y,z,dim,MAPS,ITEMS,INTERACT,ENEMIES) # drops the proper object elif INTERACT[Item].need == None or INTERACT[Item].need == "": # Has no needed Items (I.E. it's a quest interface or a vendor or a trigger) INTERACT[Item].quest = True # this turns on the quest flag so it can trigger quest events printT("" +interactcolour+ INTERACT[Item].colouredname.upper() +textcolour+ "" ,72,0) # Due to the upper it removes the colour printT(INTERACT[Item].info,72,0) printT(INTERACT[Item].Sinfo,72,0) if INTERACT[Item].drop: INTERACT[Item].drop_objects(Item, x, y, z, dim, MAPS, ITEMS, INTERACT, ENEMIES) else: printT("" +interactcolour+ INTERACT[Item].colouredname.upper() +textcolour+ "" ,72,0) # Due to the upper it removes the colour printT(INTERACT[Item].info,72,0.1) #fast version if GAMEINFO['devmode']: # If in devmode can see the stats/quest of enemies printT("NEED : " + str(INTERACT[Item].need)) printT("DROP : " + str(INTERACT[Item].drop)) printT("QUESTFlag : " + str(INTERACT[Item].quest)) printT("Aesthetic : " + str(INTERACT[Item].aesthetic)) if INTERACT[Item].aesthetic and not(GAMESETTINGS['HardcoreMode']): # if it's aesthetic and not in hardcore mode printT("This doesn't look very useful.") # other acceptations for weird requests # If you try to inspect a person elif Item in ENEMIES and ((list(ENEMIES[Item].location) == PLAYER.location)) and (ENEMIES[Item].alive): printT(" (\S)It's rude to stare at people!") else: printT(" (\S)You can't find " + Item + " around here. Maybe it's your hungover brain.")
def Stats(): global PLAYER if PLAYER.health > 99: printT("You're in perfect health.") elif PLAYER.health > 90: printT("You feel really great!") elif PLAYER.health > 80: printT("You feel a little banged up but not too bad.") elif PLAYER.health > 60: printT("You're pretty badly beat up but still kicking.") elif PLAYER.health > 40: printT("You're very injured. Probably a lot of broken bones. Should get that checked out.") elif PLAYER.health > 20:printT("You're EXTREMELY injured. It's a wonder you can even walk.") elif PLAYER.health > 10: printT("You're bleeding profusely and barely alive. Why are you not in a hospital?") elif PLAYER.health > 0:printT("You're on the verge of death, don't go towards the light.") if GAMEINFO['devmode']: # If in devmode can see the stats/quest of enemies printT("\nHEALTH: " + str(PLAYER.health)) printT("ATK: " + str(PLAYER.stats[0])) printT("DEF: " + str(PLAYER.stats[1])) printT("SPD: " + str(PLAYER.stats[2])+" (\S)")
def Talk(E): # E is a string not an object global ENEMIES global MAPS global PLAYER global ITEMS x = PLAYER.location[0] y = PLAYER.location[1] z = PLAYER.location[2] dim = PLAYER.location[3] if E in ENEMIES and (list(ENEMIES[E].location) == PLAYER.location) and (ENEMIES[E].alive): enemy = ENEMIES[E] if enemy.need and PLAYER.inv[ITEMS[enemy.need].worn]==ITEMS[enemy.need]and not enemy.quest: printT(enemy.colouredname + " took the " + ITEMS[enemy.need].colouredname+ ".") printT(enemy.Sinfo) # default print speed ITEMS[enemy.need].location = (None, None, None) # Brendan added this, used to clear the item location PLAYER.inv[ITEMS[enemy.need].worn] = PLAYER.emptyinv[ITEMS[enemy.need].worn] PLAYER.updateStats() enemy.quest = True if enemy.drop: MAPS[x][y][z][dim].placeItem(ITEMS[enemy.drop]) printT("You see a " + ITEMS[enemy.drop].colouredname +". (\S)") enemy.drop = None elif enemy.quest and enemy.drop: printT(enemy.Sinfo) MAPS[x][y][z][dim].placeItem(ITEMS[enemy.drop]) printT( "You see a " + ITEMS[enemy.drop].colouredname +". (\S)") enemy.drop = None elif enemy.quest: printT(enemy.Sinfo) else: printT(enemy.info) if enemy.aesthetic and not(GAMESETTINGS['HardcoreMode']): printT("They don't seem very helpful to you.") enemy.spoke = True if GAMEINFO['devmode']: # If in devmode can see the stats/quest of enemies printT("HEALTH: " + str(ENEMIES[E].health)) printT("ATK : " + str(ENEMIES[E].stats[0])) printT("DEF : " + str(ENEMIES[E].stats[1])) printT("SPD : " + str(ENEMIES[E].stats[2])) printT("NEED : " + str(ENEMIES[E].need)) printT("DROP : " + str(ENEMIES[E].drop)) printT("QUESTFlag : " + str(ENEMIES[E].quest)) printT("SPOKE : " + str(ENEMIES[E].spoke)) printT("Aesthetic : " + str(ENEMIES[E].aesthetic)) # other acceptations for weird requests elif E in INTERACT and list(INTERACT[E].location) == PLAYER.location: # Interacts printT("You talk at the " + str(INTERACT[E].colouredname) + ". Best conversation you've had in a while.") elif E in ITEMS and list(ITEMS[E].location) == PLAYER.location: # Items printT("You talk at the " + ITEMS[E].colouredname + ". Still better than the Student Wellness Centre person.") elif E in ENEMIES and list(ENEMIES[E].location) == PLAYER.location and not ENEMIES[E].alive: # Dead People printT("Most people don't believe in talking to the dead. But you try talking to " +deadpersoncolour+ ENEMIES[E].name +textcolour+ " anyways.") else: printT("(\S)" + personcolour + str(E) + textcolour + " doesn't appear to be here.")
def Attack(E): # E is a string not an object global ENEMIES global MAPS global PLAYER global ITEMS x = PLAYER.location[0] y = PLAYER.location[1] z = PLAYER.location[2] dim = PLAYER.location[3] CurrentPlace = MAPS[x][y][z][dim] if E in ENEMIES and (list(ENEMIES[E].location) == PLAYER.location) and (ENEMIES[E].alive): enemy = ENEMIES[E] #making it the object from the name bgchance = 0.01 if PLAYER.inv['head'] == ITEMS['helm of orin bearclaw']: bgchance += 0.10 if PLAYER.inv['body'] == ITEMS['big hits shirt']: bgchance += 0.05 if PLAYER.name == "Big Hits Twofer": # This is for testing big hits events bgchance = 20 if random() <= bgchance: #bigHits feature TODO have oblivion sound effects # AsciiArt.BigHits() # TODO Enable once Dynamic Ascii Art printT(" (\S)An oblivion gate opens and a " +lightmagenta+"purple faced hero" +textcolour +" in " +lightblack+"ebony armour" +wincolour+ " punches " +personcolour+ enemy.name +textcolour+ " to death.") printT(enemy.Dinfo) #slow version enemy.alive = False if enemy.drop: printT(" (\S)" +enemy.colouredname+ " dropped the " + ITEMS[enemy.drop].colouredname + ".") CurrentPlace.placeItem(ITEMS[enemy.drop]) else: Outcome = Combat(PLAYER,enemy) if Outcome: printT("You " +wincolour + "defeated " + enemy.colouredname + ". (\S)") printT(enemy.Dinfo) if enemy.drop: printT( enemy.colouredname + " dropped a " + ITEMS[enemy.drop].colouredname + ".") CurrentPlace.placeItem(ITEMS[enemy.drop]) else: printT("Oh no! " + enemy.colouredname + " " +losecolour + "defeated" + textcolour+ " you! (\S)You died, without ever finding your " +wincolour+"iron ring" + textcolour +".") # other acceptations for weird requests elif E in INTERACT and list(INTERACT[E].location) == PLAYER.location: # Interacts printT("You probably shouldn't attack the " + str(INTERACT[E].colouredname) + ". You might get in major trouble.") elif E in ITEMS and list(ITEMS[E].location) == PLAYER.location: # Items printT("You probably shouldn't attack the " + ITEMS[E].colouredname + " it might go badly.") elif E in ENEMIES and list(ENEMIES[E].location) == PLAYER.location and not ENEMIES[E].alive: # Dead People printT("Umm... Okay. You attack " +deadpersoncolour+ ENEMIES[E].name +textcolour+ " and they're still dead...") else: printT("(\S)" + personcolour+ str(E) + textcolour+ " doesn't appear to be here.")