forked from rubendal/SSBU-Dump-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
article.py
58 lines (45 loc) · 1.9 KB
/
article.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
from hash40 import Hash40
class NameHash40:
def __init__(self, name, hash40):
self.name = name
self.hash40 = hash40
HashList = []
ArticleList = []
def loadHashes(kind):
with open('scriptNames.txt', 'r') as f:
HashList.append(NameHash40(kind, Hash40.CreateFromString(kind.lower()))) #Share animation
for s in f:
if(s != "\n"):
s = (kind + s).strip()
HashList.append(NameHash40(s, Hash40.CreateFromString(s.lower())))
if 'Special' in s or 'Final' in s:
HashList.append(NameHash40(s.replace('Special','SpecialAir').replace('Final','FinalAir').strip(), Hash40.CreateFromString(s.replace('Special','SpecialAir').replace('Final','FinalAir').lower().strip())))
articlesFile = open('articles.txt','r')
for s in articlesFile:
if(s != "\n"):
s = s.replace("WEAPON_KIND_", "").strip()
ArticleList.append(NameHash40(s.lower(), Hash40.CreateFromString(s.lower())))
class Article: # Character / Weapon
def __init__(self, article, hashes = []):
self.article = article
self.scriptsHash = hashes
def addScriptHash(self, hash, address):
self.scriptsHash.append(ScriptHash(hash, address))
def findHashValue(self):
find = next((x for x in ArticleList if self.article.hash == x.hash40.hash and self.article.length == x.hash40.length), None)
if find:
return find.name
else:
return self.article.hash40
class ScriptHash:
def __init__(self, hash, address):
self.hash = hash
self.address = address
def getAddress(self):
return hex(self.address)
def findHashValue(self):
find = next((x for x in HashList if self.hash.hash == x.hash40.hash and self.hash.length == x.hash40.length), None)
if find:
return find.name
else:
return self.hash.hash40