This commit is contained in:
2024-03-29 15:47:35 +01:00
parent 85d2cf4be2
commit 7619856ef2
27 changed files with 2255 additions and 193 deletions

View File

@ -1,3 +0,0 @@
<?php
$tpl['file'] = 'default.html';
$tpl['data'] = '';

3
pages/default.php Normal file
View File

@ -0,0 +1,3 @@
<?php
$tpl['file'] = 'default.twig';
$tpl['data'] = '';

View File

@ -1,45 +0,0 @@
<?php
$tpl['file'] = 'doppelklinge.html';
$tpl['data'] = [];
$progress = !empty($_POST['progress']) ? $_POST['progress'] : '';
if(!empty($progress)) {
$list = [];
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; });
$act = $max = $avg = 0;
for($i = 0; $i < 5; $i++) {
$act += $list[$i]->act;
$max += $list[$i]->max;
$avg += $list[$i]->percent;
}
$percent = round($act / $max * 100, 2);
$tpl['data'] = [
'progress' => $progress,
'list' => $list,
'percent' => $percent,
'avg' => round($avg / 5, 2)
];
}
else {
$tpl['data'] = [
'progress' => ''
];
}

116
pages/doppelklinge.php Normal file
View File

@ -0,0 +1,116 @@
<?php
require_once __DIR__ . '/../inc/db.inc.php';
$tpl['file'] = 'doppelklinge.twig';
$tpl['data'] = [];
$tasks = [
'auftrag' => [ 'name' => 'Aufträge / Vermessungen', 'max' => 15000 ],
'blut' => [ 'name' => 'Blutproben abgegeben', 'max' => 500 ],
'gewebe' => [ 'name' => 'Gewebeproben abgegeben', 'max' => 750 ],
'gnpc' => [ 'name' => 'Gruppen-NPCs getötet', 'max' => 5000 ],
'npc' => [ 'name' => 'NPCs getötet', 'max' => 100000 ],
'pflanzen' => [ 'name' => 'Pflanzen geerntet', 'max' => 1500 ],
'unique' => [ 'name' => 'Unique-NPCs getötet', 'max' => 2500 ]
];
if(isset($_GET['c'])) {
$res = $db->prepare('select * from ft_doppelklinge where uuid = :uuid limit 1');
$res->execute([ ':uuid' => $_GET['c'] ]);
$arr = $res->fetch($db::FETCH_ASSOC);
$i = 0;
foreach($tasks as $type => $data) {
$list[$i] = (object)[
'task' => $data['name'],
'act' => $arr[$type],
'max' => $data['max']
];
$list[$i]->percent = round($list[$i]->act / $list[$i]->max * 100, 2);
$list[$i]->left = $list[$i]->max - $list[$i]->act;
$i++;
}
usort($list, function($a, $b) { return $b->percent <=> $a->percent; });
$act = $max = $avg = 0;
for($i = 0; $i < 5; $i++) {
$act += $list[$i]->act;
$max += $list[$i]->max;
$avg += $list[$i]->percent;
}
$percent = round($act / $max * 100, 2);
$tpl['data'] = [
'progress' => $progress,
'list' => $list,
'percent' => $percent,
'avg' => round($avg / 5, 2),
'dt' => date('d.m.Y - H:i:s', strtotime($arr['created_at']))
];
return;
}
$progress = !empty($_POST['progress']) ? $_POST['progress'] : '';
if(!empty($progress)) {
$list = [];
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;
}
$query = <<<SQL
replace into ft_doppelklinge
(`uuid`, `sessid`, `auftrag`, `blut`, `gewebe`, `gnpc`, `npc`, `pflanzen`, `unique`)
values
(substr(uuid(), 1, 8), :sessid, :auftrag, :blut, :gewebe, :gnpc, :npc, :pflanzen, :unique)
returning uuid;
SQL;
$insert = $db->prepare($query);
$insert->execute([
':sessid' => session_id(),
':auftrag' => $list[0]->act,
':blut' => $list[1]->act,
':gewebe' => $list[2]->act,
':gnpc' => $list[3]->act,
':npc' => $list[4]->act,
':pflanzen' => $list[5]->act,
':unique' =>$list[6]->act
]);
$uuid = $insert->fetch()->uuid;
usort($list, function($a, $b) { return $b->percent <=> $a->percent; });
$act = $max = $avg = 0;
for($i = 0; $i < 5; $i++) {
$act += $list[$i]->act;
$max += $list[$i]->max;
$avg += $list[$i]->percent;
}
$percent = round($act / $max * 100, 2);
$tpl['data'] = [
'progress' => $progress,
'list' => $list,
'percent' => $percent,
'avg' => round($avg / 5, 2),
'share' => $uuid
];
}
else {
$tpl['data'] = [
'progress' => ''
];
}

22
pages/knochen.php Normal file
View File

@ -0,0 +1,22 @@
<?php
require_once __DIR__ . '/../inc/db.inc.php';
$tpl['file'] = 'knochen.twig';
$res = $db->query(<<<SQL
SELECT
type, id, title, solution, origin
FROM ft_knochen
ORDER BY id
SQL)->fetchAll($db::FETCH_GROUP);
$tpl['data'] = [
'types' => [
'nimm' => 'Nimm Knochen weg',
'lege' => 'Lege Knochen um'
],
'knochen' => [
'nimm' => $res['nimm'],
'lege' => $res['lege']
]
];

View File

@ -1,5 +1,5 @@
<?php
$tpl['file'] = 'vermessung.html';
$tpl['file'] = 'vermessung.twig';
$tpl['data'] = [];
$tpl['debug'] = false;
@ -23,17 +23,31 @@ if(!empty($protocol)) {
];
}
if(!array_key_exists($res['amt'][$i], $vms[$tmpdt]['user']))
$vms[$tmpdt]['user'][$res['amt'][$i]] = 1;
else
$vms[$tmpdt]['user'][$res['amt'][$i]] += 1;
$laeufer = explode(', ', str_replace(' und ', ', ', trim($res['laeufer'][$i], ',')));
$pro = (int)str_replace('.', '', $res['gm'][$i]) / (count($laeufer) + 1);
if(!array_key_exists($res['amt'][$i], $vms[$tmpdt]['user'])) {
$vms[$tmpdt]['user'][$res['amt'][$i]] = [
'gold' => $pro,
'count' => 1
];
}
else {
$vms[$tmpdt]['user'][$res['amt'][$i]]['gold'] += $pro;
$vms[$tmpdt]['user'][$res['amt'][$i]]['count'] += 1;
}
foreach($laeufer as $tmp) {
if(!array_key_exists($tmp, $vms[$tmpdt]['user']))
$vms[$tmpdt]['user'][$tmp] = 1;
else
$vms[$tmpdt]['user'][$tmp] += 1;
if(!array_key_exists($tmp, $vms[$tmpdt]['user'])) {
$vms[$tmpdt]['user'][$tmp] = [
'gold' => $pro,
'count' => 1
];
}
else {
$vms[$tmpdt]['user'][$tmp]['gold'] += $pro;
$vms[$tmpdt]['user'][$tmp]['count'] += 1;
}
}
arsort($vms[$tmpdt]['user']);
@ -44,7 +58,7 @@ if(!empty($protocol)) {
'gold' => (int)str_replace('.', '', $res['gm'][$i]),
'amt' => $res['amt'][$i],
'laeufer' => $laeufer,
'a' => (int)str_replace('.', '', $res['gm'][$i]) / (count($laeufer) + 1)
'a' => $pro
];
}