Skip to content

Commit

Permalink
only show promotion table if move could be legal
Browse files Browse the repository at this point in the history
  • Loading branch information
fohristiwhirl committed Jun 24, 2019
1 parent c0b1f67 commit 33c0b38
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions 95_renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function NewRenderer() {

if (typeof s !== "string") {
console.log(`renderer.move(${s}) - bad argument`);
return false;
return;
}

let board = this.node.get_board();
Expand All @@ -69,12 +69,13 @@ function NewRenderer() {

if (s.length === 4) {
let source = Point(s.slice(0, 2));
if (board.piece(source) === "P" && source.y === 1) {
this.show_promotiontable(s);
return;
}
if (board.piece(source) === "p" && source.y === 6) {
this.show_promotiontable(s);
if ((board.piece(source) === "P" && source.y === 1) || (board.piece(source) === "p" && source.y === 6)) {
let illegal_reason = board.illegal(s + "q");
if (illegal_reason !== "") {
console.log(`renderer.move(${s}) - ${illegal_reason}`);
} else {
this.show_promotiontable(s);
}
return;
}
}
Expand All @@ -84,12 +85,12 @@ function NewRenderer() {
let illegal_reason = board.illegal(s);
if (illegal_reason !== "") {
console.log(`renderer.move(${s}) - ${illegal_reason}`);
return false;
return;
}

this.node = this.node.make_move(s);
this.position_changed();
return true;
return;
};

renderer.play_info_index = function(n) {
Expand Down

0 comments on commit 33c0b38

Please sign in to comment.