From 5220ac5823de6dfb7ddc5112e5a247d70c89d715 Mon Sep 17 00:00:00 2001 From: Simponic Date: Wed, 25 Jan 2023 12:58:02 -0700 Subject: Fix initial render when game joined by creating new state in genserver init, also some more color changes --- lib/chessh/ssh/client/game/game.ex | 20 ++++++++++---------- lib/chessh/ssh/client/game/renderer.ex | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'lib/chessh/ssh/client/game') diff --git a/lib/chessh/ssh/client/game/game.ex b/lib/chessh/ssh/client/game/game.ex index 4e2f6ae..6d107e6 100644 --- a/lib/chessh/ssh/client/game/game.ex +++ b/lib/chessh/ssh/client/game/game.ex @@ -96,22 +96,22 @@ defmodule Chessh.SSH.Client.Game do end binbo_pid = initialize_game(game_id, fen) - new_game = Repo.get(Game, game_id) |> Repo.preload([:light_player, :dark_player]) player_color = if(new_game.light_player_id == player_session.player_id, do: :light, else: :dark) - send(client_pid, {:send_to_ssh, Utils.clear_codes()}) + new_state = %State{ + state + | binbo_pid: binbo_pid, + color: player_color, + game: new_game, + flipped: player_color == :dark + } - {:ok, - %State{ - state - | binbo_pid: binbo_pid, - color: player_color, - game: new_game, - flipped: player_color == :dark - }} + send(client_pid, {:send_to_ssh, [Utils.clear_codes() | render_state(new_state)]}) + + {:ok, new_state} end def init([ diff --git a/lib/chessh/ssh/client/game/renderer.ex b/lib/chessh/ssh/client/game/renderer.ex index 5b85a3b..161780a 100644 --- a/lib/chessh/ssh/client/game/renderer.ex +++ b/lib/chessh/ssh/client/game/renderer.ex @@ -10,10 +10,10 @@ defmodule Chessh.SSH.Client.Game.Renderer do @tile_height 4 @previous_move_background ANSI.light_yellow_background() - @from_select_background ANSI.light_green_background() - @to_select_background ANSI.green_background() - @dark_piece_color ANSI.light_red() - @light_piece_color ANSI.light_blue() + @from_select_background ANSI.light_magenta_background() + @to_select_background ANSI.light_magenta_background() + @dark_piece_color ANSI.red() + @light_piece_color ANSI.light_cyan() def chess_board_height(), do: @chess_board_height def chess_board_width(), do: @chess_board_width -- cgit v1.2.3-70-g09d2