chore: rebuild game.js with the Planet Designer (t1139)
@@ -187,6 +187,839 @@ var PLANET_CATALOG = {
187
187
]
188
188
}
189
189
;
190
var BLOCK_REGISTRY = {
191
"_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).",
192
"terraCount": 5,
193
"firstThreshold": 500,
194
"thresholdGrowth": 1.145,
195
"blocks": [
196
{
197
"id": "terra-ember",
198
"name": "Ember",
199
"hex": "#e85d3a",
200
"shape": "triangle",
201
"image": "images/block-terra-ember.png",
202
"terra": true
203
},
204
{
205
"id": "terra-aqua",
206
"name": "Aqua",
207
"hex": "#3db8e8",
208
"shape": "circle",
209
"image": "images/block-terra-aqua.png",
210
"terra": true
211
},
212
{
213
"id": "terra-leaf",
214
"name": "Leaf",
215
"hex": "#4cbf4c",
216
"shape": "square",
217
"image": "images/block-terra-leaf.png",
218
"terra": true
219
},
220
{
221
"id": "terra-sun",
222
"name": "Sun",
223
"hex": "#f0c53a",
224
"shape": "diamond",
225
"image": "images/block-terra-sun.png",
226
"terra": true
227
},
228
{
229
"id": "terra-orchid",
230
"name": "Orchid",
231
"hex": "#c45ad4",
232
"shape": "star",
233
"image": "images/block-terra-orchid.png",
234
"terra": true
235
},
236
{
237
"id": "rune-fehu",
238
"name": "Fehu",
239
"hex": "#e8a44a",
240
"shape": "rune_fehu",
241
"image": "images/block-rune-fehu.png",
242
"terra": false
243
},
244
{
245
"id": "rune-ansuz",
246
"name": "Ansuz",
247
"hex": "#6ab0e8",
248
"shape": "rune_ansuz",
249
"image": "images/block-rune-ansuz.png",
250
"terra": false
251
},
252
{
253
"id": "rune-thurisaz",
254
"name": "Thurisaz",
255
"hex": "#c05040",
256
"shape": "rune_thurisaz",
257
"image": "images/block-rune-thurisaz.png",
258
"terra": false
259
},
260
{
261
"id": "rune-raido",
262
"name": "Raido",
263
"hex": "#d0c070",
264
"shape": "rune_raido",
265
"image": "images/block-rune-raido.png",
266
"terra": false
267
},
268
{
269
"id": "rune-sowilo",
270
"name": "Sowilo",
271
"hex": "#f0d040",
272
"shape": "rune_sowilo",
273
"image": "images/block-rune-sowilo.png",
274
"terra": false
275
},
276
{
277
"id": "rune-algiz",
278
"name": "Algiz",
279
"hex": "#80d0a0",
280
"shape": "rune_algiz",
281
"image": "images/block-rune-algiz.png",
282
"terra": false
283
},
284
{
285
"id": "arrow-up",
286
"name": "Arrow",
287
"hex": "#f07040",
288
"shape": "arrow",
289
"image": "images/block-arrow-up.png",
290
"terra": false
291
},
292
{
293
"id": "arrow-chevron",
294
"name": "Chevron",
295
"hex": "#50c0e0",
296
"shape": "chevron",
297
"image": "images/block-arrow-chevron.png",
298
"terra": false
299
},
300
{
301
"id": "arrow-double",
302
"name": "Double Arrow",
303
"hex": "#e05080",
304
"shape": "double_arrow",
305
"image": "images/block-arrow-double.png",
306
"terra": false
307
},
308
{
309
"id": "arrow-return",
310
"name": "Return",
311
"hex": "#a080e0",
312
"shape": "return_arrow",
313
"image": "images/block-arrow-return.png",
314
"terra": false
315
},
316
{
317
"id": "fig-person",
318
"name": "Figure",
319
"hex": "#f0c0a0",
320
"shape": "person",
321
"image": "images/block-fig-person.png",
322
"terra": false
323
},
324
{
325
"id": "fig-walker",
326
"name": "Walker",
327
"hex": "#c09070",
328
"shape": "walker",
329
"image": "images/block-fig-walker.png",
330
"terra": false
331
},
332
{
333
"id": "fig-hero",
334
"name": "Hero",
335
"hex": "#e8b070",
336
"shape": "hero",
337
"image": "images/block-fig-hero.png",
338
"terra": false
339
},
340
{
341
"id": "face-smile",
342
"name": "Smile",
343
"hex": "#f0d060",
344
"shape": "smile",
345
"image": "images/block-face-smile.png",
346
"terra": false
347
},
348
{
349
"id": "face-wink",
350
"name": "Wink",
351
"hex": "#f0a050",
352
"shape": "wink",
353
"image": "images/block-face-wink.png",
354
"terra": false
355
},
356
{
357
"id": "face-cool",
358
"name": "Cool",
359
"hex": "#6090d0",
360
"shape": "cool",
361
"image": "images/block-face-cool.png",
362
"terra": false
363
},
364
{
365
"id": "face-grin",
366
"name": "Grin",
367
"hex": "#f0c848",
368
"shape": "grin",
369
"image": "images/block-face-grin.png",
370
"terra": false
371
},
372
{
373
"id": "icon-heart",
374
"name": "Heart",
375
"hex": "#e04060",
376
"shape": "heart",
377
"image": "images/block-icon-heart.png",
378
"terra": false
379
},
380
{
381
"id": "icon-moon",
382
"name": "Moon",
383
"hex": "#d0d8f0",
384
"shape": "crescent",
385
"image": "images/block-icon-moon.png",
386
"terra": false
387
},
388
{
389
"id": "icon-bolt",
390
"name": "Bolt",
391
"hex": "#f0e050",
392
"shape": "lightning",
393
"image": "images/block-icon-bolt.png",
394
"terra": false
395
},
396
{
397
"id": "icon-shield",
398
"name": "Shield",
399
"hex": "#5080c0",
400
"shape": "shield",
401
"image": "images/block-icon-shield.png",
402
"terra": false
403
},
404
{
405
"id": "icon-crown",
406
"name": "Crown",
407
"hex": "#f0c030",
408
"shape": "crown",
409
"image": "images/block-icon-crown.png",
410
"terra": false
411
},
412
{
413
"id": "icon-eye",
414
"name": "Eye",
415
"hex": "#70d0c0",
416
"shape": "eye",
417
"image": "images/block-icon-eye.png",
418
"terra": false
419
},
420
{
421
"id": "icon-star6",
422
"name": "Hexastar",
423
"hex": "#f0e8a0",
424
"shape": "star6",
425
"image": "images/block-icon-star6.png",
426
"terra": false
427
},
428
{
429
"id": "icon-spiral",
430
"name": "Spiral",
431
"hex": "#c070d0",
432
"shape": "spiral",
433
"image": "images/block-icon-spiral.png",
434
"terra": false
435
},
436
{
437
"id": "icon-wave",
438
"name": "Wave",
439
"hex": "#3090d0",
440
"shape": "wave",
441
"image": "images/block-icon-wave.png",
442
"terra": false
443
},
444
{
445
"id": "icon-mountain",
446
"name": "Mountain",
447
"hex": "#809070",
448
"shape": "mountain",
449
"image": "images/block-icon-mountain.png",
450
"terra": false
451
},
452
{
453
"id": "icon-fish",
454
"name": "Fish",
455
"hex": "#40a8c8",
456
"shape": "fish",
457
"image": "images/block-icon-fish.png",
458
"terra": false
459
},
460
{
461
"id": "icon-bird",
462
"name": "Bird",
463
"hex": "#e07050",
464
"shape": "bird",
465
"image": "images/block-icon-bird.png",
466
"terra": false
467
},
468
{
469
"id": "icon-key",
470
"name": "Key",
471
"hex": "#d0b050",
472
"shape": "key",
473
"image": "images/block-icon-key.png",
474
"terra": false
475
},
476
{
477
"id": "icon-comet",
478
"name": "Comet",
479
"hex": "#90d0f0",
480
"shape": "comet",
481
"image": "images/block-icon-comet.png",
482
"terra": false
483
},
484
{
485
"id": "icon-clover",
486
"name": "Clover",
487
"hex": "#40b060",
488
"shape": "clover",
489
"image": "images/block-icon-clover.png",
490
"terra": false
491
},
492
{
493
"id": "icon-paw",
494
"name": "Paw",
495
"hex": "#c08050",
496
"shape": "paw",
497
"image": "images/block-icon-paw.png",
498
"terra": false
499
},
500
{
501
"id": "icon-sword",
502
"name": "Sword",
503
"hex": "#b0b8c0",
504
"shape": "sword",
505
"image": "images/block-icon-sword.png",
506
"terra": false
507
},
508
{
509
"id": "icon-bell",
510
"name": "Bell",
511
"hex": "#f0c848",
512
"shape": "bell",
513
"image": "images/block-icon-bell.png",
514
"terra": false
515
},
516
{
517
"id": "icon-mushroom",
518
"name": "Mushroom",
519
"hex": "#e06050",
520
"shape": "mushroom",
521
"image": "images/block-icon-mushroom.png",
522
"terra": false
523
},
524
{
525
"id": "icon-cactus",
526
"name": "Cactus",
527
"hex": "#50b068",
528
"shape": "cactus",
529
"image": "images/block-icon-cactus.png",
530
"terra": false
531
},
532
{
533
"id": "icon-ring",
534
"name": "Ring",
535
"hex": "#e8d080",
536
"shape": "ring",
537
"image": "images/block-icon-ring.png",
538
"terra": false
539
},
540
{
541
"id": "icon-flag",
542
"name": "Flag",
543
"hex": "#d04050",
544
"shape": "flag",
545
"image": "images/block-icon-flag.png",
546
"terra": false
547
},
548
{
549
"id": "icon-snow",
550
"name": "Snowflake",
551
"hex": "#c8e0f8",
552
"shape": "snowflake",
553
"image": "images/block-icon-snow.png",
554
"terra": false
555
},
556
{
557
"id": "icon-flame",
558
"name": "Flame",
559
"hex": "#ff7030",
560
"shape": "flame_icon",
561
"image": "images/block-icon-flame.png",
562
"terra": false
563
},
564
{
565
"id": "icon-ankh",
566
"name": "Ankh",
567
"hex": "#d0a060",
568
"shape": "ankh",
569
"image": "images/block-icon-ankh.png",
570
"terra": false
571
},
572
{
573
"id": "icon-yin",
574
"name": "Yin Yang",
575
"hex": "#606080",
576
"shape": "yinyang",
577
"image": "images/block-icon-yin.png",
578
"terra": false
579
},
580
{
581
"id": "aurel-gold",
582
"name": "Aurel gold",
583
"hex": "#f4c860",
584
"shape": "hexagon",
585
"image": "images/block-aurel-gold.png",
586
"terra": false
587
},
588
{
589
"id": "aurel-cream",
590
"name": "Aurel cream",
591
"hex": "#f6e7c1",
592
"shape": "circle",
593
"image": "images/block-aurel-cream.png",
594
"terra": false
595
},
596
{
597
"id": "aurel-amber",
598
"name": "Aurel amber",
599
"hex": "#e09a3e",
600
"shape": "teardrop",
601
"image": "images/block-aurel-amber.png",
602
"terra": false
603
},
604
{
605
"id": "aurel-sage",
606
"name": "Aurel sage",
607
"hex": "#8fb86f",
608
"shape": "plus",
609
"image": "images/block-aurel-sage.png",
610
"terra": false
611
},
612
{
613
"id": "aurel-rose",
614
"name": "Aurel rose",
615
"hex": "#e8a0a8",
616
"shape": "pentagon",
617
"image": "images/block-aurel-rose.png",
618
"terra": false
619
},
620
{
621
"id": "cinder-magma",
622
"name": "Cinder magma",
623
"hex": "#ff3b1f",
624
"shape": "triangle",
625
"image": "images/block-cinder-magma.png",
626
"terra": false
627
},
628
{
629
"id": "cinder-coal",
630
"name": "Cinder coal",
631
"hex": "#3a3232",
632
"shape": "square",
633
"image": "images/block-cinder-coal.png",
634
"terra": false
635
},
636
{
637
"id": "cinder-spark",
638
"name": "Cinder spark",
639
"hex": "#ffb347",
640
"shape": "diamond",
641
"image": "images/block-cinder-spark.png",
642
"terra": false
643
},
644
{
645
"id": "cinder-ash",
646
"name": "Cinder ash",
647
"hex": "#8a7a76",
648
"shape": "circle",
649
"image": "images/block-cinder-ash.png",
650
"terra": false
651
},
652
{
653
"id": "cinder-core",
654
"name": "Cinder core",
655
"hex": "#ff6a00",
656
"shape": "star",
657
"image": "images/block-cinder-core.png",
658
"terra": false
659
},
660
{
661
"id": "lunara-silver",
662
"name": "Lunara silver",
663
"hex": "#c5d0e0",
664
"shape": "circle",
665
"image": "images/block-lunara-silver.png",
666
"terra": false
667
},
668
{
669
"id": "lunara-dust",
670
"name": "Lunara dust",
671
"hex": "#8b90a0",
672
"shape": "diamond",
673
"image": "images/block-lunara-dust.png",
674
"terra": false
675
},
676
{
677
"id": "lunara-pale",
678
"name": "Lunara pale",
679
"hex": "#e8d9a8",
680
"shape": "crescent",
681
"image": "images/block-lunara-pale.png",
682
"terra": false
683
},
684
{
685
"id": "lunara-void",
686
"name": "Lunara void",
687
"hex": "#2c3348",
688
"shape": "square",
689
"image": "images/block-lunara-void.png",
690
"terra": false
691
},
692
{
693
"id": "lunara-lilac",
694
"name": "Lunara lilac",
695
"hex": "#b9a4d4",
696
"shape": "star",
697
"image": "images/block-lunara-lilac.png",
698
"terra": false
699
},
700
{
701
"id": "mire-moss",
702
"name": "Mire moss",
703
"hex": "#3d7a45",
704
"shape": "hexagon",
705
"image": "images/block-mire-moss.png",
706
"terra": false
707
},
708
{
709
"id": "mire-bog",
710
"name": "Mire bog",
711
"hex": "#1f4d3a",
712
"shape": "teardrop",
713
"image": "images/block-mire-bog.png",
714
"terra": false
715
},
716
{
717
"id": "mire-rust",
718
"name": "Mire rust",
719
"hex": "#8b5a2b",
720
"shape": "pentagon",
721
"image": "images/block-mire-rust.png",
722
"terra": false
723
},
724
{
725
"id": "mire-spore",
726
"name": "Mire spore",
727
"hex": "#9cbf5a",
728
"shape": "circle",
729
"image": "images/block-mire-spore.png",
730
"terra": false
731
},
732
{
733
"id": "mire-murk",
734
"name": "Mire murk",
735
"hex": "#2e3b2f",
736
"shape": "diamond",
737
"image": "images/block-mire-murk.png",
738
"terra": false
739
},
740
{
741
"id": "galeon-sky",
742
"name": "Galeon sky",
743
"hex": "#4aa3ff",
744
"shape": "arrow",
745
"image": "images/block-galeon-sky.png",
746
"terra": false
747
},
748
{
749
"id": "galeon-cloud",
750
"name": "Galeon cloud",
751
"hex": "#e8eef6",
752
"shape": "circle",
753
"image": "images/block-galeon-cloud.png",
754
"terra": false
755
},
756
{
757
"id": "galeon-storm",
758
"name": "Galeon storm",
759
"hex": "#3d4d6e",
760
"shape": "square",
761
"image": "images/block-galeon-storm.png",
762
"terra": false
763
},
764
{
765
"id": "galeon-sand",
766
"name": "Galeon sand",
767
"hex": "#d4b483",
768
"shape": "diamond",
769
"image": "images/block-galeon-sand.png",
770
"terra": false
771
},
772
{
773
"id": "galeon-kite",
774
"name": "Galeon kite",
775
"hex": "#7fd0c0",
776
"shape": "star",
777
"image": "images/block-galeon-kite.png",
778
"terra": false
779
},
780
{
781
"id": "obsid-glass",
782
"name": "Obsid glass",
783
"hex": "#1a1a22",
784
"shape": "gem",
785
"image": "images/block-obsid-glass.png",
786
"terra": false
787
},
788
{
789
"id": "obsid-violet",
790
"name": "Obsid violet",
791
"hex": "#5a3d8a",
792
"shape": "hexagon",
793
"image": "images/block-obsid-violet.png",
794
"terra": false
795
},
796
{
797
"id": "obsid-shard",
798
"name": "Obsid shard",
799
"hex": "#8a8aa0",
800
"shape": "triangle",
801
"image": "images/block-obsid-shard.png",
802
"terra": false
803
},
804
{
805
"id": "obsid-vein",
806
"name": "Obsid vein",
807
"hex": "#c45a3a",
808
"shape": "diamond",
809
"image": "images/block-obsid-vein.png",
810
"terra": false
811
},
812
{
813
"id": "obsid-basalt",
814
"name": "Obsid basalt",
815
"hex": "#3a3a42",
816
"shape": "square",
817
"image": "images/block-obsid-basalt.png",
818
"terra": false
819
},
820
{
821
"id": "wisp-glow",
822
"name": "Wisp glow",
823
"hex": "#c8ffe0",
824
"shape": "circle",
825
"image": "images/block-wisp-glow.png",
826
"terra": false
827
},
828
{
829
"id": "wisp-mist",
830
"name": "Wisp mist",
831
"hex": "#a8d4e8",
832
"shape": "diamond",
833
"image": "images/block-wisp-mist.png",
834
"terra": false
835
},
836
{
837
"id": "wisp-sparkle",
838
"name": "Wisp sparkle",
839
"hex": "#fff6a8",
840
"shape": "star",
841
"image": "images/block-wisp-sparkle.png",
842
"terra": false
843
},
844
{
845
"id": "wisp-veil",
846
"name": "Wisp veil",
847
"hex": "#d0b8f0",
848
"shape": "teardrop",
849
"image": "images/block-wisp-veil.png",
850
"terra": false
851
},
852
{
853
"id": "wisp-gleam",
854
"name": "Wisp gleam",
855
"hex": "#f4f7ff",
856
"shape": "plus",
857
"image": "images/block-wisp-gleam.png",
858
"terra": false
859
},
860
{
861
"id": "thorn-briar",
862
"name": "Thorn briar",
863
"hex": "#5a7a30",
864
"shape": "triangle",
865
"image": "images/block-thorn-briar.png",
866
"terra": false
867
},
868
{
869
"id": "thorn-berry",
870
"name": "Thorn berry",
871
"hex": "#8b1a4a",
872
"shape": "circle",
873
"image": "images/block-thorn-berry.png",
874
"terra": false
875
},
876
{
877
"id": "thorn-bark",
878
"name": "Thorn bark",
879
"hex": "#5a3a20",
880
"shape": "square",
881
"image": "images/block-thorn-bark.png",
882
"terra": false
883
},
884
{
885
"id": "thorn-petal",
886
"name": "Thorn petal",
887
"hex": "#e89ab0",
888
"shape": "diamond",
889
"image": "images/block-thorn-petal.png",
890
"terra": false
891
},
892
{
893
"id": "thorn-gold",
894
"name": "Thorn gold",
895
"hex": "#c8a030",
896
"shape": "star",
897
"image": "images/block-thorn-gold.png",
898
"terra": false
899
},
900
{
901
"id": "zephyr-azure",
902
"name": "Zephyr azure",
903
"hex": "#6ec8ff",
904
"shape": "crescent",
905
"image": "images/block-zephyr-azure.png",
906
"terra": false
907
},
908
{
909
"id": "zephyr-breeze",
910
"name": "Zephyr breeze",
911
"hex": "#b8e8ff",
912
"shape": "circle",
913
"image": "images/block-zephyr-breeze.png",
914
"terra": false
915
},
916
{
917
"id": "zephyr-cirrus",
918
"name": "Zephyr cirrus",
919
"hex": "#f0f7ff",
920
"shape": "plus",
921
"image": "images/block-zephyr-cirrus.png",
922
"terra": false
923
},
924
{
925
"id": "zephyr-dusk",
926
"name": "Zephyr dusk",
927
"hex": "#7a6ab0",
928
"shape": "diamond",
929
"image": "images/block-zephyr-dusk.png",
930
"terra": false
931
},
932
{
933
"id": "zephyr-haze",
934
"name": "Zephyr haze",
935
"hex": "#ffe08a",
936
"shape": "star",
937
"image": "images/block-zephyr-haze.png",
938
"terra": false
939
},
940
{
941
"id": "frore-ice",
942
"name": "Frore ice",
943
"hex": "#a8d8f0",
944
"shape": "hexagon",
945
"image": "images/block-frore-ice.png",
946
"terra": false
947
},
948
{
949
"id": "frore-frost",
950
"name": "Frore frost",
951
"hex": "#eef7ff",
952
"shape": "circle",
953
"image": "images/block-frore-frost.png",
954
"terra": false
955
},
956
{
957
"id": "frore-deep",
958
"name": "Frore deep",
959
"hex": "#3a6a8a",
960
"shape": "diamond",
961
"image": "images/block-frore-deep.png",
962
"terra": false
963
},
964
{
965
"id": "frore-aurora",
966
"name": "Frore aurora",
967
"hex": "#5ae8c0",
968
"shape": "star",
969
"image": "images/block-frore-aurora.png",
970
"terra": false
971
},
972
{
973
"id": "frore-rime",
974
"name": "Frore rime",
975
"hex": "#d0e4f0",
976
"shape": "triangle",
977
"image": "images/block-frore-rime.png",
978
"terra": false
979
},
980
{
981
"id": "forge-iron",
982
"name": "Forge iron",
983
"hex": "#6a6a72",
984
"shape": "square",
985
"image": "images/block-forge-iron.png",
986
"terra": false
987
},
988
{
989
"id": "forge-slag",
990
"name": "Forge slag",
991
"hex": "#3a3028",
992
"shape": "hexagon",
993
"image": "images/block-forge-slag.png",
994
"terra": false
995
},
996
{
997
"id": "forge-spark",
998
"name": "Forge spark",
999
"hex": "#ff7a1a",
1000
"shape": "triangle",
1001
"image": "images/block-forge-spark.png",
1002
"terra": false
1003
},
1004
{
1005
"id": "forge-brass",
1006
"name": "Forge brass",
1007
"hex": "#c8a048",
1008
"shape": "diamond",
1009
"image": "images/block-forge-brass.png",
1010
"terra": false
1011
},
1012
{
1013
"id": "forge-soot",
1014
"name": "Forge soot",
1015
"hex": "#2a2a28",
1016
"shape": "circle",
1017
"image": "images/block-forge-soot.png",
1018
"terra": false
1019
}
1020
]
1021
}
1022
;
190
1023
191
1024
/*
192
1025
* Start File:
@@ -353,6 +1186,34 @@ function loadCatalog ()
353
1186
return { planets: [] };
354
1187
}
355
1188
1189
/** Player-owned custom planets (from the profile) and any remembered
1190
* snapshots (opponents in a lobby), not part of the official catalog. */
1191
var _customPlanets = [];
1192
var _remembered = Object.create(null);
1193
1194
function setCustomPlanets (list)
1195
{
1196
_customPlanets = [];
1197
if (!list || !list.length)
1198
{ return; }
1199
for (var i = 0; i < list.length; i++)
1200
{ _customPlanets.push(planetFromData(list[i])); }
1201
}
1202
1203
function rememberPlanet (data)
1204
{
1205
if (!data || !data.id)
1206
{ return null; }
1207
var pl = planetFromData(data);
1208
_remembered[pl.id] = pl;
1209
return pl;
1210
}
1211
1212
function forgetRemembered ()
1213
{
1214
_remembered = Object.create(null);
1215
}
1216
356
1217
function planetFromData (data)
357
1218
{
358
1219
var planet = createPlanet({
@@ -364,6 +1225,10 @@ function planetFromData (data)
364
1225
colors: data.colors
365
1226
});
366
1227
planet.id = data.id;
1228
if (data.custom)
1229
{ planet.custom = true; }
1230
if (data.owner_id)
1231
{ planet.owner_id = data.owner_id; }
367
1232
return planet;
368
1233
}
369
1234
@@ -375,6 +1240,8 @@ function allPlanets ()
375
1240
{ out.push(planetFromData(raw[i])); }
376
1241
if (out.length === 0)
377
1242
{ out.push(createPlanet({ name: 'Terra', people: 'Terrans', jumpsToClear: 2, fallTime: 3, riseTime: 1.5 })); out[0].id = 'terra'; }
1243
for (var c = 0; c < _customPlanets.length; c++)
1244
{ out.push(_customPlanets[c]); }
378
1245
return out;
379
1246
}
380
1247
@@ -386,9 +1253,30 @@ function planetById (id)
386
1253
if (all[i].id === id)
387
1254
{ return all[i]; }
388
1255
}
1256
if (id && _remembered[id])
1257
{ return _remembered[id]; }
389
1258
return defaultPlanet();
390
1259
}
391
1260
1261
function officialPlanets ()
1262
{
1263
var raw = loadCatalog().planets || [];
1264
var out = [];
1265
for (var i = 0; i < raw.length; i++)
1266
{ out.push(planetFromData(raw[i])); }
1267
return out;
1268
}
1269
1270
function customPlanets ()
1271
{
1272
return _customPlanets.slice();
1273
}
1274
1275
function pickerPlanets ()
1276
{
1277
return officialPlanets().concat(_customPlanets);
1278
}
1279
392
1280
function defaultPlanet ()
393
1281
{
394
1282
var all = allPlanets();
@@ -415,6 +1303,11 @@ function spriteKey (planet, colorIndex)
415
1303
var c = colors && colors[colorIndex];
416
1304
if (!c)
417
1305
{ return 'gray'; }
1306
// Custom planets (and any color that names a registry block) share
1307
// the preloaded Blocks.images() sprite, so late-loaded customs and
1308
// opponent snapshots do not need a second preload.
1309
if (c.block)
1310
{ return 'block:' + c.block; }
418
1311
return (planet.id || 'planet') + '-' + (c.name || String(colorIndex));
419
1312
}
420
1313
@@ -512,6 +1405,12 @@ var Planet = {
512
1405
defaultPlanet: defaultPlanet,
513
1406
defaultColors: defaultColors,
514
1407
allPlanets: allPlanets,
1408
officialPlanets: officialPlanets,
1409
customPlanets: customPlanets,
1410
pickerPlanets: pickerPlanets,
1411
setCustomPlanets: setCustomPlanets,
1412
rememberPlanet: rememberPlanet,
1413
forgetRemembered: forgetRemembered,
515
1414
planetById: planetById,
516
1415
planetFromData: planetFromData,
517
1416
formatStats: formatStats,
@@ -528,13 +1427,183 @@ var Planet = {
528
1427
};
529
1428
530
1429
if (typeof module !== 'undefined' && module.exports)
531
{ module.exports = Planet; }
1430
{ module.exports = Planet; }
1431
else if (typeof globalThis !== 'undefined')
1432
{ globalThis.Planet = Planet; }
1433
1434
/*
1435
* End File:
1436
* /workspace/meteors/src/planet.js
1437
*/
1438
1439
/*
1440
* Start File:
1441
* /workspace/meteors/src/blocks.js
1442
*/
1443
'use strict';
1444
1445
/**
1446
* Append-only block registry. Thresholds and order stay in lockstep with
1447
* server/lib/Blocks.php: Terra's first five are free; the next costs 500
1448
* lifetime points; each one after that costs 14.5% more (rounded, always
1449
* strictly increasing). Points are a requirement, not a spend.
1450
*/
1451
1452
var Blocks = (function ()
1453
{
1454
var TERRA_COUNT = 5;
1455
var FIRST_THRESHOLD = 500;
1456
var GROWTH = 1.145;
1457
var _all = null;
1458
1459
function loadRegistry ()
1460
{
1461
if (_all)
1462
{ return _all; }
1463
var data = null;
1464
if (typeof BLOCK_REGISTRY !== 'undefined' && BLOCK_REGISTRY && BLOCK_REGISTRY.blocks)
1465
{ data = BLOCK_REGISTRY; }
1466
else if (typeof require !== 'undefined')
1467
{
1468
try
1469
{ data = require('../server/lib/blocks.json'); }
1470
catch (e) { data = null; }
1471
}
1472
_all = (data && data.blocks) ? data.blocks.slice() : [];
1473
return _all;
1474
}
1475
1476
function all ()
1477
{
1478
return loadRegistry();
1479
}
1480
1481
function byId (id)
1482
{
1483
var list = all();
1484
for (var i = 0; i < list.length; i++)
1485
{
1486
if (list[i].id === id)
1487
{ return list[i]; }
1488
}
1489
return null;
1490
}
1491
1492
function indexOf (id)
1493
{
1494
var list = all();
1495
for (var i = 0; i < list.length; i++)
1496
{
1497
if (list[i].id === id)
1498
{ return i; }
1499
}
1500
return -1;
1501
}
1502
1503
function threshold (index)
1504
{
1505
if (index < TERRA_COUNT)
1506
{ return 0; }
1507
var t = FIRST_THRESHOLD;
1508
for (var i = TERRA_COUNT; i < index; i++)
1509
{
1510
var next = Math.round(t * GROWTH);
1511
t = Math.max(t + 1, next);
1512
}
1513
return t;
1514
}
1515
1516
function unlocked (index, points)
1517
{
1518
points = points || 0;
1519
return points >= threshold(index);
1520
}
1521
1522
function unlockedId (id, points)
1523
{
1524
var i = indexOf(id);
1525
return i >= 0 && unlocked(i, points);
1526
}
1527
1528
function present (points)
1529
{
1530
points = points || 0;
1531
var list = all();
1532
var out = [];
1533
for (var i = 0; i < list.length; i++)
1534
{
1535
var b = list[i];
1536
var need = threshold(i);
1537
out.push({
1538
id: b.id,
1539
name: b.name || b.id,
1540
hex: b.hex,
1541
shape: b.shape,
1542
image: b.image,
1543
terra: !!b.terra || i < TERRA_COUNT,
1544
index: i,
1545
threshold: need,
1546
unlocked: points >= need
1547
});
1548
}
1549
return out;
1550
}
1551
1552
function asColor (id, slot)
1553
{
1554
var b = byId(id);
1555
if (!b)
1556
{ return null; }
1557
return {
1558
id: slot,
1559
block: b.id,
1560
name: b.name || b.id,
1561
hex: b.hex,
1562
shape: b.shape,
1563
image: b.image
1564
};
1565
}
1566
1567
function images ()
1568
{
1569
var list = all();
1570
var out = [];
1571
var seen = Object.create(null);
1572
for (var i = 0; i < list.length; i++)
1573
{
1574
var url = list[i].image;
1575
if (!url || seen[url])
1576
{ continue; }
1577
seen[url] = true;
1578
out.push({ name: 'block:' + list[i].id, url: url });
1579
}
1580
return out;
1581
}
1582
1583
return {
1584
TERRA_COUNT: TERRA_COUNT,
1585
FIRST_THRESHOLD: FIRST_THRESHOLD,
1586
GROWTH: GROWTH,
1587
all: all,
1588
byId: byId,
1589
indexOf: indexOf,
1590
threshold: threshold,
1591
unlocked: unlocked,
1592
unlockedId: unlockedId,
1593
present: present,
1594
asColor: asColor,
1595
images: images
1596
};
1597
})();
1598
1599
if (typeof module !== 'undefined' && module.exports)
1600
{ module.exports = Blocks; }
532
1601
else if (typeof globalThis !== 'undefined')
533
{ globalThis.Planet = Planet; }
1602
{ globalThis.Blocks = Blocks; }
534
1603
535
1604
/*
536
1605
* End File:
537
* /workspace/meteors/src/planet.js
1606
* /workspace/meteors/src/blocks.js
538
1607
*/
539
1608
540
1609
/*
@@ -4074,6 +5143,10 @@ var Online = {
4074
5143
local: false,
4075
5144
csrf: '',
4076
5145
me: null,
5146
lifetimePoints: 0,
5147
locale: null,
5148
blocks: [],
5149
planets: [],
4077
5150
lobby: null,
4078
5151
incoming: [],
4079
5152
shotResults: [],
@@ -4125,6 +5198,26 @@ Online._apply = function (data)
4125
5198
{ this.error = data.error; }
4126
5199
else if (data.ok)
4127
5200
{ this.error = ''; }
5201
if (data.lifetime_points != null)
5202
{ this.lifetimePoints = data.lifetime_points; }
5203
if (data.locale !== undefined)
5204
{ this.locale = data.locale; }
5205
if (data.blocks)
5206
{ this.blocks = data.blocks; }
5207
if (data.planets)
5208
{
5209
this.planets = data.planets;
5210
if (typeof Planet !== 'undefined' && Planet.setCustomPlanets)
5211
{ Planet.setCustomPlanets(data.planets); }
5212
}
5213
if (data.lobby && data.lobby.players && typeof Planet !== 'undefined' && Planet.rememberPlanet)
5214
{
5215
for (var i = 0; i < data.lobby.players.length; i++)
5216
{
5217
if (data.lobby.players[i].planet)
5218
{ Planet.rememberPlanet(data.lobby.players[i].planet); }
5219
}
5220
}
4128
5221
};
4129
5222
4130
5223
Online.request = function (action, body)
@@ -4196,6 +5289,31 @@ Online.setPlanet = function (planetId)
4196
5289
return this.request('lobby_set_planet', { planet_id: planetId });
4197
5290
};
4198
5291
5292
Online.playBegin = function (mode)
5293
{
5294
return this.request('play_begin', { mode: mode || 'solo' });
5295
};
5296
5297
Online.playFinish = function (token, score)
5298
{
5299
return this.request('play_finish', { token: token, score: score || 0 });
5300
};
5301
5302
Online.savePlanet = function (planet)
5303
{
5304
return this.request('planet_save', { planet: planet });
5305
};
5306
5307
Online.deletePlanet = function (id)
5308
{
5309
return this.request('planet_delete', { id: id });
5310
};
5311
5312
Online.setLocale = function (locale)
5313
{
5314
return this.request('set_locale', { locale: locale });
5315
};
5316
4199
5317
Online.leaveLobby = function ()
4200
5318
{
4201
5319
return this.request('lobby_leave');
@@ -6444,6 +7562,545 @@ if (typeof module !== 'undefined' && module.exports && typeof Offline !== 'undef
6444
7562
* /workspace/meteors/src/offline.js
6445
7563
*/
6446
7564
7565
/*
7566
* Start File:
7567
* /workspace/meteors/src/designer.js
7568
*/
7569
'use strict';
7570
7571
/**
7572
* Planeetontwerper (t1139). Only available on the main menu when the
7573
* player is logged in. Talks to api.php through Online.
7574
*/
7575
var Designer = {
7576
openSlot: 0,
7577
editingId: null,
7578
slots: [null, null, null, null, null],
7579
dirty: false
7580
};
7581
7582
Designer._blocks = function ()
7583
{
7584
if (typeof Blocks !== 'undefined')
7585
{ return Blocks; }
7586
if (typeof require !== 'undefined')
7587
{
7588
try
7589
{ return require('./blocks.js'); }
7590
catch (e)
7591
{ return null; }
7592
}
7593
return null;
7594
};
7595
7596
Designer.defaultSlots = function ()
7597
{
7598
var B = Designer._blocks();
7599
var all = B ? B.all() : [];
7600
var ids = [];
7601
for (var i = 0; i < 5 && i < all.length; i++)
7602
{ ids.push(all[i].id); }
7603
return ids;
7604
};
7605
7606
Designer.points = function ()
7607
{
7608
return (typeof Online !== 'undefined' && Online.lifetimePoints) || 0;
7609
};
7610
7611
Designer.blocks = function ()
7612
{
7613
if (typeof Online !== 'undefined' && Online.blocks && Online.blocks.length)
7614
{ return Online.blocks; }
7615
var B = Designer._blocks();
7616
if (B)
7617
{ return B.present(Designer.points()); }
7618
return [];
7619
};
7620
7621
Designer.planets = function ()
7622
{
7623
if (typeof Planet !== 'undefined' && Planet.customPlanets)
7624
{ return Planet.customPlanets(); }
7625
return (typeof Online !== 'undefined' && Online.planets) || [];
7626
};
7627
7628
Designer.openList = function ()
7629
{
7630
if (typeof Online === 'undefined' || !Online.me)
7631
{ return; }
7632
if (typeof app !== 'undefined')
7633
{ app.mode = 'designer'; }
7634
hideIf('menu');
7635
hideIf('planet-select');
7636
hideIf('online-panel');
7637
hideIf('designer-edit');
7638
showIf('designer');
7639
Designer.renderList();
7640
};
7641
7642
Designer.close = function ()
7643
{
7644
hideIf('designer');
7645
hideIf('designer-edit');
7646
Designer.closeModal();
7647
if (typeof app !== 'undefined')
7648
{ app.mode = 'menu'; }
7649
showIf('menu');
7650
if (typeof refreshMenuAccount === 'function')
7651
{ refreshMenuAccount(); }
7652
if (typeof renderPlanetGrid === 'function')
7653
{
7654
renderPlanetGrid('planet-grid', false);
7655
renderPlanetGrid('lobby-planet-grid', true);
7656
}
7657
};
7658
7659
Designer.renderList = function ()
7660
{
7661
var box = document.getElementById('designer-list');
7662
var pts = document.getElementById('designer-points');
7663
if (pts)
7664
{ pts.textContent = String(Designer.points()); }
7665
if (!box)
7666
{ return; }
7667
box.innerHTML = '';
7668
var planets = Designer.planets();
7669
if (!planets.length)
7670
{
7671
var empty = document.createElement('p');
7672
empty.className = 'hint';
7673
empty.textContent = 'Je hebt nog geen eigen planeten. Maak er een aan.';
7674
box.appendChild(empty);
7675
return;
7676
}
7677
for (var i = 0; i < planets.length; i++)
7678
{
7679
var pl = planets[i];
7680
if (typeof Planet !== 'undefined' && Planet.planetFromData && !pl.baseJumpHeight)
7681
{ pl = Planet.planetFromData(pl); }
7682
var card = document.createElement('div');
7683
card.className = 'planet-card designer-card';
7684
var swatches = '';
7685
var colors = pl.colors || [];
7686
for (var c = 0; c < colors.length; c++)
7687
{
7688
swatches += '<img src="' + Designer.esc(colors[c].image) + '" alt="'
7689
+ Designer.esc(colors[c].name) + '">';
7690
}
7691
var stats = (typeof Planet !== 'undefined' && Planet.formatStats)
7692
? Planet.formatStats(pl) : '';
7693
card.innerHTML = '<div class="planet-title">' + Designer.esc(pl.name) + '</div>'
7694
+ '<div class="planet-people">' + Designer.esc(pl.people) + '</div>'
7695
+ '<div class="planet-nums">' + Designer.esc(stats) + '</div>'
7696
+ '<div class="planet-swatches">' + swatches + '</div>'
7697
+ '<div class="designer-card-actions">'
7698
+ '<button type="button" class="btn-tiny" data-edit>Bewerken</button>'
7699
+ '<button type="button" class="btn-tiny btn-danger-lite" data-del>Verwijderen</button>'
7700
+ '</div>';
7701
(function (id)
7702
{
7703
card.querySelector('[data-edit]').addEventListener('click', function ()
7704
{ Designer.openEdit(id); });
7705
card.querySelector('[data-del]').addEventListener('click', function ()
7706
{ Designer.confirmDelete(id); });
7707
})(pl.id);
7708
box.appendChild(card);
7709
}
7710
};
7711
7712
Designer.confirmDelete = function (id)
7713
{
7714
var pl = Designer.planetById(id);
7715
var name = pl ? pl.name : id;
7716
if (!window.confirm('Wil je de planeet “' + name + '” verwijderen?'))
7717
{ return; }
7718
Online.deletePlanet(id).then(function (data)
7719
{
7720
if (!data || !data.ok)
7721
{
7722
window.alert((data && data.error) || 'Verwijderen is mislukt.');
7723
return;
7724
}
7725
Designer.renderList();
7726
if (typeof renderPlanetGrid === 'function')
7727
{
7728
renderPlanetGrid('planet-grid', false);
7729
renderPlanetGrid('lobby-planet-grid', true);
7730
}
7731
});
7732
};
7733
7734
Designer.planetById = function (id)
7735
{
7736
var list = Designer.planets();
7737
for (var i = 0; i < list.length; i++)
7738
{
7739
if (list[i].id === id)
7740
{ return list[i]; }
7741
}
7742
return null;
7743
};
7744
7745
Designer.openEdit = function (id)
7746
{
7747
var pl = id ? Designer.planetById(id) : null;
7748
Designer.editingId = pl ? pl.id : null;
7749
if (pl)
7750
{
7751
Designer.slots = [];
7752
for (var i = 0; i < 5; i++)
7753
{
7754
var c = pl.colors && pl.colors[i];
7755
Designer.slots[i] = c ? (c.block || c.id) : Designer.defaultSlots()[i];
7756
// c.id is the slot index 0-4 on snapshots; prefer c.block
7757
if (c && c.block)
7758
{ Designer.slots[i] = c.block; }
7759
else if (c && typeof c.id === 'string')
7760
{ Designer.slots[i] = c.id; }
7761
}
7762
document.getElementById('des-name').value = pl.name || '';
7763
document.getElementById('des-people').value = pl.people || '';
7764
document.getElementById('des-gravity').value = String(pl.jumpsToClear != null ? pl.jumpsToClear : 2);
7765
document.getElementById('des-air').value = String(pl.fallTime != null ? pl.fallTime : 3);
7766
document.getElementById('des-mass').value = String(pl.riseTime != null ? pl.riseTime : 1.5);
7767
document.getElementById('designer-edit-title').textContent = 'Planeet bewerken';
7768
document.getElementById('btn-designer-delete').hidden = false;
7769
}
7770
else
7771
{
7772
Designer.slots = Designer.defaultSlots().slice();
7773
document.getElementById('des-name').value = '';
7774
document.getElementById('des-people').value = '';
7775
document.getElementById('des-gravity').value = '2';
7776
document.getElementById('des-air').value = '3';
7777
document.getElementById('des-mass').value = '1.5';
7778
document.getElementById('designer-edit-title').textContent = 'Nieuwe planeet';
7779
document.getElementById('btn-designer-delete').hidden = true;
7780
}
7781
hideIf('designer');
7782
showIf('designer-edit');
7783
Designer.syncPreview();
7784
Designer.renderSlots();
7785
var name = document.getElementById('des-name');
7786
if (name)
7787
{ name.focus(); }
7788
};
7789
7790
Designer.draftPlanet = function ()
7791
{
7792
var jumps = clampNum(document.getElementById('des-gravity').value, 1, 4, 2);
7793
var fall = clampNum(document.getElementById('des-air').value, 1, 5, 3);
7794
var rise = clampNum(document.getElementById('des-mass').value, 0.5, 3, 1.5);
7795
var colors = [];
7796
for (var i = 0; i < 5; i++)
7797
{
7798
var B = Designer._blocks();
7799
var col = B ? B.asColor(Designer.slots[i], i) : null;
7800
if (col)
7801
{ colors.push(col); }
7802
}
7803
var opts = {
7804
id: Designer.editingId || 'draft',
7805
name: (document.getElementById('des-name').value || 'Nieuwe planeet').trim() || 'Nieuwe planeet',
7806
people: (document.getElementById('des-people').value || 'Volk').trim() || 'Volk',
7807
jumpsToClear: jumps,
7808
fallTime: fall,
7809
riseTime: rise,
7810
colors: colors
7811
};
7812
if (typeof Planet === 'undefined')
7813
{ return opts; }
7814
return Planet.createPlanet ? (function ()
7815
{
7816
var p = Planet.createPlanet(opts);
7817
p.id = opts.id;
7818
p.custom = true;
7819
return p;
7820
})() : opts;
7821
};
7822
7823
Designer.syncPreview = function ()
7824
{
7825
var p = Designer.draftPlanet();
7826
var d = (typeof Planet !== 'undefined' && Planet.displayValues) ? Planet.displayValues(p) : null;
7827
setText('des-gravity-val', Number(document.getElementById('des-gravity').value).toFixed(1)
7828
+ (d ? ' · g ' + d.gravity.toFixed(2) : ''));
7829
setText('des-air-val', Number(document.getElementById('des-air').value).toFixed(1)
7830
+ (d ? ' · d ' + d.density.toFixed(2) : ''));
7831
setText('des-mass-val', Number(document.getElementById('des-mass').value).toFixed(1)
7832
+ (d ? ' · F ' + Math.round(d.newtons) + ' N' : ''));
7833
var power = d ? d.power : 0;
7834
setText('des-power', 'Power ' + power + '%');
7835
};
7836
7837
Designer.renderSlots = function ()
7838
{
7839
var row = document.getElementById('des-slots');
7840
if (!row)
7841
{ return; }
7842
row.innerHTML = '';
7843
for (var i = 0; i < 5; i++)
7844
{
7845
var id = Designer.slots[i];
7846
var B = Designer._blocks();
7847
var b = B ? B.byId(id) : null;
7848
var btn = document.createElement('button');
7849
btn.type = 'button';
7850
btn.className = 'des-slot';
7851
btn.setAttribute('aria-label', 'Blokje ' + (i + 1));
7852
if (b)
7853
{
7854
btn.innerHTML = '<img src="' + Designer.esc(b.image) + '" alt="' + Designer.esc(b.name) + '">'
7855
+ '<span>' + Designer.esc(b.name) + '</span>';
7856
}
7857
else
7858
{
7859
btn.innerHTML = '<span class="des-slot-empty">Kies</span>';
7860
}
7861
(function (slot)
7862
{
7863
btn.addEventListener('click', function ()
7864
{ Designer.openModal(slot); });
7865
})(i);
7866
row.appendChild(btn);
7867
}
7868
};
7869
7870
Designer.openModal = function (slot)
7871
{
7872
Designer.openSlot = slot;
7873
var modal = document.getElementById('des-modal');
7874
var grid = document.getElementById('des-modal-grid');
7875
if (!modal || !grid)
7876
{ return; }
7877
grid.innerHTML = '';
7878
var blocks = Designer.blocks();
7879
var used = Object.create(null);
7880
for (var i = 0; i < 5; i++)
7881
{
7882
if (i !== slot && Designer.slots[i])
7883
{ used[Designer.slots[i]] = true; }
7884
}
7885
for (var i = 0; i < blocks.length; i++)
7886
{
7887
var b = blocks[i];
7888
var cell = document.createElement('button');
7889
cell.type = 'button';
7890
cell.className = 'des-block';
7891
cell.dataset.id = b.id;
7892
var locked = !b.unlocked;
7893
var taken = !!used[b.id];
7894
if (locked)
7895
{ cell.classList.add('locked'); }
7896
if (taken)
7897
{ cell.classList.add('used'); }
7898
if (Designer.slots[slot] === b.id)
7899
{ cell.classList.add('current'); }
7900
var title = b.name;
7901
if (locked)
7902
{ title += ' — ' + b.threshold + ' punten nodig'; }
7903
else if (taken)
7904
{ title += ' — al in een ander vak'; }
7905
cell.title = title;
7906
cell.setAttribute('aria-label', title);
7907
cell.innerHTML = '<img src="' + Designer.esc(b.image) + '" alt="">'
7908
+ (locked ? '<span class="des-lock" aria-hidden="true">'
7909
+ '<svg viewBox="0 0 18 18" width="16" height="16">'
7910
+ '<rect x="4" y="8" width="10" height="8" rx="1.5" fill="#ffe27a"/>'
7911
+ '<path d="M6 8 V6 a3 3 0 0 1 6 0 v2" fill="none" stroke="#ffe27a" stroke-width="1.8" stroke-linecap="round"/>'
7912
+ '<circle cx="9" cy="12" r="1.2" fill="#1a1628"/>'
7913
+ '</svg></span>' : '')
7914
+ '<span class="des-block-name">' + Designer.esc(b.name) + '</span>'
7915
+ (locked ? '<span class="des-block-need">' + b.threshold + '</span>' : '');
7916
if (locked || taken)
7917
{ cell.disabled = true; }
7918
else
7919
{
7920
cell.addEventListener('click', (function (id)
7921
{
7922
return function ()
7923
{
7924
Designer.slots[Designer.openSlot] = id;
7925
Designer.closeModal();
7926
Designer.renderSlots();
7927
};
7928
})(b.id));
7929
}
7930
grid.appendChild(cell);
7931
}
7932
modal.hidden = false;
7933
modal.setAttribute('aria-hidden', 'false');
7934
var close = document.getElementById('des-modal-close');
7935
if (close)
7936
{ close.focus(); }
7937
};
7938
7939
Designer.closeModal = function ()
7940
{
7941
var modal = document.getElementById('des-modal');
7942
if (!modal)
7943
{ return; }
7944
modal.hidden = true;
7945
modal.setAttribute('aria-hidden', 'true');
7946
};
7947
7948
Designer.save = function ()
7949
{
7950
var name = (document.getElementById('des-name').value || '').trim();
7951
var people = (document.getElementById('des-people').value || '').trim();
7952
if (!name || !people)
7953
{
7954
window.alert('Vul een naam voor de planeet en voor de bevolking in.');
7955
return;
7956
}
7957
for (var i = 0; i < 5; i++)
7958
{
7959
if (!Designer.slots[i])
7960
{
7961
window.alert('Kies vijf blokjes.');
7962
return;
7963
}
7964
}
7965
var payload = {
7966
id: Designer.editingId || undefined,
7967
name: name,
7968
people: people,
7969
jumpsToClear: clampNum(document.getElementById('des-gravity').value, 1, 4, 2),
7970
fallTime: clampNum(document.getElementById('des-air').value, 1, 5, 3),
7971
riseTime: clampNum(document.getElementById('des-mass').value, 0.5, 3, 1.5),
7972
colors: Designer.slots.slice()
7973
};
7974
Online.savePlanet(payload).then(function (data)
7975
{
7976
if (!data || !data.ok)
7977
{
7978
window.alert((data && data.error) || 'Opslaan is mislukt.');
7979
return;
7980
}
7981
hideIf('designer-edit');
7982
showIf('designer');
7983
Designer.editingId = data.planet ? data.planet.id : null;
7984
Designer.renderList();
7985
if (typeof renderPlanetGrid === 'function')
7986
{
7987
renderPlanetGrid('planet-grid', false);
7988
renderPlanetGrid('lobby-planet-grid', true);
7989
}
7990
});
7991
};
7992
7993
Designer.bind = function ()
7994
{
7995
var btn = document.getElementById('btn-designer');
7996
if (btn)
7997
{ btn.addEventListener('click', function () { Designer.openList(); }); }
7998
var back = document.getElementById('btn-designer-back');
7999
if (back)
8000
{ back.addEventListener('click', Designer.close); }
8001
var neu = document.getElementById('btn-designer-new');
8002
if (neu)
8003
{ neu.addEventListener('click', function () { Designer.openEdit(null); }); }
8004
var cancel = document.getElementById('btn-designer-cancel');
8005
if (cancel)
8006
{
8007
cancel.addEventListener('click', function ()
8008
{
8009
hideIf('designer-edit');
8010
showIf('designer');
8011
Designer.renderList();
8012
});
8013
}
8014
var save = document.getElementById('btn-designer-save');
8015
if (save)
8016
{ save.addEventListener('click', function (e) { e.preventDefault(); Designer.save(); }); }
8017
var form = document.getElementById('designer-form');
8018
if (form)
8019
{ form.addEventListener('submit', function (e) { e.preventDefault(); Designer.save(); }); }
8020
var del = document.getElementById('btn-designer-delete');
8021
if (del)
8022
{
8023
del.addEventListener('click', function ()
8024
{
8025
if (!Designer.editingId)
8026
{ return; }
8027
Designer.confirmDelete(Designer.editingId);
8028
hideIf('designer-edit');
8029
showIf('designer');
8030
});
8031
}
8032
['des-gravity', 'des-air', 'des-mass'].forEach(function (id)
8033
{
8034
var el = document.getElementById(id);
8035
if (!el)
8036
{ return; }
8037
el.addEventListener('input', Designer.syncPreview);
8038
});
8039
var modal = document.getElementById('des-modal');
8040
if (modal)
8041
{
8042
modal.addEventListener('click', function (e)
8043
{
8044
if (e.target === modal)
8045
{ Designer.closeModal(); }
8046
});
8047
}
8048
var close = document.getElementById('des-modal-close');
8049
if (close)
8050
{ close.addEventListener('click', Designer.closeModal); }
8051
document.addEventListener('keydown', function (e)
8052
{
8053
if (e.key === 'Escape')
8054
{ Designer.closeModal(); }
8055
});
8056
};
8057
8058
Designer.esc = function (s)
8059
{
8060
return String(s == null ? '' : s)
8061
.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
8062
.replace(/"/g, '"');
8063
};
8064
8065
function hideIf (id)
8066
{
8067
var el = document.getElementById(id);
8068
if (el)
8069
{ el.hidden = true; }
8070
}
8071
8072
function showIf (id)
8073
{
8074
var el = document.getElementById(id);
8075
if (el)
8076
{ el.hidden = false; }
8077
}
8078
8079
function setText (id, text)
8080
{
8081
var el = document.getElementById(id);
8082
if (el)
8083
{ el.textContent = text; }
8084
}
8085
8086
function clampNum (v, lo, hi, fallback)
8087
{
8088
var n = Number(v);
8089
if (!isFinite(n))
8090
{ n = fallback; }
8091
return Math.max(lo, Math.min(hi, n));
8092
}
8093
8094
if (typeof module !== 'undefined' && module.exports)
8095
{ module.exports = Designer; }
8096
else if (typeof globalThis !== 'undefined')
8097
{ globalThis.Designer = Designer; }
8098
8099
/*
8100
* End File:
8101
* /workspace/meteors/src/designer.js
8102
*/
8103
6447
8104
/*
6448
8105
* Start File:
6449
8106
* /workspace/meteors/src/main.js
@@ -6486,6 +8143,12 @@ function planetImages ()
6486
8143
});
6487
8144
}
6488
8145
}
8146
if (typeof Blocks !== 'undefined' && Blocks.images)
8147
{
8148
var extra = Blocks.images();
8149
for (var b = 0; b < extra.length; b++)
8150
{ list.push(extra[b]); }
8151
}
6489
8152
return list;
6490
8153
}
6491
8154
@@ -6560,6 +8223,20 @@ window.onload = function ()
6560
8223
bindOfflineUi();
6561
8224
bindPlanetSelect();
6562
8225
restoreSelectedPlanet();
8226
if (typeof Designer !== 'undefined' && Designer.bind)
8227
{ Designer.bind(); }
8228
if (typeof Online !== 'undefined' && Online.refresh)
8229
{
8230
Online.refresh().then(function ()
8231
{
8232
refreshMenuAccount();
8233
restoreSelectedPlanet();
8234
renderPlanetGrid('planet-grid', false);
8235
renderPlanetGrid('lobby-planet-grid', true);
8236
});
8237
}
8238
else
8239
{ refreshMenuAccount(); }
6563
8240
};
6564
8241
6565
8242
function onPlay ()
@@ -6579,6 +8256,10 @@ function startPlay (opts)
6579
8256
hideEl('podium');
6580
8257
hideEl('planet-select');
6581
8258
hideEl('offline-result');
8259
hideEl('designer');
8260
hideEl('designer-edit');
8261
if (typeof Designer !== 'undefined' && Designer.closeModal)
8262
{ Designer.closeModal(); }
6582
8263
showEl('hud');
6583
8264
6584
8265
var planetMod = typeof Planet !== 'undefined' ? Planet : PlanetMod;
@@ -6642,6 +8323,8 @@ function startPlay (opts)
6642
8323
buildColumnWarn();
6643
8324
refreshOfflineHud();
6644
8325
refreshChainIndicator();
8326
if (!opts.online)
8327
{ beginPlaySession(opts.offline ? 'offline' : 'solo'); }
6645
8328
}
6646
8329
6647
8330
function teardownPlay ()
@@ -7234,7 +8917,10 @@ function tickView (dt)
7234
8917
else if (app.offline)
7235
8918
{ /* Offline result is shown from tickOffline. */ }
7236
8919
else
7237
{ showEl('game-over'); }
8920
{
8921
showEl('game-over');
8922
finishPlaySession(app.lastScore);
8923
}
7238
8924
}
7239
8925
if (!app.online && !app.offline && app.core.state === 'gameover'
7240
8926
&& app.core.gameOverTime >= GAME_OVER_DELAY)
@@ -7845,6 +9531,8 @@ function startNextOfflineRound ()
7845
9531
// Tear down the current scene then start a fresh player field,
7846
9532
// keeping the same battle (already advanced).
7847
9533
var planet = app.battle.playerPlanet;
9534
var roundScore = app.core ? app.core.score : 0;
9535
finishPlaySession(roundScore);
7848
9536
app._keepBattleOnTeardown = true;
7849
9537
teardownPlay();
7850
9538
app.offline = true;
@@ -7870,6 +9558,7 @@ function showOfflineResult ()
7870
9558
}
7871
9559
hideEl('game-over');
7872
9560
showEl('offline-result');
9561
finishPlaySession(app.core ? app.core.score : 0);
7873
9562
}
7874
9563
7875
9564
function refreshOfflineHud ()
@@ -8181,10 +9870,18 @@ function startOnlineMatch ()
8181
9870
if (app.mode === 'playing' && app.online)
8182
9871
{ return; }
8183
9872
var planet = Planet.planetById(selectedPlanetId());
9873
var miss = Planet.missChance(planet);
8184
9874
var me = (typeof Online !== 'undefined' && Online.mePlayer) ? Online.mePlayer() : null;
8185
if (me && me.planet && me.planet.id)
8186
{ planet = Planet.planetById(me.planet.id); }
8187
startPlay({ online: true, planet: planet, missChance: Planet.missChance(planet) });
9875
if (me && me.planet)
9876
{
9877
if (typeof Planet.rememberPlanet === 'function')
9878
{ planet = Planet.rememberPlanet(me.planet) || planet; }
9879
else if (me.planet.id)
9880
{ planet = Planet.planetById(me.planet.id); }
9881
if (typeof me.planet.miss_chance === 'number')
9882
{ miss = me.planet.miss_chance; }
9883
}
9884
startPlay({ online: true, planet: planet, missChance: miss });
8188
9885
if (typeof Online !== 'undefined')
8189
9886
{ Online.startPolling(onlinePayload); }
8190
9887
}
@@ -8562,19 +10259,22 @@ function renderPlanetGrid (containerId, compact)
8562
10259
var pl = all[i];
8563
10260
var btn = document.createElement('button');
8564
10261
btn.type = 'button';
8565
btn.className = 'planet-card' + (pl.id === current ? ' selected' : '');
10262
btn.className = 'planet-card' + (pl.id === current ? ' selected' : '')
10263
+ (pl.custom ? ' custom' : '');
8566
10264
btn.setAttribute('role', 'listitem');
8567
10265
btn.dataset.planet = pl.id;
8568
10266
var swatches = '';
8569
for (var c = 0; c < pl.colors.length; c++)
10267
var colors = pl.colors || [];
10268
for (var c = 0; c < colors.length; c++)
8570
10269
{
8571
swatches += '<img src="' + escapeText(pl.colors[c].image) + '" alt="'
8572
+ escapeText(pl.colors[c].name) + '" title="' + escapeText(pl.colors[c].name) + '">';
10270
swatches += '<img src="' + escapeText(colors[c].image) + '" alt="'
10271
+ escapeText(colors[c].name) + '" title="' + escapeText(colors[c].name) + '">';
8573
10272
}
8574
10273
btn.innerHTML = '<div class="planet-title">' + escapeText(pl.name) + '</div>'
8575
10274
+ '<div class="planet-people">' + escapeText(pl.people) + '</div>'
8576
10275
+ '<div class="planet-nums">' + escapeText(Planet.formatStats(pl)) + '</div>'
8577
+ '<div class="planet-swatches">' + swatches + '</div>';
10276
+ '<div class="planet-swatches">' + swatches + '</div>'
10277
+ (pl.custom ? '<span class="custom-badge">Eigen</span>' : '');
8578
10278
btn.addEventListener('click', (function (id, isCompact)
8579
10279
{
8580
10280
return function ()
@@ -8636,6 +10336,67 @@ function bindPlanetSelect ()
8636
10336
}
8637
10337
}
8638
10338
10339
10340
function refreshMenuAccount ()
10341
{
10342
var guest = document.getElementById('menu-guest');
10343
var user = document.getElementById('menu-user');
10344
var designerBtn = document.getElementById('btn-designer');
10345
var localLogin = document.getElementById('menu-local-login');
10346
var me = (typeof Online !== 'undefined') ? Online.me : null;
10347
if (me)
10348
{
10349
if (guest)
10350
{ guest.hidden = true; }
10351
if (user)
10352
{ user.hidden = false; }
10353
var name = document.getElementById('menu-name');
10354
if (name)
10355
{ name.textContent = me.name || me.id || 'speler'; }
10356
var pts = document.getElementById('menu-points');
10357
if (pts)
10358
{ pts.textContent = String((typeof Online !== 'undefined' && Online.lifetimePoints) || 0); }
10359
if (designerBtn)
10360
{ designerBtn.hidden = false; }
10361
}
10362
else
10363
{
10364
if (guest)
10365
{ guest.hidden = false; }
10366
if (user)
10367
{ user.hidden = true; }
10368
if (designerBtn)
10369
{ designerBtn.hidden = true; }
10370
}
10371
if (localLogin)
10372
{ localLogin.hidden = !(typeof Online !== 'undefined' && Online.local); }
10373
}
10374
10375
function beginPlaySession (mode)
10376
{
10377
if (app.playToken)
10378
{ finishPlaySession(app.core ? app.core.score : (app.lastScore || 0)); }
10379
app.playToken = null;
10380
if (typeof Online === 'undefined' || !Online.me || !Online.playBegin)
10381
{ return; }
10382
Online.playBegin(mode || 'solo').then(function (data)
10383
{
10384
if (data && data.ok && data.token)
10385
{ app.playToken = data.token; }
10386
});
10387
}
10388
10389
function finishPlaySession (score)
10390
{
10391
var token = app.playToken;
10392
app.playToken = null;
10393
if (!token || typeof Online === 'undefined' || !Online.playFinish)
10394
{ return; }
10395
Online.playFinish(token, score || 0).then(function ()
10396
{ refreshMenuAccount(); });
10397
}
10398
10399
8639
10400
/*
8640
10401
* End File:
8641
10402
* /workspace/meteors/src/main.js
@@ -187,6 +187,839 @@ var PLANET_CATALOG = {187
]187
]188
}188
}189
;189
;190
var BLOCK_REGISTRY = {191
"_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).",192
"terraCount": 5,193
"firstThreshold": 500,194
"thresholdGrowth": 1.145,195
"blocks": [196
{197
"id": "terra-ember",198
"name": "Ember",199
"hex": "#e85d3a",200
"shape": "triangle",201
"image": "images/block-terra-ember.png",202
"terra": true203
},204
{205
"id": "terra-aqua",206
"name": "Aqua",207
"hex": "#3db8e8",208
"shape": "circle",209
"image": "images/block-terra-aqua.png",210
"terra": true211
},212
{213
"id": "terra-leaf",214
"name": "Leaf",215
"hex": "#4cbf4c",216
"shape": "square",217
"image": "images/block-terra-leaf.png",218
"terra": true219
},220
{221
"id": "terra-sun",222
"name": "Sun",223
"hex": "#f0c53a",224
"shape": "diamond",225
"image": "images/block-terra-sun.png",226
"terra": true227
},228
{229
"id": "terra-orchid",230
"name": "Orchid",231
"hex": "#c45ad4",232
"shape": "star",233
"image": "images/block-terra-orchid.png",234
"terra": true235
},236
{237
"id": "rune-fehu",238
"name": "Fehu",239
"hex": "#e8a44a",240
"shape": "rune_fehu",241
"image": "images/block-rune-fehu.png",242
"terra": false243
},244
{245
"id": "rune-ansuz",246
"name": "Ansuz",247
"hex": "#6ab0e8",248
"shape": "rune_ansuz",249
"image": "images/block-rune-ansuz.png",250
"terra": false251
},252
{253
"id": "rune-thurisaz",254
"name": "Thurisaz",255
"hex": "#c05040",256
"shape": "rune_thurisaz",257
"image": "images/block-rune-thurisaz.png",258
"terra": false259
},260
{261
"id": "rune-raido",262
"name": "Raido",263
"hex": "#d0c070",264
"shape": "rune_raido",265
"image": "images/block-rune-raido.png",266
"terra": false267
},268
{269
"id": "rune-sowilo",270
"name": "Sowilo",271
"hex": "#f0d040",272
"shape": "rune_sowilo",273
"image": "images/block-rune-sowilo.png",274
"terra": false275
},276
{277
"id": "rune-algiz",278
"name": "Algiz",279
"hex": "#80d0a0",280
"shape": "rune_algiz",281
"image": "images/block-rune-algiz.png",282
"terra": false283
},284
{285
"id": "arrow-up",286
"name": "Arrow",287
"hex": "#f07040",288
"shape": "arrow",289
"image": "images/block-arrow-up.png",290
"terra": false291
},292
{293
"id": "arrow-chevron",294
"name": "Chevron",295
"hex": "#50c0e0",296
"shape": "chevron",297
"image": "images/block-arrow-chevron.png",298
"terra": false299
},300
{301
"id": "arrow-double",302
"name": "Double Arrow",303
"hex": "#e05080",304
"shape": "double_arrow",305
"image": "images/block-arrow-double.png",306
"terra": false307
},308
{309
"id": "arrow-return",310
"name": "Return",311
"hex": "#a080e0",312
"shape": "return_arrow",313
"image": "images/block-arrow-return.png",314
"terra": false315
},316
{317
"id": "fig-person",318
"name": "Figure",319
"hex": "#f0c0a0",320
"shape": "person",321
"image": "images/block-fig-person.png",322
"terra": false323
},324
{325
"id": "fig-walker",326
"name": "Walker",327
"hex": "#c09070",328
"shape": "walker",329
"image": "images/block-fig-walker.png",330
"terra": false331
},332
{333
"id": "fig-hero",334
"name": "Hero",335
"hex": "#e8b070",336
"shape": "hero",337
"image": "images/block-fig-hero.png",338
"terra": false339
},340
{341
"id": "face-smile",342
"name": "Smile",343
"hex": "#f0d060",344
"shape": "smile",345
"image": "images/block-face-smile.png",346
"terra": false347
},348
{349
"id": "face-wink",350
"name": "Wink",351
"hex": "#f0a050",352
"shape": "wink",353
"image": "images/block-face-wink.png",354
"terra": false355
},356
{357
"id": "face-cool",358
"name": "Cool",359
"hex": "#6090d0",360
"shape": "cool",361
"image": "images/block-face-cool.png",362
"terra": false363
},364
{365
"id": "face-grin",366
"name": "Grin",367
"hex": "#f0c848",368
"shape": "grin",369
"image": "images/block-face-grin.png",370
"terra": false371
},372
{373
"id": "icon-heart",374
"name": "Heart",375
"hex": "#e04060",376
"shape": "heart",377
"image": "images/block-icon-heart.png",378
"terra": false379
},380
{381
"id": "icon-moon",382
"name": "Moon",383
"hex": "#d0d8f0",384
"shape": "crescent",385
"image": "images/block-icon-moon.png",386
"terra": false387
},388
{389
"id": "icon-bolt",390
"name": "Bolt",391
"hex": "#f0e050",392
"shape": "lightning",393
"image": "images/block-icon-bolt.png",394
"terra": false395
},396
{397
"id": "icon-shield",398
"name": "Shield",399
"hex": "#5080c0",400
"shape": "shield",401
"image": "images/block-icon-shield.png",402
"terra": false403
},404
{405
"id": "icon-crown",406
"name": "Crown",407
"hex": "#f0c030",408
"shape": "crown",409
"image": "images/block-icon-crown.png",410
"terra": false411
},412
{413
"id": "icon-eye",414
"name": "Eye",415
"hex": "#70d0c0",416
"shape": "eye",417
"image": "images/block-icon-eye.png",418
"terra": false419
},420
{421
"id": "icon-star6",422
"name": "Hexastar",423
"hex": "#f0e8a0",424
"shape": "star6",425
"image": "images/block-icon-star6.png",426
"terra": false427
},428
{429
"id": "icon-spiral",430
"name": "Spiral",431
"hex": "#c070d0",432
"shape": "spiral",433
"image": "images/block-icon-spiral.png",434
"terra": false435
},436
{437
"id": "icon-wave",438
"name": "Wave",439
"hex": "#3090d0",440
"shape": "wave",441
"image": "images/block-icon-wave.png",442
"terra": false443
},444
{445
"id": "icon-mountain",446
"name": "Mountain",447
"hex": "#809070",448
"shape": "mountain",449
"image": "images/block-icon-mountain.png",450
"terra": false451
},452
{453
"id": "icon-fish",454
"name": "Fish",455
"hex": "#40a8c8",456
"shape": "fish",457
"image": "images/block-icon-fish.png",458
"terra": false459
},460
{461
"id": "icon-bird",462
"name": "Bird",463
"hex": "#e07050",464
"shape": "bird",465
"image": "images/block-icon-bird.png",466
"terra": false467
},468
{469
"id": "icon-key",470
"name": "Key",471
"hex": "#d0b050",472
"shape": "key",473
"image": "images/block-icon-key.png",474
"terra": false475
},476
{477
"id": "icon-comet",478
"name": "Comet",479
"hex": "#90d0f0",480
"shape": "comet",481
"image": "images/block-icon-comet.png",482
"terra": false483
},484
{485
"id": "icon-clover",486
"name": "Clover",487
"hex": "#40b060",488
"shape": "clover",489
"image": "images/block-icon-clover.png",490
"terra": false491
},492
{493
"id": "icon-paw",494
"name": "Paw",495
"hex": "#c08050",496
"shape": "paw",497
"image": "images/block-icon-paw.png",498
"terra": false499
},500
{501
"id": "icon-sword",502
"name": "Sword",503
"hex": "#b0b8c0",504
"shape": "sword",505
"image": "images/block-icon-sword.png",506
"terra": false507
},508
{509
"id": "icon-bell",510
"name": "Bell",511
"hex": "#f0c848",512
"shape": "bell",513
"image": "images/block-icon-bell.png",514
"terra": false515
},516
{517
"id": "icon-mushroom",518
"name": "Mushroom",519
"hex": "#e06050",520
"shape": "mushroom",521
"image": "images/block-icon-mushroom.png",522
"terra": false523
},524
{525
"id": "icon-cactus",526
"name": "Cactus",527
"hex": "#50b068",528
"shape": "cactus",529
"image": "images/block-icon-cactus.png",530
"terra": false531
},532
{533
"id": "icon-ring",534
"name": "Ring",535
"hex": "#e8d080",536
"shape": "ring",537
"image": "images/block-icon-ring.png",538
"terra": false539
},540
{541
"id": "icon-flag",542
"name": "Flag",543
"hex": "#d04050",544
"shape": "flag",545
"image": "images/block-icon-flag.png",546
"terra": false547
},548
{549
"id": "icon-snow",550
"name": "Snowflake",551
"hex": "#c8e0f8",552
"shape": "snowflake",553
"image": "images/block-icon-snow.png",554
"terra": false555
},556
{557
"id": "icon-flame",558
"name": "Flame",559
"hex": "#ff7030",560
"shape": "flame_icon",561
"image": "images/block-icon-flame.png",562
"terra": false563
},564
{565
"id": "icon-ankh",566
"name": "Ankh",567
"hex": "#d0a060",568
"shape": "ankh",569
"image": "images/block-icon-ankh.png",570
"terra": false571
},572
{573
"id": "icon-yin",574
"name": "Yin Yang",575
"hex": "#606080",576
"shape": "yinyang",577
"image": "images/block-icon-yin.png",578
"terra": false579
},580
{581
"id": "aurel-gold",582
"name": "Aurel gold",583
"hex": "#f4c860",584
"shape": "hexagon",585
"image": "images/block-aurel-gold.png",586
"terra": false587
},588
{589
"id": "aurel-cream",590
"name": "Aurel cream",591
"hex": "#f6e7c1",592
"shape": "circle",593
"image": "images/block-aurel-cream.png",594
"terra": false595
},596
{597
"id": "aurel-amber",598
"name": "Aurel amber",599
"hex": "#e09a3e",600
"shape": "teardrop",601
"image": "images/block-aurel-amber.png",602
"terra": false603
},604
{605
"id": "aurel-sage",606
"name": "Aurel sage",607
"hex": "#8fb86f",608
"shape": "plus",609
"image": "images/block-aurel-sage.png",610
"terra": false611
},612
{613
"id": "aurel-rose",614
"name": "Aurel rose",615
"hex": "#e8a0a8",616
"shape": "pentagon",617
"image": "images/block-aurel-rose.png",618
"terra": false619
},620
{621
"id": "cinder-magma",622
"name": "Cinder magma",623
"hex": "#ff3b1f",624
"shape": "triangle",625
"image": "images/block-cinder-magma.png",626
"terra": false627
},628
{629
"id": "cinder-coal",630
"name": "Cinder coal",631
"hex": "#3a3232",632
"shape": "square",633
"image": "images/block-cinder-coal.png",634
"terra": false635
},636
{637
"id": "cinder-spark",638
"name": "Cinder spark",639
"hex": "#ffb347",640
"shape": "diamond",641
"image": "images/block-cinder-spark.png",642
"terra": false643
},644
{645
"id": "cinder-ash",646
"name": "Cinder ash",647
"hex": "#8a7a76",648
"shape": "circle",649
"image": "images/block-cinder-ash.png",650
"terra": false651
},652
{653
"id": "cinder-core",654
"name": "Cinder core",655
"hex": "#ff6a00",656
"shape": "star",657
"image": "images/block-cinder-core.png",658
"terra": false659
},660
{661
"id": "lunara-silver",662
"name": "Lunara silver",663
"hex": "#c5d0e0",664
"shape": "circle",665
"image": "images/block-lunara-silver.png",666
"terra": false667
},668
{669
"id": "lunara-dust",670
"name": "Lunara dust",671
"hex": "#8b90a0",672
"shape": "diamond",673
"image": "images/block-lunara-dust.png",674
"terra": false675
},676
{677
"id": "lunara-pale",678
"name": "Lunara pale",679
"hex": "#e8d9a8",680
"shape": "crescent",681
"image": "images/block-lunara-pale.png",682
"terra": false683
},684
{685
"id": "lunara-void",686
"name": "Lunara void",687
"hex": "#2c3348",688
"shape": "square",689
"image": "images/block-lunara-void.png",690
"terra": false691
},692
{693
"id": "lunara-lilac",694
"name": "Lunara lilac",695
"hex": "#b9a4d4",696
"shape": "star",697
"image": "images/block-lunara-lilac.png",698
"terra": false699
},700
{701
"id": "mire-moss",702
"name": "Mire moss",703
"hex": "#3d7a45",704
"shape": "hexagon",705
"image": "images/block-mire-moss.png",706
"terra": false707
},708
{709
"id": "mire-bog",710
"name": "Mire bog",711
"hex": "#1f4d3a",712
"shape": "teardrop",713
"image": "images/block-mire-bog.png",714
"terra": false715
},716
{717
"id": "mire-rust",718
"name": "Mire rust",719
"hex": "#8b5a2b",720
"shape": "pentagon",721
"image": "images/block-mire-rust.png",722
"terra": false723
},724
{725
"id": "mire-spore",726
"name": "Mire spore",727
"hex": "#9cbf5a",728
"shape": "circle",729
"image": "images/block-mire-spore.png",730
"terra": false731
},732
{733
"id": "mire-murk",734
"name": "Mire murk",735
"hex": "#2e3b2f",736
"shape": "diamond",737
"image": "images/block-mire-murk.png",738
"terra": false739
},740
{741
"id": "galeon-sky",742
"name": "Galeon sky",743
"hex": "#4aa3ff",744
"shape": "arrow",745
"image": "images/block-galeon-sky.png",746
"terra": false747
},748
{749
"id": "galeon-cloud",750
"name": "Galeon cloud",751
"hex": "#e8eef6",752
"shape": "circle",753
"image": "images/block-galeon-cloud.png",754
"terra": false755
},756
{757
"id": "galeon-storm",758
"name": "Galeon storm",759
"hex": "#3d4d6e",760
"shape": "square",761
"image": "images/block-galeon-storm.png",762
"terra": false763
},764
{765
"id": "galeon-sand",766
"name": "Galeon sand",767
"hex": "#d4b483",768
"shape": "diamond",769
"image": "images/block-galeon-sand.png",770
"terra": false771
},772
{773
"id": "galeon-kite",774
"name": "Galeon kite",775
"hex": "#7fd0c0",776
"shape": "star",777
"image": "images/block-galeon-kite.png",778
"terra": false779
},780
{781
"id": "obsid-glass",782
"name": "Obsid glass",783
"hex": "#1a1a22",784
"shape": "gem",785
"image": "images/block-obsid-glass.png",786
"terra": false787
},788
{789
"id": "obsid-violet",790
"name": "Obsid violet",791
"hex": "#5a3d8a",792
"shape": "hexagon",793
"image": "images/block-obsid-violet.png",794
"terra": false795
},796
{797
"id": "obsid-shard",798
"name": "Obsid shard",799
"hex": "#8a8aa0",800
"shape": "triangle",801
"image": "images/block-obsid-shard.png",802
"terra": false803
},804
{805
"id": "obsid-vein",806
"name": "Obsid vein",807
"hex": "#c45a3a",808
"shape": "diamond",809
"image": "images/block-obsid-vein.png",810
"terra": false811
},812
{813
"id": "obsid-basalt",814
"name": "Obsid basalt",815
"hex": "#3a3a42",816
"shape": "square",817
"image": "images/block-obsid-basalt.png",818
"terra": false819
},820
{821
"id": "wisp-glow",822
"name": "Wisp glow",823
"hex": "#c8ffe0",824
"shape": "circle",825
"image": "images/block-wisp-glow.png",826
"terra": false827
},828
{829
"id": "wisp-mist",830
"name": "Wisp mist",831
"hex": "#a8d4e8",832
"shape": "diamond",833
"image": "images/block-wisp-mist.png",834
"terra": false835
},836
{837
"id": "wisp-sparkle",838
"name": "Wisp sparkle",839
"hex": "#fff6a8",840
"shape": "star",841
"image": "images/block-wisp-sparkle.png",842
"terra": false843
},844
{845
"id": "wisp-veil",846
"name": "Wisp veil",847
"hex": "#d0b8f0",848
"shape": "teardrop",849
"image": "images/block-wisp-veil.png",850
"terra": false851
},852
{853
"id": "wisp-gleam",854
"name": "Wisp gleam",855
"hex": "#f4f7ff",856
"shape": "plus",857
"image": "images/block-wisp-gleam.png",858
"terra": false859
},860
{861
"id": "thorn-briar",862
"name": "Thorn briar",863
"hex": "#5a7a30",864
"shape": "triangle",865
"image": "images/block-thorn-briar.png",866
"terra": false867
},868
{869
"id": "thorn-berry",870
"name": "Thorn berry",871
"hex": "#8b1a4a",872
"shape": "circle",873
"image": "images/block-thorn-berry.png",874
"terra": false875
},876
{877
"id": "thorn-bark",878
"name": "Thorn bark",879
"hex": "#5a3a20",880
"shape": "square",881
"image": "images/block-thorn-bark.png",882
"terra": false883
},884
{885
"id": "thorn-petal",886
"name": "Thorn petal",887
"hex": "#e89ab0",888
"shape": "diamond",889
"image": "images/block-thorn-petal.png",890
"terra": false891
},892
{893
"id": "thorn-gold",894
"name": "Thorn gold",895
"hex": "#c8a030",896
"shape": "star",897
"image": "images/block-thorn-gold.png",898
"terra": false899
},900
{901
"id": "zephyr-azure",902
"name": "Zephyr azure",903
"hex": "#6ec8ff",904
"shape": "crescent",905
"image": "images/block-zephyr-azure.png",906
"terra": false907
},908
{909
"id": "zephyr-breeze",910
"name": "Zephyr breeze",911
"hex": "#b8e8ff",912
"shape": "circle",913
"image": "images/block-zephyr-breeze.png",914
"terra": false915
},916
{917
"id": "zephyr-cirrus",918
"name": "Zephyr cirrus",919
"hex": "#f0f7ff",920
"shape": "plus",921
"image": "images/block-zephyr-cirrus.png",922
"terra": false923
},924
{925
"id": "zephyr-dusk",926
"name": "Zephyr dusk",927
"hex": "#7a6ab0",928
"shape": "diamond",929
"image": "images/block-zephyr-dusk.png",930
"terra": false931
},932
{933
"id": "zephyr-haze",934
"name": "Zephyr haze",935
"hex": "#ffe08a",936
"shape": "star",937
"image": "images/block-zephyr-haze.png",938
"terra": false939
},940
{941
"id": "frore-ice",942
"name": "Frore ice",943
"hex": "#a8d8f0",944
"shape": "hexagon",945
"image": "images/block-frore-ice.png",946
"terra": false947
},948
{949
"id": "frore-frost",950
"name": "Frore frost",951
"hex": "#eef7ff",952
"shape": "circle",953
"image": "images/block-frore-frost.png",954
"terra": false955
},956
{957
"id": "frore-deep",958
"name": "Frore deep",959
"hex": "#3a6a8a",960
"shape": "diamond",961
"image": "images/block-frore-deep.png",962
"terra": false963
},964
{965
"id": "frore-aurora",966
"name": "Frore aurora",967
"hex": "#5ae8c0",968
"shape": "star",969
"image": "images/block-frore-aurora.png",970
"terra": false971
},972
{973
"id": "frore-rime",974
"name": "Frore rime",975
"hex": "#d0e4f0",976
"shape": "triangle",977
"image": "images/block-frore-rime.png",978
"terra": false979
},980
{981
"id": "forge-iron",982
"name": "Forge iron",983
"hex": "#6a6a72",984
"shape": "square",985
"image": "images/block-forge-iron.png",986
"terra": false987
},988
{989
"id": "forge-slag",990
"name": "Forge slag",991
"hex": "#3a3028",992
"shape": "hexagon",993
"image": "images/block-forge-slag.png",994
"terra": false995
},996
{997
"id": "forge-spark",998
"name": "Forge spark",999
"hex": "#ff7a1a",1000
"shape": "triangle",1001
"image": "images/block-forge-spark.png",1002
"terra": false1003
},1004
{1005
"id": "forge-brass",1006
"name": "Forge brass",1007
"hex": "#c8a048",1008
"shape": "diamond",1009
"image": "images/block-forge-brass.png",1010
"terra": false1011
},1012
{1013
"id": "forge-soot",1014
"name": "Forge soot",1015
"hex": "#2a2a28",1016
"shape": "circle",1017
"image": "images/block-forge-soot.png",1018
"terra": false1019
}1020
]1021
}1022
;190
1023
191
/*1024
/*192
* Start File:1025
* Start File:@@ -353,6 +1186,34 @@ function loadCatalog ()353
return { planets: [] };1186
return { planets: [] };354
}1187
}355
1188
1189
/** Player-owned custom planets (from the profile) and any remembered1190
* snapshots (opponents in a lobby), not part of the official catalog. */1191
var _customPlanets = [];1192
var _remembered = Object.create(null);1193
1194
function setCustomPlanets (list)1195
{1196
_customPlanets = [];1197
if (!list || !list.length)1198
{ return; }1199
for (var i = 0; i < list.length; i++)1200
{ _customPlanets.push(planetFromData(list[i])); }1201
}1202
1203
function rememberPlanet (data)1204
{1205
if (!data || !data.id)1206
{ return null; }1207
var pl = planetFromData(data);1208
_remembered[pl.id] = pl;1209
return pl;1210
}1211
1212
function forgetRemembered ()1213
{1214
_remembered = Object.create(null);1215
}1216
356
function planetFromData (data)1217
function planetFromData (data)357
{1218
{358
var planet = createPlanet({1219
var planet = createPlanet({@@ -364,6 +1225,10 @@ function planetFromData (data)364
colors: data.colors1225
colors: data.colors365
});1226
});366
planet.id = data.id;1227
planet.id = data.id;1228
if (data.custom)1229
{ planet.custom = true; }1230
if (data.owner_id)1231
{ planet.owner_id = data.owner_id; }367
return planet;1232
return planet;368
}1233
}369
1234
@@ -375,6 +1240,8 @@ function allPlanets ()375
{ out.push(planetFromData(raw[i])); }1240
{ out.push(planetFromData(raw[i])); }376
if (out.length === 0)1241
if (out.length === 0)377
{ out.push(createPlanet({ name: 'Terra', people: 'Terrans', jumpsToClear: 2, fallTime: 3, riseTime: 1.5 })); out[0].id = 'terra'; }1242
{ out.push(createPlanet({ name: 'Terra', people: 'Terrans', jumpsToClear: 2, fallTime: 3, riseTime: 1.5 })); out[0].id = 'terra'; }1243
for (var c = 0; c < _customPlanets.length; c++)1244
{ out.push(_customPlanets[c]); }378
return out;1245
return out;379
}1246
}380
1247
@@ -386,9 +1253,30 @@ function planetById (id)386
if (all[i].id === id)1253
if (all[i].id === id)387
{ return all[i]; }1254
{ return all[i]; }388
}1255
}1256
if (id && _remembered[id])1257
{ return _remembered[id]; }389
return defaultPlanet();1258
return defaultPlanet();390
}1259
}391
1260
1261
function officialPlanets ()1262
{1263
var raw = loadCatalog().planets || [];1264
var out = [];1265
for (var i = 0; i < raw.length; i++)1266
{ out.push(planetFromData(raw[i])); }1267
return out;1268
}1269
1270
function customPlanets ()1271
{1272
return _customPlanets.slice();1273
}1274
1275
function pickerPlanets ()1276
{1277
return officialPlanets().concat(_customPlanets);1278
}1279
392
function defaultPlanet ()1280
function defaultPlanet ()393
{1281
{394
var all = allPlanets();1282
var all = allPlanets();@@ -415,6 +1303,11 @@ function spriteKey (planet, colorIndex)415
var c = colors && colors[colorIndex];1303
var c = colors && colors[colorIndex];416
if (!c)1304
if (!c)417
{ return 'gray'; }1305
{ return 'gray'; }1306
// Custom planets (and any color that names a registry block) share1307
// the preloaded Blocks.images() sprite, so late-loaded customs and1308
// opponent snapshots do not need a second preload.1309
if (c.block)1310
{ return 'block:' + c.block; }418
return (planet.id || 'planet') + '-' + (c.name || String(colorIndex));1311
return (planet.id || 'planet') + '-' + (c.name || String(colorIndex));419
}1312
}420
1313
@@ -512,6 +1405,12 @@ var Planet = {512
defaultPlanet: defaultPlanet,1405
defaultPlanet: defaultPlanet,513
defaultColors: defaultColors,1406
defaultColors: defaultColors,514
allPlanets: allPlanets,1407
allPlanets: allPlanets,1408
officialPlanets: officialPlanets,1409
customPlanets: customPlanets,1410
pickerPlanets: pickerPlanets,1411
setCustomPlanets: setCustomPlanets,1412
rememberPlanet: rememberPlanet,1413
forgetRemembered: forgetRemembered,515
planetById: planetById,1414
planetById: planetById,516
planetFromData: planetFromData,1415
planetFromData: planetFromData,517
formatStats: formatStats,1416
formatStats: formatStats,@@ -528,13 +1427,183 @@ var Planet = {528
};1427
};529
1428
530
if (typeof module !== 'undefined' && module.exports)1429
if (typeof module !== 'undefined' && module.exports)531
{ module.exports = Planet; }1430
{ module.exports = Planet; }1431
else if (typeof globalThis !== 'undefined')1432
{ globalThis.Planet = Planet; }1433
1434
/*1435
* End File:1436
* /workspace/meteors/src/planet.js1437
*/ 1438
1439
/*1440
* Start File:1441
* /workspace/meteors/src/blocks.js1442
*/ 1443
'use strict';1444
1445
/**1446
* Append-only block registry. Thresholds and order stay in lockstep with1447
* server/lib/Blocks.php: Terra's first five are free; the next costs 5001448
* lifetime points; each one after that costs 14.5% more (rounded, always1449
* strictly increasing). Points are a requirement, not a spend.1450
*/1451
1452
var Blocks = (function ()1453
{1454
var TERRA_COUNT = 5;1455
var FIRST_THRESHOLD = 500;1456
var GROWTH = 1.145;1457
var _all = null;1458
1459
function loadRegistry ()1460
{1461
if (_all)1462
{ return _all; }1463
var data = null;1464
if (typeof BLOCK_REGISTRY !== 'undefined' && BLOCK_REGISTRY && BLOCK_REGISTRY.blocks)1465
{ data = BLOCK_REGISTRY; }1466
else if (typeof require !== 'undefined')1467
{1468
try1469
{ data = require('../server/lib/blocks.json'); }1470
catch (e) { data = null; }1471
}1472
_all = (data && data.blocks) ? data.blocks.slice() : [];1473
return _all;1474
}1475
1476
function all ()1477
{1478
return loadRegistry();1479
}1480
1481
function byId (id)1482
{1483
var list = all();1484
for (var i = 0; i < list.length; i++)1485
{1486
if (list[i].id === id)1487
{ return list[i]; }1488
}1489
return null;1490
}1491
1492
function indexOf (id)1493
{1494
var list = all();1495
for (var i = 0; i < list.length; i++)1496
{1497
if (list[i].id === id)1498
{ return i; }1499
}1500
return -1;1501
}1502
1503
function threshold (index)1504
{1505
if (index < TERRA_COUNT)1506
{ return 0; }1507
var t = FIRST_THRESHOLD;1508
for (var i = TERRA_COUNT; i < index; i++)1509
{1510
var next = Math.round(t * GROWTH);1511
t = Math.max(t + 1, next);1512
}1513
return t;1514
}1515
1516
function unlocked (index, points)1517
{1518
points = points || 0;1519
return points >= threshold(index);1520
}1521
1522
function unlockedId (id, points)1523
{1524
var i = indexOf(id);1525
return i >= 0 && unlocked(i, points);1526
}1527
1528
function present (points)1529
{1530
points = points || 0;1531
var list = all();1532
var out = [];1533
for (var i = 0; i < list.length; i++)1534
{1535
var b = list[i];1536
var need = threshold(i);1537
out.push({1538
id: b.id,1539
name: b.name || b.id,1540
hex: b.hex,1541
shape: b.shape,1542
image: b.image,1543
terra: !!b.terra || i < TERRA_COUNT,1544
index: i,1545
threshold: need,1546
unlocked: points >= need1547
});1548
}1549
return out;1550
}1551
1552
function asColor (id, slot)1553
{1554
var b = byId(id);1555
if (!b)1556
{ return null; }1557
return {1558
id: slot,1559
block: b.id,1560
name: b.name || b.id,1561
hex: b.hex,1562
shape: b.shape,1563
image: b.image1564
};1565
}1566
1567
function images ()1568
{1569
var list = all();1570
var out = [];1571
var seen = Object.create(null);1572
for (var i = 0; i < list.length; i++)1573
{1574
var url = list[i].image;1575
if (!url || seen[url])1576
{ continue; }1577
seen[url] = true;1578
out.push({ name: 'block:' + list[i].id, url: url });1579
}1580
return out;1581
}1582
1583
return {1584
TERRA_COUNT: TERRA_COUNT,1585
FIRST_THRESHOLD: FIRST_THRESHOLD,1586
GROWTH: GROWTH,1587
all: all,1588
byId: byId,1589
indexOf: indexOf,1590
threshold: threshold,1591
unlocked: unlocked,1592
unlockedId: unlockedId,1593
present: present,1594
asColor: asColor,1595
images: images1596
};1597
})();1598
1599
if (typeof module !== 'undefined' && module.exports)1600
{ module.exports = Blocks; }532
else if (typeof globalThis !== 'undefined')1601
else if (typeof globalThis !== 'undefined')533
{ globalThis.Planet = Planet; }1602
{ globalThis.Blocks = Blocks; }534
1603
535
/*1604
/*536
* End File:1605
* End File:537
* /workspace/meteors/src/planet.js1606
* /workspace/meteors/src/blocks.js538
*/ 1607
*/ 539
1608
540
/*1609
/*@@ -4074,6 +5143,10 @@ var Online = {4074
local: false,5143
local: false,4075
csrf: '',5144
csrf: '',4076
me: null,5145
me: null,5146
lifetimePoints: 0,5147
locale: null,5148
blocks: [],5149
planets: [],4077
lobby: null,5150
lobby: null,4078
incoming: [],5151
incoming: [],4079
shotResults: [],5152
shotResults: [],@@ -4125,6 +5198,26 @@ Online._apply = function (data)4125
{ this.error = data.error; }5198
{ this.error = data.error; }4126
else if (data.ok)5199
else if (data.ok)4127
{ this.error = ''; }5200
{ this.error = ''; }5201
if (data.lifetime_points != null)5202
{ this.lifetimePoints = data.lifetime_points; }5203
if (data.locale !== undefined)5204
{ this.locale = data.locale; }5205
if (data.blocks)5206
{ this.blocks = data.blocks; }5207
if (data.planets)5208
{5209
this.planets = data.planets;5210
if (typeof Planet !== 'undefined' && Planet.setCustomPlanets)5211
{ Planet.setCustomPlanets(data.planets); }5212
}5213
if (data.lobby && data.lobby.players && typeof Planet !== 'undefined' && Planet.rememberPlanet)5214
{5215
for (var i = 0; i < data.lobby.players.length; i++)5216
{5217
if (data.lobby.players[i].planet)5218
{ Planet.rememberPlanet(data.lobby.players[i].planet); }5219
}5220
}4128
};5221
};4129
5222
4130
Online.request = function (action, body)5223
Online.request = function (action, body)@@ -4196,6 +5289,31 @@ Online.setPlanet = function (planetId)4196
return this.request('lobby_set_planet', { planet_id: planetId });5289
return this.request('lobby_set_planet', { planet_id: planetId });4197
};5290
};4198
5291
5292
Online.playBegin = function (mode)5293
{5294
return this.request('play_begin', { mode: mode || 'solo' });5295
};5296
5297
Online.playFinish = function (token, score)5298
{5299
return this.request('play_finish', { token: token, score: score || 0 });5300
};5301
5302
Online.savePlanet = function (planet)5303
{5304
return this.request('planet_save', { planet: planet });5305
};5306
5307
Online.deletePlanet = function (id)5308
{5309
return this.request('planet_delete', { id: id });5310
};5311
5312
Online.setLocale = function (locale)5313
{5314
return this.request('set_locale', { locale: locale });5315
};5316
4199
Online.leaveLobby = function ()5317
Online.leaveLobby = function ()4200
{5318
{4201
return this.request('lobby_leave');5319
return this.request('lobby_leave');@@ -6444,6 +7562,545 @@ if (typeof module !== 'undefined' && module.exports && typeof Offline !== 'undef6444
* /workspace/meteors/src/offline.js7562
* /workspace/meteors/src/offline.js6445
*/ 7563
*/ 6446
7564
7565
/*7566
* Start File:7567
* /workspace/meteors/src/designer.js7568
*/ 7569
'use strict';7570
7571
/**7572
* Planeetontwerper (t1139). Only available on the main menu when the7573
* player is logged in. Talks to api.php through Online.7574
*/7575
var Designer = {7576
openSlot: 0,7577
editingId: null,7578
slots: [null, null, null, null, null],7579
dirty: false7580
};7581
7582
Designer._blocks = function ()7583
{7584
if (typeof Blocks !== 'undefined')7585
{ return Blocks; }7586
if (typeof require !== 'undefined')7587
{7588
try7589
{ return require('./blocks.js'); }7590
catch (e)7591
{ return null; }7592
}7593
return null;7594
};7595
7596
Designer.defaultSlots = function ()7597
{7598
var B = Designer._blocks();7599
var all = B ? B.all() : [];7600
var ids = [];7601
for (var i = 0; i < 5 && i < all.length; i++)7602
{ ids.push(all[i].id); }7603
return ids;7604
};7605
7606
Designer.points = function ()7607
{7608
return (typeof Online !== 'undefined' && Online.lifetimePoints) || 0;7609
};7610
7611
Designer.blocks = function ()7612
{7613
if (typeof Online !== 'undefined' && Online.blocks && Online.blocks.length)7614
{ return Online.blocks; }7615
var B = Designer._blocks();7616
if (B)7617
{ return B.present(Designer.points()); }7618
return [];7619
};7620
7621
Designer.planets = function ()7622
{7623
if (typeof Planet !== 'undefined' && Planet.customPlanets)7624
{ return Planet.customPlanets(); }7625
return (typeof Online !== 'undefined' && Online.planets) || [];7626
};7627
7628
Designer.openList = function ()7629
{7630
if (typeof Online === 'undefined' || !Online.me)7631
{ return; }7632
if (typeof app !== 'undefined')7633
{ app.mode = 'designer'; }7634
hideIf('menu');7635
hideIf('planet-select');7636
hideIf('online-panel');7637
hideIf('designer-edit');7638
showIf('designer');7639
Designer.renderList();7640
};7641
7642
Designer.close = function ()7643
{7644
hideIf('designer');7645
hideIf('designer-edit');7646
Designer.closeModal();7647
if (typeof app !== 'undefined')7648
{ app.mode = 'menu'; }7649
showIf('menu');7650
if (typeof refreshMenuAccount === 'function')7651
{ refreshMenuAccount(); }7652
if (typeof renderPlanetGrid === 'function')7653
{7654
renderPlanetGrid('planet-grid', false);7655
renderPlanetGrid('lobby-planet-grid', true);7656
}7657
};7658
7659
Designer.renderList = function ()7660
{7661
var box = document.getElementById('designer-list');7662
var pts = document.getElementById('designer-points');7663
if (pts)7664
{ pts.textContent = String(Designer.points()); }7665
if (!box)7666
{ return; }7667
box.innerHTML = '';7668
var planets = Designer.planets();7669
if (!planets.length)7670
{7671
var empty = document.createElement('p');7672
empty.className = 'hint';7673
empty.textContent = 'Je hebt nog geen eigen planeten. Maak er een aan.';7674
box.appendChild(empty);7675
return;7676
}7677
for (var i = 0; i < planets.length; i++)7678
{7679
var pl = planets[i];7680
if (typeof Planet !== 'undefined' && Planet.planetFromData && !pl.baseJumpHeight)7681
{ pl = Planet.planetFromData(pl); }7682
var card = document.createElement('div');7683
card.className = 'planet-card designer-card';7684
var swatches = '';7685
var colors = pl.colors || [];7686
for (var c = 0; c < colors.length; c++)7687
{7688
swatches += '<img src="' + Designer.esc(colors[c].image) + '" alt="'7689
+ Designer.esc(colors[c].name) + '">';7690
}7691
var stats = (typeof Planet !== 'undefined' && Planet.formatStats)7692
? Planet.formatStats(pl) : '';7693
card.innerHTML = '<div class="planet-title">' + Designer.esc(pl.name) + '</div>'7694
+ '<div class="planet-people">' + Designer.esc(pl.people) + '</div>'7695
+ '<div class="planet-nums">' + Designer.esc(stats) + '</div>'7696
+ '<div class="planet-swatches">' + swatches + '</div>'7697
+ '<div class="designer-card-actions">'7698
+ '<button type="button" class="btn-tiny" data-edit>Bewerken</button>'7699
+ '<button type="button" class="btn-tiny btn-danger-lite" data-del>Verwijderen</button>'7700
+ '</div>';7701
(function (id)7702
{7703
card.querySelector('[data-edit]').addEventListener('click', function ()7704
{ Designer.openEdit(id); });7705
card.querySelector('[data-del]').addEventListener('click', function ()7706
{ Designer.confirmDelete(id); });7707
})(pl.id);7708
box.appendChild(card);7709
}7710
};7711
7712
Designer.confirmDelete = function (id)7713
{7714
var pl = Designer.planetById(id);7715
var name = pl ? pl.name : id;7716
if (!window.confirm('Wil je de planeet “' + name + '” verwijderen?'))7717
{ return; }7718
Online.deletePlanet(id).then(function (data)7719
{7720
if (!data || !data.ok)7721
{7722
window.alert((data && data.error) || 'Verwijderen is mislukt.');7723
return;7724
}7725
Designer.renderList();7726
if (typeof renderPlanetGrid === 'function')7727
{7728
renderPlanetGrid('planet-grid', false);7729
renderPlanetGrid('lobby-planet-grid', true);7730
}7731
});7732
};7733
7734
Designer.planetById = function (id)7735
{7736
var list = Designer.planets();7737
for (var i = 0; i < list.length; i++)7738
{7739
if (list[i].id === id)7740
{ return list[i]; }7741
}7742
return null;7743
};7744
7745
Designer.openEdit = function (id)7746
{7747
var pl = id ? Designer.planetById(id) : null;7748
Designer.editingId = pl ? pl.id : null;7749
if (pl)7750
{7751
Designer.slots = [];7752
for (var i = 0; i < 5; i++)7753
{7754
var c = pl.colors && pl.colors[i];7755
Designer.slots[i] = c ? (c.block || c.id) : Designer.defaultSlots()[i];7756
// c.id is the slot index 0-4 on snapshots; prefer c.block7757
if (c && c.block)7758
{ Designer.slots[i] = c.block; }7759
else if (c && typeof c.id === 'string')7760
{ Designer.slots[i] = c.id; }7761
}7762
document.getElementById('des-name').value = pl.name || '';7763
document.getElementById('des-people').value = pl.people || '';7764
document.getElementById('des-gravity').value = String(pl.jumpsToClear != null ? pl.jumpsToClear : 2);7765
document.getElementById('des-air').value = String(pl.fallTime != null ? pl.fallTime : 3);7766
document.getElementById('des-mass').value = String(pl.riseTime != null ? pl.riseTime : 1.5);7767
document.getElementById('designer-edit-title').textContent = 'Planeet bewerken';7768
document.getElementById('btn-designer-delete').hidden = false;7769
}7770
else7771
{7772
Designer.slots = Designer.defaultSlots().slice();7773
document.getElementById('des-name').value = '';7774
document.getElementById('des-people').value = '';7775
document.getElementById('des-gravity').value = '2';7776
document.getElementById('des-air').value = '3';7777
document.getElementById('des-mass').value = '1.5';7778
document.getElementById('designer-edit-title').textContent = 'Nieuwe planeet';7779
document.getElementById('btn-designer-delete').hidden = true;7780
}7781
hideIf('designer');7782
showIf('designer-edit');7783
Designer.syncPreview();7784
Designer.renderSlots();7785
var name = document.getElementById('des-name');7786
if (name)7787
{ name.focus(); }7788
};7789
7790
Designer.draftPlanet = function ()7791
{7792
var jumps = clampNum(document.getElementById('des-gravity').value, 1, 4, 2);7793
var fall = clampNum(document.getElementById('des-air').value, 1, 5, 3);7794
var rise = clampNum(document.getElementById('des-mass').value, 0.5, 3, 1.5);7795
var colors = [];7796
for (var i = 0; i < 5; i++)7797
{7798
var B = Designer._blocks();7799
var col = B ? B.asColor(Designer.slots[i], i) : null;7800
if (col)7801
{ colors.push(col); }7802
}7803
var opts = {7804
id: Designer.editingId || 'draft',7805
name: (document.getElementById('des-name').value || 'Nieuwe planeet').trim() || 'Nieuwe planeet',7806
people: (document.getElementById('des-people').value || 'Volk').trim() || 'Volk',7807
jumpsToClear: jumps,7808
fallTime: fall,7809
riseTime: rise,7810
colors: colors7811
};7812
if (typeof Planet === 'undefined')7813
{ return opts; }7814
return Planet.createPlanet ? (function ()7815
{7816
var p = Planet.createPlanet(opts);7817
p.id = opts.id;7818
p.custom = true;7819
return p;7820
})() : opts;7821
};7822
7823
Designer.syncPreview = function ()7824
{7825
var p = Designer.draftPlanet();7826
var d = (typeof Planet !== 'undefined' && Planet.displayValues) ? Planet.displayValues(p) : null;7827
setText('des-gravity-val', Number(document.getElementById('des-gravity').value).toFixed(1)7828
+ (d ? ' · g ' + d.gravity.toFixed(2) : ''));7829
setText('des-air-val', Number(document.getElementById('des-air').value).toFixed(1)7830
+ (d ? ' · d ' + d.density.toFixed(2) : ''));7831
setText('des-mass-val', Number(document.getElementById('des-mass').value).toFixed(1)7832
+ (d ? ' · F ' + Math.round(d.newtons) + ' N' : ''));7833
var power = d ? d.power : 0;7834
setText('des-power', 'Power ' + power + '%');7835
};7836
7837
Designer.renderSlots = function ()7838
{7839
var row = document.getElementById('des-slots');7840
if (!row)7841
{ return; }7842
row.innerHTML = '';7843
for (var i = 0; i < 5; i++)7844
{7845
var id = Designer.slots[i];7846
var B = Designer._blocks();7847
var b = B ? B.byId(id) : null;7848
var btn = document.createElement('button');7849
btn.type = 'button';7850
btn.className = 'des-slot';7851
btn.setAttribute('aria-label', 'Blokje ' + (i + 1));7852
if (b)7853
{7854
btn.innerHTML = '<img src="' + Designer.esc(b.image) + '" alt="' + Designer.esc(b.name) + '">'7855
+ '<span>' + Designer.esc(b.name) + '</span>';7856
}7857
else7858
{7859
btn.innerHTML = '<span class="des-slot-empty">Kies</span>';7860
}7861
(function (slot)7862
{7863
btn.addEventListener('click', function ()7864
{ Designer.openModal(slot); });7865
})(i);7866
row.appendChild(btn);7867
}7868
};7869
7870
Designer.openModal = function (slot)7871
{7872
Designer.openSlot = slot;7873
var modal = document.getElementById('des-modal');7874
var grid = document.getElementById('des-modal-grid');7875
if (!modal || !grid)7876
{ return; }7877
grid.innerHTML = '';7878
var blocks = Designer.blocks();7879
var used = Object.create(null);7880
for (var i = 0; i < 5; i++)7881
{7882
if (i !== slot && Designer.slots[i])7883
{ used[Designer.slots[i]] = true; }7884
}7885
for (var i = 0; i < blocks.length; i++)7886
{7887
var b = blocks[i];7888
var cell = document.createElement('button');7889
cell.type = 'button';7890
cell.className = 'des-block';7891
cell.dataset.id = b.id;7892
var locked = !b.unlocked;7893
var taken = !!used[b.id];7894
if (locked)7895
{ cell.classList.add('locked'); }7896
if (taken)7897
{ cell.classList.add('used'); }7898
if (Designer.slots[slot] === b.id)7899
{ cell.classList.add('current'); }7900
var title = b.name;7901
if (locked)7902
{ title += ' — ' + b.threshold + ' punten nodig'; }7903
else if (taken)7904
{ title += ' — al in een ander vak'; }7905
cell.title = title;7906
cell.setAttribute('aria-label', title);7907
cell.innerHTML = '<img src="' + Designer.esc(b.image) + '" alt="">'7908
+ (locked ? '<span class="des-lock" aria-hidden="true">'7909
+ '<svg viewBox="0 0 18 18" width="16" height="16">'7910
+ '<rect x="4" y="8" width="10" height="8" rx="1.5" fill="#ffe27a"/>'7911
+ '<path d="M6 8 V6 a3 3 0 0 1 6 0 v2" fill="none" stroke="#ffe27a" stroke-width="1.8" stroke-linecap="round"/>'7912
+ '<circle cx="9" cy="12" r="1.2" fill="#1a1628"/>'7913
+ '</svg></span>' : '')7914
+ '<span class="des-block-name">' + Designer.esc(b.name) + '</span>'7915
+ (locked ? '<span class="des-block-need">' + b.threshold + '</span>' : '');7916
if (locked || taken)7917
{ cell.disabled = true; }7918
else7919
{7920
cell.addEventListener('click', (function (id)7921
{7922
return function ()7923
{7924
Designer.slots[Designer.openSlot] = id;7925
Designer.closeModal();7926
Designer.renderSlots();7927
};7928
})(b.id));7929
}7930
grid.appendChild(cell);7931
}7932
modal.hidden = false;7933
modal.setAttribute('aria-hidden', 'false');7934
var close = document.getElementById('des-modal-close');7935
if (close)7936
{ close.focus(); }7937
};7938
7939
Designer.closeModal = function ()7940
{7941
var modal = document.getElementById('des-modal');7942
if (!modal)7943
{ return; }7944
modal.hidden = true;7945
modal.setAttribute('aria-hidden', 'true');7946
};7947
7948
Designer.save = function ()7949
{7950
var name = (document.getElementById('des-name').value || '').trim();7951
var people = (document.getElementById('des-people').value || '').trim();7952
if (!name || !people)7953
{7954
window.alert('Vul een naam voor de planeet en voor de bevolking in.');7955
return;7956
}7957
for (var i = 0; i < 5; i++)7958
{7959
if (!Designer.slots[i])7960
{7961
window.alert('Kies vijf blokjes.');7962
return;7963
}7964
}7965
var payload = {7966
id: Designer.editingId || undefined,7967
name: name,7968
people: people,7969
jumpsToClear: clampNum(document.getElementById('des-gravity').value, 1, 4, 2),7970
fallTime: clampNum(document.getElementById('des-air').value, 1, 5, 3),7971
riseTime: clampNum(document.getElementById('des-mass').value, 0.5, 3, 1.5),7972
colors: Designer.slots.slice()7973
};7974
Online.savePlanet(payload).then(function (data)7975
{7976
if (!data || !data.ok)7977
{7978
window.alert((data && data.error) || 'Opslaan is mislukt.');7979
return;7980
}7981
hideIf('designer-edit');7982
showIf('designer');7983
Designer.editingId = data.planet ? data.planet.id : null;7984
Designer.renderList();7985
if (typeof renderPlanetGrid === 'function')7986
{7987
renderPlanetGrid('planet-grid', false);7988
renderPlanetGrid('lobby-planet-grid', true);7989
}7990
});7991
};7992
7993
Designer.bind = function ()7994
{7995
var btn = document.getElementById('btn-designer');7996
if (btn)7997
{ btn.addEventListener('click', function () { Designer.openList(); }); }7998
var back = document.getElementById('btn-designer-back');7999
if (back)8000
{ back.addEventListener('click', Designer.close); }8001
var neu = document.getElementById('btn-designer-new');8002
if (neu)8003
{ neu.addEventListener('click', function () { Designer.openEdit(null); }); }8004
var cancel = document.getElementById('btn-designer-cancel');8005
if (cancel)8006
{8007
cancel.addEventListener('click', function ()8008
{8009
hideIf('designer-edit');8010
showIf('designer');8011
Designer.renderList();8012
});8013
}8014
var save = document.getElementById('btn-designer-save');8015
if (save)8016
{ save.addEventListener('click', function (e) { e.preventDefault(); Designer.save(); }); }8017
var form = document.getElementById('designer-form');8018
if (form)8019
{ form.addEventListener('submit', function (e) { e.preventDefault(); Designer.save(); }); }8020
var del = document.getElementById('btn-designer-delete');8021
if (del)8022
{8023
del.addEventListener('click', function ()8024
{8025
if (!Designer.editingId)8026
{ return; }8027
Designer.confirmDelete(Designer.editingId);8028
hideIf('designer-edit');8029
showIf('designer');8030
});8031
}8032
['des-gravity', 'des-air', 'des-mass'].forEach(function (id)8033
{8034
var el = document.getElementById(id);8035
if (!el)8036
{ return; }8037
el.addEventListener('input', Designer.syncPreview);8038
});8039
var modal = document.getElementById('des-modal');8040
if (modal)8041
{8042
modal.addEventListener('click', function (e)8043
{8044
if (e.target === modal)8045
{ Designer.closeModal(); }8046
});8047
}8048
var close = document.getElementById('des-modal-close');8049
if (close)8050
{ close.addEventListener('click', Designer.closeModal); }8051
document.addEventListener('keydown', function (e)8052
{8053
if (e.key === 'Escape')8054
{ Designer.closeModal(); }8055
});8056
};8057
8058
Designer.esc = function (s)8059
{8060
return String(s == null ? '' : s)8061
.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')8062
.replace(/"/g, '"');8063
};8064
8065
function hideIf (id)8066
{8067
var el = document.getElementById(id);8068
if (el)8069
{ el.hidden = true; }8070
}8071
8072
function showIf (id)8073
{8074
var el = document.getElementById(id);8075
if (el)8076
{ el.hidden = false; }8077
}8078
8079
function setText (id, text)8080
{8081
var el = document.getElementById(id);8082
if (el)8083
{ el.textContent = text; }8084
}8085
8086
function clampNum (v, lo, hi, fallback)8087
{8088
var n = Number(v);8089
if (!isFinite(n))8090
{ n = fallback; }8091
return Math.max(lo, Math.min(hi, n));8092
}8093
8094
if (typeof module !== 'undefined' && module.exports)8095
{ module.exports = Designer; }8096
else if (typeof globalThis !== 'undefined')8097
{ globalThis.Designer = Designer; }8098
8099
/*8100
* End File:8101
* /workspace/meteors/src/designer.js8102
*/ 8103
6447
/*8104
/*6448
* Start File:8105
* Start File:6449
* /workspace/meteors/src/main.js8106
* /workspace/meteors/src/main.js@@ -6486,6 +8143,12 @@ function planetImages ()6486
});8143
});6487
}8144
}6488
}8145
}8146
if (typeof Blocks !== 'undefined' && Blocks.images)8147
{8148
var extra = Blocks.images();8149
for (var b = 0; b < extra.length; b++)8150
{ list.push(extra[b]); }8151
}6489
return list;8152
return list;6490
}8153
}6491
8154
@@ -6560,6 +8223,20 @@ window.onload = function ()6560
bindOfflineUi();8223
bindOfflineUi();6561
bindPlanetSelect();8224
bindPlanetSelect();6562
restoreSelectedPlanet();8225
restoreSelectedPlanet();8226
if (typeof Designer !== 'undefined' && Designer.bind)8227
{ Designer.bind(); }8228
if (typeof Online !== 'undefined' && Online.refresh)8229
{8230
Online.refresh().then(function ()8231
{8232
refreshMenuAccount();8233
restoreSelectedPlanet();8234
renderPlanetGrid('planet-grid', false);8235
renderPlanetGrid('lobby-planet-grid', true);8236
});8237
}8238
else8239
{ refreshMenuAccount(); }6563
};8240
};6564
8241
6565
function onPlay ()8242
function onPlay ()@@ -6579,6 +8256,10 @@ function startPlay (opts)6579
hideEl('podium');8256
hideEl('podium');6580
hideEl('planet-select');8257
hideEl('planet-select');6581
hideEl('offline-result');8258
hideEl('offline-result');8259
hideEl('designer');8260
hideEl('designer-edit');8261
if (typeof Designer !== 'undefined' && Designer.closeModal)8262
{ Designer.closeModal(); }6582
showEl('hud');8263
showEl('hud');6583
8264
6584
var planetMod = typeof Planet !== 'undefined' ? Planet : PlanetMod;8265
var planetMod = typeof Planet !== 'undefined' ? Planet : PlanetMod;@@ -6642,6 +8323,8 @@ function startPlay (opts)6642
buildColumnWarn();8323
buildColumnWarn();6643
refreshOfflineHud();8324
refreshOfflineHud();6644
refreshChainIndicator();8325
refreshChainIndicator();8326
if (!opts.online)8327
{ beginPlaySession(opts.offline ? 'offline' : 'solo'); }6645
}8328
}6646
8329
6647
function teardownPlay ()8330
function teardownPlay ()@@ -7234,7 +8917,10 @@ function tickView (dt)7234
else if (app.offline)8917
else if (app.offline)7235
{ /* Offline result is shown from tickOffline. */ }8918
{ /* Offline result is shown from tickOffline. */ }7236
else8919
else7237
{ showEl('game-over'); }8920
{8921
showEl('game-over');8922
finishPlaySession(app.lastScore);8923
}7238
}8924
}7239
if (!app.online && !app.offline && app.core.state === 'gameover'8925
if (!app.online && !app.offline && app.core.state === 'gameover'7240
&& app.core.gameOverTime >= GAME_OVER_DELAY)8926
&& app.core.gameOverTime >= GAME_OVER_DELAY)@@ -7845,6 +9531,8 @@ function startNextOfflineRound ()7845
// Tear down the current scene then start a fresh player field,9531
// Tear down the current scene then start a fresh player field,7846
// keeping the same battle (already advanced).9532
// keeping the same battle (already advanced).7847
var planet = app.battle.playerPlanet;9533
var planet = app.battle.playerPlanet;9534
var roundScore = app.core ? app.core.score : 0;9535
finishPlaySession(roundScore);7848
app._keepBattleOnTeardown = true;9536
app._keepBattleOnTeardown = true;7849
teardownPlay();9537
teardownPlay();7850
app.offline = true;9538
app.offline = true;@@ -7870,6 +9558,7 @@ function showOfflineResult ()7870
}9558
}7871
hideEl('game-over');9559
hideEl('game-over');7872
showEl('offline-result');9560
showEl('offline-result');9561
finishPlaySession(app.core ? app.core.score : 0);7873
}9562
}7874
9563
7875
function refreshOfflineHud ()9564
function refreshOfflineHud ()@@ -8181,10 +9870,18 @@ function startOnlineMatch ()8181
if (app.mode === 'playing' && app.online)9870
if (app.mode === 'playing' && app.online)8182
{ return; }9871
{ return; }8183
var planet = Planet.planetById(selectedPlanetId());9872
var planet = Planet.planetById(selectedPlanetId());9873
var miss = Planet.missChance(planet);8184
var me = (typeof Online !== 'undefined' && Online.mePlayer) ? Online.mePlayer() : null;9874
var me = (typeof Online !== 'undefined' && Online.mePlayer) ? Online.mePlayer() : null;8185
if (me && me.planet && me.planet.id)9875
if (me && me.planet)8186
{ planet = Planet.planetById(me.planet.id); }9876
{8187
startPlay({ online: true, planet: planet, missChance: Planet.missChance(planet) });9877
if (typeof Planet.rememberPlanet === 'function')9878
{ planet = Planet.rememberPlanet(me.planet) || planet; }9879
else if (me.planet.id)9880
{ planet = Planet.planetById(me.planet.id); }9881
if (typeof me.planet.miss_chance === 'number')9882
{ miss = me.planet.miss_chance; }9883
}9884
startPlay({ online: true, planet: planet, missChance: miss });8188
if (typeof Online !== 'undefined')9885
if (typeof Online !== 'undefined')8189
{ Online.startPolling(onlinePayload); }9886
{ Online.startPolling(onlinePayload); }8190
}9887
}@@ -8562,19 +10259,22 @@ function renderPlanetGrid (containerId, compact)8562
var pl = all[i];10259
var pl = all[i];8563
var btn = document.createElement('button');10260
var btn = document.createElement('button');8564
btn.type = 'button';10261
btn.type = 'button';8565
btn.className = 'planet-card' + (pl.id === current ? ' selected' : '');10262
btn.className = 'planet-card' + (pl.id === current ? ' selected' : '')10263
+ (pl.custom ? ' custom' : '');8566
btn.setAttribute('role', 'listitem');10264
btn.setAttribute('role', 'listitem');8567
btn.dataset.planet = pl.id;10265
btn.dataset.planet = pl.id;8568
var swatches = '';10266
var swatches = '';8569
for (var c = 0; c < pl.colors.length; c++)10267
var colors = pl.colors || [];10268
for (var c = 0; c < colors.length; c++)8570
{10269
{8571
swatches += '<img src="' + escapeText(pl.colors[c].image) + '" alt="'10270
swatches += '<img src="' + escapeText(colors[c].image) + '" alt="'8572
+ escapeText(pl.colors[c].name) + '" title="' + escapeText(pl.colors[c].name) + '">';10271
+ escapeText(colors[c].name) + '" title="' + escapeText(colors[c].name) + '">';8573
}10272
}8574
btn.innerHTML = '<div class="planet-title">' + escapeText(pl.name) + '</div>'10273
btn.innerHTML = '<div class="planet-title">' + escapeText(pl.name) + '</div>'8575
+ '<div class="planet-people">' + escapeText(pl.people) + '</div>'10274
+ '<div class="planet-people">' + escapeText(pl.people) + '</div>'8576
+ '<div class="planet-nums">' + escapeText(Planet.formatStats(pl)) + '</div>'10275
+ '<div class="planet-nums">' + escapeText(Planet.formatStats(pl)) + '</div>'8577
+ '<div class="planet-swatches">' + swatches + '</div>';10276
+ '<div class="planet-swatches">' + swatches + '</div>'10277
+ (pl.custom ? '<span class="custom-badge">Eigen</span>' : '');8578
btn.addEventListener('click', (function (id, isCompact)10278
btn.addEventListener('click', (function (id, isCompact)8579
{10279
{8580
return function ()10280
return function ()@@ -8636,6 +10336,67 @@ function bindPlanetSelect ()8636
}10336
}8637
}10337
}8638
10338
10339
10340
function refreshMenuAccount ()10341
{10342
var guest = document.getElementById('menu-guest');10343
var user = document.getElementById('menu-user');10344
var designerBtn = document.getElementById('btn-designer');10345
var localLogin = document.getElementById('menu-local-login');10346
var me = (typeof Online !== 'undefined') ? Online.me : null;10347
if (me)10348
{10349
if (guest)10350
{ guest.hidden = true; }10351
if (user)10352
{ user.hidden = false; }10353
var name = document.getElementById('menu-name');10354
if (name)10355
{ name.textContent = me.name || me.id || 'speler'; }10356
var pts = document.getElementById('menu-points');10357
if (pts)10358
{ pts.textContent = String((typeof Online !== 'undefined' && Online.lifetimePoints) || 0); }10359
if (designerBtn)10360
{ designerBtn.hidden = false; }10361
}10362
else10363
{10364
if (guest)10365
{ guest.hidden = false; }10366
if (user)10367
{ user.hidden = true; }10368
if (designerBtn)10369
{ designerBtn.hidden = true; }10370
}10371
if (localLogin)10372
{ localLogin.hidden = !(typeof Online !== 'undefined' && Online.local); }10373
}10374
10375
function beginPlaySession (mode)10376
{10377
if (app.playToken)10378
{ finishPlaySession(app.core ? app.core.score : (app.lastScore || 0)); }10379
app.playToken = null;10380
if (typeof Online === 'undefined' || !Online.me || !Online.playBegin)10381
{ return; }10382
Online.playBegin(mode || 'solo').then(function (data)10383
{10384
if (data && data.ok && data.token)10385
{ app.playToken = data.token; }10386
});10387
}10388
10389
function finishPlaySession (score)10390
{10391
var token = app.playToken;10392
app.playToken = null;10393
if (!token || typeof Online === 'undefined' || !Online.playFinish)10394
{ return; }10395
Online.playFinish(token, score || 0).then(function ()10396
{ refreshMenuAccount(); });10397
}10398
10399
8639
/*10400
/*8640
* End File:10401
* End File:8641
* /workspace/meteors/src/main.js10402
* /workspace/meteors/src/main.js