diff --git a/.gitignore b/.gitignore
index b3b547a..d8df129 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,7 +37,3 @@ chesstrainer-*.tar
# In case you use Node.js/npm, you want to ignore these.
npm-debug.log
/assets/node_modules/
-
-
-# graft's local graph cache — regenerable, not committed (run `graft build`).
-graft/
diff --git a/lib/chesstrainer_web/live/endgame_live/play.ex b/lib/chesstrainer_web/live/endgame_live/play.ex
index cca5edf..db3e399 100644
--- a/lib/chesstrainer_web/live/endgame_live/play.ex
+++ b/lib/chesstrainer_web/live/endgame_live/play.ex
@@ -10,7 +10,7 @@ defmodule ChesstrainerWeb.EndgameLive.Play do
<.header>
Play endgame {@endgame.key}
<:subtitle>
- {@endgame.color} to move · Result: {@endgame.result} · Rating: {@endgame.rating}
+ {@endgame.color |> Atom.to_string() |> String.capitalize()} to move · Rating: {@endgame.rating}
<:actions>
<.button navigate={~p"/endgames"}>
@@ -19,44 +19,45 @@ defmodule ChesstrainerWeb.EndgameLive.Play do
-
-
-
Last Played Move:
-
{@last_from_to}
-
{@last_san}
-
- {if @move_list == [] do
- "No Moves"
- else
- Enum.reverse(@move_list) |> Enum.join(", ")
- end}
-
-
-
- <.button phx-click="reset" variant="primary">
- <.icon name="hero-arrow-path" /> Reset
-
-
-
-
-
+
- <.list>
- <:item title="Fen">{@endgame.fen}
- <:item title="Key">{@endgame.key}
- <:item title="Color">{@endgame.color}
- <:item title="Result">{@endgame.result}
- <:item title="Rating">{@endgame.rating}
-
+
+
+
Moves:
+
+ <%= if @move_list == [] do %>
+
No Moves
+ <% else %>
+ <%= for {[white_move, black_move], i} <- format_move_pairs(@move_list, @endgame.color) do %>
+
+ {i}.
+ {white_move || "..."}
+ <%= if black_move do %>
+ {black_move}
+ <% end %>
+
+ <% end %>
+ <% end %>
+
+
+
+
Buttons
+
+
+ <.button phx-click="reset" variant="primary">
+ <.icon name="hero-arrow-path" /> Reset
+
+
+
+
"""
end
@@ -92,7 +93,7 @@ defmodule ChesstrainerWeb.EndgameLive.Play do
socket
|> assign(:last_from_to, "#{from} ➔ #{to}")
|> assign(:last_san, san)
- |> assign(:move_list, [san | socket.assigns.move_list])}
+ |> assign(:move_list, socket.assigns.move_list ++ [san])}
end
def handle_event("chess_fen_invalid", %{"fen" => fen, "message" => message}, socket) do
@@ -116,4 +117,12 @@ defmodule ChesstrainerWeb.EndgameLive.Play do
player_color: Atom.to_string(socket.assigns.endgame.color)
})}
end
+
+ def format_move_pairs(move_list, color) do
+ moves = if color in [:black, "black"], do: [nil | move_list], else: move_list
+
+ moves
+ |> Enum.chunk_every(2, 2, [nil])
+ |> Enum.with_index(1)
+ end
end