GithubHelp home page GithubHelp logo

the-game-of-set's Introduction

Getting Started

Useful Commands:

  • pushd src && elm test && popd
  • elm reactor

the-game-of-set's People

Contributors

callmenorm avatar cifer-y avatar danfinnie avatar dey-dey avatar franklinchen avatar hiteshjasani avatar hossameldeen avatar jvoigtlaender avatar jwmerrill avatar knuton avatar markymarkmcdonald avatar process-bot avatar rgscherf avatar sircharleswatson avatar svenheden avatar thomasweiser avatar tim-butterworth avatar vpeurala avatar zimmi48 avatar

Watchers

 avatar

the-game-of-set's Issues

Pushing is hard

\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 ->
    
  •    { model | selected = True }
    
  •  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

  • ]

  • let

  • seeds = scanl (\b -> ZZ) (Random.initialSeed 323947) (repeat 4 0)

  • in

  • Model [

  •  Card.init seed0, Card.init seed0, Card.init seed0
    
  • ]

-- UPDATE

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.