diff options
author | Elizabeth (Lizzy) Hunt <elizabeth.hunt@simponic.xyz> | 2023-04-22 23:32:55 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-22 23:32:55 -0600 |
commit | f5773f606a738e092845597f2af77e9602b06552 (patch) | |
tree | f5611aa4fef4c5d972f18451e2127762ffd54bd7 /lib/chessh/ssh/client | |
parent | fb1825e964ee5ebb8427c56eaa34e9437c56c5ab (diff) | |
download | chessh-f5773f606a738e092845597f2af77e9602b06552.tar.gz chessh-f5773f606a738e092845597f2af77e9602b06552.zip |
README changes, create thread on join, update package-lock (#21)
Diffstat (limited to 'lib/chessh/ssh/client')
-rw-r--r-- | lib/chessh/ssh/client/game/game.ex | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/chessh/ssh/client/game/game.ex b/lib/chessh/ssh/client/game/game.ex index cd641f0..4ac0f31 100644 --- a/lib/chessh/ssh/client/game/game.ex +++ b/lib/chessh/ssh/client/game/game.ex @@ -32,7 +32,10 @@ defmodule Chessh.SSH.Client.Game do def init([ %State{ color: color, - game: %Game{dark_player_id: dark_player_id, light_player_id: light_player_id}, + game: %Game{ + dark_player_id: dark_player_id, + light_player_id: light_player_id + }, player_session: %{player_id: player_id} } = state | tail @@ -47,7 +50,6 @@ defmodule Chessh.SSH.Client.Game do else case {is_nil(dark_player_id), is_nil(light_player_id)} do {true, false} -> %State{state | color: :dark} - {false, true} -> %State{state | color: :light} {_, _} -> %State{state | color: :light} end end @@ -210,6 +212,12 @@ defmodule Chessh.SSH.Client.Game do :player_joined, %State{client_pid: client_pid, game: %Game{id: game_id}} = state ) do + GenServer.cast( + :discord_notifier, + {:schedule_notification, {:player_joined, game_id}, + Application.get_env(:chessh, DiscordNotifications)[:game_player_joined_notif_delay_ms]} + ) + game = Repo.get(Game, game_id) |> Repo.preload([:light_player, :dark_player]) new_state = %State{state | game: game} send(client_pid, {:send_to_ssh, Renderer.render_board_state(new_state)}) |