summaryrefslogtreecommitdiff |
diff options
author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-03-27 18:24:38 +0100 |
---|---|---|
committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-03-27 18:24:38 +0100 |
commit | 6ca8f6fbb8083db156c906e848173e827de838ef (patch) | |
tree | 3e887472de809bf8a2210a28e892c9d8782d75b8 /src | |
parent | 4dcb831ddc1f30251b302b129a18c4e08b276989 (diff) |
It compiles again!
Diffstat (limited to 'src')
23 files changed, 180 insertions, 112 deletions
diff --git a/src/battle/src/Update/HandleServerReply.elm b/src/battle/src/Update/HandleServerReply.elm index 9d1aa24..f13118e 100644 --- a/src/battle/src/Update/HandleServerReply.elm +++ b/src/battle/src/Update/HandleServerReply.elm @@ -52,58 +52,6 @@ import Struct.UI -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- -weapon_getter : ( - Struct.Model.Type -> - BattleCharacters.Struct.Weapon.Ref -> - BattleCharacters.Struct.Weapon.Type - ) -weapon_getter model ref = - case (Dict.get ref model.weapons) of - (Just w) -> w - Nothing -> BattleCharacters.Struct.Weapon.none - -armor_getter : ( - Struct.Model.Type -> - BattleCharacters.Struct.Armor.Ref -> - BattleCharacters.Struct.Armor.Type - ) -armor_getter model ref = - case (Dict.get ref model.armors) of - (Just w) -> w - Nothing -> BattleCharacters.Struct.Armor.none - -portrait_getter : ( - Struct.Model.Type -> - BattleCharacters.Struct.Portrait.Ref -> - BattleCharacters.Struct.Portrait.Type - ) -portrait_getter model ref = - case (Dict.get ref model.portraits) of - (Just w) -> w - Nothing -> BattleCharacters.Struct.Portrait.default - -glyph_board_getter : ( - Struct.Model.Type -> - BattleCharacters.Struct.GlyphBoard.Ref -> - BattleCharacters.Struct.GlyphBoard.Type - ) -glyph_board_getter model ref = - case (Dict.get ref model.glyph_boards) of - (Just w) -> w - Nothing -> BattleCharacters.Struct.GlyphBoard.default - -glyph_getter : ( - Struct.Model.Type -> - BattleCharacters.Struct.Glyph.Ref -> - BattleCharacters.Struct.Glyph.Type - ) -glyph_getter model ref = - case (Dict.get ref model.glyphs) of - (Just w) -> w - Nothing -> BattleCharacters.Struct.Glyph.default - ------------ - disconnected : ( (Struct.Model.Type, (List (Cmd Struct.Event.Type))) -> (Struct.Model.Type, (List (Cmd Struct.Event.Type))) @@ -204,11 +152,11 @@ add_character unresolved_char current_state = (Struct.Character.resolve (Struct.Model.tile_omnimods_fun model) (BattleCharacters.Struct.Equipment.resolve - (weapon_getter model) - (armor_getter model) - (portrait_getter model) - (glyph_board_getter model) - (glyph_getter model) + (BattleCharacters.Struct.Weapon.find model.weapons) + (BattleCharacters.Struct.Armor.find model.armors) + (BattleCharacters.Struct.Portrait.find model.portraits) + (BattleCharacters.Struct.GlyphBoard.find model.glyph_boards) + (BattleCharacters.Struct.Glyph.find model.glyphs) ) unresolved_char ) diff --git a/src/battle/src/View/Controlled/CharacterCard.elm b/src/battle/src/View/Controlled/CharacterCard.elm index 785cc02..e64b7f8 100644 --- a/src/battle/src/View/Controlled/CharacterCard.elm +++ b/src/battle/src/View/Controlled/CharacterCard.elm @@ -46,7 +46,7 @@ get_name : ( BattleCharacters.Struct.Character.Type -> (Html.Html Struct.Event.Type) ) -get_name char = +get_name base_char = (Html.div [ (Html.Attributes.class "info-card-name"), @@ -54,7 +54,7 @@ get_name char = (Html.Attributes.class "character-card-name") ] [ - (Html.text (BattleCharacters.Struct.Character.get_name char)) + (Html.text (BattleCharacters.Struct.Character.get_name base_char)) ] ) @@ -399,7 +399,7 @@ get_summary_html char_turn player_ix char = (Html.Attributes.class "character-card") ] [ - (get_name char), + (get_name base_char), (Html.div [ (Html.Attributes.class "info-card-top"), diff --git a/src/roster-editor/src/Comm/AddChar.elm b/src/roster-editor/src/Comm/AddChar.elm index 15eff83..bd4454c 100644 --- a/src/roster-editor/src/Comm/AddChar.elm +++ b/src/roster-editor/src/Comm/AddChar.elm @@ -4,7 +4,7 @@ module Comm.AddChar exposing (decode) import Json.Decode -- Local Module ---------------------------------------------------------------- -import Struct.CharacterRecord +import Struct.Character import Struct.ServerReply -------------------------------------------------------------------------------- @@ -14,12 +14,11 @@ import Struct.ServerReply -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- - -internal_decoder : Struct.CharacterRecord.Type -> Struct.ServerReply.Type -internal_decoder char= (Struct.ServerReply.AddCharacter char) +internal_decoder : Struct.Character.Unresolved -> Struct.ServerReply.Type +internal_decoder char = (Struct.ServerReply.AddCharacter char) -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- decode : (Json.Decode.Decoder Struct.ServerReply.Type) -decode = (Json.Decode.map (internal_decoder) (Struct.CharacterRecord.decoder)) +decode = (Json.Decode.map (internal_decoder) (Struct.Character.decoder)) diff --git a/src/roster-editor/src/Comm/Send.elm b/src/roster-editor/src/Comm/Send.elm index 23a03bc..3253f96 100644 --- a/src/roster-editor/src/Comm/Send.elm +++ b/src/roster-editor/src/Comm/Send.elm @@ -15,6 +15,7 @@ import BattleCharacters.Comm.AddWeapon --- Local Module --------------------------------------------------------------- import Comm.GoTo +import Comm.AddChar import Comm.SetInventory import Struct.Event diff --git a/src/roster-editor/src/Struct/Event.elm b/src/roster-editor/src/Struct/Event.elm index 1dbae24..408f858 100644 --- a/src/roster-editor/src/Struct/Event.elm +++ b/src/roster-editor/src/Struct/Event.elm @@ -35,8 +35,8 @@ type Type = | SetCharacterName String | SelectedArmor BattleCharacters.Struct.Armor.Ref - | SelectedGlyph Struct.Glyph.Ref - | SelectedGlyphBoard Struct.GlyphBoard.Ref + | SelectedGlyph BattleCharacters.Struct.Glyph.Ref + | SelectedGlyphBoard BattleCharacters.Struct.GlyphBoard.Ref | SelectedPortrait BattleCharacters.Struct.Portrait.Ref | SelectedWeapon BattleCharacters.Struct.Weapon.Ref diff --git a/src/roster-editor/src/Struct/Model.elm b/src/roster-editor/src/Struct/Model.elm index 2ba403d..0c304c9 100644 --- a/src/roster-editor/src/Struct/Model.elm +++ b/src/roster-editor/src/Struct/Model.elm @@ -96,11 +96,11 @@ add_character_from_unresolved char_ref model = char = (Struct.Character.resolve (BattleCharacters.Struct.Equipment.resolve - (\e -> (Dict.get e model.weapons)) - (\e -> (Dict.get e model.armors)) - (\e -> (Dict.get e model.portraits)) - (\e -> (Dict.get e model.glyph_boards)) - (\e -> (Dict.get e model.glyphs)) + (BattleCharacters.Struct.Weapon.find model.weapons) + (BattleCharacters.Struct.Armor.find model.armors) + (BattleCharacters.Struct.Portrait.find model.portraits) + (BattleCharacters.Struct.GlyphBoard.find model.glyph_boards) + (BattleCharacters.Struct.Glyph.find model.glyphs) ) char_ref ) @@ -108,7 +108,7 @@ add_character_from_unresolved char_ref model = {model | characters = (Array.push - (Struct.Character.get_index char) +-- (Struct.Character.get_index char) char model.characters ) diff --git a/src/roster-editor/src/Struct/ServerReply.elm b/src/roster-editor/src/Struct/ServerReply.elm index 3d0ff79..8e643bf 100644 --- a/src/roster-editor/src/Struct/ServerReply.elm +++ b/src/roster-editor/src/Struct/ServerReply.elm @@ -21,8 +21,8 @@ type Type = | GoTo String | SetInventory Struct.Inventory.Type | AddArmor BattleCharacters.Struct.Armor.Type - | AddGlyph Struct.Glyph.Type - | AddGlyphBoard Struct.GlyphBoard.Type + | AddGlyph BattleCharacters.Struct.Glyph.Type + | AddGlyphBoard BattleCharacters.Struct.GlyphBoard.Type | AddPortrait BattleCharacters.Struct.Portrait.Type | AddWeapon BattleCharacters.Struct.Weapon.Type | AddCharacter Struct.Character.Unresolved diff --git a/src/roster-editor/src/Update/HandleServerReply.elm b/src/roster-editor/src/Update/HandleServerReply.elm index d3ac975..5f1bc52 100644 --- a/src/roster-editor/src/Update/HandleServerReply.elm +++ b/src/roster-editor/src/Update/HandleServerReply.elm @@ -211,7 +211,7 @@ apply_command command current_state = Struct.ServerReply.Okay -> let (model, cmds) = current_state in ( - (Struct.Model.enable_character_records model), + (Struct.Model.resolve_all_characters model), cmds ) diff --git a/src/roster-editor/src/Update/SetArmor.elm b/src/roster-editor/src/Update/SetArmor.elm index 5878be2..8adf9a0 100644 --- a/src/roster-editor/src/Update/SetArmor.elm +++ b/src/roster-editor/src/Update/SetArmor.elm @@ -5,6 +5,8 @@ import Dict -- Battle Characters ----------------------------------------------------------- import BattleCharacters.Struct.Armor +import BattleCharacters.Struct.Character +import BattleCharacters.Struct.Equipment -- Local Module ---------------------------------------------------------------- import Struct.Character @@ -28,8 +30,23 @@ apply_to model ref = ( case (model.edited_char, (Dict.get ref model.armors)) of ((Just char), (Just armor)) -> + let base_char = (Struct.Character.get_base_character char) in {model | - edited_char = (Just (Struct.Character.set_armor armor char)) + edited_char = + (Just + (Struct.Character.set_base_character + (BattleCharacters.Struct.Character.set_equipment + (BattleCharacters.Struct.Equipment.set_armor + armor + (BattleCharacters.Struct.Character.get_equipment + base_char + ) + ) + base_char + ) + char + ) + ) } _ -> model diff --git a/src/roster-editor/src/Update/SetName.elm b/src/roster-editor/src/Update/SetName.elm index 002af51..6250a73 100644 --- a/src/roster-editor/src/Update/SetName.elm +++ b/src/roster-editor/src/Update/SetName.elm @@ -1,5 +1,8 @@ module Update.SetName exposing (apply_to) +-- Battle Characters ----------------------------------------------------------- +import BattleCharacters.Struct.Character + -- Local Module ---------------------------------------------------------------- import Struct.Character import Struct.Event @@ -24,7 +27,17 @@ apply_to model name = (Just char) -> {model | edited_char = - (Just (Struct.Character.set_name name char)) + (Just + (Struct.Character.set_base_character + (BattleCharacters.Struct.Character.set_name + name + (Struct.Character.get_base_character + char + ) + ) + char + ) + ) } _ -> model diff --git a/src/roster-editor/src/Update/SetPortrait.elm b/src/roster-editor/src/Update/SetPortrait.elm index dc29c13..369d644 100644 --- a/src/roster-editor/src/Update/SetPortrait.elm +++ b/src/roster-editor/src/Update/SetPortrait.elm @@ -4,6 +4,8 @@ module Update.SetPortrait exposing (apply_to) import Dict -- Battle Characters ----------------------------------------------------------- +import BattleCharacters.Struct.Character +import BattleCharacters.Struct.Equipment import BattleCharacters.Struct.Portrait -- Local Module ---------------------------------------------------------------- @@ -28,9 +30,23 @@ apply_to model ref = ( case (model.edited_char, (Dict.get ref model.portraits)) of ((Just char), (Just portrait)) -> + let base_char = (Struct.Character.get_base_character char) in {model | edited_char = - (Just (Struct.Character.set_portrait portrait char)) + (Just + (Struct.Character.set_base_character + (BattleCharacters.Struct.Character.set_equipment + (BattleCharacters.Struct.Equipment.set_portrait + portrait + (BattleCharacters.Struct.Character.get_equipment + base_char + ) + ) + base_char + ) + char + ) + ) } _ -> model diff --git a/src/roster-editor/src/Update/SetWeapon.elm b/src/roster-editor/src/Update/SetWeapon.elm index 1f796b0..da385a2 100644 --- a/src/roster-editor/src/Update/SetWeapon.elm +++ b/src/roster-editor/src/Update/SetWeapon.elm @@ -4,6 +4,8 @@ module Update.SetWeapon exposing (apply_to) import Dict -- Battle Characters ----------------------------------------------------------- +import BattleCharacters.Struct.Character +import BattleCharacters.Struct.Equipment import BattleCharacters.Struct.Weapon -- Local Module ---------------------------------------------------------------- @@ -31,19 +33,35 @@ apply_to model ref = ((Just char), (Just weapon)) -> {model | edited_char = + let + base_char = (Struct.Character.get_base_character char) + in (Just - ( - if (Struct.Character.get_is_using_secondary char) - then - (Struct.Character.set_secondary_weapon - weapon - char - ) - else - (Struct.Character.set_primary_weapon - weapon - char + (Struct.Character.set_base_character + (BattleCharacters.Struct.Character.set_equipment + ( + if + (BattleCharacters.Struct.Character.is_using_secondary + base_char + ) + then + (BattleCharacters.Struct.Equipment.set_secondary_weapon + weapon + (BattleCharacters.Struct.Character.get_equipment + base_char + ) + ) + else + (BattleCharacters.Struct.Equipment.set_primary_weapon + weapon + (BattleCharacters.Struct.Character.get_equipment + base_char + ) + ) ) + base_char + ) + char ) ) } diff --git a/src/roster-editor/src/Update/SwitchWeapons.elm b/src/roster-editor/src/Update/SwitchWeapons.elm index 38f8b8f..40cc7ac 100644 --- a/src/roster-editor/src/Update/SwitchWeapons.elm +++ b/src/roster-editor/src/Update/SwitchWeapons.elm @@ -4,7 +4,7 @@ module Update.SwitchWeapons exposing (apply_to) import Dict -- Battle Characters ----------------------------------------------------------- -import BattleCharacters.Struct.Weapon +import BattleCharacters.Struct.Character -- Local Module ---------------------------------------------------------------- import Struct.Character @@ -31,7 +31,10 @@ apply_to model = {model | edited_char = (Just - (Struct.Character.switch_weapons + (Struct.Character.set_base_character + (BattleCharacters.Struct.Character.switch_weapons + (Struct.Character.get_base_character char) + ) char ) ) diff --git a/src/roster-editor/src/View/Character.elm b/src/roster-editor/src/View/Character.elm index a19b448..1462b07 100644 --- a/src/roster-editor/src/View/Character.elm +++ b/src/roster-editor/src/View/Character.elm @@ -14,7 +14,8 @@ import Util.Html -- Battle Characters ----------------------------------------------------------- import BattleCharacters.Struct.Armor -import BattleCharacters.Struct.Portrait +import BattleCharacters.Struct.Character +import BattleCharacters.Struct.Equipment import BattleCharacters.View.Portrait @@ -46,7 +47,11 @@ get_icon_head_html char = "asset-character-icon-" ++ (BattleCharacters.Struct.Armor.get_image_id - (Struct.Character.get_armor char) + (BattleCharacters.Struct.Equipment.get_armor + (BattleCharacters.Struct.Character.get_equipment + (Struct.Character.get_base_character char) + ) + ) ) ) ) @@ -99,7 +104,9 @@ get_portrait_html click_to_toggle char = else [(Html.Attributes.class "character-portrait-team-0")] ) - char + (BattleCharacters.Struct.Character.get_equipment + (Struct.Character.get_base_character char) + ) ), (get_battle_index_html char) ] diff --git a/src/roster-editor/src/View/CharacterCard.elm b/src/roster-editor/src/View/CharacterCard.elm index d87a9b8..5b1187f 100644 --- a/src/roster-editor/src/View/CharacterCard.elm +++ b/src/roster-editor/src/View/CharacterCard.elm @@ -20,6 +20,8 @@ import Battle.View.Omnimods -- Battle Characters ----------------------------------------------------------- import BattleCharacters.Struct.Armor +import BattleCharacters.Struct.Character +import BattleCharacters.Struct.Equipment import BattleCharacters.Struct.Weapon import BattleCharacters.Struct.GlyphBoard @@ -35,11 +37,11 @@ import View.Gauge -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- get_name : ( - Struct.Character.Type -> + BattleCharacters.Struct.Character.Type -> Bool -> (Html.Html Struct.Event.Type) ) -get_name char can_edit = +get_name base_char can_edit = if can_edit then (Html.input @@ -48,7 +50,9 @@ get_name char can_edit = (Html.Attributes.class "info-card-text-field"), (Html.Attributes.class "character-card-name"), (Html.Events.onInput Struct.Event.SetCharacterName), - (Html.Attributes.value (Struct.Character.get_name char)) + (Html.Attributes.value + (BattleCharacters.Struct.Character.get_name base_char) + ) ] [ ] @@ -61,11 +65,11 @@ get_name char can_edit = (Html.Attributes.class "character-card-name") ] [ - (Html.text (Struct.Character.get_name char)) + (Html.text (BattleCharacters.Struct.Character.get_name base_char)) ] ) -get_health_bar : Battle.Struct.Statistic.Type -> (Html.Html Struct.Event.Type) +get_health_bar : Battle.Struct.Statistics.Type -> (Html.Html Struct.Event.Type) get_health_bar char_stats = (View.Gauge.get_html ( @@ -110,16 +114,6 @@ get_movement_bar char_stats = [] [] ) -get_health_bar : Battle.Struct.Statistic.Type -> (Html.Html Struct.Event.Type) -get_health_bar char_stats = - let max = (Battle.Struct.Statistics.get_max_health char_stats) in - (View.Gauge.get_html - ("HP: " ++ (String.fromInt max)) - 100.0 - [(Html.Attributes.class "character-card-health")] - [] - [] - ) get_weapon_field_header : ( Float -> diff --git a/src/roster-editor/src/View/GlyphManagement.elm b/src/roster-editor/src/View/GlyphManagement.elm index 11fd2fe..072dca3 100644 --- a/src/roster-editor/src/View/GlyphManagement.elm +++ b/src/roster-editor/src/View/GlyphManagement.elm @@ -42,7 +42,7 @@ get_mod_html mod = get_glyph_html : ( Int -> - (Int, Struct.Glyph.Type) + (Int, BattleCharacters.Struct.Glyph.Type) -> (Html.Html Struct.Event.Type) ) get_glyph_html modifier (index, glyph) = diff --git a/src/roster-editor/src/View/WeaponSelection.elm b/src/roster-editor/src/View/WeaponSelection.elm index 2f6f514..7844237 100644 --- a/src/roster-editor/src/View/WeaponSelection.elm +++ b/src/roster-editor/src/View/WeaponSelection.elm @@ -14,6 +14,7 @@ import Util.Html import Battle.View.Omnimods -- Battle Characters ----------------------------------------------------------- +import BattleCharacters.Struct.Character import BattleCharacters.Struct.Weapon -- Local Module ---------------------------------------------------------------- @@ -131,7 +132,9 @@ get_html model = (Just char) -> let is_selecting_secondary = - (Struct.Character.get_is_using_secondary char) + (BattleCharacters.Struct.Character.is_using_secondary + (Struct.Character.get_base_character char) + ) in (Html.div [ diff --git a/src/shared/battle-characters/BattleCharacters/Struct/Armor.elm b/src/shared/battle-characters/BattleCharacters/Struct/Armor.elm index 5cb99d6..93f768c 100644 --- a/src/shared/battle-characters/BattleCharacters/Struct/Armor.elm +++ b/src/shared/battle-characters/BattleCharacters/Struct/Armor.elm @@ -3,6 +3,7 @@ module BattleCharacters.Struct.Armor exposing Type, Ref, new, + find, get_id, get_name, get_image_id, @@ -13,6 +14,8 @@ module BattleCharacters.Struct.Armor exposing ) -- Elm ------------------------------------------------------------------------- +import Dict + import Json.Decode import Json.Decode.Pipeline @@ -38,6 +41,12 @@ type alias Ref = String -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- +find : (Dict.Dict Ref Type) -> Ref -> Type +find dict ref = + case (Dict.get ref dict) of + (Just e) -> e + Nothing -> none + new : String -> String -> Battle.Struct.Omnimods.Type -> Type new id name omnimods = { diff --git a/src/shared/battle-characters/BattleCharacters/Struct/Character.elm b/src/shared/battle-characters/BattleCharacters/Struct/Character.elm index e3ba148..39c7d26 100644 --- a/src/shared/battle-characters/BattleCharacters/Struct/Character.elm +++ b/src/shared/battle-characters/BattleCharacters/Struct/Character.elm @@ -14,6 +14,7 @@ module BattleCharacters.Struct.Character exposing get_statistics, get_active_weapon, get_inactive_weapon, + is_using_secondary, switch_weapons, dirty_switch_weapons, decoder, @@ -148,6 +149,9 @@ get_attributes char = char.attributes get_statistics : Type -> Battle.Struct.Statistics.Type get_statistics char = char.statistics +is_using_secondary : Type -> Bool +is_using_secondary char = char.is_using_secondary + switch_weapons : Type -> Type switch_weapons char = (refresh_omnimods diff --git a/src/shared/battle-characters/BattleCharacters/Struct/Glyph.elm b/src/shared/battle-characters/BattleCharacters/Struct/Glyph.elm index 4cadc6b..9a86fb4 100644 --- a/src/shared/battle-characters/BattleCharacters/Struct/Glyph.elm +++ b/src/shared/battle-characters/BattleCharacters/Struct/Glyph.elm @@ -2,6 +2,7 @@ module BattleCharacters.Struct.Glyph exposing ( Type, Ref, + find, get_name, get_id, get_omnimods, @@ -11,6 +12,8 @@ module BattleCharacters.Struct.Glyph exposing ) -- Elm ------------------------------------------------------------------------- +import Dict + import Json.Decode import Json.Decode.Pipeline @@ -36,6 +39,12 @@ type alias Ref = String -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- +find : (Dict.Dict Ref Type) -> Ref -> Type +find dict ref = + case (Dict.get ref dict) of + (Just e) -> e + Nothing -> none + get_id : Type -> Ref get_id g = g.id diff --git a/src/shared/battle-characters/BattleCharacters/Struct/GlyphBoard.elm b/src/shared/battle-characters/BattleCharacters/Struct/GlyphBoard.elm index 7d08ec0..e8fa0f6 100644 --- a/src/shared/battle-characters/BattleCharacters/Struct/GlyphBoard.elm +++ b/src/shared/battle-characters/BattleCharacters/Struct/GlyphBoard.elm @@ -2,6 +2,7 @@ module BattleCharacters.Struct.GlyphBoard exposing ( Type, Ref, + find, get_name, get_id, get_slots, @@ -15,6 +16,8 @@ module BattleCharacters.Struct.GlyphBoard exposing -- Elm ------------------------------------------------------------------------- import Array +import Dict + import List import Json.Decode @@ -46,6 +49,12 @@ type alias Ref = String -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- +find : (Dict.Dict Ref Type) -> Ref -> Type +find dict ref = + case (Dict.get ref dict) of + (Just e) -> e + Nothing -> none + get_id : Type -> String get_id g = g.id diff --git a/src/shared/battle-characters/BattleCharacters/Struct/Portrait.elm b/src/shared/battle-characters/BattleCharacters/Struct/Portrait.elm index 35f5260..8fe92c0 100644 --- a/src/shared/battle-characters/BattleCharacters/Struct/Portrait.elm +++ b/src/shared/battle-characters/BattleCharacters/Struct/Portrait.elm @@ -2,6 +2,7 @@ module BattleCharacters.Struct.Portrait exposing ( Type, Ref, + find, default, get_id, get_name, @@ -11,6 +12,8 @@ module BattleCharacters.Struct.Portrait exposing ) -- Elm ------------------------------------------------------------------------- +import Dict + import Json.Decode import Json.Decode.Pipeline @@ -34,6 +37,12 @@ type alias Ref = String -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- +find : (Dict.Dict Ref Type) -> Ref -> Type +find dict ref = + case (Dict.get ref dict) of + (Just e) -> e + Nothing -> default + default : Type default = { diff --git a/src/shared/battle-characters/BattleCharacters/Struct/Weapon.elm b/src/shared/battle-characters/BattleCharacters/Struct/Weapon.elm index 0aff932..cea3b0f 100644 --- a/src/shared/battle-characters/BattleCharacters/Struct/Weapon.elm +++ b/src/shared/battle-characters/BattleCharacters/Struct/Weapon.elm @@ -2,6 +2,7 @@ module BattleCharacters.Struct.Weapon exposing ( Type, Ref, + find, get_id, get_name, get_is_primary, @@ -15,6 +16,8 @@ module BattleCharacters.Struct.Weapon exposing ) -- Elm ------------------------------------------------------------------------- +import Dict + import Json.Decode import Json.Decode.Pipeline @@ -44,6 +47,12 @@ type alias Ref = String -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- +find : (Dict.Dict Ref Type) -> Ref -> Type +find dict ref = + case (Dict.get ref dict) of + (Just e) -> e + Nothing -> none + get_id : Type -> String get_id wp = wp.id |