7 var id := get_tree().get_rpc_sender_id()
8 print("PING from ", id)
12 var id := get_tree().get_rpc_sender_id()
13 print("PONG from ", id)
15 remote func move(id, x, y):
17 for child in $"pieces".get_children():
19 child.position = Vector2(x, y)
21 print("piece ", id, " not found!")
24 remote func setup() -> void:
25 print("was ordered to set up!")
29 func _onmoving(id, x, y):
30 rpc_unreliable("move", id, x, y)
33 func _onmoved(id, x, y):
37 func _addpiece(kind: String, black: bool, off: int) -> void:
39 var piece := preload("res://src/piece/piece.tscn").instance()
40 piece.setup(_ids, kind, black)
41 piece.connect("moving", self, "_onmoving")
42 piece.connect("moved", self, "_onmoved")
43 $"pieces".add_child(piece)
52 piece.position = Vector2(off, y)
55 func _on_setup_click() -> void:
59 func _place(send: bool) -> void:
63 # remove and re-place (pun intended) all the pieces
65 for child in $"pieces".get_children():
66 $"pieces".remove_child(child)
70 for i in 8: # the pawns
71 _addpiece("pawn", true, off)
72 _addpiece("pawn", false, off)
75 var row := ["rook", "knight", "bishop", "queen", "king", "bishop", "knight", "rook"]
78 _addpiece(p, true, off)
79 _addpiece(p, false, off)
83 func _fai_cose() -> void:
87 func _on_dropqueen_pressed() -> void: