ChessBuilder/addons/Chess/Scripts/Bishop.gd

51 lines
1.2 KiB
GDScript

@tool
extends Pawn
class_name Bishop
func _ready():
self.texture = load("res://addons/Chess/Textures/WBishop.svg")
Points = 3
original_movement_string = "B"
current_movement_string = original_movement_string
func _process(_delta):
if Item_Color != Temp_Color:
Temp_Color = Item_Color
if Item_Color == 0:
self.texture = load("res://addons/Chess/Textures/WBishop.svg")
elif Item_Color == 1:
self.texture = load("res://addons/Chess/Textures/BBishop.svg")
# func getValidMoves(board_flow, current_location: String) -> Dictionary:
# var moves = {
# "regular_moves": [],
# "special_moves": []
# }
# var loc = current_location.split("-")
# var x = int(loc[0])
# var y = int(loc[1])
# # Bishop moves diagonally
# var diagonal_dirs = [[1,1], [1,-1], [-1,1], [-1,-1]]
# for dir in diagonal_dirs:
# var curr_x = x
# var curr_y = y
# while true:
# curr_x += dir[0]
# curr_y += dir[1]
# var new_loc = str(curr_x) + "-" + str(curr_y)
# if !is_valid_cell(board_flow, new_loc):
# break
# if can_move_to_cell(board_flow, new_loc):
# moves.regular_moves.append(new_loc)
# elif can_move_to_cell(board_flow, new_loc, true):
# moves.regular_moves.append(new_loc)
# break
# else:
# break
# return moves