@@ -302,7 +302,7 @@ export class Pigs2Game extends GameBaseSimultaneous {
302302 return false ;
303303 }
304304
305- public move ( m : string , { trusted = false } = { } ) : Pigs2Game {
305+ public move ( m : string , { trusted = false , partial = false } = { } ) : Pigs2Game {
306306 if ( this . gameover ) {
307307 throw new UserFacingError ( "MOVES_GAMEOVER" , i18next . t ( "apgames:MOVES_GAMEOVER" ) ) ;
308308 }
@@ -311,7 +311,7 @@ export class Pigs2Game extends GameBaseSimultaneous {
311311 throw new UserFacingError ( "MOVES_SIMULTANEOUS_PARTIAL" , i18next . t ( "apgames:MOVES_SIMULTANEOUS_PARTIAL" ) ) ;
312312 }
313313 for ( let i = 0 ; i < moves . length ; i ++ ) {
314- if ( ( moves [ i ] === undefined ) || ( moves [ i ] === "" ) ) {
314+ if ( ( partial ) && ( ( moves [ i ] === undefined ) || ( moves [ i ] === "" ) ) ) {
315315 continue ;
316316 }
317317 moves [ i ] = moves [ i ] . toLowerCase ( ) ;
@@ -336,6 +336,8 @@ export class Pigs2Game extends GameBaseSimultaneous {
336336
337337 // first store the received orders
338338 for ( let p = 0 ; p < this . numplayers ; p ++ ) {
339+ // if partial, ignore blank moves
340+ if ( partial && ( moves [ p ] === "" || moves [ p ] === undefined ) ) { continue ; }
339341 // ignore eliminated players
340342 if ( this . isEliminated ( p + 1 ) ) { continue ; }
341343 if ( this . stack . length === 1 ) {
@@ -515,6 +517,8 @@ export class Pigs2Game extends GameBaseSimultaneous {
515517 this . results . push ( { type : "_group" , who : i + 1 , results : resultGroups [ i ] as [ APMoveResult , ...APMoveResult [ ] ] } ) ;
516518 }
517519
520+ if ( partial ) { return this ; }
521+
518522 this . lastmove = [ ...parsed ] . join ( ',' ) . toUpperCase ( ) . replace ( / V / g, "v" ) ;
519523 this . checkEOG ( ) ;
520524 this . saveState ( ) ;
@@ -678,7 +682,7 @@ export class Pigs2Game extends GameBaseSimultaneous {
678682 const areas : AreaPieces [ ] = [ ] ;
679683 for ( let p = 1 ; p <= this . numplayers ; p ++ ) {
680684 const order = this . orders [ p - 1 ] ;
681- if ( order !== null && order !== undefined && Array . isArray ( order ) && order . length > 0 ) {
685+ if ( Array . isArray ( order ) && order . length > 0 ) {
682686 areas . push ( {
683687 type : "pieces" ,
684688 pieces : order . map ( c => cmd2glyph . get ( c ) ! ) as [ string , ...string [ ] ] ,
0 commit comments