| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2019-03-26 18:53:44 +0100 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2019-03-26 18:53:44 +0100 | 
| commit | ec2967aab36020c9ea3d8a88877bd448e3b06d40 (patch) | |
| tree | 4e9ff642b80e42851698048ffbd07d587cbae4f7 /src/roster-editor | |
| parent | c48281aff0237837beb91270f6160dadc2476d47 (diff) | |
[Broken] ...
Diffstat (limited to 'src/roster-editor')
| -rw-r--r-- | src/roster-editor/src/Comm/AddArmor.elm | 27 | ||||
| -rw-r--r-- | src/roster-editor/src/Comm/AddPortrait.elm | 33 | ||||
| -rw-r--r-- | src/roster-editor/src/Comm/AddWeapon.elm | 30 | ||||
| -rw-r--r-- | src/roster-editor/src/Comm/Send.elm | 23 | ||||
| -rw-r--r-- | src/roster-editor/src/Comm/UpdateRoster.elm | 5 | ||||
| -rw-r--r-- | src/roster-editor/src/Struct/Character.elm | 195 | ||||
| -rw-r--r-- | src/roster-editor/src/Struct/CharacterRecord.elm | 148 | ||||
| -rw-r--r-- | src/roster-editor/src/Struct/Event.elm | 4 | ||||
| -rw-r--r-- | src/roster-editor/src/Struct/Model.elm | 83 | ||||
| -rw-r--r-- | src/roster-editor/src/Struct/ServerReply.elm | 8 | ||||
| -rw-r--r-- | src/roster-editor/src/Update/HandleServerReply.elm | 16 | ||||
| -rw-r--r-- | src/roster-editor/src/Update/SetGlyphBoard.elm | 22 | ||||
| -rw-r--r-- | src/roster-editor/src/View/CharacterCard.elm | 235 | 
13 files changed, 257 insertions, 572 deletions
| diff --git a/src/roster-editor/src/Comm/AddArmor.elm b/src/roster-editor/src/Comm/AddArmor.elm deleted file mode 100644 index bef92bb..0000000 --- a/src/roster-editor/src/Comm/AddArmor.elm +++ /dev/null @@ -1,27 +0,0 @@ -module Comm.AddArmor exposing (decode) - --- Elm ------------------------------------------------------------------------- -import Json.Decode - --- Battle Characters ----------------------------------------------------------- -import BattleCharacters.Struct.Armor - --- Local Module ---------------------------------------------------------------- -import Struct.ServerReply - --------------------------------------------------------------------------------- --- TYPES ----------------------------------------------------------------------- --------------------------------------------------------------------------------- - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -internal_decoder : BattleCharacters.Struct.Armor.Type -> Struct.ServerReply.Type -internal_decoder ar = (Struct.ServerReply.AddArmor ar) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -decode : (Json.Decode.Decoder Struct.ServerReply.Type) -decode = -   (Json.Decode.map (internal_decoder) (BattleCharacters.Struct.Armor.decoder)) diff --git a/src/roster-editor/src/Comm/AddPortrait.elm b/src/roster-editor/src/Comm/AddPortrait.elm deleted file mode 100644 index 8fd29af..0000000 --- a/src/roster-editor/src/Comm/AddPortrait.elm +++ /dev/null @@ -1,33 +0,0 @@ -module Comm.AddPortrait exposing (decode) - --- Elm ------------------------------------------------------------------------- -import Json.Decode - --- Battle Characters ----------------------------------------------------------- -import BattleCharacters.Struct.Portrait - --- Local Module ---------------------------------------------------------------- -import Struct.ServerReply - --------------------------------------------------------------------------------- --- TYPES ----------------------------------------------------------------------- --------------------------------------------------------------------------------- - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -internal_decoder : ( -      BattleCharacters.Struct.Portrait.Type -> -      Struct.ServerReply.Type -   ) -internal_decoder pt = (Struct.ServerReply.AddPortrait pt) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -decode : (Json.Decode.Decoder Struct.ServerReply.Type) -decode = -   (Json.Decode.map -      (internal_decoder) -      (BattleCharacters.Struct.Portrait.decoder) -   ) diff --git a/src/roster-editor/src/Comm/AddWeapon.elm b/src/roster-editor/src/Comm/AddWeapon.elm deleted file mode 100644 index 73c526f..0000000 --- a/src/roster-editor/src/Comm/AddWeapon.elm +++ /dev/null @@ -1,30 +0,0 @@ -module Comm.AddWeapon exposing (decode) - --- Elm ------------------------------------------------------------------------- -import Json.Decode - --- Battle Characters ----------------------------------------------------------- -import BattleCharacters.Struct.Weapon - --- Local Module ---------------------------------------------------------------- -import Struct.ServerReply - --------------------------------------------------------------------------------- --- TYPES ----------------------------------------------------------------------- --------------------------------------------------------------------------------- - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -internal_decoder : ( -      BattleCharacters.Struct.Weapon.Type -> -      Struct.ServerReply.Type -   ) -internal_decoder wp = (Struct.ServerReply.AddWeapon wp) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -decode : (Json.Decode.Decoder Struct.ServerReply.Type) -decode = -   (Json.Decode.map (internal_decoder) (BattleCharacters.Struct.Weapon.decoder)) diff --git a/src/roster-editor/src/Comm/Send.elm b/src/roster-editor/src/Comm/Send.elm index 605fe1e..23a03bc 100644 --- a/src/roster-editor/src/Comm/Send.elm +++ b/src/roster-editor/src/Comm/Send.elm @@ -6,13 +6,14 @@ import Http  import Json.Decode  import Json.Encode +--- Battle Characters ---------------------------------------------------------- +import BattleCharacters.Comm.AddArmor +import BattleCharacters.Comm.AddGlyph +import BattleCharacters.Comm.AddGlyphBoard +import BattleCharacters.Comm.AddPortrait +import BattleCharacters.Comm.AddWeapon +  --- Local Module --------------------------------------------------------------- -import Comm.AddArmor -import Comm.AddChar -import Comm.AddGlyph -import Comm.AddGlyphBoard -import Comm.AddPortrait -import Comm.AddWeapon  import Comm.GoTo  import Comm.SetInventory @@ -34,11 +35,11 @@ internal_decoder reply_type =        "add_char" -> (Comm.AddChar.decode) -      "add_armor" -> (Comm.AddArmor.decode) -      "add_weapon" -> (Comm.AddWeapon.decode) -      "add_portrait" -> (Comm.AddPortrait.decode) -      "add_glyph" -> (Comm.AddGlyph.decode) -      "add_glyph_board" -> (Comm.AddGlyphBoard.decode) +      "add_armor" -> (BattleCharacters.Comm.AddArmor.decode) +      "add_weapon" -> (BattleCharacters.Comm.AddWeapon.decode) +      "add_portrait" -> (BattleCharacters.Comm.AddPortrait.decode) +      "add_glyph" -> (BattleCharacters.Comm.AddGlyph.decode) +      "add_glyph_board" -> (BattleCharacters.Comm.AddGlyphBoard.decode)        "disconnected" -> (Json.Decode.succeed Struct.ServerReply.Disconnected)        "goto" -> (Comm.GoTo.decode) diff --git a/src/roster-editor/src/Comm/UpdateRoster.elm b/src/roster-editor/src/Comm/UpdateRoster.elm index fb29aee..9f77fc4 100644 --- a/src/roster-editor/src/Comm/UpdateRoster.elm +++ b/src/roster-editor/src/Comm/UpdateRoster.elm @@ -13,7 +13,6 @@ import Comm.Send  import Constants.IO  import Struct.Character -import Struct.CharacterRecord  import Struct.Event  import Struct.Model @@ -35,8 +34,8 @@ try_encoding model =                 "rst",                 (Json.Encode.list                    ( -                     (Struct.CharacterRecord.from_character) -                     >> (Struct.CharacterRecord.encode) +                     (Struct.Character.to_unresolved) +                     >> (Struct.Character.encode)                    )                    (List.filter                       (Struct.Character.get_was_edited) diff --git a/src/roster-editor/src/Struct/Character.elm b/src/roster-editor/src/Struct/Character.elm index 2b64322..5dc7752 100644 --- a/src/roster-editor/src/Struct/Character.elm +++ b/src/roster-editor/src/Struct/Character.elm @@ -1,35 +1,31 @@  module Struct.Character exposing     (        Type, -      new, +      Unresolved,        get_index,        get_battle_index,        set_battle_index, -      get_name, -      set_name, -      get_equipment, -      set_equipment, -      get_current_omnimods, -      get_attributes, -      get_statistics, -      get_is_using_secondary, +      get_base_character, +      set_base_character,        set_was_edited,        get_was_edited, -      switch_weapons +      resolve, +      to_unresolved, +      decoder, +      encode     )  -- Elm ------------------------------------------------------------------------- +import Json.Decode +import Json.Decode.Pipeline + +import Json.Encode  -- Battle ----------------------------------------------------------------------  import Battle.Struct.Omnimods -import Battle.Struct.Attributes -import Battle.Struct.Statistics  -- Battle Characters ----------------------------------------------------------- -import BattleCharacters.Struct.Armor -import BattleCharacters.Struct.Equipment -import BattleCharacters.Struct.Weapon -import BattleCharacters.Struct.GlyphBoard +import BattleCharacters.Struct.Character  --------------------------------------------------------------------------------  -- TYPES ----------------------------------------------------------------------- @@ -38,90 +34,25 @@ type alias Type =     {        ix : Int,        battle_ix : Int, -      name : String, -      equipment : BattleCharacters.Struct.Equipment, -      attributes : Battle.Struct.Attributes.Type, -      statistics : Battle.Struct.Statistics.Type, -      is_using_secondary : Bool, -      current_omnimods : Battle.Struct.Omnimods.Type, -      was_edited : Bool +      was_edited : Bool, +      base : BattleCharacters.Struct.Character.Type +   } + +type alias Unresolved = +   { +      ix : Int, +      battle_ix : Int, +      was_edited : Bool, +      base : BattleCharacters.Struct.Character.Unresolved     }  --------------------------------------------------------------------------------  -- LOCAL -----------------------------------------------------------------------  -------------------------------------------------------------------------------- -refresh_omnimods : Type -> Type -refresh_omnimods char = -   let -      equipment = char.equipment -      current_omnimods = -         (Battle.Struct.Omnimods.merge -            (Battle.Struct.Omnimods.merge -               (BattleCharacters.Struct.Weapon.get_omnimods -                  ( -                     if (char.is_using_secondary) -                     then -                        (BattleCharacters.Struct.Equipment.get_secondary_weapon -                           equipment -                        ) -                     else -                        (BattleCharacters.Struct.Equipment.get_primary_weapon -                           equipment -                        ) -                  ) -               ) -               (BattleCharacters.Struct.Armor.get_omnimods char.armor) -            ) -            (BattleCharacters.Struct.GlyphBoard.get_omnimods_with_glyphs -               (BattleCharacters.Struct.Equipment.get_glyphs equipment) -               (BattleCharacters.Struct.Equipment.get_glyph_board equipment) -            ) -         ) -      current_attributes = -         (Battle.Struct.Omnimods.apply_to_attributes -            current_omnimods -            (Battle.Struct.Attributes.default) -         ) -      current_statistics = -         (Battle.Struct.Omnimods.apply_to_statistics -            current_omnimods -            (Battle.Struct.Statistics.new_raw current_attributes) -         ) -   in -      {char | -         attributes = current_attributes, -         statistics = current_statistics, -         current_omnimods = current_omnimods -      } -  --------------------------------------------------------------------------------  -- EXPORTED --------------------------------------------------------------------  -------------------------------------------------------------------------------- -new : ( -      Int -> -      String -> -      BattleCharacters.Struct.Equipment.Type -> -      Type -   ) -new index name equipment = -   (refresh_omnimods -      { -         ix = index, -         battle_ix = -1, -         name = name, -         equipment = equipment, -         attributes = (Battle.Struct.Attributes.default), -         statistics = -            (Battle.Struct.Statistics.new_raw -               (Battle.Struct.Attributes.default) -            ), -         is_using_secondary = False, -         current_omnimods = (Battle.Struct.Omnimods.none), -         was_edited = False -      } -   ) -  get_index : Type -> Int  get_index c = c.ix @@ -131,29 +62,11 @@ get_battle_index c = c.battle_ix  set_battle_index : Int -> Type -> Type  set_battle_index battle_ix c = {c | battle_ix = battle_ix} -get_name : Type -> String -get_name c = c.name - -set_name : String -> Type -> Type -set_name name char = {char | name = name} - -get_equipment : Type -> BattleCharacters.Struct.Equipment.Type -get_equipment c = c.equipment +get_base_character : Type -> BattleCharacter.Struct.Character +get_base_character c = c.base -set_equipment : BattleCharacters.Struct.Equipment.Type -> Type -> Type -set_equipment equipment char = (refresh_omnimods {char | equipment = equipment}) - -get_current_omnimods : Type -> Battle.Struct.Omnimods.Type -get_current_omnimods c = c.current_omnimods - -get_attributes : Type -> Battle.Struct.Attributes.Type -get_attributes char = char.attributes - -get_statistics : Type -> Battle.Struct.Statistics.Type -get_statistics char = char.statistics - -get_is_using_secondary : Type -> Bool -get_is_using_secondary char = char.is_using_secondary +set_base_character : BattleCharacter.Struct.Character -> Type -> Type +set_base_character base c = {c | base = base }  get_was_edited : Type -> Bool  get_was_edited char = char.was_edited @@ -161,8 +74,56 @@ 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)} +resolve : ( +      ( +         BattleCharacters.Struct.Equipment.Unresolved -> +         BattleCharacters.Struct.Equipment.Type +      ) -> +      Unresolved -> +      Type +   ) +resolve equipment_resolver ref = +   { +      ix = ref.ix, +      battle_ix = ref.battle_ix, +      was_edited = ref.was_edited, +      base = +         (BattleCharacters.Struct.Character.resolve +            (equipment_resolver) +            (Battle.Omnimods.none) +            ref.base +         ) +   } + +to_unresolved : Type -> Unresolved +to_unresolved char = +   { +      ix = char.ix, +      battle_ix = char.battle_ix, +      was_edited = char.was_edited, +      base = (BattleCharacters.Struct.Character.to_unresolved char.base) +   } + +decoder : (Json.Decode.Decoder Unresolved) +decoder = +   (Json.Decode.succeed +      Unresolved +      |> (Json.Decode.Pipeline.required "ix" Json.Decode.int) +      |> (Json.Decode.Pipeline.hardcoded -1) +      |> (Json.Decode.Pipeline.hardcoded False) +      |> +         (Json.Decode.Pipeline.required +            "bas" +            (BattleCharacters.Struct.Character.decoder) +         ) +   ) + +encode : Unresolved -> Json.Encode.Value +encode ref = +   (Json.Encode.object +      [ +         ("ix", (Json.Encode.int ref.ix)), +         ("bix", (Json.Encode.int ref.battle_ix)), +         ("bas", (BattleCharacters.Struct.Character.encode ref.base)) +      ]     ) diff --git a/src/roster-editor/src/Struct/CharacterRecord.elm b/src/roster-editor/src/Struct/CharacterRecord.elm deleted file mode 100644 index 7209d3c..0000000 --- a/src/roster-editor/src/Struct/CharacterRecord.elm +++ /dev/null @@ -1,148 +0,0 @@ -module Struct.CharacterRecord exposing -   ( -      Type, -      get_index, -      get_name, -      get_portrait_id, -      get_armor_id, -      get_main_weapon_id, -      get_secondary_weapon_id, -      get_glyph_board_id, -      get_glyph_ids, -      from_character, -      decoder, -      encode -   ) - --- Elm ------------------------------------------------------------------------- -import Array - -import Json.Decode -import Json.Decode.Pipeline -import Json.Encode - --- Battle Characters ----------------------------------------------------------- -import BattleCharacters.Struct.Armor -import BattleCharacters.Struct.Portrait -import BattleCharacters.Struct.Weapon - --- Local Module ---------------------------------------------------------------- -import Struct.Character -import Struct.Glyph -import Struct.GlyphBoard - --------------------------------------------------------------------------------- --- TYPES ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -type alias Type = -   { -      index : Int, -      name : String, -      portrait_id : String, -      main_weapon_id : String, -      secondary_weapon_id : String, -      armor_id : String, -      glyph_board_id : String, -      glyph_ids : (List String) -   } - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_index : Type -> Int -get_index c = c.index - -get_name : Type -> String -get_name c = c.name - -get_portrait_id : Type -> String -get_portrait_id c = c.portrait_id - -get_main_weapon_id : Type -> String -get_main_weapon_id char = char.main_weapon_id - -get_secondary_weapon_id : Type -> String -get_secondary_weapon_id char = char.secondary_weapon_id - -get_armor_id : Type -> String -get_armor_id char = char.armor_id - -get_glyph_board_id : Type -> String -get_glyph_board_id char = char.glyph_board_id - -get_glyph_ids : Type -> (List String) -get_glyph_ids char = char.glyph_ids - -from_character : Struct.Character.Type -> Type -from_character char = -   { -      index = (Struct.Character.get_index char), -      name = (Struct.Character.get_name char), -      portrait_id = -         (BattleCharacters.Struct.Portrait.get_id -            (Struct.Character.get_portrait char) -         ), -      armor_id = -         (BattleCharacters.Struct.Armor.get_id -            (Struct.Character.get_armor char) -         ), -      main_weapon_id = -         (BattleCharacters.Struct.Weapon.get_id -            (Struct.Character.get_primary_weapon char) -         ), -      secondary_weapon_id = -         (BattleCharacters.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 = -         (Array.toList -            (Array.map -               (Struct.Glyph.get_id) -               (Struct.Character.get_glyphs char) -            ) -         ) -   } - -decoder : (Json.Decode.Decoder Type) -decoder = -   (Json.Decode.succeed -      Type -      |> (Json.Decode.Pipeline.required "ix" Json.Decode.int) -      |> (Json.Decode.Pipeline.required "nam" Json.Decode.string) -      |> (Json.Decode.Pipeline.required "prt" Json.Decode.string) -      |> (Json.Decode.Pipeline.required "awp" Json.Decode.string) -      |> (Json.Decode.Pipeline.required "swp" Json.Decode.string) -      |> (Json.Decode.Pipeline.required "ar" Json.Decode.string) -      |> (Json.Decode.Pipeline.required "gb" Json.Decode.string) -      |> (Json.Decode.Pipeline.required -            "gls" -            (Json.Decode.list Json.Decode.string) -         ) -   ) - -encode : Type -> Json.Encode.Value -encode char = -   (Json.Encode.object -      [ -         ("ix", (Json.Encode.int char.index)), -         ("nam", (Json.Encode.string char.name)), -         ("prt", (Json.Encode.string char.portrait_id)), -         ("awp", (Json.Encode.string char.main_weapon_id)), -         ("swp", (Json.Encode.string char.secondary_weapon_id)), -         ("ar", (Json.Encode.string char.armor_id)), -         ("gb", (Json.Encode.string char.glyph_board_id)), -         ( -            "gls", -            (Json.Encode.list -               (Json.Encode.string) -               char.glyph_ids -            ) -         ) -      ] -   ) diff --git a/src/roster-editor/src/Struct/Event.elm b/src/roster-editor/src/Struct/Event.elm index fa65c87..1dbae24 100644 --- a/src/roster-editor/src/Struct/Event.elm +++ b/src/roster-editor/src/Struct/Event.elm @@ -7,11 +7,11 @@ import Http  import BattleCharacters.Struct.Armor  import BattleCharacters.Struct.Portrait  import BattleCharacters.Struct.Weapon +import BattleCharacters.Struct.Glyph +import BattleCharacters.Struct.GlyphBoard  -- Local Module ----------------------------------------------------------------  import Struct.Error -import Struct.Glyph -import Struct.GlyphBoard  import Struct.HelpRequest  import Struct.ServerReply  import Struct.UI diff --git a/src/roster-editor/src/Struct/Model.elm b/src/roster-editor/src/Struct/Model.elm index 5ed5fbd..b8886aa 100644 --- a/src/roster-editor/src/Struct/Model.elm +++ b/src/roster-editor/src/Struct/Model.elm @@ -2,8 +2,8 @@ module Struct.Model exposing     (        Type,        new, -      add_character_record, -      enable_character_records, +      add_unresolved_character, +      resolve_characters,        update_character,        update_character_fun,        save_character, @@ -32,13 +32,12 @@ import Util.Array  import BattleCharacters.Struct.Armor  import BattleCharacters.Struct.Portrait  import BattleCharacters.Struct.Weapon +import BattleCharacters.Struct.Glyph +import BattleCharacters.Struct.GlyphBoard  -- Local Module ----------------------------------------------------------------  import Struct.Character -import Struct.CharacterRecord  import Struct.Error -import Struct.Glyph -import Struct.GlyphBoard  import Struct.HelpRequest  import Struct.Inventory  import Struct.UI @@ -51,7 +50,7 @@ type alias Type =        flags : Struct.Flags.Type,        help_request : Struct.HelpRequest.Type,        characters : (Array.Array Struct.Character.Type), -      stalled_characters : (List Struct.CharacterRecord.Type), +      unresolved_characters : (List Struct.Character.Unresolved),        weapons :           (Dict.Dict              BattleCharacters.Struct.Weapon.Ref @@ -82,40 +81,26 @@ type alias Type =  --------------------------------------------------------------------------------  -- LOCAL -----------------------------------------------------------------------  -------------------------------------------------------------------------------- -add_character : Struct.CharacterRecord.Type -> Type -> Type -add_character char_rec model = -   let index = (Struct.CharacterRecord.get_index char_rec) in +add_character_from_unresolved : Struct.Character.Unresolved -> Type -> Type +add_character_from_unresolved char_ref model = +   let +      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)) +            ) +            char_ref +         ) +   in        {model |           characters =              (Array.push -               (Struct.Character.new -                  index -                  (Struct.CharacterRecord.get_name char_rec) -                  (Dict.get -                     (Struct.CharacterRecord.get_portrait_id char_rec) -                     model.portraits -                  ) -                  (Dict.get -                     (Struct.CharacterRecord.get_main_weapon_id char_rec) -                     model.weapons -                  ) -                  (Dict.get -                     (Struct.CharacterRecord.get_secondary_weapon_id char_rec) -                     model.weapons -                  ) -                  (Dict.get -                     (Struct.CharacterRecord.get_armor_id char_rec) -                     model.armors -                  ) -                  (Dict.get -                     (Struct.CharacterRecord.get_glyph_board_id char_rec) -                     model.glyph_boards -                  ) -                  (List.map -                     (\e -> (Dict.get e model.glyphs)) -                     (Struct.CharacterRecord.get_glyph_ids char_rec) -                  ) -               ) +               (Struct.Character.get_index char) +               char                 model.characters              )        } @@ -143,7 +128,7 @@ new flags =        flags = flags,        help_request = Struct.HelpRequest.None,        characters = (Array.empty), -      stalled_characters = [], +      unresolved_characters = [],        weapons = (Dict.empty),        armors = (Dict.empty),        glyphs = (Dict.empty), @@ -175,20 +160,24 @@ new flags =        ui = (Struct.UI.default)     } -add_character_record : Struct.CharacterRecord.Type -> Type -> Type -add_character_record char model = +add_unresolved_character : Struct.Character.Unresolved -> Type -> Type +add_unresolved_character char_ref model =     if (has_loaded_data model) -   then (add_character char model) -   else {model | stalled_characters = (char :: model.stalled_characters)} +   then +      (add_character_from_unresolved char_ref model) +   else +      {model | +         unresolved_characters = (char_ref :: model.unresolved_characters) +      } -enable_character_records : Type -> Type -enable_character_records model = +resolve_all_characters : Type -> Type +resolve_all_characters model =     if (has_loaded_data model)     then        (List.foldr -         (add_character) -         {model | stalled_characters = []} -         model.stalled_characters +         (add_character_from_unresolved) +         {model | unresolved_characters = []} +         model.unresolved_characters        )     else        model diff --git a/src/roster-editor/src/Struct/ServerReply.elm b/src/roster-editor/src/Struct/ServerReply.elm index 7201bac..3d0ff79 100644 --- a/src/roster-editor/src/Struct/ServerReply.elm +++ b/src/roster-editor/src/Struct/ServerReply.elm @@ -4,11 +4,11 @@ module Struct.ServerReply exposing (Type(..))  import BattleCharacters.Struct.Armor  import BattleCharacters.Struct.Portrait  import BattleCharacters.Struct.Weapon +import BattleCharacters.Struct.Glyph +import BattleCharacters.Struct.GlyphBoard  -- Local Module ---------------------------------------------------------------- -import Struct.CharacterRecord -import Struct.Glyph -import Struct.GlyphBoard +import Struct.Character  import Struct.Inventory  -------------------------------------------------------------------------------- @@ -25,7 +25,7 @@ type Type =     | AddGlyphBoard Struct.GlyphBoard.Type     | AddPortrait BattleCharacters.Struct.Portrait.Type     | AddWeapon BattleCharacters.Struct.Weapon.Type -   | AddCharacter Struct.CharacterRecord.Type +   | AddCharacter Struct.Character.Unresolved  --------------------------------------------------------------------------------  -- LOCAL ----------------------------------------------------------------------- diff --git a/src/roster-editor/src/Update/HandleServerReply.elm b/src/roster-editor/src/Update/HandleServerReply.elm index 3469ea7..d3ac975 100644 --- a/src/roster-editor/src/Update/HandleServerReply.elm +++ b/src/roster-editor/src/Update/HandleServerReply.elm @@ -18,15 +18,15 @@ import Util.Http  import BattleCharacters.Struct.Armor  import BattleCharacters.Struct.Portrait  import BattleCharacters.Struct.Weapon +import BattleCharacters.Struct.Glyph +import BattleCharacters.Struct.GlyphBoard  -- Local Module ----------------------------------------------------------------  import Constants.IO -import Struct.CharacterRecord +import Struct.Character  import Struct.Error  import Struct.Event -import Struct.Glyph -import Struct.GlyphBoard  import Struct.Inventory  import Struct.Model  import Struct.ServerReply @@ -128,7 +128,7 @@ add_portrait pt current_state =        ((Struct.Model.add_portrait pt model), cmds)  add_glyph : ( -      Struct.Glyph.Type -> +      BattleCharacters.Struct.Glyph.Type ->        (Struct.Model.Type, (List (Cmd Struct.Event.Type))) ->        (Struct.Model.Type, (List (Cmd Struct.Event.Type)))     ) @@ -137,7 +137,7 @@ add_glyph gl current_state =        ((Struct.Model.add_glyph gl model), cmds)  add_glyph_board : ( -      Struct.GlyphBoard.Type -> +      BattleCharacters.Struct.GlyphBoard.Type ->        (Struct.Model.Type, (List (Cmd Struct.Event.Type))) ->        (Struct.Model.Type, (List (Cmd Struct.Event.Type)))     ) @@ -164,14 +164,14 @@ set_inventory inv current_state =        ({model | inventory = inv}, cmds)  add_character : ( -      Struct.CharacterRecord.Type -> +      Struct.Character.Unresolved ->        (Struct.Model.Type, (List (Cmd Struct.Event.Type))) ->        (Struct.Model.Type, (List (Cmd Struct.Event.Type)))     ) -add_character char current_state = +add_character char_ref current_state =     let (model, cmds) = current_state in        ( -         (Struct.Model.add_character_record char model), +         (Struct.Model.add_unresolved_character char_ref model),           cmds        ) diff --git a/src/roster-editor/src/Update/SetGlyphBoard.elm b/src/roster-editor/src/Update/SetGlyphBoard.elm index 45f2b10..ac03e53 100644 --- a/src/roster-editor/src/Update/SetGlyphBoard.elm +++ b/src/roster-editor/src/Update/SetGlyphBoard.elm @@ -3,10 +3,14 @@ module Update.SetGlyphBoard exposing (apply_to)  -- Elm -------------------------------------------------------------------------  import Dict +-- Battle Characters ----------------------------------------------------------- +import BattleCharacters.Struct.Character +import BattleCharacters.Struct.Equipment +import BattleCharacters.Struct.GlyphBoard +  -- Local Module ----------------------------------------------------------------  import Struct.Character  import Struct.Event -import Struct.GlyphBoard  import Struct.Model  -------------------------------------------------------------------------------- @@ -18,7 +22,7 @@ import Struct.Model  --------------------------------------------------------------------------------  apply_to : (        Struct.Model.Type -> -      Struct.GlyphBoard.Ref -> +      BattleCharacters.Struct.GlyphBoard.Ref ->        (Struct.Model.Type, (Cmd Struct.Event.Type))     )  apply_to model ref = @@ -26,10 +30,22 @@ apply_to model ref =        (           case (model.edited_char, (Dict.get ref model.glyph_boards)) of              ((Just char), (Just glyph_board)) -> +               let base_char = (Struct.Character.get_base_character char) in                 {model |                    edited_char =                       (Just -                        (Struct.Character.set_glyph_board glyph_board char) +                        (Struct.Character.set_base_character +                           (BattleCharacters.Struct.Character.set_equipment +                              (BattleCharacters.Struct.Equipment.set_glyph_board +                                 glyph_board +                                 (BattleCharacters.Struct.Character.get_equipment +                                    base_char +                                 ) +                              ) +                              base_char +                           ) +                           char +                        )                       )                 } diff --git a/src/roster-editor/src/View/CharacterCard.elm b/src/roster-editor/src/View/CharacterCard.elm index 10d35dd..d87a9b8 100644 --- a/src/roster-editor/src/View/CharacterCard.elm +++ b/src/roster-editor/src/View/CharacterCard.elm @@ -21,11 +21,11 @@ import Battle.View.Omnimods  -- Battle Characters -----------------------------------------------------------  import BattleCharacters.Struct.Armor  import BattleCharacters.Struct.Weapon +import BattleCharacters.Struct.GlyphBoard  -- Local Module ----------------------------------------------------------------  import Struct.Character  import Struct.Event -import Struct.GlyphBoard  import Struct.UI  import View.Character @@ -65,24 +65,19 @@ get_name char can_edit =           ]        ) -get_health_bar : ( -      Struct.Character.Type -> -      (Html.Html Struct.Event.Type) -   ) -get_health_bar char = -   let -      max = -         (Battle.Struct.Statistics.get_max_health -            (Struct.Character.get_statistics char) -         ) -   in -      (View.Gauge.get_html -         ("HP: " ++ (String.fromInt max)) -         100.0 -         [(Html.Attributes.class "character-card-health")] -         [] -         [] +get_health_bar : Battle.Struct.Statistic.Type -> (Html.Html Struct.Event.Type) +get_health_bar char_stats = +   (View.Gauge.get_html +      ( +         "HP: " +         ++ +         (String.fromInt (Battle.Struct.Statistics.get_max_health char_stats))        ) +      100.0 +      [(Html.Attributes.class "character-card-health")] +      [] +      [] +   )  get_statuses : (        Struct.Character.Type -> @@ -97,26 +92,31 @@ get_statuses char =        ]     ) -get_movement_bar : Struct.Character.Type -> (Html.Html Struct.Event.Type) -get_movement_bar char = -   let -      max = -         (Battle.Struct.Statistics.get_movement_points -            (Struct.Character.get_statistics char) +get_movement_bar : ( +      Battle.Struct.Statistics.Type -> +      (Html.Html Struct.Event.Type) +   ) +get_movement_bar char_stats = +   (View.Gauge.get_html +      ( +         "MP: " +         ++ +         (String.fromInt +            (Battle.Struct.Statistics.get_movement_points char_stats)           ) -   in +      ) +      100.0 +      [(Html.Attributes.class "character-card-movement")] +      [] +      [] +   ) +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 -         ( -            "MP: " -            ++ -            (String.fromInt -               (Battle.Struct.Statistics.get_movement_points -                  (Struct.Character.get_statistics char) -               ) -            ) -         ) +         ("HP: " ++ (String.fromInt max))           100.0 -         [(Html.Attributes.class "character-card-movement")] +         [(Html.Attributes.class "character-card-health")]           []           []        ) @@ -313,7 +313,7 @@ get_armor_details damage_modifier armor =  get_glyph_board_details : (        Float -> -      Struct.GlyphBoard.Type -> +      BattleCharacters.Struct.GlyphBoard.Type ->        (Html.Html Struct.Event.Type)     )  get_glyph_board_details damage_modifier board = @@ -331,46 +331,12 @@ get_glyph_board_details damage_modifier board =                 (Html.Attributes.class "character-card-glyph-board-name")              ]              [ -               (Html.text (Struct.GlyphBoard.get_name board)) +               (Html.text (BattleCharacters.Struct.GlyphBoard.get_name board))              ]           ),           (Battle.View.Omnimods.get_html_with_modifier              damage_modifier -            (Struct.GlyphBoard.get_omnimods board) -         ) -      ] -   ) - -stat_name  : String -> (Html.Html Struct.Event.Type) -stat_name name = -   (Html.div -      [ -         (Html.Attributes.class "omnimod-icon"), -         (Html.Attributes.class ("omnimod-icon-" ++ name)) -      ] -      [ -      ] -   ) - -stat_val : Int -> Bool -> (Html.Html Struct.Event.Type) -stat_val val perc = -   (Html.div -      [ -         (Html.Attributes.class "character-card-stat-val") -      ] -      [ -         (Html.text -            ( -               (String.fromInt val) -               ++ -               ( -                  if perc -                  then -                     "%" -                  else -                     "" -               ) -            ) +            (BattleCharacters.Struct.GlyphBoard.get_omnimods board)           )        ]     ) @@ -389,16 +355,6 @@ get_relevant_stats stats =           )        ]        [ -         (stat_name "dodg"), -         (stat_val (Battle.Struct.Statistics.get_dodges stats) True), -         (stat_name "pary"), -         (stat_val (Battle.Struct.Statistics.get_parries stats) True), -         (stat_name "accu"), -         (stat_val (Battle.Struct.Statistics.get_accuracy stats) False), -         (stat_name "dhit"), -         (stat_val (Battle.Struct.Statistics.get_double_hits stats) True), -         (stat_name "crit"), -         (stat_val (Battle.Struct.Statistics.get_critical_hits stats) True)        ]     ) @@ -416,18 +372,6 @@ get_attributes atts =           )        ]        [ -         (stat_name "con"), -         (stat_val (Battle.Struct.Attributes.get_constitution atts) False), -         (stat_name "str"), -         (stat_val (Battle.Struct.Attributes.get_strength atts) False), -         (stat_name "dex"), -         (stat_val (Battle.Struct.Attributes.get_dexterity atts) False), -         (stat_name "spe"), -         (stat_val (Battle.Struct.Attributes.get_speed atts) False), -         (stat_name "int"), -         (stat_val (Battle.Struct.Attributes.get_intelligence atts) False), -         (stat_name "min"), -         (stat_val (Battle.Struct.Attributes.get_mind atts) False)        ]     ) @@ -437,52 +381,61 @@ get_attributes atts =  --------------------------------------------------------------------------------  get_minimal_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)  get_minimal_html char = -   (Html.div -      [ -         (Html.Attributes.class "info-card"), -         (Html.Attributes.class "info-card-minimal"), -         (Html.Attributes.class "character-card"), -         (Html.Attributes.class "character-card-minimal"), -         (Html.Events.onClick -            (Struct.Event.CharacterSelected -               (Struct.Character.get_index char) +   let +      base_char = (Struct.Character.get_base_character char) +      char_statistics = +         (BattleCharacters.Struct.Character.get_statistics base_char) +   in +      (Html.div +         [ +            (Html.Attributes.class "info-card"), +            (Html.Attributes.class "info-card-minimal"), +            (Html.Attributes.class "character-card"), +            (Html.Attributes.class "character-card-minimal"), +            (Html.Events.onClick +               (Struct.Event.CharacterSelected +                  (Struct.Character.get_index char) +               )              ) -         ) -      ] -      [ -         (get_name char False), -         (Html.div -            [ -               (Html.Attributes.class "info-card-top"), -               (Html.Attributes.class "character-card-top") -            ] -            [ -               (Html.div -                  [ -                     (Html.Attributes.class "info-card-picture") -                  ] -                  [ -                     (View.Character.get_portrait_html True char) -                  ] -               ), -               (get_health_bar char), -               (get_movement_bar char), -               (get_statuses char) -            ] -         ) -      ] -   ) +         ] +         [ +            (get_name base_char False), +            (Html.div +               [ +                  (Html.Attributes.class "info-card-top"), +                  (Html.Attributes.class "character-card-top") +               ] +               [ +                  (Html.div +                     [ +                        (Html.Attributes.class "info-card-picture") +                     ] +                     [ +                        (View.Character.get_portrait_html True char) +                     ] +                  ), +                  (get_health_bar char_statistics), +                  (get_movement_bar char_statistics), +                  (get_statuses char) +               ] +            ) +         ] +      )  get_full_html : Struct.Character.Type -> (Html.Html Struct.Event.Type)  get_full_html char =     let -      is_using_secondary = (Struct.Character.get_is_using_secondary char) -      char_statistics = (Struct.Character.get_statistics char) +      base_char = (Struct.Character.get_base_character char) +      char_statistics = +         (BattleCharacters.Struct.Character.get_statistics base_char)        damage_modifier =           (Battle.Struct.Statistics.get_damage_modifier              char_statistics           ) -      armor = (Struct.Character.get_armor char) +      omnimods = (BattleCharacters.Struct.Character.get_omnimods base_char) +      equipment = (BattleCharacters.Struct.Character.get_equipment base_char) +      is_using_secondary = +         (BattleCharacters.Struct.Character.is_using_secondary base_char)     in        (Html.div           [ @@ -490,7 +443,7 @@ get_full_html char =              (Html.Attributes.class "character-card")           ]           [ -            (get_name char True), +            (get_name base_char True),              (Html.div                 [                    (Html.Attributes.class "info-card-top"), @@ -511,29 +464,33 @@ get_full_html char =                          (View.Character.get_portrait_html False char)                       ]                    ), -                  (get_health_bar char), -                  (get_movement_bar char), +                  (get_health_bar char_statistics), +                  (get_movement_bar char_statistics),                    (get_statuses char)                 ]              ),              (get_weapon_details                 damage_modifier -               (Struct.Character.get_primary_weapon char) +               (BattleCharacters.Struct.Equipment.get_primary_weapon equipment)                 (not is_using_secondary)              ),              (get_armor_details                 damage_modifier -               armor +               (BattleCharacters.Struct.Equipment.get_armor equipment)              ),              (get_glyph_board_details                 damage_modifier -               (Struct.Character.get_glyph_board char) +               (BattleCharacters.Struct.Equipment.get_glyph_board equipment)              ),              (get_relevant_stats char_statistics), -            (get_attributes (Struct.Character.get_attributes char)), +            (get_attributes +               (BattleCharacters.Struct.Character.get_attributes base_char) +            ),              (get_weapon_details                 damage_modifier -               (Struct.Character.get_secondary_weapon char) +               (BattleCharacters.Struct.Equipment.get_secondary_weapon +                  equipment +               )                 is_using_secondary              )           ] | 


