online multiplayer chess game (note server currently down)
(not-actually-a-fix) make it easier to un-bug the flipped pieces
| -rw-r--r-- | Log.gd | 4 | ||||
| -rw-r--r-- | networking/PacketHandler.gd | 5 | ||||
| -rw-r--r-- | piece/Piece.gd | 5 | ||||
| -rw-r--r-- | ui/board/Board.gd | 6 |
4 files changed, 13 insertions, 7 deletions
@@ -25,7 +25,9 @@ static func net(args) -> void: static func file(path: String, args) -> void: - SaveLoad.append_string(path, "(%s)%s" % [now(), to_str(args)]) + var arg_string := to_str(args) + debug(arg_string) + SaveLoad.append_string(path, "(%s)%s" % [now(), arg_string]) static func now(): diff --git a/networking/PacketHandler.gd b/networking/PacketHandler.gd index 3b87049..550eb37 100644 --- a/networking/PacketHandler.gd +++ b/networking/PacketHandler.gd @@ -137,6 +137,7 @@ func host_result(accepted) -> void: func handle_result(accepted, resultstring: String) -> bool: if typeof(accepted) == TYPE_DICTIONARY: Globals.team = "w" if accepted.idx == 0 else "b" + Log.debug("Team set to " + Utils.expand_color(Globals.team)) lobby.set_status(resultstring, true) return true lobby.set_status(accepted, false) @@ -161,8 +162,10 @@ func _start_game() -> void: lobby.toggle(false) emit_signal("start_game") lobby.set_buttons(false) + SoundFx.play("Victory") + yield(get_tree(), "idle_frame") + Log.debug("Flipping board" if Globals.team == Chess.BLACK else "Not flipping board") if Globals.team == Chess.BLACK: - yield(get_tree(), "idle_frame") board.get_board().flip_board() diff --git a/piece/Piece.gd b/piece/Piece.gd index 7e99386..0492414 100644 --- a/piece/Piece.gd +++ b/piece/Piece.gd @@ -22,6 +22,8 @@ var promote_to := "" func size() -> void: # size the control rect_size = Globals.grid.piece_size rect_position = Chess.algebraic2vec(position) * Globals.grid.piece_size + sprite.flip_v = Globals.grid.flipped + sprite.flip_h = Globals.grid.flipped func _ready(): @@ -31,9 +33,6 @@ func _ready(): frame.modulate = Globals.grid.overlay_color background.color = Globals.grid.overlay_color - sprite.flip_v = Globals.grid.flipped - sprite.flip_h = Globals.grid.flipped - if type == Chess.PAWN: popup = PopupPanel.new() popup.popup_exclusive = true diff --git a/ui/board/Board.gd b/ui/board/Board.gd index 7728f14..1da4089 100644 --- a/ui/board/Board.gd +++ b/ui/board/Board.gd @@ -64,6 +64,7 @@ func _resized(): rect_pivot_offset = (piece_size * 8) / 2 if !(board.empty() && background_array.empty()) and piece_size != old_pc: resize_board() + Log.debug("Resizing board") func _ready(): @@ -173,7 +174,6 @@ func make_piece(algebraic: String, piece_type: String, color := "w") -> void: # piece.name = "%s@%s" % [piece_type, algebraic] piece.position = algebraic piece.type = piece_type - piece.size() piece.color = color pieces.add_child(piece) # add the piece to the grid set_piece(algebraic, piece) @@ -197,9 +197,10 @@ func flip_labels() -> void: func flip_board() -> void: - flipped = !flipped rect_rotation = 0 if rect_rotation == 180 else 180 foreground.rect_rotation = rect_rotation + flipped = rect_rotation == 180 + Log.debug(["Flipped the board, now", "flipped" if flipped else "not flipped"]) sidebar.flip_panels() flip_pieces() flip_labels() @@ -222,6 +223,7 @@ func square_clicked(clicked_square: String) -> void: func move(san: String, is_recieved_move := true) -> void: + resize_board() var sound_handled = false var move_0x88 = chess.__move_from_san(san, true) var valid_moves = chess.moves({square = chess.algebraic(move_0x88.from), stripped = true}) |