19 lines
515 B
GDScript
19 lines
515 B
GDScript
extends "res://Piece.gd"
|
|
|
|
func setup():
|
|
kind = KIND.KING
|
|
var sprite2d = get_node("Sprite2D")
|
|
if team == TEAM.WHITE:
|
|
sprite2d.region_rect = Rect2(5, 5, 35, 36)
|
|
elif team == TEAM.BLACK:
|
|
sprite2d.region_rect = Rect2(5, 50, 35, 36)
|
|
|
|
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
|
|
# TODO castling
|
|
|
|
return abs(destination.x - grid_pos.x) + abs(destination.y - grid_pos.y) == 1
|