| summaryrefslogtreecommitdiff | 
diff options
Diffstat (limited to 'src/roster-editor')
| -rw-r--r-- | src/roster-editor/src/Struct/Inventory.elm | 54 | ||||
| -rw-r--r-- | src/roster-editor/src/Struct/Model.elm | 19 | 
2 files changed, 44 insertions, 29 deletions
diff --git a/src/roster-editor/src/Struct/Inventory.elm b/src/roster-editor/src/Struct/Inventory.elm index e04e828..85ae5b5 100644 --- a/src/roster-editor/src/Struct/Inventory.elm +++ b/src/roster-editor/src/Struct/Inventory.elm @@ -25,6 +25,7 @@ import BattleCharacters.Struct.Equipment  import BattleCharacters.Struct.Glyph  import BattleCharacters.Struct.GlyphBoard  import BattleCharacters.Struct.Portrait +import BattleCharacters.Struct.Skill  import BattleCharacters.Struct.Weapon  -------------------------------------------------------------------------------- @@ -36,7 +37,8 @@ type alias Type =        glyphs : (Set.Set BattleCharacters.Struct.Glyph.Ref),        glyph_boards : (Set.Set BattleCharacters.Struct.GlyphBoard.Ref),        weapons : (Set.Set BattleCharacters.Struct.Weapon.Ref), -      armors : (Set.Set BattleCharacters.Struct.Armor.Ref) +      armors : (Set.Set BattleCharacters.Struct.Armor.Ref), +      skills : (Set.Set BattleCharacters.Struct.Skill.Ref)     }  -------------------------------------------------------------------------------- @@ -46,63 +48,73 @@ type alias Type =  --------------------------------------------------------------------------------  -- EXPORTED --------------------------------------------------------------------  -------------------------------------------------------------------------------- -has_portrait : Type -> BattleCharacters.Struct.Portrait.Ref -> Bool -has_portrait inv id = (Set.member id inv.portraits) +has_portrait : BattleCharacters.Struct.Portrait.Ref -> Type -> Bool +has_portrait id inv = (Set.member id inv.portraits) -has_glyph : Type -> BattleCharacters.Struct.Glyph.Ref -> Bool -has_glyph inv id = (Set.member id inv.glyphs) +has_glyph : BattleCharacters.Struct.Glyph.Ref -> Type -> Bool +has_glyph id inv = (Set.member id inv.glyphs) -has_glyph_board : Type -> BattleCharacters.Struct.GlyphBoard.Ref -> Bool -has_glyph_board inv id = (Set.member id inv.glyph_boards) +has_glyph_board : BattleCharacters.Struct.GlyphBoard.Ref -> Type -> Bool +has_glyph_board id inv = (Set.member id inv.glyph_boards) -has_weapon : Type -> BattleCharacters.Struct.Weapon.Ref -> Bool -has_weapon inv id = (Set.member id inv.weapons) +has_weapon : BattleCharacters.Struct.Weapon.Ref -> Type -> Bool +has_weapon id inv = (Set.member id inv.weapons) -has_armor : Type -> BattleCharacters.Struct.Armor.Ref -> Bool -has_armor inv id = (Set.member id inv.armors) +has_armor : BattleCharacters.Struct.Armor.Ref -> Type -> Bool +has_armor id inv = (Set.member id inv.armors) -allows : Type -> BattleCharacters.Struct.Equipment.Type -> Bool -allows inv equipment = +has_skill : BattleCharacters.Struct.Skill.Ref -> Type -> Bool +has_skill id inv = (Set.member id inv.skills) + +allows : BattleCharacters.Struct.Equipment.Type -> Type -> Bool +allows equipment inv =     (        (has_weapon -         inv           (BattleCharacters.Struct.Weapon.get_id              (BattleCharacters.Struct.Equipment.get_primary_weapon equipment)           ) +         inv        )        &&        (has_weapon -         inv           (BattleCharacters.Struct.Weapon.get_id              (BattleCharacters.Struct.Equipment.get_secondary_weapon equipment)           ) +         inv        )        &&        (has_armor -         inv           (BattleCharacters.Struct.Armor.get_id              (BattleCharacters.Struct.Equipment.get_armor equipment)           ) +         inv        )        &&        (has_portrait -         inv           (BattleCharacters.Struct.Portrait.get_id              (BattleCharacters.Struct.Equipment.get_portrait equipment)           ) +         inv        )        &&        (has_glyph_board -         inv           (BattleCharacters.Struct.GlyphBoard.get_id              (BattleCharacters.Struct.Equipment.get_glyph_board equipment)           ) +         inv        )        &&        (List.all -         ((BattleCharacters.Struct.Glyph.get_id) >> (has_glyph inv)) +         (e -> (has_glyph e inv))           (Array.toList (BattleCharacters.Struct.Equipment.get_glyphs equipment))        ) +      && +      (has_skill +         (BattleCharacters.Struct.Skill.get_id +            (BattleCharacters.Struct.Equipment.get_skill equipment) +         ) +         inv +      )     )  empty : Type @@ -112,7 +124,8 @@ empty =        glyphs = (Set.empty),        glyph_boards = (Set.empty),        weapons = (Set.empty), -      armors = (Set.empty) +      armors = (Set.empty), +      skills = (Set.empty)     }  decoder : (Json.Decode.Decoder Type) @@ -125,4 +138,5 @@ decoder =        |> (Json.Decode.Pipeline.hardcoded (Set.empty))        |> (Json.Decode.Pipeline.hardcoded (Set.empty))        |> (Json.Decode.Pipeline.hardcoded (Set.empty)) +      |> (Json.Decode.Pipeline.hardcoded (Set.empty))     ) diff --git a/src/roster-editor/src/Struct/Model.elm b/src/roster-editor/src/Struct/Model.elm index 3e573f9..d0d70b4 100644 --- a/src/roster-editor/src/Struct/Model.elm +++ b/src/roster-editor/src/Struct/Model.elm @@ -44,18 +44,19 @@ import Struct.UI  type alias Type =     {        flags : Struct.Flags.Type, +      error : (Maybe Struct.Error.Type), +      ui : Struct.UI.Type        help_request : Struct.HelpRequest.Type, +      edited_char : (Maybe Struct.Character.Type), + +      roster_id : String, +      battle_order : (Array.Array Int), +        characters : (Array.Array Struct.Character.Type),        unresolved_characters : (List Struct.Character.Unresolved), -      inventory : BattleCharacters.Struct.Inventory.Type, -      error : (Maybe Struct.Error.Type), -      battle_order : (Array.Array Int), -      player_id : String, -      roster_id : String, -      edited_char : (Maybe Struct.Character.Type),        inventory : Struct.Inventory.Type, -      session_token : String, -      ui : Struct.UI.Type + +      characters_data_set : BattleCharacters.Struct.DataSet.Type,     }  -------------------------------------------------------------------------------- @@ -83,7 +84,7 @@ has_loaded_data : Type -> Bool  has_loaded_data model =     (        ((Array.length model.characters) > 0) -      || (BattleCharacters.Struct.Inventory.is_ready model.inventory) +      || (BattleCharacters.Struct.DataSet.is_ready model.characters_data_set)     )  --------------------------------------------------------------------------------  | 


