@@ -269,7 +269,30 @@ export function interpret_discard(game, action) {
269
269
state . dda = state . deck [ order ] . identity ( ) ;
270
270
}
271
271
}
272
-
272
+ // Check if a Trash Order Chop Move happened.
273
+ if ( game . level >= LEVEL . TRASH_PUSH && ! state . inEndgame ( ) ) {
274
+ const leftmost_kt = before_trash . sort ( ( a , b ) => b - a ) [ 0 ] ;
275
+ if ( order !== leftmost_kt ) {
276
+ // check for the Shout Trash Order cm
277
+ const shout = ( common . thinksPlayables ( state , playerIndex ) . length ) > 0 ? 1 : 0 ;
278
+ const players_after = before_trash . indexOf ( order ) + shout ;
279
+ // make sure the discarded card is actually known trash
280
+ if ( players_after === - 1 || players_after >= game . players . length ) {
281
+ resolve_discard ( game , action , DISCARD_INTERP . NONE ) ;
282
+ return game ;
283
+ }
284
+ const player_to_cm = ( players_after + playerIndex ) % game . players . length ;
285
+ const player_chop = common . chop ( state . hands [ player_to_cm ] ) ;
286
+ // make sure the player has a chop
287
+ if ( player_chop === undefined ) {
288
+ resolve_discard ( game , action , DISCARD_INTERP . NONE ) ;
289
+ return game ;
290
+ }
291
+ // chop move
292
+ console . log ( player_to_cm ) ;
293
+ perform_cm ( state , common , [ player_chop ] ) ;
294
+ }
295
+ }
273
296
if ( game . level >= LEVEL . LAST_RESORTS && ! action . failed && ! state . inEndgame ( ) ) {
274
297
let interp = check_sdcm ( game , action , before_trash , old_chop ) ;
275
298
@@ -344,28 +367,7 @@ export function interpret_discard(game, action) {
344
367
return game ;
345
368
}
346
369
}
347
- // Check if a Trash Order Chop Move happened.
348
- if ( game . level >= LEVEL . TRASH_PUSH && ! state . inEndgame ( ) ) {
349
- const leftmost_kt = before_trash . sort ( ( a , b ) => b - a ) [ 0 ] ;
350
- if ( order !== leftmost_kt ) {
351
- const players_after = before_trash . indexOf ( order ) ;
352
- // make sure the discarded card is actually known trash
353
- if ( players_after === - 1 || players_after >= game . players . length ) {
354
- resolve_discard ( game , action , DISCARD_INTERP . NONE ) ;
355
- return game ;
356
- }
357
- const player_to_cm = ( players_after + playerIndex ) % game . players . length ;
358
- const player_chop = common . chop ( state . hands [ player_to_cm ] ) ;
359
- // make sure the player has a chop
360
- if ( player_chop === undefined ) {
361
- resolve_discard ( game , action , DISCARD_INTERP . NONE ) ;
362
- return game ;
363
- }
364
- // chop move
365
- console . log ( player_to_cm ) ;
366
- perform_cm ( state , common , [ player_chop ] ) ;
367
- }
368
- }
370
+
369
371
resolve_discard ( game , action , DISCARD_INTERP . NONE ) ;
370
372
return game ;
371
373
}
0 commit comments