@clarity-js/engine 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/schema.json ADDED
@@ -0,0 +1,628 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://clarity-js.com/schema/game.json",
4
+ "title": "Clarity engine game",
5
+ "description": "A game of @clarity-js/engine: the kit, the look, the feel, the levels and the checks. validateGame() in @clarity-js/engine checks it with the place of each mistake.",
6
+ "type": "object",
7
+ "required": [
8
+ "engine",
9
+ "title",
10
+ "kit",
11
+ "rules"
12
+ ],
13
+ "properties": {
14
+ "engine": {
15
+ "const": 1
16
+ },
17
+ "title": {
18
+ "type": "string",
19
+ "minLength": 1,
20
+ "maxLength": 60
21
+ },
22
+ "pitch": {
23
+ "type": "string",
24
+ "description": "The sentence the game was made from."
25
+ },
26
+ "kit": {
27
+ "enum": [
28
+ "puzzle-grid",
29
+ "platformer",
30
+ "top-down",
31
+ "shmup",
32
+ "racing",
33
+ "card-board",
34
+ "explore-3d",
35
+ "physics-toy",
36
+ "blank"
37
+ ]
38
+ },
39
+ "look": {
40
+ "type": "object",
41
+ "properties": {
42
+ "style": {
43
+ "enum": [
44
+ "paper-marbling",
45
+ "pixel",
46
+ "neon-night",
47
+ "ink-sketch",
48
+ "toy-plastic",
49
+ "pastel",
50
+ "flat",
51
+ "low-poly-diorama"
52
+ ]
53
+ },
54
+ "palette": {
55
+ "type": "array",
56
+ "minItems": 2,
57
+ "maxItems": 8,
58
+ "items": {
59
+ "type": "string",
60
+ "pattern": "^#[0-9a-fA-F]{6}$"
61
+ }
62
+ },
63
+ "camera": {
64
+ "enum": [
65
+ "top",
66
+ "side",
67
+ "follow",
68
+ "diorama"
69
+ ]
70
+ },
71
+ "background": {
72
+ "type": "string",
73
+ "pattern": "^#[0-9a-fA-F]{6}$"
74
+ },
75
+ "ink": {
76
+ "type": "string",
77
+ "pattern": "^#[0-9a-fA-F]{6}$"
78
+ },
79
+ "radius": {
80
+ "type": "number",
81
+ "minimum": 0,
82
+ "maximum": 0.5,
83
+ "description": "Corners, a share of a shape's size."
84
+ },
85
+ "glow": {
86
+ "type": "number",
87
+ "minimum": 0,
88
+ "maximum": 1
89
+ },
90
+ "gloss": {
91
+ "type": "number",
92
+ "minimum": 0,
93
+ "maximum": 1
94
+ },
95
+ "outline": {
96
+ "type": "number",
97
+ "minimum": 0,
98
+ "maximum": 1
99
+ },
100
+ "shade": {
101
+ "type": "number",
102
+ "minimum": 0,
103
+ "maximum": 1
104
+ },
105
+ "pattern": {
106
+ "enum": [
107
+ "marble",
108
+ "hatch",
109
+ "bevel",
110
+ null
111
+ ]
112
+ }
113
+ }
114
+ },
115
+ "feel": {
116
+ "type": "object",
117
+ "properties": {
118
+ "pace": {
119
+ "enum": [
120
+ "calm",
121
+ "steady",
122
+ "fast"
123
+ ]
124
+ },
125
+ "session": {
126
+ "type": "string"
127
+ },
128
+ "input": {
129
+ "type": "array",
130
+ "items": {
131
+ "type": "string"
132
+ }
133
+ },
134
+ "device": {
135
+ "enum": [
136
+ "phone-first",
137
+ "any"
138
+ ]
139
+ }
140
+ }
141
+ },
142
+ "rules": {
143
+ "type": "string",
144
+ "pattern": "\\.m?js$"
145
+ },
146
+ "settings": {
147
+ "type": "object",
148
+ "additionalProperties": {
149
+ "type": "number"
150
+ },
151
+ "description": "The kit's numbers (kits() lists each kit's, with its range): platformer gravity, jump, speed, accel, coyote, buffer, lives, enemySpeed; top-down speed, hp, reach, cooldown, enemySpeed, sight, enemyHp; shmup width, speed, fireRate, lives, bulletSpeed, hitbox; racing top, accel, brake, turn, grip, grass; explore-3d speed, climb, fog; physics-toy gravity, launch, ball, friction."
152
+ },
153
+ "levels": {
154
+ "type": "array",
155
+ "minItems": 1,
156
+ "items": {
157
+ "type": "object",
158
+ "properties": {
159
+ "id": {
160
+ "type": "string"
161
+ },
162
+ "goal": {
163
+ "oneOf": [
164
+ {
165
+ "enum": [
166
+ "match",
167
+ "push",
168
+ "lights",
169
+ "slide",
170
+ "shed",
171
+ "line",
172
+ "topple",
173
+ "stack"
174
+ ]
175
+ },
176
+ {
177
+ "type": "object",
178
+ "properties": {
179
+ "x": {
180
+ "type": "number"
181
+ },
182
+ "y": {
183
+ "type": "number"
184
+ }
185
+ },
186
+ "description": "explore-3d: where to bring what is found."
187
+ }
188
+ ]
189
+ },
190
+ "size": {
191
+ "type": "array",
192
+ "minItems": 2,
193
+ "maxItems": 2,
194
+ "items": {
195
+ "type": "integer",
196
+ "minimum": 2,
197
+ "maximum": 96
198
+ }
199
+ },
200
+ "moves": {
201
+ "type": "integer",
202
+ "minimum": 1
203
+ },
204
+ "target": {
205
+ "type": "number",
206
+ "exclusiveMinimum": 0
207
+ },
208
+ "colors": {
209
+ "type": "integer",
210
+ "minimum": 3,
211
+ "maximum": 8
212
+ },
213
+ "presses": {
214
+ "type": "integer",
215
+ "minimum": 1
216
+ },
217
+ "shuffle": {
218
+ "type": "integer",
219
+ "minimum": 2
220
+ },
221
+ "map": {
222
+ "type": "array",
223
+ "items": {
224
+ "type": "string"
225
+ },
226
+ "description": "push: # wall, . mark, $ crate, * crate on a mark, @ keeper, + keeper on a mark. platformer: # ground, - ledge, @ start, o coin, E walker, ^ spikes, D door, C checkpoint. top-down: # wall, . floor, @ start, X way out, E chaser, S sentry, k key, L locked door, h heart, o gem."
227
+ },
228
+ "coins": {
229
+ "type": "integer",
230
+ "minimum": 0
231
+ },
232
+ "time": {
233
+ "type": "number",
234
+ "exclusiveMinimum": 0
235
+ },
236
+ "gems": {
237
+ "type": "integer",
238
+ "minimum": 0,
239
+ "description": "top-down: gems asked for before the way out opens."
240
+ },
241
+ "length": {
242
+ "type": "number",
243
+ "minimum": 5,
244
+ "description": "shmup: seconds before the boss."
245
+ },
246
+ "waves": {
247
+ "type": "array",
248
+ "items": {
249
+ "type": "object",
250
+ "required": [
251
+ "t"
252
+ ],
253
+ "properties": {
254
+ "t": {
255
+ "type": "number"
256
+ },
257
+ "kind": {
258
+ "enum": [
259
+ "line",
260
+ "vee",
261
+ "sine",
262
+ "dive",
263
+ "column"
264
+ ]
265
+ },
266
+ "n": {
267
+ "type": "integer",
268
+ "minimum": 1,
269
+ "maximum": 14
270
+ },
271
+ "x": {
272
+ "type": "number",
273
+ "minimum": 0,
274
+ "maximum": 1
275
+ },
276
+ "hp": {
277
+ "type": "integer",
278
+ "minimum": 1
279
+ },
280
+ "fire": {
281
+ "type": "number",
282
+ "minimum": 0
283
+ }
284
+ }
285
+ }
286
+ },
287
+ "boss": {
288
+ "type": "object",
289
+ "properties": {
290
+ "hp": {
291
+ "type": "number",
292
+ "exclusiveMinimum": 0
293
+ },
294
+ "pattern": {
295
+ "enum": [
296
+ "ring",
297
+ "spiral",
298
+ "fan"
299
+ ]
300
+ }
301
+ }
302
+ },
303
+ "track": {
304
+ "type": "array",
305
+ "minItems": 4,
306
+ "items": {
307
+ "type": "array",
308
+ "minItems": 2,
309
+ "maxItems": 2,
310
+ "items": {
311
+ "type": "number"
312
+ }
313
+ },
314
+ "description": "racing: the control points of a closed track."
315
+ },
316
+ "width": {
317
+ "type": "number",
318
+ "minimum": 3,
319
+ "maximum": 30
320
+ },
321
+ "laps": {
322
+ "type": "integer",
323
+ "minimum": 1,
324
+ "maximum": 9
325
+ },
326
+ "rivals": {
327
+ "type": "integer",
328
+ "minimum": 0,
329
+ "maximum": 7
330
+ },
331
+ "rivalPace": {
332
+ "type": "number",
333
+ "minimum": 0.3,
334
+ "maximum": 1.1
335
+ },
336
+ "place": {
337
+ "type": "integer",
338
+ "minimum": 1
339
+ },
340
+ "hand": {
341
+ "type": "integer",
342
+ "minimum": 2,
343
+ "maximum": 12
344
+ },
345
+ "ranks": {
346
+ "type": "integer",
347
+ "minimum": 3,
348
+ "maximum": 12
349
+ },
350
+ "wilds": {
351
+ "type": "integer",
352
+ "minimum": 0,
353
+ "maximum": 8
354
+ },
355
+ "extra": {
356
+ "type": "integer",
357
+ "minimum": -3,
358
+ "maximum": 4
359
+ },
360
+ "rival": {
361
+ "type": "integer",
362
+ "minimum": 0,
363
+ "maximum": 5,
364
+ "description": "card-board: how well the rival plays (shed 0 to 2; line: moves it looks ahead)."
365
+ },
366
+ "inRow": {
367
+ "type": "integer",
368
+ "minimum": 3,
369
+ "maximum": 6
370
+ },
371
+ "heights": {
372
+ "type": "string",
373
+ "pattern": "^[a-z~]*$",
374
+ "description": "explore-3d: one character a cell, a to z low to high, ~ water."
375
+ },
376
+ "things": {
377
+ "type": "array",
378
+ "items": {
379
+ "type": "object",
380
+ "required": [
381
+ "kind",
382
+ "x",
383
+ "y"
384
+ ],
385
+ "properties": {
386
+ "kind": {
387
+ "enum": [
388
+ "item",
389
+ "npc",
390
+ "tree",
391
+ "rock"
392
+ ]
393
+ },
394
+ "x": {
395
+ "type": "number"
396
+ },
397
+ "y": {
398
+ "type": "number"
399
+ },
400
+ "says": {
401
+ "type": "string"
402
+ },
403
+ "name": {
404
+ "type": "string"
405
+ },
406
+ "s": {
407
+ "type": "number"
408
+ }
409
+ }
410
+ }
411
+ },
412
+ "start": {
413
+ "type": "object",
414
+ "properties": {
415
+ "x": {
416
+ "type": "number"
417
+ },
418
+ "y": {
419
+ "type": "number"
420
+ }
421
+ }
422
+ },
423
+ "fog": {
424
+ "type": "number",
425
+ "minimum": 2,
426
+ "maximum": 30
427
+ },
428
+ "blocks": {
429
+ "type": "array",
430
+ "items": {
431
+ "type": "array",
432
+ "minItems": 4,
433
+ "maxItems": 4,
434
+ "items": {
435
+ "type": "number"
436
+ }
437
+ },
438
+ "description": "physics-toy topple: [x, y, width, height]."
439
+ },
440
+ "targets": {
441
+ "type": "array",
442
+ "items": {
443
+ "type": "array",
444
+ "minItems": 3,
445
+ "maxItems": 3,
446
+ "items": {
447
+ "type": "number"
448
+ }
449
+ },
450
+ "description": "physics-toy topple: [x, y, size]."
451
+ },
452
+ "shots": {
453
+ "type": "integer",
454
+ "minimum": 1,
455
+ "maximum": 12
456
+ },
457
+ "platform": {
458
+ "type": "number",
459
+ "minimum": 0.5,
460
+ "maximum": 12
461
+ },
462
+ "pieces": {
463
+ "type": "array",
464
+ "items": {
465
+ "type": "array",
466
+ "minItems": 2,
467
+ "maxItems": 2,
468
+ "items": {
469
+ "type": "number"
470
+ }
471
+ }
472
+ },
473
+ "height": {
474
+ "type": "number",
475
+ "exclusiveMinimum": 0
476
+ }
477
+ }
478
+ }
479
+ },
480
+ "sound": {
481
+ "type": "object",
482
+ "properties": {
483
+ "music": {
484
+ "enum": [
485
+ "calm",
486
+ "tense",
487
+ "playful",
488
+ "none"
489
+ ]
490
+ },
491
+ "sfx": {
492
+ "type": "boolean"
493
+ },
494
+ "volume": {
495
+ "type": "number",
496
+ "minimum": 0,
497
+ "maximum": 1
498
+ }
499
+ },
500
+ "description": "Music composed from the game's seed in a mood, and effects synthesized for its events."
501
+ },
502
+ "text": {
503
+ "type": "object",
504
+ "additionalProperties": {
505
+ "type": "string"
506
+ }
507
+ },
508
+ "checks": {
509
+ "type": "object",
510
+ "properties": {
511
+ "bots": {
512
+ "type": "array",
513
+ "items": {
514
+ "enum": [
515
+ "random",
516
+ "greedy",
517
+ "planner"
518
+ ]
519
+ }
520
+ },
521
+ "finish": {
522
+ "oneOf": [
523
+ {
524
+ "type": "number",
525
+ "minimum": 0,
526
+ "maximum": 1
527
+ },
528
+ {
529
+ "type": "string",
530
+ "pattern": "^\\s*>=?\\s*(0(\\.\\d+)?|1(\\.0+)?)\\s*$"
531
+ }
532
+ ]
533
+ },
534
+ "firstAction": {
535
+ "type": "string"
536
+ },
537
+ "fps": {
538
+ "type": "number"
539
+ }
540
+ }
541
+ },
542
+ "splash": {
543
+ "type": "string"
544
+ },
545
+ "credits": {
546
+ "type": "string"
547
+ },
548
+ "art": {
549
+ "description": "Pictures in place of the kit's shapes (platformer, top-down, shmup). A part with no picture keeps its shape.",
550
+ "type": "object",
551
+ "required": [
552
+ "sheet",
553
+ "sprites"
554
+ ],
555
+ "properties": {
556
+ "sheet": {
557
+ "type": "string",
558
+ "description": "The picture's address, from the page (or a data: address)."
559
+ },
560
+ "frame": {
561
+ "type": "array",
562
+ "items": {
563
+ "type": "number",
564
+ "exclusiveMinimum": 0
565
+ },
566
+ "minItems": 2,
567
+ "maxItems": 2,
568
+ "description": "Cut as a grid of [width, height] pixels, numbered across then down from 0."
569
+ },
570
+ "frames": {
571
+ "type": "object",
572
+ "additionalProperties": {
573
+ "type": "array",
574
+ "items": {
575
+ "type": "number",
576
+ "minimum": 0
577
+ },
578
+ "minItems": 4,
579
+ "maxItems": 4
580
+ },
581
+ "description": "Rectangles by name: [x, y, width, height]."
582
+ },
583
+ "fps": {
584
+ "type": "number",
585
+ "exclusiveMinimum": 0,
586
+ "maximum": 60
587
+ },
588
+ "smooth": {
589
+ "type": "boolean",
590
+ "description": "true: smoothed when scaled (painted art). Default: hard pixels."
591
+ },
592
+ "sprites": {
593
+ "type": "object",
594
+ "description": "Which frames stand for which part: a frame, frames shown in turn, or { what it does: frames, size: [w, h] in cells, fps }.",
595
+ "additionalProperties": {
596
+ "oneOf": [
597
+ {
598
+ "type": "integer",
599
+ "minimum": 0
600
+ },
601
+ {
602
+ "type": "string"
603
+ },
604
+ {
605
+ "type": "array",
606
+ "items": {
607
+ "oneOf": [
608
+ {
609
+ "type": "integer",
610
+ "minimum": 0
611
+ },
612
+ {
613
+ "type": "string"
614
+ }
615
+ ]
616
+ },
617
+ "minItems": 1
618
+ },
619
+ {
620
+ "type": "object"
621
+ }
622
+ ]
623
+ }
624
+ }
625
+ }
626
+ }
627
+ }
628
+ }