# A Void - Functions # by Gorgs Prc # # Adaptation to IF by log # ------------------ # Variables # ------------------ import random import os import sys import json from time import sleep global current_room global visited_rooms global viewedthings current_room = "room" visited_rooms=[] viewedthings=[] with open('voiddata.json', 'r') as f: voiddata = json.load(f) class bcolors: BLUE = '\033[94m' CYAN = '\033[96m' GREEN = '\033[92m' YELLOW = '\033[93m' RED = '\033[91m' MAGENTA = '\x1b[35m' ENDC = '\033[0m' BOLD = '\033[1m' UNDERLINE = '\033[4m' # Funtions # ------------------ def delayPrint(s): for c in s: sys.stdout.write(c) sys.stdout.flush() sleep(0.01) print("\n") sys.stdout.write(">") def interact(thing): print("") delayPrint(voiddata[current_room]["items"][thing]) viewedthings.append(thing) def look(): roomstring = ", a ".join(voiddata[current_room]["items"]) delayPrint(f"Looking around this spot, you sight a {roomstring}") def portflip(rooms): global current_room rooms.remove(current_room) current_room = "bar" rooms.append(current_room) delayPrint("""COMMANDANT (vigorously nodding): That's right, a port-flip! Any port-flip in a storm, what? Ha ha ha! BARMAN (as though in pain): I . . . don't .. . think . . . any . .. in .. . stock . . . COMMANDANT (jumping up off his stool): What, no port-flips! But only last month I had (laboriously counting out) 1, 2, no, 3 port-flips in this bar! BARMAN (almost inaudibly): But now . . . now . . . you can't. . . """) def defaultReply(): messages = ["You cannot do that", "What?", "That won't work"] return random.choice(messages) def nextroom(rooms): global current_room sleep(1) delayPrint(bcolors.RED + voiddata[current_room]["death"] + bcolors.ENDC) sleep(1) rooms.remove(current_room) if len(rooms) == 0: gameover() current_room = random.choice(rooms) print(bcolors.CYAN + "-"*79) sleep(1) delayPrint("\n" + " "*40 + voiddata[current_room]["intro"]) print("-"*79 + bcolors.ENDC) sleep(1) delayPrint(voiddata[current_room]["message"]) def gameover(): print(bcolors.RED + "-"*79 + "\n" + "-"*80 + "\n" + "-"*80 + "\n") sleep(1) print("\n" + " "*28 + " / \ / \ / \ ") print(" "*28 + "( f | i | n )") print(" "*28 + " \_/ \_/ \_/ " + "\n") sleep(1) print("-"*79 + "\n" + "-"*80 + "\n" + "-"*80 + "\n" + bcolors.ENDC) exit()