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/game.ex | |
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/game.ex')
-rw-r--r-- | lib/chessh/ssh/client/game/game.ex | 20 |
1 files changed, 10 insertions, 10 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([ |