25 lines
616 B
GDScript
25 lines
616 B
GDScript
extends "res://Piece.gd"
|
|
|
|
# todo castling
|
|
|
|
func setup():
|
|
kind = KIND.ROOK
|
|
var sprite2d = get_node("Sprite2D")
|
|
if team == TEAM.WHITE:
|
|
sprite2d.region_rect = Rect2(188, 8, 29, 32)
|
|
elif team == TEAM.BLACK:
|
|
sprite2d.region_rect = Rect2(188, 53, 29, 32)
|
|
|
|
func check_move(destination: Vector2i) -> bool:
|
|
var board_state = get_board_state()
|
|
if board_state.has(destination):
|
|
if board_state[destination].team == team:
|
|
return false
|
|
|
|
if !path_empty(destination):
|
|
return false
|
|
|
|
var dx = abs(destination.x - grid_pos.x)
|
|
var dy = abs(destination.y - grid_pos.y)
|
|
return min(dx, dy) == 0 and max(dx, dy) > 0
|