summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCasey Robinson <casey@rampantmonkey.com>2017-03-29 18:22:19 -0400
committerCasey Robinson <casey@rampantmonkey.com>2017-11-03 18:02:00 -0400
commite221c26f1a60050e8ad354ea05e6d768a6458979 (patch)
tree2de22a06be35a24995cb5b4f3e07d065ecadeb5e
parentb1f7390a3cb08b4c73dfa45b013ce5660d627a21 (diff)
downloaddcphr-pocket_monsters.tar.gz
dcphr-pocket_monsters.tar.bz2
dcphr-pocket_monsters.zip
Display status message to indicate status of final answerpocket_monsters
red -> try again green -> correct
-rw-r--r--pocket_monsters/src/Models.elm9
-rw-r--r--pocket_monsters/src/Update.elm6
-rw-r--r--pocket_monsters/src/View.elm34
3 files changed, 32 insertions, 17 deletions
diff --git a/pocket_monsters/src/Models.elm b/pocket_monsters/src/Models.elm
index 46e3f04..d7db8ec 100644
--- a/pocket_monsters/src/Models.elm
+++ b/pocket_monsters/src/Models.elm
@@ -1,4 +1,4 @@
-module Models exposing (Model, Pokemon, State(..), initialModel, sortModel, correctGuess)
+module Models exposing (Model, Pokemon, State(..), Status(..), initialModel, sortModel, correctGuess)
import Pokemon.Model as Pkmn
import Regex exposing (..)
@@ -10,6 +10,7 @@ type alias Model =
, pokemon: List Pokemon
, submission: String
, screenWidth: Int
+ , status: Status
}
type State
@@ -17,12 +18,18 @@ type State
| Pokestop
| Capture Pokemon
+type Status
+ = Unsubmitted
+ | Wrong
+ | Solved
+
initialModel : Model
initialModel =
{ state = Map
, pokemon = Pkmn.initialModel
, submission = ""
, screenWidth = 0
+ , status = Unsubmitted
}
correctGuess : Model -> Bool
diff --git a/pocket_monsters/src/Update.elm b/pocket_monsters/src/Update.elm
index ab6a85d..9f8e136 100644
--- a/pocket_monsters/src/Update.elm
+++ b/pocket_monsters/src/Update.elm
@@ -1,7 +1,7 @@
module Update exposing (..)
import Pokemon.Update as PkmnUpdate
-import Models exposing (Model, State(..), Pokemon, correctGuess)
+import Models exposing (Model, State(..), Status(..), Pokemon, correctGuess)
import Messages exposing (Msg(..))
update : Msg -> Model -> ( Model, Cmd Msg )
@@ -19,9 +19,9 @@ update msg model =
WidthChanged w -> ( {model | screenWidth = w}, Cmd.none )
PokestopSubmitAnswer ->
if correctGuess model then
- (Debug.log "correct!" model, Cmd.none)
+ ( { model | status = Solved }, Cmd.none )
else
- (Debug.log "wrong!" model, Cmd.none)
+ ( { model | status = Wrong }, Cmd.none )
MsgForPokemon pkmn pkmnMsg ->
let
diff --git a/pocket_monsters/src/View.elm b/pocket_monsters/src/View.elm
index 317bd74..e7ac899 100644
--- a/pocket_monsters/src/View.elm
+++ b/pocket_monsters/src/View.elm
@@ -1,9 +1,9 @@
module View exposing (..)
import Html exposing (..)
-import Html.Attributes exposing (id, class, src, name, coords, href, shape, usemap, value, placeholder)
+import Html.Attributes exposing (id, class, src, name, coords, href, shape, usemap, value, placeholder, style)
import Html.Events exposing (onClick, onInput, on, keyCode)
-import Models exposing (Model, Pokemon, State(..), sortModel)
+import Models exposing (Model, Pokemon, State(..), Status(..), sortModel)
import Messages exposing (Msg(..))
import List exposing (..)
import Pokemon.View exposing (renderPokemon)
@@ -18,17 +18,25 @@ view model =
renderPokestop : Model -> Html Msg
renderPokestop model =
- div
- [ id "pocket_monsters" ]
- [ div [] [ text "welcome to the pokestop" ]
- , input
- [ placeholder "final answer"
- , onInput (\s -> PokestopAnswer s)
- , onKeyDown (\x -> PokestopKeyDown x)
- , value model.submission ]
- []
- , div [ onClick ShowMap ] [ text "←" ]
- ]
+ let
+ statusMsg =
+ case model.status of
+ Unsubmitted -> div [] []
+ Solved -> div [ style [("color", "#90a959")]] [ text "Correct!" ]
+ Wrong -> div [ style [("color", "#de1b1b")]] [ text "Try Again" ]
+ in
+ div
+ [ id "pocket_monsters" ]
+ [ div [] [ text "welcome to the pokestop" ]
+ , input
+ [ placeholder "final answer"
+ , onInput (\s -> PokestopAnswer s)
+ , onKeyDown (\x -> PokestopKeyDown x)
+ , value model.submission ]
+ []
+ , statusMsg
+ , div [ onClick ShowMap ] [ text "←" ]
+ ]
renderMap : Model -> Html Msg
renderMap model =