-
Notifications
You must be signed in to change notification settings - Fork 0
/
ancestries.py
79 lines (65 loc) · 2.85 KB
/
ancestries.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
import json
import nethysdb
# I don't know if this is useful, but for now I am leaving it here just in case
class Ancestry(nethysdb.NethysDB):
def __init__(self, link, SourceBook, Page, name, description, YouMight, OthersProbably, PhysicalDescription, Society, AlignmentAndReligion, Adventurers, Names, Hitpoints, Size, Speed, AbilityBoost1, AbilityBoost2, AbilityFlaw):
super().__init__(link, SourceBook, Page)
self.name = name
self.description = description
self.YouMight = YouMight
self.OthersProbably = OthersProbably
self.PhysicalDescription = PhysicalDescription
self.Society = Society
self.AlignmentAndReligion = AlignmentAndReligion
self.Adventurers = Adventurers
self.Names = Names
self.Hitpoints = Hitpoints
self.Size = Size
self.Speed = Speed
self.AbilityBoost1 = AbilityBoost1
self.AbilityBoost2 = AbilityBoost2
self.AbilityFlaw = AbilityFlaw
with open('data/ancestries.json') as f:
data = json.load(f)
list_of_ancestries = []
# grab data from JSON, create classes and append ancestries on the list
for ancestry in data['ancestries']:
name = ancestry['race']
link = ancestry['NethysUrl']
SourceBook = ancestry['Source']
Page = ancestry['Page']
description = ancestry['Description']
YouMight = ancestry['YouMight']
OthersProbably = ancestry['OthersProbably']
PhysicalDescription = ancestry['Physical Description']
Society = ancestry['Society']
AlignmentAndReligion = ancestry['Alignment and Religion']
Adventurers = ancestry['Adventurers']
Names = ancestry['Names']
Hitpoints = ancestry['Hit Points']
Size = ancestry['Size']
Speed = ancestry['Speed']
AbilityBoost1 = ancestry['Ability Boosts'][0]
AbilityBoost2 = ancestry['Ability Boosts'][1]
AbilityFlaw = ancestry['Ability Flaw'][0]
name = Ancestry(link, SourceBook, Page, name, description, YouMight, OthersProbably, PhysicalDescription, Society, AlignmentAndReligion, Adventurers, Names, Hitpoints, Size, Speed, AbilityBoost1, AbilityBoost2, AbilityFlaw)
list_of_ancestries.append(ancestry['race'])
def get_boosts(ancestry):
if ancestry in list_of_ancestries:
index = list_of_ancestries.index(ancestry)
boosts = []
boosts.append(data['ancestries'][index]['Ability Boosts'][0])
boosts.append(data['ancestries'][index]['Ability Boosts'][1])
return boosts
else:
raise Exception("Ancestry not found in the list_of_ancestries")
def get_flaw(ancestry, n):
if ancestry in list_of_ancestries:
index = list_of_ancestries.index(ancestry)
return data['ancestries'][index]['Ability Flaw'][n]
else:
raise Exception("Ancestry not found in the list_of_ancestries")
def main():
print(list_of_ancestries)
if __name__ == '__main__':
main()