1
/*
2
 *  The Mana World
3
 *  Copyright (C) 2004  The Mana World Development Team
4
 *
5
 *  This file is part of The Mana World.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program; if not, write to the Free Software
19
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
 */
21
22
#ifndef ITEM_H
23
#define ITEM_H
24
25
#include "resources/itemdb.h"
26
27
class Image;
28
29
/**
30
 * Represents one or more instances of a certain item type.
31
 */
32
class Item
33
{
34
    public:
35
        /**
36
         * Constructor.
37
         */
38
        Item(int id = -1, int quantity = 0, bool equipment = false,
39
             bool equipped = false);
40
41
        /**
42
         * Destructor.
43
         */
44
        ~Item();
45
46
        /**
47
         * Sets the item id, identifying the item type.
48
         */
49
        void setId(int id);
50
51
        /**
52
         * Returns the item id.
53
         */
54
        int getId() const { return mId; }
55
56
        /**
57
         * Returns the item image.
58
         */
59
        Image *getImage() { return mImage; }
60
61
        /**
62
         * Returns the item image.
63
         */
64
        Image *getDrawImage() { return mDrawImage; }
65
66
        /**
67
         * Sets the number of items.
68
         */
69
        void setQuantity(int quantity) { mQuantity = quantity; }
70
71
        /**
72
         * Increases the number of items by the given amount.
73
         */
74
        void increaseQuantity(int amount) { mQuantity += amount; }
75
76
        /**
77
         * Returns the number of items.
78
         */
79
        int getQuantity() const { return mQuantity; }
80
81
        /**
82
         * Sets whether this item is considered equipment.
83
         */
84
        void setEquipment(bool equipment) { mEquipment = equipment; }
85
86
        /**
87
         * Returns whether this item is considered equipment.
88
         */
89
        bool isEquipment() const { return mEquipment; }
90
91
        /**
92
         * Sets whether this item is equipped.
93
         */
94
        void setEquipped(bool equipped) { mEquipped = equipped; }
95
96
        /**
97
         * Returns whether this item is equipped.
98
         */
99
        bool isEquipped() const { return mEquipped; }
100
101
        /**
102
         * Sets whether this item is in equipment.
103
         */
104
        void setInEquipment(bool inEquipment) { mInEquipment = inEquipment; }
105
106
        /**
107
         * Returns whether this item is in equipment.
108
         */
109
        bool isInEquipment() const { return mInEquipment; }
110
111
        /**
112
         * Sets the inventory index of this item.
113
         */
114
        void setInvIndex(int index) { mInvIndex = index; }
115
116
        /**
117
         * Returns the inventory index of this item.
118
         */
119
        int getInvIndex() const { return mInvIndex; }
120
121
        /**
122
         * Returns information about this item type.
123
         */
124
        const ItemInfo &getInfo() const { return ItemDB::get(mId); }
125
126
    protected:
127
        int mId;              /**< Item type id. */
128
        Image *mImage;        /**< Item image. */
129
        Image *mDrawImage;    /**< Draw image. */
130
        int mQuantity;        /**< Number of items. */
131
        bool mEquipment;      /**< Item is equipment. */
132
        bool mEquipped;       /**< Item is equipped. */
133
        bool mInEquipment;    /**< Item is in equipment */
134
        int mInvIndex;        /**< Inventory index. */
135
};
136
137
#endif