-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cards.elm
84 lines (65 loc) · 1.52 KB
/
Cards.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
port module Cards exposing (..)
import Html exposing (..)
import Html.App as App
import Html.Events as Events
import Model exposing (..)
import Random
port currentTime : (Int -> msg) -> Sub msg
type alias Model =
{ playerHand : List Card
, playerDeck : List Card
, playerBoard : List Card
, opponentHand : List Card
, opponentDeck : List Card
, opponentBoard : List Card
, gameState : GameState
, random : Int
}
type Msg
= NoOp
| NewRandom Int
| GenInt
type GameState
= Pause
| PlayerTurn
| OpponentTurn
| StartScreen
initialModel : ( Model, Cmd Msg )
initialModel =
( { playerHand = []
, playerDeck = []
, playerBoard = []
, opponentHand = []
, opponentDeck = []
, opponentBoard = []
, gameState = Pause
, random = 0
}
, Cmd.none
)
view : Model -> Html Msg
view model =
div []
[ Html.button [ Events.onClick GenInt ]
[ Html.text "Generate" ]
, model.random
|> toString
|> Html.text
]
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
NoOp ->
( model, Cmd.none )
GenInt ->
( model, Random.generate NewRandom (Random.int 1 10) )
NewRandom new ->
( { model | random = new }, Cmd.none )
main : Program Never
main =
App.program
{ init = initialModel
, view = view
, subscriptions = \_ -> Sub.none
, update = update
}