board-game-engine-react 0.0.16 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nycrc.json +8 -0
- package/babel.config.js +6 -1
- package/dist/board-game-engine-react.js +10 -3
- package/dist/board-game-engine-react.min.js +1 -1
- package/e2e/coverage.js +28 -0
- package/e2e/harness.spec.js +73 -0
- package/examples/checkers.json +793 -0
- package/examples/connect-four.json +126 -0
- package/examples/eights.json +653 -0
- package/examples/reversi.json +215 -0
- package/examples/tic-tac-toe.json +53 -0
- package/package.json +15 -3
- package/playwright.config.cjs +23 -0
- package/src/components/entity/entity.js +10 -3
- package/src/components/game/game.js +1 -0
- package/test-app/index.html +25 -0
- package/test-app/main.jsx +101 -0
- package/test-app/public/games/checkers.json +793 -0
- package/test-app/public/games/connect-four.json +126 -0
- package/test-app/public/games/eights.json +653 -0
- package/test-app/public/games/reversi.json +215 -0
- package/test-app/public/games/tic-tac-toe.json +53 -0
- package/vite.harness.config.js +16 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
{
|
|
2
|
+
"entities": [
|
|
3
|
+
{
|
|
4
|
+
"name": "mainGrid",
|
|
5
|
+
"entityType": "Grid",
|
|
6
|
+
"width": 8,
|
|
7
|
+
"height": 8
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"name": "disc",
|
|
11
|
+
"state": { "player": "0" },
|
|
12
|
+
"count": "Infinity"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"sharedBoard": [{ "name": "mainGrid" }],
|
|
16
|
+
"initialPlacements": [
|
|
17
|
+
{
|
|
18
|
+
"entity": {
|
|
19
|
+
"name": "disc",
|
|
20
|
+
"state": { "player": "0" }
|
|
21
|
+
},
|
|
22
|
+
"destination": { "index": 27 }
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"entity": {
|
|
26
|
+
"name": "disc",
|
|
27
|
+
"state": { "player": "1" }
|
|
28
|
+
},
|
|
29
|
+
"destination": { "index": 28 }
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"entity": {
|
|
33
|
+
"name": "disc",
|
|
34
|
+
"state": { "player": "1" }
|
|
35
|
+
},
|
|
36
|
+
"destination": { "index": 35 }
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"entity": {
|
|
40
|
+
"name": "disc",
|
|
41
|
+
"state": { "player": "0" }
|
|
42
|
+
},
|
|
43
|
+
"destination": { "index": 36 }
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"minPlayers": 2,
|
|
47
|
+
"maxPlayers": 2,
|
|
48
|
+
"turn": {
|
|
49
|
+
"minMoves": 1,
|
|
50
|
+
"maxMoves": 1,
|
|
51
|
+
"initialMoves": [{
|
|
52
|
+
"moveType": "PassTurn",
|
|
53
|
+
"conditions": [{ "conditionType": "NoPossibleMoves" }]
|
|
54
|
+
}]
|
|
55
|
+
},
|
|
56
|
+
"moves": {
|
|
57
|
+
"placeDisc": {
|
|
58
|
+
"moveType": "PlaceNew",
|
|
59
|
+
"entity": {
|
|
60
|
+
"state": {
|
|
61
|
+
"player": {
|
|
62
|
+
"type": "ctxPath",
|
|
63
|
+
"path": ["currentPlayer"]
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"conditions": [{
|
|
67
|
+
"conditionType": "Is",
|
|
68
|
+
"matcher": { "name": "disc" }
|
|
69
|
+
}]
|
|
70
|
+
},
|
|
71
|
+
"arguments": {
|
|
72
|
+
"destination": {
|
|
73
|
+
"playerChoice": true,
|
|
74
|
+
"conditions": [
|
|
75
|
+
{
|
|
76
|
+
"conditionType": "Is",
|
|
77
|
+
"matcher": { "entityType": "Space" }
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"conditionType": "Not",
|
|
81
|
+
"conditions": [{ "conditionType": "Contains" }]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"conditionType": "InLine",
|
|
85
|
+
"sequence": [
|
|
86
|
+
{
|
|
87
|
+
"conditions": [{
|
|
88
|
+
"conditionType": "Is",
|
|
89
|
+
"entity": {
|
|
90
|
+
"type": "contextPath",
|
|
91
|
+
"path": ["originalTarget"]
|
|
92
|
+
}
|
|
93
|
+
}]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"minCount": 1,
|
|
97
|
+
"conditions": [
|
|
98
|
+
{
|
|
99
|
+
"conditionType": "Not",
|
|
100
|
+
"conditions": [{
|
|
101
|
+
"conditionType": "Contains",
|
|
102
|
+
"conditions": [{
|
|
103
|
+
"conditionType": "Is",
|
|
104
|
+
"matcher": {
|
|
105
|
+
"player": {
|
|
106
|
+
"type": "ctxPath",
|
|
107
|
+
"path": ["currentPlayer"]
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}]
|
|
111
|
+
}]
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"conditionType": "ContainsSame",
|
|
115
|
+
"properties": ["player"]
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"conditions": [{
|
|
121
|
+
"conditionType": "Contains",
|
|
122
|
+
"conditions": [{
|
|
123
|
+
"conditionType": "Is",
|
|
124
|
+
"matcher": {
|
|
125
|
+
"player": {
|
|
126
|
+
"type": "ctxPath",
|
|
127
|
+
"path": ["currentPlayer"]
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}]
|
|
131
|
+
}]
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"then": [{
|
|
139
|
+
"moveType": "ForEach",
|
|
140
|
+
"arguments": {
|
|
141
|
+
"targets": {
|
|
142
|
+
"type": "contextPath",
|
|
143
|
+
"path": [
|
|
144
|
+
"moveConditionResults",
|
|
145
|
+
0,
|
|
146
|
+
"conditionResults",
|
|
147
|
+
"argumentResults",
|
|
148
|
+
"destination",
|
|
149
|
+
"results",
|
|
150
|
+
0,
|
|
151
|
+
"results",
|
|
152
|
+
2,
|
|
153
|
+
"matches",
|
|
154
|
+
{ "flatten": true, "map": ["entities"] },
|
|
155
|
+
{ "flatten": true }
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
"move": {
|
|
160
|
+
"moveType": "SetState",
|
|
161
|
+
"arguments": {
|
|
162
|
+
"entity": {
|
|
163
|
+
"type": "contextPath",
|
|
164
|
+
"path": [ "loopTarget" ]
|
|
165
|
+
},
|
|
166
|
+
"state": {
|
|
167
|
+
"property": "player",
|
|
168
|
+
"value": {
|
|
169
|
+
"type": "ctxPath",
|
|
170
|
+
"path": ["currentPlayer"]
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}]
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
"endIf": [{
|
|
179
|
+
"conditions": [{
|
|
180
|
+
"conditionType": "Evaluate",
|
|
181
|
+
"expression": "passCount == numPlayers",
|
|
182
|
+
"arguments": {
|
|
183
|
+
"passCount": {
|
|
184
|
+
"type": "gamePath",
|
|
185
|
+
"path": ["_meta", "passedPlayers", "length"]
|
|
186
|
+
},
|
|
187
|
+
"numPlayers": {
|
|
188
|
+
"type": "ctxPath",
|
|
189
|
+
"path": ["playOrder", "length"]
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}],
|
|
193
|
+
"result": {
|
|
194
|
+
"winners": {
|
|
195
|
+
"type": "mapMax",
|
|
196
|
+
"targets": {
|
|
197
|
+
"type": "ctxPath",
|
|
198
|
+
"path": ["playOrder"]
|
|
199
|
+
},
|
|
200
|
+
"mapping": {
|
|
201
|
+
"type": "count",
|
|
202
|
+
"conditions": [{
|
|
203
|
+
"conditionType": "Is",
|
|
204
|
+
"matcher": {
|
|
205
|
+
"player": {
|
|
206
|
+
"type": "contextPath",
|
|
207
|
+
"path": [ "loopTarget" ]
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}]
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}]
|
|
215
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"entities": [
|
|
3
|
+
{
|
|
4
|
+
"name": "mainGrid",
|
|
5
|
+
"entityType": "Grid",
|
|
6
|
+
"width": 3,
|
|
7
|
+
"height": 3
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
"numPlayers": 2,
|
|
11
|
+
"moves": {
|
|
12
|
+
"placePlayerMarker": {
|
|
13
|
+
"moveType": "PlaceNew",
|
|
14
|
+
"entity": {
|
|
15
|
+
"conditions": "isCurrentPlayer"
|
|
16
|
+
},
|
|
17
|
+
"arguments": {
|
|
18
|
+
"destination": {
|
|
19
|
+
"conditions": [
|
|
20
|
+
{ "entityType": "Space" },
|
|
21
|
+
"isEmpty"
|
|
22
|
+
],
|
|
23
|
+
"playerChoice": true
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"endIf": [
|
|
29
|
+
{
|
|
30
|
+
"conditions": [{
|
|
31
|
+
"conditionType": "HasLine",
|
|
32
|
+
"target": "mainGrid",
|
|
33
|
+
"sequence": [
|
|
34
|
+
{
|
|
35
|
+
"minCount": 3,
|
|
36
|
+
"conditions": [{
|
|
37
|
+
"conditionType": "ContainsSame",
|
|
38
|
+
"properties": ["player"]
|
|
39
|
+
}]
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}],
|
|
43
|
+
"result": { "winner": "ownerOfFirstResultEntity" }
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"conditions": [{
|
|
47
|
+
"conditionType": "IsFull",
|
|
48
|
+
"target": "mainGrid"
|
|
49
|
+
}],
|
|
50
|
+
"result": { "draw": true }
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { resolve } from 'path'
|
|
2
|
+
import { defineConfig } from 'vite'
|
|
3
|
+
import react from '@vitejs/plugin-react'
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
root: resolve(__dirname, 'test-app'),
|
|
7
|
+
plugins: [react()],
|
|
8
|
+
server: {
|
|
9
|
+
port: 5174,
|
|
10
|
+
},
|
|
11
|
+
resolve: {
|
|
12
|
+
alias: {
|
|
13
|
+
'board-game-engine-react': resolve(__dirname, 'dist/board-game-engine-react.js'),
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
})
|