feat: 12-planet catalog shared by JS and PHP, with Power miss chance
Aurel is Power 0 (60% miss), Cinder is Power 1 (5% miss). GameCore defaults missChance to the planet's Power formula; a third argument still overrides it. planets.json is the single source of truth.
@@ -0,0 +1,147 @@
1
<?php
2
declare(strict_types=1);
3
4
/**
5
* Planet catalog shared with the JS client (server/lib/planets.json).
6
* Power and miss-chance formulas must stay in lockstep with src/planet.js.
7
*/
8
final class Planets
9
{
10
private static ?array $all = null;
11
12
public static function path(): string
13
{
14
return __DIR__ . '/planets.json';
15
}
16
17
/** @return list<array> raw catalog entries */
18
public static function all(): array
19
{
20
if (self::$all !== null) {
21
return self::$all;
22
}
23
$raw = file_get_contents(self::path());
24
if ($raw === false) {
25
throw new RuntimeException('planets.json ontbreekt.');
26
}
27
$data = json_decode($raw, true);
28
if (!is_array($data) || !isset($data['planets']) || !is_array($data['planets'])) {
29
throw new RuntimeException('planets.json is ongeldig.');
30
}
31
self::$all = [];
32
foreach ($data['planets'] as $row) {
33
if (!is_array($row) || empty($row['id'])) {
34
continue;
35
}
36
self::$all[] = $row;
37
}
38
return self::$all;
39
}
40
41
public static function byId(string $id): ?array
42
{
43
foreach (self::all() as $p) {
44
if (($p['id'] ?? '') === $id) {
45
return $p;
46
}
47
}
48
return null;
49
}
50
51
public static function defaultId(): string
52
{
53
return 'terra';
54
}
55
56
public static function default(): array
57
{
58
return self::byId(self::defaultId()) ?? self::all()[0];
59
}
60
61
public static function known(string $id): bool
62
{
63
return self::byId($id) !== null;
64
}
65
66
/** Difficulty in 0..1. Higher is harder. */
67
public static function power(array $planet): float
68
{
69
$j = self::clamp((float) ($planet['jumpsToClear'] ?? 2), 1, 4);
70
$f = self::clamp((float) ($planet['fallTime'] ?? 3), 1, 5);
71
$r = self::clamp((float) ($planet['riseTime'] ?? 1.5), 0.5, 3);
72
$gravity = ($j - 1) / 3;
73
$air = (5 - $f) / 4;
74
$mass = (3 - $r) / 2.5;
75
return ($gravity + $air + $mass) / 3;
76
}
77
78
/** Miss chance: 0.60 at power 0, 0.05 at power 1. */
79
public static function missChance(array $planet): float
80
{
81
return 0.60 - 0.55 * self::power($planet);
82
}
83
84
public static function missChanceForId(string $id): float
85
{
86
$p = self::byId($id);
87
if ($p === null) {
88
$p = self::default();
89
}
90
return self::missChance($p);
91
}
92
93
/** @return array{gravity:float,density:float,newtons:float,power:int,missChance:float} */
94
public static function displayValues(array $planet): array
95
{
96
$j = self::clamp((float) ($planet['jumpsToClear'] ?? 2), 1, 4);
97
$f = self::clamp((float) ($planet['fallTime'] ?? 3), 1, 5);
98
$r = self::clamp((float) ($planet['riseTime'] ?? 1.5), 0.5, 3);
99
$power = self::power($planet);
100
return [
101
'gravity' => 9.81 * $j / 2,
102
'density' => 0.25 + ((5 - $f) / 4) * 1.60,
103
'newtons' => 40 + (($r - 0.5) / 2.5) * 160,
104
'power' => (int) round($power * 100),
105
'missChance' => 0.60 - 0.55 * $power,
106
];
107
}
108
109
/** Public subset sent to clients (no need to ship the full catalog again). */
110
public static function present(?string $id): array
111
{
112
$p = $id ? self::byId($id) : null;
113
if ($p === null) {
114
$p = self::default();
115
}
116
$d = self::displayValues($p);
117
$colors = [];
118
foreach ($p['colors'] ?? [] as $c) {
119
if (!is_array($c)) {
120
continue;
121
}
122
$colors[] = [
123
'id' => (int) ($c['id'] ?? 0),
124
'name' => (string) ($c['name'] ?? ''),
125
'hex' => (string) ($c['hex'] ?? '#888'),
126
'shape' => (string) ($c['shape'] ?? ''),
127
'image' => (string) ($c['image'] ?? ''),
128
];
129
}
130
return [
131
'id' => (string) $p['id'],
132
'name' => (string) $p['name'],
133
'people' => (string) $p['people'],
134
'jumpsToClear' => (float) $p['jumpsToClear'],
135
'fallTime' => (float) $p['fallTime'],
136
'riseTime' => (float) $p['riseTime'],
137
'miss_chance' => $d['missChance'],
138
'display' => $d,
139
'colors' => $colors,
140
];
141
}
142
143
private static function clamp(float $value, float $lo, float $hi): float
144
{
145
return max($lo, min($hi, $value));
146
}
147
}
@@ -0,0 +1,147 @@1
<?php2
declare(strict_types=1);3
4
/**5
* Planet catalog shared with the JS client (server/lib/planets.json).6
* Power and miss-chance formulas must stay in lockstep with src/planet.js.7
*/8
final class Planets9
{10
private static ?array $all = null;11
12
public static function path(): string13
{14
return __DIR__ . '/planets.json';15
}16
17
/** @return list<array> raw catalog entries */18
public static function all(): array19
{20
if (self::$all !== null) {21
return self::$all;22
}23
$raw = file_get_contents(self::path());24
if ($raw === false) {25
throw new RuntimeException('planets.json ontbreekt.');26
}27
$data = json_decode($raw, true);28
if (!is_array($data) || !isset($data['planets']) || !is_array($data['planets'])) {29
throw new RuntimeException('planets.json is ongeldig.');30
}31
self::$all = [];32
foreach ($data['planets'] as $row) {33
if (!is_array($row) || empty($row['id'])) {34
continue;35
}36
self::$all[] = $row;37
}38
return self::$all;39
}40
41
public static function byId(string $id): ?array42
{43
foreach (self::all() as $p) {44
if (($p['id'] ?? '') === $id) {45
return $p;46
}47
}48
return null;49
}50
51
public static function defaultId(): string52
{53
return 'terra';54
}55
56
public static function default(): array57
{58
return self::byId(self::defaultId()) ?? self::all()[0];59
}60
61
public static function known(string $id): bool62
{63
return self::byId($id) !== null;64
}65
66
/** Difficulty in 0..1. Higher is harder. */67
public static function power(array $planet): float68
{69
$j = self::clamp((float) ($planet['jumpsToClear'] ?? 2), 1, 4);70
$f = self::clamp((float) ($planet['fallTime'] ?? 3), 1, 5);71
$r = self::clamp((float) ($planet['riseTime'] ?? 1.5), 0.5, 3);72
$gravity = ($j - 1) / 3;73
$air = (5 - $f) / 4;74
$mass = (3 - $r) / 2.5;75
return ($gravity + $air + $mass) / 3;76
}77
78
/** Miss chance: 0.60 at power 0, 0.05 at power 1. */79
public static function missChance(array $planet): float80
{81
return 0.60 - 0.55 * self::power($planet);82
}83
84
public static function missChanceForId(string $id): float85
{86
$p = self::byId($id);87
if ($p === null) {88
$p = self::default();89
}90
return self::missChance($p);91
}92
93
/** @return array{gravity:float,density:float,newtons:float,power:int,missChance:float} */94
public static function displayValues(array $planet): array95
{96
$j = self::clamp((float) ($planet['jumpsToClear'] ?? 2), 1, 4);97
$f = self::clamp((float) ($planet['fallTime'] ?? 3), 1, 5);98
$r = self::clamp((float) ($planet['riseTime'] ?? 1.5), 0.5, 3);99
$power = self::power($planet);100
return [101
'gravity' => 9.81 * $j / 2,102
'density' => 0.25 + ((5 - $f) / 4) * 1.60,103
'newtons' => 40 + (($r - 0.5) / 2.5) * 160,104
'power' => (int) round($power * 100),105
'missChance' => 0.60 - 0.55 * $power,106
];107
}108
109
/** Public subset sent to clients (no need to ship the full catalog again). */110
public static function present(?string $id): array111
{112
$p = $id ? self::byId($id) : null;113
if ($p === null) {114
$p = self::default();115
}116
$d = self::displayValues($p);117
$colors = [];118
foreach ($p['colors'] ?? [] as $c) {119
if (!is_array($c)) {120
continue;121
}122
$colors[] = [123
'id' => (int) ($c['id'] ?? 0),124
'name' => (string) ($c['name'] ?? ''),125
'hex' => (string) ($c['hex'] ?? '#888'),126
'shape' => (string) ($c['shape'] ?? ''),127
'image' => (string) ($c['image'] ?? ''),128
];129
}130
return [131
'id' => (string) $p['id'],132
'name' => (string) $p['name'],133
'people' => (string) $p['people'],134
'jumpsToClear' => (float) $p['jumpsToClear'],135
'fallTime' => (float) $p['fallTime'],136
'riseTime' => (float) $p['riseTime'],137
'miss_chance' => $d['missChance'],138
'display' => $d,139
'colors' => $colors,140
];141
}142
143
private static function clamp(float $value, float $lo, float $hi): float144
{145
return max($lo, min($hi, $value));146
}147
}@@ -0,0 +1,184 @@
1
{
2
"planets": [
3
{
4
"id": "terra",
5
"name": "Terra",
6
"people": "Terrans",
7
"jumpsToClear": 2,
8
"fallTime": 3,
9
"riseTime": 1.5,
10
"colors": [
11
{"id": 0, "name": "ember", "hex": "#e85d3a", "shape": "triangle", "image": "images/block-terra-ember.png"},
12
{"id": 1, "name": "aqua", "hex": "#3db8e8", "shape": "circle", "image": "images/block-terra-aqua.png"},
13
{"id": 2, "name": "leaf", "hex": "#4cbf4c", "shape": "square", "image": "images/block-terra-leaf.png"},
14
{"id": 3, "name": "sun", "hex": "#f0c53a", "shape": "diamond", "image": "images/block-terra-sun.png"},
15
{"id": 4, "name": "orchid", "hex": "#c45ad4", "shape": "star", "image": "images/block-terra-orchid.png"}
16
]
17
},
18
{
19
"id": "aurel",
20
"name": "Aurel",
21
"people": "Aurelians",
22
"jumpsToClear": 1,
23
"fallTime": 5,
24
"riseTime": 3,
25
"colors": [
26
{"id": 0, "name": "gold", "hex": "#f4c860", "shape": "hexagon", "image": "images/block-aurel-gold.png"},
27
{"id": 1, "name": "cream", "hex": "#f6e7c1", "shape": "circle", "image": "images/block-aurel-cream.png"},
28
{"id": 2, "name": "amber", "hex": "#e09a3e", "shape": "teardrop", "image": "images/block-aurel-amber.png"},
29
{"id": 3, "name": "sage", "hex": "#8fb86f", "shape": "plus", "image": "images/block-aurel-sage.png"},
30
{"id": 4, "name": "rose", "hex": "#e8a0a8", "shape": "pentagon", "image": "images/block-aurel-rose.png"}
31
]
32
},
33
{
34
"id": "cinder",
35
"name": "Cinder",
36
"people": "Cindari",
37
"jumpsToClear": 4,
38
"fallTime": 1,
39
"riseTime": 0.5,
40
"colors": [
41
{"id": 0, "name": "magma", "hex": "#ff3b1f", "shape": "triangle", "image": "images/block-cinder-magma.png"},
42
{"id": 1, "name": "coal", "hex": "#3a3232", "shape": "square", "image": "images/block-cinder-coal.png"},
43
{"id": 2, "name": "spark", "hex": "#ffb347", "shape": "diamond", "image": "images/block-cinder-spark.png"},
44
{"id": 3, "name": "ash", "hex": "#8a7a76", "shape": "circle", "image": "images/block-cinder-ash.png"},
45
{"id": 4, "name": "core", "hex": "#ff6a00", "shape": "star", "image": "images/block-cinder-core.png"}
46
]
47
},
48
{
49
"id": "lunara",
50
"name": "Lunara",
51
"people": "Lunarites",
52
"jumpsToClear": 1,
53
"fallTime": 2,
54
"riseTime": 1.2,
55
"colors": [
56
{"id": 0, "name": "silver", "hex": "#c5d0e0", "shape": "circle", "image": "images/block-lunara-silver.png"},
57
{"id": 1, "name": "dust", "hex": "#8b90a0", "shape": "diamond", "image": "images/block-lunara-dust.png"},
58
{"id": 2, "name": "pale", "hex": "#e8d9a8", "shape": "crescent", "image": "images/block-lunara-pale.png"},
59
{"id": 3, "name": "void", "hex": "#2c3348", "shape": "square", "image": "images/block-lunara-void.png"},
60
{"id": 4, "name": "lilac", "hex": "#b9a4d4", "shape": "star", "image": "images/block-lunara-lilac.png"}
61
]
62
},
63
{
64
"id": "mire",
65
"name": "Mire",
66
"people": "Mirians",
67
"jumpsToClear": 2,
68
"fallTime": 5,
69
"riseTime": 2.5,
70
"colors": [
71
{"id": 0, "name": "moss", "hex": "#3d7a45", "shape": "hexagon", "image": "images/block-mire-moss.png"},
72
{"id": 1, "name": "bog", "hex": "#1f4d3a", "shape": "teardrop", "image": "images/block-mire-bog.png"},
73
{"id": 2, "name": "rust", "hex": "#8b5a2b", "shape": "pentagon", "image": "images/block-mire-rust.png"},
74
{"id": 3, "name": "spore", "hex": "#9cbf5a", "shape": "circle", "image": "images/block-mire-spore.png"},
75
{"id": 4, "name": "murk", "hex": "#2e3b2f", "shape": "diamond", "image": "images/block-mire-murk.png"}
76
]
77
},
78
{
79
"id": "galeon",
80
"name": "Galeon",
81
"people": "Galeoni",
82
"jumpsToClear": 3,
83
"fallTime": 1,
84
"riseTime": 1.8,
85
"colors": [
86
{"id": 0, "name": "sky", "hex": "#4aa3ff", "shape": "arrow", "image": "images/block-galeon-sky.png"},
87
{"id": 1, "name": "cloud", "hex": "#e8eef6", "shape": "circle", "image": "images/block-galeon-cloud.png"},
88
{"id": 2, "name": "storm", "hex": "#3d4d6e", "shape": "square", "image": "images/block-galeon-storm.png"},
89
{"id": 3, "name": "sand", "hex": "#d4b483", "shape": "diamond","image": "images/block-galeon-sand.png"},
90
{"id": 4, "name": "kite", "hex": "#7fd0c0", "shape": "star", "image": "images/block-galeon-kite.png"}
91
]
92
},
93
{
94
"id": "obsid",
95
"name": "Obsid",
96
"people": "Obsidians",
97
"jumpsToClear": 4,
98
"fallTime": 3.5,
99
"riseTime": 2.2,
100
"colors": [
101
{"id": 0, "name": "glass", "hex": "#1a1a22", "shape": "gem", "image": "images/block-obsid-glass.png"},
102
{"id": 1, "name": "violet","hex": "#5a3d8a", "shape": "hexagon", "image": "images/block-obsid-violet.png"},
103
{"id": 2, "name": "shard", "hex": "#8a8aa0", "shape": "triangle", "image": "images/block-obsid-shard.png"},
104
{"id": 3, "name": "vein", "hex": "#c45a3a", "shape": "diamond", "image": "images/block-obsid-vein.png"},
105
{"id": 4, "name": "basalt","hex": "#3a3a42", "shape": "square", "image": "images/block-obsid-basalt.png"}
106
]
107
},
108
{
109
"id": "wisp",
110
"name": "Wisp",
111
"people": "Wisplings",
112
"jumpsToClear": 2,
113
"fallTime": 3.5,
114
"riseTime": 0.5,
115
"colors": [
116
{"id": 0, "name": "glow", "hex": "#c8ffe0", "shape": "circle", "image": "images/block-wisp-glow.png"},
117
{"id": 1, "name": "mist", "hex": "#a8d4e8", "shape": "diamond", "image": "images/block-wisp-mist.png"},
118
{"id": 2, "name": "sparkle", "hex": "#fff6a8", "shape": "star", "image": "images/block-wisp-sparkle.png"},
119
{"id": 3, "name": "veil", "hex": "#d0b8f0", "shape": "teardrop", "image": "images/block-wisp-veil.png"},
120
{"id": 4, "name": "gleam", "hex": "#f4f7ff", "shape": "plus", "image": "images/block-wisp-gleam.png"}
121
]
122
},
123
{
124
"id": "thorn",
125
"name": "Thorn",
126
"people": "Thornfolk",
127
"jumpsToClear": 3,
128
"fallTime": 2,
129
"riseTime": 1.0,
130
"colors": [
131
{"id": 0, "name": "briar", "hex": "#5a7a30", "shape": "triangle", "image": "images/block-thorn-briar.png"},
132
{"id": 1, "name": "berry", "hex": "#8b1a4a", "shape": "circle", "image": "images/block-thorn-berry.png"},
133
{"id": 2, "name": "bark", "hex": "#5a3a20", "shape": "square", "image": "images/block-thorn-bark.png"},
134
{"id": 3, "name": "petal", "hex": "#e89ab0", "shape": "diamond", "image": "images/block-thorn-petal.png"},
135
{"id": 4, "name": "gold", "hex": "#c8a030", "shape": "star", "image": "images/block-thorn-gold.png"}
136
]
137
},
138
{
139
"id": "zephyr",
140
"name": "Zephyr",
141
"people": "Zephyrites",
142
"jumpsToClear": 1,
143
"fallTime": 1.2,
144
"riseTime": 2.8,
145
"colors": [
146
{"id": 0, "name": "azure", "hex": "#6ec8ff", "shape": "crescent", "image": "images/block-zephyr-azure.png"},
147
{"id": 1, "name": "breeze","hex": "#b8e8ff", "shape": "circle", "image": "images/block-zephyr-breeze.png"},
148
{"id": 2, "name": "cirrus","hex": "#f0f7ff", "shape": "plus", "image": "images/block-zephyr-cirrus.png"},
149
{"id": 3, "name": "dusk", "hex": "#7a6ab0", "shape": "diamond", "image": "images/block-zephyr-dusk.png"},
150
{"id": 4, "name": "haze", "hex": "#ffe08a", "shape": "star", "image": "images/block-zephyr-haze.png"}
151
]
152
},
153
{
154
"id": "frore",
155
"name": "Frore",
156
"people": "Frorians",
157
"jumpsToClear": 3,
158
"fallTime": 4.5,
159
"riseTime": 0.8,
160
"colors": [
161
{"id": 0, "name": "ice", "hex": "#a8d8f0", "shape": "hexagon", "image": "images/block-frore-ice.png"},
162
{"id": 1, "name": "frost", "hex": "#eef7ff", "shape": "circle", "image": "images/block-frore-frost.png"},
163
{"id": 2, "name": "deep", "hex": "#3a6a8a", "shape": "diamond", "image": "images/block-frore-deep.png"},
164
{"id": 3, "name": "aurora", "hex": "#5ae8c0", "shape": "star", "image": "images/block-frore-aurora.png"},
165
{"id": 4, "name": "rime", "hex": "#d0e4f0", "shape": "triangle", "image": "images/block-frore-rime.png"}
166
]
167
},
168
{
169
"id": "forge",
170
"name": "Forge",
171
"people": "Forgelings",
172
"jumpsToClear": 4,
173
"fallTime": 2,
174
"riseTime": 1.5,
175
"colors": [
176
{"id": 0, "name": "iron", "hex": "#6a6a72", "shape": "square", "image": "images/block-forge-iron.png"},
177
{"id": 1, "name": "slag", "hex": "#3a3028", "shape": "hexagon", "image": "images/block-forge-slag.png"},
178
{"id": 2, "name": "spark", "hex": "#ff7a1a", "shape": "triangle", "image": "images/block-forge-spark.png"},
179
{"id": 3, "name": "brass", "hex": "#c8a048", "shape": "diamond", "image": "images/block-forge-brass.png"},
180
{"id": 4, "name": "soot", "hex": "#2a2a28", "shape": "circle", "image": "images/block-forge-soot.png"}
181
]
182
}
183
]
184
}
@@ -0,0 +1,184 @@1
{2
"planets": [3
{4
"id": "terra",5
"name": "Terra",6
"people": "Terrans",7
"jumpsToClear": 2,8
"fallTime": 3,9
"riseTime": 1.5,10
"colors": [11
{"id": 0, "name": "ember", "hex": "#e85d3a", "shape": "triangle", "image": "images/block-terra-ember.png"},12
{"id": 1, "name": "aqua", "hex": "#3db8e8", "shape": "circle", "image": "images/block-terra-aqua.png"},13
{"id": 2, "name": "leaf", "hex": "#4cbf4c", "shape": "square", "image": "images/block-terra-leaf.png"},14
{"id": 3, "name": "sun", "hex": "#f0c53a", "shape": "diamond", "image": "images/block-terra-sun.png"},15
{"id": 4, "name": "orchid", "hex": "#c45ad4", "shape": "star", "image": "images/block-terra-orchid.png"}16
]17
},18
{19
"id": "aurel",20
"name": "Aurel",21
"people": "Aurelians",22
"jumpsToClear": 1,23
"fallTime": 5,24
"riseTime": 3,25
"colors": [26
{"id": 0, "name": "gold", "hex": "#f4c860", "shape": "hexagon", "image": "images/block-aurel-gold.png"},27
{"id": 1, "name": "cream", "hex": "#f6e7c1", "shape": "circle", "image": "images/block-aurel-cream.png"},28
{"id": 2, "name": "amber", "hex": "#e09a3e", "shape": "teardrop", "image": "images/block-aurel-amber.png"},29
{"id": 3, "name": "sage", "hex": "#8fb86f", "shape": "plus", "image": "images/block-aurel-sage.png"},30
{"id": 4, "name": "rose", "hex": "#e8a0a8", "shape": "pentagon", "image": "images/block-aurel-rose.png"}31
]32
},33
{34
"id": "cinder",35
"name": "Cinder",36
"people": "Cindari",37
"jumpsToClear": 4,38
"fallTime": 1,39
"riseTime": 0.5,40
"colors": [41
{"id": 0, "name": "magma", "hex": "#ff3b1f", "shape": "triangle", "image": "images/block-cinder-magma.png"},42
{"id": 1, "name": "coal", "hex": "#3a3232", "shape": "square", "image": "images/block-cinder-coal.png"},43
{"id": 2, "name": "spark", "hex": "#ffb347", "shape": "diamond", "image": "images/block-cinder-spark.png"},44
{"id": 3, "name": "ash", "hex": "#8a7a76", "shape": "circle", "image": "images/block-cinder-ash.png"},45
{"id": 4, "name": "core", "hex": "#ff6a00", "shape": "star", "image": "images/block-cinder-core.png"}46
]47
},48
{49
"id": "lunara",50
"name": "Lunara",51
"people": "Lunarites",52
"jumpsToClear": 1,53
"fallTime": 2,54
"riseTime": 1.2,55
"colors": [56
{"id": 0, "name": "silver", "hex": "#c5d0e0", "shape": "circle", "image": "images/block-lunara-silver.png"},57
{"id": 1, "name": "dust", "hex": "#8b90a0", "shape": "diamond", "image": "images/block-lunara-dust.png"},58
{"id": 2, "name": "pale", "hex": "#e8d9a8", "shape": "crescent", "image": "images/block-lunara-pale.png"},59
{"id": 3, "name": "void", "hex": "#2c3348", "shape": "square", "image": "images/block-lunara-void.png"},60
{"id": 4, "name": "lilac", "hex": "#b9a4d4", "shape": "star", "image": "images/block-lunara-lilac.png"}61
]62
},63
{64
"id": "mire",65
"name": "Mire",66
"people": "Mirians",67
"jumpsToClear": 2,68
"fallTime": 5,69
"riseTime": 2.5,70
"colors": [71
{"id": 0, "name": "moss", "hex": "#3d7a45", "shape": "hexagon", "image": "images/block-mire-moss.png"},72
{"id": 1, "name": "bog", "hex": "#1f4d3a", "shape": "teardrop", "image": "images/block-mire-bog.png"},73
{"id": 2, "name": "rust", "hex": "#8b5a2b", "shape": "pentagon", "image": "images/block-mire-rust.png"},74
{"id": 3, "name": "spore", "hex": "#9cbf5a", "shape": "circle", "image": "images/block-mire-spore.png"},75
{"id": 4, "name": "murk", "hex": "#2e3b2f", "shape": "diamond", "image": "images/block-mire-murk.png"}76
]77
},78
{79
"id": "galeon",80
"name": "Galeon",81
"people": "Galeoni",82
"jumpsToClear": 3,83
"fallTime": 1,84
"riseTime": 1.8,85
"colors": [86
{"id": 0, "name": "sky", "hex": "#4aa3ff", "shape": "arrow", "image": "images/block-galeon-sky.png"},87
{"id": 1, "name": "cloud", "hex": "#e8eef6", "shape": "circle", "image": "images/block-galeon-cloud.png"},88
{"id": 2, "name": "storm", "hex": "#3d4d6e", "shape": "square", "image": "images/block-galeon-storm.png"},89
{"id": 3, "name": "sand", "hex": "#d4b483", "shape": "diamond","image": "images/block-galeon-sand.png"},90
{"id": 4, "name": "kite", "hex": "#7fd0c0", "shape": "star", "image": "images/block-galeon-kite.png"}91
]92
},93
{94
"id": "obsid",95
"name": "Obsid",96
"people": "Obsidians",97
"jumpsToClear": 4,98
"fallTime": 3.5,99
"riseTime": 2.2,100
"colors": [101
{"id": 0, "name": "glass", "hex": "#1a1a22", "shape": "gem", "image": "images/block-obsid-glass.png"},102
{"id": 1, "name": "violet","hex": "#5a3d8a", "shape": "hexagon", "image": "images/block-obsid-violet.png"},103
{"id": 2, "name": "shard", "hex": "#8a8aa0", "shape": "triangle", "image": "images/block-obsid-shard.png"},104
{"id": 3, "name": "vein", "hex": "#c45a3a", "shape": "diamond", "image": "images/block-obsid-vein.png"},105
{"id": 4, "name": "basalt","hex": "#3a3a42", "shape": "square", "image": "images/block-obsid-basalt.png"}106
]107
},108
{109
"id": "wisp",110
"name": "Wisp",111
"people": "Wisplings",112
"jumpsToClear": 2,113
"fallTime": 3.5,114
"riseTime": 0.5,115
"colors": [116
{"id": 0, "name": "glow", "hex": "#c8ffe0", "shape": "circle", "image": "images/block-wisp-glow.png"},117
{"id": 1, "name": "mist", "hex": "#a8d4e8", "shape": "diamond", "image": "images/block-wisp-mist.png"},118
{"id": 2, "name": "sparkle", "hex": "#fff6a8", "shape": "star", "image": "images/block-wisp-sparkle.png"},119
{"id": 3, "name": "veil", "hex": "#d0b8f0", "shape": "teardrop", "image": "images/block-wisp-veil.png"},120
{"id": 4, "name": "gleam", "hex": "#f4f7ff", "shape": "plus", "image": "images/block-wisp-gleam.png"}121
]122
},123
{124
"id": "thorn",125
"name": "Thorn",126
"people": "Thornfolk",127
"jumpsToClear": 3,128
"fallTime": 2,129
"riseTime": 1.0,130
"colors": [131
{"id": 0, "name": "briar", "hex": "#5a7a30", "shape": "triangle", "image": "images/block-thorn-briar.png"},132
{"id": 1, "name": "berry", "hex": "#8b1a4a", "shape": "circle", "image": "images/block-thorn-berry.png"},133
{"id": 2, "name": "bark", "hex": "#5a3a20", "shape": "square", "image": "images/block-thorn-bark.png"},134
{"id": 3, "name": "petal", "hex": "#e89ab0", "shape": "diamond", "image": "images/block-thorn-petal.png"},135
{"id": 4, "name": "gold", "hex": "#c8a030", "shape": "star", "image": "images/block-thorn-gold.png"}136
]137
},138
{139
"id": "zephyr",140
"name": "Zephyr",141
"people": "Zephyrites",142
"jumpsToClear": 1,143
"fallTime": 1.2,144
"riseTime": 2.8,145
"colors": [146
{"id": 0, "name": "azure", "hex": "#6ec8ff", "shape": "crescent", "image": "images/block-zephyr-azure.png"},147
{"id": 1, "name": "breeze","hex": "#b8e8ff", "shape": "circle", "image": "images/block-zephyr-breeze.png"},148
{"id": 2, "name": "cirrus","hex": "#f0f7ff", "shape": "plus", "image": "images/block-zephyr-cirrus.png"},149
{"id": 3, "name": "dusk", "hex": "#7a6ab0", "shape": "diamond", "image": "images/block-zephyr-dusk.png"},150
{"id": 4, "name": "haze", "hex": "#ffe08a", "shape": "star", "image": "images/block-zephyr-haze.png"}151
]152
},153
{154
"id": "frore",155
"name": "Frore",156
"people": "Frorians",157
"jumpsToClear": 3,158
"fallTime": 4.5,159
"riseTime": 0.8,160
"colors": [161
{"id": 0, "name": "ice", "hex": "#a8d8f0", "shape": "hexagon", "image": "images/block-frore-ice.png"},162
{"id": 1, "name": "frost", "hex": "#eef7ff", "shape": "circle", "image": "images/block-frore-frost.png"},163
{"id": 2, "name": "deep", "hex": "#3a6a8a", "shape": "diamond", "image": "images/block-frore-deep.png"},164
{"id": 3, "name": "aurora", "hex": "#5ae8c0", "shape": "star", "image": "images/block-frore-aurora.png"},165
{"id": 4, "name": "rime", "hex": "#d0e4f0", "shape": "triangle", "image": "images/block-frore-rime.png"}166
]167
},168
{169
"id": "forge",170
"name": "Forge",171
"people": "Forgelings",172
"jumpsToClear": 4,173
"fallTime": 2,174
"riseTime": 1.5,175
"colors": [176
{"id": 0, "name": "iron", "hex": "#6a6a72", "shape": "square", "image": "images/block-forge-iron.png"},177
{"id": 1, "name": "slag", "hex": "#3a3028", "shape": "hexagon", "image": "images/block-forge-slag.png"},178
{"id": 2, "name": "spark", "hex": "#ff7a1a", "shape": "triangle", "image": "images/block-forge-spark.png"},179
{"id": 3, "name": "brass", "hex": "#c8a048", "shape": "diamond", "image": "images/block-forge-brass.png"},180
{"id": 4, "name": "soot", "hex": "#2a2a28", "shape": "circle", "image": "images/block-forge-soot.png"}181
]182
}183
]184
}@@ -26,6 +26,9 @@ FILES=(
26
26
printf '%s\n' " * AUTO-GENERATED FILE — DO NOT EDIT BY HAND."
27
27
printf '%s\n' " * Built by src/build.sh from the sources in src/."
28
28
printf '%s\n' " */"
29
printf '%s' "var PLANET_CATALOG = "
30
cat "$ROOT/server/lib/planets.json"
31
printf ';\n'
29
32
} >> "$BUILD_FILE"
30
33
31
34
for file in "${FILES[@]}"
@@ -48,7 +51,9 @@ cp -f "$SERVER/api.php" "$SERVER/auth.php" "$SERVER/callback.php" \
48
51
"$SERVER/logout.php" "$SERVER/router.php" "$SERVER/.htaccess" \
49
52
"$ROOT/build/"
50
53
mkdir -p "$ROOT/build/lib"
51
cp -f "$SERVER/lib/bootstrap.php" "$SERVER/lib/Store.php" "$ROOT/build/lib/"
54
cp -f "$SERVER/lib/bootstrap.php" "$SERVER/lib/Store.php" \
55
"$SERVER/lib/Planets.php" "$SERVER/lib/planets.json" \
56
"$ROOT/build/lib/"
52
57
mkdir -p "$ROOT/build/data"
53
58
cp -f "$SERVER/data/.htaccess" "$ROOT/build/data/.htaccess"
54
59
# Belt and braces: a leftover local config or db must never enter build/.
@@ -26,6 +26,9 @@ FILES=(26
printf '%s\n' " * AUTO-GENERATED FILE — DO NOT EDIT BY HAND."26
printf '%s\n' " * AUTO-GENERATED FILE — DO NOT EDIT BY HAND."27
printf '%s\n' " * Built by src/build.sh from the sources in src/."27
printf '%s\n' " * Built by src/build.sh from the sources in src/."28
printf '%s\n' " */"28
printf '%s\n' " */"29
printf '%s' "var PLANET_CATALOG = "30
cat "$ROOT/server/lib/planets.json"31
printf ';\n'29
} >> "$BUILD_FILE"32
} >> "$BUILD_FILE"30
33
31
for file in "${FILES[@]}"34
for file in "${FILES[@]}"@@ -48,7 +51,9 @@ cp -f "$SERVER/api.php" "$SERVER/auth.php" "$SERVER/callback.php" \48
"$SERVER/logout.php" "$SERVER/router.php" "$SERVER/.htaccess" \51
"$SERVER/logout.php" "$SERVER/router.php" "$SERVER/.htaccess" \49
"$ROOT/build/"52
"$ROOT/build/"50
mkdir -p "$ROOT/build/lib"53
mkdir -p "$ROOT/build/lib"51
cp -f "$SERVER/lib/bootstrap.php" "$SERVER/lib/Store.php" "$ROOT/build/lib/"54
cp -f "$SERVER/lib/bootstrap.php" "$SERVER/lib/Store.php" \55
"$SERVER/lib/Planets.php" "$SERVER/lib/planets.json" \56
"$ROOT/build/lib/"52
mkdir -p "$ROOT/build/data"57
mkdir -p "$ROOT/build/data"53
cp -f "$SERVER/data/.htaccess" "$ROOT/build/data/.htaccess"58
cp -f "$SERVER/data/.htaccess" "$ROOT/build/data/.htaccess"54
# Belt and braces: a leftover local config or db must never enter build/.59
# Belt and braces: a leftover local config or db must never enter build/.@@ -87,6 +87,9 @@ function optsMissChance (args)
87
87
// GameCore(planet, rng, missChance) — third arg is optional.
88
88
if (args.length >= 3 && typeof args[2] === 'number' && isFinite(args[2]))
89
89
{ return Math.max(0, Math.min(1, args[2])); }
90
var planet = args[0];
91
if (planet && typeof PlanetMod.missChance === 'function')
92
{ return PlanetMod.missChance(planet); }
90
93
return GameCore.DEFAULT_MISS_CHANCE;
91
94
}
92
95
@@ -87,6 +87,9 @@ function optsMissChance (args)87
// GameCore(planet, rng, missChance) — third arg is optional.87
// GameCore(planet, rng, missChance) — third arg is optional.88
if (args.length >= 3 && typeof args[2] === 'number' && isFinite(args[2]))88
if (args.length >= 3 && typeof args[2] === 'number' && isFinite(args[2]))89
{ return Math.max(0, Math.min(1, args[2])); }89
{ return Math.max(0, Math.min(1, args[2])); }90
var planet = args[0];91
if (planet && typeof PlanetMod.missChance === 'function')92
{ return PlanetMod.missChance(planet); }90
return GameCore.DEFAULT_MISS_CHANCE;93
return GameCore.DEFAULT_MISS_CHANCE;91
}94
}92
95
@@ -51,6 +51,7 @@ function createPlanet (opts)
51
51
var riseTime = clamp(opts.riseTime == null ? 1.5 : opts.riseTime, 0.5, 3);
52
52
var colors = opts.colors || defaultColors();
53
53
var planet = {
54
id: opts.id || null,
54
55
name: opts.name || 'Terra',
55
56
people: opts.people || 'Terrans',
56
57
jumpsToClear: jumpsToClear,
@@ -70,15 +71,82 @@ function createPlanet (opts)
70
71
return planet;
71
72
}
72
73
73
function defaultPlanet ()
74
function loadCatalog ()
75
{
76
if (typeof PLANET_CATALOG !== 'undefined' && PLANET_CATALOG && PLANET_CATALOG.planets)
77
{ return PLANET_CATALOG; }
78
if (typeof require !== 'undefined')
79
{
80
try
81
{ return require('../server/lib/planets.json'); }
82
catch (e) {}
83
}
84
return { planets: [] };
85
}
86
87
function planetFromData (data)
74
88
{
75
return createPlanet({
76
name: 'Terra',
77
people: 'Terrans',
78
jumpsToClear: 2,
79
fallTime: 3,
80
riseTime: 1.5
89
var planet = createPlanet({
90
name: data.name,
91
people: data.people,
92
jumpsToClear: data.jumpsToClear,
93
fallTime: data.fallTime,
94
riseTime: data.riseTime,
95
colors: data.colors
81
96
});
97
planet.id = data.id;
98
return planet;
99
}
100
101
function allPlanets ()
102
{
103
var raw = loadCatalog().planets || [];
104
var out = [];
105
for (var i = 0; i < raw.length; i++)
106
{ out.push(planetFromData(raw[i])); }
107
if (out.length === 0)
108
{ out.push(createPlanet({ name: 'Terra', people: 'Terrans', jumpsToClear: 2, fallTime: 3, riseTime: 1.5 })); out[0].id = 'terra'; }
109
return out;
110
}
111
112
function planetById (id)
113
{
114
var all = allPlanets();
115
for (var i = 0; i < all.length; i++)
116
{
117
if (all[i].id === id)
118
{ return all[i]; }
119
}
120
return defaultPlanet();
121
}
122
123
function defaultPlanet ()
124
{
125
var all = allPlanets();
126
for (var i = 0; i < all.length; i++)
127
{
128
if (all[i].id === 'terra')
129
{ return all[i]; }
130
}
131
return all[0];
132
}
133
134
function formatStats (planet)
135
{
136
var d = displayValues(planet);
137
return 'g ' + d.gravity.toFixed(2)
138
+ ' d ' + d.density.toFixed(2)
139
+ ' F ' + Math.round(d.newtons) + ' N'
140
+ ' Power ' + d.power + '%';
141
}
142
143
function spriteKey (planet, colorIndex)
144
{
145
var colors = planet && planet.colors;
146
var c = colors && colors[colorIndex];
147
if (!c)
148
{ return 'gray'; }
149
return (planet.id || 'planet') + '-' + (c.name || String(colorIndex));
82
150
}
83
151
84
152
/**
@@ -158,6 +226,11 @@ var Planet = {
158
226
createPlanet: createPlanet,
159
227
defaultPlanet: defaultPlanet,
160
228
defaultColors: defaultColors,
229
allPlanets: allPlanets,
230
planetById: planetById,
231
planetFromData: planetFromData,
232
formatStats: formatStats,
233
spriteKey: spriteKey,
161
234
jumpHeight: jumpHeight,
162
235
launchVelocity: launchVelocity,
163
236
launchDeceleration: launchDeceleration,
@@ -51,6 +51,7 @@ function createPlanet (opts)51
var riseTime = clamp(opts.riseTime == null ? 1.5 : opts.riseTime, 0.5, 3);51
var riseTime = clamp(opts.riseTime == null ? 1.5 : opts.riseTime, 0.5, 3);52
var colors = opts.colors || defaultColors();52
var colors = opts.colors || defaultColors();53
var planet = {53
var planet = {54
id: opts.id || null,54
name: opts.name || 'Terra',55
name: opts.name || 'Terra',55
people: opts.people || 'Terrans',56
people: opts.people || 'Terrans',56
jumpsToClear: jumpsToClear,57
jumpsToClear: jumpsToClear,@@ -70,15 +71,82 @@ function createPlanet (opts)70
return planet;71
return planet;71
}72
}72
73
73
function defaultPlanet ()74
function loadCatalog ()75
{76
if (typeof PLANET_CATALOG !== 'undefined' && PLANET_CATALOG && PLANET_CATALOG.planets)77
{ return PLANET_CATALOG; }78
if (typeof require !== 'undefined')79
{80
try81
{ return require('../server/lib/planets.json'); }82
catch (e) {}83
}84
return { planets: [] };85
}86
87
function planetFromData (data)74
{88
{75
return createPlanet({89
var planet = createPlanet({76
name: 'Terra',90
name: data.name,77
people: 'Terrans',91
people: data.people,78
jumpsToClear: 2,92
jumpsToClear: data.jumpsToClear,79
fallTime: 3,93
fallTime: data.fallTime,80
riseTime: 1.594
riseTime: data.riseTime,95
colors: data.colors81
});96
});97
planet.id = data.id;98
return planet;99
}100
101
function allPlanets ()102
{103
var raw = loadCatalog().planets || [];104
var out = [];105
for (var i = 0; i < raw.length; i++)106
{ out.push(planetFromData(raw[i])); }107
if (out.length === 0)108
{ out.push(createPlanet({ name: 'Terra', people: 'Terrans', jumpsToClear: 2, fallTime: 3, riseTime: 1.5 })); out[0].id = 'terra'; }109
return out;110
}111
112
function planetById (id)113
{114
var all = allPlanets();115
for (var i = 0; i < all.length; i++)116
{117
if (all[i].id === id)118
{ return all[i]; }119
}120
return defaultPlanet();121
}122
123
function defaultPlanet ()124
{125
var all = allPlanets();126
for (var i = 0; i < all.length; i++)127
{128
if (all[i].id === 'terra')129
{ return all[i]; }130
}131
return all[0];132
}133
134
function formatStats (planet)135
{136
var d = displayValues(planet);137
return 'g ' + d.gravity.toFixed(2)138
+ ' d ' + d.density.toFixed(2)139
+ ' F ' + Math.round(d.newtons) + ' N'140
+ ' Power ' + d.power + '%';141
}142
143
function spriteKey (planet, colorIndex)144
{145
var colors = planet && planet.colors;146
var c = colors && colors[colorIndex];147
if (!c)148
{ return 'gray'; }149
return (planet.id || 'planet') + '-' + (c.name || String(colorIndex));82
}150
}83
151
84
/**152
/**@@ -158,6 +226,11 @@ var Planet = {158
createPlanet: createPlanet,226
createPlanet: createPlanet,159
defaultPlanet: defaultPlanet,227
defaultPlanet: defaultPlanet,160
defaultColors: defaultColors,228
defaultColors: defaultColors,229
allPlanets: allPlanets,230
planetById: planetById,231
planetFromData: planetFromData,232
formatStats: formatStats,233
spriteKey: spriteKey,161
jumpHeight: jumpHeight,234
jumpHeight: jumpHeight,162
launchVelocity: launchVelocity,235
launchVelocity: launchVelocity,163
launchDeceleration: launchDeceleration,236
launchDeceleration: launchDeceleration,@@ -67,18 +67,21 @@ describe('Outgoing shots and incoming garbage', () =>
67
67
assert.equal(g.ingestGarbage(), null);
68
68
});
69
69
70
it('missChance is a parameter defaulting to 0.30, independent of planet Power', () =>
70
it('missChance defaults to the planet Power formula and can still be overridden', () =>
71
71
{
72
72
const g = makeGame({ noSpawn: true });
73
assert.equal(g.missChance, 0.30);
73
const terraMiss = Planet.missChance(Planet.defaultPlanet());
74
assert.ok(Math.abs(g.missChance - terraMiss) < 1e-12);
75
assert.ok(Math.abs(terraMiss - 0.30) > 0.01, 'Terra Power miss is not the old flat 30%');
74
76
assert.equal(GameCore.DEFAULT_MISS_CHANCE, 0.30);
75
77
const custom = new GameCore(Planet.defaultPlanet(), Math.random, 0.05);
76
78
assert.equal(custom.missChance, 0.05);
77
79
const clamped = new GameCore(Planet.defaultPlanet(), Math.random, 2);
78
80
assert.equal(clamped.missChance, 1);
79
// Planet.missChance stays the stage-3 Power formula, unused here.
80
const terraMiss = Planet.missChance(Planet.defaultPlanet());
81
assert.ok(Math.abs(terraMiss - 0.30) > 0.01, 'Terra Power miss is not the stage-2 30%');
81
const cinder = new GameCore(Planet.planetById('cinder'), Math.random);
82
assert.ok(Math.abs(cinder.missChance - 0.05) < 1e-12);
83
const aurel = new GameCore(Planet.planetById('aurel'), Math.random);
84
assert.ok(Math.abs(aurel.missChance - 0.60) < 1e-12);
82
85
});
83
86
84
87
it('fieldSnapshot lists every block for opponent miniatures', () =>
@@ -67,18 +67,21 @@ describe('Outgoing shots and incoming garbage', () =>67
assert.equal(g.ingestGarbage(), null);67
assert.equal(g.ingestGarbage(), null);68
});68
});69
69
70
it('missChance is a parameter defaulting to 0.30, independent of planet Power', () =>70
it('missChance defaults to the planet Power formula and can still be overridden', () =>71
{71
{72
const g = makeGame({ noSpawn: true });72
const g = makeGame({ noSpawn: true });73
assert.equal(g.missChance, 0.30);73
const terraMiss = Planet.missChance(Planet.defaultPlanet());74
assert.ok(Math.abs(g.missChance - terraMiss) < 1e-12);75
assert.ok(Math.abs(terraMiss - 0.30) > 0.01, 'Terra Power miss is not the old flat 30%');74
assert.equal(GameCore.DEFAULT_MISS_CHANCE, 0.30);76
assert.equal(GameCore.DEFAULT_MISS_CHANCE, 0.30);75
const custom = new GameCore(Planet.defaultPlanet(), Math.random, 0.05);77
const custom = new GameCore(Planet.defaultPlanet(), Math.random, 0.05);76
assert.equal(custom.missChance, 0.05);78
assert.equal(custom.missChance, 0.05);77
const clamped = new GameCore(Planet.defaultPlanet(), Math.random, 2);79
const clamped = new GameCore(Planet.defaultPlanet(), Math.random, 2);78
assert.equal(clamped.missChance, 1);80
assert.equal(clamped.missChance, 1);79
// Planet.missChance stays the stage-3 Power formula, unused here.81
const cinder = new GameCore(Planet.planetById('cinder'), Math.random);80
const terraMiss = Planet.missChance(Planet.defaultPlanet());82
assert.ok(Math.abs(cinder.missChance - 0.05) < 1e-12);81
assert.ok(Math.abs(terraMiss - 0.30) > 0.01, 'Terra Power miss is not the stage-2 30%');83
const aurel = new GameCore(Planet.planetById('aurel'), Math.random);84
assert.ok(Math.abs(aurel.missChance - 0.60) < 1e-12);82
});85
});83
86
84
it('fieldSnapshot lists every block for opponent miniatures', () =>87
it('fieldSnapshot lists every block for opponent miniatures', () =>@@ -157,3 +157,47 @@ describe('Power and display values', () =>
157
157
assert.ok(Math.abs(d.gravity - 9.81) < 1e-9);
158
158
});
159
159
});
160
161
describe('Planet catalog', () =>
162
{
163
it('has 8–12 named worlds, each with a people name and five unique shapes', () =>
164
{
165
const all = Planet.allPlanets();
166
assert.ok(all.length >= 8 && all.length <= 12, 'catalog size ' + all.length);
167
const ids = new Set();
168
const images = new Set();
169
for (const p of all)
170
{
171
assert.ok(p.id && p.name && p.people, p.id);
172
assert.ok(!ids.has(p.id), 'duplicate id ' + p.id);
173
ids.add(p.id);
174
assert.equal(p.colors.length, 5);
175
const shapes = new Set(p.colors.map((c) => c.shape));
176
assert.equal(shapes.size, 5, p.id + ' shapes');
177
for (const c of p.colors)
178
{
179
assert.ok(c.image.startsWith('images/block-' + p.id + '-'), c.image);
180
assert.ok(!images.has(c.image), 'duplicate image ' + c.image);
181
images.add(c.image);
182
}
183
assert.ok(p.jumpsToClear >= 1 && p.jumpsToClear <= 4);
184
assert.ok(p.fallTime >= 1 && p.fallTime <= 5);
185
assert.ok(p.riseTime >= 0.5 && p.riseTime <= 3);
186
}
187
assert.ok(ids.has('terra'));
188
assert.equal(Planet.defaultPlanet().id, 'terra');
189
assert.equal(Planet.planetById('cinder').name, 'Cinder');
190
});
191
192
it('Aurel is the easiest (Power 0, 60% miss) and Cinder the hardest (Power 1, 5% miss)', () =>
193
{
194
const aurel = Planet.planetById('aurel');
195
const cinder = Planet.planetById('cinder');
196
assert.equal(Planet.power(aurel), 0);
197
assert.equal(Planet.missChance(aurel), 0.60);
198
assert.ok(Math.abs(Planet.power(cinder) - 1) < 1e-12);
199
assert.ok(Math.abs(Planet.missChance(cinder) - 0.05) < 1e-12);
200
assert.equal(Planet.displayValues(aurel).power, 0);
201
assert.equal(Planet.displayValues(cinder).power, 100);
202
});
203
});
@@ -157,3 +157,47 @@ describe('Power and display values', () =>157
assert.ok(Math.abs(d.gravity - 9.81) < 1e-9);157
assert.ok(Math.abs(d.gravity - 9.81) < 1e-9);158
});158
});159
});159
});160
161
describe('Planet catalog', () =>162
{163
it('has 8–12 named worlds, each with a people name and five unique shapes', () =>164
{165
const all = Planet.allPlanets();166
assert.ok(all.length >= 8 && all.length <= 12, 'catalog size ' + all.length);167
const ids = new Set();168
const images = new Set();169
for (const p of all)170
{171
assert.ok(p.id && p.name && p.people, p.id);172
assert.ok(!ids.has(p.id), 'duplicate id ' + p.id);173
ids.add(p.id);174
assert.equal(p.colors.length, 5);175
const shapes = new Set(p.colors.map((c) => c.shape));176
assert.equal(shapes.size, 5, p.id + ' shapes');177
for (const c of p.colors)178
{179
assert.ok(c.image.startsWith('images/block-' + p.id + '-'), c.image);180
assert.ok(!images.has(c.image), 'duplicate image ' + c.image);181
images.add(c.image);182
}183
assert.ok(p.jumpsToClear >= 1 && p.jumpsToClear <= 4);184
assert.ok(p.fallTime >= 1 && p.fallTime <= 5);185
assert.ok(p.riseTime >= 0.5 && p.riseTime <= 3);186
}187
assert.ok(ids.has('terra'));188
assert.equal(Planet.defaultPlanet().id, 'terra');189
assert.equal(Planet.planetById('cinder').name, 'Cinder');190
});191
192
it('Aurel is the easiest (Power 0, 60% miss) and Cinder the hardest (Power 1, 5% miss)', () =>193
{194
const aurel = Planet.planetById('aurel');195
const cinder = Planet.planetById('cinder');196
assert.equal(Planet.power(aurel), 0);197
assert.equal(Planet.missChance(aurel), 0.60);198
assert.ok(Math.abs(Planet.power(cinder) - 1) < 1e-12);199
assert.ok(Math.abs(Planet.missChance(cinder) - 0.05) < 1e-12);200
assert.equal(Planet.displayValues(aurel).power, 0);201
assert.equal(Planet.displayValues(cinder).power, 100);202
});203
});