-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
94 lines (75 loc) · 2.56 KB
/
utils.py
File metadata and controls
94 lines (75 loc) · 2.56 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
90
91
92
93
94
import xml.etree.ElementTree as ET
import re
def get_data_strings(prefix, prefix_length):
data = {}
with open('data/GameStrings.txt', 'r') as f:
for line in f:
if line[0:prefix_length] == prefix:
sub_line = line[prefix_length:].split("=", 1)
data[sub_line[0]] = sub_line[1].strip()
return data
def get_weapon_damage(name):
weapon_dmg_min = 0
weapon_dmg_max = 0
effect_tree = ET.parse('data/EffectData.xml')
root = effect_tree.getroot()
for child in root:
if child.attrib['id'] == name:
dmg_amount = ""
dmg_rand = ""
for subchild in child:
if subchild.tag == 'Amount':
dmg_amount = subchild.attrib['value']
elif subchild.tag == 'Random':
dmg_rand = subchild.attrib['value']
weapon_dmg_max = dmg_amount
weapon_dmg_min = dmg_rand
return weapon_dmg_max, weapon_dmg_min
def get_weapon_type(name):
dmg_type = ''
dmg_min = 0
dmg_max = 0
attack_speed = ""
weapon_tree = ET.parse('data/WeaponData.xml')
root = weapon_tree.getroot()
for child in root:
if child.attrib['id'] == name:
dmg_parent = child.attrib['parent']
if dmg_parent == 'NormalAttack':
dmg_type = "Normal"
elif dmg_parent == 'ChaosAttack':
dmg_type = 'Chaos'
elif dmg_parent == 'PiercingAttack':
dmg_type = 'Piercing'
elif dmg_parent == 'MagicAttack':
dmg_type = 'Magic'
elif dmg_parent == 'SiegeAttack':
dmg_type = "Siege"
for subchild in child:
if subchild.tag == "DisplayEffect":
dmg_max, dmg_min = get_weapon_damage(subchild.attrib['value'])
elif subchild.tag == "Period":
attack_speed = subchild.attrib['value']
return dmg_type, dmg_max, dmg_min, attack_speed
def leading_strip(string):
if string[0] == '0':
return string[1:]
else:
return string
def rewrite_string(str):
s = re.sub(r'<(s|c)[^>]*>', '**', str)
s = re.sub(r'</(s|c)>', '**', s)
s = re.sub(r'<n/>', '\n', s)
s = re.sub(r'<n>', '', s)
return s
def leading_strip(string):
if string[0] == '0':
return string[1:]
else:
return string
def rewrite_send(str):
s = re.sub(r'<(s|c)[^>]*>', '', str)
s = re.sub(r'</(s|c)>', '', s)
s = re.sub(r'<n/>', '\n', s)
s = re.sub(r'<n>', '', s)
return s