From dafce480d10fdb6d0ed934e317df768cad77466e Mon Sep 17 00:00:00 2001 From: log Date: Tue, 24 Jan 2023 15:16:01 +0100 Subject: [PATCH] deleted log game --- .../avoid-checkpoint.py | 94 ++++--------------- 1 file changed, 16 insertions(+), 78 deletions(-) rename a-void.py => .ipynb_checkpoints/avoid-checkpoint.py (76%) diff --git a/a-void.py b/.ipynb_checkpoints/avoid-checkpoint.py similarity index 76% rename from a-void.py rename to .ipynb_checkpoints/avoid-checkpoint.py index 24353e0..ab441a3 100644 --- a/a-void.py +++ b/.ipynb_checkpoints/avoid-checkpoint.py @@ -11,11 +11,9 @@ import random import os from time import sleep import sys +import voidfunc rooms = ["room", "island", "bar"] -visited_rooms=[] -viewedthings=[] -current_room = "room" roomthings = {} roomthings["room"]={"bookstand": "To his right is a mahogany stand on which sit 26 books - on which, I should say, 26 books normally ought to sit, but, as always, a book is missing, a book with an inscription, '5', on its flap. Nothing about this stand, though, looks at all abnormal or out of proportion, no hint of a missing publication, no filing card or 'ghost', as librarians quaintly call it, no conspicuous gap or blank", @@ -89,66 +87,6 @@ class bcolors: 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(roomthings[current_room][thing]) - viewedthings.append(thing) - -def look(): - roomstring = ", a ".join(roomthings[current_room]) - delayPrint(f"Looking around this spot, you sight a {roomstring}") - -def portflip(): - 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(): - global current_room - sleep(1) - delayPrint(bcolors.RED + death[current_room] + 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 + intro[current_room]) - print("-"*79 + bcolors.ENDC) - sleep(1) - delayPrint(message[current_room]) - -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() - # Start of book # ------------------ @@ -194,10 +132,10 @@ print(bcolors.CYAN + "-"*80 + """) print("-"*80) sleep(1) -delayPrint("\n" + " "*40 + intro[current_room]) +voidfunc.delayPrint("\n" + " "*40 + intro[voidfunc.current_room]) print("-"*79 + bcolors.ENDC) sleep(1) -delayPrint(message[current_room]) +voidfunc.delayPrint(message[voidfunc.current_room]) while True: # Wait for user input @@ -205,27 +143,27 @@ while True: # End the game if all rooms have been explored if len(rooms) == 0: - gameover() + voidfunc.gameover() break # End the room if all items have been interacted with - if any(s not in viewedthings for s in roomthings[current_room]): + if any(s not in voidfunc.viewedthings for s in roomthings[voidfunc.current_room]): pass else: - nextroom() + voidfunc.nextroom(death,rooms,intro,message) # Do functions based on reply if "exit" in reply: - gameover() + voidfunc.gameover() break - elif "e" in reply or len(roomthings[current_room]) == 0: - nextroom() + elif "e" in reply or len(roomthings[voidfunc.current_room]) == 0: + voidfunc.nextroom(death,rooms,intro,message) elif "port" in reply and "flip" in reply: - portflip() - elif any(word in reply.split() for word in roomthings[current_room]): - word = next((s for s in reply.split() if s in roomthings[current_room]), None) - interact(word) - elif any(s in reply for s in ["look", "scan", "watch", "study", "spot", "spy", "analysis", "probing", "grill", current_room]): - look() + voidfunc.portflip(rooms) + elif any(word in reply.split() for word in roomthings[voidfunc.current_room]): + word = next((s for s in reply.split() if s in roomthings[voidfunc.current_room]), None) + voidfunc.interact(word, roomthings) + elif any(s in reply for s in ["look", "scan", "watch", "study", "spot", "spy", "analysis", "probing", "grill", voidfunc.current_room]): + voidfunc.look(roomthings, voidfunc.current_room) else: - delayPrint(defaultReply()) \ No newline at end of file + voidfunc.delayPrint(voidfunc.defaultReply()) \ No newline at end of file