| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2018-01-12 17:23:28 +0100 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2018-01-12 17:23:28 +0100 | 
| commit | fc03dc63636177c35aebf2c0f662709a0a764031 (patch) | |
| tree | b63de3808833d6ea2a6effd84fbb3b376dd9a65e /src | |
| parent | 94ed7fb32138013d6d21baeadba9019540ccc66d (diff) | |
Start to work on the character stats.
Diffstat (limited to 'src')
| -rw-r--r-- | src/battlemap/src/Move.elm | 160 | ||||
| -rw-r--r-- | src/battlemap/src/Update/SelectTile.elm | 2 | ||||
| -rw-r--r-- | src/battlemap/src/View/SideBar/TabMenu/Status.elm | 11 | ||||
| -rw-r--r-- | src/battlemap/src/View/SideBar/TabMenu/Status/CharacterInfo.elm | 106 | 
4 files changed, 116 insertions, 163 deletions
| diff --git a/src/battlemap/src/Move.elm b/src/battlemap/src/Move.elm deleted file mode 100644 index 945d29f..0000000 --- a/src/battlemap/src/Move.elm +++ /dev/null @@ -1,160 +0,0 @@ -module ???.MoveNavigator exposing (to) - --- TODO: This should not belong to the Struct.Navigator module, as it's actually --- a module used to manipulate an existing navigator in a certain way. - -import Set -import List - -import Struct.Battlemap -import Struct.Direction -import Struct.Location -import Struct.Tile -import Struct.Navigator - -import Character - -import Util.List - -can_move_to_new_tile : ( -      Struct.Navigator.Type -> -      Struct.Battlemap.Type -> -      Struct.Location.Type -> -      Bool -   ) -can_move_to_new_tile nav battlemap next_location = -   ( -      (nav.remaining_points > 0) -      && (Struct.Battlemap.has_location battlemap next_location) -      && (nav.current_location /= next_location) -      && -      (not -         (Set.member -            (Struct.Location.get_ref next_location) -            nav.visited_locations -         ) -      ) -   ) - -battlemap_move_to : ( -      Struct.Battlemap.Type -> -      Struct.Location.Type -> -      Struct.Direction.Type -> -      Struct.Location.Type -> -      Struct.Battlemap.Type -   ) -battlemap_move_to battlemap current_loc dir next_loc = -   (Struct.Battlemap.apply_to_tile_unsafe -      (Struct.Battlemap.apply_to_tile_unsafe -         battlemap -         current_loc -         (Struct.Tile.set_direction dir) -      ) -      next_loc -      (Struct.Tile.set_direction dir) -   ) - -navigator_move_to : ( -      Struct.Navigator.Type -> -      Struct.Direction.Type -> -      Struct.Location.Type -> -      Struct.Navigator.Type -   ) -navigator_move_to nav dir next_loc = -   {nav | -      current_location = next_loc, -      visited_locations = -         (Set.insert -            (Struct.Location.get_ref nav.current_location) -            nav.visited_locations -         ), -      previous_directions = (dir :: nav.previous_directions), -      remaining_points = (nav.remaining_points - 1) -   } - -battlemap_backtrack : ( -      Struct.Battlemap.Type -> -      Struct.Location.Type -> -      Struct.Battlemap.Type -   ) -battlemap_backtrack battlemap current_loc = -   (Struct.Battlemap.apply_to_tile_unsafe -      battlemap -      current_loc -      (Struct.Tile.set_direction -         Struct.Direction.None -      ) -   ) - -navigator_backtrack : ( -      Struct.Navigator.Type -> -      Struct.Location.Type -> -      (List Struct.Direction.Type) -> -      Struct.Navigator.Type -   ) -navigator_backtrack nav next_loc prev_dir_tail = -   {nav | -      current_location = next_loc, -      visited_locations = -         (Set.remove -            (Struct.Location.get_ref next_loc) -            nav.visited_locations -         ), -      previous_directions = prev_dir_tail, -      remaining_points = (nav.remaining_points + 1) -   } - -to : ( -      Struct.Battlemap.Type -> -      Struct.Navigator.Type -> -      Struct.Direction.Type -> -      (List Character.Type) -> -      (Struct.Battlemap.Type, Struct.Navigator.Type) -   ) -to battlemap nav dir char_list = -   let -      next_location = (Struct.Location.neighbor nav.current_location dir) -      is_occupied = -         (List.any -            (\c -> ((Character.get_location c) == next_location)) -            char_list -         ) -   in -      if (not is_occupied) -      then -         if (can_move_to_new_tile nav battlemap next_location) -         then -            ( -               (battlemap_move_to -                  battlemap -                  nav.current_location -                  dir -                  next_location -               ), -               (navigator_move_to -                  nav -                  dir -                  next_location -               ) -            ) -         else -            case (Util.List.pop nav.previous_directions) of -               Nothing -> (battlemap, nav) -               (Just (head, tail)) -> -                  if (head == (Struct.Direction.opposite_of dir)) -                  then -                     ( -                        (battlemap_backtrack -                           battlemap -                           nav.current_location -                        ), -                        (navigator_backtrack -                           nav -                           next_location -                           tail -                        ) -                     ) -                  else -                     (battlemap, nav) -      else -         (battlemap, nav) diff --git a/src/battlemap/src/Update/SelectTile.elm b/src/battlemap/src/Update/SelectTile.elm index 817b511..2abaa9e 100644 --- a/src/battlemap/src/Update/SelectTile.elm +++ b/src/battlemap/src/Update/SelectTile.elm @@ -124,7 +124,7 @@ go_to_tile model navigator loc_ref =           Nothing -> -- Clicked outside of the range indicator              ((Struct.Model.reset model model.characters), Cmd.none) ------------------------------------------------- maybe_nav-------------------------------- +--------------------------------------------------------------------------------  -- EXPORTED --------------------------------------------------------------------  --------------------------------------------------------------------------------  apply_to : ( diff --git a/src/battlemap/src/View/SideBar/TabMenu/Status.elm b/src/battlemap/src/View/SideBar/TabMenu/Status.elm index 61c0540..97325bc 100644 --- a/src/battlemap/src/View/SideBar/TabMenu/Status.elm +++ b/src/battlemap/src/View/SideBar/TabMenu/Status.elm @@ -18,10 +18,10 @@ import Struct.UI  import Util.Html +import View.SideBar.TabMenu.Status.CharacterInfo  --------------------------------------------------------------------------------  -- LOCAL -----------------------------------------------------------------------  -------------------------------------------------------------------------------- -  get_char_info_html : (        Struct.Model.Type ->        Struct.Character.Ref -> @@ -132,7 +132,14 @@ get_html model =                 )              (Just (Struct.UI.SelectedCharacter target_char)) -> -               (get_char_info_html model target_char) +               case (Dict.get target_char model.characters) of +                  (Just char) -> +                     (View.SideBar.TabMenu.Status.CharacterInfo.get_html +                        model +                        char +                     ) + +                  _ -> (Html.text "Error: Unknown character selected.")              _ ->                 (Html.text "Double-click on a character to control it.") diff --git a/src/battlemap/src/View/SideBar/TabMenu/Status/CharacterInfo.elm b/src/battlemap/src/View/SideBar/TabMenu/Status/CharacterInfo.elm new file mode 100644 index 0000000..699a5f1 --- /dev/null +++ b/src/battlemap/src/View/SideBar/TabMenu/Status/CharacterInfo.elm @@ -0,0 +1,106 @@ +module View.SideBar.TabMenu.Status.CharacterInfo exposing (get_html) + +-- Elm ------------------------------------------------------------------------- +import Dict + +import Html +import Html.Attributes + +-- Struct.Battlemap ------------------------------------------------------------------- +import Struct.Character +import Struct.Event +import Struct.Model + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_attributes_list: ( +      Struct.Character.Type -> +      (Html.Html Struct.Event.Type) +   ) +get_attributes_list char = +   (Html.ul +      [ +      ] +      [ +         (Html.li [] [(Html.text "Agility: ???")]), +         (Html.li [] [(Html.text "Dexterity: ???")]), +         (Html.li [] [(Html.text "Sight: ???")]), +         (Html.li [] [(Html.text "Strength: ???")]) +      ] +   ) + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html: ( +      Struct.Model.Type -> +      Struct.Character.Type -> +      (Html.Html Struct.Event.Type) +   ) +get_html model char = +   (Html.div +      [ +            (Html.Attributes.class "battlemap-tabmenu-character-info") +      ] +      [ +         (Html.text ("Focusing " ++ char.name ++ ":")), +         (Html.dl +            [ +            ] +            [ +               (Html.dt [] [(Html.text "Team")]), +               (Html.dd +                  [] +                  [ +                     (Html.text +                        (toString +                           (Struct.Character.get_team char) +                        ) +                     ) +                  ] +               ), +               (Html.dt [] [(Html.text "Health")]), +               (Html.dd +                  [] +                  [ +                     (Html.text +                        ( +                           (toString +                              (Struct.Character.get_current_health char) +                           ) +                           ++ "/" +                           ++ +                           (toString +                              (Struct.Character.get_max_health char) +                           ) +                        ) +                     ) +                  ] +               ), +               (Html.dt [] [(Html.text "Movement Points")]), +               (Html.dd +                  [] +                  [ +                     (Html.text +                        (toString +                           (Struct.Character.get_movement_points char) +                        ) +                     ) +                  ] +               ), +               (Html.dt [] [(Html.text "Attack Range")]), +               (Html.dd +                  [] +                  [ +                     (Html.text +                        (toString +                           (Struct.Character.get_attack_range char) +                        ) +                     ) +                  ] +               ) +            ] +         ) +      ] +   ) | 


