| summaryrefslogtreecommitdiff | 
diff options
Diffstat (limited to 'src/battle')
| -rw-r--r-- | src/battle/src/Comm/AddPortrait.elm | 2 | ||||
| -rw-r--r-- | src/battle/src/Comm/AddTile.elm | 2 | ||||
| -rw-r--r-- | src/battle/src/Struct/Character.elm | 18 | ||||
| -rw-r--r-- | src/battle/src/Struct/Map.elm | 182 | ||||
| -rw-r--r-- | src/battle/src/Struct/MapMarker.elm | 99 | ||||
| -rw-r--r-- | src/battle/src/Update/HandleServerReply.elm | 2 | ||||
| -rw-r--r-- | src/battle/src/Update/SelectCharacter.elm | 9 | ||||
| -rw-r--r-- | src/battle/src/Update/SwitchWeapon.elm | 2 | ||||
| -rw-r--r-- | src/battle/src/Update/UndoAction.elm | 5 | ||||
| -rw-r--r-- | src/battle/src/View/Map.elm | 7 | ||||
| -rw-r--r-- | src/battle/src/View/SubMenu/Status/TileInfo.elm | 4 | 
11 files changed, 28 insertions, 304 deletions
| diff --git a/src/battle/src/Comm/AddPortrait.elm b/src/battle/src/Comm/AddPortrait.elm index 321684c..8fd29af 100644 --- a/src/battle/src/Comm/AddPortrait.elm +++ b/src/battle/src/Comm/AddPortrait.elm @@ -1,4 +1,4 @@ -module BattleCharacters.Comm.AddPortrait exposing (decode) +module Comm.AddPortrait exposing (decode)  -- Elm -------------------------------------------------------------------------  import Json.Decode diff --git a/src/battle/src/Comm/AddTile.elm b/src/battle/src/Comm/AddTile.elm index 6b27310..797731b 100644 --- a/src/battle/src/Comm/AddTile.elm +++ b/src/battle/src/Comm/AddTile.elm @@ -16,7 +16,7 @@ import Struct.ServerReply  --------------------------------------------------------------------------------  -- LOCAL -----------------------------------------------------------------------  -------------------------------------------------------------------------------- -internal_decoder : Struct.Tile.Type -> Struct.ServerReply.Type +internal_decoder : BattleMap.Struct.Tile.Type -> Struct.ServerReply.Type  internal_decoder wp = (Struct.ServerReply.AddTile wp)  -------------------------------------------------------------------------------- diff --git a/src/battle/src/Struct/Character.elm b/src/battle/src/Struct/Character.elm index 4e03082..12f63ba 100644 --- a/src/battle/src/Struct/Character.elm +++ b/src/battle/src/Struct/Character.elm @@ -46,7 +46,7 @@ import BattleCharacters.Struct.Portrait  import BattleCharacters.Struct.Weapon  -- Battle Map ------------------------------------------------------------------ -import Struct.Location +import BattleMap.Struct.Location  --------------------------------------------------------------------------------  -- TYPES ----------------------------------------------------------------------- @@ -57,7 +57,7 @@ type alias PartiallyDecoded =        nam : String,        rnk : String,        prt : String, -      lc : Struct.Location.Type, +      lc : BattleMap.Struct.Location.Type,        hea : Int,        pla : Int,        ena : Bool, @@ -80,7 +80,7 @@ type alias Type =        name : String,        rank : Rank,        portrait : BattleCharacters.Struct.Portrait.Type, -      location : Struct.Location.Type, +      location : BattleMap.Struct.Location.Type,        health : Int,        player_ix : Int,        enabled : Bool, @@ -118,7 +118,7 @@ finish_decoding : PartiallyDecoded -> TypeAndEquipmentRef  finish_decoding add_char =     let        armor = BattleCharacters.Struct.Armor.none -      portrait = BattleCharacters.Struct.Portrait.none +      portrait = BattleCharacters.Struct.Portrait.default        default_attributes = (Battle.Struct.Attributes.default)        almost_char =           { @@ -176,10 +176,10 @@ get_sane_current_health c = (max 0 c.health)  set_current_health : Int -> Type -> Type  set_current_health health c = {c | health = health} -get_location : Type -> Struct.Location.Type +get_location : Type -> BattleMap.Struct.Location.Type  get_location t = t.location -set_location : Struct.Location.Type -> Type -> Type +set_location : BattleMap.Struct.Location.Type -> Type -> Type  set_location location char = {char | location = location}  get_attributes : Type -> Battle.Struct.Attributes.Type @@ -232,7 +232,7 @@ decoder =           |> (Json.Decode.Pipeline.required "nam" Json.Decode.string)           |> (Json.Decode.Pipeline.required "rnk" Json.Decode.string)           |> (Json.Decode.Pipeline.required "prt" Json.Decode.string) -         |> (Json.Decode.Pipeline.required "lc" Struct.Location.decoder) +         |> (Json.Decode.Pipeline.required "lc" BattleMap.Struct.Location.decoder)           |> (Json.Decode.Pipeline.required "hea" Json.Decode.int)           |> (Json.Decode.Pipeline.required "pla" Json.Decode.int)           |> (Json.Decode.Pipeline.required "ena" Json.Decode.bool) @@ -249,7 +249,7 @@ decoder =     )  refresh_omnimods : ( -      (Struct.Location.Type -> Battle.Struct.Omnimods.Type) -> +      (BattleMap.Struct.Location.Type -> Battle.Struct.Omnimods.Type) ->        Type ->        Type     ) @@ -302,7 +302,7 @@ refresh_omnimods tile_omnimods_fun char =        }  fill_missing_equipment_and_omnimods : ( -      (Struct.Location.Type -> Battle.Struct.Omnimods.Type) -> +      (BattleMap.Struct.Location.Type -> Battle.Struct.Omnimods.Type) ->        BattleCharacters.Struct.Portrait.Type ->        BattleCharacters.Struct.Weapon.Type ->        BattleCharacters.Struct.Weapon.Type -> diff --git a/src/battle/src/Struct/Map.elm b/src/battle/src/Struct/Map.elm deleted file mode 100644 index c28f133..0000000 --- a/src/battle/src/Struct/Map.elm +++ /dev/null @@ -1,182 +0,0 @@ -module Struct.Map exposing -   ( -      Type, -      empty, -      new, -      get_width, -      get_height, -      get_tiles, -      get_movement_cost_function, -      solve_tiles, -      try_getting_tile_at, -      get_omnimods_at, -      decoder -   ) - --- Elm ------------------------------------------------------------------------- -import Array - -import Dict - -import Json.Decode - --- Battle ---------------------------------------------------------------------- -import Constants.Movement - -import Struct.Character -import Struct.Location -import Battle.Struct.Omnimods -import Struct.Tile -import Struct.TileInstance -import Struct.MapMarker - --------------------------------------------------------------------------------- --- TYPES ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -type alias Type = -   { -      width : Int, -      height : Int, -      content : (Array.Array Struct.TileInstance.Type), -      markers : (Dict.Dict String Struct.MapMarker.Type) -   } - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -location_to_index : Struct.Location.Type -> Type -> Int -location_to_index loc bmap = -   ((loc.y * bmap.width) + loc.x) - -has_location : Struct.Location.Type -> Type -> Bool -has_location loc bmap = -   ( -      (loc.x >= 0) -      && (loc.y >= 0) -      && (loc.x < bmap.width) -      && (loc.y < bmap.height) -   ) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_width : Type -> Int -get_width bmap = bmap.width - -get_height : Type -> Int -get_height bmap = bmap.height - -get_tiles : Type -> (Array.Array Struct.TileInstance.Type) -get_tiles map = map.content - -empty : Type -empty = -   { -      width = 0, -      height = 0, -      content = (Array.empty), -      markers = (Dict.empty) -   } - -new : Int -> Int -> (List Struct.TileInstance.Type) -> Type -new width height tiles = -   { -      width = width, -      height = height, -      content = (Array.fromList tiles), -      markers = (Dict.empty) -   } - -try_getting_tile_at : ( -      Struct.Location.Type -> -      Type -> -      (Maybe Struct.TileInstance.Type) -   ) -try_getting_tile_at loc map = -   if (has_location loc map) -   then (Array.get (location_to_index loc map) map.content) -   else Nothing - -get_movement_cost_function : ( -      Type -> -      Struct.Location.Type -> -      (List Struct.Character.Type) -> -      Struct.Location.Type -> -      Int -   ) -get_movement_cost_function bmap start_loc char_list loc = -   if (has_location loc bmap) -   then -      case (Array.get (location_to_index loc bmap) bmap.content) of -         (Just tile) -> -            if -               (List.any -                  ( -                     \c -> -                        ( -                           ((Struct.Character.get_location c) == loc) -                           && (loc /= start_loc) -                           && (Struct.Character.is_alive c) -                        ) -                  ) -                  char_list -               ) -            then -               Constants.Movement.cost_when_occupied_tile -            else -               (Struct.TileInstance.get_cost tile) - -         Nothing -> Constants.Movement.cost_when_out_of_bounds -   else -      Constants.Movement.cost_when_out_of_bounds - -get_omnimods_at : ( -      Struct.Location.Type -> -      (Dict.Dict Struct.Tile.Ref Struct.Tile.Type) -> -      Type -> -      Battle.Struct.Omnimods.Type -   ) -get_omnimods_at loc tiles_solver map = -   case (try_getting_tile_at loc map) of -      Nothing -> (Battle.Struct.Omnimods.new [] [] [] []) -      (Just tile_inst) -> -         case -            (Dict.get (Struct.TileInstance.get_class_id tile_inst) tiles_solver) -         of -            Nothing -> (Battle.Struct.Omnimods.new [] [] [] []) -            (Just tile) -> (Struct.Tile.get_omnimods tile) - -solve_tiles : (Dict.Dict Struct.Tile.Ref Struct.Tile.Type) -> Type -> Type -solve_tiles tiles map = -   {map | -      content = (Array.map (Struct.TileInstance.solve tiles) map.content) -   } - -decoder : (Json.Decode.Decoder Type) -decoder = -   (Json.Decode.andThen -      (\width -> -         (Json.Decode.map4 -            Type -            (Json.Decode.field "w" Json.Decode.int) -            (Json.Decode.field "h" Json.Decode.int) -            (Json.Decode.field -               "t" -               (Json.Decode.map -                  (Array.indexedMap -                     (Struct.TileInstance.set_location_from_index width) -                  ) -                  (Json.Decode.array (Struct.TileInstance.decoder)) -               ) -            ) -            (Json.Decode.field -               "m" -               (Json.Decode.map -                  (Dict.fromList) -                  (Json.Decode.keyValuePairs (Struct.MapMarker.decoder)) -               ) -            ) -         ) -      ) -      (Json.Decode.field "w" Json.Decode.int) -   ) diff --git a/src/battle/src/Struct/MapMarker.elm b/src/battle/src/Struct/MapMarker.elm deleted file mode 100644 index 790ac1a..0000000 --- a/src/battle/src/Struct/MapMarker.elm +++ /dev/null @@ -1,99 +0,0 @@ -module BattleMap.Struct.MapMarker exposing -   ( -      Type, -      new, -      get_locations, -      is_in_locations, -      decoder, -      encode -   ) - --- Elm ------------------------------------------------------------------------- -import Set -import Json.Decode -import Json.Encode -import List - --- Battle Map ------------------------------------------------------------------ -import BattleMap.Struct.Location - --------------------------------------------------------------------------------- --- TYPES ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -type alias Type = -   { -      permissions : (Set.Set String), -      locations : (Set.Set BattleMap.Struct.Location.Ref) -   } - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- - -new : Type -new = -   { -      permissions = (Set.empty), -      locations = (Set.empty) -   } - -get_locations : Type -> (Set.Set BattleMap.Struct.Location.Ref) -get_locations marker = marker.locations - -is_in_locations : BattleMap.Struct.Location.Ref -> Type -> Bool -is_in_locations loc_ref marker = -   (Set.member loc_ref marker.locations) - -decoder : (Json.Decode.Decoder Type) -decoder = -   (Json.Decode.map2 -      Type -      (Json.Decode.field -         "p" -         (Json.Decode.map -            (Set.fromList) -            (Json.Decode.list (Json.Decode.string)) -         ) -      ) -      (Json.Decode.field -         "l" -         (Json.Decode.map -            (Set.fromList) -            (Json.Decode.list -               (Json.Decode.map -                  (BattleMap.Struct.Location.get_ref) -                  (BattleMap.Struct.Location.decoder) -               ) -            ) -         ) -      ) -   ) - -encode : Type -> Json.Encode.Value -encode marker = -   (Json.Encode.object -      [ -         ( -            "p", -            (Json.Encode.list -               (Json.Encode.string) -               (Set.toList marker.permissions) -            ) -         ), -         ( -            "l", -            (Json.Encode.list -               (\e -> -                  (BattleMap.Struct.Location.encode -                     (BattleMap.Struct.Location.from_ref e) -                  ) -               ) -               (Set.toList marker.locations) -            ) -         ) -      ] -   ) diff --git a/src/battle/src/Update/HandleServerReply.elm b/src/battle/src/Update/HandleServerReply.elm index 8140ebd..a17b20d 100644 --- a/src/battle/src/Update/HandleServerReply.elm +++ b/src/battle/src/Update/HandleServerReply.elm @@ -77,7 +77,7 @@ portrait_getter : (  portrait_getter model ref =     case (Dict.get ref model.portraits) of        (Just w) -> w -      Nothing -> BattleCharacters.Struct.Portrait.none +      Nothing -> BattleCharacters.Struct.Portrait.default  ----------- diff --git a/src/battle/src/Update/SelectCharacter.elm b/src/battle/src/Update/SelectCharacter.elm index 2b70f1c..b48f6c8 100644 --- a/src/battle/src/Update/SelectCharacter.elm +++ b/src/battle/src/Update/SelectCharacter.elm @@ -12,7 +12,7 @@ import Battle.Struct.Statistics  import BattleCharacters.Struct.Weapon  -- Battle Map ------------------------------------------------------------------ -import Struct.Map +import BattleMap.Struct.Map  import BattleMap.Struct.Location  -- Local Module ---------------------------------------------------------------- @@ -50,10 +50,13 @@ get_character_navigator model char =           )           (BattleCharacters.Struct.Weapon.get_defense_range weapon)           (BattleCharacters.Struct.Weapon.get_attack_range weapon) -         (Struct.Map.get_movement_cost_function +         (BattleMap.Struct.Map.get_movement_cost_function              model.map +            (List.map +               (Struct.Character.get_location) +               (Array.toList model.characters) +            )              (Struct.Character.get_location char) -            (Array.toList model.characters)           )        ) diff --git a/src/battle/src/Update/SwitchWeapon.elm b/src/battle/src/Update/SwitchWeapon.elm index 33031f2..de72880 100644 --- a/src/battle/src/Update/SwitchWeapon.elm +++ b/src/battle/src/Update/SwitchWeapon.elm @@ -32,7 +32,7 @@ make_it_so model =              new_char =                 (Struct.Character.refresh_omnimods                    (\e -> current_tile_omnimods) -                  (Struct.Character.set_weapons new_weapons char) +                  (Struct.Character.toggle_is_using_primary char)                 )           in              {model | diff --git a/src/battle/src/Update/UndoAction.elm b/src/battle/src/Update/UndoAction.elm index cd3ab41..c30f41b 100644 --- a/src/battle/src/Update/UndoAction.elm +++ b/src/battle/src/Update/UndoAction.elm @@ -45,8 +45,11 @@ get_character_navigator model char =           (BattleCharacters.Struct.Weapon.get_attack_range weapon)           (BattleMap.Struct.Map.get_movement_cost_function              model.map +            (List.map +               (Struct.Character.get_location) +               (Array.toList model.characters) +            )              (Struct.Character.get_location char) -            (Array.toList model.characters)           )        ) diff --git a/src/battle/src/View/Map.elm b/src/battle/src/View/Map.elm index 1de8472..dc0c770 100644 --- a/src/battle/src/View/Map.elm +++ b/src/battle/src/View/Map.elm @@ -12,12 +12,11 @@ import List  -- Shared ----------------------------------------------------------------------  import Util.Html --- Battle ---------------------------------------------------------------------- -import View.BattleMap.Tile -  -- Battle Map ------------------------------------------------------------------  import BattleMap.Struct.Map +import BattleMap.View.Tile +  -- Local Module ----------------------------------------------------------------  import Constants.UI @@ -64,7 +63,7 @@ get_tiles_html map =           )        ]        (List.map -         (View.BattleMap.Tile.get_html False) +         (BattleMap.View.Tile.get_html False)           (Array.toList (BattleMap.Struct.Map.get_tiles map))        )     ) diff --git a/src/battle/src/View/SubMenu/Status/TileInfo.elm b/src/battle/src/View/SubMenu/Status/TileInfo.elm index f8b2b82..a045caf 100644 --- a/src/battle/src/View/SubMenu/Status/TileInfo.elm +++ b/src/battle/src/View/SubMenu/Status/TileInfo.elm @@ -18,7 +18,7 @@ import BattleMap.Struct.Map  import BattleMap.Struct.Tile  import BattleMap.Struct.TileInstance -import BattleMap.View.Map.Tile +import BattleMap.View.Tile  -- Local Module ----------------------------------------------------------------  import Constants.Movement @@ -45,7 +45,7 @@ get_icon tile =              )           )        ] -      (BattleMap.View.Map.Tile.get_content_html tile) +      (BattleMap.View.Tile.get_content_html tile)     )  get_name : ( | 


