1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
//! Item categories.


/// Category of an item.
///
/// This roughly describes the item's purpose, such as the slot it can be worn on.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum ItemCategory {
    /// Accessory item (also referred to as jewelry).
    Accessory(AccessoryType),
    /// Armour item.
    Armour(ArmourType),
    /// Weapon item.
    Weapon(WeaponType),
    /// Jewel item.
    ///
    /// This includes jewels socketed into the passive tree,
    /// as well as abyss jewels that can additionally go into abyssal sockets.
    Jewel(JewelType),
    /// A flask.
    Flask,
    /// A map item.
    Map,
    /// Skill gem.
    Gem,
    /// Divination card.
    DivinationCard,
    /// Sealed prophecy item.
    Prophecy,
    /// Relic item.
    Relic,
    /// Currency item.
    Currency,  // NOTE: Keep it as last variant.
}

impl ItemCategory {
    /// Whether items of this category are normally used & consumed by players
    /// rather than being worn.
    ///
    /// Vendor recipes do not count as "use" in this meaning.
    pub fn is_consumable(&self) -> bool {
        match *self {
            ItemCategory::Map |
            ItemCategory::DivinationCard |
            ItemCategory::Currency => true, // TODO: prophecy
            _ => false,
        }
    }

    /// Whether items of this category can be worn on the character.
    ///
    /// Note that this also includes flasks, jewels, and gems,
    /// as they are put into equipment slots either directly or indirectly.
    pub fn is_equippable(&self) -> bool {
        match *self {
            ItemCategory::Accessory(..) |
            ItemCategory::Armour(..) |
            ItemCategory::Weapon(..) |
            ItemCategory::Jewel(..) |
            ItemCategory::Flask |
            ItemCategory::Gem => true,
            _ => false,
        }
    }

    /// Whether items of this category can be modified using currency items.
    pub fn is_modifiable(&self) -> bool {
        match *self {
            ItemCategory::Accessory(..) |
            ItemCategory::Armour(..) |
            ItemCategory::Weapon(..) |
            ItemCategory::Jewel(..) |
            ItemCategory::Flask |
            ItemCategory::Map |
            ItemCategory::Gem => true,
            _ => false,
        }
    }
}


/// Type of an accessory item.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum AccessoryType {
    /// Amulet (necklace).
    ///
    /// This also includes talismans from the Talisman league.
    Amulet,
    /// Belt.
    Belt,
    /// Ring.
    Ring,
}

/// Type of an armor.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum ArmourType {
    /// Head slot item.
    Helmet,
    /// Hand slot item.
    Gloves,
    /// Body armor slot item.
    Chest,
    /// Feet slot item.
    Boots,
    /// A shield.
    Shield,
    /// A quiver.
    Quiver,
}
// TODO: consider introducing a Slot enum (to lump together quivers and shields)

/// Type of a weapon.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum WeaponType {
    /// A bow.
    Bow,
    /// A claw.
    Claw,
    /// A dagger.
    Dagger,
    /// One-handed axe.
    OneHandedAxe,
    /// One-handed mace,
    OneHandedMace,
    /// One-handed sword.
    OneHandedSword,
    /// Scepter (one-handed intelligence-based mace).
    Sceptre,
    /// Staff,
    Staff,
    /// Two-handed axe.
    TwoHandedAxe,
    /// Two-handed mace.
    TwoHandedMace,
    /// Two-handed sword.
    TwoHandedSword,
    /// Wand.
    Wand,
}
// TODO: consider introducing weapon "kind" (mace/staff/sword/axe) that lumps 1H & 2H together;
// bear in mind that "handedness" is ambiguous for bows, though

/// Type of a jewel.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum JewelType {
    /// Regular jewel.
    ///
    /// Those jewels  can only be placed in a passive tree slot.
    Regular,
    /// Abyss jewel.
    ///
    /// These can be placed both in passive tree slots and abyss sockets in gear.
    Abyss
}