@@ -214,3 +214,105 @@ describe('premove() test', () => {
214
214
expect ( premoves ) . to . have . members ( expected ) ;
215
215
} ) ;
216
216
} ) ;
217
+
218
+ describe ( 'premove() test' , ( ) => {
219
+ it ( 'breakthroughTroyka pawns can premove forward diagonally and in front of them when there is no piece' , ( ) => {
220
+ const state = defaults ( ) as State ;
221
+ configure ( state , {
222
+ dimensions : { width : 8 , height : 8 } ,
223
+ variant : 'breakthroughtroyka' ,
224
+ fen : 'pppppppp/pppppppp/8/8/8/8/PPPPPPPP/PPPPPPPP' ,
225
+ } ) ;
226
+
227
+ const expected = [ 'e6' , 'f6' , 'g6' ] ;
228
+ const premoves = premove (
229
+ state . pieces ,
230
+ 'f7' ,
231
+ state . premovable . castle ,
232
+ state . dimensions ,
233
+ state . variant ,
234
+ state . chess960
235
+ ) ;
236
+ expect ( premoves ) . to . have . members ( expected ) ;
237
+ } ) ;
238
+
239
+ it ( 'breakthroughTroyka pawns on the edge can not premove outside the board' , ( ) => {
240
+ const state = defaults ( ) as State ;
241
+ configure ( state , {
242
+ dimensions : { width : 8 , height : 8 } ,
243
+ variant : 'breakthroughtroyka' ,
244
+ fen : 'pppppppp/pppppppp/8/8/8/8/PPPPPPPP/PPPPPPPP' ,
245
+ } ) ;
246
+
247
+ const expected = [ 'g6' , 'h6' ] ;
248
+ const premoves = premove (
249
+ state . pieces ,
250
+ 'h7' ,
251
+ state . premovable . castle ,
252
+ state . dimensions ,
253
+ state . variant ,
254
+ state . chess960
255
+ ) ;
256
+ expect ( premoves ) . to . have . members ( expected ) ;
257
+ } ) ;
258
+
259
+ it ( 'breakthroughTroyka pawns can premove to opponent pawn in front of them' , ( ) => {
260
+ const state = defaults ( ) as State ;
261
+ configure ( state , {
262
+ dimensions : { width : 8 , height : 8 } ,
263
+ variant : 'breakthroughtroyka' ,
264
+ fen : 'pppppppp/ppp1pppp/8/4p3/4P3/8/PPPP1PPP/PPPPPPPP' ,
265
+ } ) ;
266
+
267
+ const expected = [ 'd4' , 'e4' , 'f4' ] ;
268
+ const premoves = premove (
269
+ state . pieces ,
270
+ 'e5' ,
271
+ state . premovable . castle ,
272
+ state . dimensions ,
273
+ state . variant ,
274
+ state . chess960
275
+ ) ;
276
+ expect ( premoves ) . to . have . members ( expected ) ;
277
+ } ) ;
278
+
279
+ it ( 'breakthroughTroyka pawns can not premove to friendly pawn in front of them' , ( ) => {
280
+ const state = defaults ( ) as State ;
281
+ configure ( state , {
282
+ dimensions : { width : 8 , height : 8 } ,
283
+ variant : 'breakthroughtroyka' ,
284
+ fen : 'pppppppp/ppp1p1pp/4p3/4p3/4P3/4P3/PPP2PPP/PPPPPPPP' ,
285
+ } ) ;
286
+
287
+ const expected = [ 'd5' , 'f5' ] ;
288
+ const premoves = premove (
289
+ state . pieces ,
290
+ 'e6' ,
291
+ state . premovable . castle ,
292
+ state . dimensions ,
293
+ state . variant ,
294
+ state . chess960
295
+ ) ;
296
+ expect ( premoves ) . to . have . members ( expected ) ;
297
+ } ) ;
298
+
299
+ it ( 'breakthroughTroyka pawns can premove to friendly and opponent pawn in diagonal' , ( ) => {
300
+ const state = defaults ( ) as State ;
301
+ configure ( state , {
302
+ dimensions : { width : 8 , height : 8 } ,
303
+ variant : 'breakthroughtroyka' ,
304
+ fen : 'pppppppp/ppp1p1pp/8/4p3/3pPP2/4P3/PPP3PP/PPPPPPPP' ,
305
+ } ) ;
306
+
307
+ const expected = [ 'd4' , 'e4' , 'f4' ] ;
308
+ const premoves = premove (
309
+ state . pieces ,
310
+ 'e5' ,
311
+ state . premovable . castle ,
312
+ state . dimensions ,
313
+ state . variant ,
314
+ state . chess960
315
+ ) ;
316
+ expect ( premoves ) . to . have . members ( expected ) ;
317
+ } ) ;
318
+ } ) ;
0 commit comments