BlueGit

projects-timfalken-com meteors

feat: append-only block registry and 43 new icons (t1139)

Terra's five stay free; the next block unlocks at 500 lifetime points,
then each one costs 14.5% more (rounded, strictly increasing). New
64x64 art (runes, arrows, figures, faces, icons) matches the existing
block style. Official non-Terra colours sit at the end of the register.

timfa Grok Bot · pushed by timfa

Authored 2026-11-13 · 4 days ago

Hash
7638a860237212eb3aa08faa5bada0c8ec9a34e9
Parent
d4cca679
47 files changed +1798 −0
build/images/block-arrow-chevron.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-arrow-double.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-arrow-return.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-arrow-up.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-face-cool.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-face-grin.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-face-smile.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-face-wink.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-fig-hero.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-fig-person.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-fig-walker.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-ankh.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-bell.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-bird.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-bolt.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-cactus.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-clover.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-comet.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-crown.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-eye.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-fish.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-flag.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-flame.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-heart.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-key.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-moon.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-mountain.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-mushroom.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-paw.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-ring.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-shield.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-snow.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-spiral.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-star6.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-sword.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-wave.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-icon-yin.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-rune-algiz.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-rune-ansuz.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-rune-fehu.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-rune-raido.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-rune-sowilo.png added Binary file +0 −0

The contents of this binary file are not shown.

build/images/block-rune-thurisaz.png added Binary file +0 −0

The contents of this binary file are not shown.

