avg and bugfix

This commit is contained in:
2022-12-22 07:06:30 +01:00
parent b2591bd1b6
commit 196fc337e0
2 changed files with 8 additions and 2 deletions

View File

@ -9,12 +9,16 @@ if(!empty($progress)) {
preg_match_all("/(?<task>.*): (?<act>.*) \/ (?<max>.*)/m", $progress, $tmp);
for($i = 0; $i < count($tmp[0]); $i++) {
if(preg_match('/XP\:/', $tmp['task'][$i]))
continue;
$list[$i] = (object)[
'task' => trim($tmp['task'][$i]),
'act' => (int)str_replace('.', '', $tmp['act'][$i]),
'max' => (int)str_replace('.', '', $tmp['max'][$i])
];
$list[$i]->percent = round($list[$i]->act / $list[$i]->max * 100, 2);
$list[$i]->left = $list[$i]->max - $list[$i]->act;
}
usort($list, function($a, $b) { return $b->percent <=> $a->percent; });