pub struct Item {
pub typ: ItemType,
pub price: u32,
pub mushroom_price: u32,
pub model_id: u16,
pub class: Option<Class>,
pub type_specific_val: u32,
pub attributes: EnumMap<AttributeType, u32>,
pub gem_slot: Option<GemSlot>,
pub rune: Option<Rune>,
pub enchantment: Option<Enchantment>,
pub color: u8,
}
Expand description
Information about a single item. This can be anything, that is either in a inventory, in a reward slot, or similar
Fields§
§typ: ItemType
The type of this item. May contain further type specific values
price: u32
Either the price to buy, or sell
mushroom_price: u32
The price you would have to pay for this item. Note that this value is junk for other players and potentially in other cases, where you should not be able to see a price
model_id: u16
The model id of this item
class: Option<Class>
The class restriction, that this item has. Will only cover the three main classes
type_specific_val: u32
Either the armor, weapon dmg, or other. You should be using armor()
,
or the weapon types damages though, if you want to have a safe
abstraction. This is only public in case I am missing a case here
attributes: EnumMap<AttributeType, u32>
The stats this item gives, when equipped
gem_slot: Option<GemSlot>
The gemslot of this item, if any. A gemslot can be filled or empty
rune: Option<Rune>
The rune on this item
enchantment: Option<Enchantment>
The enchantment applied to this item
color: u8
This is the color, or other cosmetic variation of an item. There is no clear 1 => red mapping, so only the raw value here
Implementations§
Source§impl Item
impl Item
Sourcepub fn equipment_ident(&self) -> Option<EquipmentIdent>
pub fn equipment_ident(&self) -> Option<EquipmentIdent>
Maps an item to its ident. This is mainly useful, if you want to see, if a item is already in your scrapbook
Sourcepub fn is_unique(&self) -> bool
pub fn is_unique(&self) -> bool
Checks, if this item is unique. Technically they are not always unique, as the scrapbook/keys can be sold, but it should be clear what this is
Sourcepub fn is_legendary(&self) -> bool
pub fn is_legendary(&self) -> bool
Checks if this item is a legendary
Sourcepub fn is_enchantable(&self) -> bool
pub fn is_enchantable(&self) -> bool
Checks, if this item can be enchanted
Sourcepub fn can_be_equipped_by_companion(&self, class: impl Into<Class>) -> bool
pub fn can_be_equipped_by_companion(&self, class: impl Into<Class>) -> bool
Checks if a companion of the given class can equip this item.
Returns true
if the item itself is equipment and this class has the
ability to wear it
Sourcepub fn can_be_equipped_by(&self, class: Class) -> bool
pub fn can_be_equipped_by(&self, class: Class) -> bool
Checks if a character of the given class can equip this item. Note that
this only checks the class, so this will make no sense if you use this
for anything that can not equip items at all (monsters, etc.). For
companions you should use can_companion_equip
Returns true
if the item itself is equipment and this class has the
ability to wear it
Sourcepub fn can_be_used_by(&self, class: Class) -> bool
pub fn can_be_used_by(&self, class: Class) -> bool
Checks if a character of the given class can use this item. If you want
to check equipment, you should use can_be_equipped_by
Returns true
if the item does not have a class requirement, or if the
class requirement matches the given class.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Item
impl<'de> Deserialize<'de> for Item
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Item
impl StructuralPartialEq for Item
Auto Trait Implementations§
impl Freeze for Item
impl RefUnwindSafe for Item
impl Send for Item
impl Sync for Item
impl Unpin for Item
impl UnwindSafe for Item
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.