scripts/gen_unlock_blocks.py added +665 −0
@@ -0,0 +1,665 @@
1 #!/usr/bin/env python3
2 """Build server/lib/blocks.json (append-only registry) and new unlockable
3 block PNGs in the existing 64×64 style: coloured silhouette, dark outline,
4 soft highlight, drop shadow.
5
6 Official catalog colours are listed first (Terra's five, then the other
7 planets in catalog order) and their existing PNGs are left untouched.
8 New icons are appended and rendered here.
9
10 Run from the repo root: python3 scripts/gen_unlock_blocks.py
11 """
12 from __future__ import annotations
13
14 import json
15 import math
16 from pathlib import Path
17
18 from PIL import Image, ImageDraw, ImageFilter
19
20 ROOT = Path(__file__).resolve().parents[1]
21 CATALOG = ROOT / 'server' / 'lib' / 'planets.json'
22 OUT_JSON = ROOT / 'server' / 'lib' / 'blocks.json'
23 OUT_IMG = ROOT / 'build' / 'images'
24 SIZE = 64
25 SCALE = 4
26 SS = SIZE * SCALE
27
28
29 def hex_rgb(h):
30 h = h.lstrip('#')
31 return tuple(int(h[i:i + 2], 16) for i in (0, 2, 4))
32
33
34 def lighten(rgb, f=0.35):
35 return tuple(min(255, int(c + (255 - c) * f)) for c in rgb)
36
37
38 def darken(rgb, f=0.28):
39 return tuple(max(0, int(c * (1 - f))) for c in rgb)
40
41
42 def regular_poly(cx, cy, r, n, rot=-math.pi / 2):
43 pts = []
44 for i in range(n):
45 a = rot + i * 2 * math.pi / n
46 pts.append((cx + r * math.cos(a), cy + r * math.sin(a)))
47 return pts
48
49
50 def star_pts(cx, cy, r, n=5, inner=0.42, rot=-math.pi / 2):
51 pts = []
52 for i in range(n * 2):
53 a = rot + i * math.pi / n
54 rr = r if i % 2 == 0 else r * inner
55 pts.append((cx + rr * math.cos(a), cy + rr * math.sin(a)))
56 return pts
57
58
59 # ---------- shape primitives (filled polygons / lines) ----------
60
61 def poly_stroke(draw, pts, fill, outline, width):
62 draw.polygon(pts, fill=fill, outline=outline, width=width)
63
64
65 def thick_lines(draw, segs, color, width, closed=False):
66 """segs: list of point lists."""
67 for pts in segs:
68 if len(pts) < 2:
69 continue
70 draw.line(pts, fill=color, width=width, joint='curve')
71 # round caps
72 r = width / 2
73 for p in (pts[0], pts[-1]):
74 draw.ellipse([p[0] - r, p[1] - r, p[0] + r, p[1] + r], fill=color)
75 if closed and pts[0] != pts[-1]:
76 draw.line([pts[-1], pts[0]], fill=color, width=width)
77
78
79 def icon_path(cx, cy, r, kind):
80 """Return ('poly', pts) or ('polys', [pts, ...]) or ('lines', [pts,...], wfrac)
81 or ('combo', list of commands). Coordinates in actual pixels."""
82 def P(x, y):
83 return (cx + x * r, cy + y * r)
84
85 k = kind.lower()
86 if k == 'circle':
87 return ('ellipse', [-1, -1, 1, 1])
88 if k == 'square':
89 s = 0.86
90 return ('roundrect', [-s, -s, s, s], 0.12)
91 if k == 'triangle':
92 return ('poly', regular_poly(cx, cy + r * 0.08, r * 1.08, 3, -math.pi / 2))
93 if k == 'diamond':
94 return ('poly', regular_poly(cx, cy, r * 1.05, 4, 0))
95 if k == 'star':
96 return ('poly', star_pts(cx, cy, r * 1.12))
97 if k == 'hexagon':
98 return ('poly', regular_poly(cx, cy, r * 1.05, 6, 0))
99 if k == 'pentagon':
100 return ('poly', regular_poly(cx, cy, r * 1.08, 5))
101 if k == 'arrow':
102 return ('poly', [
103 P(0, -1.1), P(0.85, 0.05), P(0.28, 0.05), P(0.28, 1),
104 P(-0.28, 1), P(-0.28, 0.05), P(-0.85, 0.05),
105 ])
106 if k == 'chevron':
107 return ('poly', [
108 P(0, -1.05), P(0.95, 0.15), P(0.95, 0.55), P(0, -0.15),
109 P(-0.95, 0.55), P(-0.95, 0.15),
110 ])
111 if k == 'double_arrow':
112 return ('poly', [
113 P(0, -1.15), P(0.72, -0.25), P(0.28, -0.25), P(0.28, 0.05),
114 P(0.72, 0.05), P(0, 1.15), P(-0.72, 0.05), P(-0.28, 0.05),
115 P(-0.28, -0.25), P(-0.72, -0.25),
116 ])
117 if k == 'return_arrow':
118 return ('poly', [
119 P(-0.15, -1.1), P(0.7, -0.4), P(0.25, -0.4), P(0.25, 0.15),
120 P(0.85, 0.15), P(0.85, 0.55), P(-0.25, 0.55), P(-0.25, -0.4),
121 P(-0.7, -0.4),
122 ])
123 # Runes — stylized, thick, readable
124 if k == 'rune_fehu':
125 return ('lines', [
126 [P(-0.15, 1.0), P(-0.15, -1.0)],
127 [P(-0.15, -0.55), P(0.85, -0.95)],
128 [P(-0.15, -0.05), P(0.85, -0.45)],
129 ], 0.28)
130 if k == 'rune_ansuz':
131 return ('lines', [
132 [P(-0.2, 1.0), P(-0.2, -1.0)],
133 [P(-0.2, -0.85), P(0.85, -0.25)],
134 [P(-0.2, -0.15), P(0.7, 0.45)],
135 ], 0.28)
136 if k == 'rune_thurisaz':
137 return ('lines', [
138 [P(-0.35, 1.0), P(-0.35, -1.0)],
139 [P(-0.35, -0.55), P(0.7, 0), P(-0.35, 0.55)],
140 ], 0.28)
141 if k == 'rune_raido':
142 return ('lines', [
143 [P(-0.3, 1.0), P(-0.3, -1.0)],
144 [P(-0.3, -1.0), P(0.65, -0.55), P(-0.3, -0.1)],
145 [P(-0.05, -0.1), P(0.7, 1.0)],
146 ], 0.26)
147 if k == 'rune_sowilo':
148 return ('lines', [
149 [P(0.55, -1.05), P(-0.45, -0.25), P(0.45, 0.25), P(-0.55, 1.05)],
150 ], 0.30)
151 if k == 'rune_algiz':
152 return ('lines', [
153 [P(0, 1.05), P(0, -1.05)],
154 [P(0, -0.15), P(-0.75, -0.95)],
155 [P(0, -0.15), P(0.75, -0.95)],
156 ], 0.28)
157 # Figures
158 if k == 'person':
159 # head + body + arms + legs as one silhouette
160 head = []
161 for i in range(16):
162 a = i * 2 * math.pi / 16
163 head.append(P(0.0 + 0.28 * math.cos(a), -0.72 + 0.28 * math.sin(a)))
164 body = [
165 P(-0.22, -0.42), P(-0.72, -0.15), P(-0.72, 0.12), P(-0.22, -0.08),
166 P(-0.28, 0.35), P(-0.55, 1.05), P(-0.22, 1.05), P(0, 0.5),
167 P(0.22, 1.05), P(0.55, 1.05), P(0.28, 0.35), P(0.22, -0.08),
168 P(0.72, 0.12), P(0.72, -0.15), P(0.22, -0.42),
169 ]
170 return ('polys', [head, body])
171 if k == 'walker':
172 head = [P(0.15 + 0.26 * math.cos(i * 2 * math.pi / 16),
173 -0.7 + 0.26 * math.sin(i * 2 * math.pi / 16)) for i in range(16)]
174 body = [
175 P(-0.05, -0.42), P(-0.65, 0.05), P(-0.45, 0.25), P(-0.05, -0.05),
176 P(-0.15, 0.35), P(-0.7, 0.95), P(-0.4, 1.08), P(0.05, 0.45),
177 P(0.45, 1.08), P(0.7, 0.85), P(0.25, 0.3), P(0.25, -0.05),
178 P(0.7, -0.25), P(0.5, -0.45), P(0.2, -0.42),
179 ]
180 return ('polys', [head, body])
181 if k == 'hero':
182 # arms up in a V
183 head = [P(0.0 + 0.26 * math.cos(i * 2 * math.pi / 16),
184 -0.62 + 0.26 * math.sin(i * 2 * math.pi / 16)) for i in range(16)]
185 body = [
186 P(-0.18, -0.35), P(-0.95, -0.95), P(-0.7, -1.08), P(-0.1, -0.4),
187 P(-0.25, 0.35), P(-0.5, 1.08), P(-0.18, 1.08), P(0, 0.5),
188 P(0.18, 1.08), P(0.5, 1.08), P(0.25, 0.35), P(0.1, -0.4),
189 P(0.7, -1.08), P(0.95, -0.95), P(0.18, -0.35),
190 ]
191 return ('polys', [head, body])
192 # Faces
193 if k == 'smile':
194 return ('face', 'smile')
195 if k == 'wink':
196 return ('face', 'wink')
197 if k == 'cool':
198 return ('face', 'cool')
199 if k == 'grin':
200 return ('face', 'grin')
201 # Icons
202 if k == 'heart':
203 pts = []
204 for i in range(32):
205 t = i * 2 * math.pi / 32
206 # classic heart parametric, scaled
207 x = 16 * math.sin(t) ** 3
208 y = -(13 * math.cos(t) - 5 * math.cos(2 * t) - 2 * math.cos(3 * t) - math.cos(4 * t))
209 pts.append(P(x / 16.5, y / 16.5 + 0.08))
210 return ('poly', pts)
211 if k == 'lightning':
212 return ('poly', [
213 P(0.15, -1.1), P(0.55, -1.1), P(0.05, -0.1), P(0.45, -0.1),
214 P(-0.55, 1.15), P(-0.05, 0.15), P(-0.5, 0.15),
215 ])
216 if k == 'shield':
217 return ('poly', [
218 P(0, -1.1), P(0.95, -0.7), P(0.85, 0.25), P(0, 1.1),
219 P(-0.85, 0.25), P(-0.95, -0.7),
220 ])
221 if k == 'crown':
222 return ('poly', [
223 P(-0.95, 0.45), P(-0.95, -0.15), P(-0.5, 0.25), P(0, -0.95),
224 P(0.5, 0.25), P(0.95, -0.15), P(0.95, 0.45),
225 P(0.85, 0.85), P(-0.85, 0.85),
226 ])
227 if k == 'eye':
228 return ('eye',)
229 if k == 'star6':
230 return ('poly', star_pts(cx, cy, r * 1.12, n=6, inner=0.48))
231 if k == 'spiral':
232 pts = []
233 for i in range(60):
234 t = i / 59 * 3.4 * math.pi
235 rr = 0.12 + 0.88 * (i / 59)
236 pts.append(P(rr * math.cos(t), rr * math.sin(t)))
237 return ('lines', [pts], 0.26)
238 if k == 'wave':
239 pts_top, pts_bot = [], []
240 for i in range(21):
241 x = -1.05 + i * 2.1 / 20
242 y = 0.28 * math.sin(x * math.pi * 1.4)
243 pts_top.append(P(x, y - 0.28))
244 pts_bot.append(P(x, y + 0.28))
245 return ('poly', pts_top + list(reversed(pts_bot)))
246 if k == 'mountain':
247 return ('poly', [
248 P(-1.1, 0.9), P(-0.45, -0.55), P(-0.15, -0.05),
249 P(0.15, -1.05), P(0.5, -0.25), P(0.7, -0.55),
250 P(1.1, 0.9),
251 ])
252 if k == 'fish':
253 return ('poly', [
254 P(-1.05, 0), P(-0.55, -0.55), P(0.35, -0.55), P(0.75, -0.15),
255 P(1.1, -0.55), P(0.85, 0), P(1.1, 0.55), P(0.75, 0.15),
256 P(0.35, 0.55), P(-0.55, 0.55),
257 ])
258 if k == 'bird':
259 return ('poly', [
260 P(-1.05, 0.15), P(-0.3, -0.15), P(-0.05, -0.85), P(0.2, -0.15),
261 P(0.55, -0.25), P(1.05, 0.05), P(0.45, 0.15),
262 P(0.2, 0.85), P(-0.05, 0.2), P(-0.55, 0.45),
263 ])
264 if k == 'key':
265 # head circle + shaft + teeth as one poly
266 pts = []
267 for i in range(12):
268 a = -math.pi * 0.6 + i * 1.6 * math.pi / 11
269 pts.append(P(-0.55 + 0.42 * math.cos(a), -0.55 + 0.42 * math.sin(a)))
270 pts += [
271 P(-0.25, -0.2), P(1.05, -0.2), P(1.05, 0.15),
272 P(0.85, 0.15), P(0.85, 0.5), P(0.6, 0.5), P(0.6, 0.15),
273 P(0.4, 0.15), P(0.4, 0.38), P(0.15, 0.38), P(0.15, 0.15),
274 P(-0.25, 0.15),
275 ]
276 return ('poly', pts)
277 if k == 'comet':
278 return ('poly', [
279 P(0.95, -0.95), P(0.35, -0.45), P(0.15, -0.7), P(-0.15, -0.15),
280 P(0.15, -0.05), P(-1.05, 1.05), P(-0.05, 0.15), P(0.15, 0.35),
281 P(0.55, -0.15), P(0.45, -0.45),
282 ])
283 if k == 'clover':
284 lobes = []
285 for ang, ox, oy in ((0, 0, -0.42), (2.1, -0.4, 0.18), (4.2, 0.4, 0.18)):
286 pts = []
287 for i in range(16):
288 a = i * 2 * math.pi / 16
289 pts.append(P(ox + 0.42 * math.cos(a), oy + 0.42 * math.sin(a)))
290 lobes.append(pts)
291 stem = [P(-0.08, 0.35), P(0.08, 0.35), P(0.18, 1.05), P(-0.05, 1.05)]
292 lobes.append(stem)
293 return ('polys', lobes)
294 if k == 'paw':
295 pads = []
296 for ox, oy, rr in ((-0.5, -0.55, 0.28), (0, -0.75, 0.28), (0.5, -0.55, 0.28),
297 (0.0, 0.28, 0.52)):
298 pts = []
299 for i in range(16):
300 a = i * 2 * math.pi / 16
301 pts.append(P(ox + rr * math.cos(a), oy + rr * math.sin(a)))
302 pads.append(pts)
303 return ('polys', pads)
304 if k == 'sword':
305 return ('poly', [
306 P(-0.18, 1.1), P(-0.18, 0.45), P(-0.55, 0.45), P(-0.55, 0.22),
307 P(-0.18, 0.22), P(-0.18, -0.95), P(0, -1.15), P(0.18, -0.95),
308 P(0.18, 0.22), P(0.55, 0.22), P(0.55, 0.45), P(0.18, 0.45),
309 P(0.18, 1.1),
310 ])
311 if k == 'bell':
312 pts = []
313 for i in range(18):
314 a = math.pi + i * math.pi / 17
315 pts.append(P(0.85 * math.cos(a), -0.25 + 0.85 * math.sin(a)))
316 pts += [P(0.95, 0.55), P(0.7, 0.75), P(0.15, 0.75), P(0.15, 0.95),
317 P(-0.15, 0.95), P(-0.15, 0.75), P(-0.7, 0.75), P(-0.95, 0.55)]
318 return ('poly', pts)
319 if k == 'mushroom':
320 cap = []
321 for i in range(18):
322 a = math.pi + i * math.pi / 17
323 cap.append(P(0.95 * math.cos(a), -0.25 + 0.7 * math.sin(a)))
324 cap += [P(0.95, 0.05), P(-0.95, 0.05)]
325 stem = [P(-0.32, 0.05), P(0.32, 0.05), P(0.38, 1.05), P(-0.38, 1.05)]
326 return ('polys', [cap, stem])
327 if k == 'cactus':
328 return ('poly', [
329 P(-0.22, 1.05), P(-0.22, 0.15), P(-0.75, 0.15), P(-0.75, -0.35),
330 P(-0.5, -0.35), P(-0.5, -0.05), P(-0.22, -0.05), P(-0.22, -1.05),
331 P(0.22, -1.05), P(0.22, -0.25), P(0.55, -0.25), P(0.55, -0.7),
332 P(0.8, -0.7), P(0.8, -0.02), P(0.22, -0.02), P(0.22, 1.05),
333 ])
334 if k == 'ring':
335 return ('ring', 1.0, 0.55)
336 if k == 'flag':
337 return ('poly', [
338 P(-0.7, 1.1), P(-0.7, -1.05), P(-0.5, -1.05), P(-0.5, -0.85),
339 P(1.0, -0.85), P(0.7, -0.4), P(1.0, 0.05), P(-0.5, 0.05),
340 P(-0.5, 1.1),
341 ])
342 if k == 'snowflake':
343 arms = []
344 for k0 in range(6):
345 a = k0 * math.pi / 3
346 c, s = math.cos(a), math.sin(a)
347 def rot(x, y):
348 return P(x * c - y * s, x * s + y * c)
349 arms.append([rot(0, 0), rot(0, -1.05)])
350 arms.append([rot(-0.28, -0.6), rot(0, -0.4), rot(0.28, -0.6)])
351 return ('lines', arms, 0.22)
352 if k == 'flame_icon':
353 return ('poly', [
354 P(0, -1.15), P(0.35, -0.45), P(0.55, -0.7), P(0.75, -0.15),
355 P(0.55, 0.55), P(0.2, 1.0), P(-0.25, 1.0), P(-0.6, 0.5),
356 P(-0.7, -0.05), P(-0.35, -0.55), P(-0.15, -0.2),
357 ])
358 if k == 'ankh':
359 return ('lines', [
360 [P(0, 1.05), P(0, -0.25)],
361 [P(-0.55, 0.15), P(0.55, 0.15)],
362 ], 0.28) # loop added in combo
363 if k == 'yinyang':
364 return ('yinyang',)
365 if k == 'crescent':
366 # moon
367 return ('crescent',)
368 # fallback
369 return ('ellipse', [-1, -1, 1, 1])
370
371
372 def draw_kind(draw, img, kind, cx, cy, r, fill, outline, width):
373 cmd = icon_path(cx, cy, r, kind)
374 kind_l = kind.lower()
375
376 def fill_poly(pts):
377 if len(pts) >= 3:
378 draw.polygon(pts, fill=fill, outline=outline, width=width)
379
380 def fill_lines(segs, wfrac):
381 w = max(width, int(r * wfrac))
382 # draw in outline color slightly thicker, then fill
383 thick_lines(draw, segs, outline, w + max(2, width // 2))
384 thick_lines(draw, segs, fill, w)
385
386 if cmd[0] == 'poly':
387 fill_poly(cmd[1])
388 elif cmd[0] == 'polys':
389 for pts in cmd[1]:
390 fill_poly(pts)
391 elif cmd[0] == 'lines':
392 fill_lines(cmd[1], cmd[2])
393 if kind_l == 'ankh':
394 # loop at top
395 box = [cx - r * 0.42, cy - r * 1.15, cx + r * 0.42, cy - r * 0.25]
396 draw.ellipse(box, outline=outline, width=int(r * 0.28) + width)
397 draw.ellipse([box[0] + r * 0.14, box[1] + r * 0.14,
398 box[2] - r * 0.14, box[3] - r * 0.14],
399 outline=fill, width=int(r * 0.16))
400 # fill ring by a second pass
401 # simpler: thick ellipse
402 w = int(r * 0.26)
403 draw.ellipse(box, outline=outline, width=w + width)
404 draw.ellipse(box, outline=fill, width=w)
405 elif cmd[0] == 'ellipse':
406 a, b, c, d = cmd[1]
407 box = [cx + a * r, cy + b * r, cx + c * r, cy + d * r]
408 draw.ellipse(box, fill=fill, outline=outline, width=width)
409 elif cmd[0] == 'roundrect':
410 a, b, c, d = cmd[1]
411 box = [cx + a * r, cy + b * r, cx + c * r, cy + d * r]
412 draw.rounded_rectangle(box, radius=r * cmd[2], fill=fill, outline=outline, width=width)
413 elif cmd[0] == 'ring':
414 _, ro, ri = cmd
415 outer = [cx - r * ro, cy - r * ro, cx + r * ro, cy + r * ro]
416 inner = [cx - r * ri, cy - r * ri, cx + r * ri, cy + r * ri]
417 draw.ellipse(outer, fill=fill, outline=outline, width=width)
418 # punch inner with destination-out
419 # We'll handle punch at a higher level; draw inner as transparent later
420 draw.ellipse(inner, fill=(0, 0, 0, 0), outline=outline, width=width)
421 elif cmd[0] == 'face':
422 box = [cx - r, cy - r, cx + r, cy + r]
423 draw.ellipse(box, fill=fill, outline=outline, width=width)
424 eye_c = outline
425 er = r * 0.12
426 if cmd[1] == 'wink':
427 draw.ellipse([cx - r * 0.38 - er, cy - r * 0.28 - er,
428 cx - r * 0.38 + er, cy - r * 0.28 + er], fill=eye_c)
429 draw.line([(cx + r * 0.18, cy - r * 0.28), (cx + r * 0.52, cy - r * 0.28)],
430 fill=eye_c, width=max(width, int(r * 0.12)))
431 elif cmd[1] == 'cool':
432 # sunglasses
433 draw.rounded_rectangle([cx - r * 0.7, cy - r * 0.42, cx - r * 0.08, cy - r * 0.08],
434 radius=r * 0.12, fill=eye_c)
435 draw.rounded_rectangle([cx + r * 0.08, cy - r * 0.42, cx + r * 0.7, cy - r * 0.08],
436 radius=r * 0.12, fill=eye_c)
437 draw.line([(cx - r * 0.08, cy - r * 0.25), (cx + r * 0.08, cy - r * 0.25)],
438 fill=eye_c, width=max(3, int(r * 0.1)))
439 else:
440 draw.ellipse([cx - r * 0.38 - er, cy - r * 0.28 - er,
441 cx - r * 0.38 + er, cy - r * 0.28 + er], fill=eye_c)
442 draw.ellipse([cx + r * 0.38 - er, cy - r * 0.28 - er,
443 cx + r * 0.38 + er, cy - r * 0.28 + er], fill=eye_c)
444 # smile
445 smile = []
446 for i in range(9):
447 a = math.pi * 0.2 + i * math.pi * 0.6 / 8
448 smile.append((cx + r * 0.48 * math.cos(a), cy + r * 0.12 + r * 0.42 * math.sin(a)))
449 sw = max(width, int(r * 0.12))
450 if cmd[1] == 'grin':
451 draw.chord([cx - r * 0.5, cy + r * 0.05, cx + r * 0.5, cy + r * 0.65],
452 start=0, end=180, fill=eye_c, outline=eye_c)
453 else:
454 draw.line(smile, fill=eye_c, width=sw, joint='curve')
455 elif cmd[0] == 'eye':
456 # almond
457 pts = []
458 for i in range(24):
459 t = i * 2 * math.pi / 24
460 x = math.cos(t)
461 y = 0.5 * math.sin(t)
462 pts.append((cx + r * 1.05 * x, cy + r * 0.85 * y))
463 fill_poly(pts)
464 iris_c = outline
465 draw.ellipse([cx - r * 0.38, cy - r * 0.38, cx + r * 0.38, cy + r * 0.38],
466 fill=iris_c)
467 draw.ellipse([cx - r * 0.14, cy - r * 0.18, cx + r * 0.06, cy + r * 0.02],
468 fill=lighten(fill[:3] if isinstance(fill, tuple) else (255, 255, 255), 0.8) + (255,))
469 elif cmd[0] == 'yinyang':
470 draw.ellipse([cx - r, cy - r, cx + r, cy + r], fill=fill, outline=outline, width=width)
471 # right half dark via chord is messy; draw a dark semicircle + two dots
472 # Use a path: top-center to bottom via right, with small circles
473 # We'll approximate with a pie and two discs
474 dark = outline
475 draw.pieslice([cx - r, cy - r, cx + r, cy + r], start=90, end=270, fill=dark)
476 draw.ellipse([cx - r * 0.5, cy - r, cx + r * 0.5, cy], fill=dark)
477 draw.ellipse([cx - r * 0.5, cy, cx + r * 0.5, cy + r], fill=fill)
478 # dots
479 draw.ellipse([cx - r * 0.16, cy - r * 0.58, cx + r * 0.16, cy - r * 0.26], fill=fill)
480 draw.ellipse([cx - r * 0.16, cy + r * 0.26, cx + r * 0.16, cy + r * 0.58], fill=dark)
481 draw.ellipse([cx - r, cy - r, cx + r, cy + r], outline=outline, width=width)
482 elif cmd[0] == 'crescent':
483 # moon: two circles, punch later — draw a crescent polygon
484 outer, inner = [], []
485 for i in range(24):
486 a = -math.pi * 0.75 + i * (1.5 * math.pi) / 23
487 outer.append((cx + r * math.cos(a) - r * 0.05, cy + r * math.sin(a)))
488 ox, oy = cx + r * 0.42, cy - r * 0.05
489 for i in range(20, -1, -1):
490 a = -math.pi * 0.7 + i * (1.4 * math.pi) / 20
491 inner.append((ox + r * 0.72 * math.cos(a), oy + r * 0.72 * math.sin(a)))
492 fill_poly(outer + inner)
493 else:
494 draw.ellipse([cx - r, cy - r, cx + r, cy + r], fill=fill, outline=outline, width=width)
495
496
497 def render_block(hex_color, shape):
498 rgb = hex_rgb(hex_color)
499 hi = lighten(rgb, 0.42)
500 lo = darken(rgb, 0.32)
501 img = Image.new('RGBA', (SS, SS), (0, 0, 0, 0))
502 cx = cy = SS / 2
503 r = SS * 0.36
504 width = max(2, SCALE)
505 # drop shadow
506 shadow = Image.new('RGBA', (SS, SS), (0, 0, 0, 0))
507 sd = ImageDraw.Draw(shadow)
508 draw_kind(sd, shadow, shape, cx + SCALE * 1.2, cy + SCALE * 1.6, r,
509 (0, 0, 0, 90), None, 0)
510 shadow = shadow.filter(ImageFilter.GaussianBlur(radius=SCALE * 1.1))
511 img = Image.alpha_composite(img, shadow)
512 # For ring, punch a hole after drawing body
513 body = Image.new('RGBA', (SS, SS), (0, 0, 0, 0))
514 bd = ImageDraw.Draw(body)
515 draw_kind(bd, body, shape, cx, cy, r, rgb + (255,), lo + (255,), width)
516 if shape == 'ring':
517 # punch inner hole
518 mask = Image.new('L', (SS, SS), 0)
519 md = ImageDraw.Draw(mask)
520 ri = r * 0.55
521 md.ellipse([cx - ri, cy - ri, cx + ri, cy + ri], fill=255)
522 clear = Image.new('RGBA', (SS, SS), (0, 0, 0, 0))
523 body = Image.composite(clear, body, mask)
524 # redraw inner outline
525 bd = ImageDraw.Draw(body)
526 bd.ellipse([cx - ri, cy - ri, cx + ri, cy + ri], outline=lo + (255,), width=width)
527 img = Image.alpha_composite(img, body)
528 # highlight
529 hi_layer = Image.new('RGBA', (SS, SS), (0, 0, 0, 0))
530 hd = ImageDraw.Draw(hi_layer)
531 draw_kind(hd, hi_layer, shape, cx - r * 0.06, cy - r * 0.10, r * 0.55,
532 hi + (110,), None, 0)
533 hi_layer = hi_layer.filter(ImageFilter.GaussianBlur(radius=SCALE * 0.6))
534 # clip highlight to body alpha
535 body_a = body.split()[3]
536 ha = hi_layer.split()[3]
537 from PIL import ImageChops
538 ha = ImageChops.multiply(ha, body_a)
539 hi_layer.putalpha(ha)
540 img = Image.alpha_composite(img, hi_layer)
541 return img.resize((SIZE, SIZE), Image.Resampling.LANCZOS)
542
543
544 # New unlockable blocks, appended after official catalog colours.
545 # ids are stable and must never be reordered or reused.
546 NEW_BLOCKS = [
547 # Runes
548 {'id': 'rune-fehu', 'name': 'Fehu', 'hex': '#e8a44a', 'shape': 'rune_fehu'},
549 {'id': 'rune-ansuz', 'name': 'Ansuz', 'hex': '#6ab0e8', 'shape': 'rune_ansuz'},
550 {'id': 'rune-thurisaz', 'name': 'Thurisaz', 'hex': '#c05040', 'shape': 'rune_thurisaz'},
551 {'id': 'rune-raido', 'name': 'Raido', 'hex': '#d0c070', 'shape': 'rune_raido'},
552 {'id': 'rune-sowilo', 'name': 'Sowilo', 'hex': '#f0d040', 'shape': 'rune_sowilo'},
553 {'id': 'rune-algiz', 'name': 'Algiz', 'hex': '#80d0a0', 'shape': 'rune_algiz'},
554 # Arrows
555 {'id': 'arrow-up', 'name': 'Arrow', 'hex': '#f07040', 'shape': 'arrow'},
556 {'id': 'arrow-chevron', 'name': 'Chevron', 'hex': '#50c0e0', 'shape': 'chevron'},
557 {'id': 'arrow-double', 'name': 'Double Arrow', 'hex': '#e05080', 'shape': 'double_arrow'},
558 {'id': 'arrow-return', 'name': 'Return', 'hex': '#a080e0', 'shape': 'return_arrow'},
559 # Figures
560 {'id': 'fig-person', 'name': 'Figure', 'hex': '#f0c0a0', 'shape': 'person'},
561 {'id': 'fig-walker', 'name': 'Walker', 'hex': '#c09070', 'shape': 'walker'},
562 {'id': 'fig-hero', 'name': 'Hero', 'hex': '#e8b070', 'shape': 'hero'},
563 # Faces
564 {'id': 'face-smile', 'name': 'Smile', 'hex': '#f0d060', 'shape': 'smile'},
565 {'id': 'face-wink', 'name': 'Wink', 'hex': '#f0a050', 'shape': 'wink'},
566 {'id': 'face-cool', 'name': 'Cool', 'hex': '#6090d0', 'shape': 'cool'},
567 {'id': 'face-grin', 'name': 'Grin', 'hex': '#f0c848', 'shape': 'grin'},
568 # Icons
569 {'id': 'icon-heart', 'name': 'Heart', 'hex': '#e04060', 'shape': 'heart'},
570 {'id': 'icon-moon', 'name': 'Moon', 'hex': '#d0d8f0', 'shape': 'crescent'},
571 {'id': 'icon-bolt', 'name': 'Bolt', 'hex': '#f0e050', 'shape': 'lightning'},
572 {'id': 'icon-shield', 'name': 'Shield', 'hex': '#5080c0', 'shape': 'shield'},
573 {'id': 'icon-crown', 'name': 'Crown', 'hex': '#f0c030', 'shape': 'crown'},
574 {'id': 'icon-eye', 'name': 'Eye', 'hex': '#70d0c0', 'shape': 'eye'},
575 {'id': 'icon-star6', 'name': 'Hexastar', 'hex': '#f0e8a0', 'shape': 'star6'},
576 {'id': 'icon-spiral', 'name': 'Spiral', 'hex': '#c070d0', 'shape': 'spiral'},
577 {'id': 'icon-wave', 'name': 'Wave', 'hex': '#3090d0', 'shape': 'wave'},
578 {'id': 'icon-mountain', 'name': 'Mountain', 'hex': '#809070', 'shape': 'mountain'},
579 {'id': 'icon-fish', 'name': 'Fish', 'hex': '#40a8c8', 'shape': 'fish'},
580 {'id': 'icon-bird', 'name': 'Bird', 'hex': '#e07050', 'shape': 'bird'},
581 {'id': 'icon-key', 'name': 'Key', 'hex': '#d0b050', 'shape': 'key'},
582 {'id': 'icon-comet', 'name': 'Comet', 'hex': '#90d0f0', 'shape': 'comet'},
583 {'id': 'icon-clover', 'name': 'Clover', 'hex': '#40b060', 'shape': 'clover'},
584 {'id': 'icon-paw', 'name': 'Paw', 'hex': '#c08050', 'shape': 'paw'},
585 {'id': 'icon-sword', 'name': 'Sword', 'hex': '#b0b8c0', 'shape': 'sword'},
586 {'id': 'icon-bell', 'name': 'Bell', 'hex': '#f0c848', 'shape': 'bell'},
587 {'id': 'icon-mushroom', 'name': 'Mushroom', 'hex': '#e06050', 'shape': 'mushroom'},
588 {'id': 'icon-cactus', 'name': 'Cactus', 'hex': '#50b068', 'shape': 'cactus'},
589 {'id': 'icon-ring', 'name': 'Ring', 'hex': '#e8d080', 'shape': 'ring'},
590 {'id': 'icon-flag', 'name': 'Flag', 'hex': '#d04050', 'shape': 'flag'},
591 {'id': 'icon-snow', 'name': 'Snowflake', 'hex': '#c8e0f8', 'shape': 'snowflake'},
592 {'id': 'icon-flame', 'name': 'Flame', 'hex': '#ff7030', 'shape': 'flame_icon'},
593 {'id': 'icon-ankh', 'name': 'Ankh', 'hex': '#d0a060', 'shape': 'ankh'},
594 {'id': 'icon-yin', 'name': 'Yin Yang', 'hex': '#606080', 'shape': 'yinyang'},
595 ]
596
597
598 def official_blocks(catalog):
599 out = []
600 seen = set()
601 for planet in catalog['planets']:
602 pid = planet['id']
603 for c in planet['colors']:
604 bid = f"{pid}-{c['name']}"
605 if bid in seen:
606 raise SystemExit(f'duplicate official id {bid}')
607 seen.add(bid)
608 out.append({
609 'id': bid,
610 'name': c['name'].capitalize() if pid == 'terra' else f"{planet['name']} {c['name']}",
611 'hex': c['hex'],
612 'shape': c.get('shape') or 'circle',
613 'image': c['image'],
614 'terra': pid == 'terra',
615 })
616 return out
617
618
619 def main():
620 catalog = json.loads(CATALOG.read_text())
621 official = official_blocks(catalog)
622 terra = [b for b in official if b.get('terra')]
623 others = [b for b in official if not b.get('terra')]
624 if len(terra) != 5 or terra[0]['id'] != 'terra-ember':
625 raise SystemExit(f'Terra five unexpected: {[b["id"] for b in terra]}')
626
627 new = []
628 seen = {b['id'] for b in official}
629 OUT_IMG.mkdir(parents=True, exist_ok=True)
630 for b in NEW_BLOCKS:
631 if b['id'] in seen:
632 raise SystemExit(f'duplicate new id {b["id"]}')
633 seen.add(b['id'])
634 image = f"images/block-{b['id']}.png"
635 path = ROOT / 'build' / image
636 img = render_block(b['hex'], b['shape'])
637 img.save(path, 'PNG', optimize=True)
638 new.append({
639 'id': b['id'],
640 'name': b['name'],
641 'hex': b['hex'],
642 'shape': b['shape'],
643 'image': image,
644 'terra': False,
645 })
646 print(f' wrote {path.relative_to(ROOT)} ({path.stat().st_size} bytes)')
647
648 registry = {
649 '_comment': (
650 'Append-only block registry. Never reorder, rename ids, or insert '
651 'in the middle. New blocks go at the end. The first five (Terra) '
652 'are unlocked by default; index 5 requires 500 lifetime points, '
653 'each next index requires 14.5% more (rounded).'
654 ),
655 'terraCount': 5,
656 'firstThreshold': 500,
657 'thresholdGrowth': 1.145,
658 'blocks': terra + new + others,
659 }
660 OUT_JSON.write_text(json.dumps(registry, indent=2, ensure_ascii=False) + '\n')
661 print(f'wrote {OUT_JSON.relative_to(ROOT)}: {len(terra)} terra + {len(new)} new + {len(others)} official = {len(registry["blocks"])} total')
662
663
664 if __name__ == '__main__':
665 main()
@@ -0,0 +1,665 @@
1#!/usr/bin/env python3
2"""Build server/lib/blocks.json (append-only registry) and new unlockable
3block PNGs in the existing 64×64 style: coloured silhouette, dark outline,
4soft highlight, drop shadow.
5
6Official catalog colours are listed first (Terra's five, then the other
7planets in catalog order) and their existing PNGs are left untouched.
8New icons are appended and rendered here.
9
10Run from the repo root: python3 scripts/gen_unlock_blocks.py
11"""
12from __future__ import annotations
13
14import json
15import math
16from pathlib import Path
17
18from PIL import Image, ImageDraw, ImageFilter
19
20ROOT = Path(__file__).resolve().parents[1]
21CATALOG = ROOT / 'server' / 'lib' / 'planets.json'
22OUT_JSON = ROOT / 'server' / 'lib' / 'blocks.json'
23OUT_IMG = ROOT / 'build' / 'images'
24SIZE = 64
25SCALE = 4
26SS = SIZE * SCALE
27
28
29def hex_rgb(h):
30 h = h.lstrip('#')
31 return tuple(int(h[i:i + 2], 16) for i in (0, 2, 4))
32
33
34def lighten(rgb, f=0.35):
35 return tuple(min(255, int(c + (255 - c) * f)) for c in rgb)
36
37
38def darken(rgb, f=0.28):
39 return tuple(max(0, int(c * (1 - f))) for c in rgb)
40
41
42def regular_poly(cx, cy, r, n, rot=-math.pi / 2):
43 pts = []
44 for i in range(n):
45 a = rot + i * 2 * math.pi / n
46 pts.append((cx + r * math.cos(a), cy + r * math.sin(a)))
47 return pts
48
49
50def star_pts(cx, cy, r, n=5, inner=0.42, rot=-math.pi / 2):
51 pts = []
52 for i in range(n * 2):
53 a = rot + i * math.pi / n
54 rr = r if i % 2 == 0 else r * inner
55 pts.append((cx + rr * math.cos(a), cy + rr * math.sin(a)))
56 return pts
57
58
59# ---------- shape primitives (filled polygons / lines) ----------
60
61def poly_stroke(draw, pts, fill, outline, width):
62 draw.polygon(pts, fill=fill, outline=outline, width=width)
63
64
65def thick_lines(draw, segs, color, width, closed=False):
66 """segs: list of point lists."""
67 for pts in segs:
68 if len(pts) < 2:
69 continue
70 draw.line(pts, fill=color, width=width, joint='curve')
71 # round caps
72 r = width / 2
73 for p in (pts[0], pts[-1]):
74 draw.ellipse([p[0] - r, p[1] - r, p[0] + r, p[1] + r], fill=color)
75 if closed and pts[0] != pts[-1]:
76 draw.line([pts[-1], pts[0]], fill=color, width=width)
77
78
79def icon_path(cx, cy, r, kind):
80 """Return ('poly', pts) or ('polys', [pts, ...]) or ('lines', [pts,...], wfrac)
81 or ('combo', list of commands). Coordinates in actual pixels."""
82 def P(x, y):
83 return (cx + x * r, cy + y * r)
84
85 k = kind.lower()
86 if k == 'circle':
87 return ('ellipse', [-1, -1, 1, 1])
88 if k == 'square':
89 s = 0.86
90 return ('roundrect', [-s, -s, s, s], 0.12)
91 if k == 'triangle':
92 return ('poly', regular_poly(cx, cy + r * 0.08, r * 1.08, 3, -math.pi / 2))
93 if k == 'diamond':
94 return ('poly', regular_poly(cx, cy, r * 1.05, 4, 0))
95 if k == 'star':
96 return ('poly', star_pts(cx, cy, r * 1.12))
97 if k == 'hexagon':
98 return ('poly', regular_poly(cx, cy, r * 1.05, 6, 0))
99 if k == 'pentagon':
100 return ('poly', regular_poly(cx, cy, r * 1.08, 5))
101 if k == 'arrow':
102 return ('poly', [
103 P(0, -1.1), P(0.85, 0.05), P(0.28, 0.05), P(0.28, 1),
104 P(-0.28, 1), P(-0.28, 0.05), P(-0.85, 0.05),
105 ])
106 if k == 'chevron':
107 return ('poly', [
108 P(0, -1.05), P(0.95, 0.15), P(0.95, 0.55), P(0, -0.15),
109 P(-0.95, 0.55), P(-0.95, 0.15),
110 ])
111 if k == 'double_arrow':
112 return ('poly', [
113 P(0, -1.15), P(0.72, -0.25), P(0.28, -0.25), P(0.28, 0.05),
114 P(0.72, 0.05), P(0, 1.15), P(-0.72, 0.05), P(-0.28, 0.05),
115 P(-0.28, -0.25), P(-0.72, -0.25),
116 ])
117 if k == 'return_arrow':
118 return ('poly', [
119 P(-0.15, -1.1), P(0.7, -0.4), P(0.25, -0.4), P(0.25, 0.15),
120 P(0.85, 0.15), P(0.85, 0.55), P(-0.25, 0.55), P(-0.25, -0.4),
121 P(-0.7, -0.4),
122 ])
123 # Runes — stylized, thick, readable
124 if k == 'rune_fehu':
125 return ('lines', [
126 [P(-0.15, 1.0), P(-0.15, -1.0)],
127 [P(-0.15, -0.55), P(0.85, -0.95)],
128 [P(-0.15, -0.05), P(0.85, -0.45)],
129 ], 0.28)
130 if k == 'rune_ansuz':
131 return ('lines', [
132 [P(-0.2, 1.0), P(-0.2, -1.0)],
133 [P(-0.2, -0.85), P(0.85, -0.25)],
134 [P(-0.2, -0.15), P(0.7, 0.45)],
135 ], 0.28)
136 if k == 'rune_thurisaz':
137 return ('lines', [
138 [P(-0.35, 1.0), P(-0.35, -1.0)],
139 [P(-0.35, -0.55), P(0.7, 0), P(-0.35, 0.55)],
140 ], 0.28)
141 if k == 'rune_raido':
142 return ('lines', [
143 [P(-0.3, 1.0), P(-0.3, -1.0)],
144 [P(-0.3, -1.0), P(0.65, -0.55), P(-0.3, -0.1)],
145 [P(-0.05, -0.1), P(0.7, 1.0)],
146 ], 0.26)
147 if k == 'rune_sowilo':
148 return ('lines', [
149 [P(0.55, -1.05), P(-0.45, -0.25), P(0.45, 0.25), P(-0.55, 1.05)],
150 ], 0.30)
151 if k == 'rune_algiz':
152 return ('lines', [
153 [P(0, 1.05), P(0, -1.05)],
154 [P(0, -0.15), P(-0.75, -0.95)],
155 [P(0, -0.15), P(0.75, -0.95)],
156 ], 0.28)
157 # Figures
158 if k == 'person':
159 # head + body + arms + legs as one silhouette
160 head = []
161 for i in range(16):
162 a = i * 2 * math.pi / 16
163 head.append(P(0.0 + 0.28 * math.cos(a), -0.72 + 0.28 * math.sin(a)))
164 body = [
165 P(-0.22, -0.42), P(-0.72, -0.15), P(-0.72, 0.12), P(-0.22, -0.08),
166 P(-0.28, 0.35), P(-0.55, 1.05), P(-0.22, 1.05), P(0, 0.5),
167 P(0.22, 1.05), P(0.55, 1.05), P(0.28, 0.35), P(0.22, -0.08),
168 P(0.72, 0.12), P(0.72, -0.15), P(0.22, -0.42),
169 ]
170 return ('polys', [head, body])
171 if k == 'walker':
172 head = [P(0.15 + 0.26 * math.cos(i * 2 * math.pi / 16),
173 -0.7 + 0.26 * math.sin(i * 2 * math.pi / 16)) for i in range(16)]
174 body = [
175 P(-0.05, -0.42), P(-0.65, 0.05), P(-0.45, 0.25), P(-0.05, -0.05),
176 P(-0.15, 0.35), P(-0.7, 0.95), P(-0.4, 1.08), P(0.05, 0.45),
177 P(0.45, 1.08), P(0.7, 0.85), P(0.25, 0.3), P(0.25, -0.05),
178 P(0.7, -0.25), P(0.5, -0.45), P(0.2, -0.42),
179 ]
180 return ('polys', [head, body])
181 if k == 'hero':
182 # arms up in a V
183 head = [P(0.0 + 0.26 * math.cos(i * 2 * math.pi / 16),
184 -0.62 + 0.26 * math.sin(i * 2 * math.pi / 16)) for i in range(16)]
185 body = [
186 P(-0.18, -0.35), P(-0.95, -0.95), P(-0.7, -1.08), P(-0.1, -0.4),
187 P(-0.25, 0.35), P(-0.5, 1.08), P(-0.18, 1.08), P(0, 0.5),
188 P(0.18, 1.08), P(0.5, 1.08), P(0.25, 0.35), P(0.1, -0.4),
189 P(0.7, -1.08), P(0.95, -0.95), P(0.18, -0.35),
190 ]
191 return ('polys', [head, body])
192 # Faces
193 if k == 'smile':
194 return ('face', 'smile')
195 if k == 'wink':
196 return ('face', 'wink')
197 if k == 'cool':
198 return ('face', 'cool')
199 if k == 'grin':
200 return ('face', 'grin')
201 # Icons
202 if k == 'heart':
203 pts = []
204 for i in range(32):
205 t = i * 2 * math.pi / 32
206 # classic heart parametric, scaled
207 x = 16 * math.sin(t) ** 3
208 y = -(13 * math.cos(t) - 5 * math.cos(2 * t) - 2 * math.cos(3 * t) - math.cos(4 * t))
209 pts.append(P(x / 16.5, y / 16.5 + 0.08))
210 return ('poly', pts)
211 if k == 'lightning':
212 return ('poly', [
213 P(0.15, -1.1), P(0.55, -1.1), P(0.05, -0.1), P(0.45, -0.1),
214 P(-0.55, 1.15), P(-0.05, 0.15), P(-0.5, 0.15),
215 ])
216 if k == 'shield':
217 return ('poly', [
218 P(0, -1.1), P(0.95, -0.7), P(0.85, 0.25), P(0, 1.1),
219 P(-0.85, 0.25), P(-0.95, -0.7),
220 ])
221 if k == 'crown':
222 return ('poly', [
223 P(-0.95, 0.45), P(-0.95, -0.15), P(-0.5, 0.25), P(0, -0.95),
224 P(0.5, 0.25), P(0.95, -0.15), P(0.95, 0.45),
225 P(0.85, 0.85), P(-0.85, 0.85),
226 ])
227 if k == 'eye':
228 return ('eye',)
229 if k == 'star6':
230 return ('poly', star_pts(cx, cy, r * 1.12, n=6, inner=0.48))
231 if k == 'spiral':
232 pts = []
233 for i in range(60):
234 t = i / 59 * 3.4 * math.pi
235 rr = 0.12 + 0.88 * (i / 59)
236 pts.append(P(rr * math.cos(t), rr * math.sin(t)))
237 return ('lines', [pts], 0.26)
238 if k == 'wave':
239 pts_top, pts_bot = [], []
240 for i in range(21):
241 x = -1.05 + i * 2.1 / 20
242 y = 0.28 * math.sin(x * math.pi * 1.4)
243 pts_top.append(P(x, y - 0.28))
244 pts_bot.append(P(x, y + 0.28))
245 return ('poly', pts_top + list(reversed(pts_bot)))
246 if k == 'mountain':
247 return ('poly', [
248 P(-1.1, 0.9), P(-0.45, -0.55), P(-0.15, -0.05),
249 P(0.15, -1.05), P(0.5, -0.25), P(0.7, -0.55),
250 P(1.1, 0.9),
251 ])
252 if k == 'fish':
253 return ('poly', [
254 P(-1.05, 0), P(-0.55, -0.55), P(0.35, -0.55), P(0.75, -0.15),
255 P(1.1, -0.55), P(0.85, 0), P(1.1, 0.55), P(0.75, 0.15),
256 P(0.35, 0.55), P(-0.55, 0.55),
257 ])
258 if k == 'bird':
259 return ('poly', [
260 P(-1.05, 0.15), P(-0.3, -0.15), P(-0.05, -0.85), P(0.2, -0.15),
261 P(0.55, -0.25), P(1.05, 0.05), P(0.45, 0.15),
262 P(0.2, 0.85), P(-0.05, 0.2), P(-0.55, 0.45),
263 ])
264 if k == 'key':
265 # head circle + shaft + teeth as one poly
266 pts = []
267 for i in range(12):
268 a = -math.pi * 0.6 + i * 1.6 * math.pi / 11
269 pts.append(P(-0.55 + 0.42 * math.cos(a), -0.55 + 0.42 * math.sin(a)))
270 pts += [
271 P(-0.25, -0.2), P(1.05, -0.2), P(1.05, 0.15),
272 P(0.85, 0.15), P(0.85, 0.5), P(0.6, 0.5), P(0.6, 0.15),
273 P(0.4, 0.15), P(0.4, 0.38), P(0.15, 0.38), P(0.15, 0.15),
274 P(-0.25, 0.15),
275 ]
276 return ('poly', pts)
277 if k == 'comet':
278 return ('poly', [
279 P(0.95, -0.95), P(0.35, -0.45), P(0.15, -0.7), P(-0.15, -0.15),
280 P(0.15, -0.05), P(-1.05, 1.05), P(-0.05, 0.15), P(0.15, 0.35),
281 P(0.55, -0.15), P(0.45, -0.45),
282 ])
283 if k == 'clover':
284 lobes = []
285 for ang, ox, oy in ((0, 0, -0.42), (2.1, -0.4, 0.18), (4.2, 0.4, 0.18)):
286 pts = []
287 for i in range(16):
288 a = i * 2 * math.pi / 16
289 pts.append(P(ox + 0.42 * math.cos(a), oy + 0.42 * math.sin(a)))
290 lobes.append(pts)
291 stem = [P(-0.08, 0.35), P(0.08, 0.35), P(0.18, 1.05), P(-0.05, 1.05)]
292 lobes.append(stem)
293 return ('polys', lobes)
294 if k == 'paw':
295 pads = []
296 for ox, oy, rr in ((-0.5, -0.55, 0.28), (0, -0.75, 0.28), (0.5, -0.55, 0.28),
297 (0.0, 0.28, 0.52)):
298 pts = []
299 for i in range(16):
300 a = i * 2 * math.pi / 16
301 pts.append(P(ox + rr * math.cos(a), oy + rr * math.sin(a)))
302 pads.append(pts)
303 return ('polys', pads)
304 if k == 'sword':
305 return ('poly', [
306 P(-0.18, 1.1), P(-0.18, 0.45), P(-0.55, 0.45), P(-0.55, 0.22),
307 P(-0.18, 0.22), P(-0.18, -0.95), P(0, -1.15), P(0.18, -0.95),
308 P(0.18, 0.22), P(0.55, 0.22), P(0.55, 0.45), P(0.18, 0.45),
309 P(0.18, 1.1),
310 ])
311 if k == 'bell':
312 pts = []
313 for i in range(18):
314 a = math.pi + i * math.pi / 17
315 pts.append(P(0.85 * math.cos(a), -0.25 + 0.85 * math.sin(a)))
316 pts += [P(0.95, 0.55), P(0.7, 0.75), P(0.15, 0.75), P(0.15, 0.95),
317 P(-0.15, 0.95), P(-0.15, 0.75), P(-0.7, 0.75), P(-0.95, 0.55)]
318 return ('poly', pts)
319 if k == 'mushroom':
320 cap = []
321 for i in range(18):
322 a = math.pi + i * math.pi / 17
323 cap.append(P(0.95 * math.cos(a), -0.25 + 0.7 * math.sin(a)))
324 cap += [P(0.95, 0.05), P(-0.95, 0.05)]
325 stem = [P(-0.32, 0.05), P(0.32, 0.05), P(0.38, 1.05), P(-0.38, 1.05)]
326 return ('polys', [cap, stem])
327 if k == 'cactus':
328 return ('poly', [
329 P(-0.22, 1.05), P(-0.22, 0.15), P(-0.75, 0.15), P(-0.75, -0.35),
330 P(-0.5, -0.35), P(-0.5, -0.05), P(-0.22, -0.05), P(-0.22, -1.05),
331 P(0.22, -1.05), P(0.22, -0.25), P(0.55, -0.25), P(0.55, -0.7),
332 P(0.8, -0.7), P(0.8, -0.02), P(0.22, -0.02), P(0.22, 1.05),
333 ])
334 if k == 'ring':
335 return ('ring', 1.0, 0.55)
336 if k == 'flag':
337 return ('poly', [
338 P(-0.7, 1.1), P(-0.7, -1.05), P(-0.5, -1.05), P(-0.5, -0.85),
339 P(1.0, -0.85), P(0.7, -0.4), P(1.0, 0.05), P(-0.5, 0.05),
340 P(-0.5, 1.1),
341 ])
342 if k == 'snowflake':
343 arms = []
344 for k0 in range(6):
345 a = k0 * math.pi / 3
346 c, s = math.cos(a), math.sin(a)
347 def rot(x, y):
348 return P(x * c - y * s, x * s + y * c)
349 arms.append([rot(0, 0), rot(0, -1.05)])
350 arms.append([rot(-0.28, -0.6), rot(0, -0.4), rot(0.28, -0.6)])
351 return ('lines', arms, 0.22)
352 if k == 'flame_icon':
353 return ('poly', [
354 P(0, -1.15), P(0.35, -0.45), P(0.55, -0.7), P(0.75, -0.15),
355 P(0.55, 0.55), P(0.2, 1.0), P(-0.25, 1.0), P(-0.6, 0.5),
356 P(-0.7, -0.05), P(-0.35, -0.55), P(-0.15, -0.2),
357 ])
358 if k == 'ankh':
359 return ('lines', [
360 [P(0, 1.05), P(0, -0.25)],
361 [P(-0.55, 0.15), P(0.55, 0.15)],
362 ], 0.28) # loop added in combo
363 if k == 'yinyang':
364 return ('yinyang',)
365 if k == 'crescent':
366 # moon
367 return ('crescent',)
368 # fallback
369 return ('ellipse', [-1, -1, 1, 1])
370
371
372def draw_kind(draw, img, kind, cx, cy, r, fill, outline, width):
373 cmd = icon_path(cx, cy, r, kind)
374 kind_l = kind.lower()
375
376 def fill_poly(pts):
377 if len(pts) >= 3:
378 draw.polygon(pts, fill=fill, outline=outline, width=width)
379
380 def fill_lines(segs, wfrac):
381 w = max(width, int(r * wfrac))
382 # draw in outline color slightly thicker, then fill
383 thick_lines(draw, segs, outline, w + max(2, width // 2))
384 thick_lines(draw, segs, fill, w)
385
386 if cmd[0] == 'poly':
387 fill_poly(cmd[1])
388 elif cmd[0] == 'polys':
389 for pts in cmd[1]:
390 fill_poly(pts)
391 elif cmd[0] == 'lines':
392 fill_lines(cmd[1], cmd[2])
393 if kind_l == 'ankh':
394 # loop at top
395 box = [cx - r * 0.42, cy - r * 1.15, cx + r * 0.42, cy - r * 0.25]
396 draw.ellipse(box, outline=outline, width=int(r * 0.28) + width)
397 draw.ellipse([box[0] + r * 0.14, box[1] + r * 0.14,
398 box[2] - r * 0.14, box[3] - r * 0.14],
399 outline=fill, width=int(r * 0.16))
400 # fill ring by a second pass
401 # simpler: thick ellipse
402 w = int(r * 0.26)
403 draw.ellipse(box, outline=outline, width=w + width)
404 draw.ellipse(box, outline=fill, width=w)
405 elif cmd[0] == 'ellipse':
406 a, b, c, d = cmd[1]
407 box = [cx + a * r, cy + b * r, cx + c * r, cy + d * r]
408 draw.ellipse(box, fill=fill, outline=outline, width=width)
409 elif cmd[0] == 'roundrect':
410 a, b, c, d = cmd[1]
411 box = [cx + a * r, cy + b * r, cx + c * r, cy + d * r]
412 draw.rounded_rectangle(box, radius=r * cmd[2], fill=fill, outline=outline, width=width)
413 elif cmd[0] == 'ring':
414 _, ro, ri = cmd
415 outer = [cx - r * ro, cy - r * ro, cx + r * ro, cy + r * ro]
416 inner = [cx - r * ri, cy - r * ri, cx + r * ri, cy + r * ri]
417 draw.ellipse(outer, fill=fill, outline=outline, width=width)
418 # punch inner with destination-out
419 # We'll handle punch at a higher level; draw inner as transparent later
420 draw.ellipse(inner, fill=(0, 0, 0, 0), outline=outline, width=width)
421 elif cmd[0] == 'face':
422 box = [cx - r, cy - r, cx + r, cy + r]
423 draw.ellipse(box, fill=fill, outline=outline, width=width)
424 eye_c = outline
425 er = r * 0.12
426 if cmd[1] == 'wink':
427 draw.ellipse([cx - r * 0.38 - er, cy - r * 0.28 - er,
428 cx - r * 0.38 + er, cy - r * 0.28 + er], fill=eye_c)
429 draw.line([(cx + r * 0.18, cy - r * 0.28), (cx + r * 0.52, cy - r * 0.28)],
430 fill=eye_c, width=max(width, int(r * 0.12)))
431 elif cmd[1] == 'cool':
432 # sunglasses
433 draw.rounded_rectangle([cx - r * 0.7, cy - r * 0.42, cx - r * 0.08, cy - r * 0.08],
434 radius=r * 0.12, fill=eye_c)
435 draw.rounded_rectangle([cx + r * 0.08, cy - r * 0.42, cx + r * 0.7, cy - r * 0.08],
436 radius=r * 0.12, fill=eye_c)
437 draw.line([(cx - r * 0.08, cy - r * 0.25), (cx + r * 0.08, cy - r * 0.25)],
438 fill=eye_c, width=max(3, int(r * 0.1)))
439 else:
440 draw.ellipse([cx - r * 0.38 - er, cy - r * 0.28 - er,
441 cx - r * 0.38 + er, cy - r * 0.28 + er], fill=eye_c)
442 draw.ellipse([cx + r * 0.38 - er, cy - r * 0.28 - er,
443 cx + r * 0.38 + er, cy - r * 0.28 + er], fill=eye_c)
444 # smile
445 smile = []
446 for i in range(9):
447 a = math.pi * 0.2 + i * math.pi * 0.6 / 8
448 smile.append((cx + r * 0.48 * math.cos(a), cy + r * 0.12 + r * 0.42 * math.sin(a)))
449 sw = max(width, int(r * 0.12))
450 if cmd[1] == 'grin':
451 draw.chord([cx - r * 0.5, cy + r * 0.05, cx + r * 0.5, cy + r * 0.65],
452 start=0, end=180, fill=eye_c, outline=eye_c)
453 else:
454 draw.line(smile, fill=eye_c, width=sw, joint='curve')
455 elif cmd[0] == 'eye':
456 # almond
457 pts = []
458 for i in range(24):
459 t = i * 2 * math.pi / 24
460 x = math.cos(t)
461 y = 0.5 * math.sin(t)
462 pts.append((cx + r * 1.05 * x, cy + r * 0.85 * y))
463 fill_poly(pts)
464 iris_c = outline
465 draw.ellipse([cx - r * 0.38, cy - r * 0.38, cx + r * 0.38, cy + r * 0.38],
466 fill=iris_c)
467 draw.ellipse([cx - r * 0.14, cy - r * 0.18, cx + r * 0.06, cy + r * 0.02],
468 fill=lighten(fill[:3] if isinstance(fill, tuple) else (255, 255, 255), 0.8) + (255,))
469 elif cmd[0] == 'yinyang':
470 draw.ellipse([cx - r, cy - r, cx + r, cy + r], fill=fill, outline=outline, width=width)
471 # right half dark via chord is messy; draw a dark semicircle + two dots
472 # Use a path: top-center to bottom via right, with small circles
473 # We'll approximate with a pie and two discs
474 dark = outline
475 draw.pieslice([cx - r, cy - r, cx + r, cy + r], start=90, end=270, fill=dark)
476 draw.ellipse([cx - r * 0.5, cy - r, cx + r * 0.5, cy], fill=dark)
477 draw.ellipse([cx - r * 0.5, cy, cx + r * 0.5, cy + r], fill=fill)
478 # dots
479 draw.ellipse([cx - r * 0.16, cy - r * 0.58, cx + r * 0.16, cy - r * 0.26], fill=fill)
480 draw.ellipse([cx - r * 0.16, cy + r * 0.26, cx + r * 0.16, cy + r * 0.58], fill=dark)
481 draw.ellipse([cx - r, cy - r, cx + r, cy + r], outline=outline, width=width)
482 elif cmd[0] == 'crescent':
483 # moon: two circles, punch later — draw a crescent polygon
484 outer, inner = [], []
485 for i in range(24):
486 a = -math.pi * 0.75 + i * (1.5 * math.pi) / 23
487 outer.append((cx + r * math.cos(a) - r * 0.05, cy + r * math.sin(a)))
488 ox, oy = cx + r * 0.42, cy - r * 0.05
489 for i in range(20, -1, -1):
490 a = -math.pi * 0.7 + i * (1.4 * math.pi) / 20
491 inner.append((ox + r * 0.72 * math.cos(a), oy + r * 0.72 * math.sin(a)))
492 fill_poly(outer + inner)
493 else:
494 draw.ellipse([cx - r, cy - r, cx + r, cy + r], fill=fill, outline=outline, width=width)
495
496
497def render_block(hex_color, shape):
498 rgb = hex_rgb(hex_color)
499 hi = lighten(rgb, 0.42)
500 lo = darken(rgb, 0.32)
501 img = Image.new('RGBA', (SS, SS), (0, 0, 0, 0))
502 cx = cy = SS / 2
503 r = SS * 0.36
504 width = max(2, SCALE)
505 # drop shadow
506 shadow = Image.new('RGBA', (SS, SS), (0, 0, 0, 0))
507 sd = ImageDraw.Draw(shadow)
508 draw_kind(sd, shadow, shape, cx + SCALE * 1.2, cy + SCALE * 1.6, r,
509 (0, 0, 0, 90), None, 0)
510 shadow = shadow.filter(ImageFilter.GaussianBlur(radius=SCALE * 1.1))
511 img = Image.alpha_composite(img, shadow)
512 # For ring, punch a hole after drawing body
513 body = Image.new('RGBA', (SS, SS), (0, 0, 0, 0))
514 bd = ImageDraw.Draw(body)
515 draw_kind(bd, body, shape, cx, cy, r, rgb + (255,), lo + (255,), width)
516 if shape == 'ring':
517 # punch inner hole
518 mask = Image.new('L', (SS, SS), 0)
519 md = ImageDraw.Draw(mask)
520 ri = r * 0.55
521 md.ellipse([cx - ri, cy - ri, cx + ri, cy + ri], fill=255)
522 clear = Image.new('RGBA', (SS, SS), (0, 0, 0, 0))
523 body = Image.composite(clear, body, mask)
524 # redraw inner outline
525 bd = ImageDraw.Draw(body)
526 bd.ellipse([cx - ri, cy - ri, cx + ri, cy + ri], outline=lo + (255,), width=width)
527 img = Image.alpha_composite(img, body)
528 # highlight
529 hi_layer = Image.new('RGBA', (SS, SS), (0, 0, 0, 0))
530 hd = ImageDraw.Draw(hi_layer)
531 draw_kind(hd, hi_layer, shape, cx - r * 0.06, cy - r * 0.10, r * 0.55,
532 hi + (110,), None, 0)
533 hi_layer = hi_layer.filter(ImageFilter.GaussianBlur(radius=SCALE * 0.6))
534 # clip highlight to body alpha
535 body_a = body.split()[3]
536 ha = hi_layer.split()[3]
537 from PIL import ImageChops
538 ha = ImageChops.multiply(ha, body_a)
539 hi_layer.putalpha(ha)
540 img = Image.alpha_composite(img, hi_layer)
541 return img.resize((SIZE, SIZE), Image.Resampling.LANCZOS)
542
543
544# New unlockable blocks, appended after official catalog colours.
545# ids are stable and must never be reordered or reused.
546NEW_BLOCKS = [
547 # Runes
548 {'id': 'rune-fehu', 'name': 'Fehu', 'hex': '#e8a44a', 'shape': 'rune_fehu'},
549 {'id': 'rune-ansuz', 'name': 'Ansuz', 'hex': '#6ab0e8', 'shape': 'rune_ansuz'},
550 {'id': 'rune-thurisaz', 'name': 'Thurisaz', 'hex': '#c05040', 'shape': 'rune_thurisaz'},
551 {'id': 'rune-raido', 'name': 'Raido', 'hex': '#d0c070', 'shape': 'rune_raido'},
552 {'id': 'rune-sowilo', 'name': 'Sowilo', 'hex': '#f0d040', 'shape': 'rune_sowilo'},
553 {'id': 'rune-algiz', 'name': 'Algiz', 'hex': '#80d0a0', 'shape': 'rune_algiz'},
554 # Arrows
555 {'id': 'arrow-up', 'name': 'Arrow', 'hex': '#f07040', 'shape': 'arrow'},
556 {'id': 'arrow-chevron', 'name': 'Chevron', 'hex': '#50c0e0', 'shape': 'chevron'},
557 {'id': 'arrow-double', 'name': 'Double Arrow', 'hex': '#e05080', 'shape': 'double_arrow'},
558 {'id': 'arrow-return', 'name': 'Return', 'hex': '#a080e0', 'shape': 'return_arrow'},
559 # Figures
560 {'id': 'fig-person', 'name': 'Figure', 'hex': '#f0c0a0', 'shape': 'person'},
561 {'id': 'fig-walker', 'name': 'Walker', 'hex': '#c09070', 'shape': 'walker'},
562 {'id': 'fig-hero', 'name': 'Hero', 'hex': '#e8b070', 'shape': 'hero'},
563 # Faces
564 {'id': 'face-smile', 'name': 'Smile', 'hex': '#f0d060', 'shape': 'smile'},
565 {'id': 'face-wink', 'name': 'Wink', 'hex': '#f0a050', 'shape': 'wink'},
566 {'id': 'face-cool', 'name': 'Cool', 'hex': '#6090d0', 'shape': 'cool'},
567 {'id': 'face-grin', 'name': 'Grin', 'hex': '#f0c848', 'shape': 'grin'},
568 # Icons
569 {'id': 'icon-heart', 'name': 'Heart', 'hex': '#e04060', 'shape': 'heart'},
570 {'id': 'icon-moon', 'name': 'Moon', 'hex': '#d0d8f0', 'shape': 'crescent'},
571 {'id': 'icon-bolt', 'name': 'Bolt', 'hex': '#f0e050', 'shape': 'lightning'},
572 {'id': 'icon-shield', 'name': 'Shield', 'hex': '#5080c0', 'shape': 'shield'},
573 {'id': 'icon-crown', 'name': 'Crown', 'hex': '#f0c030', 'shape': 'crown'},
574 {'id': 'icon-eye', 'name': 'Eye', 'hex': '#70d0c0', 'shape': 'eye'},
575 {'id': 'icon-star6', 'name': 'Hexastar', 'hex': '#f0e8a0', 'shape': 'star6'},
576 {'id': 'icon-spiral', 'name': 'Spiral', 'hex': '#c070d0', 'shape': 'spiral'},
577 {'id': 'icon-wave', 'name': 'Wave', 'hex': '#3090d0', 'shape': 'wave'},
578 {'id': 'icon-mountain', 'name': 'Mountain', 'hex': '#809070', 'shape': 'mountain'},
579 {'id': 'icon-fish', 'name': 'Fish', 'hex': '#40a8c8', 'shape': 'fish'},
580 {'id': 'icon-bird', 'name': 'Bird', 'hex': '#e07050', 'shape': 'bird'},
581 {'id': 'icon-key', 'name': 'Key', 'hex': '#d0b050', 'shape': 'key'},
582 {'id': 'icon-comet', 'name': 'Comet', 'hex': '#90d0f0', 'shape': 'comet'},
583 {'id': 'icon-clover', 'name': 'Clover', 'hex': '#40b060', 'shape': 'clover'},
584 {'id': 'icon-paw', 'name': 'Paw', 'hex': '#c08050', 'shape': 'paw'},
585 {'id': 'icon-sword', 'name': 'Sword', 'hex': '#b0b8c0', 'shape': 'sword'},
586 {'id': 'icon-bell', 'name': 'Bell', 'hex': '#f0c848', 'shape': 'bell'},
587 {'id': 'icon-mushroom', 'name': 'Mushroom', 'hex': '#e06050', 'shape': 'mushroom'},
588 {'id': 'icon-cactus', 'name': 'Cactus', 'hex': '#50b068', 'shape': 'cactus'},
589 {'id': 'icon-ring', 'name': 'Ring', 'hex': '#e8d080', 'shape': 'ring'},
590 {'id': 'icon-flag', 'name': 'Flag', 'hex': '#d04050', 'shape': 'flag'},
591 {'id': 'icon-snow', 'name': 'Snowflake', 'hex': '#c8e0f8', 'shape': 'snowflake'},
592 {'id': 'icon-flame', 'name': 'Flame', 'hex': '#ff7030', 'shape': 'flame_icon'},
593 {'id': 'icon-ankh', 'name': 'Ankh', 'hex': '#d0a060', 'shape': 'ankh'},
594 {'id': 'icon-yin', 'name': 'Yin Yang', 'hex': '#606080', 'shape': 'yinyang'},
595]
596
597
598def official_blocks(catalog):
599 out = []
600 seen = set()
601 for planet in catalog['planets']:
602 pid = planet['id']
603 for c in planet['colors']:
604 bid = f"{pid}-{c['name']}"
605 if bid in seen:
606 raise SystemExit(f'duplicate official id {bid}')
607 seen.add(bid)
608 out.append({
609 'id': bid,
610 'name': c['name'].capitalize() if pid == 'terra' else f"{planet['name']} {c['name']}",
611 'hex': c['hex'],
612 'shape': c.get('shape') or 'circle',
613 'image': c['image'],
614 'terra': pid == 'terra',
615 })
616 return out
617
618
619def main():
620 catalog = json.loads(CATALOG.read_text())
621 official = official_blocks(catalog)
622 terra = [b for b in official if b.get('terra')]
623 others = [b for b in official if not b.get('terra')]
624 if len(terra) != 5 or terra[0]['id'] != 'terra-ember':
625 raise SystemExit(f'Terra five unexpected: {[b["id"] for b in terra]}')
626
627 new = []
628 seen = {b['id'] for b in official}
629 OUT_IMG.mkdir(parents=True, exist_ok=True)
630 for b in NEW_BLOCKS:
631 if b['id'] in seen:
632 raise SystemExit(f'duplicate new id {b["id"]}')
633 seen.add(b['id'])
634 image = f"images/block-{b['id']}.png"
635 path = ROOT / 'build' / image
636 img = render_block(b['hex'], b['shape'])
637 img.save(path, 'PNG', optimize=True)
638 new.append({
639 'id': b['id'],
640 'name': b['name'],
641 'hex': b['hex'],
642 'shape': b['shape'],
643 'image': image,
644 'terra': False,
645 })
646 print(f' wrote {path.relative_to(ROOT)} ({path.stat().st_size} bytes)')
647
648 registry = {
649 '_comment': (
650 'Append-only block registry. Never reorder, rename ids, or insert '
651 'in the middle. New blocks go at the end. The first five (Terra) '
652 'are unlocked by default; index 5 requires 500 lifetime points, '
653 'each next index requires 14.5% more (rounded).'
654 ),
655 'terraCount': 5,
656 'firstThreshold': 500,
657 'thresholdGrowth': 1.145,
658 'blocks': terra + new + others,
659 }
660 OUT_JSON.write_text(json.dumps(registry, indent=2, ensure_ascii=False) + '\n')
661 print(f'wrote {OUT_JSON.relative_to(ROOT)}: {len(terra)} terra + {len(new)} new + {len(others)} official = {len(registry["blocks"])} total')
662
663
664if __name__ == '__main__':
665 main()
server/lib/Blocks.php added +141 −0
@@ -0,0 +1,141 @@
1 <?php
2 declare(strict_types=1);
3
4 /**
5 * Append-only block registry shared with the JS client (server/lib/blocks.json).
6 * Never reorder entries; new blocks are appended. Thresholds stay in lockstep
7 * with src/blocks.js: Terra's first five are free; index 5 costs 500 lifetime
8 * points, each next index costs 14.5% more (rounded to a strictly increasing int).
9 */
10 final class Blocks
11 {
12 public const TERRA_COUNT = 5;
13 public const FIRST_THRESHOLD = 500;
14 public const GROWTH = 1.145;
15
16 private static ?array $all = null;
17 private static ?array $byId = null;
18
19 public static function path(): string
20 {
21 return __DIR__ . '/blocks.json';
22 }
23
24 /** @return list<array> */
25 public static function all(): array
26 {
27 if (self::$all !== null) {
28 return self::$all;
29 }
30 $raw = file_get_contents(self::path());
31 if ($raw === false) {
32 throw new RuntimeException('blocks.json ontbreekt.');
33 }
34 $data = json_decode($raw, true);
35 if (!is_array($data) || !isset($data['blocks']) || !is_array($data['blocks'])) {
36 throw new RuntimeException('blocks.json is ongeldig.');
37 }
38 self::$all = [];
39 self::$byId = [];
40 foreach ($data['blocks'] as $i => $row) {
41 if (!is_array($row) || empty($row['id'])) {
42 continue;
43 }
44 $row['_index'] = $i;
45 self::$all[] = $row;
46 self::$byId[(string) $row['id']] = $row;
47 }
48 if (count(self::$all) < self::TERRA_COUNT) {
49 throw new RuntimeException('blocks.json mist de Terra-blokjes.');
50 }
51 return self::$all;
52 }
53
54 public static function byId(string $id): ?array
55 {
56 if (self::$byId === null) {
57 self::all();
58 }
59 return self::$byId[$id] ?? null;
60 }
61
62 public static function known(string $id): bool
63 {
64 return self::byId($id) !== null;
65 }
66
67 public static function indexOf(string $id): ?int
68 {
69 $b = self::byId($id);
70 return $b !== null ? (int) $b['_index'] : null;
71 }
72
73 public static function isTerra(string $id): bool
74 {
75 $i = self::indexOf($id);
76 return $i !== null && $i < self::TERRA_COUNT;
77 }
78
79 /** Lifetime points required to unlock the block at $index (0-based). */
80 public static function threshold(int $index): int
81 {
82 if ($index < self::TERRA_COUNT) {
83 return 0;
84 }
85 $t = self::FIRST_THRESHOLD;
86 for ($i = self::TERRA_COUNT; $i < $index; $i++) {
87 $next = (int) round($t * self::GROWTH);
88 $t = max($t + 1, $next);
89 }
90 return $t;
91 }
92
93 public static function unlocked(int $index, int $points): bool
94 {
95 return $points >= self::threshold($index);
96 }
97
98 public static function unlockedId(string $id, int $points): bool
99 {
100 $i = self::indexOf($id);
101 return $i !== null && self::unlocked($i, $points);
102 }
103
104 /** Public list for the client: every block plus its threshold and unlock state. */
105 public static function present(int $points): array
106 {
107 $out = [];
108 foreach (self::all() as $i => $b) {
109 $need = self::threshold($i);
110 $out[] = [
111 'id' => (string) $b['id'],
112 'name' => (string) ($b['name'] ?? $b['id']),
113 'hex' => (string) ($b['hex'] ?? '#888'),
114 'shape' => (string) ($b['shape'] ?? ''),
115 'image' => (string) ($b['image'] ?? ''),
116 'terra' => !empty($b['terra']) || $i < self::TERRA_COUNT,
117 'index' => $i,
118 'threshold' => $need,
119 'unlocked' => $points >= $need,
120 ];
121 }
122 return $out;
123 }
124
125 /** Resolve a registry id to a planet-slot colour (with a 0–4 slot id). */
126 public static function asColor(string $id, int $slot): ?array
127 {
128 $b = self::byId($id);
129 if ($b === null) {
130 return null;
131 }
132 return [
133 'id' => $slot,
134 'block' => (string) $b['id'],
135 'name' => (string) ($b['name'] ?? $b['id']),
136 'hex' => (string) ($b['hex'] ?? '#888'),
137 'shape' => (string) ($b['shape'] ?? ''),
138 'image' => (string) ($b['image'] ?? ''),
139 ];
140 }
141 }
@@ -0,0 +1,141 @@
1<?php
2declare(strict_types=1);
3
4/**
5 * Append-only block registry shared with the JS client (server/lib/blocks.json).
6 * Never reorder entries; new blocks are appended. Thresholds stay in lockstep
7 * with src/blocks.js: Terra's first five are free; index 5 costs 500 lifetime
8 * points, each next index costs 14.5% more (rounded to a strictly increasing int).
9 */
10final class Blocks
11{
12 public const TERRA_COUNT = 5;
13 public const FIRST_THRESHOLD = 500;
14 public const GROWTH = 1.145;
15
16 private static ?array $all = null;
17 private static ?array $byId = null;
18
19 public static function path(): string
20 {
21 return __DIR__ . '/blocks.json';
22 }
23
24 /** @return list<array> */
25 public static function all(): array
26 {
27 if (self::$all !== null) {
28 return self::$all;
29 }
30 $raw = file_get_contents(self::path());
31 if ($raw === false) {
32 throw new RuntimeException('blocks.json ontbreekt.');
33 }
34 $data = json_decode($raw, true);
35 if (!is_array($data) || !isset($data['blocks']) || !is_array($data['blocks'])) {
36 throw new RuntimeException('blocks.json is ongeldig.');
37 }
38 self::$all = [];
39 self::$byId = [];
40 foreach ($data['blocks'] as $i => $row) {
41 if (!is_array($row) || empty($row['id'])) {
42 continue;
43 }
44 $row['_index'] = $i;
45 self::$all[] = $row;
46 self::$byId[(string) $row['id']] = $row;
47 }
48 if (count(self::$all) < self::TERRA_COUNT) {
49 throw new RuntimeException('blocks.json mist de Terra-blokjes.');
50 }
51 return self::$all;
52 }
53
54 public static function byId(string $id): ?array
55 {
56 if (self::$byId === null) {
57 self::all();
58 }
59 return self::$byId[$id] ?? null;
60 }
61
62 public static function known(string $id): bool
63 {
64 return self::byId($id) !== null;
65 }
66
67 public static function indexOf(string $id): ?int
68 {
69 $b = self::byId($id);
70 return $b !== null ? (int) $b['_index'] : null;
71 }
72
73 public static function isTerra(string $id): bool
74 {
75 $i = self::indexOf($id);
76 return $i !== null && $i < self::TERRA_COUNT;
77 }
78
79 /** Lifetime points required to unlock the block at $index (0-based). */
80 public static function threshold(int $index): int
81 {
82 if ($index < self::TERRA_COUNT) {
83 return 0;
84 }
85 $t = self::FIRST_THRESHOLD;
86 for ($i = self::TERRA_COUNT; $i < $index; $i++) {
87 $next = (int) round($t * self::GROWTH);
88 $t = max($t + 1, $next);
89 }
90 return $t;
91 }
92
93 public static function unlocked(int $index, int $points): bool
94 {
95 return $points >= self::threshold($index);
96 }
97
98 public static function unlockedId(string $id, int $points): bool
99 {
100 $i = self::indexOf($id);
101 return $i !== null && self::unlocked($i, $points);
102 }
103
104 /** Public list for the client: every block plus its threshold and unlock state. */
105 public static function present(int $points): array
106 {
107 $out = [];
108 foreach (self::all() as $i => $b) {
109 $need = self::threshold($i);
110 $out[] = [
111 'id' => (string) $b['id'],
112 'name' => (string) ($b['name'] ?? $b['id']),
113 'hex' => (string) ($b['hex'] ?? '#888'),
114 'shape' => (string) ($b['shape'] ?? ''),
115 'image' => (string) ($b['image'] ?? ''),
116 'terra' => !empty($b['terra']) || $i < self::TERRA_COUNT,
117 'index' => $i,
118 'threshold' => $need,
119 'unlocked' => $points >= $need,
120 ];
121 }
122 return $out;
123 }
124
125 /** Resolve a registry id to a planet-slot colour (with a 0–4 slot id). */
126 public static function asColor(string $id, int $slot): ?array
127 {
128 $b = self::byId($id);
129 if ($b === null) {
130 return null;
131 }
132 return [
133 'id' => $slot,
134 'block' => (string) $b['id'],
135 'name' => (string) ($b['name'] ?? $b['id']),
136 'hex' => (string) ($b['hex'] ?? '#888'),
137 'shape' => (string) ($b['shape'] ?? ''),
138 'image' => (string) ($b['image'] ?? ''),
139 ];
140 }
141}
server/lib/blocks.json added +832 −0
@@ -0,0 +1,832 @@
1 {
2 "_comment": "Append-only block registry. Never reorder, rename ids, or insert in the middle. New blocks go at the end. The first five (Terra) are unlocked by default; index 5 requires 500 lifetime points, each next index requires 14.5% more (rounded).",
3 "terraCount": 5,
4 "firstThreshold": 500,
5 "thresholdGrowth": 1.145,
6 "blocks": [
7 {
8 "id": "terra-ember",
9 "name": "Ember",
10 "hex": "#e85d3a",
11 "shape": "triangle",
12 "image": "images/block-terra-ember.png",
13 "terra": true
14 },
15 {
16 "id": "terra-aqua",
17 "name": "Aqua",
18 "hex": "#3db8e8",
19 "shape": "circle",
20 "image": "images/block-terra-aqua.png",
21 "terra": true
22 },
23 {
24 "id": "terra-leaf",
25 "name": "Leaf",
26 "hex": "#4cbf4c",
27 "shape": "square",
28 "image": "images/block-terra-leaf.png",
29 "terra": true
30 },
31 {
32 "id": "terra-sun",
33 "name": "Sun",
34 "hex": "#f0c53a",
35 "shape": "diamond",
36 "image": "images/block-terra-sun.png",
37 "terra": true
38 },
39 {
40 "id": "terra-orchid",
41 "name": "Orchid",
42 "hex": "#c45ad4",
43 "shape": "star",
44 "image": "images/block-terra-orchid.png",
45 "terra": true
46 },
47 {
48 "id": "rune-fehu",
49 "name": "Fehu",
50 "hex": "#e8a44a",
51 "shape": "rune_fehu",
52 "image": "images/block-rune-fehu.png",
53 "terra": false
54 },
55 {
56 "id": "rune-ansuz",
57 "name": "Ansuz",
58 "hex": "#6ab0e8",
59 "shape": "rune_ansuz",
60 "image": "images/block-rune-ansuz.png",
61 "terra": false
62 },
63 {
64 "id": "rune-thurisaz",
65 "name": "Thurisaz",
66 "hex": "#c05040",
67 "shape": "rune_thurisaz",
68 "image": "images/block-rune-thurisaz.png",
69 "terra": false
70 },
71 {
72 "id": "rune-raido",
73 "name": "Raido",
74 "hex": "#d0c070",
75 "shape": "rune_raido",
76 "image": "images/block-rune-raido.png",
77 "terra": false
78 },
79 {
80 "id": "rune-sowilo",
81 "name": "Sowilo",
82 "hex": "#f0d040",
83 "shape": "rune_sowilo",
84 "image": "images/block-rune-sowilo.png",
85 "terra": false
86 },
87 {
88 "id": "rune-algiz",
89 "name": "Algiz",
90 "hex": "#80d0a0",
91 "shape": "rune_algiz",
92 "image": "images/block-rune-algiz.png",
93 "terra": false
94 },
95 {
96 "id": "arrow-up",
97 "name": "Arrow",
98 "hex": "#f07040",
99 "shape": "arrow",
100 "image": "images/block-arrow-up.png",
101 "terra": false
102 },
103 {
104 "id": "arrow-chevron",
105 "name": "Chevron",
106 "hex": "#50c0e0",
107 "shape": "chevron",
108 "image": "images/block-arrow-chevron.png",
109 "terra": false
110 },
111 {
112 "id": "arrow-double",
113 "name": "Double Arrow",
114 "hex": "#e05080",
115 "shape": "double_arrow",
116 "image": "images/block-arrow-double.png",
117 "terra": false
118 },
119 {
120 "id": "arrow-return",
121 "name": "Return",
122 "hex": "#a080e0",
123 "shape": "return_arrow",
124 "image": "images/block-arrow-return.png",
125 "terra": false
126 },
127 {
128 "id": "fig-person",
129 "name": "Figure",
130 "hex": "#f0c0a0",
131 "shape": "person",
132 "image": "images/block-fig-person.png",
133 "terra": false
134 },
135 {
136 "id": "fig-walker",
137 "name": "Walker",
138 "hex": "#c09070",
139 "shape": "walker",
140 "image": "images/block-fig-walker.png",
141 "terra": false
142 },
143 {
144 "id": "fig-hero",
145 "name": "Hero",
146 "hex": "#e8b070",
147 "shape": "hero",
148 "image": "images/block-fig-hero.png",
149 "terra": false
150 },
151 {
152 "id": "face-smile",
153 "name": "Smile",
154 "hex": "#f0d060",
155 "shape": "smile",
156 "image": "images/block-face-smile.png",
157 "terra": false
158 },
159 {
160 "id": "face-wink",
161 "name": "Wink",
162 "hex": "#f0a050",
163 "shape": "wink",
164 "image": "images/block-face-wink.png",
165 "terra": false
166 },
167 {
168 "id": "face-cool",
169 "name": "Cool",
170 "hex": "#6090d0",
171 "shape": "cool",
172 "image": "images/block-face-cool.png",
173 "terra": false
174 },
175 {
176 "id": "face-grin",
177 "name": "Grin",
178 "hex": "#f0c848",
179 "shape": "grin",
180 "image": "images/block-face-grin.png",
181 "terra": false
182 },
183 {
184 "id": "icon-heart",
185 "name": "Heart",
186 "hex": "#e04060",
187 "shape": "heart",
188 "image": "images/block-icon-heart.png",
189 "terra": false
190 },
191 {
192 "id": "icon-moon",
193 "name": "Moon",
194 "hex": "#d0d8f0",
195 "shape": "crescent",
196 "image": "images/block-icon-moon.png",
197 "terra": false
198 },
199 {
200 "id": "icon-bolt",
201 "name": "Bolt",
202 "hex": "#f0e050",
203 "shape": "lightning",
204 "image": "images/block-icon-bolt.png",
205 "terra": false
206 },
207 {
208 "id": "icon-shield",
209 "name": "Shield",
210 "hex": "#5080c0",
211 "shape": "shield",
212 "image": "images/block-icon-shield.png",
213 "terra": false
214 },
215 {
216 "id": "icon-crown",
217 "name": "Crown",
218 "hex": "#f0c030",
219 "shape": "crown",
220 "image": "images/block-icon-crown.png",
221 "terra": false
222 },
223 {
224 "id": "icon-eye",
225 "name": "Eye",
226 "hex": "#70d0c0",
227 "shape": "eye",
228 "image": "images/block-icon-eye.png",
229 "terra": false
230 },
231 {
232 "id": "icon-star6",
233 "name": "Hexastar",
234 "hex": "#f0e8a0",
235 "shape": "star6",
236 "image": "images/block-icon-star6.png",
237 "terra": false
238 },
239 {
240 "id": "icon-spiral",
241 "name": "Spiral",
242 "hex": "#c070d0",
243 "shape": "spiral",
244 "image": "images/block-icon-spiral.png",
245 "terra": false
246 },
247 {
248 "id": "icon-wave",
249 "name": "Wave",
250 "hex": "#3090d0",
251 "shape": "wave",
252 "image": "images/block-icon-wave.png",
253 "terra": false
254 },
255 {
256 "id": "icon-mountain",
257 "name": "Mountain",
258 "hex": "#809070",
259 "shape": "mountain",
260 "image": "images/block-icon-mountain.png",
261 "terra": false
262 },
263 {
264 "id": "icon-fish",
265 "name": "Fish",
266 "hex": "#40a8c8",
267 "shape": "fish",
268 "image": "images/block-icon-fish.png",
269 "terra": false
270 },
271 {
272 "id": "icon-bird",
273 "name": "Bird",
274 "hex": "#e07050",
275 "shape": "bird",
276 "image": "images/block-icon-bird.png",
277 "terra": false
278 },
279 {
280 "id": "icon-key",
281 "name": "Key",
282 "hex": "#d0b050",
283 "shape": "key",
284 "image": "images/block-icon-key.png",
285 "terra": false
286 },
287 {
288 "id": "icon-comet",
289 "name": "Comet",
290 "hex": "#90d0f0",
291 "shape": "comet",
292 "image": "images/block-icon-comet.png",
293 "terra": false
294 },
295 {
296 "id": "icon-clover",
297 "name": "Clover",
298 "hex": "#40b060",
299 "shape": "clover",
300 "image": "images/block-icon-clover.png",
301 "terra": false
302 },
303 {
304 "id": "icon-paw",
305 "name": "Paw",
306 "hex": "#c08050",
307 "shape": "paw",
308 "image": "images/block-icon-paw.png",
309 "terra": false
310 },
311 {
312 "id": "icon-sword",
313 "name": "Sword",
314 "hex": "#b0b8c0",
315 "shape": "sword",
316 "image": "images/block-icon-sword.png",
317 "terra": false
318 },
319 {
320 "id": "icon-bell",
321 "name": "Bell",
322 "hex": "#f0c848",
323 "shape": "bell",
324 "image": "images/block-icon-bell.png",
325 "terra": false
326 },
327 {
328 "id": "icon-mushroom",
329 "name": "Mushroom",
330 "hex": "#e06050",
331 "shape": "mushroom",
332 "image": "images/block-icon-mushroom.png",
333 "terra": false
334 },
335 {
336 "id": "icon-cactus",
337 "name": "Cactus",
338 "hex": "#50b068",
339 "shape": "cactus",
340 "image": "images/block-icon-cactus.png",
341 "terra": false
342 },
343 {
344 "id": "icon-ring",
345 "name": "Ring",
346 "hex": "#e8d080",
347 "shape": "ring",
348 "image": "images/block-icon-ring.png",
349 "terra": false
350 },
351 {
352 "id": "icon-flag",
353 "name": "Flag",
354 "hex": "#d04050",
355 "shape": "flag",
356 "image": "images/block-icon-flag.png",
357 "terra": false
358 },
359 {
360 "id": "icon-snow",
361 "name": "Snowflake",
362 "hex": "#c8e0f8",
363 "shape": "snowflake",
364 "image": "images/block-icon-snow.png",
365 "terra": false
366 },
367 {
368 "id": "icon-flame",
369 "name": "Flame",
370 "hex": "#ff7030",
371 "shape": "flame_icon",
372 "image": "images/block-icon-flame.png",
373 "terra": false
374 },
375 {
376 "id": "icon-ankh",
377 "name": "Ankh",
378 "hex": "#d0a060",
379 "shape": "ankh",
380 "image": "images/block-icon-ankh.png",
381 "terra": false
382 },
383 {
384 "id": "icon-yin",
385 "name": "Yin Yang",
386 "hex": "#606080",
387 "shape": "yinyang",
388 "image": "images/block-icon-yin.png",
389 "terra": false
390 },
391 {
392 "id": "aurel-gold",
393 "name": "Aurel gold",
394 "hex": "#f4c860",
395 "shape": "hexagon",
396 "image": "images/block-aurel-gold.png",
397 "terra": false
398 },
399 {
400 "id": "aurel-cream",
401 "name": "Aurel cream",
402 "hex": "#f6e7c1",
403 "shape": "circle",
404 "image": "images/block-aurel-cream.png",
405 "terra": false
406 },
407 {
408 "id": "aurel-amber",
409 "name": "Aurel amber",
410 "hex": "#e09a3e",
411 "shape": "teardrop",
412 "image": "images/block-aurel-amber.png",
413 "terra": false
414 },
415 {
416 "id": "aurel-sage",
417 "name": "Aurel sage",
418 "hex": "#8fb86f",
419 "shape": "plus",
420 "image": "images/block-aurel-sage.png",
421 "terra": false
422 },
423 {
424 "id": "aurel-rose",
425 "name": "Aurel rose",
426 "hex": "#e8a0a8",
427 "shape": "pentagon",
428 "image": "images/block-aurel-rose.png",
429 "terra": false
430 },
431 {
432 "id": "cinder-magma",
433 "name": "Cinder magma",
434 "hex": "#ff3b1f",
435 "shape": "triangle",
436 "image": "images/block-cinder-magma.png",
437 "terra": false
438 },
439 {
440 "id": "cinder-coal",
441 "name": "Cinder coal",
442 "hex": "#3a3232",
443 "shape": "square",
444 "image": "images/block-cinder-coal.png",
445 "terra": false
446 },
447 {
448 "id": "cinder-spark",
449 "name": "Cinder spark",
450 "hex": "#ffb347",
451 "shape": "diamond",
452 "image": "images/block-cinder-spark.png",
453 "terra": false
454 },
455 {
456 "id": "cinder-ash",
457 "name": "Cinder ash",
458 "hex": "#8a7a76",
459 "shape": "circle",
460 "image": "images/block-cinder-ash.png",
461 "terra": false
462 },
463 {
464 "id": "cinder-core",
465 "name": "Cinder core",
466 "hex": "#ff6a00",
467 "shape": "star",
468 "image": "images/block-cinder-core.png",
469 "terra": false
470 },
471 {
472 "id": "lunara-silver",
473 "name": "Lunara silver",
474 "hex": "#c5d0e0",
475 "shape": "circle",
476 "image": "images/block-lunara-silver.png",
477 "terra": false
478 },
479 {
480 "id": "lunara-dust",
481 "name": "Lunara dust",
482 "hex": "#8b90a0",
483 "shape": "diamond",
484 "image": "images/block-lunara-dust.png",
485 "terra": false
486 },
487 {
488 "id": "lunara-pale",
489 "name": "Lunara pale",
490 "hex": "#e8d9a8",
491 "shape": "crescent",
492 "image": "images/block-lunara-pale.png",
493 "terra": false
494 },
495 {
496 "id": "lunara-void",
497 "name": "Lunara void",
498 "hex": "#2c3348",
499 "shape": "square",
500 "image": "images/block-lunara-void.png",
501 "terra": false
502 },
503 {
504 "id": "lunara-lilac",
505 "name": "Lunara lilac",
506 "hex": "#b9a4d4",
507 "shape": "star",
508 "image": "images/block-lunara-lilac.png",
509 "terra": false
510 },
511 {
512 "id": "mire-moss",
513 "name": "Mire moss",
514 "hex": "#3d7a45",
515 "shape": "hexagon",
516 "image": "images/block-mire-moss.png",
517 "terra": false
518 },
519 {
520 "id": "mire-bog",
521 "name": "Mire bog",
522 "hex": "#1f4d3a",
523 "shape": "teardrop",
524 "image": "images/block-mire-bog.png",
525 "terra": false
526 },
527 {
528 "id": "mire-rust",
529 "name": "Mire rust",
530 "hex": "#8b5a2b",
531 "shape": "pentagon",
532 "image": "images/block-mire-rust.png",
533 "terra": false
534 },
535 {
536 "id": "mire-spore",
537 "name": "Mire spore",
538 "hex": "#9cbf5a",
539 "shape": "circle",
540 "image": "images/block-mire-spore.png",
541 "terra": false
542 },
543 {
544 "id": "mire-murk",
545 "name": "Mire murk",
546 "hex": "#2e3b2f",
547 "shape": "diamond",
548 "image": "images/block-mire-murk.png",
549 "terra": false
550 },
551 {
552 "id": "galeon-sky",
553 "name": "Galeon sky",
554 "hex": "#4aa3ff",
555 "shape": "arrow",
556 "image": "images/block-galeon-sky.png",
557 "terra": false
558 },
559 {
560 "id": "galeon-cloud",
561 "name": "Galeon cloud",
562 "hex": "#e8eef6",
563 "shape": "circle",
564 "image": "images/block-galeon-cloud.png",
565 "terra": false
566 },
567 {
568 "id": "galeon-storm",
569 "name": "Galeon storm",
570 "hex": "#3d4d6e",
571 "shape": "square",
572 "image": "images/block-galeon-storm.png",
573 "terra": false
574 },
575 {
576 "id": "galeon-sand",
577 "name": "Galeon sand",
578 "hex": "#d4b483",
579 "shape": "diamond",
580 "image": "images/block-galeon-sand.png",
581 "terra": false
582 },
583 {
584 "id": "galeon-kite",
585 "name": "Galeon kite",
586 "hex": "#7fd0c0",
587 "shape": "star",
588 "image": "images/block-galeon-kite.png",
589 "terra": false
590 },
591 {
592 "id": "obsid-glass",
593 "name": "Obsid glass",
594 "hex": "#1a1a22",
595 "shape": "gem",
596 "image": "images/block-obsid-glass.png",
597 "terra": false
598 },
599 {
600 "id": "obsid-violet",
601 "name": "Obsid violet",
602 "hex": "#5a3d8a",
603 "shape": "hexagon",
604 "image": "images/block-obsid-violet.png",
605 "terra": false
606 },
607 {
608 "id": "obsid-shard",
609 "name": "Obsid shard",
610 "hex": "#8a8aa0",
611 "shape": "triangle",
612 "image": "images/block-obsid-shard.png",
613 "terra": false
614 },
615 {
616 "id": "obsid-vein",
617 "name": "Obsid vein",
618 "hex": "#c45a3a",
619 "shape": "diamond",
620 "image": "images/block-obsid-vein.png",
621 "terra": false
622 },
623 {
624 "id": "obsid-basalt",
625 "name": "Obsid basalt",
626 "hex": "#3a3a42",
627 "shape": "square",
628 "image": "images/block-obsid-basalt.png",
629 "terra": false
630 },
631 {
632 "id": "wisp-glow",
633 "name": "Wisp glow",
634 "hex": "#c8ffe0",
635 "shape": "circle",
636 "image": "images/block-wisp-glow.png",
637 "terra": false
638 },
639 {
640 "id": "wisp-mist",
641 "name": "Wisp mist",
642 "hex": "#a8d4e8",
643 "shape": "diamond",
644 "image": "images/block-wisp-mist.png",
645 "terra": false
646 },
647 {
648 "id": "wisp-sparkle",
649 "name": "Wisp sparkle",
650 "hex": "#fff6a8",
651 "shape": "star",
652 "image": "images/block-wisp-sparkle.png",
653 "terra": false
654 },
655 {
656 "id": "wisp-veil",
657 "name": "Wisp veil",
658 "hex": "#d0b8f0",
659 "shape": "teardrop",
660 "image": "images/block-wisp-veil.png",
661 "terra": false
662 },
663 {
664 "id": "wisp-gleam",
665 "name": "Wisp gleam",
666 "hex": "#f4f7ff",
667 "shape": "plus",
668 "image": "images/block-wisp-gleam.png",
669 "terra": false
670 },
671 {
672 "id": "thorn-briar",
673 "name": "Thorn briar",
674 "hex": "#5a7a30",
675 "shape": "triangle",
676 "image": "images/block-thorn-briar.png",
677 "terra": false
678 },
679 {
680 "id": "thorn-berry",
681 "name": "Thorn berry",
682 "hex": "#8b1a4a",
683 "shape": "circle",
684 "image": "images/block-thorn-berry.png",
685 "terra": false
686 },
687 {
688 "id": "thorn-bark",
689 "name": "Thorn bark",
690 "hex": "#5a3a20",
691 "shape": "square",
692 "image": "images/block-thorn-bark.png",
693 "terra": false
694 },
695 {
696 "id": "thorn-petal",
697 "name": "Thorn petal",
698 "hex": "#e89ab0",
699 "shape": "diamond",
700 "image": "images/block-thorn-petal.png",
701 "terra": false
702 },
703 {
704 "id": "thorn-gold",
705 "name": "Thorn gold",
706 "hex": "#c8a030",
707 "shape": "star",
708 "image": "images/block-thorn-gold.png",
709 "terra": false
710 },
711 {
712 "id": "zephyr-azure",
713 "name": "Zephyr azure",
714 "hex": "#6ec8ff",
715 "shape": "crescent",
716 "image": "images/block-zephyr-azure.png",
717 "terra": false
718 },
719 {
720 "id": "zephyr-breeze",
721 "name": "Zephyr breeze",
722 "hex": "#b8e8ff",
723 "shape": "circle",
724 "image": "images/block-zephyr-breeze.png",
725 "terra": false
726 },
727 {
728 "id": "zephyr-cirrus",
729 "name": "Zephyr cirrus",
730 "hex": "#f0f7ff",
731 "shape": "plus",
732 "image": "images/block-zephyr-cirrus.png",
733 "terra": false
734 },
735 {
736 "id": "zephyr-dusk",
737 "name": "Zephyr dusk",
738 "hex": "#7a6ab0",
739 "shape": "diamond",
740 "image": "images/block-zephyr-dusk.png",
741 "terra": false
742 },
743 {
744 "id": "zephyr-haze",
745 "name": "Zephyr haze",
746 "hex": "#ffe08a",
747 "shape": "star",
748 "image": "images/block-zephyr-haze.png",
749 "terra": false
750 },
751 {
752 "id": "frore-ice",
753 "name": "Frore ice",
754 "hex": "#a8d8f0",
755 "shape": "hexagon",
756 "image": "images/block-frore-ice.png",
757 "terra": false
758 },
759 {
760 "id": "frore-frost",
761 "name": "Frore frost",
762 "hex": "#eef7ff",
763 "shape": "circle",
764 "image": "images/block-frore-frost.png",
765 "terra": false
766 },
767 {
768 "id": "frore-deep",
769 "name": "Frore deep",
770 "hex": "#3a6a8a",
771 "shape": "diamond",
772 "image": "images/block-frore-deep.png",
773 "terra": false
774 },
775 {
776 "id": "frore-aurora",
777 "name": "Frore aurora",
778 "hex": "#5ae8c0",
779 "shape": "star",
780 "image": "images/block-frore-aurora.png",
781 "terra": false
782 },
783 {
784 "id": "frore-rime",
785 "name": "Frore rime",
786 "hex": "#d0e4f0",
787 "shape": "triangle",
788 "image": "images/block-frore-rime.png",
789 "terra": false
790 },
791 {
792 "id": "forge-iron",
793 "name": "Forge iron",
794 "hex": "#6a6a72",
795 "shape": "square",
796 "image": "images/block-forge-iron.png",
797 "terra": false
798 },
799 {
800 "id": "forge-slag",
801 "name": "Forge slag",
802 "hex": "#3a3028",
803 "shape": "hexagon",
804 "image": "images/block-forge-slag.png",
805 "terra": false
806 },
807 {
808 "id": "forge-spark",
809 "name": "Forge spark",
810 "hex": "#ff7a1a",
811 "shape": "triangle",
812 "image": "images/block-forge-spark.png",
813 "terra": false
814 },
815 {
816 "id": "forge-brass",
817 "name": "Forge brass",
818 "hex": "#c8a048",
819 "shape": "diamond",
820 "image": "images/block-forge-brass.png",
821 "terra": false
822 },
823 {
824 "id": "forge-soot",
825 "name": "Forge soot",
826 "hex": "#2a2a28",
827 "shape": "circle",
828 "image": "images/block-forge-soot.png",
829 "terra": false
830 }
831 ]
832 }
@@ -0,0 +1,832 @@
1{
2 "_comment": "Append-only block registry. Never reorder, rename ids, or insert in the middle. New blocks go at the end. The first five (Terra) are unlocked by default; index 5 requires 500 lifetime points, each next index requires 14.5% more (rounded).",
3 "terraCount": 5,
4 "firstThreshold": 500,
5 "thresholdGrowth": 1.145,
6 "blocks": [
7 {
8 "id": "terra-ember",
9 "name": "Ember",
10 "hex": "#e85d3a",
11 "shape": "triangle",
12 "image": "images/block-terra-ember.png",
13 "terra": true
14 },
15 {
16 "id": "terra-aqua",
17 "name": "Aqua",
18 "hex": "#3db8e8",
19 "shape": "circle",
20 "image": "images/block-terra-aqua.png",
21 "terra": true
22 },
23 {
24 "id": "terra-leaf",
25 "name": "Leaf",
26 "hex": "#4cbf4c",
27 "shape": "square",
28 "image": "images/block-terra-leaf.png",
29 "terra": true
30 },
31 {
32 "id": "terra-sun",
33 "name": "Sun",
34 "hex": "#f0c53a",
35 "shape": "diamond",
36 "image": "images/block-terra-sun.png",
37 "terra": true
38 },
39 {
40 "id": "terra-orchid",
41 "name": "Orchid",
42 "hex": "#c45ad4",
43 "shape": "star",
44 "image": "images/block-terra-orchid.png",
45 "terra": true
46 },
47 {
48 "id": "rune-fehu",
49 "name": "Fehu",
50 "hex": "#e8a44a",
51 "shape": "rune_fehu",
52 "image": "images/block-rune-fehu.png",
53 "terra": false
54 },
55 {
56 "id": "rune-ansuz",
57 "name": "Ansuz",
58 "hex": "#6ab0e8",
59 "shape": "rune_ansuz",
60 "image": "images/block-rune-ansuz.png",
61 "terra": false
62 },
63 {
64 "id": "rune-thurisaz",
65 "name": "Thurisaz",
66 "hex": "#c05040",
67 "shape": "rune_thurisaz",
68 "image": "images/block-rune-thurisaz.png",
69 "terra": false
70 },
71 {
72 "id": "rune-raido",
73 "name": "Raido",
74 "hex": "#d0c070",
75 "shape": "rune_raido",
76 "image": "images/block-rune-raido.png",
77 "terra": false
78 },
79 {
80 "id": "rune-sowilo",
81 "name": "Sowilo",
82 "hex": "#f0d040",
83 "shape": "rune_sowilo",
84 "image": "images/block-rune-sowilo.png",
85 "terra": false
86 },
87 {
88 "id": "rune-algiz",
89 "name": "Algiz",
90 "hex": "#80d0a0",
91 "shape": "rune_algiz",
92 "image": "images/block-rune-algiz.png",
93 "terra": false
94 },
95 {
96 "id": "arrow-up",
97 "name": "Arrow",
98 "hex": "#f07040",
99 "shape": "arrow",
100 "image": "images/block-arrow-up.png",
101 "terra": false
102 },
103 {
104 "id": "arrow-chevron",
105 "name": "Chevron",
106 "hex": "#50c0e0",
107 "shape": "chevron",
108 "image": "images/block-arrow-chevron.png",
109 "terra": false
110 },
111 {
112 "id": "arrow-double",
113 "name": "Double Arrow",
114 "hex": "#e05080",
115 "shape": "double_arrow",
116 "image": "images/block-arrow-double.png",
117 "terra": false
118 },
119 {
120 "id": "arrow-return",
121 "name": "Return",
122 "hex": "#a080e0",
123 "shape": "return_arrow",
124 "image": "images/block-arrow-return.png",
125 "terra": false
126 },
127 {
128 "id": "fig-person",
129 "name": "Figure",
130 "hex": "#f0c0a0",
131 "shape": "person",
132 "image": "images/block-fig-person.png",
133 "terra": false
134 },
135 {
136 "id": "fig-walker",
137 "name": "Walker",
138 "hex": "#c09070",
139 "shape": "walker",
140 "image": "images/block-fig-walker.png",
141 "terra": false
142 },
143 {
144 "id": "fig-hero",
145 "name": "Hero",
146 "hex": "#e8b070",
147 "shape": "hero",
148 "image": "images/block-fig-hero.png",
149 "terra": false
150 },
151 {
152 "id": "face-smile",
153 "name": "Smile",
154 "hex": "#f0d060",
155 "shape": "smile",
156 "image": "images/block-face-smile.png",
157 "terra": false
158 },
159 {
160 "id": "face-wink",
161 "name": "Wink",
162 "hex": "#f0a050",
163 "shape": "wink",
164 "image": "images/block-face-wink.png",
165 "terra": false
166 },
167 {
168 "id": "face-cool",
169 "name": "Cool",
170 "hex": "#6090d0",
171 "shape": "cool",
172 "image": "images/block-face-cool.png",
173 "terra": false
174 },
175 {
176 "id": "face-grin",
177 "name": "Grin",
178 "hex": "#f0c848",
179 "shape": "grin",
180 "image": "images/block-face-grin.png",
181 "terra": false
182 },
183 {
184 "id": "icon-heart",
185 "name": "Heart",
186 "hex": "#e04060",
187 "shape": "heart",
188 "image": "images/block-icon-heart.png",
189 "terra": false
190 },
191 {
192 "id": "icon-moon",
193 "name": "Moon",
194 "hex": "#d0d8f0",
195 "shape": "crescent",
196 "image": "images/block-icon-moon.png",
197 "terra": false
198 },
199 {
200 "id": "icon-bolt",
201 "name": "Bolt",
202 "hex": "#f0e050",
203 "shape": "lightning",
204 "image": "images/block-icon-bolt.png",
205 "terra": false
206 },
207 {
208 "id": "icon-shield",
209 "name": "Shield",
210 "hex": "#5080c0",
211 "shape": "shield",
212 "image": "images/block-icon-shield.png",
213 "terra": false
214 },
215 {
216 "id": "icon-crown",
217 "name": "Crown",
218 "hex": "#f0c030",
219 "shape": "crown",
220 "image": "images/block-icon-crown.png",
221 "terra": false
222 },
223 {
224 "id": "icon-eye",
225 "name": "Eye",
226 "hex": "#70d0c0",
227 "shape": "eye",
228 "image": "images/block-icon-eye.png",
229 "terra": false
230 },
231 {
232 "id": "icon-star6",
233 "name": "Hexastar",
234 "hex": "#f0e8a0",
235 "shape": "star6",
236 "image": "images/block-icon-star6.png",
237 "terra": false
238 },
239 {
240 "id": "icon-spiral",
241 "name": "Spiral",
242 "hex": "#c070d0",
243 "shape": "spiral",
244 "image": "images/block-icon-spiral.png",
245 "terra": false
246 },
247 {
248 "id": "icon-wave",
249 "name": "Wave",
250 "hex": "#3090d0",
251 "shape": "wave",
252 "image": "images/block-icon-wave.png",
253 "terra": false
254 },
255 {
256 "id": "icon-mountain",
257 "name": "Mountain",
258 "hex": "#809070",
259 "shape": "mountain",
260 "image": "images/block-icon-mountain.png",
261 "terra": false
262 },
263 {
264 "id": "icon-fish",
265 "name": "Fish",
266 "hex": "#40a8c8",
267 "shape": "fish",
268 "image": "images/block-icon-fish.png",
269 "terra": false
270 },
271 {
272 "id": "icon-bird",
273 "name": "Bird",
274 "hex": "#e07050",
275 "shape": "bird",
276 "image": "images/block-icon-bird.png",
277 "terra": false
278 },
279 {
280 "id": "icon-key",
281 "name": "Key",
282 "hex": "#d0b050",
283 "shape": "key",
284 "image": "images/block-icon-key.png",
285 "terra": false
286 },
287 {
288 "id": "icon-comet",
289 "name": "Comet",
290 "hex": "#90d0f0",
291 "shape": "comet",
292 "image": "images/block-icon-comet.png",
293 "terra": false
294 },
295 {
296 "id": "icon-clover",
297 "name": "Clover",
298 "hex": "#40b060",
299 "shape": "clover",
300 "image": "images/block-icon-clover.png",
301 "terra": false
302 },
303 {
304 "id": "icon-paw",
305 "name": "Paw",
306 "hex": "#c08050",
307 "shape": "paw",
308 "image": "images/block-icon-paw.png",
309 "terra": false
310 },
311 {
312 "id": "icon-sword",
313 "name": "Sword",
314 "hex": "#b0b8c0",
315 "shape": "sword",
316 "image": "images/block-icon-sword.png",
317 "terra": false
318 },
319 {
320 "id": "icon-bell",
321 "name": "Bell",
322 "hex": "#f0c848",
323 "shape": "bell",
324 "image": "images/block-icon-bell.png",
325 "terra": false
326 },
327 {
328 "id": "icon-mushroom",
329 "name": "Mushroom",
330 "hex": "#e06050",
331 "shape": "mushroom",
332 "image": "images/block-icon-mushroom.png",
333 "terra": false
334 },
335 {
336 "id": "icon-cactus",
337 "name": "Cactus",
338 "hex": "#50b068",
339 "shape": "cactus",
340 "image": "images/block-icon-cactus.png",
341 "terra": false
342 },
343 {
344 "id": "icon-ring",
345 "name": "Ring",
346 "hex": "#e8d080",
347 "shape": "ring",
348 "image": "images/block-icon-ring.png",
349 "terra": false
350 },
351 {
352 "id": "icon-flag",
353 "name": "Flag",
354 "hex": "#d04050",
355 "shape": "flag",
356 "image": "images/block-icon-flag.png",
357 "terra": false
358 },
359 {
360 "id": "icon-snow",
361 "name": "Snowflake",
362 "hex": "#c8e0f8",
363 "shape": "snowflake",
364 "image": "images/block-icon-snow.png",
365 "terra": false
366 },
367 {
368 "id": "icon-flame",
369 "name": "Flame",
370 "hex": "#ff7030",
371 "shape": "flame_icon",
372 "image": "images/block-icon-flame.png",
373 "terra": false
374 },
375 {
376 "id": "icon-ankh",
377 "name": "Ankh",
378 "hex": "#d0a060",
379 "shape": "ankh",
380 "image": "images/block-icon-ankh.png",
381 "terra": false
382 },
383 {
384 "id": "icon-yin",
385 "name": "Yin Yang",
386 "hex": "#606080",
387 "shape": "yinyang",
388 "image": "images/block-icon-yin.png",
389 "terra": false
390 },
391 {
392 "id": "aurel-gold",
393 "name": "Aurel gold",
394 "hex": "#f4c860",
395 "shape": "hexagon",
396 "image": "images/block-aurel-gold.png",
397 "terra": false
398 },
399 {
400 "id": "aurel-cream",
401 "name": "Aurel cream",
402 "hex": "#f6e7c1",
403 "shape": "circle",
404 "image": "images/block-aurel-cream.png",
405 "terra": false
406 },
407 {
408 "id": "aurel-amber",
409 "name": "Aurel amber",
410 "hex": "#e09a3e",
411 "shape": "teardrop",
412 "image": "images/block-aurel-amber.png",
413 "terra": false
414 },
415 {
416 "id": "aurel-sage",
417 "name": "Aurel sage",
418 "hex": "#8fb86f",
419 "shape": "plus",
420 "image": "images/block-aurel-sage.png",
421 "terra": false
422 },
423 {
424 "id": "aurel-rose",
425 "name": "Aurel rose",
426 "hex": "#e8a0a8",
427 "shape": "pentagon",
428 "image": "images/block-aurel-rose.png",
429 "terra": false
430 },
431 {
432 "id": "cinder-magma",
433 "name": "Cinder magma",
434 "hex": "#ff3b1f",
435 "shape": "triangle",
436 "image": "images/block-cinder-magma.png",
437 "terra": false
438 },
439 {
440 "id": "cinder-coal",
441 "name": "Cinder coal",
442 "hex": "#3a3232",
443 "shape": "square",
444 "image": "images/block-cinder-coal.png",
445 "terra": false
446 },
447 {
448 "id": "cinder-spark",
449 "name": "Cinder spark",
450 "hex": "#ffb347",
451 "shape": "diamond",
452 "image": "images/block-cinder-spark.png",
453 "terra": false
454 },
455 {
456 "id": "cinder-ash",
457 "name": "Cinder ash",
458 "hex": "#8a7a76",
459 "shape": "circle",
460 "image": "images/block-cinder-ash.png",
461 "terra": false
462 },
463 {
464 "id": "cinder-core",
465 "name": "Cinder core",
466 "hex": "#ff6a00",
467 "shape": "star",
468 "image": "images/block-cinder-core.png",
469 "terra": false
470 },
471 {
472 "id": "lunara-silver",
473 "name": "Lunara silver",
474 "hex": "#c5d0e0",
475 "shape": "circle",
476 "image": "images/block-lunara-silver.png",
477 "terra": false
478 },
479 {
480 "id": "lunara-dust",
481 "name": "Lunara dust",
482 "hex": "#8b90a0",
483 "shape": "diamond",
484 "image": "images/block-lunara-dust.png",
485 "terra": false
486 },
487 {
488 "id": "lunara-pale",
489 "name": "Lunara pale",
490 "hex": "#e8d9a8",
491 "shape": "crescent",
492 "image": "images/block-lunara-pale.png",
493 "terra": false
494 },
495 {
496 "id": "lunara-void",
497 "name": "Lunara void",
498 "hex": "#2c3348",
499 "shape": "square",
500 "image": "images/block-lunara-void.png",
501 "terra": false
502 },
503 {
504 "id": "lunara-lilac",
505 "name": "Lunara lilac",
506 "hex": "#b9a4d4",
507 "shape": "star",
508 "image": "images/block-lunara-lilac.png",
509 "terra": false
510 },
511 {
512 "id": "mire-moss",
513 "name": "Mire moss",
514 "hex": "#3d7a45",
515 "shape": "hexagon",
516 "image": "images/block-mire-moss.png",
517 "terra": false
518 },
519 {
520 "id": "mire-bog",
521 "name": "Mire bog",
522 "hex": "#1f4d3a",
523 "shape": "teardrop",
524 "image": "images/block-mire-bog.png",
525 "terra": false
526 },
527 {
528 "id": "mire-rust",
529 "name": "Mire rust",
530 "hex": "#8b5a2b",
531 "shape": "pentagon",
532 "image": "images/block-mire-rust.png",
533 "terra": false
534 },
535 {
536 "id": "mire-spore",
537 "name": "Mire spore",
538 "hex": "#9cbf5a",
539 "shape": "circle",
540 "image": "images/block-mire-spore.png",
541 "terra": false
542 },
543 {
544 "id": "mire-murk",
545 "name": "Mire murk",
546 "hex": "#2e3b2f",
547 "shape": "diamond",
548 "image": "images/block-mire-murk.png",
549 "terra": false
550 },
551 {
552 "id": "galeon-sky",
553 "name": "Galeon sky",
554 "hex": "#4aa3ff",
555 "shape": "arrow",
556 "image": "images/block-galeon-sky.png",
557 "terra": false
558 },
559 {
560 "id": "galeon-cloud",
561 "name": "Galeon cloud",
562 "hex": "#e8eef6",
563 "shape": "circle",
564 "image": "images/block-galeon-cloud.png",
565 "terra": false
566 },
567 {
568 "id": "galeon-storm",
569 "name": "Galeon storm",
570 "hex": "#3d4d6e",
571 "shape": "square",
572 "image": "images/block-galeon-storm.png",
573 "terra": false
574 },
575 {
576 "id": "galeon-sand",
577 "name": "Galeon sand",
578 "hex": "#d4b483",
579 "shape": "diamond",
580 "image": "images/block-galeon-sand.png",
581 "terra": false
582 },
583 {
584 "id": "galeon-kite",
585 "name": "Galeon kite",
586 "hex": "#7fd0c0",
587 "shape": "star",
588 "image": "images/block-galeon-kite.png",
589 "terra": false
590 },
591 {
592 "id": "obsid-glass",
593 "name": "Obsid glass",
594 "hex": "#1a1a22",
595 "shape": "gem",
596 "image": "images/block-obsid-glass.png",
597 "terra": false
598 },
599 {
600 "id": "obsid-violet",
601 "name": "Obsid violet",
602 "hex": "#5a3d8a",
603 "shape": "hexagon",
604 "image": "images/block-obsid-violet.png",
605 "terra": false
606 },
607 {
608 "id": "obsid-shard",
609 "name": "Obsid shard",
610 "hex": "#8a8aa0",
611 "shape": "triangle",
612 "image": "images/block-obsid-shard.png",
613 "terra": false
614 },
615 {
616 "id": "obsid-vein",
617 "name": "Obsid vein",
618 "hex": "#c45a3a",
619 "shape": "diamond",
620 "image": "images/block-obsid-vein.png",
621 "terra": false
622 },
623 {
624 "id": "obsid-basalt",
625 "name": "Obsid basalt",
626 "hex": "#3a3a42",
627 "shape": "square",
628 "image": "images/block-obsid-basalt.png",
629 "terra": false
630 },
631 {
632 "id": "wisp-glow",
633 "name": "Wisp glow",
634 "hex": "#c8ffe0",
635 "shape": "circle",
636 "image": "images/block-wisp-glow.png",
637 "terra": false
638 },
639 {
640 "id": "wisp-mist",
641 "name": "Wisp mist",
642 "hex": "#a8d4e8",
643 "shape": "diamond",
644 "image": "images/block-wisp-mist.png",
645 "terra": false
646 },
647 {
648 "id": "wisp-sparkle",
649 "name": "Wisp sparkle",
650 "hex": "#fff6a8",
651 "shape": "star",
652 "image": "images/block-wisp-sparkle.png",
653 "terra": false
654 },
655 {
656 "id": "wisp-veil",
657 "name": "Wisp veil",
658 "hex": "#d0b8f0",
659 "shape": "teardrop",
660 "image": "images/block-wisp-veil.png",
661 "terra": false
662 },
663 {
664 "id": "wisp-gleam",
665 "name": "Wisp gleam",
666 "hex": "#f4f7ff",
667 "shape": "plus",
668 "image": "images/block-wisp-gleam.png",
669 "terra": false
670 },
671 {
672 "id": "thorn-briar",
673 "name": "Thorn briar",
674 "hex": "#5a7a30",
675 "shape": "triangle",
676 "image": "images/block-thorn-briar.png",
677 "terra": false
678 },
679 {
680 "id": "thorn-berry",
681 "name": "Thorn berry",
682 "hex": "#8b1a4a",
683 "shape": "circle",
684 "image": "images/block-thorn-berry.png",
685 "terra": false
686 },
687 {
688 "id": "thorn-bark",
689 "name": "Thorn bark",
690 "hex": "#5a3a20",
691 "shape": "square",
692 "image": "images/block-thorn-bark.png",
693 "terra": false
694 },
695 {
696 "id": "thorn-petal",
697 "name": "Thorn petal",
698 "hex": "#e89ab0",
699 "shape": "diamond",
700 "image": "images/block-thorn-petal.png",
701 "terra": false
702 },
703 {
704 "id": "thorn-gold",
705 "name": "Thorn gold",
706 "hex": "#c8a030",
707 "shape": "star",
708 "image": "images/block-thorn-gold.png",
709 "terra": false
710 },
711 {
712 "id": "zephyr-azure",
713 "name": "Zephyr azure",
714 "hex": "#6ec8ff",
715 "shape": "crescent",
716 "image": "images/block-zephyr-azure.png",
717 "terra": false
718 },
719 {
720 "id": "zephyr-breeze",
721 "name": "Zephyr breeze",
722 "hex": "#b8e8ff",
723 "shape": "circle",
724 "image": "images/block-zephyr-breeze.png",
725 "terra": false
726 },
727 {
728 "id": "zephyr-cirrus",
729 "name": "Zephyr cirrus",
730 "hex": "#f0f7ff",
731 "shape": "plus",
732 "image": "images/block-zephyr-cirrus.png",
733 "terra": false
734 },
735 {
736 "id": "zephyr-dusk",
737 "name": "Zephyr dusk",
738 "hex": "#7a6ab0",
739 "shape": "diamond",
740 "image": "images/block-zephyr-dusk.png",
741 "terra": false
742 },
743 {
744 "id": "zephyr-haze",
745 "name": "Zephyr haze",
746 "hex": "#ffe08a",
747 "shape": "star",
748 "image": "images/block-zephyr-haze.png",
749 "terra": false
750 },
751 {
752 "id": "frore-ice",
753 "name": "Frore ice",
754 "hex": "#a8d8f0",
755 "shape": "hexagon",
756 "image": "images/block-frore-ice.png",
757 "terra": false
758 },
759 {
760 "id": "frore-frost",
761 "name": "Frore frost",
762 "hex": "#eef7ff",
763 "shape": "circle",
764 "image": "images/block-frore-frost.png",
765 "terra": false
766 },
767 {
768 "id": "frore-deep",
769 "name": "Frore deep",
770 "hex": "#3a6a8a",
771 "shape": "diamond",
772 "image": "images/block-frore-deep.png",
773 "terra": false
774 },
775 {
776 "id": "frore-aurora",
777 "name": "Frore aurora",
778 "hex": "#5ae8c0",
779 "shape": "star",
780 "image": "images/block-frore-aurora.png",
781 "terra": false
782 },
783 {
784 "id": "frore-rime",
785 "name": "Frore rime",
786 "hex": "#d0e4f0",
787 "shape": "triangle",
788 "image": "images/block-frore-rime.png",
789 "terra": false
790 },
791 {
792 "id": "forge-iron",
793 "name": "Forge iron",
794 "hex": "#6a6a72",
795 "shape": "square",
796 "image": "images/block-forge-iron.png",
797 "terra": false
798 },
799 {
800 "id": "forge-slag",
801 "name": "Forge slag",
802 "hex": "#3a3028",
803 "shape": "hexagon",
804 "image": "images/block-forge-slag.png",
805 "terra": false
806 },
807 {
808 "id": "forge-spark",
809 "name": "Forge spark",
810 "hex": "#ff7a1a",
811 "shape": "triangle",
812 "image": "images/block-forge-spark.png",
813 "terra": false
814 },
815 {
816 "id": "forge-brass",
817 "name": "Forge brass",
818 "hex": "#c8a048",
819 "shape": "diamond",
820 "image": "images/block-forge-brass.png",
821 "terra": false
822 },
823 {
824 "id": "forge-soot",
825 "name": "Forge soot",
826 "hex": "#2a2a28",
827 "shape": "circle",
828 "image": "images/block-forge-soot.png",
829 "terra": false
830 }
831 ]
832}
src/blocks.js added +160 −0
@@ -0,0 +1,160 @@
1 'use strict';
2
3 /**
4 * Append-only block registry. Thresholds and order stay in lockstep with
5 * server/lib/Blocks.php: Terra's first five are free; the next costs 500
6 * lifetime points; each one after that costs 14.5% more (rounded, always
7 * strictly increasing). Points are a requirement, not a spend.
8 */
9
10 var Blocks = (function ()
11 {
12 var TERRA_COUNT = 5;
13 var FIRST_THRESHOLD = 500;
14 var GROWTH = 1.145;
15 var _all = null;
16
17 function loadRegistry ()
18 {
19 if (_all)
20 { return _all; }
21 var data = null;
22 if (typeof BLOCK_REGISTRY !== 'undefined' && BLOCK_REGISTRY && BLOCK_REGISTRY.blocks)
23 { data = BLOCK_REGISTRY; }
24 else if (typeof require !== 'undefined')
25 {
26 try
27 { data = require('../server/lib/blocks.json'); }
28 catch (e) { data = null; }
29 }
30 _all = (data && data.blocks) ? data.blocks.slice() : [];
31 return _all;
32 }
33
34 function all ()
35 {
36 return loadRegistry();
37 }
38
39 function byId (id)
40 {
41 var list = all();
42 for (var i = 0; i < list.length; i++)
43 {
44 if (list[i].id === id)
45 { return list[i]; }
46 }
47 return null;
48 }
49
50 function indexOf (id)
51 {
52 var list = all();
53 for (var i = 0; i < list.length; i++)
54 {
55 if (list[i].id === id)
56 { return i; }
57 }
58 return -1;
59 }
60
61 function threshold (index)
62 {
63 if (index < TERRA_COUNT)
64 { return 0; }
65 var t = FIRST_THRESHOLD;
66 for (var i = TERRA_COUNT; i < index; i++)
67 {
68 var next = Math.round(t * GROWTH);
69 t = Math.max(t + 1, next);
70 }
71 return t;
72 }
73
74 function unlocked (index, points)
75 {
76 points = points || 0;
77 return points >= threshold(index);
78 }
79
80 function unlockedId (id, points)
81 {
82 var i = indexOf(id);
83 return i >= 0 && unlocked(i, points);
84 }
85
86 function present (points)
87 {
88 points = points || 0;
89 var list = all();
90 var out = [];
91 for (var i = 0; i < list.length; i++)
92 {
93 var b = list[i];
94 var need = threshold(i);
95 out.push({
96 id: b.id,
97 name: b.name || b.id,
98 hex: b.hex,
99 shape: b.shape,
100 image: b.image,
101 terra: !!b.terra || i < TERRA_COUNT,
102 index: i,
103 threshold: need,
104 unlocked: points >= need
105 });
106 }
107 return out;
108 }
109
110 function asColor (id, slot)
111 {
112 var b = byId(id);
113 if (!b)
114 { return null; }
115 return {
116 id: slot,
117 block: b.id,
118 name: b.name || b.id,
119 hex: b.hex,
120 shape: b.shape,
121 image: b.image
122 };
123 }
124
125 function images ()
126 {
127 var list = all();
128 var out = [];
129 var seen = Object.create(null);
130 for (var i = 0; i < list.length; i++)
131 {
132 var url = list[i].image;
133 if (!url || seen[url])
134 { continue; }
135 seen[url] = true;
136 out.push({ name: 'block:' + list[i].id, url: url });
137 }
138 return out;
139 }
140
141 return {
142 TERRA_COUNT: TERRA_COUNT,
143 FIRST_THRESHOLD: FIRST_THRESHOLD,
144 GROWTH: GROWTH,
145 all: all,
146 byId: byId,
147 indexOf: indexOf,
148 threshold: threshold,
149 unlocked: unlocked,
150 unlockedId: unlockedId,
151 present: present,
152 asColor: asColor,
153 images: images
154 };
155 })();
156
157 if (typeof module !== 'undefined' && module.exports)
158 { module.exports = Blocks; }
159 else if (typeof globalThis !== 'undefined')
160 { globalThis.Blocks = Blocks; }
@@ -0,0 +1,160 @@
1'use strict';
2
3/**
4 * Append-only block registry. Thresholds and order stay in lockstep with
5 * server/lib/Blocks.php: Terra's first five are free; the next costs 500
6 * lifetime points; each one after that costs 14.5% more (rounded, always
7 * strictly increasing). Points are a requirement, not a spend.
8 */
9
10var Blocks = (function ()
11{
12 var TERRA_COUNT = 5;
13 var FIRST_THRESHOLD = 500;
14 var GROWTH = 1.145;
15 var _all = null;
16
17 function loadRegistry ()
18 {
19 if (_all)
20 { return _all; }
21 var data = null;
22 if (typeof BLOCK_REGISTRY !== 'undefined' && BLOCK_REGISTRY && BLOCK_REGISTRY.blocks)
23 { data = BLOCK_REGISTRY; }
24 else if (typeof require !== 'undefined')
25 {
26 try
27 { data = require('../server/lib/blocks.json'); }
28 catch (e) { data = null; }
29 }
30 _all = (data && data.blocks) ? data.blocks.slice() : [];
31 return _all;
32 }
33
34 function all ()
35 {
36 return loadRegistry();
37 }
38
39 function byId (id)
40 {
41 var list = all();
42 for (var i = 0; i < list.length; i++)
43 {
44 if (list[i].id === id)
45 { return list[i]; }
46 }
47 return null;
48 }
49
50 function indexOf (id)
51 {
52 var list = all();
53 for (var i = 0; i < list.length; i++)
54 {
55 if (list[i].id === id)
56 { return i; }
57 }
58 return -1;
59 }
60
61 function threshold (index)
62 {
63 if (index < TERRA_COUNT)
64 { return 0; }
65 var t = FIRST_THRESHOLD;
66 for (var i = TERRA_COUNT; i < index; i++)
67 {
68 var next = Math.round(t * GROWTH);
69 t = Math.max(t + 1, next);
70 }
71 return t;
72 }
73
74 function unlocked (index, points)
75 {
76 points = points || 0;
77 return points >= threshold(index);
78 }
79
80 function unlockedId (id, points)
81 {
82 var i = indexOf(id);
83 return i >= 0 && unlocked(i, points);
84 }
85
86 function present (points)
87 {
88 points = points || 0;
89 var list = all();
90 var out = [];
91 for (var i = 0; i < list.length; i++)
92 {
93 var b = list[i];
94 var need = threshold(i);
95 out.push({
96 id: b.id,
97 name: b.name || b.id,
98 hex: b.hex,
99 shape: b.shape,
100 image: b.image,
101 terra: !!b.terra || i < TERRA_COUNT,
102 index: i,
103 threshold: need,
104 unlocked: points >= need
105 });
106 }
107 return out;
108 }
109
110 function asColor (id, slot)
111 {
112 var b = byId(id);
113 if (!b)
114 { return null; }
115 return {
116 id: slot,
117 block: b.id,
118 name: b.name || b.id,
119 hex: b.hex,
120 shape: b.shape,
121 image: b.image
122 };
123 }
124
125 function images ()
126 {
127 var list = all();
128 var out = [];
129 var seen = Object.create(null);
130 for (var i = 0; i < list.length; i++)
131 {
132 var url = list[i].image;
133 if (!url || seen[url])
134 { continue; }
135 seen[url] = true;
136 out.push({ name: 'block:' + list[i].id, url: url });
137 }
138 return out;
139 }
140
141 return {
142 TERRA_COUNT: TERRA_COUNT,
143 FIRST_THRESHOLD: FIRST_THRESHOLD,
144 GROWTH: GROWTH,
145 all: all,
146 byId: byId,
147 indexOf: indexOf,
148 threshold: threshold,
149 unlocked: unlocked,
150 unlockedId: unlockedId,
151 present: present,
152 asColor: asColor,
153 images: images
154 };
155})();
156
157if (typeof module !== 'undefined' && module.exports)
158{ module.exports = Blocks; }
159else if (typeof globalThis !== 'undefined')
160{ globalThis.Blocks = Blocks; }