1 import { MakrukRules
} from "@/variants/Makruk";
3 export class MakpongRules
extends MakrukRules
{
6 const color
= this.turn
;
7 if (!this.underCheck(color
)) return super.filterValid(moves
);
8 // Filter out all moves involving king, except for capturing a
10 const pawnAttack
= (color
== 'w' ? -1 : 1);
11 return super.filterValid(moves
.filter(m
=> {
12 const p
= (m
.vanish
.length
== 2 ? m
.vanish
[1].p : null);
14 m
.vanish
[0].p
!= V
.KING
||
16 m
.vanish
.length
== 2 &&
20 m
.end
.x
- m
.start
.x
== pawnAttack
&&
21 Math
.abs(m
.end
.y
- m
.start
.y
) == 1
26 (m
.end
.x
== m
.start
.x
|| m
.end
.y
== m
.start
.y
)
30 [V
.PROMOTED
, V
.QUEEN
].includes(p
) &&
31 m
.end
.x
!= m
.start
.x
&& m
.end
.y
!= m
.start
.y
37 m
.end
.x
- m
.start
.x
== pawnAttack
||
39 m
.end
.x
- m
.start
.x
== -pawnAttack
&&
40 Math
.abs(m
.end
.y
- m
.start
.y
) == 1