-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecordcalculator.php
105 lines (83 loc) · 2.65 KB
/
recordcalculator.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
98
99
100
101
102
103
104
105
<?php
include("stats.php");
$serialized = trim(file_get_contents("foot"));
$updates = unserialize($serialized);
function time_triples($gap) {
global $updates;
$triples = array();
$lower_bound = 0;
$update_count = count($updates);
for($i = 0; $i < $update_count; $i++) {
$first_index = $i;
$first = $updates[$first_index];
for($j = $lower_bound; $j < $update_count; $j++) {
$u = $updates[$j];
if ($u->time - $first->time > $gap)
break;
$lower_bound = $j;
}
$last_index = $lower_bound;
$last = $updates[$last_index];
$triples[] = array($first, $last, $last_index);
}
return $triples;
}
function record($triples, $skill) {
global $updates;
$record_xp = 0;
$record_triple = $triples[0];
foreach($triples as $triple) {
$xp_difference = $triple[1]->xp[$skill] - $triple[0]->xp[$skill];
if ($xp_difference > $record_xp) {
$record_triple = $triple;
$record_xp = $xp_difference;
}
}
$timespan_end = $record_triple[2];
$actual_end = $record_triple[2];
while($updates[$actual_end - 1]->xp[$skill] == $updates[$timespan_end]->xp[$skill]) {
$actual_end--;
if ($actual_end == 0)
break;
}
$record = array("xp" => $record_xp, "time" => $updates[$actual_end]->time);
return $record;
}
function ehp_record($triples) {
global $updates;
$record_ehp = 0;
$record_triple = $triples[0];
foreach($triples as $triple) {
$ehp_difference = $triple[1]->ehp - $triple[0]->ehp;
if ($ehp_difference > $record_ehp) {
$record_triple = $triple;
$record_ehp = $ehp_difference;
}
}
$timespan_end = $record_triple[2];
$actual_end = $record_triple[2];
while($updates[$actual_end - 1]->ehp == $updates[$timespan_end]->ehp) {
$actual_end--;
if ($actual_end == 0)
break;
}
$record = array("ehp" => $record_ehp, "time" => $record_triple[1]->time);
return $record;
}
for($n = 0; $n < 10; $n++) {
$times = array(1, 7, 31);
$triples_cached = array();
foreach($times as $time) {
$triples_cached[$time] = time_triples($time * 86400);
}
foreach($times as $time) {
$triples = $triples_cached[$time];
for($i = 0; $i < $SKILL_COUNT; $i++) {
$record = record($triples, $i);
$skill = skill_name($i);
// echo "$skill $time day record xp " . $record["xp"] . "\n";
}
$record = ehp_record($triples);
// echo "EHP $time day record: " . $record["ehp"] . "\n";
}
}