Commit 0d4b813c authored by zlu's avatar zlu 🤸🏿
Browse files

Roll dice gives random integer

parent d30cb31f
import Html exposing (..)
import Html.Events exposing (onClick)
import Html.App as App
import Random
main =
App.program
......@@ -11,7 +12,7 @@ main =
}
type alias Model = { dieFace : Int }
type Msg = Roll
type Msg = Roll | NewFace Int
init : (Model, Cmd Msg)
init =
......@@ -21,7 +22,9 @@ update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
case msg of
Roll ->
(model, Cmd.none)
(model, Random.generate NewFace (Random.int 1 6))
NewFace newFace ->
(Model newFace, Cmd.none)
view : Model -> Html Msg
view model =
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment