X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=variants%2FMadrasi%2Fclass.js;fp=variants%2FMadrasi%2Fclass.js;h=eaabf07e38932c5889d1cdca7da8dc80ff98a687;hb=57b8015b5c22ccfd419df11b9d0174484397c417;hp=0000000000000000000000000000000000000000;hpb=c9ab034035a3cac65e4ac9f48a946ecef5ed111e;p=xogo.git diff --git a/variants/Madrasi/class.js b/variants/Madrasi/class.js new file mode 100644 index 0000000..eaabf07 --- /dev/null +++ b/variants/Madrasi/class.js @@ -0,0 +1,38 @@ +import ChessRules from "/base_rules.js"; + +export default class MadrasiRules extends ChessRules { + + static get Options() { + return { + select: C.Options.select, + check: [ + { + label: "Rex Incl.", + defaut: false, + variable: "rexincl" + } + ].concat(C.Options.check), + styles: C.Options.styles.filter(s => s != "madrasi") + }; + } + + constructor(o) { + o.options["madrasi"] = true; + super(o); + } + + underCheck([x, y], color) { + if (this.options["rexincl"]) { + // If Rex Inclusive, kings do not check each other: + // we just replace it very temporarily. + const [ox, oy] = this.searchKingPos(color); + const saveOppKing = this.board[ox][oy]; + this.board[ox][oy] = C.GetOppCol(color) + "q"; //arbitrary + const res = super.underCheck([x, y], color); + this.board[ox][oy] = saveOppKing; + return res; + } + return super.underCheck([x, y], color); + } + +};