|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace Smr; |
|
4
|
|
|
|
|
5
|
|
|
use Exception; |
|
6
|
|
|
use SmrPlayer; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Collection of functions to help display messages and message boxes. |
|
10
|
|
|
*/ |
|
11
|
|
|
class Messages { |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @return ($typeID is null ? array<int, string> : string) |
|
|
|
|
|
|
15
|
|
|
*/ |
|
16
|
|
|
public static function getMessageTypeNames(int $typeID = null): array|string { |
|
17
|
|
|
$typeNames = [ |
|
18
|
|
|
MSG_PLAYER => 'Player Messages', |
|
19
|
|
|
MSG_PLANET => 'Planet Messages', |
|
20
|
|
|
MSG_SCOUT => 'Scout Messages', |
|
21
|
|
|
MSG_ALLIANCE => 'Alliance Messages', |
|
22
|
|
|
MSG_POLITICAL => 'Political Messages', |
|
23
|
|
|
MSG_GLOBAL => 'Global Messages', |
|
24
|
|
|
MSG_ADMIN => 'Admin Messages', |
|
25
|
|
|
MSG_CASINO => 'Casino Messages', |
|
26
|
|
|
MSG_SENT => 'Sent Messages', |
|
27
|
|
|
]; |
|
28
|
|
|
return $typeID === null ? $typeNames : $typeNames[$typeID]; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public static function getMessageTypeImage(int $typeID): string { |
|
32
|
|
|
return match ($typeID) { |
|
33
|
|
|
MSG_PLAYER => 'images/personal_msg.png', |
|
34
|
|
|
MSG_PLANET => 'images/planet_msg.png', |
|
35
|
|
|
MSG_SCOUT => 'images/scout_msg.png', |
|
36
|
|
|
MSG_ALLIANCE => 'images/alliance_msg.png', |
|
37
|
|
|
MSG_POLITICAL => 'images/council_msg.png', |
|
38
|
|
|
MSG_GLOBAL => 'images/global_msg.png', |
|
39
|
|
|
MSG_ADMIN => 'images/admin_msg.png', |
|
40
|
|
|
MSG_CASINO => 'images/casino_msg.png', |
|
41
|
|
|
default => throw new Exception('No image for message type ID: ' . $typeID), |
|
42
|
|
|
}; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @return array<int, string> |
|
47
|
|
|
*/ |
|
48
|
|
|
public static function getAdminBoxNames(): array { |
|
49
|
|
|
return [ |
|
50
|
|
|
BOX_BUGS_AUTO => 'Automatic Bug Reports', |
|
51
|
|
|
BOX_BUGS_REPORTED => 'Player Bug Reports', |
|
52
|
|
|
BOX_GLOBALS => 'Global Messages', |
|
53
|
|
|
BOX_ALLIANCE_DESCRIPTIONS => 'Alliance Descriptions', |
|
54
|
|
|
BOX_ALBUM_COMMENTS => 'Photo Album Comments', |
|
55
|
|
|
BOX_BARTENDER => 'Bartender Gossip', |
|
56
|
|
|
]; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public static function getMessagePlayer(int $accountID, int $gameID, int $messageType = null): string|SmrPlayer { |
|
60
|
|
|
if ($accountID == ACCOUNT_ID_PORT) { |
|
61
|
|
|
$return = '<span class="yellow">Port Defenses</span>'; |
|
62
|
|
|
} elseif ($accountID == ACCOUNT_ID_ADMIN) { |
|
63
|
|
|
$return = '<span class="admin">Administrator</span>'; |
|
64
|
|
|
} elseif ($accountID == ACCOUNT_ID_PLANET) { |
|
65
|
|
|
$return = '<span class="yellow">Planetary Defenses</span>'; |
|
66
|
|
|
} elseif ($accountID == ACCOUNT_ID_ALLIANCE_AMBASSADOR) { |
|
67
|
|
|
$return = '<span class="green">Alliance Ambassador</span>'; |
|
68
|
|
|
} elseif ($accountID == ACCOUNT_ID_CASINO) { |
|
69
|
|
|
$return = '<span class="yellow">Casino</span>'; |
|
70
|
|
|
} elseif ($accountID == ACCOUNT_ID_FED_CLERK) { |
|
71
|
|
|
$return = '<span class="yellow">Federal Clerk</span>'; |
|
72
|
|
|
} elseif ($accountID == ACCOUNT_ID_OP_ANNOUNCE || $accountID == ACCOUNT_ID_ALLIANCE_COMMAND) { |
|
73
|
|
|
$return = '<span class="green">Alliance Command</span>'; |
|
74
|
|
|
} else { |
|
75
|
|
|
foreach (Race::getAllNames() as $raceID => $raceName) { |
|
76
|
|
|
if ($accountID == ACCOUNT_ID_GROUP_RACES + $raceID) { |
|
77
|
|
|
return '<span class="yellow">' . $raceName . ' Government</span>'; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
if (!empty($accountID)) { |
|
81
|
|
|
$return = SmrPlayer::getPlayer($accountID, $gameID); |
|
82
|
|
|
} else { |
|
83
|
|
|
$return = match ($messageType) { |
|
84
|
|
|
MSG_ADMIN => '<span class="admin">Administrator</span>', |
|
85
|
|
|
MSG_ALLIANCE => '<span class="green">Alliance Ambassador</span>', |
|
86
|
|
|
default => 'Unknown', |
|
87
|
|
|
}; |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
return $return; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
} |
|
94
|
|
|
|