-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstoryManager.py
51 lines (40 loc) · 1.24 KB
/
storyManager.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import json
from typing import List
class StoryManager:
currentPerson = ""
currentDialogID = ""
dialogs = {}
logs = {}
alreadyPlayedDialog: dict[str, List[str]] = {}
alreadyPlayedLog: dict[str, List[str]] = {}
def setup():
with open("assets/dialogs.json", "r") as dialogsFile:
StoryManager.dialogs = json.load(dialogsFile)
with open("assets/log.json", "r") as logFile:
StoryManager.logs = json.load(logFile)
def selectPerson(person: str):
if person not in StoryManager.dialogs:
print(f"\033[31mInvalid person id '{person}'\033[m")
return
StoryManager.currentPerson = person
def selectDialog(dialog: str):
StoryManager.currentDialogID = dialog
return
def getAvailableLogs():
return StoryManager.logs[StoryManager.currentPerson]
def selectLog(log: str):
for logObject in StoryManager.logs[StoryManager.currentPerson]:
if logObject["id"] != log:
continue
if logObject["dialog"] == "":
return
StoryManager.selectDialog(logObject["dialog"])
return
def getCurrentDialog():
for dialog in StoryManager.dialogs[StoryManager.currentPerson]:
if dialog["id"] != StoryManager.currentDialogID:
continue
return dialog
return {}
def getLog():
return StoryManager.logs[StoryManager.currentPerson]