aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/roster-editor/src/Update/SetArmor.elm40
-rw-r--r--src/roster-editor/src/Update/SetWeapon.elm66
2 files changed, 54 insertions, 52 deletions
diff --git a/src/roster-editor/src/Update/SetArmor.elm b/src/roster-editor/src/Update/SetArmor.elm
index 8adf9a0..3dc899c 100644
--- a/src/roster-editor/src/Update/SetArmor.elm
+++ b/src/roster-editor/src/Update/SetArmor.elm
@@ -16,6 +16,27 @@ import Struct.Model
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
+equip : (
+ BattleCharacters.Struct.Armor.Type ->
+ Struct.Character.Type ->
+ Struct.Character.Type
+ )
+equip armor char =
+ let base_char = (Struct.Character.get_base_character char) in
+ (Struct.Character.set_is_valid
+ (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
+ )
+ )
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
@@ -30,24 +51,7 @@ 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_base_character
- (BattleCharacters.Struct.Character.set_equipment
- (BattleCharacters.Struct.Equipment.set_armor
- armor
- (BattleCharacters.Struct.Character.get_equipment
- base_char
- )
- )
- base_char
- )
- char
- )
- )
- }
+ {model | edited_char = (Just (equip armor char)) }
_ -> model
),
diff --git a/src/roster-editor/src/Update/SetWeapon.elm b/src/roster-editor/src/Update/SetWeapon.elm
index da385a2..56ded72 100644
--- a/src/roster-editor/src/Update/SetWeapon.elm
+++ b/src/roster-editor/src/Update/SetWeapon.elm
@@ -17,6 +17,37 @@ import Struct.UI
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
+equip : (
+ BattleCharacters.Struct.Weapon.Type ->
+ Struct.Character.Type ->
+ Struct.Character.Type
+ )
+equip weapon char =
+ let base_char = (Struct.Character.get_base_character char) in
+ if (BattleCharacters.Struct.Character.is_using_secondary base_char) then
+ (Struct.Character.set_base_character
+ (BattleCharacters.Struct.Character.set_equipment
+ (BattleCharacters.Struct.Equipment.set_secondary_weapon
+ weapon
+ (BattleCharacters.Struct.Character.get_equipment base_char)
+ )
+ base_char
+ )
+ char
+ )
+ else
+ (Struct.Character.set_is_valid
+ (Struct.Character.set_base_character
+ (BattleCharacters.Struct.Character.set_equipment
+ (BattleCharacters.Struct.Equipment.set_primary_weapon
+ weapon
+ (BattleCharacters.Struct.Character.get_equipment base_char)
+ )
+ base_char
+ )
+ char
+ )
+ )
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
@@ -31,40 +62,7 @@ apply_to model ref =
(
case (model.edited_char, (Dict.get ref model.weapons)) of
((Just char), (Just weapon)) ->
- {model |
- edited_char =
- let
- base_char = (Struct.Character.get_base_character char)
- in
- (Just
- (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
- )
- )
- }
+ {model | edited_char = (Just (equip weapon char)) }
_ -> model
),