online multiplayer chess game (note server currently down)
fix castling for O-O-O
bendn 2022-05-18
parent 73f83db · commit 5fe8e90
-rw-r--r--Grid.gd5
-rw-r--r--pieces/King.gd8
2 files changed, 5 insertions, 8 deletions
diff --git a/Grid.gd b/Grid.gd
index 3a8367f..ef993bc 100644
--- a/Grid.gd
+++ b/Grid.gd
@@ -62,11 +62,6 @@ func _exit_tree() -> void:
func _input(event) -> void: # input
if event.is_action_released("debug"): # if debug
print_matrix_pretty(matrix) # print the matrix
- if event.is_action_released("kill"):
- if last_clicked and OS.is_debug_build(): # last clicked isnt null and were in debug
- last_clicked.took() # kill the piece
- last_clicked = null
- clear_fx() # clear the circles
static func print_matrix_pretty(mat) -> void: # print the matrix
diff --git a/pieces/King.gd b/pieces/King.gd
index 3e438c9..8e9ba58 100644
--- a/pieces/King.gd
+++ b/pieces/King.gd
@@ -62,10 +62,12 @@ func castleing(justcheckrooks = false) -> Array:
var direction: Vector2 = king_moveto_spots[i]
var posx2: Vector2 = pos_around(direction * 2)
var pos: Vector2 = pos_around(direction)
- if at_pos(posx2) or at_pos(pos):
- continue
- if checkcheck(posx2) or checkcheck(pos):
+ if at_pos(posx2) or at_pos(pos) or checkcheck(posx2) or checkcheck(pos):
continue
+ if i == 1: # 3x check for O-O-O
+ var posx3 := pos_around(direction * 3)
+ if at_pos(posx3) or checkcheck(posx3):
+ continue
can_castle.append([posx2, rook, rook_motion[i], "O-O-O" if i == 1 else "O-O"])
moves.append(posx2)
return moves