We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
\diff --git a/the-game-of-set/Card.elm b/the-game-of-set/Card.elm index 3cbbd5d..f0d7076 100644 --- a/the-game-of-set/Card.elm +++ b/the-game-of-set/Card.elm @@ -5,10 +5,14 @@ import Html.App as Html import Html.Attributes exposing (..) import Html.Events exposing (onClick) import String exposing (repeat) +import Random
-init: Model -init =
{ shape = Diamond, number = 3, color = Red, selected = False } +init: Random.Seed -> (Model, Random.Seed) +init seed0 =
let
(number, seed1) = Random.step (Random.int 0 3) seed0
in
({ shape = Diamond, number = number, color = Red, selected = False }, seed1)
type alias Model = { shape: Shape, @@ -31,25 +35,29 @@ asciiArt shape =
-- UPDATE
-type Msg = SelectCard +type Msg = SelectCard | DeselectCard
update : Msg -> Model -> Model update msg model =
{ model | selected = True }
case msg of
SelectCard ->
DeselectCard ->
{ model | selected = False }
-- VIEW
view : Model -> Html Msg view card = div [
onClick SelectCard,
onClick (if card.selected then DeselectCard else SelectCard), style [ ("color", toString card.color) , ("width", "150px") , ("height", "100px") , ("line-height", "100px") , ("font-size", "50px")
, ("border", "1px solid black")
, ("border", (if card.selected then "5px solid red" else "5px solid black")) , ("display", "inline-block") ]
] [ text ((repeat card.number (asciiArt card.shape)) ++ toString card.selected) ]
] [ text ((repeat card.number (asciiArt card.shape))) ]
diff --git a/the-game-of-set/the-game.elm b/the-game-of-set/the-game.elm index ad528fb..de1787e 100644 --- a/the-game-of-set/the-game.elm +++ b/the-game-of-set/the-game.elm @@ -4,6 +4,8 @@ import Html.Attributes exposing (..) import Html.Events exposing (onClick) import String exposing (repeat) import Card +import Random +import List exposing (scanl repeat)
main = Html.beginnerProgram @@ -20,9 +22,12 @@ type alias Model =
init : Model init =
Model [
Card.init, Card.init, Card.init
]
seeds = scanl (\b -> ZZ) (Random.initialSeed 323947) (repeat 4 0)
Card.init seed0, Card.init seed0, Card.init seed0
The text was updated successfully, but these errors were encountered:
No branches or pull requests
\diff --git a/the-game-of-set/Card.elm b/the-game-of-set/Card.elm
index 3cbbd5d..f0d7076 100644
--- a/the-game-of-set/Card.elm
+++ b/the-game-of-set/Card.elm
@@ -5,10 +5,14 @@ import Html.App as Html
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
import String exposing (repeat)
+import Random
-init: Model
-init =
{ shape = Diamond, number = 3, color = Red, selected = False }
+init: Random.Seed -> (Model, Random.Seed)
+init seed0 =
let
in
type alias Model = {
shape: Shape,
@@ -31,25 +35,29 @@ asciiArt shape =
-- UPDATE
-type Msg = SelectCard
+type Msg = SelectCard | DeselectCard
update : Msg -> Model -> Model
update msg model =
{ model | selected = True }
case msg of
-- VIEW
view : Model -> Html Msg
view card =
div [
diff --git a/the-game-of-set/the-game.elm b/the-game-of-set/the-game.elm
index ad528fb..de1787e 100644
--- a/the-game-of-set/the-game.elm
+++ b/the-game-of-set/the-game.elm
@@ -4,6 +4,8 @@ import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
import String exposing (repeat)
import Card
+import Random
+import List exposing (scanl repeat)
main =
Html.beginnerProgram
@@ -20,9 +22,12 @@ type alias Model =
init : Model
init =
Model [
Card.init, Card.init, Card.init
]
let
seeds = scanl (\b -> ZZ) (Random.initialSeed 323947) (repeat 4 0)
in
Model [
]
-- UPDATE
The text was updated successfully, but these errors were encountered: