diff --git a/assets/js/hooks/chessBoard.js b/assets/js/hooks/chessBoard.js index d288ba1..4a6ae28 100644 --- a/assets/js/hooks/chessBoard.js +++ b/assets/js/hooks/chessBoard.js @@ -34,12 +34,11 @@ export const ChessBoard = { const move = this.chess.move({ from: orig, to: dest, promotion: 'q' }); if (move) { - const san = move.san this.pushEvent("move_played", { from: orig, to: dest, - san: san, - fen: this.chess.fen() + fen: this.chess.fen(), + san: move.san, }); const nextTurnColor = this.chess.turn() === 'w' ? 'white' : 'black'; diff --git a/lib/chesstrainer_web/live/chess_test_live.ex b/lib/chesstrainer_web/live/chess_test_live.ex index 017f383..08fb0fd 100644 --- a/lib/chesstrainer_web/live/chess_test_live.ex +++ b/lib/chesstrainer_web/live/chess_test_live.ex @@ -3,7 +3,7 @@ defmodule ChesstrainerWeb.ChessTestLive do @impl true def mount(_params, _session, socket) do - {:ok, assign(socket, last_move: "None yet", total_moves: 0, san: "None yet")} + {:ok, assign(socket, last_move: "None yet", san: "None yet", move_list: [])} end @impl true @@ -17,10 +17,13 @@ defmodule ChesstrainerWeb.ChessTestLive do
Last Played Move:
{@last_move}
{@san}
- -Total Moves:
-{@total_moves}
++ {if length(@move_list) == 0 do + "No Moves" + else + Enum.reverse(@move_list) |> Enum.join(", ") + end} +