Skip to content

Commit

Permalink
Generate Game inside Main GameState
Browse files Browse the repository at this point in the history
  • Loading branch information
mwunsch committed Dec 15, 2016
1 parent 7bce316 commit 0b8e158
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Main.elm
Expand Up @@ -3,6 +3,7 @@ module Main exposing (..)
import Action exposing (Action, Failure)
import Array
import Dice
import Game exposing (Game)
import Gang exposing (Gang)
import Html exposing (Html)
import Html.Events exposing (on, onClick)
Expand Down Expand Up @@ -47,6 +48,7 @@ type alias GameState =
, turn : Turn
, contextMessage : Maybe ContextMessage
, rolling : Maybe DiceRoll
, game : Game
}


Expand All @@ -68,10 +70,12 @@ init =
, turn = Turn.init
, contextMessage = Nothing
, rolling = Nothing
, game = Game.init
}
, Cmd.batch
[ Task.perform Resize Window.width
, Random.generate Generate (Gang.positionedGenerator table)
, Random.generate Begin (Game.generator)
]
)

Expand All @@ -93,11 +97,17 @@ type Msg
| Generate Gang
| NoOp
| Log String String
| Begin Game


update : Msg -> GameState -> ( GameState, Cmd Msg )
update msg game =
case msg of
Begin newGame ->
( { game | game = newGame }
, Cmd.none
)

Select model ->
( { game | player = Player.selectModel game.player model.id }, Cmd.none )

Expand Down

0 comments on commit 0b8e158

Please sign in to comment.