-
Notifications
You must be signed in to change notification settings - Fork 4
/
ffxiv_desynth.php
executable file
·97 lines (77 loc) · 1.76 KB
/
ffxiv_desynth.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
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
#!/usr/bin/php
<?php
require_once __DIR__."/ffxivData.inc";
require_once __DIR__."/universalis.inc";
require __DIR__.'/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::create(__DIR__);
$dotenv->load();
$dataset = new FfxivDataSet();
$xiv = new Universalis($_ENV['server']);
$typeID = 8;
$target = 100;
$limit = 1000;
$JOBS = [
"Carpenter",
"Blacksmith",
"Armorer",
"Goldsmith",
"Leatherworker",
"Weaver",
"Alchemist",
"Culinarian"
];
if (count($argv) > 1) {
$typeID = $argv[1];
}
if (count($argv) > 2) {
$target = intval($argv[2]);
}
if (count($argv) > 3) {
$limit = intval($argv[3]);
}
if (!is_numeric($typeID)) {
$result = array_search($typeID, $JOBS);
if ($result === false) {
print 'Could not find crafting type \''.$typeID."'\n";
exit();
}
$typeID = 8 + $result;
}
function doit($target, $type)
{
global $dataset, $limit;
$result = array();
$ds = $dataset->getItems();
foreach ($ds as $i) {
if (!$i->IsUntradable && $i->{'Level{Item}'} >= $target && $i->{'Level{Item}'} <= $target + $limit &&
$i->{'ClassJob{Repair}'} == $type) {
$result[] = $i;
}
}
return $result;
}
function sortMe($a, $b)
{
return $a->Cost - $b->Cost;
}
function noop($stage, $data = null)
{
}
$result = doit($target, $typeID);
foreach ($result as $idx => &$i) {
$data = $xiv->getMarket($i->Index, false, 'noop');
if (!$data) {
unset($result[$idx]);
continue;
}
$cheap = $xiv->currentCheapest($data[$i->Index]);
if (!$cheap) {
unset($result[$idx]);
continue;
}
$i->Cost = $cheap['Item']->pricePerUnit;
}
usort($result, "sortMe");
foreach ($result as $i) {
print ($i->{'Level{Item}'}).' : '.$i->Name." ".$i->Cost." \n";
}