~ubuntu-branches/ubuntu/raring/lordsawar/raring

« back to all changes in this revision

Viewing changes to src/Item.h

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese, Barry deFreese, Gonéri Le Bouder
  • Date: 2008-06-17 11:15:26 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080617111526-yjyvu9df50zmpdo0
Tags: 0.0.9-1
[ Barry deFreese ]
* New upstream release.
  + Fixes gcc-4.3 builds so drop ftbfs_gcc-4.3_fix.diff.
  + Add new build-dependency for libgnet-dev.
* Add simple man page for new lordsawar-tile-editor.
* Add desktop file for lordsawar-tile-editor.
* Remove French translation on install.

[ Gonéri Le Bouder ]
* bump Debian Policy to 3.8.0. No change needed.
* fix wording in the 0.0.8-3 entry of the Debian changelog

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2004, 2005, 2006 Ulf Lorenz
 
2
// Copyright (C) 2004 Andrea Paternesi
 
3
// Copyright (C) 2007, 2008 Ben Asselstine
 
4
//
 
5
//  This program is free software; you can redistribute it and/or modify
1
6
//  it under the terms of the GNU General Public License as published by
2
7
//  the Free Software Foundation; either version 2 of the License, or
3
8
//  (at your option) any later version.
9
14
//
10
15
//  You should have received a copy of the GNU General Public License
11
16
//  along with this program; if not, write to the Free Software
12
 
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
17
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
 
18
//  02110-1301, USA.
13
19
 
14
20
#ifndef ITEM_H
15
21
#define ITEM_H
22
28
#include "defs.h"
23
29
#include "player.h"
24
30
#include "playerlist.h"
25
 
 
26
 
/** This class describes an item.
27
 
  * 
28
 
  * Items are defined by three values. They have a type, which determines where
29
 
  * they may be worn (Weapon, Shield, Accessoire etc.), a bonus which determines
30
 
  * what goods they bring to their wielder (strength, defense, army bonus etc.)
31
 
  * and a value which tells how much the stat is raised or what boni the user
32
 
  * gets.
33
 
  *
34
 
  * @note Items occur on two places. First, there is an itemlist which holds
35
 
  * templates of all available items. They can be identified by an id of 0.
36
 
  * Second, there are items in the actual game, which are gained by cloning an
37
 
  * item from the itemlist.
38
 
  *
39
 
  * @note Items should have not more than three boni. If they give an army or
40
 
  * movement bonus, just count each of the boni as one bonus.
41
 
  */
42
 
 
43
 
class Item
 
31
#include "Renamable.h"
 
32
 
 
33
//! A carryable thing that confers special properties on it's holder.
 
34
/** 
 
35
 * This class describes an item.  Items are carried by heroes in a backpack.
 
36
 * When Items are carried they give special abilities to that hero, and 
 
37
 * perhaps the stack it is included in.
 
38
 * Items can be dropped onto the ground, and picked up from the ground.
 
39
 * When a hero dies, all of that hero's items get dropped onto the ground.
 
40
 *
 
41
 * There are "plantable items", that a hero can stick into the ground.  This
 
42
 * gives the ability to vector Army units to that location.  Every player
 
43
 * gets a plantable item, and the item is branded to be usable only by the
 
44
 * player that it belongs to.
 
45
 * 
 
46
 */
 
