forked from mph12e/Paperless-DandD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.py
173 lines (162 loc) · 6.83 KB
/
db.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import sqlite3
class DND_DB:
def __init__(self, name = "dnd35.db"):
db = sqlite3.connect(name)
self.cursor = db.cursor()
def monsters(self, monName):
monName = monName.title()
print()
if (monName == "Aberration" or monName == "Animal" or monName == "Celestial" or
monName == "Construct" or monName == "Dragon" or monName == "Elemental" or
monName == "Fey" or monName == "Fiend" or monName == "Giant" or monName == "Humanoid" or
monName == "Magical Beast" or monName == "Monstrous Humanoid" or monName == "Ooze" or
monName == "Outsider" or monName == "Plant" or monName == "Undead" or monName == "Vermin"):
print(monName + " is a monster type, do you want monsters of that type listed? (y/n)")
yes = input()
if (yes.lower() == "y" or yes.lower() == "yes"):
monsterByType(monName)
else:
attributes = ["id", "family", "name", "altname", "size", "type", "descriptor", "hit_dice",
"initiative", "speed", "armor_class", "base_attack", "grapple", "attack", "full_attack",
"space", "reach", "special_attacks", "special_qualities", "saves", "abilities", "skills",
"bonus_feats", "feats", "epic_feats", "environment", "organization", "challenge_rating",
"treasure", "alignment", "advancement", "level_adjustment", "special_abilities",
"stat_block", "full_text", "reference"]
format = "SELECT * FROM monster WHERE (name='" + monName + "' OR altname='" + monName + "')"
self.cursor.execute(format)
if (len(self.cursor.fetchall()) == 0):
print("You did not enter a valid monster name.")
else:
self.cursor.execute(format)
temp = self.cursor.fetchall()[0]
for x in range (1, len(temp) - 2):
print(attributes[x] + ": " + temp[x])
def monsterByType(self, monName):
monName = monName.capitalize()
print()
format = "SELECT name FROM monster WHERE type='" + monName + "'"
self.cursor.execute(format)
if (len(self.cursor.fetchall()) == 0):
print("You did not enter a valid monster name.")
else:
self.cursor.execute(format)
temp = self.cursor.fetchall()
for x in range (0, len(temp)):
print(temp[x])
def spells(self, spellName):
#spellName = spellName.capitalize()
print()
attributes = ["id", "name", "altname", "school", "subschool", "descriptor", "spellcraft_dc",
"level", "components", "casting_time", "range", "target", "area", "effect", "duration",
"saving_throw", "spell_resistance", "short_description", "to_develop", "arcane_material_components",
"focus", "description", "xp_cost", "arcane_focus", "wizard_focus", "verbal_components",
"sorcerer_focus", "bard_focus", "cleric_focus", "druid_focus", "full_attack", "reference"]
format = "SELECT * FROM spell WHERE (name='" + spellName + "' OR altname='" + spellName + "')"
self.cursor.execute(format)
if (len(self.cursor.fetchall()) == 0):
print("You did not enter a valid spell name.")
else:
self.cursor.execute(format)
temp = self.cursor.fetchall()[0]
for x in range (1, len(temp) - 2):
print(attributes[x] + ": " + temp[x])
#this currently doesn't work
def spells1wizard(self):
level = input()
format = "SELECT name FROM spell WHERE level=1"
self.cursor.execute(format)
if (len(self.cursor.fetchall()) == 0):
print("You did not enter a valid spell name.")
else:
self.cursor.execute(format)
temp = self.cursor.fetchall()[0]
for x in range (1, len(temp) - 2):
print(temp[x])
def items(self, itemName):
itemName = itemName.capitalize()
print()
attributes = ["id", "name", "category", "subcategory", "special_ability", "aura", "caster_level",
"price", "manifester_level", "prereq", "cost", "weight", "full_text", "reference"]
format = "SELECT * FROM item WHERE name='" + itemName + "'"
self.cursor.execute(format)
if (len(self.cursor.fetchall()) == 0):
print("You did not enter a valid item name.")
else:
self.cursor.execute(format)
temp = self.cursor.fetchall()[0]
for x in range (1, len(temp) - 2):
print(attributes[x] + ": " + temp[x])
def equipment(self, eName):
eName = eName.capitalize()
print()
attributes = ["id", "name", "family", "category", "subcategory", "cost", "dmg_s",
"armor_shield_bonus", "maximum_dex_bonus", "dmg_m",
"weight", "critical", "armor_check_penalty", "arcane_spell_failure_chance", "range_increment",
"speed_30", "type", "speed_20", "full_text", "reference"]
format = "SELECT * FROM equipment WHERE name='" + eName + "'"
#self.cursor.execute("SELECT * FROM eq
self.cursor.execute(format)
if (len(self.cursor.fetchall()) == 0):
print("You did not enter a valid item name.")
else:
self.cursor.execute(format)
temp = self.cursor.fetchall()[0]
for x in range (1, len(temp) - 2):
print(attributes[x] + ": " + temp[x])
def monsterAlignment(self, monAlign):
print()
format = "SELECT name FROM monster WHERE alignment='" + monAlign + "'"
self.cursor.execute(format)
if (len(self.cursor.fetchall()) != 0):
self.cursor.execute(format)
temp = self.cursor.fetchall()
for x in range (0, len(temp)):
print(temp[x][0] + monAlign)
format = "SELECT name FROM monster WHERE alignment='Usually " + monAlign + "'"
self.cursor.execute(format)
if (len(self.cursor.fetchall()) != 0):
self.cursor.execute(format)
temp = self.cursor.fetchall()
for x in range (0, len(temp)):
print(temp[x][0] + " is Usually " + monAlign)
format = "SELECT name FROM monster WHERE alignment='Always " + monAlign + "'"
self.cursor.execute(format)
if (len(self.cursor.fetchall()) != 0):
self.cursor.execute(format)
temp = self.cursor.fetchall()
for x in range (0, len(temp)):
print(temp[x][0] + " is Always " + monAlign)
format = "SELECT name FROM monster WHERE alignment='Often " + monAlign + "'"
self.cursor.execute(format)
if (len(self.cursor.fetchall()) == 0):
print("You did not enter a valid alignment")
else:
self.cursor.execute(format)
temp = self.cursor.fetchall()
for x in range (0, len(temp)):
print(temp[x][0] + " is Often" + monAlign)
def magicSchool(self, school):
school = school.capitalize()
print()
format = "SELECT name, level FROM spell WHERE school='" + school + "'"
self.cursor.execute(format)
if (len(self.cursor.fetchall()) == 0):
print("You did not enter a valid school of magic")
else:
self.cursor.execute(format)
temp = self.cursor.fetchall()
for x in range (0, len(temp)):
print(temp[x][0] + ", available to: " + temp[x][1])
def feats(self, feat):
print()
attributes = ["id", "name", "type", "multiple", "stack", "choice", "prerequisite",
"benefit", "normal", "special", "full_text", "reference"]
format = "SELECT * FROM feat WHERE name='" + feat + "'"
self.cursor.execute(format)
if (len(self.cursor.fetchall()) == 0):
print("You did not enter a valid feat name.")
else:
self.cursor.execute(format)
temp = self.cursor.fetchall()[0]
for x in range (1, len(temp) - 2):
print(attributes[x] + ": " + temp[x])