@ -6,11 +6,7 @@ use crate::entity::character::{CharacterEntity, CharacterEntityId, TechLevel};
use crate ::entity ::item ::{ ItemDetail , ItemLocation , BankName } ;
use crate ::entity ::item ::{ Meseta , NewItemEntity , ItemEntity , InventoryItemEntity , EquippedEntity , InventoryEntity , BankItemEntity , BankEntity , ItemType } ;
use crate ::entity ::item ::tool ::{ Tool , ToolType } ;
use crate ::entity ::item ::unit ;
use crate ::entity ::item ::weapon ;
use crate ::entity ::item ::armor ;
use crate ::entity ::item ::shield ;
use crate ::entity ::item ::mag ;
use crate ::entity ::item ::{ unit , weapon , armor , shield , mag , tech , tool , esweapon } ;
use crate ::ship ::map ::MapArea ;
use crate ::ship ::ship ::ItemDropLocation ;
use crate ::ship ::drops ::{ ItemDrop , ItemDropType } ;
@ -506,7 +502,7 @@ impl ItemManager {
let inventory = self . character_inventory . get_mut ( & character . id ) . ok_or ( ItemManagerError ::NoCharacter ( character . id ) ) ? ;
let used_item = inventory . get_item_handle_by_id ( item_id ) . ok_or ( ItemManagerError ::NoSuchItemId ( item_id ) ) ? ;
let consumed_item = used_item . consume ( amount ) ? ;
println ! ( "consumed some item" ) ;
if let ItemDetail ::TechniqueDisk ( tech_disk ) = consumed_item . item ( ) {
// TODO: validate tech level in packet is in bounds [1..30]
character . techs . set_tech ( tech_disk . tech , TechLevel ( tech_disk . level as u8 ) ) ;
@ -645,164 +641,144 @@ impl ItemManager {
let inventory = self . character_inventory . get_mut ( & character . id ) . ok_or ( ItemManagerError ::NoCharacter ( character . id ) ) ? ;
let mut used_item_handle = inventory . get_item_handle_by_id ( client_item_id ) . ok_or ( ItemManagerError ::ItemIdNotInInventory ( client_item_id ) ) ? ;
let used_item = used_item_handle . item_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? ;
match used_item . item_type ( ) {
ItemType ::Armor ( _ ) = > {
let actual_used_item = used_item . individual_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? . armor_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? ;
if actual_used_item . wrapping . is_some ( ) {
actual_used_item . apply_modifier ( & armor ::ArmorModifier ::UnwrapPresent ) ;
entity_gateway . add_armor_modifier ( & used_item . entity_ids ( ) [ 0 ] , armor ::ArmorModifier ::UnwrapPresent ) . await ? ;
} else {
if used_item . is_wrapped ( ) {
used_item . unwrap_present ( ) ;
} else {
match used_item . item_type ( ) {
ItemType ::Armor ( _ ) = > {
let _actual_used_item = used_item . individual_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? . armor_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? ;
// combining / unsealing?
}
} ,
ItemType ::ESWeapon ( _ ) = > {
} ,
ItemType ::Mag ( _ ) = > {
let actual_used_item = used_item . individual_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? . mag_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? ;
if actual_used_item . wrapping . is_some ( ) {
actual_used_item . apply_modifier ( & mag ::MagModifier ::UnwrapPresent ) ;
entity_gateway . add_mag_modifier ( & used_item . entity_ids ( ) [ 0 ] , mag ::MagModifier ::UnwrapPresent ) . await ? ;
} else {
} ,
ItemType ::ESWeapon ( _ ) = > { // TODO: wrap srank weapons
let _actual_used_item = used_item . individual_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? . esweapon_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? ;
// combining / unsealing?
}
} ,
ItemType ::Shield ( _ ) = > {
let actual_used_item = used_item . individual_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? . shield_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? ;
if actual_used_item . wrapping . is_some ( ) {
actual_used_item . apply_modifier ( & shield ::ShieldModifier ::UnwrapPresent ) ;
entity_gateway . add_shield_modifier ( & used_item . entity_ids ( ) [ 0 ] , shield ::ShieldModifier ::UnwrapPresent ) . await ? ;
} else {
} ,
ItemType ::Mag ( _ ) = > {
let _actual_used_item = used_item . individual_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? . mag_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? ;
// combining / unsealing?
}
} ,
ItemType ::TechniqueDisk ( _ ) = > {
} ,
ItemType ::Tool ( _ ) = > {
let consumed_item = used_item . as_consumed_item ( ) ;
match & used_item . item_detail ( ) {
ItemDetail ::Tool ( t ) = > {
match t . tool {
ToolType ::PowerMaterial = > {
use_tool ::power_material ( entity_gateway , character ) . await ;
} ,
ToolType ::MindMaterial = > {
use_tool ::mind_material ( entity_gateway , character ) . await ;
} ,
ToolType ::EvadeMaterial = > {
use_tool ::evade_material ( entity_gateway , character ) . await ;
} ,
ToolType ::DefMaterial = > {
use_tool ::def_material ( entity_gateway , character ) . await ;
} ,
ToolType ::LuckMaterial = > {
use_tool ::luck_material ( entity_gateway , character ) . await ;
} ,
ToolType ::HpMaterial = > {
use_tool ::hp_material ( entity_gateway , character ) . await ;
} ,
ToolType ::TpMaterial = > {
use_tool ::tp_material ( entity_gateway , character ) . await ;
} ,
ToolType ::CellOfMag502 = > {
use_tool ::cell_of_mag_502 ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::CellOfMag213 = > {
use_tool ::cell_of_mag_213 ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::PartsOfRobochao = > {
use_tool ::parts_of_robochao ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::HeartOfOpaOpa = > {
use_tool ::heart_of_opaopa ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::HeartOfPian = > {
use_tool ::heart_of_pian ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::HeartOfChao = > {
use_tool ::heart_of_chao ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::HeartOfAngel = > {
use_tool ::heart_of_angel ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::KitOfHamburger = > {
use_tool ::kit_of_hamburger ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::PanthersSpirit = > {
use_tool ::panthers_spirit ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::KitOfMark3 = > {
use_tool ::kit_of_mark3 ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::KitOfMasterSystem = > {
use_tool ::kit_of_master_system ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::KitOfGenesis = > {
use_tool ::kit_of_genesis ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::KitOfSegaSaturn = > {
use_tool ::kit_of_sega_saturn ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::KitOfDreamcast = > {
use_tool ::kit_of_dreamcast ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::Tablet = > {
use_tool ::tablet ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::DragonScale = > {
use_tool ::dragon_scale ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::HeavenStrikerCoat = > {
use_tool ::heaven_striker_coat ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::PioneerParts = > {
use_tool ::pioneer_parts ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::AmitiesMemo = > {
use_tool ::amities_memo ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::HeartOfMorolian = > {
use_tool ::heart_of_morolian ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::RappysBeak = > {
use_tool ::rappys_beak ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::YahoosEngine = > {
use_tool ::yahoos_engine ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::DPhotonCore = > {
use_tool ::d_photon_core ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::LibertaKit = > {
use_tool ::liberta_kit ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
_ = > { }
}
} ,
ItemType ::Shield ( _ ) = > {
let _actual_used_item = used_item . individual_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? . shield_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? ;
// combining / unsealing?
} ,
ItemType ::TechniqueDisk ( _ ) = > {
let _actual_used_item = used_item . individual_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? . tech_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? ;
// combining / unsealing?
} ,
ItemType ::Tool ( _ ) = > {
let consumed_item = used_item . as_consumed_item ( ) ;
match & used_item . item_detail ( ) {
ItemDetail ::Tool ( t ) = > {
match t . tool {
ToolType ::PowerMaterial = > {
use_tool ::power_material ( entity_gateway , character ) . await ;
} ,
ToolType ::MindMaterial = > {
use_tool ::mind_material ( entity_gateway , character ) . await ;
} ,
ToolType ::EvadeMaterial = > {
use_tool ::evade_material ( entity_gateway , character ) . await ;
} ,
ToolType ::DefMaterial = > {
use_tool ::def_material ( entity_gateway , character ) . await ;
} ,
ToolType ::LuckMaterial = > {
use_tool ::luck_material ( entity_gateway , character ) . await ;
} ,
ToolType ::HpMaterial = > {
use_tool ::hp_material ( entity_gateway , character ) . await ;
} ,
ToolType ::TpMaterial = > {
use_tool ::tp_material ( entity_gateway , character ) . await ;
} ,
ToolType ::CellOfMag502 = > {
use_tool ::cell_of_mag_502 ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::CellOfMag213 = > {
use_tool ::cell_of_mag_213 ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::PartsOfRobochao = > {
use_tool ::parts_of_robochao ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::HeartOfOpaOpa = > {
use_tool ::heart_of_opaopa ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::HeartOfPian = > {
use_tool ::heart_of_pian ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::HeartOfChao = > {
use_tool ::heart_of_chao ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::HeartOfAngel = > {
use_tool ::heart_of_angel ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::KitOfHamburger = > {
use_tool ::kit_of_hamburger ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::PanthersSpirit = > {
use_tool ::panthers_spirit ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::KitOfMark3 = > {
use_tool ::kit_of_mark3 ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::KitOfMasterSystem = > {
use_tool ::kit_of_master_system ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::KitOfGenesis = > {
use_tool ::kit_of_genesis ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::KitOfSegaSaturn = > {
use_tool ::kit_of_sega_saturn ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::KitOfDreamcast = > {
use_tool ::kit_of_dreamcast ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::Tablet = > {
use_tool ::tablet ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::DragonScale = > {
use_tool ::dragon_scale ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::HeavenStrikerCoat = > {
use_tool ::heaven_striker_coat ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::PioneerParts = > {
use_tool ::pioneer_parts ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::AmitiesMemo = > {
use_tool ::amities_memo ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::HeartOfMorolian = > {
use_tool ::heart_of_morolian ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::RappysBeak = > {
use_tool ::rappys_beak ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::YahoosEngine = > {
use_tool ::yahoos_engine ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::DPhotonCore = > {
use_tool ::d_photon_core ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
ToolType ::LibertaKit = > {
use_tool ::liberta_kit ( entity_gateway , & consumed_item , inventory ) . await ? ;
} ,
_ = > { }
}
} ,
_ = > { } ,
}
_ = > { }
}
} ,
ItemType ::Unit ( _ ) = > {
let actual_used_item = used_item . individual_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? . unit_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? ;
if actual_used_item . wrapping . is_some ( ) {
actual_used_item . apply_modifier ( & unit ::UnitModifier ::UnwrapPresent ) ;
entity_gateway . add_unit_modifier ( & used_item . entity_ids ( ) [ 0 ] , unit ::UnitModifier ::UnwrapPresent ) . await ? ;
} else {
} ,
ItemType ::Unit ( _ ) = > {
let _actual_used_item = used_item . individual_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? . unit_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? ;
// combining / unsealing?
}
} ,
ItemType ::Weapon ( _ ) = > {
let actual_used_item = used_item . individual_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? . weapon_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? ;
if actual_used_item . wrapping . is_some ( ) {
actual_used_item . apply_modifier ( & weapon ::WeaponModifier ::UnwrapPresent ) ;
entity_gateway . add_weapon_modifier ( & used_item . entity_ids ( ) [ 0 ] , weapon ::WeaponModifier ::UnwrapPresent ) . await ? ;
} else {
} ,
ItemType ::Weapon ( _ ) = > {
let _actual_used_item = used_item . individual_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? . weapon_mut ( ) . ok_or ( ItemManagerError ::CannotGetMutItem ) ? ;
// combining / unsealing?
}
} ,
} ,
}
}
entity_gateway . set_character_inventory ( & character . id , & inventory . as_inventory_entity ( & character . id ) ) . await ? ;
Ok ( ( ) )
}