-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathall-items.ts
More file actions
151 lines (142 loc) · 5.83 KB
/
all-items.ts
File metadata and controls
151 lines (142 loc) · 5.83 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
Chunithm All-Items generator
Run this with Bun, with all options (including A000) in a folder named `option`
It will spit out `all-items.json`
*/
import { XMLParser } from "fast-xml-parser";
import ora from "ora";
import fs from "fs";
const options = fs.readdirSync("option");
interface Item {
name: string,
disable: "false" | "true",
style?: string, // For SymbolChat and Trophy items
category?: string // For AvatarAccessory items
}
let data: Record<string, Record<string, Item>> = {
trophy: {},
chara: {},
event: {},
frame: {},
ticket: {},
mapIcon: {},
systemVoice: {},
namePlate: {},
avatarAccessory: {},
symbolChat: {}
};
function getXmlContents(file: string) {
if (!fs.existsSync(file))
return;
if (!fs.statSync(file).isFile())
return;
const data = fs.readFileSync(file).toString();
const parser = new XMLParser();
return parser.parse(data);
}
for (const option of options) {
const spinner = ora(`Processing ${option}`).start();
for (const category of fs.readdirSync(`option/${option}`)) {
if (!fs.statSync(`option/${option}/${category}`).isDirectory())
continue;
const children = fs.readdirSync(`option/${option}/${category}`);
switch (category) {
case "symbolChat":
for (const child of children) {
const xmlData = getXmlContents(`option/${option}/${category}/${child}/SymbolChat.xml`);
if (xmlData)
data.symbolChat[xmlData.SymbolChatData.name.id.toString()] = {
disable: "false",
name: xmlData.SymbolChatData.text,
style: xmlData.SymbolChatData.balloonID
}
}
break;
case "trophy":
for (const child of children) {
const xmlData = getXmlContents(`option/${option}/${category}/${child}/Trophy.xml`);
if (xmlData)
data.trophy[xmlData.TrophyData.name.id.toString()] = {
disable: "false",
name: xmlData.TrophyData.name.str,
style: xmlData.TrophyData.rareType
}
}
break;
case "chara":
for (const child of children) {
const xmlData = getXmlContents(`option/${option}/${category}/${child}/Chara.xml`);
if (xmlData)
data.chara[xmlData.CharaData.name.id.toString()] = {
disable: "false",
name: xmlData.CharaData.name.str
}
}
break;
case "namePlate":
for (const child of children) {
const xmlData = getXmlContents(`option/${option}/${category}/${child}/NamePlate.xml`);
if (xmlData)
data.namePlate[xmlData.NamePlateData.name.id.toString()] = {
disable: "false",
name: xmlData.NamePlateData.name.str
}
}
break;
case "avatarAccessory":
for (const child of children) {
const xmlData = getXmlContents(`option/${option}/${category}/${child}/AvatarAccessory.xml`);
if (xmlData)
data.avatarAccessory[xmlData.AvatarAccessoryData.name.id.toString()] = {
disable: "false",
name: xmlData.AvatarAccessoryData.name.str,
category: xmlData.AvatarAccessoryData.category
}
}
break;
case "mapIcon":
for (const child of children) {
const xmlData = getXmlContents(`option/${option}/${category}/${child}/MapIcon.xml`);
if (xmlData)
data.mapIcon[xmlData.MapIconData.name.id.toString()] = {
disable: "false",
name: xmlData.MapIconData.name.str
}
}
break;
case "systemVoice":
for (const child of children) {
const xmlData = getXmlContents(`option/${option}/${category}/${child}/SystemVoice.xml`);
if (xmlData)
data.systemVoice[xmlData.SystemVoiceData.name.id.toString()] = {
disable: "false",
name: xmlData.SystemVoiceData.name.str
}
}
break;
case "ticket":
for (const child of children) {
const xmlData = getXmlContents(`option/${option}/${category}/${child}/Ticket.xml`);
if (xmlData)
data.ticket[xmlData.TicketData.name.id.toString()] = {
disable: "false",
name: xmlData.TicketData.name.str,
style: xmlData.TicketData.type
}
}
break;
case "frame":
for (const child of children) {
const xmlData = getXmlContents(`option/${option}/${category}/${child}/Frame.xml`);
if (xmlData)
data.frame[xmlData.FrameData.name.id.toString()] = {
disable: "false",
name: xmlData.FrameData.name.str
}
}
break;
}
};
spinner.stop();
}
fs.writeFileSync(`all-items.json`, JSON.stringify(data))