| summaryrefslogtreecommitdiff | 
diff options
Diffstat (limited to 'src/roster-editor')
| -rw-r--r-- | src/roster-editor/src/ElmModule/Update.elm | 10 | ||||
| -rw-r--r-- | src/roster-editor/src/Struct/Character.elm | 54 | ||||
| -rw-r--r-- | src/roster-editor/src/Struct/CharacterRecord.elm | 8 | ||||
| -rw-r--r-- | src/roster-editor/src/Struct/Event.elm | 3 | ||||
| -rw-r--r-- | src/roster-editor/src/Struct/UI.elm | 11 | ||||
| -rw-r--r-- | src/roster-editor/src/Struct/WeaponSet.elm | 47 | ||||
| -rw-r--r-- | src/roster-editor/src/Update/SetWeapon.elm | 28 | ||||
| -rw-r--r-- | src/roster-editor/src/Update/SwitchWeapons.elm | 41 | ||||
| -rw-r--r-- | src/roster-editor/src/View/ArmorSelection.elm | 2 | ||||
| -rw-r--r-- | src/roster-editor/src/View/CharacterCard.elm | 84 | ||||
| -rw-r--r-- | src/roster-editor/src/View/GlyphBoardSelection.elm | 5 | ||||
| -rw-r--r-- | src/roster-editor/src/View/GlyphSelection.elm | 2 | ||||
| -rw-r--r-- | src/roster-editor/src/View/Omnimods.elm | 55 | ||||
| -rw-r--r-- | src/roster-editor/src/View/WeaponSelection.elm | 2 | 
14 files changed, 200 insertions, 152 deletions
| diff --git a/src/roster-editor/src/ElmModule/Update.elm b/src/roster-editor/src/ElmModule/Update.elm index 97d787d..7e95a3a 100644 --- a/src/roster-editor/src/ElmModule/Update.elm +++ b/src/roster-editor/src/ElmModule/Update.elm @@ -20,6 +20,7 @@ import Update.SetName  import Update.SetPortrait  import Update.SetRequestedHelp  import Update.SetWeapon +import Update.SwitchWeapons  import Update.ToggleBattleIndex  -------------------------------------------------------------------------------- @@ -81,13 +82,8 @@ update event model =        (Struct.Event.SetCharacterName name) ->           (Update.SetName.apply_to new_model name) -      (Struct.Event.ClickedOnWeapon is_main) -> -         (Update.SelectTab.apply_to -            {model | -               ui = (Struct.UI.set_is_selecting_main_weapon is_main model.ui) -            } -            Struct.UI.WeaponSelectionTab -         ) +      (Struct.Event.SwitchWeapons) -> +         (Update.SwitchWeapons.apply_to new_model)        (Struct.Event.ServerReplied result) ->           (Update.HandleServerReply.apply_to model result) diff --git a/src/roster-editor/src/Struct/Character.elm b/src/roster-editor/src/Struct/Character.elm index 958aa58..45e2cbf 100644 --- a/src/roster-editor/src/Struct/Character.elm +++ b/src/roster-editor/src/Struct/Character.elm @@ -14,14 +14,18 @@ module Struct.Character exposing        get_current_omnimods,        get_attributes,        get_statistics, -      get_weapons, -      set_weapons, +      get_primary_weapon, +      set_primary_weapon, +      get_secondary_weapon, +      set_secondary_weapon, +      get_is_using_secondary,        get_glyph_board,        set_glyph_board,        get_glyphs,        set_glyph,        set_was_edited, -      get_was_edited +      get_was_edited, +      switch_weapons     )  -- Elm ------------------------------------------------------------------------- @@ -36,7 +40,6 @@ import Struct.Omnimods  import Struct.Portrait  import Struct.Statistics  import Struct.Weapon -import Struct.WeaponSet  --------------------------------------------------------------------------------  -- TYPES ----------------------------------------------------------------------- @@ -49,7 +52,9 @@ type alias Type =        portrait : Struct.Portrait.Type,        attributes : Struct.Attributes.Type,        statistics : Struct.Statistics.Type, -      weapons : Struct.WeaponSet.Type, +      primary_weapon : Struct.Weapon.Type, +      secondary_weapon : Struct.Weapon.Type, +      is_using_secondary : Bool,        armor : Struct.Armor.Type,        glyph_board : Struct.GlyphBoard.Type,        glyphs : (Array.Array Struct.Glyph.Type), @@ -67,7 +72,11 @@ refresh_omnimods char =           (Struct.Omnimods.merge              (Struct.Omnimods.merge                 (Struct.Weapon.get_omnimods -                  (Struct.WeaponSet.get_active_weapon char.weapons) +                  ( +                     if (char.is_using_secondary) +                     then char.secondary_weapon +                     else char.primary_weapon +                  )                 )                 (Struct.Armor.get_omnimods char.armor)              ) @@ -122,19 +131,18 @@ new index name m_portrait m_main_wp m_sec_wp m_armor m_board m_glyphs =              ),           attributes = (Struct.Attributes.default),           statistics = (Struct.Statistics.new_raw (Struct.Attributes.default)), -         weapons = -            (Struct.WeaponSet.new +         primary_weapon =                 (                    case m_main_wp of                       (Just w) -> w                       Nothing -> (Struct.Weapon.default) -               ) +               ), +         secondary_weapon =                 (                    case m_sec_wp of                       (Just w) -> w                       Nothing -> (Struct.Weapon.default) -               ) -            ), +               ),           armor =              (                 case m_armor of @@ -158,6 +166,7 @@ new index name m_portrait m_main_wp m_sec_wp m_armor m_board m_glyphs =                    m_glyphs                 )              ), +         is_using_secondary = False,           current_omnimods = (Struct.Omnimods.none),           was_edited = False        } @@ -193,11 +202,20 @@ get_attributes char = char.attributes  get_statistics : Type -> Struct.Statistics.Type  get_statistics char = char.statistics -get_weapons : Type -> Struct.WeaponSet.Type -get_weapons char = char.weapons +get_primary_weapon : Type -> Struct.Weapon.Type +get_primary_weapon char = char.primary_weapon + +set_primary_weapon : Struct.Weapon.Type -> Type -> Type +set_primary_weapon wp char = (refresh_omnimods {char | primary_weapon = wp}) -set_weapons : Struct.WeaponSet.Type -> Type -> Type -set_weapons weapons char = (refresh_omnimods {char | weapons = weapons}) +get_secondary_weapon : Type -> Struct.Weapon.Type +get_secondary_weapon char = char.secondary_weapon + +set_secondary_weapon : Struct.Weapon.Type -> Type -> Type +set_secondary_weapon wp char = (refresh_omnimods {char | secondary_weapon = wp}) + +get_is_using_secondary : Type -> Bool +get_is_using_secondary char = char.is_using_secondary  get_armor : Type -> Struct.Armor.Type  get_armor char = char.armor @@ -233,3 +251,9 @@ get_was_edited char = char.was_edited  set_was_edited : Bool -> Type -> Type  set_was_edited val char = {char | was_edited = val} + +switch_weapons : Type -> Type +switch_weapons char = +   (refresh_omnimods +      {char | is_using_secondary = (not char.is_using_secondary)} +   ) diff --git a/src/roster-editor/src/Struct/CharacterRecord.elm b/src/roster-editor/src/Struct/CharacterRecord.elm index de78f27..66fadbe 100644 --- a/src/roster-editor/src/Struct/CharacterRecord.elm +++ b/src/roster-editor/src/Struct/CharacterRecord.elm @@ -28,7 +28,6 @@ import Struct.Glyph  import Struct.GlyphBoard  import Struct.Portrait  import Struct.Weapon -import Struct.WeaponSet  --------------------------------------------------------------------------------  -- TYPES ----------------------------------------------------------------------- @@ -78,9 +77,6 @@ get_glyph_ids char = char.glyph_ids  from_character : Struct.Character.Type -> Type  from_character char = -   let -      weapons = (Struct.Character.get_weapons char) -   in     {        index = (Struct.Character.get_index char),        name = (Struct.Character.get_name char), @@ -88,9 +84,9 @@ from_character char =           (Struct.Portrait.get_id (Struct.Character.get_portrait char)),        armor_id = (Struct.Armor.get_id (Struct.Character.get_armor char)),        main_weapon_id = -         (Struct.Weapon.get_id (Struct.WeaponSet.get_active_weapon weapons)), +         (Struct.Weapon.get_id (Struct.Character.get_primary_weapon char)),        secondary_weapon_id = -         (Struct.Weapon.get_id (Struct.WeaponSet.get_secondary_weapon weapons)), +         (Struct.Weapon.get_id (Struct.Character.get_secondary_weapon char)),        glyph_board_id =           (Struct.GlyphBoard.get_id (Struct.Character.get_glyph_board char)),        glyph_ids = diff --git a/src/roster-editor/src/Struct/Event.elm b/src/roster-editor/src/Struct/Event.elm index 1dafdab..7902338 100644 --- a/src/roster-editor/src/Struct/Event.elm +++ b/src/roster-editor/src/Struct/Event.elm @@ -26,7 +26,6 @@ type Type =     | RequestedHelp Struct.HelpRequest.Type     | ServerReplied (Result Http.Error (List Struct.ServerReply.Type))     | TabSelected Struct.UI.Tab -   | ClickedOnWeapon Bool     | ClickedOnGlyph Int     | SaveRequest     | GoRequest @@ -39,6 +38,8 @@ type Type =     | SelectedPortrait Struct.Portrait.Ref     | SelectedWeapon Struct.Weapon.Ref +   | SwitchWeapons +  attempted : (Result.Result err val) -> Type  attempted act =     case act of diff --git a/src/roster-editor/src/Struct/UI.elm b/src/roster-editor/src/Struct/UI.elm index c128347..1c2041e 100644 --- a/src/roster-editor/src/Struct/UI.elm +++ b/src/roster-editor/src/Struct/UI.elm @@ -7,9 +7,6 @@ module Struct.UI exposing        get_displayed_tab,        set_displayed_tab,        reset_displayed_tab, -      -- Main or Secondary Weapon? -      set_is_selecting_main_weapon, -      is_selecting_main_weapon,        -- Which glyph slot is being edited?        set_glyph_slot,        get_glyph_slot @@ -35,7 +32,6 @@ type Tab =  type alias Type =     {        displayed_tab : Tab, -      is_selecting_main_weapon : Bool,        glyph_slot : Int     } @@ -50,7 +46,6 @@ default : Type  default =     {        displayed_tab = CharacterSelectionTab, -      is_selecting_main_weapon = False,        glyph_slot = -1     } @@ -64,12 +59,6 @@ set_displayed_tab tab ui = {ui | displayed_tab = tab}  reset_displayed_tab : Type -> Type  reset_displayed_tab ui = {ui | displayed_tab = CharacterSelectionTab} -set_is_selecting_main_weapon : Bool -> Type -> Type -set_is_selecting_main_weapon val ui = {ui | is_selecting_main_weapon = val} - -is_selecting_main_weapon : Type -> Bool -is_selecting_main_weapon ui = ui.is_selecting_main_weapon -  get_glyph_slot : Type -> Int  get_glyph_slot ui = ui.glyph_slot diff --git a/src/roster-editor/src/Struct/WeaponSet.elm b/src/roster-editor/src/Struct/WeaponSet.elm deleted file mode 100644 index ac483fe..0000000 --- a/src/roster-editor/src/Struct/WeaponSet.elm +++ /dev/null @@ -1,47 +0,0 @@ -module Struct.WeaponSet exposing -   ( -      Type, -      new, -      get_active_weapon, -      set_active_weapon, -      get_secondary_weapon, -      set_secondary_weapon, -      switch_weapons -   ) - --- Map ------------------------------------------------------------------- -import Struct.Weapon - --------------------------------------------------------------------------------- --- TYPES ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -type alias Type = -   { -      active : Struct.Weapon.Type, -      secondary : Struct.Weapon.Type -   } - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -new : Struct.Weapon.Type -> Struct.Weapon.Type -> Type -new wp0 wp1 = { active = wp0, secondary = wp1 } - -get_active_weapon : Type -> Struct.Weapon.Type -get_active_weapon set = set.active - -set_active_weapon : Struct.Weapon.Type -> Type -> Type -set_active_weapon weapon set = {set | active = weapon} - -get_secondary_weapon : Type -> Struct.Weapon.Type -get_secondary_weapon set = set.secondary - -set_secondary_weapon : Struct.Weapon.Type -> Type -> Type -set_secondary_weapon weapon set = {set | secondary = weapon} - -switch_weapons : Type -> Type -switch_weapons set = {set | active = set.secondary, secondary = set.active} diff --git a/src/roster-editor/src/Update/SetWeapon.elm b/src/roster-editor/src/Update/SetWeapon.elm index ae590c8..24a7885 100644 --- a/src/roster-editor/src/Update/SetWeapon.elm +++ b/src/roster-editor/src/Update/SetWeapon.elm @@ -9,7 +9,6 @@ import Struct.Event  import Struct.Model  import Struct.UI  import Struct.Weapon -import Struct.WeaponSet  --------------------------------------------------------------------------------  -- LOCAL ----------------------------------------------------------------------- @@ -31,21 +30,18 @@ apply_to model ref =                 {model |                    edited_char =                       (Just -                        (Struct.Character.set_weapons -                           ( -                              if (Struct.UI.is_selecting_main_weapon model.ui) -                              then -                                 (Struct.WeaponSet.set_active_weapon -                                    weapon -                                    (Struct.Character.get_weapons char) -                                 ) -                              else -                                 (Struct.WeaponSet.set_secondary_weapon -                                    weapon -                                    (Struct.Character.get_weapons char) -                                 ) -                           ) -                           char +                        ( +                           if (Struct.Character.get_is_using_secondary char) +                           then +                              (Struct.Character.set_secondary_weapon +                                 weapon +                                 char +                              ) +                           else +                              (Struct.Character.set_primary_weapon +                                 weapon +                                 char +                              )                          )                       )                 } diff --git a/src/roster-editor/src/Update/SwitchWeapons.elm b/src/roster-editor/src/Update/SwitchWeapons.elm new file mode 100644 index 0000000..f7675f6 --- /dev/null +++ b/src/roster-editor/src/Update/SwitchWeapons.elm @@ -0,0 +1,41 @@ +module Update.SwitchWeapons exposing (apply_to) + +-- Elm ------------------------------------------------------------------------- +import Dict + +-- Roster Editor --------------------------------------------------------------- +import Struct.Character +import Struct.Event +import Struct.Model +import Struct.UI +import Struct.Weapon + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +apply_to : ( +      Struct.Model.Type -> +      (Struct.Model.Type, (Cmd Struct.Event.Type)) +   ) +apply_to model = +   ( +      ( +         case model.edited_char of +            (Just char) -> +               {model | +                  edited_char = +                     (Just +                        (Struct.Character.switch_weapons +                           char +                        ) +                     ) +               } + +            _ -> model +      ), +      Cmd.none +   ) diff --git a/src/roster-editor/src/View/ArmorSelection.elm b/src/roster-editor/src/View/ArmorSelection.elm index 7566405..71d5e90 100644 --- a/src/roster-editor/src/View/ArmorSelection.elm +++ b/src/roster-editor/src/View/ArmorSelection.elm @@ -55,7 +55,7 @@ get_armor_html armor =                 (Html.text (Struct.Armor.get_name armor))              ]           ), -         (View.Omnimods.get_html 1.0 (Struct.Armor.get_omnimods armor)) +         (View.Omnimods.get_html (Struct.Armor.get_omnimods armor))        ]     ) diff --git a/src/roster-editor/src/View/CharacterCard.elm b/src/roster-editor/src/View/CharacterCard.elm index 08eaa81..569a97b 100644 --- a/src/roster-editor/src/View/CharacterCard.elm +++ b/src/roster-editor/src/View/CharacterCard.elm @@ -21,7 +21,6 @@ import Struct.Omnimods  import Struct.Statistics  import Struct.UI  import Struct.Weapon -import Struct.WeaponSet  import View.Character  import View.Gauge @@ -231,40 +230,39 @@ get_multiplied_mod_html multiplier mod =  get_weapon_details : (        Float ->        Struct.Weapon.Type -> +      Bool ->        (Html.Html Struct.Event.Type)     ) -get_weapon_details damage_multiplier weapon = -   (Html.div -      [ -         (Html.Attributes.class "character-card-weapon"), -         (Html.Attributes.class "clickable"), -         (Html.Events.onClick (Struct.Event.ClickedOnWeapon True)) -     ] -      [ -         (get_weapon_field_header damage_multiplier weapon), -         (View.Omnimods.get_html -            damage_multiplier -            (Struct.Weapon.get_omnimods weapon) -         ) -      ] -   ) - -get_weapon_summary : ( -      Float -> -      Struct.Weapon.Type -> -      (Html.Html Struct.Event.Type) -   ) -get_weapon_summary damage_multiplier weapon = -   (Html.div -      [ -         (Html.Attributes.class "character-card-weapon-summary"), -         (Html.Attributes.class "clickable"), -         (Html.Events.onClick (Struct.Event.ClickedOnWeapon False)) -      ] -      [ -         (get_weapon_field_header damage_multiplier weapon) -      ] -   ) +get_weapon_details damage_multiplier weapon is_active_wp = +   if (is_active_wp) +   then +      (Html.div +         [ +            (Html.Attributes.class "character-card-weapon"), +            (Html.Attributes.class "clickable"), +            (Html.Events.onClick +               (Struct.Event.TabSelected Struct.UI.WeaponSelectionTab) +            ) +        ] +         [ +            (get_weapon_field_header damage_multiplier weapon), +            (View.Omnimods.get_html_for_main_weapon +               damage_multiplier +               (Struct.Weapon.get_omnimods weapon) +            ) +         ] +      ) +   else +      (Html.div +         [ +            (Html.Attributes.class "character-card-weapon-summary"), +            (Html.Attributes.class "clickable"), +            (Html.Events.onClick (Struct.Event.SwitchWeapons)) +         ] +         [ +            (get_weapon_field_header damage_multiplier weapon) +         ] +      )  get_armor_details : (        Struct.Armor.Type -> @@ -288,7 +286,7 @@ get_armor_details armor =                 (Html.text (Struct.Armor.get_name armor))              ]           ), -         (View.Omnimods.get_html 1.0 (Struct.Armor.get_omnimods armor)) +         (View.Omnimods.get_html (Struct.Armor.get_omnimods armor))        ]     ) @@ -314,7 +312,7 @@ get_glyph_board_details board =                 (Html.text (Struct.GlyphBoard.get_name board))              ]           ), -         (View.Omnimods.get_html 1.0 (Struct.GlyphBoard.get_omnimods board)) +         (View.Omnimods.get_html (Struct.GlyphBoard.get_omnimods board))        ]     ) @@ -453,11 +451,9 @@ get_minimal_html char =  get_full_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)  get_full_html char =     let -      weapon_set = (Struct.Character.get_weapons char) -      main_weapon = (Struct.WeaponSet.get_active_weapon weapon_set) +      is_using_secondary = (Struct.Character.get_is_using_secondary char)        char_statistics = (Struct.Character.get_statistics char)        damage_modifier = (Struct.Statistics.get_damage_modifier char_statistics) -      secondary_weapon = (Struct.WeaponSet.get_secondary_weapon weapon_set)        armor = (Struct.Character.get_armor char)     in        (Html.div @@ -492,11 +488,19 @@ get_full_html char =                    (get_statuses char)                 ]              ), -            (get_weapon_details damage_modifier main_weapon), +            (get_weapon_details +               damage_modifier +               (Struct.Character.get_primary_weapon char) +               (not is_using_secondary) +            ),              (get_armor_details armor),              (get_glyph_board_details (Struct.Character.get_glyph_board char)),              (get_relevant_stats char_statistics),              (get_attributes (Struct.Character.get_attributes char)), -            (get_weapon_summary damage_modifier secondary_weapon) +            (get_weapon_details +               damage_modifier +               (Struct.Character.get_secondary_weapon char) +               is_using_secondary +            )           ]        ) diff --git a/src/roster-editor/src/View/GlyphBoardSelection.elm b/src/roster-editor/src/View/GlyphBoardSelection.elm index c2b7999..b6a25b2 100644 --- a/src/roster-editor/src/View/GlyphBoardSelection.elm +++ b/src/roster-editor/src/View/GlyphBoardSelection.elm @@ -55,10 +55,7 @@ get_glyph_board_html glyph_board =                 (Html.text (Struct.GlyphBoard.get_name glyph_board))              ]           ), -         (View.Omnimods.get_html -            1.0 -            (Struct.GlyphBoard.get_omnimods glyph_board) -         ) +         (View.Omnimods.get_html (Struct.GlyphBoard.get_omnimods glyph_board))        ]     ) diff --git a/src/roster-editor/src/View/GlyphSelection.elm b/src/roster-editor/src/View/GlyphSelection.elm index 6158cac..4ee62d0 100644 --- a/src/roster-editor/src/View/GlyphSelection.elm +++ b/src/roster-editor/src/View/GlyphSelection.elm @@ -48,7 +48,7 @@ get_glyph_html glyph  =        ]        [           (Html.text (Struct.Glyph.get_name glyph)), -         (View.Omnimods.get_html 1.0 (Struct.Glyph.get_omnimods glyph)) +         (View.Omnimods.get_html (Struct.Glyph.get_omnimods glyph))        ]     ) diff --git a/src/roster-editor/src/View/Omnimods.elm b/src/roster-editor/src/View/Omnimods.elm index f5d3c86..3856347 100644 --- a/src/roster-editor/src/View/Omnimods.elm +++ b/src/roster-editor/src/View/Omnimods.elm @@ -1,5 +1,6 @@  module View.Omnimods exposing     ( +      get_html_for_main_weapon,        get_html     ) @@ -66,8 +67,12 @@ get_multiplied_mod_html multiplier mod =  --------------------------------------------------------------------------------  -- EXPORTED --------------------------------------------------------------------  -------------------------------------------------------------------------------- -get_html : Float -> Struct.Omnimods.Type -> (Html.Html Struct.Event.Type) -get_html attack_multiplier omnimods = +get_html_for_main_weapon : ( +      Float -> +      Struct.Omnimods.Type -> +      (Html.Html Struct.Event.Type) +   ) +get_html_for_main_weapon attack_multiplier omnimods =     (Html.div        [           (Html.Attributes.class "omnimod-listing") @@ -111,3 +116,49 @@ get_html attack_multiplier omnimods =           )        ]     ) + +get_html : Struct.Omnimods.Type -> (Html.Html Struct.Event.Type) +get_html omnimods = +   (Html.div +      [ +         (Html.Attributes.class "omnimod-listing") +      ] +      [ +         (Html.div +            [ +               (Html.Attributes.class "omnimod-attack-mods") +            ] +            (List.map +               (get_mod_html) +               (Struct.Omnimods.get_attack_mods omnimods) +            ) +         ), +         (Html.div +            [ +               (Html.Attributes.class "omnimod-defense-mods") +            ] +            (List.map +               (get_mod_html) +               (Struct.Omnimods.get_defense_mods omnimods) +            ) +         ), +         (Html.div +            [ +               (Html.Attributes.class "omnimod-attribute-mods") +            ] +            (List.map +               (get_mod_html) +               (Struct.Omnimods.get_attributes_mods omnimods) +            ) +         ), +         (Html.div +            [ +               (Html.Attributes.class "omnimod-statistics-mods") +            ] +            (List.map +               (get_mod_html) +               (Struct.Omnimods.get_statistics_mods omnimods) +            ) +         ) +      ] +   ) diff --git a/src/roster-editor/src/View/WeaponSelection.elm b/src/roster-editor/src/View/WeaponSelection.elm index 46b871d..608568a 100644 --- a/src/roster-editor/src/View/WeaponSelection.elm +++ b/src/roster-editor/src/View/WeaponSelection.elm @@ -98,7 +98,7 @@ get_weapon_html weapon =                 )              ]           ), -         (View.Omnimods.get_html 1.0 (Struct.Weapon.get_omnimods weapon)) +         (View.Omnimods.get_html (Struct.Weapon.get_omnimods weapon))        ]     ) | 


