| summaryrefslogtreecommitdiff | 
diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ElmModule/Init.elm | 2 | ||||
| -rw-r--r-- | src/Main.elm | 2 | ||||
| -rw-r--r-- | src/Struct/Event.elm | 2 | ||||
| -rw-r--r-- | src/Struct/Model.elm | 9 | ||||
| -rw-r--r-- | src/Struct/UI.elm | 8 | ||||
| -rw-r--r-- | src/Tonkadur/Execute.elm | 3 | ||||
| -rw-r--r-- | src/Tonkadur/Types.elm | 62 | 
7 files changed, 70 insertions, 18 deletions
| diff --git a/src/ElmModule/Init.elm b/src/ElmModule/Init.elm index 9af3cce..885153a 100644 --- a/src/ElmModule/Init.elm +++ b/src/ElmModule/Init.elm @@ -15,4 +15,4 @@ import Struct.Model  init : Struct.Flags.Type -> (Struct.Model.Type, (Cmd Struct.Event.Type))  init flags =     -- TODO: read flags and request story. -   (model, Cmd.none) +   ((Struct.Model.new), Cmd.none) diff --git a/src/Main.elm b/src/Main.elm index 0f8f61a..795328e 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -13,7 +13,7 @@ import Struct.Flags  import Struct.Model  import Struct.Event -main : (Program Shared.Struct.Flags.Type Struct.Model.Type Struct.Event.Type) +main : (Program Struct.Flags.Type Struct.Model.Type Struct.Event.Type)  main =     (Browser.element        { diff --git a/src/Struct/Event.elm b/src/Struct/Event.elm index 78079d2..5127422 100644 --- a/src/Struct/Event.elm +++ b/src/Struct/Event.elm @@ -8,7 +8,7 @@ module Struct.Event exposing (..)  -- TYPES -----------------------------------------------------------------------  --------------------------------------------------------------------------------  type Type = -   EventType0 +   None  --------------------------------------------------------------------------------  -- LOCAL ----------------------------------------------------------------------- diff --git a/src/Struct/Model.elm b/src/Struct/Model.elm index a11db5c..b9c8d61 100644 --- a/src/Struct/Model.elm +++ b/src/Struct/Model.elm @@ -1,6 +1,7 @@  module Struct.Model exposing     ( -      Type +      Type, +      new     )  -- Elm ------------------------------------------------------------------------- @@ -27,3 +28,9 @@ type alias Type =  --------------------------------------------------------------------------------  -- EXPORTED --------------------------------------------------------------------  -------------------------------------------------------------------------------- +new : Type +new = +   { +      tonkadur = (Tonkadur.Types.new_state), +      ui = (Struct.UI.new) +   } diff --git a/src/Struct/UI.elm b/src/Struct/UI.elm index 53348f6..80cd9e6 100644 --- a/src/Struct/UI.elm +++ b/src/Struct/UI.elm @@ -1,6 +1,7 @@  module Struct.UI exposing     ( -      Type +      Type, +      new     )  -- Elm ------------------------------------------------------------------------- @@ -22,3 +23,8 @@ type alias Type =  --------------------------------------------------------------------------------  -- EXPORTED --------------------------------------------------------------------  -------------------------------------------------------------------------------- +new : Type +new = +   { +      displayed_options = [] +   } diff --git a/src/Tonkadur/Execute.elm b/src/Tonkadur/Execute.elm index 98eb680..cf582dd 100644 --- a/src/Tonkadur/Execute.elm +++ b/src/Tonkadur/Execute.elm @@ -80,6 +80,7 @@ extra_instruction : (  extra_instruction name parameters state =     -- No extra instruction supported.     -- TODO: error report. +   state  initialize : (        String -> @@ -103,6 +104,7 @@ initialize type_name address state =              )              state.memory           ) +      -- TODO: detect allocated memory for special handling.     }  prompt_command : ( @@ -168,6 +170,7 @@ remove address state =              (\last_addr dict -> (Dict.remove last_addr dict))              state.memory           ) +      -- TODO: detect allocated memory for special handling.     }  resolve_choice : Tonkadur.Types.State -> Tonkadur.Types.State diff --git a/src/Tonkadur/Types.elm b/src/Tonkadur/Types.elm index 9df1df7..504695b 100644 --- a/src/Tonkadur/Types.elm +++ b/src/Tonkadur/Types.elm @@ -107,6 +107,22 @@ type alias State =  --------------------------------------------------------------------------------  -- EXPORTED --------------------------------------------------------------------  -------------------------------------------------------------------------------- +new_state : State +new_state = +   { +      memory = (Dict.empty), +      user_types = (Dict.empty), +      sequences = (Dict.empty), +      code = [], +      program_counter = 0, +      allocated_data = 0, +      last_choice_index = 0, +      available_options = [], +      memorized_target = (PointerValue [""]), + +      last_instruction_effect = MustContinue +   } +  value_to_bool : Value -> Bool  value_to_bool value =     case value of @@ -141,12 +157,15 @@ value_to_string value =              (StringText result) -> result              (AugmentedText rich_text) ->                 (String.concat -                  (List.map (value_to_string) rich_text.content) +                  (List.map +                     (\text_value -> (value_to_string (TextValue text_value))) +                     rich_text.content +                  )                 )              NewlineText -> "\n" -      _ -> (StringText "") +      _ -> "Cannot turn this value into string without cast."  value_to_dict : Value -> (Dict.Dict String Value)  value_to_dict value = @@ -177,7 +196,10 @@ append_text_content base addition =                    (AugmentedText                       {text_data |                          content = -                           (List.append base.content other_text_data.content) +                           (List.append +                              text_data.content +                              other_text_data.content +                           )                       }                    )                 else @@ -185,8 +207,8 @@ append_text_content base addition =                       {text_data |                          content =                             (List.append -                              base.content -                              (List.singleton other_text_data) +                              text_data.content +                              (List.singleton addition)                             )                       }                    ) @@ -195,7 +217,7 @@ append_text_content base addition =                 (AugmentedText                    {text_data |                       content = -                        (List.append base.content (List.singleton other)) +                        (List.append text_data.content (List.singleton other))                    }                 ) @@ -233,7 +255,7 @@ get_default state type_name =        other ->           case (Dict.get other state.user_types) of              (Just default) -> default -            Nothing -> (StringValue ("Unknown type '" + other + "'")) +            Nothing -> (StringValue ("Unknown type '" ++ other ++ "'"))  apply_at_address : (        (List String) -> @@ -254,15 +276,29 @@ apply_at_address address fun memory =              next_element              (\maybe_value ->                 case maybe_value of -                  (Just value) -> +                  (Just (StructureValue value)) ->                       (Just -                        (apply_at_address -                           next_address -                           fun -                           (value_to_dict value) +                        (StructureValue +                           (apply_at_address +                              next_address +                              (fun) +                              value +                           ) +                        ) +                     ) + +                  (Just (ListValue value)) -> +                     (Just +                        (ListValue +                           (apply_at_address +                              next_address +                              (fun) +                              value +                           )                          )                       ) -                  Nothing -> Nothing +                  _ -> Nothing              ) +            memory           ) | 


