| summaryrefslogtreecommitdiff | 
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2022-01-07 19:35:38 +0100 | 
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2022-01-07 19:35:38 +0100 | 
| commit | 127f9c3fe7190a4e5daebf63b6fad7dd75af3257 (patch) | |
| tree | 2e2e37de651acee10ca87f548919c9073f6718f7 /src/Update | |
| parent | b2d29a6ec8d55cebaae7cbff86375f05c77c2d11 (diff) | |
...
Diffstat (limited to 'src/Update')
| -rw-r--r-- | src/Update/Story.elm | 112 | 
1 files changed, 103 insertions, 9 deletions
| diff --git a/src/Update/Story.elm b/src/Update/Story.elm index 68ed403..d2fc75f 100644 --- a/src/Update/Story.elm +++ b/src/Update/Story.elm @@ -80,7 +80,8 @@ step model =           }        Tonkadur.Types.MustPromptChoice -> -         let (last_ix, new_ui) = +         let +            (last_ix, new_ui) =                 (List.foldl                    (\option (ix, ui) ->                       case option of @@ -140,17 +141,110 @@ start : Struct.Model.Type -> Struct.Model.Type  start model = (step model)  select_choice : Int -> Struct.Model.Type -> Struct.Model.Type -select_choice ix model = model -   -- TODO: implement +select_choice ix model = +   (step +      {model | +         tonkadur = +            (Tonkadur.Types.set_last_choice_index +               ix +               model.tonkadur +            ) +      } +   )  input_string : String -> Struct.Model.Type -> Struct.Model.Type -input_string string model = model -   -- TODO: implement +input_string string model = +   let string_length = (String.length string) in +   if ((string_length < model.ui.min) || (string_length > model.ui.max)) +   then +      {model | +         ui = +            (Struct.UI.display_string_error +               ( +                  "Input string should be between " +                  ++ (String.fromInt model.ui.min) +                  ++ " and " +                  ++ (String.fromInt model.ui.max) +                  ++ " characters." +               ) +               model.ui +            ) +      } +   else +      (step +         {model | +            tonkadur = +               (Tonkadur.Types.set_target_from_string +                  string +                  model.tonkadur +               ) +         } +      )  input_integer : String -> Struct.Model.Type -> Struct.Model.Type -input_integer string model = model -   -- TODO: implement +input_integer string model = +   case (String.toInt string) of +      Nothing -> +         {model | +            ui = +               (Struct.UI.display_string_error +                  "Input expects an integer." +                  model.ui +               ) +         } + +      (Just int) -> +         if ((int < model.ui.min) || (int > model.ui.max)) +         then +            {model | +               ui = +                  (Struct.UI.display_string_error +                     ( +                        "Input integer should be between " +                        ++ (String.fromInt model.ui.min) +                        ++ " and " +                        ++ (String.fromInt model.ui.max) +                        ++ "." +                     ) +                     model.ui +                  ) +            } +         else +            (step +               {model | +                  tonkadur = +                     (Tonkadur.Types.set_target_from_integer +                        int +                        model.tonkadur +                     ) +               } +            )  input_command : String -> Struct.Model.Type -> Struct.Model.Type -input_command string model = model -   -- TODO: implement +input_command string model = +   let string_length = (String.length string) in +   if ((string_length < model.ui.min) || (string_length > model.ui.max)) +   then +      {model | +         ui = +            (Struct.UI.display_string_error +               ( +                  "Input string should be between " +                  ++ (String.fromInt model.ui.min) +                  ++ " and " +                  ++ (String.fromInt model.ui.max) +                  ++ " characters." +               ) +               model.ui +            ) +      } +   else +      (step +         {model | +            tonkadur = +               (Tonkadur.Types.set_target_from_command +                  (String.words string) +                  model.tonkadur +               ) +         } +      ) | 


