OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
BattleItem.h
1 /*
2  * Copyright 2010-2014 OpenXcom Developers.
3  *
4  * This file is part of OpenXcom.
5  *
6  * OpenXcom is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * OpenXcom is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef OPENXCOM_BATTLEITEM_H
20 #define OPENXCOM_BATTLEITEM_H
21 
22 #include "../Battlescape/Position.h"
23 #include <yaml-cpp/yaml.h>
24 
25 namespace OpenXcom
26 {
27 
28 class RuleItem;
29 class RuleInventory;
30 class BattleUnit;
31 class Tile;
32 
40 {
41 private:
42  int _id;
43  RuleItem *_rules;
44  BattleUnit *_owner, *_previousOwner;
45  BattleUnit *_unit;
46  Tile *_tile;
47  RuleInventory *_inventorySlot;
48  int _inventoryX, _inventoryY;
49  BattleItem *_ammoItem;
50  int _fuseTimer, _ammoQuantity;
51  int _painKiller, _heal, _stimulant;
52  bool _XCOMProperty, _droppedOnAlienTurn;
53 public:
55  BattleItem(RuleItem *rules, int *id);
57  ~BattleItem();
59  void load(const YAML::Node& node);
61  YAML::Node save() const;
63  RuleItem *getRules() const;
65  int getAmmoQuantity() const;
67  void setAmmoQuantity(int qty);
69  int getFuseTimer() const;
71  void setFuseTimer(int turns);
73  bool spendBullet();
75  BattleUnit *getOwner() const;
79  void setOwner(BattleUnit *owner);
81  void moveToOwner(BattleUnit *owner);
83  RuleInventory *getSlot() const;
85  void setSlot(RuleInventory *slot);
87  int getSlotX() const;
89  void setSlotX(int x);
91  int getSlotY() const;
93  void setSlotY(int y);
95  bool occupiesSlot(int x, int y, BattleItem *item = 0) const;
99  bool needsAmmo() const;
101  int setAmmoItem(BattleItem *item);
103  Tile *getTile() const;
105  void setTile(Tile *tile);
107  int getId() const;
109  BattleUnit *getUnit() const;
111  void setUnit(BattleUnit *unit);
113  void setHealQuantity (int heal);
115  int getHealQuantity () const;
117  void setPainKillerQuantity (int pk);
119  int getPainKillerQuantity () const;
121  void setStimulantQuantity (int stimulant);
123  int getStimulantQuantity () const;
125  void setXCOMProperty (bool flag);
127  bool getXCOMProperty () const;
129  bool getTurnFlag() const;
131  void setTurnFlag(bool flag);
133  void convertToCorpse(RuleItem *rules);
134 
135 };
136 
137 }
138 
139 #endif
int getAmmoQuantity() const
Gets the item's ammo quantity.
Definition: BattleItem.cpp:173
void setAmmoQuantity(int qty)
Sets the item's ammo quantity.
Definition: BattleItem.cpp:186
void setSlotX(int x)
Sets the item's inventory X position.
Definition: BattleItem.cpp:288
int getPainKillerQuantity() const
Get medikit pain killers quantity.
Definition: BattleItem.cpp:462
BattleUnit * getPreviousOwner() const
Gets the item's previous owner.
Definition: BattleItem.cpp:217
RuleItem * getRules() const
Gets the item's ruleset.
Definition: BattleItem.cpp:146
BattleUnit * getOwner() const
Gets the item's owner.
Definition: BattleItem.cpp:208
void setOwner(BattleUnit *owner)
Sets the owner.
Definition: BattleItem.cpp:226
void load(const YAML::Node &node)
Loads the item from YAML.
Definition: BattleItem.cpp:65
bool needsAmmo() const
Determines if this item uses ammo.
Definition: BattleItem.cpp:351
bool occupiesSlot(int x, int y, BattleItem *item=0) const
Checks if the item is occupying a slot.
Definition: BattleItem.cpp:318
Represents a specific type of item.
Definition: RuleItem.h:41
RuleInventory * getSlot() const
Gets the item's inventory slot.
Definition: BattleItem.cpp:261
int getSlotY() const
Gets the item's inventory Y position.
Definition: BattleItem.cpp:297
BattleItem * getAmmoItem()
Gets the item's ammo item.
Definition: BattleItem.cpp:342
Represents a single item in the battlescape.
Definition: BattleItem.h:39
void convertToCorpse(RuleItem *rules)
Sets the item's ruleset.
Definition: BattleItem.cpp:526
void setTurnFlag(bool flag)
set the flag representing "not dropped on player turn"
Definition: BattleItem.cpp:517
void setPainKillerQuantity(int pk)
Set medikit pain killers quantity.
Definition: BattleItem.cpp:453
void setTile(Tile *tile)
Sets the tile.
Definition: BattleItem.cpp:399
int getHealQuantity() const
Get medikit heal quantity.
Definition: BattleItem.cpp:444
void setStimulantQuantity(int stimulant)
Set medikit stimulant quantity.
Definition: BattleItem.cpp:471
YAML::Node save() const
Saves the item to YAML.
Definition: BattleItem.cpp:81
Basic element of which a battle map is build.
Definition: Tile.h:43
int getId() const
Gets it's unique id.
Definition: BattleItem.cpp:408
void setFuseTimer(int turns)
Sets the turns until explosion.
Definition: BattleItem.cpp:164
void setUnit(BattleUnit *unit)
Sets the corpse's unit.
Definition: BattleItem.cpp:426
Tile * getTile() const
Gets the item's tile.
Definition: BattleItem.cpp:390
BattleUnit * getUnit() const
Gets the corpse's unit.
Definition: BattleItem.cpp:417
~BattleItem()
Cleans up the item.
Definition: BattleItem.cpp:57
BattleItem(RuleItem *rules, int *id)
Creates a item of the specified type.
Definition: BattleItem.cpp:33
int setAmmoItem(BattleItem *item)
Sets the item's ammo item.
Definition: BattleItem.cpp:361
bool spendBullet()
Spend one bullet.
Definition: BattleItem.cpp:195
int getFuseTimer() const
Gets the turn until explosion.
Definition: BattleItem.cpp:155
int getStimulantQuantity() const
Get medikit stimulant quantity.
Definition: BattleItem.cpp:480
bool getTurnFlag() const
get the flag representing "not dropped on player turn"
Definition: BattleItem.cpp:507
void setSlotY(int y)
Sets the item's inventory Y position.
Definition: BattleItem.cpp:306
void setSlot(RuleInventory *slot)
Sets the item's inventory slot.
Definition: BattleItem.cpp:270
void setXCOMProperty(bool flag)
Set xcom property flag.
Definition: BattleItem.cpp:489
void setHealQuantity(int heal)
Set medikit Heal quantity.
Definition: BattleItem.cpp:435
bool getXCOMProperty() const
Get xcom property flag.
Definition: BattleItem.cpp:497
int getSlotX() const
Gets the item's inventory X position.
Definition: BattleItem.cpp:279
Represents a moving unit in the battlescape, player controlled or AI controlled it holds info about i...
Definition: BattleUnit.h:58
void moveToOwner(BattleUnit *owner)
Removes the item from previous owner and moves to new owner.
Definition: BattleItem.cpp:236
Represents a specific section of the inventory, containing information like available slots and scree...
Definition: RuleInventory.h:44