1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Smr\Pages\Player; |
4
|
|
|
|
5
|
|
|
use AbstractSmrPlayer; |
6
|
|
|
use Menu; |
7
|
|
|
use Smr\Database; |
8
|
|
|
use Smr\Page\PlayerPage; |
9
|
|
|
use Smr\Page\ReusableTrait; |
10
|
|
|
use Smr\Template; |
11
|
|
|
|
12
|
|
|
class CombatLogViewer extends PlayerPage { |
13
|
|
|
|
14
|
|
|
use ReusableTrait; |
15
|
|
|
|
16
|
|
|
public string $file = 'combat_log_viewer.php'; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @param non-empty-array<int> $logIDs |
|
|
|
|
20
|
|
|
*/ |
21
|
|
|
public function __construct( |
22
|
|
|
private readonly array $logIDs, |
23
|
|
|
private readonly int $currentLog = 0 |
24
|
|
|
) {} |
25
|
|
|
|
26
|
|
|
public function build(AbstractSmrPlayer $player, Template $template): void { |
27
|
|
|
// Set properties for the current display page |
28
|
|
|
$display_id = $this->logIDs[$this->currentLog]; |
29
|
|
|
$db = Database::getInstance(); |
30
|
|
|
$dbResult = $db->read('SELECT timestamp,sector_id,result,type FROM combat_logs WHERE log_id=' . $db->escapeNumber($display_id) . ' LIMIT 1'); |
31
|
|
|
|
32
|
|
|
$dbRecord = $dbResult->record(); |
33
|
|
|
$template->assign('CombatLogSector', $dbRecord->getInt('sector_id')); |
34
|
|
|
$template->assign('CombatLogTimestamp', date($player->getAccount()->getDateTimeFormat(), $dbRecord->getInt('timestamp'))); |
35
|
|
|
$results = $dbRecord->getObject('result', true); |
36
|
|
|
$template->assign('CombatResultsType', $dbRecord->getString('type')); |
37
|
|
|
$template->assign('CombatResults', $results); |
38
|
|
|
|
39
|
|
|
// Create a container for the next/previous log. |
40
|
|
|
// We initialize it with the current $var, then modify it to set |
41
|
|
|
// which log to view when we press the next/previous log buttons. |
42
|
|
|
if ($this->currentLog > 0) { |
43
|
|
|
$container = new self($this->logIDs, $this->currentLog - 1); |
44
|
|
|
$template->assign('PreviousLogHREF', $container->href()); |
45
|
|
|
} |
46
|
|
|
if ($this->currentLog < count($this->logIDs) - 1) { |
47
|
|
|
$container = new self($this->logIDs, $this->currentLog + 1); |
48
|
|
|
$template->assign('NextLogHREF', $container->href()); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
$template->assign('PageTopic', 'Combat Logs'); |
52
|
|
|
Menu::combatLog(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
} |
56
|
|
|
|