board-game-engine 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,793 @@
1
+ {
2
+ "entities": [
3
+ {
4
+ "name": "mainGrid",
5
+ "entityType": "Grid",
6
+ "width": 8,
7
+ "height": 8
8
+ },
9
+ {
10
+ "name": "checker",
11
+ "perPlayer": true,
12
+ "state": {
13
+ "isKing": false
14
+ },
15
+ "displayProperties": ["isKing"],
16
+ "count": 12
17
+ }
18
+ ],
19
+ "sharedBoard": [{ "name": "mainGrid" }],
20
+ "initialPlacements": [
21
+ {"entity": {"name": "checker", "player": "1"}, "destination": {"index": 1}},
22
+ {"entity": {"name": "checker", "player": "1"}, "destination": {"index": 3}},
23
+ {"entity": {"name": "checker", "player": "1"}, "destination": {"index": 5}},
24
+ {"entity": {"name": "checker", "player": "1"}, "destination": {"index": 7}},
25
+ {"entity": {"name": "checker", "player": "1"}, "destination": {"index": 8}},
26
+ {"entity": {"name": "checker", "player": "1"}, "destination": {"index": 10}},
27
+ {"entity": {"name": "checker", "player": "1"}, "destination": {"index": 12}},
28
+ {"entity": {"name": "checker", "player": "1"}, "destination": {"index": 14}},
29
+ {"entity": {"name": "checker", "player": "1"}, "destination": {"index": 17}},
30
+ {"entity": {"name": "checker", "player": "1"}, "destination": {"index": 19}},
31
+ {"entity": {"name": "checker", "player": "1"}, "destination": {"index": 21}},
32
+ {"entity": {"name": "checker", "player": "1"}, "destination": {"index": 23}},
33
+ {"entity": {"name": "checker", "player": "0"}, "destination": {"index": 40}},
34
+ {"entity": {"name": "checker", "player": "0"}, "destination": {"index": 42}},
35
+ {"entity": {"name": "checker", "player": "0"}, "destination": {"index": 44}},
36
+ {"entity": {"name": "checker", "player": "0"}, "destination": {"index": 46}},
37
+ {"entity": {"name": "checker", "player": "0"}, "destination": {"index": 49}},
38
+ {"entity": {"name": "checker", "player": "0"}, "destination": {"index": 51}},
39
+ {"entity": {"name": "checker", "player": "0"}, "destination": {"index": 53}},
40
+ {"entity": {"name": "checker", "player": "0"}, "destination": {"index": 55}},
41
+ {"entity": {"name": "checker", "player": "0"}, "destination": {"index": 56}},
42
+ {"entity": {"name": "checker", "player": "0"}, "destination": {"index": 58}},
43
+ {"entity": {"name": "checker", "player": "0"}, "destination": {"index": 60}},
44
+ {"entity": {"name": "checker", "player": "0"}, "destination": {"index": 62}}
45
+ ],
46
+ "minPlayers": 2,
47
+ "maxPlayers": 2,
48
+ "turn": {
49
+ "activePlayers": { "currentPlayer": "jumpIfPossible" },
50
+ "stages": {
51
+ "jumpIfPossible": {
52
+ "initialMoves": [{
53
+ "moveType": "SetActivePlayers",
54
+ "options": {
55
+ "currentPlayer": { "stage": "moveIfNoJump" }
56
+ },
57
+ "conditions": [{ "conditionType": "NoPossibleMoves" }]
58
+ }],
59
+ "moves": {
60
+ "jumpChecker": {
61
+ "moveType": "MoveEntity",
62
+ "arguments": {
63
+ "entity": {
64
+ "playerChoice": true,
65
+ "conditions": [
66
+ {
67
+ "conditionType": "Is",
68
+ "matcher": {
69
+ "name": "checker",
70
+ "player": {
71
+ "type": "ctxPath",
72
+ "path": ["currentPlayer"]
73
+ }
74
+ }
75
+ }
76
+ ]
77
+ },
78
+ "destination": {
79
+ "playerChoice": true,
80
+ "conditions": [
81
+ {
82
+ "conditionType": "Is",
83
+ "matcher": { "entityType": "Space" }
84
+ },
85
+ {
86
+ "conditionType": "Not",
87
+ "conditions": [{ "conditionType": "Contains" }]
88
+ },
89
+ {
90
+ "conditionType": "Or",
91
+ "conditions": [
92
+ {
93
+ "conditionType": "Contains",
94
+ "target": {
95
+ "type": "relativeCoordinates",
96
+ "location": {
97
+ "type": "expression",
98
+ "expression": "player == '0' ? player0RelativeCoordinates : player1RelativeCoordinates",
99
+ "arguments": {
100
+ "player0RelativeCoordinates": [-2, 2],
101
+ "player1RelativeCoordinates": [-2, -2],
102
+ "player": {
103
+ "type": "ctxPath",
104
+ "path": ["currentPlayer"]
105
+ }
106
+ }
107
+ }
108
+ },
109
+ "conditions": [{
110
+ "conditionType": "Is",
111
+ "entity": {
112
+ "type": "contextPath",
113
+ "path": ["moveArguments", "entity"]
114
+ }
115
+ }]
116
+ },
117
+ {
118
+ "conditionType": "Contains",
119
+ "target": {
120
+ "type": "relativeCoordinates",
121
+ "location": {
122
+ "type": "expression",
123
+ "expression": "player == '0' ? player0RelativeCoordinates : player1RelativeCoordinates",
124
+ "arguments": {
125
+ "player0RelativeCoordinates": [2, 2],
126
+ "player1RelativeCoordinates": [2, -2],
127
+ "player": {
128
+ "type": "ctxPath",
129
+ "path": ["currentPlayer"]
130
+ }
131
+ }
132
+ }
133
+ },
134
+ "conditions": [{
135
+ "conditionType": "Is",
136
+ "entity": {
137
+ "type": "contextPath",
138
+ "path": ["moveArguments", "entity"]
139
+ }
140
+ }]
141
+ },
142
+ {
143
+ "conditionType": "Contains",
144
+ "target": {
145
+ "type": "relativeCoordinates",
146
+ "location": {
147
+ "type": "expression",
148
+ "expression": "player == '0' ? player0RelativeCoordinates : player1RelativeCoordinates",
149
+ "arguments": {
150
+ "player0RelativeCoordinates": [-2, -2],
151
+ "player1RelativeCoordinates": [-2, 2],
152
+ "player": {
153
+ "type": "ctxPath",
154
+ "path": ["currentPlayer"]
155
+ }
156
+ }
157
+ }
158
+ },
159
+ "conditions": [
160
+ {
161
+ "conditionType": "Is",
162
+ "entity": {
163
+ "type": "contextPath",
164
+ "path": ["moveArguments", "entity"]
165
+ }
166
+ },
167
+ {
168
+ "conditionType": "Is",
169
+ "matcher": { "isKing": true }
170
+ }
171
+ ]
172
+ },
173
+ {
174
+ "conditionType": "Contains",
175
+ "target": {
176
+ "type": "relativeCoordinates",
177
+ "location": {
178
+ "type": "expression",
179
+ "expression": "player == '0' ? player0RelativeCoordinates : player1RelativeCoordinates",
180
+ "arguments": {
181
+ "player0RelativeCoordinates": [2, -2],
182
+ "player1RelativeCoordinates": [2, 2],
183
+ "player": {
184
+ "type": "ctxPath",
185
+ "path": ["currentPlayer"]
186
+ }
187
+ }
188
+ }
189
+ },
190
+ "conditions": [
191
+ {
192
+ "conditionType": "Is",
193
+ "entity": {
194
+ "type": "contextPath",
195
+ "path": ["moveArguments", "entity"]
196
+ }
197
+ },
198
+ {
199
+ "conditionType": "Is",
200
+ "matcher": { "isKing": true }
201
+ }
202
+ ]
203
+ }
204
+ ]
205
+ },
206
+ {
207
+ "conditionType": "InLine",
208
+ "sequence": [
209
+ {
210
+ "conditions": [{
211
+ "conditionType": "Contains",
212
+ "conditions": [{
213
+ "conditionType": "Is",
214
+ "entity": {
215
+ "type": "contextPath",
216
+ "path": ["moveArguments", "entity"]
217
+ }
218
+ }]
219
+ }]
220
+ },
221
+ {
222
+ "conditions": [{
223
+ "conditionType": "Contains",
224
+ "conditions": [{
225
+ "conditionType": "Not",
226
+ "conditions": [{
227
+ "conditionType": "Is",
228
+ "matcher": {
229
+ "player": {
230
+ "type": "ctxPath",
231
+ "path": ["currentPlayer"]
232
+ }
233
+ }
234
+ }]
235
+ }]
236
+ }]
237
+ },
238
+ {
239
+ "conditions": [{
240
+ "conditionType": "Is",
241
+ "entity": {
242
+ "type": "contextPath",
243
+ "path": ["originalTarget"]
244
+ }
245
+ }]
246
+ }
247
+ ]
248
+ }
249
+ ]
250
+ }
251
+ },
252
+ "then": [
253
+ {
254
+ "moveType": "ForEach",
255
+ "arguments": {
256
+ "targets": {
257
+ "type": "contextPath",
258
+ "path": [
259
+ "moveConditionResults",
260
+ 0,
261
+ "conditionResults",
262
+ "argumentResults",
263
+ "destination",
264
+ "results",
265
+ 0,
266
+ "results",
267
+ 3,
268
+ "matches",
269
+ 0,
270
+ 1,
271
+ "entities"
272
+ ]
273
+ }
274
+ },
275
+ "move": {
276
+ "moveType": "RemoveEntity",
277
+ "arguments": {
278
+ "entity": {
279
+ "type": "contextPath",
280
+ "path": [ "loopTarget" ]
281
+ }
282
+ }
283
+ }
284
+ },
285
+ {
286
+ "moveType": "SetActivePlayers",
287
+ "options": {
288
+ "currentPlayer": { "stage": "keepJumping" }
289
+ }
290
+ }
291
+ ]
292
+ }
293
+ }
294
+ },
295
+ "keepJumping": {
296
+ "initialMoves": [{
297
+ "moveType": "SetActivePlayers",
298
+ "options": {
299
+ "currentPlayer": { "stage": "kingPieces" }
300
+ },
301
+ "conditions": [{ "conditionType": "NoPossibleMoves" }]
302
+ }],
303
+ "moves": {
304
+ "jumpChecker": {
305
+ "moveType": "MoveEntity",
306
+ "arguments": {
307
+ "entity": {
308
+ "conditions": [
309
+ {
310
+ "conditionType": "Is",
311
+ "entity": {
312
+ "type": "gamePath",
313
+ "path": ["_meta", "previousPayloads", "jumpChecker", "arguments", "entity"]
314
+ }
315
+ }
316
+ ]
317
+ },
318
+ "destination": {
319
+ "playerChoice": true,
320
+ "conditions": [
321
+ {
322
+ "conditionType": "Is",
323
+ "matcher": { "entityType": "Space" }
324
+ },
325
+ {
326
+ "conditionType": "Not",
327
+ "conditions": [{ "conditionType": "Contains" }]
328
+ },
329
+ {
330
+ "conditionType": "Or",
331
+ "conditions": [
332
+ {
333
+ "conditionType": "Contains",
334
+ "target": {
335
+ "type": "relativeCoordinates",
336
+ "location": {
337
+ "type": "expression",
338
+ "expression": "player == '0' ? player0RelativeCoordinates : player1RelativeCoordinates",
339
+ "arguments": {
340
+ "player0RelativeCoordinates": [-2, 2],
341
+ "player1RelativeCoordinates": [-2, -2],
342
+ "player": {
343
+ "type": "ctxPath",
344
+ "path": ["currentPlayer"]
345
+ }
346
+ }
347
+ }
348
+ },
349
+ "conditions": [{
350
+ "conditionType": "Is",
351
+ "entity": {
352
+ "type": "contextPath",
353
+ "path": ["moveArguments", "entity"]
354
+ }
355
+ }]
356
+ },
357
+ {
358
+ "conditionType": "Contains",
359
+ "target": {
360
+ "type": "relativeCoordinates",
361
+ "location": {
362
+ "type": "expression",
363
+ "expression": "player == '0' ? player0RelativeCoordinates : player1RelativeCoordinates",
364
+ "arguments": {
365
+ "player0RelativeCoordinates": [2, 2],
366
+ "player1RelativeCoordinates": [2, -2],
367
+ "player": {
368
+ "type": "ctxPath",
369
+ "path": ["currentPlayer"]
370
+ }
371
+ }
372
+ }
373
+ },
374
+ "conditions": [{
375
+ "conditionType": "Is",
376
+ "entity": {
377
+ "type": "contextPath",
378
+ "path": ["moveArguments", "entity"]
379
+ }
380
+ }]
381
+ },
382
+ {
383
+ "conditionType": "Contains",
384
+ "target": {
385
+ "type": "relativeCoordinates",
386
+ "location": {
387
+ "type": "expression",
388
+ "expression": "player == '0' ? player0RelativeCoordinates : player1RelativeCoordinates",
389
+ "arguments": {
390
+ "player0RelativeCoordinates": [-2, -2],
391
+ "player1RelativeCoordinates": [-2, 2],
392
+ "player": {
393
+ "type": "ctxPath",
394
+ "path": ["currentPlayer"]
395
+ }
396
+ }
397
+ }
398
+ },
399
+ "conditions": [
400
+ {
401
+ "conditionType": "Is",
402
+ "entity": {
403
+ "type": "contextPath",
404
+ "path": ["moveArguments", "entity"]
405
+ }
406
+ },
407
+ {
408
+ "conditionType": "Is",
409
+ "matcher": { "isKing": true }
410
+ }
411
+ ]
412
+ },
413
+ {
414
+ "conditionType": "Contains",
415
+ "target": {
416
+ "type": "relativeCoordinates",
417
+ "location": {
418
+ "type": "expression",
419
+ "expression": "player == '0' ? player0RelativeCoordinates : player1RelativeCoordinates",
420
+ "arguments": {
421
+ "player0RelativeCoordinates": [2, -2],
422
+ "player1RelativeCoordinates": [2, 2],
423
+ "player": {
424
+ "type": "ctxPath",
425
+ "path": ["currentPlayer"]
426
+ }
427
+ }
428
+ }
429
+ },
430
+ "conditions": [
431
+ {
432
+ "conditionType": "Is",
433
+ "entity": {
434
+ "type": "contextPath",
435
+ "path": ["moveArguments", "entity"]
436
+ }
437
+ },
438
+ {
439
+ "conditionType": "Is",
440
+ "matcher": { "isKing": true }
441
+ }
442
+ ]
443
+ }
444
+ ]
445
+ },
446
+ {
447
+ "conditionType": "InLine",
448
+ "sequence": [
449
+ {
450
+ "conditions": [{
451
+ "conditionType": "Contains",
452
+ "conditions": [{
453
+ "conditionType": "Is",
454
+ "entity": {
455
+ "type": "contextPath",
456
+ "path": ["moveArguments", "entity"]
457
+ }
458
+ }]
459
+ }]
460
+ },
461
+ {
462
+ "conditions": [{
463
+ "conditionType": "Contains",
464
+ "conditions": [{
465
+ "conditionType": "Not",
466
+ "conditions": [{
467
+ "conditionType": "Is",
468
+ "matcher": {
469
+ "player": {
470
+ "type": "ctxPath",
471
+ "path": ["currentPlayer"]
472
+ }
473
+ }
474
+ }]
475
+ }]
476
+ }]
477
+ },
478
+ {
479
+ "conditions": [{
480
+ "conditionType": "Is",
481
+ "entity": {
482
+ "type": "contextPath",
483
+ "path": ["originalTarget"]
484
+ }
485
+ }]
486
+ }
487
+ ]
488
+ }
489
+ ]
490
+ }
491
+ },
492
+ "then": [
493
+ {
494
+ "moveType": "ForEach",
495
+ "arguments": {
496
+ "targets": {
497
+ "type": "contextPath",
498
+ "path": [
499
+ "moveConditionResults",
500
+ 0,
501
+ "conditionResults",
502
+ "argumentResults",
503
+ "destination",
504
+ "results",
505
+ 0,
506
+ "results",
507
+ 3,
508
+ "matches",
509
+ 0,
510
+ 1,
511
+ "entities"
512
+ ]
513
+ }
514
+ },
515
+ "move": {
516
+ "moveType": "RemoveEntity",
517
+ "arguments": {
518
+ "entity": {
519
+ "type": "contextPath",
520
+ "path": [ "loopTarget" ]
521
+ }
522
+ }
523
+ }
524
+ },
525
+ {
526
+ "moveType": "SetActivePlayers",
527
+ "options": {
528
+ "currentPlayer": { "stage": "kingPieces" }
529
+ },
530
+ "conditions": [{ "conditionType": "NoPossibleMoves" }]
531
+ }
532
+ ]
533
+ }
534
+ }
535
+ },
536
+ "moveIfNoJump": {
537
+ "initialMoves": [{
538
+ "moveType": "PassTurn",
539
+ "conditions": [{ "conditionType": "NoPossibleMoves" }]
540
+ }],
541
+ "moves": {
542
+ "moveChecker": {
543
+ "moveType": "MoveEntity",
544
+ "arguments": {
545
+ "entity": {
546
+ "playerChoice": true,
547
+ "conditions": [
548
+ {
549
+ "conditionType": "Is",
550
+ "matcher": {
551
+ "name": "checker",
552
+ "player": {
553
+ "type": "ctxPath",
554
+ "path": ["currentPlayer"]
555
+ }
556
+ }
557
+ }
558
+ ]
559
+ },
560
+ "destination": {
561
+ "playerChoice": true,
562
+ "conditions": [
563
+ {
564
+ "conditionType": "Is",
565
+ "matcher": { "entityType": "Space" }
566
+ },
567
+ {
568
+ "conditionType": "Not",
569
+ "conditions": [{ "conditionType": "Contains" }]
570
+ },
571
+ {
572
+ "conditionType": "Or",
573
+ "conditions": [
574
+ {
575
+ "conditionType": "Contains",
576
+ "target": {
577
+ "type": "relativeCoordinates",
578
+ "location": {
579
+ "type": "expression",
580
+ "expression": "player == '0' ? player0RelativeCoordinates : player1RelativeCoordinates",
581
+ "arguments": {
582
+ "player0RelativeCoordinates": [-1, 1],
583
+ "player1RelativeCoordinates": [-1, -1],
584
+ "player": {
585
+ "type": "ctxPath",
586
+ "path": ["currentPlayer"]
587
+ }
588
+ }
589
+ }
590
+ },
591
+ "conditions": [{
592
+ "conditionType": "Is",
593
+ "entity": {
594
+ "type": "contextPath",
595
+ "path": ["moveArguments", "entity"]
596
+ }
597
+ }]
598
+ },
599
+ {
600
+ "conditionType": "Contains",
601
+ "target": {
602
+ "type": "relativeCoordinates",
603
+ "location": {
604
+ "type": "expression",
605
+ "expression": "player == '0' ? player0RelativeCoordinates : player1RelativeCoordinates",
606
+ "arguments": {
607
+ "player0RelativeCoordinates": [1, 1],
608
+ "player1RelativeCoordinates": [1, -1],
609
+ "player": {
610
+ "type": "ctxPath",
611
+ "path": ["currentPlayer"]
612
+ }
613
+ }
614
+ }
615
+ },
616
+ "conditions": [{
617
+ "conditionType": "Is",
618
+ "entity": {
619
+ "type": "contextPath",
620
+ "path": ["moveArguments", "entity"]
621
+ }
622
+ }]
623
+ },
624
+ {
625
+ "conditionType": "Contains",
626
+ "target": {
627
+ "type": "relativeCoordinates",
628
+ "location": {
629
+ "type": "expression",
630
+ "expression": "player == '0' ? player0RelativeCoordinates : player1RelativeCoordinates",
631
+ "arguments": {
632
+ "player0RelativeCoordinates": [-1, -1],
633
+ "player1RelativeCoordinates": [-1, 1],
634
+ "player": {
635
+ "type": "ctxPath",
636
+ "path": ["currentPlayer"]
637
+ }
638
+ }
639
+ }
640
+ },
641
+ "conditions": [
642
+ {
643
+ "conditionType": "Is",
644
+ "entity": {
645
+ "type": "contextPath",
646
+ "path": ["moveArguments", "entity"]
647
+ }
648
+ },
649
+ {
650
+ "conditionType": "Is",
651
+ "matcher": { "isKing": true }
652
+ }
653
+ ]
654
+ },
655
+ {
656
+ "conditionType": "Contains",
657
+ "target": {
658
+ "type": "relativeCoordinates",
659
+ "location": {
660
+ "type": "expression",
661
+ "expression": "player == '0' ? player0RelativeCoordinates : player1RelativeCoordinates",
662
+ "arguments": {
663
+ "player0RelativeCoordinates": [1, -1],
664
+ "player1RelativeCoordinates": [1, 1],
665
+ "player": {
666
+ "type": "ctxPath",
667
+ "path": ["currentPlayer"]
668
+ }
669
+ }
670
+ }
671
+ },
672
+ "conditions": [
673
+ {
674
+ "conditionType": "Is",
675
+ "entity": {
676
+ "type": "contextPath",
677
+ "path": ["moveArguments", "entity"]
678
+ }
679
+ },
680
+ {
681
+ "conditionType": "Is",
682
+ "matcher": { "isKing": true }
683
+ }
684
+ ]
685
+ }
686
+ ]
687
+ }
688
+ ]
689
+ }
690
+ },
691
+ "then": [
692
+ {
693
+ "moveType": "SetActivePlayers",
694
+ "options": {
695
+ "currentPlayer": { "stage": "kingPieces" }
696
+ }
697
+ }
698
+ ]
699
+ }
700
+ }
701
+ },
702
+ "kingPieces": {
703
+ "initialMoves": [
704
+ {
705
+ "moveType": "ForEach",
706
+ "arguments": {
707
+ "targets": {
708
+ "type": "map",
709
+ "targets": {
710
+ "matchMultiple": true,
711
+ "conditions": [
712
+ {
713
+ "conditionType": "Is",
714
+ "matcher": { "entityType": "Space" }
715
+ },
716
+ { "conditionType": "Contains" },
717
+ {
718
+ "conditionType": "Evaluate",
719
+ "expression": "(player == '0' and destinationCoordinates[1] == 0) or (player == '1' and destinationCoordinates[1] == 7)",
720
+ "arguments": {
721
+ "player": {
722
+ "type": "RelativePath",
723
+ "target": {
724
+ "type": "contextPath",
725
+ "path": ["originalTarget"]
726
+ },
727
+ "path": ["entities", 0, "rule", "player"]
728
+ },
729
+ "destinationCoordinates": {
730
+ "type": "Coordinates",
731
+ "target": {
732
+ "type": "contextPath",
733
+ "path": ["target"]
734
+ }
735
+ }
736
+ }
737
+ }
738
+ ]
739
+ },
740
+ "mapping": {
741
+ "type": "contextPath",
742
+ "path": [
743
+ "loopTarget",
744
+ "entities",
745
+ 0
746
+ ]
747
+ }
748
+ }
749
+ },
750
+ "move": {
751
+ "moveType": "SetState",
752
+ "arguments": {
753
+ "entity": {
754
+ "type": "contextPath",
755
+ "path": ["loopTarget"]
756
+ },
757
+ "state": {
758
+ "property": "isKing",
759
+ "value": true
760
+ }
761
+ }
762
+ }
763
+ },
764
+ { "moveType": "EndTurn" }
765
+ ]
766
+ }
767
+ }
768
+ },
769
+ "endIf": [{
770
+ "conditions": [{
771
+ "conditionType": "Evaluate",
772
+ "expression": "passCount > 0",
773
+ "arguments": {
774
+ "passCount": {
775
+ "type": "gamePath",
776
+ "path": ["_meta", "passedPlayers", "length"]
777
+ }
778
+ }
779
+ }],
780
+ "result": {
781
+ "winner": {
782
+ "type": "expression",
783
+ "expression": "(currentPlayer + 1) % 2",
784
+ "arguments": {
785
+ "currentPlayer": {
786
+ "type": "ctxPath",
787
+ "path": ["currentPlayer"]
788
+ }
789
+ }
790
+ }
791
+ }
792
+ }]
793
+ }