-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprinter.py
68 lines (53 loc) · 1.82 KB
/
printer.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# 22.07.52 Simle console printer
# Python = 3.9.7
import csv
from rich import print
import parser
dialogue = parser.Parser().parse(parser.choose_file())
moods = {
"calm": "🙂",
"yawning": "🥱",
"happy": "😀",
"sad": "🙁",
"cool": "😎",
"smart": "🤓",
"bored": "😒",
"scared": "😱",
"ashamed": "😳",
}
characters = {} # Персонажи в формате alias: (name, color)
with open('characters.csv', mode='r', encoding="utf-8") as csv_file:
# Загружаем персонажей из characters.csv
csv_reader = csv.DictReader(csv_file)
line_count = 0
for row in csv_reader:
if line_count > 0:
if row:
characters[row["alias"]] = row["name"], row["color"]
line_count += 1
csv_file.close()
opt_colors = ["red", "green", "cyan", "yellow"]
options = []
for h in dialogue["marks"]:
if h != "start":
print("["+opt_colors[options.index(h)%4]+']-'+h+'>')
for i in dialogue["marks"][h]:
if i["type"] == "line":
if i["author"] != "narrator":
print(moods[i["state"]]
if i["state"] in moods
else i["state"],
" [bold "+
(characters[i["author"]][1]
if i["author"] in characters
else "gray")+"]"+
(characters[i["author"]][0]
if i["author"] in characters
else i["author"]))
print(i["text"])
elif i["type"] == "menu":
print(":diamond_with_a_dot:", "[bold blue u]"+i["label"])
for opt in i["opts"]:
print("["+opt_colors[len(options)]+"]"+"• "+opt["text"])
options.append(opt["mark"])
print()