summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/roster-editor')
-rw-r--r--src/roster-editor/src/Struct/Inventory.elm7
-rw-r--r--src/roster-editor/src/Struct/Model.elm26
-rw-r--r--src/roster-editor/src/Struct/ServerReply.elm14
-rw-r--r--src/roster-editor/src/Update/HandleServerReply.elm75
4 files changed, 36 insertions, 86 deletions
diff --git a/src/roster-editor/src/Struct/Inventory.elm b/src/roster-editor/src/Struct/Inventory.elm
index 8b31aec..e36d75f 100644
--- a/src/roster-editor/src/Struct/Inventory.elm
+++ b/src/roster-editor/src/Struct/Inventory.elm
@@ -105,7 +105,12 @@ allows equipment inv =
)
&&
(List.all
- (\e -> (has_glyph e inv))
+ (\gl ->
+ (has_glyph
+ (BattleCharacters.Struct.Glyph.get_id gl)
+ inv
+ )
+ )
(Array.toList (BattleCharacters.Struct.Equipment.get_glyphs equipment))
)
&&
diff --git a/src/roster-editor/src/Struct/Model.elm b/src/roster-editor/src/Struct/Model.elm
index d0d70b4..e345aaa 100644
--- a/src/roster-editor/src/Struct/Model.elm
+++ b/src/roster-editor/src/Struct/Model.elm
@@ -25,11 +25,12 @@ import Util.Array
-- Battle Characters -----------------------------------------------------------
import BattleCharacters.Struct.Armor
-import BattleCharacters.Struct.Portrait
-import BattleCharacters.Struct.Weapon
-import BattleCharacters.Struct.Glyph
+import BattleCharacters.Struct.DataSet
import BattleCharacters.Struct.Equipment
+import BattleCharacters.Struct.Glyph
import BattleCharacters.Struct.GlyphBoard
+import BattleCharacters.Struct.Portrait
+import BattleCharacters.Struct.Weapon
-- Local Module ----------------------------------------------------------------
import Struct.Character
@@ -45,7 +46,7 @@ type alias Type =
{
flags : Struct.Flags.Type,
error : (Maybe Struct.Error.Type),
- ui : Struct.UI.Type
+ ui : Struct.UI.Type,
help_request : Struct.HelpRequest.Type,
edited_char : (Maybe Struct.Character.Type),
@@ -56,7 +57,7 @@ type alias Type =
unresolved_characters : (List Struct.Character.Unresolved),
inventory : Struct.Inventory.Type,
- characters_data_set : BattleCharacters.Struct.DataSet.Type,
+ characters_dataset : BattleCharacters.Struct.DataSet.Type
}
--------------------------------------------------------------------------------
@@ -67,7 +68,7 @@ add_character_from_unresolved char_ref model =
let
char =
(Struct.Character.resolve
- (BattleCharacters.Struct.Equipment.resolve model.inventory)
+ (BattleCharacters.Struct.Equipment.resolve model.characters_dataset)
char_ref
)
in
@@ -84,7 +85,7 @@ has_loaded_data : Type -> Bool
has_loaded_data model =
(
((Array.length model.characters) > 0)
- || (BattleCharacters.Struct.DataSet.is_ready model.characters_data_set)
+ || (BattleCharacters.Struct.DataSet.is_ready model.characters_dataset)
)
--------------------------------------------------------------------------------
@@ -97,15 +98,8 @@ new flags =
help_request = Struct.HelpRequest.None,
characters = (Array.empty),
unresolved_characters = [],
- inventory = (BattleCharacters.Struct.Inventory.new),
error = Nothing,
roster_id = "",
- player_id =
- (
- if (flags.user_id == "")
- then "0"
- else flags.user_id
- ),
battle_order =
(Array.repeat
(
@@ -118,10 +112,10 @@ new flags =
)
-1
),
- session_token = flags.token,
edited_char = Nothing,
inventory = (Struct.Inventory.empty),
- ui = (Struct.UI.default)
+ ui = (Struct.UI.default),
+ characters_dataset = (BattleCharacters.Struct.DataSet.new)
}
add_unresolved_character : Struct.Character.Unresolved -> Type -> Type
diff --git a/src/roster-editor/src/Struct/ServerReply.elm b/src/roster-editor/src/Struct/ServerReply.elm
index 8e643bf..d09aa7c 100644
--- a/src/roster-editor/src/Struct/ServerReply.elm
+++ b/src/roster-editor/src/Struct/ServerReply.elm
@@ -1,11 +1,7 @@
module Struct.ServerReply exposing (Type(..))
-- Battle Characters -----------------------------------------------------------
-import BattleCharacters.Struct.Armor
-import BattleCharacters.Struct.Portrait
-import BattleCharacters.Struct.Weapon
-import BattleCharacters.Struct.Glyph
-import BattleCharacters.Struct.GlyphBoard
+import BattleCharacters.Struct.DataSetItem
-- Local Module ----------------------------------------------------------------
import Struct.Character
@@ -19,14 +15,12 @@ type Type =
Okay
| Disconnected
| GoTo String
+
| SetInventory Struct.Inventory.Type
- | AddArmor BattleCharacters.Struct.Armor.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
+ | AddCharactersDataSetItem BattleCharacters.Struct.DataSetItem.Type
+
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
diff --git a/src/roster-editor/src/Update/HandleServerReply.elm b/src/roster-editor/src/Update/HandleServerReply.elm
index 617b72a..0096753 100644
--- a/src/roster-editor/src/Update/HandleServerReply.elm
+++ b/src/roster-editor/src/Update/HandleServerReply.elm
@@ -15,11 +15,7 @@ import Struct.Flags
import Util.Http
-- Battle Characters -----------------------------------------------------------
-import BattleCharacters.Struct.Armor
-import BattleCharacters.Struct.Portrait
-import BattleCharacters.Struct.Weapon
-import BattleCharacters.Struct.Glyph
-import BattleCharacters.Struct.GlyphBoard
+import BattleCharacters.Struct.DataSetItem
-- Local Module ----------------------------------------------------------------
import Constants.IO
@@ -77,50 +73,23 @@ goto url current_state =
]
)
-add_armor : (
- BattleCharacters.Struct.Armor.Type ->
+add_characters_dataset_item : (
+ BattleCharacters.Struct.DataSetItem.Type ->
(Struct.Model.Type, (List (Cmd Struct.Event.Type))) ->
(Struct.Model.Type, (List (Cmd Struct.Event.Type)))
)
-add_armor ar current_state =
+add_characters_dataset_item item current_state =
let (model, cmds) = current_state in
- ((Struct.Model.add_armor ar model), cmds)
-
-add_portrait : (
- BattleCharacters.Struct.Portrait.Type ->
- (Struct.Model.Type, (List (Cmd Struct.Event.Type))) ->
- (Struct.Model.Type, (List (Cmd Struct.Event.Type)))
- )
-add_portrait pt current_state =
- let (model, cmds) = current_state in
- ((Struct.Model.add_portrait pt model), cmds)
-
-add_glyph : (
- BattleCharacters.Struct.Glyph.Type ->
- (Struct.Model.Type, (List (Cmd Struct.Event.Type))) ->
- (Struct.Model.Type, (List (Cmd Struct.Event.Type)))
- )
-add_glyph gl current_state =
- let (model, cmds) = current_state in
- ((Struct.Model.add_glyph gl model), cmds)
-
-add_glyph_board : (
- BattleCharacters.Struct.GlyphBoard.Type ->
- (Struct.Model.Type, (List (Cmd Struct.Event.Type))) ->
- (Struct.Model.Type, (List (Cmd Struct.Event.Type)))
- )
-add_glyph_board glb current_state =
- let (model, cmds) = current_state in
- ((Struct.Model.add_glyph_board glb model), cmds)
-
-add_weapon : (
- BattleCharacters.Struct.Weapon.Type ->
- (Struct.Model.Type, (List (Cmd Struct.Event.Type))) ->
- (Struct.Model.Type, (List (Cmd Struct.Event.Type)))
- )
-add_weapon wp current_state =
- let (model, cmds) = current_state in
- ((Struct.Model.add_weapon wp model), cmds)
+ (
+ {model |
+ characters_dataset =
+ (BattleCharacters.Struct.DataSetItem.add_to
+ item
+ model.characters_dataset
+ )
+ },
+ cmds
+ )
set_inventory : (
Struct.Inventory.Type ->
@@ -154,23 +123,11 @@ apply_command command current_state =
(Struct.ServerReply.GoTo url) -> (goto url current_state)
- (Struct.ServerReply.AddWeapon wp) ->
- (add_weapon wp current_state)
-
(Struct.ServerReply.SetInventory inv) ->
(set_inventory inv current_state)
- (Struct.ServerReply.AddArmor ar) ->
- (add_armor ar current_state)
-
- (Struct.ServerReply.AddPortrait pt) ->
- (add_portrait pt current_state)
-
- (Struct.ServerReply.AddGlyph gl) ->
- (add_glyph gl current_state)
-
- (Struct.ServerReply.AddGlyphBoard glb) ->
- (add_glyph_board glb current_state)
+ (Struct.ServerReply.AddCharactersDataSetItem it) ->
+ (add_characters_dataset_item it current_state)
(Struct.ServerReply.AddCharacter char) ->
(add_character char current_state)