diff options
author | Simponic <loganhunt@simponic.xyz> | 2023-01-25 12:58:02 -0700 |
---|---|---|
committer | Simponic <loganhunt@simponic.xyz> | 2023-01-25 12:58:02 -0700 |
commit | 5220ac5823de6dfb7ddc5112e5a247d70c89d715 (patch) | |
tree | b7dd59b0b6005559f0760a4fc364b91b1f41c030 /lib/chessh/ssh/client/game | |
parent | ab5fc4a077eadcc3dfd28c3af89a762711a6b6b4 (diff) | |
download | chessh-5220ac5823de6dfb7ddc5112e5a247d70c89d715.tar.gz chessh-5220ac5823de6dfb7ddc5112e5a247d70c89d715.zip |
Fix initial render when game joined by creating new state in genserver init, also some more color changes
Diffstat (limited to 'lib/chessh/ssh/client/game')
-rw-r--r-- | lib/chessh/ssh/client/game/game.ex | 20 | ||||
-rw-r--r-- | lib/chessh/ssh/client/game/renderer.ex | 8 |
2 files changed, 14 insertions, 14 deletions
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 |