defmodule ChesstrainerWeb.ChessTestLive do use ChesstrainerWeb, :live_view @impl true def mount(_params, _session, socket) do {:ok, assign(socket, last_move: "None yet", total_moves: 0, san: "None yet")} end @impl true def render(assigns) do ~H"""

Chessground LiveView Test

Last Played Move:

{@last_move}

{@san}

Total Moves:

{@total_moves}

""" end @impl true def handle_event( "move_played", %{"from" => from, "to" => to, "fen" => _fen, "san" => san}, socket ) do {:noreply, socket |> assign(:last_move, "#{from} ➔ #{to}") |> assign(:san, san) |> assign(:total_moves, socket.assigns.total_moves + 1)} end end