Skip to content

Commit

Permalink
Fix row calculation used to determine whether it is a promotion squar…
Browse files Browse the repository at this point in the history
…e. (#24)
  • Loading branch information
cdcadman authored Dec 7, 2024
1 parent 846caca commit af720e5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion javascript/work_board.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function handle_drop(event) {
let move = {from: SQUARES[from_square], to: SQUARES[square]};
const from_piece = chess.get(SQUARES[from_square])
if (from_piece.type == "p") {
let row = square % 8;
let row = Math.floor(square / 8);
if (row == 7 || row == 0) {
move["promotion"] = window.prompt("Promotion piece (q, r, b, or n)?");
}
Expand Down
6 changes: 3 additions & 3 deletions tests/test_work_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ def test_work_board(driver: BaseWebDriver):
make_move(driver, "f4", "f3", " f3")
make_move(driver, "f6", "g7", " 5. fxg7")
make_move(driver, "f3", "g2", " fxg2")
make_move(driver, "g7", "h8", " 6. gxh8=Q", "q")
make_move(driver, "g2", "h1", " gxh1=N", "n")
make_move(driver, "g7", "f8", " 6. gxf8=N", "n")
make_move(driver, "g2", "f1", " gxf1=Q+", "q")
driver.find_element(By.XPATH, "//*[@id='work_board_back']").click()
move_list = driver.find_element(By.XPATH, "//*[@id='move_list']")
WebDriverWait(driver, TIMEOUT).until(
lambda d: move_list.text.endswith("6. gxh8=Q")
lambda d: move_list.text.endswith("6. gxf8=N")
)

0 comments on commit af720e5

Please sign in to comment.