Skip to content

Commit 77396b3

Browse files
fixup - rename lifting -> removing
1 parent 7698a43 commit 77396b3

File tree

1 file changed

+18
-35
lines changed

1 file changed

+18
-35
lines changed

src/merelsMachine.ts

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -71,36 +71,35 @@ export const merelsMachine = createMachine(
7171
type: 'place',
7272
params: {},
7373
},
74-
target: 'Lifting',
74+
target: 'Removing',
7575
reenter: false,
7676
},
7777
{
7878
actions: [
7979
{ type: 'place' },
80-
{ type: 'increment' },
8180
{ type: 'swap' },
8281
],
8382
reenter: true,
8483
},
8584
],
8685
},
8786
},
88-
Lifting: {
87+
Removing: {
8988
on: {
9089
'point.click': [
9190
{
9291
guard:
93-
'invalid lift (empty space || occupied by self || occupied by opponent locked in mill)',
92+
'invalid removal (empty space || occupied by self || occupied by opponent locked in mill)',
9493
reenter: true,
9594
},
9695
{
9796
guard: 'all pieces have not yet been placed',
98-
actions: [{ type: 'lift' }, { type: 'swap' }],
97+
actions: [{ type: 'remove' }, { type: 'swap' }],
9998
target: 'Placing',
10099
reenter: false,
101100
},
102101
{
103-
actions: [{ type: 'lift' }, { type: 'swap' }],
102+
actions: [{ type: 'remove' }, { type: 'swap' }],
104103
target: '#merels 1.Moving.Selecting',
105104
reenter: false,
106105
},
@@ -146,7 +145,7 @@ export const merelsMachine = createMachine(
146145
},
147146
'valid place': [
148147
{
149-
target: 'Lifting',
148+
target: 'Removing',
150149
guard: 'mill is formed',
151150
reenter: false,
152151
},
@@ -157,27 +156,27 @@ export const merelsMachine = createMachine(
157156
],
158157
},
159158
},
160-
Lifting: {
159+
Removing: {
161160
on: {
162-
'valid lift': [
161+
'valid removal': [
163162
{
164163
target: '[STATE] swap players',
165-
guard: 'opponent has more than 3 pieces remaining after lift',
164+
guard: 'opponent has more than 3 pieces remaining after removal',
166165
reenter: false,
167166
},
168167
{
169168
target: '[STATE] opponent is now flying',
170-
guard: 'opponent has 3 pieces remaining after lift',
169+
guard: 'opponent has 3 pieces remaining after removal',
171170
reenter: false,
172171
},
173172
{
174173
target: 'Active player wins, Opponent loses',
175174
reenter: false,
176175
},
177176
],
178-
'invalid lift (empty space || occupied by self || occupied by opponent locked in mill)':
177+
'invalid removal (empty space || occupied by self || occupied by opponent locked in mill)':
179178
{
180-
target: 'Lifting',
179+
target: 'Removing',
181180
reenter: false,
182181
},
183182
},
@@ -200,11 +199,8 @@ export const merelsMachine = createMachine(
200199
test: ({ action }) => {
201200
// console.log(action.params);
202201
},
203-
increment: ({ action }) => {
204-
console.log('increment');
205-
},
206-
lift: ({ action }) => {
207-
console.log('lift');
202+
remove: ({ action }) => {
203+
console.log('remove');
208204
},
209205
place: assign({
210206
boards: ({ context: { boards, turn }, event: { aplIndex } }) => ({
@@ -220,29 +216,16 @@ export const merelsMachine = createMachine(
220216
guards: {
221217
'point is occupied': ({ event: { pieceAtPoint } }) => !!pieceAtPoint,
222218
'form mill': ({ context: { boards, turn }, event: { aplIndex } }) => {
223-
// console.log('guard: form mill', boards, turn, aplIndex);
224-
225-
// TODO determine if this forms a mill. If so, return true. Otherwise,
226-
// return false and then let the next event else happen
227-
228219
const previousNumberOfMills = getNumberOfMills(boards[turn]);
229-
// console.log('previousNumberOfMills', previousNumberOfMills);
230-
231220
const boardAfterPlace = aplPlacePiece(boards[turn], aplIndex);
232-
// console.log('boardAfterPlace', boardAfterPlace);
233-
234221
const newNumberOfMills = getNumberOfMills(boardAfterPlace);
235-
// console.log('newNumberOfMills', newNumberOfMills);
236-
237222
const isMillFormed = newNumberOfMills > previousNumberOfMills;
238-
// console.log('isMillFormed', isMillFormed);
239-
240223
return isMillFormed;
241224
},
242-
'invalid lift (empty space || occupied by self || occupied by opponent locked in mill)':
225+
'invalid removal (empty space || occupied by self || occupied by opponent locked in mill)':
243226
({ event: { boards, pieceAtPoint, turn }, event: { aplIndex } }) => {
244227
console.log(
245-
'invalid lift (empty space || occupied by self || occupied by opponent locked in mill)',
228+
'invalid removal (empty space || occupied by self || occupied by opponent locked in mill)',
246229
boards,
247230
pieceAtPoint,
248231
turn,
@@ -269,8 +252,8 @@ export const merelsMachine = createMachine(
269252
return numPiecesPlaced < 18;
270253
},
271254
'mill is formed': createMachine({}),
272-
'opponent has more than 3 pieces remaining after lift': createMachine({}),
273-
'opponent has 3 pieces remaining after lift': createMachine({}),
255+
'opponent has more than 3 pieces remaining after removal': createMachine({}),
256+
'opponent has 3 pieces remaining after removal': createMachine({}),
274257
},
275258
delays: {},
276259
}

0 commit comments

Comments
 (0)