|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace Smr; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Provides methods to map race IDs to basic race properties. |
|
7
|
|
|
*/ |
|
8
|
|
|
class Race { |
|
9
|
|
|
|
|
10
|
|
|
private const RACE_NAMES = [ |
|
11
|
|
|
RACE_NEUTRAL => 'Neutral', |
|
12
|
|
|
RACE_ALSKANT => 'Alskant', |
|
13
|
|
|
RACE_CREONTI => 'Creonti', |
|
14
|
|
|
RACE_HUMAN => 'Human', |
|
15
|
|
|
RACE_IKTHORNE => 'Ik\'Thorne', |
|
16
|
|
|
RACE_SALVENE => 'Salvene', |
|
17
|
|
|
RACE_THEVIAN => 'Thevian', |
|
18
|
|
|
RACE_WQHUMAN => 'WQ Human', |
|
19
|
|
|
RACE_NIJARIN => 'Nijarin', |
|
20
|
|
|
]; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* All possible race IDs. |
|
24
|
|
|
* |
|
25
|
|
|
* @return array<int> |
|
26
|
|
|
*/ |
|
27
|
|
|
public static function getAllIDs() : array { |
|
28
|
|
|
return \array_keys(self::RACE_NAMES); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Maps all possible race IDs to race names. |
|
33
|
|
|
* |
|
34
|
|
|
* @return array<int, string> |
|
35
|
|
|
*/ |
|
36
|
|
|
public static function getAllNames() : array { |
|
37
|
|
|
return self::RACE_NAMES; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Race IDs for playable races only. Practically speaking, this is the |
|
42
|
|
|
* same as `getAllIDs` with the Neutral race excluded. |
|
43
|
|
|
* |
|
44
|
|
|
* Note: Some playable races may be excluded on a game-by-game basis |
|
45
|
|
|
* by omitting racial HQ locations. See SmrGame::getPlayableRaceIDs. |
|
46
|
|
|
* |
|
47
|
|
|
* @return array<int> |
|
48
|
|
|
*/ |
|
49
|
|
|
public static function getPlayableIDs() : array { |
|
50
|
|
|
$names = self::RACE_NAMES; |
|
51
|
|
|
unset($names[RACE_NEUTRAL]); |
|
52
|
|
|
return \array_keys($names); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Maps race IDs to race names for playable races. Practically speaking, |
|
57
|
|
|
* this is the same as `getAllNames` with the Neutral race excluded. |
|
58
|
|
|
* |
|
59
|
|
|
* Note: Some playable races may be excluded on a game-by-game basis |
|
60
|
|
|
* by omitting racial HQ locations. See SmrGame::getPlayableRaceIDs. |
|
61
|
|
|
* |
|
62
|
|
|
* @return array<int, string> |
|
63
|
|
|
*/ |
|
64
|
|
|
public static function getPlayableNames() : array { |
|
65
|
|
|
$names = self::RACE_NAMES; |
|
66
|
|
|
unset($names[RACE_NEUTRAL]); |
|
67
|
|
|
return $names; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public static function getName(int $raceID) : string { |
|
71
|
|
|
return self::RACE_NAMES[$raceID]; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Relative path to racial image file. |
|
76
|
|
|
*/ |
|
77
|
|
|
public static function getImage(int $raceID) : string { |
|
78
|
|
|
return 'images/race/race' . $raceID . '.jpg'; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Relative path to racial image file (portrait version). |
|
83
|
|
|
*/ |
|
84
|
|
|
public static function getHeadImage(int $raceID) : string { |
|
85
|
|
|
return 'images/race/head/race' . $raceID . '.jpg'; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
} |
|
89
|
|
|
|