-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathextract_stats.php
60 lines (59 loc) · 1.05 KB
/
extract_stats.php
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
<?php
// Before running: Search OpenIV for "statssetup" and extract all results into the same folder as this script.
$fh = fopen("raw/stats.txt", "w");
function processCharStat($mp, $name)
{
global $fh;
$arr = $mp ? ["MP0_", "MP1_"] : ["SP0_", "SP1_", "SP2_"];
foreach($arr as $prefix)
{
fwrite($fh, $prefix.$name."\n");
}
}
function processStats($mp, $stats)
{
global $fh;
foreach($stats->stat as $stat)
{
$name = $stat["Name"];
if(empty($name))
{
$name = $stat["name"];
if(empty($name))
{
echo "Unexpected stat with no name:\n";
var_dump($stat);
exit;
}
}
if($stat["characterStat"] == "true")
{
processCharStat($mp, $name);
}
else
{
fwrite($fh, $name."\n");
}
}
}
foreach(scandir(".") as $file)
{
if(substr($file, -4) == ".xml")
{
echo $file."\n";
$mp = substr($file, 0, 2) == "mp";
$stats = simplexml_load_file($file)->stats;
if($stats->Category)
{
foreach($stats->Category as $category)
{
processStats($mp, $category);
}
}
else
{
processStats($mp, $stats);
}
}
}
fclose($fh);