-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdepy.py
More file actions
89 lines (71 loc) · 2.51 KB
/
depy.py
File metadata and controls
89 lines (71 loc) · 2.51 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import sqlite3
class VisualNovel(object):
def __init__(self, gamedata=None):
try:
conn = sqlite3.connect(gamedata)
self.c = conn.cursor()
self.c.execute("select * from games")
row = self.c.fetchone()
except:
print 'could not open database', gamedata
else:
if row:
self.name = row[1]
self.current_scene = row[2]
def get_scene(self, scene_ref):
return Scene(scene_ref, self.c)
def get_dialogue(self, dialogue_ref):
return Dialogue(dialogue_ref, self.c)
class Scene(object):
def __init__(self, scene_ref=None, c=None):
self.c = c
args = (scene_ref,)
self.c.execute("select * from Scenes where id=?", args)
row = self.c.fetchone()
self.setup_text = row[1]
self.location = Location(row[2], self.c)
self.initial_dialogue = Dialogue(row[3], self.c)
self.c.execute("select * from Actors_Scenes where sceneId=?", args)
rows = self.c.fetchall()
self.actors = []
for row in rows:
self.actors.append(Actor(row[2], self.c))
class Location(object):
def __init__(self, location_ref=None, c=None):
self.c = c
args = (location_ref,)
self.c.execute("select * from Locations where id=?", args)
row = self.c.fetchone()
self.name = row[1]
self.img_path = row[2]
class Dialogue(object):
def __init__(self, dialogue_ref=None, c=None):
self.c = c
args = (dialogue_ref,)
self.c.execute("select * from Dialogue where id=?", args)
row = self.c.fetchone()
self.actor = Actor(row[1], self.c)
self.text = row[2]
self.c.execute("select * from Options where dialogueId=?", args)
rows = self.c.fetchall()
self.options = []
for row in rows:
self.options.append(Option(row[3], row[2], row[4], row[5]))
class Option(object):
def __init__(self, text=None, display_text=None, outcome_type=None, outcome_ref=None):
self.text = text
self.display_text = display_text
self.outcome_type = outcome_type
self.outcome_ref = outcome_ref
class Actor(object):
def __init__(self, actor_ref=None, c=None):
self.c = c
args = (actor_ref,)
self.c.execute("select * from actors where id=?", args)
row = self.c.fetchone()
self.name = row[1]
class Outcome:
DIALOGUE = 0
SCENE = 1
FIGHT = 2
GAMEEND = 3