~ubuntu-branches/ubuntu/saucy/lordsawar/saucy

« back to all changes in this revision

Viewing changes to src/Item.h

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese, Barry deFreese
  • Date: 2008-12-20 13:52:12 UTC
  • mfrom: (1.1.6 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20081220135212-noeb2w3y98ebo7o9
Tags: 0.1.4-1
[ Barry deFreese ]
* New upstream release.
* Move 0.0.8-2.1 changelog entry to correct point in changelog.
* Make lordsawar-data suggest lordsawar.
* Update my e-mail address.
* Add build-depends on intltool, uuid-dev, and libboost-dev.
* Don't install locales since there are no translations currently.
* Add simple man page for new lordsawar-pbm binary.
* Drop gcc4.3 patches as they have been fixed upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include "xmlhelper.h"
26
26
#include "army.h"
27
27
 
28
 
#include "defs.h"
29
28
#include "player.h"
30
29
#include "playerlist.h"
31
 
#include "Renamable.h"
 
30
#include "UniquelyIdentified.h"
 
31
 
 
32
#include "ItemProto.h"
32
33
 
33
34
//! A carryable thing that confers special properties on it's holder.
34
35
/** 
45
46
 * 
46
47
 */
47
48
 
48
 
class Item: public Renamable
 
49
 
 
50
class Item: public ItemProto, public UniquelyIdentified
49
51
{
50
52
    public:
51
 
 
52
 
        // The item can confer these special properties.
53
 
        enum Bonus {
54
 
 
55
 
          //! Add 1 to the strength of the wearer.
56
 
          ADD1STR         = 0x00000001,
57
 
          //! Add 2 to the strength of the wearer.
58
 
          ADD2STR         = 0x00000002,
59
 
          //! Add 3 to the strength of the wearer.
60
 
          ADD3STR         = 0x00000004,
61
 
          //! Add 1 to the strength of the Stack.
62
 
          ADD1STACK       = 0x00000008, 
63
 
          //! Add 2 to the strength of the Stack.
64
 
          ADD2STACK       = 0x00000010,
65
 
          //! Add 3 to the strength of the Stack.
66
 
          ADD3STACK       = 0x00000020, 
67
 
          //! Provides the gift of flight to the Stack.
68
 
          FLYSTACK        = 0x00000040,
69
 
          //! Makes the stack go two times as far.
70
 
          DOUBLEMOVESTACK = 0x00000080,
71
 
          //! Add 2 gold to the Player's treasury per City it holds.
72
 
          ADD2GOLDPERCITY = 0x00000100,
73
 
          //! Add 3 gold to the Player's treasury per City it holds.
74
 
          ADD3GOLDPERCITY = 0x00000200,
75
 
          //! Add 4 gold to the Player's treasury per City it holds.
76
 
          ADD4GOLDPERCITY = 0x00000400,
77
 
          //! Add 5 gold to the Player's treasury per City it holds.
78
 
          ADD5GOLDPERCITY = 0x00000800, 
79
 
 
80
 
        };
81
 
        
 
53
        //! The xml tag of this object in a saved-game file.
 
54
        static std::string d_tag; 
 
55
 
82
56
        //! Loading constructor.
83
57
        Item(XML_Helper* helper);
84
58
 
85
59
        //! Copy constructor.
86
60
        Item(const Item& orig);
87
61
 
 
62
        //! Copy constructor.  make an item from a prototype.
 
63
        Item(const ItemProto &proto);
 
64
 
88
65
        //! Creates a new Item from scratch.
89
66
        Item(std::string name, bool plantable, Player *plantable_owner);
90
67
 
 
68
        static Item* createNonUniqueItem(std::string name, bool plantable,
 
69
                                         Player *plantable_owner);
91
70
        //! Destructor.
92
71
        ~Item();
93
72
        
 
73
        //! Emitted when an item is destroyed.
 
74
        sigc::signal<void, Item*> sdying;
 
75
 
94
76
        //! Save the item to the opened saved-game file.
95
77
        bool save(XML_Helper* helper) const;
96
78
 
97
 
        //! Returns whether or not the Item has a particular special bonus.
98
 
        bool getBonus(Item::Bonus bonus) const;
99
 
 
100
 
        //! Add a bonus to the Item.
101
 
        void addBonus(Item::Bonus bonus);
102
 
 
103
 
        //! Remove a bonus from the Item.
104
 
        void removeBonus(Item::Bonus bonus);
105
 
        
106
 
        //! Return the Id of the Item.  0 means the item is a prototype.
107
 
        Uint32 getId() const {return d_id;}
108
 
 
109
79
        //! Return whether or not the Item is of a kind that can be vectored to.
110
80
        bool isPlantable() const {return d_plantable;}
111
81
 
119
89
        Player *getPlantableOwner() const 
120
90
          {return Playerlist::getInstance()->getPlayer(d_plantable_owner_id);}
121
91
 
122
 
        //! Return some text describing the item's special abilities.
123
 
        std::string getBonusDescription() const;
 
92
        //! Return the type of this item.
 
93
        Uint32 getType() const {return d_type;};
124
94
 
125
95
    private:
126
 
        //! The item's bonus.
127
 
        /**
128
 
         * This value is a bitwise OR-ing of the valuesi in Item::Bonus.
129
 
         */
130
 
        Uint32 d_bonus;
131
 
        
132
 
        //! The Id of the Item.
133
 
        /**
134
 
         * This value is a unique Id among all other game objects.
135
 
         * This value does not change during gameplay.
136
 
         */
137
 
        Uint32 d_id;
 
96
 
 
97
        //! non-default constructor to make an item with a particular id.
 
98
        Item(std::string name, bool plantable, Player *plantable_owner,
 
99
             Uint32 id);
138
100
 
139
101
        /**
140
102
         * This value indicates if the type of this Item can potentially be
158
120
         */
159
121
        //! Whether or not this Item is currently planted.
160
122
        bool d_planted;
 
123
 
 
124
        //! The item was instantiated from the item prototype that has this id.
 
125
        Uint32 d_type;
161
126
};
162
127
 
163
128
#endif //ITEM_H