summaryrefslogtreecommitdiff
path: root/lib/chessh/schema/player.ex
diff options
context:
space:
mode:
authorLogan Hunt <loganhunt@simponic.xyz>2023-01-17 14:00:18 -0700
committerGitHub <noreply@github.com>2023-01-17 14:00:18 -0700
commitbdf99b4ee989df1813745e1dfd2983689b09ca85 (patch)
treef2c1c52cc2d51019b742800c24d5761f32495b95 /lib/chessh/schema/player.ex
parent53be77e2c57bac6b861d7c3d1d2d6355816a823b (diff)
downloadchessh-bdf99b4ee989df1813745e1dfd2983689b09ca85.tar.gz
chessh-bdf99b4ee989df1813745e1dfd2983689b09ca85.zip
Persistent game (#5)
* Remove unnecessary server in board * Initial persistent games * Remove done chessh README stuff, warning issue * Show current players and move * Add promotion * Merge default changeset on all status
Diffstat (limited to 'lib/chessh/schema/player.ex')
-rw-r--r--lib/chessh/schema/player.ex5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/chessh/schema/player.ex b/lib/chessh/schema/player.ex
index 8eaffee..074ea4e 100644
--- a/lib/chessh/schema/player.ex
+++ b/lib/chessh/schema/player.ex
@@ -1,6 +1,7 @@
defmodule Chessh.Player do
use Ecto.Schema
import Ecto.Changeset
+ alias Chessh.{Key, Game}
@derive {Inspect, except: [:password]}
schema "players" do
@@ -11,7 +12,9 @@ defmodule Chessh.Player do
field(:authentications, :integer, default: 0)
- has_many(:keys, Chessh.Key)
+ has_many(:keys, Key)
+ has_many(:light_games, Game, foreign_key: :light_player_id, references: :id)
+ has_many(:dark_games, Game, foreign_key: :dark_player_id, references: :id)
timestamps()
end