summaryrefslogtreecommitdiff
path: root/Main.gd
diff options
context:
space:
mode:
authorjake <jake@jakes-mail.top>2023-02-18 16:48:07 -0500
committerjake <jake@jakes-mail.top>2023-02-18 16:48:07 -0500
commitd98b3130068c36438f419353cc28d12b9b7333fe (patch)
treec10e6637d7b82d0dee3e28e207f48a43d33ad9e1 /Main.gd
parent4b9191e4819a79636ba4a68b7dd9850e622ed40f (diff)
en passant bug fix; don't check out of bounds
Diffstat (limited to 'Main.gd')
-rw-r--r--Main.gd14
1 files changed, 8 insertions, 6 deletions
diff --git a/Main.gd b/Main.gd
index 059e2d3..2fc0d1d 100644
--- a/Main.gd
+++ b/Main.gd
@@ -233,9 +233,10 @@ func can_chess_move(pattern, coords):
if pawn_maybe and pawn_maybe.get_piece() == "pawn" and pawn_maybe == en_passant_pawn and pawn_maybe.get_team() != curr_team:
if make_tiles(coords, [-1,1], 1, true, curr_team, {"en_passant_pawn": pawn_maybe}): can_move = true
en_passent_se:
- var pawn_maybe = board[coords[0]+1][coords[1]]
- if pawn_maybe and pawn_maybe.get_piece() == "pawn" and pawn_maybe == en_passant_pawn and pawn_maybe.get_team() != curr_team:
- if make_tiles(coords, [1,1], 1, true, curr_team, {"en_passant_pawn": pawn_maybe}): can_move = true
+ if ! coords[0] + 1 > BOARD_WIDTH:
+ var pawn_maybe = board[coords[0]+1][coords[1]]
+ if pawn_maybe and pawn_maybe.get_piece() == "pawn" and pawn_maybe == en_passant_pawn and pawn_maybe.get_team() != curr_team:
+ if make_tiles(coords, [1,1], 1, true, curr_team, {"en_passant_pawn": pawn_maybe}): can_move = true
move_1_up_pawn:
if make_tiles(coords, [0,-1], 1, true, curr_team): can_move = true
@@ -252,9 +253,10 @@ func can_chess_move(pattern, coords):
if pawn_maybe and pawn_maybe.get_piece() == "pawn" and pawn_maybe == en_passant_pawn and pawn_maybe.get_team() != curr_team:
if make_tiles(coords, [-1,-1], 1, true, curr_team, {"en_passant_pawn": pawn_maybe}): can_move = true
en_passent_ne:
- var pawn_maybe = board[coords[0]+1][coords[1]]
- if pawn_maybe and pawn_maybe.get_piece() == "pawn" and pawn_maybe == en_passant_pawn and pawn_maybe.get_team() != curr_team:
- if make_tiles(coords, [1,-1], 1, true, curr_team, {"en_passant_pawn": pawn_maybe}): can_move = true
+ if ! coords[0] + 1 > BOARD_WIDTH:
+ var pawn_maybe = board[coords[0]+1][coords[1]]
+ if pawn_maybe and pawn_maybe.get_piece() == "pawn" and pawn_maybe == en_passant_pawn and pawn_maybe.get_team() != curr_team:
+ if make_tiles(coords, [1,-1], 1, true, curr_team, {"en_passant_pawn": pawn_maybe}): can_move = true
move_up_inf:
if make_tiles(coords, [0,-1], BOARD_HEIGHT, false, curr_team): can_move =true