Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- import glob
- import textwrap
- import os
- import shutil
- class Encounter:
- def __init__(self, desc="Fuck", nextEnc=(None, None)):
- self.desc = desc
- self.nextEnc = nextEnc
- def setEncounter(self, encs = []): #sadly this is the part you do manually
- if encs:
- self.nextEnc = encs
- else:
- self.nextEnc = (None, None)
- #===
- def openFile(filename):
- with open(filename, "r") as f:
- return f.read()
- def getEncs(filename):
- with open(filename, "r") as f:
- fil = f.read()
- lis = re.findall("\$[0-9]*\.le", fil)
- lis = [ (int(x.replace("$",'').replace(".le",'')) - 1) for x in lis ]
- return lis
- def moveSomewhere(currentEnc):
- try: userChoice = int(input(">"))
- except: userChoice = 1
- return currentEnc.nextEnc[userChoice-1]
- def init():
- allEncounters = []
- descriptions = [f for f in glob.glob("*.le")]
- descriptions.sort()
- for x in descriptions:
- allEncounters.append(Encounter(desc = openFile(x)))
- for y,x in enumerate(allEncounters):
- tup = getEncs(descriptions[y])
- if tup == []:
- pass
- else:
- print([x for x in tup])
- x.setEncounter( [allEncounters[x] for x in tup] )
- return allEncounters
- def getText(inp):
- wordList = inp.split('\n')
- realWordList = []
- (columns, lines) = shutil.get_terminal_size()
- wrapper = textwrap.TextWrapper(width=columns - 5, replace_whitespace=False, drop_whitespace=False)
- for x in wordList:
- if x == '':
- realWordList.append('')
- else:
- realWordList.extend(wrapper.wrap(text=x))
- lineCounter = 0
- os.system("clear")
- for x in realWordList:
- if lineCounter >= lines - 1:
- lineCounter = 0
- input("press any key to cont")
- os.system("clear")
- else:
- print(x)
- lineCounter += 1
- if __name__ == "__main__":
- allEncounters = init()
- enc = allEncounters[0]
- while enc:
- getText(enc.desc)
- if enc.nextEnc == (None, None):
- enc = None
- else:
- enc = moveSomewhere(enc)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement