online multiplayer chess game (note server currently down)
Diffstat (limited to 'Square.gd')
-rw-r--r--Square.gd18
1 files changed, 9 insertions, 9 deletions
diff --git a/Square.gd b/Square.gd
index f0edd80..754ec0a 100644
--- a/Square.gd
+++ b/Square.gd
@@ -12,20 +12,22 @@ onready var circle: TextureRect = $Circle
onready var move_indicator: ColorRect = $MoveIndicator
onready var premove_indicator: ColorRect = $PremoveIndicator
+var b
+
func _ready() -> void:
- move_indicator.color = Globals.grid.last_move_indicator_color
- premove_indicator.color = Globals.grid.premove_color
- mouse_default_cursor_shape = CURSOR_FORBIDDEN if Globals.spectating else CURSOR_POINTING_HAND
+ move_indicator.color = b.last_move_indicator_color
+ premove_indicator.color = b.premove_color
+ mouse_default_cursor_shape = CURSOR_FORBIDDEN if b.spectating else CURSOR_POINTING_HAND
Events.connect("turn_over", self, "clear_move_indicators")
func check_piece_above() -> bool:
- return is_instance_valid(Globals.grid.get_piece(square))
+ return is_instance_valid(b.get_piece(square))
func _gui_input(event: InputEvent):
- if !Globals.spectating and event is InputEventMouseButton and event.pressed:
+ if !b.spectating and event is InputEventMouseButton and event.pressed:
emit_signal("clicked" if event.button_index == BUTTON_LEFT else "right_clicked")
get_tree().set_input_as_handled()
@@ -36,7 +38,7 @@ func _focus_exited():
func clear_move_indicators():
if check_piece_above():
- Globals.grid.get_piece(square).background.hide()
+ b.get_piece(square).background.hide()
for m in move_indicators:
if is_instance_valid(m):
m.hide()
@@ -45,7 +47,6 @@ func clear_move_indicators():
func show_move_indicators():
clear_move_indicators()
- var b = Globals.grid
var p = b.get_piece(square)
p.background.show()
var movs = b.chess.__generate_moves({"square": square})
@@ -57,10 +58,9 @@ func show_move_indicators():
func show_premove_indicators():
clear_move_indicators()
- var b = Globals.grid
var p = b.get_piece(square)
p.background.show()
- var movs = b.chess.piece_moves(square, p.type, Globals.team, false)
+ var movs = b.chess.piece_moves(square, p.type, b.team, false)
for m in movs:
var _p = b.board[m.to]
var i = b.background_array[m.to].circle