47
 
 
48
class Item: public Renamable
44
49
{
45
50
    public:
46
51
 
 
52
        // The item can confer these special properties.
47
53
        enum Bonus {
48
54
 
49
 
              ADD1STR         = 0x00000001, //+1 battle
50
 
              ADD2STR         = 0x00000002, //+2 battle
51
 
              ADD3STR         = 0x00000004, //+3 battle
52
 
              ADD1STACK       = 0x00000008, //+1 command
53
 
              ADD2STACK       = 0x00000010, //+2 command
54
 
              ADD3STACK       = 0x00000020, //+3 command
55
 
              FLYSTACK        = 0x00000040, // add flight to stack
56
 
              DOUBLEMOVESTACK = 0x00000080, // double movement
57
 
              ADD2GOLDPERCITY = 0x00000100, // +2 gold per city
58
 
              ADD3GOLDPERCITY = 0x00000200, // +3 gold per city
59
 
              ADD4GOLDPERCITY = 0x00000400, // +4 gold per city
60
 
              ADD5GOLDPERCITY = 0x00000800, // +5 gold per city
 
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, 
61
79
 
62
80
        };
63
81
        
64
 
        /** There are only three useful constructors. This is the loading
65
 
          * constructor which loads an item description from a savegame or
66
 
          * from an item description file
67
 
          */
 
82
        //! Loading constructor.
68
83
        Item(XML_Helper* helper);
69
84
 
70
 
        /** This constructor clones an item from a template for actual use in
71
 
          * the game.
72
 
          */
 
85
        //! Copy constructor.
73
86
        Item(const Item& orig);
74
87
 
75
 
        /** This constructor creates an item for actual use in the game.
76
 
          * No template is used.
77
 
          */
 
88
        //! Creates a new Item from scratch.
78
89
        Item(std::string name, bool plantable, Player *plantable_owner);
79
90
 
80
 
        //! In opposition to other classes, item actually needs its destructor.
 
91
        //! Destructor.
81
92
        ~Item();
82
93
        
83
 
 
84
 
        //! Saves the item data
 
94
        //! Save the item to the opened saved-game file.
85
95
        bool save(XML_Helper* helper) const;
86
96
 
87
 
        //! Returns whether the item has a special bonus
 
97
        //! Returns whether or not the Item has a particular special bonus.
88
98
        bool getBonus(Item::Bonus bonus) const;
89
99
 
90
 
        //! Add a bonus to the item
91
 
        void setBonus(Item::Bonus bonus);
 
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);
92
105
        
93
 
        //! Return the name of the item
94
 
        std::string getName() const {return __(d_name);}
95
 
 
96
 
        //! Return the id of the item. 0 means the item is a template.
 
106
        //! Return the Id of the Item.  0 means the item is a prototype.
97
107
        Uint32 getId() const {return d_id;}
98
108
 
99
 
        //! Return whether or not the item is plantable and able to be
100
 
        //vectored to.
 
109
        //! Return whether or not the Item is of a kind that can be vectored to.
101
110
        bool isPlantable() const {return d_plantable;}
102
111
 
103
 
        //!Set the item as planted or not.
 
112
        //! Set the planted status of the Item.
104
113
        void setPlanted(bool planted) {d_planted = planted;}
105
114
 
106
 
        //!Set the item as planted or not.
 
115
        //! Get the planted status of the Item.
107
116
        bool getPlanted() const {return d_planted;}
108
117
 
109
 
        //! Return the player that can plant this item.
 
118
        //! Return the Player who can plant this particular Item.
110
119
        Player *getPlantableOwner() const 
111
120
          {return Playerlist::getInstance()->getPlayer(d_plantable_owner_id);}
112
121
 
113
 
        //! Return some text describing the item's abilities
114
 
        std::string getBonusDescription();
 
122
        //! Return some text describing the item's special abilities.
 
123
        std::string getBonusDescription() const;
115
124
 
116
125
    private:
 
126
        //! The item's bonus.
 
127
        /**
 
128
         * This value is a bitwise OR-ing of the valuesi in Item::Bonus.
 
129
         */
117
130
        Uint32 d_bonus;
118
131
        
119
 
        std::string d_name;
 
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
         */
120
137
        Uint32 d_id;
 
138
 
 
139
        /**
 
140
         * This value indicates if the type of this Item can potentially be
 
141
         * planted into the ground on the GameMap, and subsequently have 
 
142
         * Army units vectored to that position.
 
143
         */
121
144
        bool d_plantable;
 
145
 
 
146
        /**
 
147
         * If the Item is plantable, this value is used to determine if the
 
148
         * correct Player is attempting to plant the Item into the ground.
 
149
         * For example, the red player cannot plant the flag belonging to the
 
150
         * yellow player.
 
151
         */
 
152
        //! The Id of the Player who can plant this Item.
122
153
        Uint32 d_plantable_owner_id;
 
154
 
 
155
        /**
 
156
         * When the Item is planted, the player can vector Army units to 
 
157
         * this item's position on the GameMap.
 
158
         */
 
159
        //! Whether or not this Item is currently planted.
123
160
        bool d_planted;
124
161
};
125
162