OpenXcom  1.0
Open-source clone of the original X-Com
BattleItem.h
1 #pragma once
2 /*
3  * Copyright 2010-2016 OpenXcom Developers.
4  *
5  * This file is part of OpenXcom.
6  *
7  * OpenXcom 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 3 of the License, or
10  * (at your option) any later version.
11  *
12  * OpenXcom 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 OpenXcom. If not, see <http://www.gnu.org/licenses/>.
19  */
20 #include <yaml-cpp/yaml.h>
21 
22 namespace OpenXcom
23 {
24 
25 class RuleItem;
26 class RuleInventory;
27 class BattleUnit;
28 class Tile;
29 
37 {
38 private:
39  int _id;
40  RuleItem *_rules;
41  BattleUnit *_owner, *_previousOwner;
42  BattleUnit *_unit;
43  Tile *_tile;
44  RuleInventory *_inventorySlot;
45  int _inventoryX, _inventoryY;
46  BattleItem *_ammoItem;
47  int _fuseTimer, _ammoQuantity;
48  int _painKiller, _heal, _stimulant;
49  bool _XCOMProperty, _droppedOnAlienTurn, _isAmmo;
50 public:
52  BattleItem(RuleItem *rules, int *id);
54  ~BattleItem();
56  void load(const YAML::Node& node);
58  YAML::Node save() const;
60  RuleItem *getRules() const;
62  int getAmmoQuantity() const;
64  void setAmmoQuantity(int qty);
66  int getFuseTimer() const;
68  void setFuseTimer(int turns);
70  bool spendBullet();
72  BattleUnit *getOwner() const;
76  void setOwner(BattleUnit *owner);
78  void setPreviousOwner(BattleUnit *owner);
80  void moveToOwner(BattleUnit *owner);
82  RuleInventory *getSlot() const;
84  void setSlot(RuleInventory *slot);
86  int getSlotX() const;
88  void setSlotX(int x);
90  int getSlotY() const;
92  void setSlotY(int y);
94  bool occupiesSlot(int x, int y, BattleItem *item = 0) const;
98  bool needsAmmo() const;
100  int setAmmoItem(BattleItem *item);
102  Tile *getTile() const;
104  void setTile(Tile *tile);
106  int getId() const;
108  BattleUnit *getUnit() const;
110  void setUnit(BattleUnit *unit);
112  void setHealQuantity (int heal);
114  int getHealQuantity() const;
116  void setPainKillerQuantity (int pk);
118  int getPainKillerQuantity() const;
120  void setStimulantQuantity (int stimulant);
122  int getStimulantQuantity() const;
124  void setXCOMProperty (bool flag);
126  bool getXCOMProperty() const;
128  bool getTurnFlag() const;
130  void setTurnFlag(bool flag);
132  void convertToCorpse(RuleItem *rules);
134  void setIsAmmo(bool ammo);
136  bool isAmmo() const;
137 };
138 
139 }
int getFuseTimer() const
Gets the turn until explosion.
Definition: BattleItem.cpp:159
void setAmmoQuantity(int qty)
Sets the item&#39;s ammo quantity.
Definition: BattleItem.cpp:190
RuleInventory * getSlot() const
Gets the item&#39;s inventory slot.
Definition: BattleItem.cpp:276
void setSlotX(int x)
Sets the item&#39;s inventory X position.
Definition: BattleItem.cpp:303
bool occupiesSlot(int x, int y, BattleItem *item=0) const
Checks if the item is occupying a slot.
Definition: BattleItem.cpp:333
int getAmmoQuantity() const
Gets the item&#39;s ammo quantity.
Definition: BattleItem.cpp:177
bool needsAmmo() const
Determines if this item uses ammo.
Definition: BattleItem.cpp:366
bool isAmmo() const
Checks a flag on the item to see if it&#39;s a clip in a weapon or not.
Definition: BattleItem.cpp:568
void setOwner(BattleUnit *owner)
Sets the owner.
Definition: BattleItem.cpp:232
void load(const YAML::Node &node)
Loads the item from YAML.
Definition: BattleItem.cpp:65
int getPainKillerQuantity() const
Get medikit pain killers quantity.
Definition: BattleItem.cpp:482
YAML::Node save() const
Saves the item to YAML.
Definition: BattleItem.cpp:81
bool getTurnFlag() const
get the flag representing "not dropped on player turn"
Definition: BattleItem.cpp:528
int getStimulantQuantity() const
Get medikit stimulant quantity.
Definition: BattleItem.cpp:500
BattleUnit * getUnit() const
Gets the corpse&#39;s unit.
Definition: BattleItem.cpp:437
void setPreviousOwner(BattleUnit *owner)
Sets the item&#39;s previous owner.
Definition: BattleItem.cpp:242
int getSlotX() const
Gets the item&#39;s inventory X position.
Definition: BattleItem.cpp:294
Represents a specific type of item.
Definition: RuleItem.h:40
int getHealQuantity() const
Get medikit heal quantity.
Definition: BattleItem.cpp:464
BattleItem * getAmmoItem()
Gets the item&#39;s ammo item.
Definition: BattleItem.cpp:357
Represents a single item in the battlescape.
Definition: BattleItem.h:36
void convertToCorpse(RuleItem *rules)
Sets the item&#39;s ruleset.
Definition: BattleItem.cpp:547
void setTurnFlag(bool flag)
set the flag representing "not dropped on player turn"
Definition: BattleItem.cpp:538
void setPainKillerQuantity(int pk)
Set medikit pain killers quantity.
Definition: BattleItem.cpp:473
void setTile(Tile *tile)
Sets the tile.
Definition: BattleItem.cpp:419
void setStimulantQuantity(int stimulant)
Set medikit stimulant quantity.
Definition: BattleItem.cpp:491
void setIsAmmo(bool ammo)
Sets a flag on the item indicating if this is a clip in a weapon or not.
Definition: BattleItem.cpp:559
BattleUnit * getPreviousOwner() const
Gets the item&#39;s previous owner.
Definition: BattleItem.cpp:223
int getSlotY() const
Gets the item&#39;s inventory Y position.
Definition: BattleItem.cpp:312
BattleUnit * getOwner() const
Gets the item&#39;s owner.
Definition: BattleItem.cpp:214
Basic element of which a battle map is build.
Definition: Tile.h:42
RuleItem * getRules() const
Gets the item&#39;s ruleset.
Definition: BattleItem.cpp:150
Tile * getTile() const
Gets the item&#39;s tile.
Definition: BattleItem.cpp:410
void setFuseTimer(int turns)
Sets the turns until explosion.
Definition: BattleItem.cpp:168
void setUnit(BattleUnit *unit)
Sets the corpse&#39;s unit.
Definition: BattleItem.cpp:446
bool getXCOMProperty() const
Get xcom property flag.
Definition: BattleItem.cpp:518
int getId() const
Gets it&#39;s unique id.
Definition: BattleItem.cpp:428
~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&#39;s ammo item.
Definition: BattleItem.cpp:376
bool spendBullet()
Spend one bullet.
Definition: BattleItem.cpp:199
void setSlotY(int y)
Sets the item&#39;s inventory Y position.
Definition: BattleItem.cpp:321
void setSlot(RuleInventory *slot)
Sets the item&#39;s inventory slot.
Definition: BattleItem.cpp:285
void setXCOMProperty(bool flag)
Set xcom property flag.
Definition: BattleItem.cpp:509
void setHealQuantity(int heal)
Set medikit Heal quantity.
Definition: BattleItem.cpp:455
Represents a moving unit in the battlescape, player controlled or AI controlled it holds info about i...
Definition: BattleUnit.h:59
Definition: BaseInfoState.cpp:40
void moveToOwner(BattleUnit *owner)
Removes the item from previous owner and moves to new owner.
Definition: BattleItem.cpp:251
Represents a specific section of the inventory, containing information like available slots and scree...
Definition: RuleInventory.h:42