summaryrefslogtreecommitdiff
path: root/lib/chessh/ssh/screens/board.ex
blob: c95049f5cafb1ec493261e621c4a81cc2fe13cf1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
defmodule Chessh.SSH.Client.Board do
  alias Chessh.SSH.Client
  alias IO.ANSI

  require Logger

  defmodule State do
    defstruct cursor_x: 0,
              cursor_y: 0
  end

  use Chessh.SSH.Client.Screen

  def render(%Client.State{} = _state) do
    knight = @ascii_chars["pieces"]["white"]["knight"]

    [ANSI.home()] ++
      Enum.map(
        Enum.zip(0..(length(knight) - 1), knight),
        fn {i, line} ->
          [ANSI.cursor(i, 0), line]
        end
      )
  end

  def handle_input(action, %Client.State{} = state) do
    case action do
      _ -> state
    end
  end
end