-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.py
92 lines (80 loc) · 2.7 KB
/
utils.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
import MySQLdb
import os, dill, json, jsonpickle
from item import *
from data import *
from config import *
from areas import *
def load_data():
if not os.path.exists("items.dll"):
from get_items import get_items_from_summit
items = get_items_from_summit()
with open("items.dll", 'wb') as output:
dill.dump(items, output, protocol=2)
else:
items = dill.load(open("items.dll", 'rb'))
#print("Num items:", len(items))
items = fill_in_tiers(items)
add_qlvls(items)
sets, items = get_sets_from_items(items)
attributes = get_global_attr_dict(items, sets)
return items, sets, attributes
def load_monsters():
if not os.path.exists("monsters.dll"):
monsters = scrape_monster_levels()
with open("monsters.dll", 'wb') as output:
dill.dump(monsters, output, protocol=2)
else:
monsters = dill.load(open("monsters.dll", 'rb'))
#print(monsters)
return monsters
def load_guides():
db = MySQLdb.connect(host=DBHOST, user=DBUSER, passwd=DBPASSWORD, db=DBNAME)
cur = db.cursor()
cur.execute("SELECT * FROM guides")
guides = []
for row in cur.fetchall():
guide_json = row[1]
guide = jsonpickle.decode(guide_json)
guides.append(guide)
db.close()
return guides
def fix_ormus():
ormus_str = ""
sorc_skills = class_skills[-1][1]
for skill_tree, skills in sorc_skills:
for skill in skills:
ormus_str += """
<TR>
<TD align=center>
<a name="twitchthroe"></a>
<font face="arial,helvetica" size=-1><span>
<img src="/diablo2exp/images/items/elite/ormusrobes.gif" width=56 height="78">
<center><font face="arial,helvetica" color=908858 size=-1><SPAN><b>Ormus' Robes</b></font></center>
<center>Dusk Shroud</center>
<br Clear=left>
</span></font>
</td>
<TD>
<font face="arial,helvetica" size=-1><SPAN>
Defense: <font color=4850B8>371-487</font> (varies) (Base Defense: 361-467)<BR>
Required Level: 75<BR>
Required Strength: 77<BR>
Durability: 20<BR>
<font color=4850B8>+10-20 Defense</font> (varies)<BR>
<font color=4850B8>20% Faster Cast Rate</font><BR>
<font color=4850B8>+10-15% To Cold Skill Damage</font> (varies)<BR>
<font color=4850B8>+10-15% To Fire Skill Damage</font> (varies)<BR>
<font color=4850B8>+10-15% To Lightning Skill Damage</font> (varies)<BR>
<font color=4850B8>+3 to {0} (Sorceress Only)</font>*<BR>
<font color=4850B8>Regenerate Mana 10-15%</font> (varies)<BR>
(Only Spawns In Patch 1.10 or later)
</font></td>
</TR>\n
""".format(skill.title())
print(ormus_str)
class dotdict(dict):
def __getattr__(self, name):
try:
return self[name]
except KeyError:
raise AttributeError