Skip to content

Commit

Permalink
Move view concerns of Model into Model module
Browse files Browse the repository at this point in the history
  • Loading branch information
mwunsch committed Oct 3, 2016
1 parent 23c4b46 commit 7e8eea7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
14 changes: 1 addition & 13 deletions src/Main.elm
Expand Up @@ -127,19 +127,7 @@ view : GameState -> Html Msg
view game =
let
fighter =
text'
[ fontSize "1"
, fontFamily "monospace"
, textAnchor "middle"
, fill color
, x
(game.fighter.position |> posX |> toString)
, y
(game.fighter.position |> posY |> toString)
, onClick <| Select game.fighter
, Svg.Attributes.cursor "pointer"
]
[ text "@" ]
Model.view game.fighter <| Select game.fighter

color =
case game.playerSelection of
Expand Down
31 changes: 30 additions & 1 deletion src/Model.elm
Expand Up @@ -16,7 +16,11 @@ From the rulebook:
-}

import Tabletop exposing (Position, Inch)
import Html.Events exposing (onClick)
import Svg exposing (..)
import Svg.Attributes exposing (..)
import Tabletop exposing (Position, Inch, posX, posY)


{-| From the rulebook:
Expand Down Expand Up @@ -88,6 +92,7 @@ type alias Model =
, hidden : Bool
, pinned : Bool
, injury : Maybe Injury
, remainingMove : Inch
}


Expand All @@ -104,13 +109,15 @@ averageFighterProfile =
, leadership = 7
}


averageFighter : Position -> Model
averageFighter pos =
{ profile = averageFighterProfile
, position = pos
, hidden = False
, pinned = False
, injury = Nothing
, remainingMove = averageFighterProfile.move
}


Expand All @@ -119,7 +126,29 @@ move model pos =
{ model | position = pos }


attemptMove : Model -> Position -> Result ( String, Model ) Model
attemptMove model pos =
Ok { model | position = pos }


type Injury
= FleshWound
| Down
| OutOfAction


view : Model -> msg -> Svg msg
view model msg =
text'
[ fontSize "1"
, fontFamily "monospace"
, textAnchor "middle"
, fill "black"
, x
(model.position |> posX |> toString)
, y
(model.position |> posY |> toString)
, onClick msg
, Svg.Attributes.cursor "pointer"
]
[ text "@" ]

0 comments on commit 7e8eea7

Please sign in to comment.