#!/usr/bin/python3 import sys import readline import random def setstuff(t, p="> "): global text, ps text = t ps = p center = (23 - text[0].count("\n")) // 2 print("\n" * center, text[0], "\n" * center) input("") def prompt(s="", p=0, param=[]): try: s = text[s] except: s = str(s) for i in range(len(param)): s = s.replace("<" + str(i) + ">", str(param[i])) print("\n" + s.strip("\n"), end="") if p == 0: p = ps if p != None: print() return input(p) turncounter = 0 oldname = "" needscream = False def playerlist(): return "\033[1;33m" + ", ".join(players) + "\033[m" def chooseother(): global needscream if turncounter != 2: return other = oldname while other == oldname: other = random.choice(players) needscream = other == players[0] return other def look(arg): global turncounter, oldname, name if not arg: prompt("look", None, [playerlist()]) prompt("phase", None, [["down", "toes", "up"][turncounter]]) return if turncounter != 2: oldname = "" elif oldname == "": oldname = name name = "" if arg[0] in target: arg[0] = arg[0][0] else: name = arg[0] if arg[0] in "at": try: name = arg[1] except IndexError: prompt("what", None) return name = name.strip().title() if turncounter == 1 and name and name not in players: players.append(name) for case in [ (name, 1, "feet", [name]), (arg[0] == "d", 0, "down", []), (arg[0] == "u", 2, "face", [oldname, chooseother()]) ]: if case[0]: if turncounter == case[1]: prompt(case[2], None, case[3]) turncounter = (case[1] + 1) % 3 else: prompt("fail", None) break def scream(arg): global needscream if needscream: prompt("actualscream", None) needscream = False else: prompt("randomscream", None) players = [ "you", "Waffle", "Icecream", "Lemonade", "Lionmeat", "Drpepper" ] words = [ "help", "quit", "look", "scream" ] actions = { "h" : (lambda arg: prompt("help", None)), "q" : (lambda arg: sys.exit("\n" + text["quad"])), "l" : look, "s" : scream } target = [ "down", "at", "toes", "up", "d", "a", "t", "u" ] def main(): setstuff(text, "\033[1;32m> \033[m") prompt("look", None, [playerlist()]) while True: action = prompt("empty").strip().lower() cmd = action.split() if not cmd: continue if cmd[0] in words: cmd[0] = cmd[0][0] if needscream and cmd[0] not in "hqs": prompt("needscream", None) continue try: cmd[0] = actions[cmd[0]] except KeyError: prompt("define", None, [cmd[0]]) cmd[0] = actions["h"] cmd[0](cmd[1:]) text = { 0 : """ __\033[1;34m@\033[m __--'' <-'' \033[1;34mAAAAA\033[m \033[1;34m@\033[m--__ \033[1;34m`@\033[m ^^ \033[1;31m_\033[m``--__ ^^ / | \033[1;31m/ )\033[m ``--__ / | / | \033[1;31m\_ C R E A M\033[m ``--__/ | / | \033[1;31m\ _____\033[m /``-+__ \033[1;34m@\033[m | \033[1;31m(_/ ( | )\033[m / | `>\033[1;34m@\033[m | \033[1;31m| O E S\033[m / | / | \033[1;31m|\033[m / | / | \033[1;31m_|_\033[m / \033[5;32mpress\033[m | / | \033[1;35mt h_e _ _\033[m / \033[5;32menter\033[m vv \033[1;34m@\033[m \033[1;35m|_)|_)/ _\033[m / \033[1;34m,@\033[m \033[1;35m| \| \_/\033[m / \033[1;34mAAAAA\033[m / \033[1;34m@\033[m """, "help" : """ Possible commands: \033[1;31ml\033[mook [\033[1;31md\033[mown|\033[1;31ma\033[mt|\033[1;31mu\033[mp] \033[1;31mh\033[melp \033[1;31mq\033[muit \033[1;31ms\033[mcream """, "quad" : """You leave to run around the quad...""", "look" : """You are outside. A game of Scream Toes is going on. In fact, you're in it.\n""" + """The people playing are <0>.""", "down" : """You look down.""", "fail" : """You can't look there, it's the wrong turn.""", "what" : """Look at what?""", "feet" : """You look at <0>'s feet.""", "face" : """You look up at <0>, who is looking at <1>.""", "phase" : """It is <0>phase.""", "define" : """I don't know, define <0>.""", "randomscream": """You start screaming. People look at you strangely.\n""" + """Eventually you run out of breath and stop.""", "actualscream": """AAAAAAAAAAAAHHH!!!""", "needscream" : """Everyone is waiting for you to scream...""", "empty" : "" } if __name__ == "__main__": main() #re.sub("\033[^m]*m", "", text[0])