summaryrefslogtreecommitdiff |
diff options
author | nsensfel <SpamShield0@noot-noot.org> | 2019-03-15 18:41:39 +0100 |
---|---|---|
committer | nsensfel <SpamShield0@noot-noot.org> | 2019-03-15 18:41:39 +0100 |
commit | 8103bf80277b759bb9c3b1e032612721f132f256 (patch) | |
tree | a1b1858483281e61a0dcb9cb42fb6df38214c06a | |
parent | 6678cfe464ed9ee595f4f3dd7398dec1416454c9 (diff) |
[Broken] Got 'battle' to compile again.
-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/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 | ||||
-rw-r--r-- | src/map-editor/src/View/SubMenu/Markers.elm | 53 | ||||
-rw-r--r-- | src/shared/battle-map/BattleMap/Struct/Direction.elm | 12 | ||||
-rw-r--r-- | src/shared/battle-map/BattleMap/Struct/Map.elm | 34 | ||||
-rw-r--r-- | src/shared/battle-map/BattleMap/Struct/Marker.elm (renamed from src/battle/src/Struct/MapMarker.elm) | 2 | ||||
-rw-r--r-- | src/shared/battle-map/BattleMap/Struct/TileInstance.elm | 16 | ||||
-rw-r--r-- | src/shared/battle-map/BattleMap/View/Tile.elm | 10 | ||||
-rw-r--r-- | src/shared/battle/Battle/Struct/Omnimods.elm | 62 |
17 files changed, 174 insertions, 248 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/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 : ( diff --git a/src/map-editor/src/View/SubMenu/Markers.elm b/src/map-editor/src/View/SubMenu/Markers.elm new file mode 100644 index 0000000..f975eef --- /dev/null +++ b/src/map-editor/src/View/SubMenu/Markers.elm @@ -0,0 +1,53 @@ +module View.SubMenu.Markers exposing (get_html) + +-- Elm ------------------------------------------------------------------------- +import Dict + +import Html +import Html.Attributes +import Html.Events + +-- Map Editor ------------------------------------------------------------------ +import Struct.Event +import Struct.Model +import Struct.Tile +import Struct.TileInstance + +import View.Map.Tile + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_marker_html : ( + (String, Struct.MapMarker.Type) + -> (Html.Html Struct.Event.Type) + ) +get_marker_html (ref, marker) = + (Html.div + [ + (Html.Attributes.class "tile"), + (Html.Attributes.class "tiled"), + (Html.Attributes.class "clickable"), + (Html.Attributes.class "tile-variant-0"), + (Html.Events.onClick + (Struct.Event.TemplateRequested ((Struct.Tile.get_id tile), "0")) + ) + ] + (View.Map.Tile.get_content_html (Struct.TileInstance.default tile)) + ) + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type) +get_html model = + (Html.div + [ + (Html.Attributes.class "tabmenu-content"), + (Html.Attributes.class "tabmenu-markers-tab") + ] + (List.map + (get_marker_html) + (Dict.toList (Struct.Map.get_markers model.map)) + ) + ) diff --git a/src/shared/battle-map/BattleMap/Struct/Direction.elm b/src/shared/battle-map/BattleMap/Struct/Direction.elm index 4620e29..0418d31 100644 --- a/src/shared/battle-map/BattleMap/Struct/Direction.elm +++ b/src/shared/battle-map/BattleMap/Struct/Direction.elm @@ -1,10 +1,10 @@ module BattleMap.Struct.Direction exposing -( - Type(..), - opposite_of, - to_string, - decoder -) + ( + Type(..), + opposite_of, + to_string, + decoder + ) -- Elm ------------------------------------------------------------------------- import Json.Decode diff --git a/src/shared/battle-map/BattleMap/Struct/Map.elm b/src/shared/battle-map/BattleMap/Struct/Map.elm index aa166d4..97f0ae8 100644 --- a/src/shared/battle-map/BattleMap/Struct/Map.elm +++ b/src/shared/battle-map/BattleMap/Struct/Map.elm @@ -27,10 +27,13 @@ import Battle.Struct.Omnimods -- Battle Map ------------------------------------------------------------------ import BattleMap.Struct.Location -import BattleMap.Struct.MapMarker +import BattleMap.Struct.Marker import BattleMap.Struct.Tile import BattleMap.Struct.TileInstance +-- Local Module ---------------------------------------------------------------- +import Constants.Movement + -------------------------------------------------------------------------------- -- TYPES ----------------------------------------------------------------------- -------------------------------------------------------------------------------- @@ -39,7 +42,7 @@ type alias Type = width : Int, height : Int, content : (Array.Array BattleMap.Struct.TileInstance.Type), - markers : (Dict.Dict String BattleMap.Struct.MapMarker.Type) + markers : (Dict.Dict String BattleMap.Struct.Marker.Type) } -------------------------------------------------------------------------------- @@ -70,7 +73,7 @@ get_height map = map.height get_tiles : Type -> (Array.Array BattleMap.Struct.TileInstance.Type) get_tiles map = map.content -get_markers : Type -> (Dict.Dict String BattleMap.Struct.MapMarker.Type) +get_markers : Type -> (Dict.Dict String BattleMap.Struct.Marker.Type) get_markers map = map.markers set_tile_to : BattleMap.Struct.Location.Type -> BattleMap.Struct.TileInstance.Type -> Type -> Type @@ -163,7 +166,7 @@ decoder = (Json.Decode.map (Dict.fromList) (Json.Decode.keyValuePairs - (BattleMap.Struct.MapMarker.decoder) + (BattleMap.Struct.Marker.decoder) ) ) ) @@ -174,32 +177,19 @@ decoder = get_movement_cost_function : ( Type -> + (List BattleMap.Struct.Location.Type) -> BattleMap.Struct.Location.Type -> - (List BattleMap.Struct.Character.Type) -> BattleMap.Struct.Location.Type -> Int ) -get_movement_cost_function bmap start_loc char_list loc = +get_movement_cost_function bmap occupied_tiles start_loc loc = if (has_location loc bmap) then case (Array.get (location_to_index loc bmap) bmap.content) of (Just tile) -> - if - (List.any - ( - \c -> - ( - ((BattleMap.Struct.Character.get_location c) == loc) - && (loc /= start_loc) - && (BattleMap.Struct.Character.is_alive c) - ) - ) - char_list - ) - then - Constants.Movement.cost_when_occupied_tile - else - (BattleMap.Struct.TileInstance.get_cost tile) + if ((loc /= start_loc) && (List.member loc occupied_tiles)) + then Constants.Movement.cost_when_occupied_tile + else (BattleMap.Struct.TileInstance.get_cost tile) Nothing -> Constants.Movement.cost_when_out_of_bounds else diff --git a/src/battle/src/Struct/MapMarker.elm b/src/shared/battle-map/BattleMap/Struct/Marker.elm index 790ac1a..9af3ece 100644 --- a/src/battle/src/Struct/MapMarker.elm +++ b/src/shared/battle-map/BattleMap/Struct/Marker.elm @@ -1,4 +1,4 @@ -module BattleMap.Struct.MapMarker exposing +module BattleMap.Struct.Marker exposing ( Type, new, diff --git a/src/shared/battle-map/BattleMap/Struct/TileInstance.elm b/src/shared/battle-map/BattleMap/Struct/TileInstance.elm index 8c39371..c8b4f09 100644 --- a/src/shared/battle-map/BattleMap/Struct/TileInstance.elm +++ b/src/shared/battle-map/BattleMap/Struct/TileInstance.elm @@ -72,7 +72,11 @@ noise_function a b c = clone : BattleMap.Struct.Location.Type -> Type -> Type clone loc inst = {inst | location = loc} -new_border : BattleMap.Struct.Tile.Ref -> BattleMap.Struct.Tile.VariantID -> Border +new_border : ( + BattleMap.Struct.Tile.Ref -> + BattleMap.Struct.Tile.VariantID -> + Border + ) new_border class_id variant_id = { class_id = class_id, @@ -83,10 +87,10 @@ default : BattleMap.Struct.Tile.Type -> Type default tile = { location = {x = 0, y = 0}, - class_id = (Struct.Tile.get_id tile), + class_id = (BattleMap.Struct.Tile.get_id tile), variant_id = "0", - crossing_cost = (Struct.Tile.get_cost tile), - family = (Struct.Tile.get_family tile), + crossing_cost = (BattleMap.Struct.Tile.get_cost tile), + family = (BattleMap.Struct.Tile.get_family tile), triggers = [], borders = [] } @@ -147,8 +151,8 @@ solve tiles tile_inst = case (Dict.get tile_inst.class_id tiles) of (Just tile) -> {tile_inst | - crossing_cost = (Struct.Tile.get_cost tile), - family = (Struct.Tile.get_family tile) + crossing_cost = (BattleMap.Struct.Tile.get_cost tile), + family = (BattleMap.Struct.Tile.get_family tile) } Nothing -> diff --git a/src/shared/battle-map/BattleMap/View/Tile.elm b/src/shared/battle-map/BattleMap/View/Tile.elm index 6039ff4..d2bf044 100644 --- a/src/shared/battle-map/BattleMap/View/Tile.elm +++ b/src/shared/battle-map/BattleMap/View/Tile.elm @@ -1,4 +1,9 @@ -module BattleMap.View.Tile exposing (get_html, get_html_extra, get_content_html) +module BattleMap.View.Tile exposing + ( + get_html, + get_html_with_extra, + get_content_html + ) -- Elm ------------------------------------------------------------------------- import Html @@ -66,6 +71,7 @@ get_content_html tile = ] [] ) + :: (Html.div [ (Html.Attributes.class "tile-icon-bg"), @@ -173,7 +179,7 @@ get_html display_cost tile = get_html_with_extra : ( Bool -> - (List Html.Attributes.Attribute) -> + (List (Html.Attribute Struct.Event.Type)) -> BattleMap.Struct.TileInstance.Type -> (Html.Html Struct.Event.Type) ) diff --git a/src/shared/battle/Battle/Struct/Omnimods.elm b/src/shared/battle/Battle/Struct/Omnimods.elm index 46843b2..fd0088b 100644 --- a/src/shared/battle/Battle/Struct/Omnimods.elm +++ b/src/shared/battle/Battle/Struct/Omnimods.elm @@ -3,6 +3,7 @@ module Battle.Struct.Omnimods exposing Type, new, merge, + none, apply_to_attributes, apply_to_statistics, get_attack_damage, @@ -11,6 +12,8 @@ module Battle.Struct.Omnimods exposing get_statistics_mods, get_attack_mods, get_defense_mods, + get_all_mods, + scale, decoder ) @@ -47,7 +50,7 @@ type alias GenericMod = generic_mods_decoder : (Json.Decode.Decoder (Dict.Dict String Int)) generic_mods_decoder = (Json.Decode.map - (Dict.fromList) + ((Dict.fromList) >> (Dict.remove "none")) (Json.Decode.list (Json.Decode.map (\gm -> (gm.t, gm.v)) @@ -75,6 +78,9 @@ merge_mods a_mods b_mods = (Dict.empty) ) +scale_dict_value : Float -> String -> Int -> Int +scale_dict_value modifier entry_name value = + (ceiling ((toFloat value) * modifier)) -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- @@ -103,6 +109,15 @@ new attribute_mods statistic_mods attack_mods defense_mods = defense = (Dict.fromList defense_mods) } +none : Type +none = + { + attributes = (Dict.empty), + statistics = (Dict.empty), + attack = (Dict.empty), + defense = (Dict.empty) + } + merge : Type -> Type -> Type merge omni_a omni_b = { @@ -112,18 +127,32 @@ merge omni_a omni_b = defense = (merge_mods omni_a.defense omni_b.defense) } -apply_to_attributes : Type -> Battle.Struct.Attributes.Type -> Battle.Struct.Attributes.Type +apply_to_attributes : ( + Type -> + Battle.Struct.Attributes.Type + -> Battle.Struct.Attributes.Type + ) apply_to_attributes omnimods attributes = (Dict.foldl - ((Battle.Struct.Attributes.decode_category) >> (Battle.Struct.Attributes.mod)) + ( + (Battle.Struct.Attributes.decode_category) + >> (Battle.Struct.Attributes.mod) + ) attributes omnimods.attributes ) -apply_to_statistics : Type -> Battle.Struct.Statistics.Type -> Battle.Struct.Statistics.Type +apply_to_statistics : ( + Type -> + Battle.Struct.Statistics.Type -> + Battle.Struct.Statistics.Type + ) apply_to_statistics omnimods statistics = (Dict.foldl - ((Battle.Struct.Statistics.decode_category) >> (Battle.Struct.Statistics.mod)) + ( + (Battle.Struct.Statistics.decode_category) + >> (Battle.Struct.Statistics.mod) + ) statistics omnimods.statistics ) @@ -139,7 +168,9 @@ get_attack_damage dmg_modifier atk_omni def_omni = ( case (Dict.get - (Battle.Struct.DamageType.encode Battle.Struct.DamageType.Base) + (Battle.Struct.DamageType.encode + Battle.Struct.DamageType.Base + ) def_omni.defense ) of @@ -167,6 +198,16 @@ get_attack_damage dmg_modifier atk_omni def_omni = atk_omni.attack ) +scale : Float -> Type -> Type +scale multiplier omnimods = + {omnimods | + attributes = (Dict.map (scale_dict_value multiplier) omnimods.attributes), + statistics = (Dict.map (scale_dict_value multiplier) omnimods.statistics), + attack = (Dict.map (scale_dict_value multiplier) omnimods.attack), + defense = + (Dict.map (scale_dict_value multiplier) omnimods.defense) + } + get_attributes_mods : Type -> (List (String, Int)) get_attributes_mods omnimods = (Dict.toList omnimods.attributes) @@ -178,3 +219,12 @@ get_attack_mods omnimods = (Dict.toList omnimods.attack) get_defense_mods : Type -> (List (String, Int)) get_defense_mods omnimods = (Dict.toList omnimods.defense) + +get_all_mods : Type -> (List (String, Int)) +get_all_mods omnimods = + ( + (get_attributes_mods omnimods) + ++ (get_statistics_mods omnimods) + ++ (get_attack_mods omnimods) + ++ (get_defense_mods omnimods) + ) |