-
Notifications
You must be signed in to change notification settings - Fork 16
/
gameInformation.py
110 lines (95 loc) · 3.95 KB
/
gameInformation.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
import json
import os
import sys
from UnityPy import Environment
import zipfile
DEBUG = False
def run(path):
with open("typetree.json") as f:
typetree = json.load(f)
env = Environment()
with zipfile.ZipFile(path) as apk:
with apk.open("assets/bin/Data/globalgamemanagers.assets") as f:
env.load_file(f.read(), name="assets/bin/Data/globalgamemanagers.assets")
with apk.open("assets/bin/Data/level0") as f:
env.load_file(f.read())
for obj in env.objects:
if obj.type.name != "MonoBehaviour":
continue
data = obj.read()
if data.m_Script.get_obj().read().name == "GameInformation":
GameInformation = obj.read_typetree(typetree["GameInformation"])
elif data.m_Script.get_obj().read().name == "GetCollectionControl":
Collections = obj.read_typetree(typetree["GetCollectionControl"], True)
elif data.m_Script.get_obj().read().name == "TipsProvider":
Tips = obj.read_typetree(typetree["TipsProvider"], True)
difficulty = []
table = []
for key, songs in GameInformation["song"].items():
if key == "otherSongs":
continue
for song in songs:
if len(song["difficulty"]) == 5:
song["difficulty"].pop()
if song["difficulty"][-1] == 0.0:
song["difficulty"].pop()
song["charter"].pop()
for i in range(len(song["difficulty"])):
song["difficulty"][i] = str(round(song["difficulty"][i], 1))
song["songsId"] = song["songsId"][:-2]
difficulty.append([song["songsId"]]+song["difficulty"])
table.append((song["songsId"], song["songsName"], song["composer"], song["illustrator"], *song["charter"]))
print(difficulty)
print(table)
with open("info/difficulty.tsv", "w", encoding="utf8") as f:
for item in difficulty:
f.write("\t".join(map(str, item)))
f.write("\n")
with open("info/info.tsv", "w", encoding="utf8") as f:
for item in table:
f.write("\t".join(item))
f.write("\n")
single = []
illustration = []
for key in GameInformation["keyStore"]:
if key["kindOfKey"] == 0:
single.append(key["keyName"])
elif key["kindOfKey"] == 2 and key["keyName"] != "Introduction" and key["keyName"] not in single:
illustration.append(key["keyName"])
with open("info/single.txt", "w", encoding="utf8") as f:
for item in single:
f.write("%s\n" % item)
with open("info/illustration.txt", "w", encoding="utf8") as f:
for item in illustration:
f.write("%s\n" % item)
print(single)
print(illustration)
D = {}
for item in Collections.collectionItems:
if item.key in D:
D[item.key][1] = item.subIndex
else:
D[item.key] = [item.multiLanguageTitle.chinese, item.subIndex]
with open("info/collection.tsv", "w", encoding="utf8") as f:
for key, value in D.items():
f.write("%s\t%s\t%s\n" % (key, value[0], value[1]))
with open("info/avatar.txt", "w", encoding="utf8") as avatar:
with open("info/tmp.tsv", "w", encoding="utf8") as tmp:
for item in Collections.avatars:
avatar.write(item.name)
avatar.write("\n")
tmp.write("%s\t%s\n" % (item.name, item.addressableKey[7:]))
with open("info/tips.txt", "w", encoding="utf8") as f:
for tip in Tips.tips[0].tips:
f.write(tip)
f.write("\n")
if __name__ == "__main__":
if len(sys.argv) == 1 and os.path.isdir("/data/"):
import subprocess
r = subprocess.run("pm path com.PigeonGames.Phigros",stdin=subprocess.DEVNULL,stdout=subprocess.PIPE,stderr=subprocess.DEVNULL,shell=True)
path = r.stdout[8:-1].decode()
else:
path = sys.argv[1]
if not os.path.isdir("info"):
os.mkdir("info")
run(path)