module ElmModule.Update exposing (update) -- Elm ------------------------------------------------------------------------- -- Local Module ---------------------------------------------------------------- import Struct.Event import Struct.Model import Struct.UI import Update.Story -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- update : ( Struct.Event.Type -> Struct.Model.Type -> (Struct.Model.Type, (Cmd Struct.Event.Type)) ) update event model = case event of (Struct.Event.ChoiceSelected ix) -> ((Update.Story.select_choice ix model), Cmd.none) Struct.Event.None -> (model, Cmd.none) (Struct.Event.LoadStory http_result) -> case http_result of (Ok story) -> ( (Update.Story.start {model | tonkadur = {story | random_seed = model.tonkadur.random_seed } } ), Cmd.none ) (Err error) -> ( {model | ui = (Struct.UI.display_string_error "Failed to load story" model.ui ) }, Cmd.none )