Commit | Line | Data |
---|---|---|
7379efc5 BA |
1 | import ChessRules from "/base_rules.js"; |
2 | ||
3 | export default class CrossingRules extends ChessRules { | |
4 | ||
5 | getSvgChessboard() { | |
6 | let svg = super.getSvgChessboard(); | |
7 | return ( | |
8 | svg.slice(0, -6) + | |
9 | '<line x1="0" y1="40" x2="80" y2="40" ' + | |
10 | 'style="stroke:black;stroke-width:0.2"/></svg>' | |
11 | ); | |
12 | } | |
13 | ||
14 | getCurrentScore(move_s) { | |
15 | const res = super.getCurrentScore(move_s); | |
16 | if (res != "*") | |
17 | return res; | |
18 | // Turn has changed: | |
19 | const color = V.GetOppTurn(this.turn); | |
20 | const secondHalf = (color == 'w' ? [0, 1, 2, 3] : [4, 5, 6, 7]); | |
21 | for (let move of move_s) { | |
22 | if ( | |
23 | move.appear.length >= 1 && | |
24 | move.appear[0].p == 'k' && | |
25 | secondHalf.includes(move.appear[0].x) | |
26 | ) { | |
27 | // Half-board is crossed | |
28 | return color == "w" ? "1-0" : "0-1"; | |
29 | } | |
30 | } | |
31 | return "*"; | |
32 | } | |
33 | ||
34 | }; |