Factor some lines (raw loading pug files)
[vchess.git] / client / src / variants / Titan.js
CommitLineData
b0d55a05
BA
1import { ChessRules } from "@/base_rules";
2
3export class TitanRules extends ChessRules {
4 // Idea: yellow = bishop, orange = knight (for white)
5 // and, red = bishop + purple = knight (black side)
6 // (avoid using a bigger board, or complicated drawings)
7
8 // TODO: decode if piece + bishop or knight
9 getPiece() {}
10
11 // Code: a/c = bishop + knight/bishop j/l for king,
12 // m/o for knight, s/t for queen, u/v for rook
13 static get AUGMENTED_PIECES() {
14 return {
15 // ...
16 };
17 }
18 // or:
19 getExtraPiece(symbol) {
20 // TODO: switch ... case ... return b or n
21 }
22
23 // TODO: hook after any move from 1st rank,
24 // if piece not in usual list, bishop or knight appears.
25 getPotentialMovesFrom(sq) {
26 let moves = super.getPotentialMovesFrom(sq);
27 const color = this.turn;
28 if (
29 !ChessRules.PIECES.includes(this.board[sq[0]][sq[1]][1]) &&
30 ((color == 'w' && sq[0] == 7) || (color == "b" && sq[0] == 0))
31 ) {
32 // (or lookup table)
33 const newPiece = this.getExtraPiece(this.board[sq[0]][sq[1]][1])
34 moves.forEach(m => {
35 m.appear.push(
36 new PiPo({
37 p: newPiece,
38 c: color,
39 x: sq[0],
40 y: sq[1]
41 })
42 );
43 });
44 }
45 return moves;
46 }
47
48 // TODO: special case of move 1 = choose squares, knight first, then bishop
49 // (just click ?)
50};