OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
RuleInventory.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_RULEINVENTORY_H
20 #define OPENXCOM_RULEINVENTORY_H
21 
22 #include <string>
23 #include <vector>
24 #include <map>
25 #include <yaml-cpp/yaml.h>
26 
27 namespace OpenXcom
28 {
29 
30 struct RuleSlot
31 {
32  int x, y;
33 };
34 
35 enum InventoryType { INV_SLOT, INV_HAND, INV_GROUND };
36 
37 class RuleItem;
38 
45 {
46 private:
47  std::string _id;
48  int _x, _y;
49  InventoryType _type;
50  std::vector<RuleSlot> _slots;
51  std::map<std::string, int> _costs;
52  int _listOrder;
53 public:
54  static const int SLOT_W = 16;
55  static const int SLOT_H = 16;
56  static const int HAND_W = 2;
57  static const int HAND_H = 3;
59  RuleInventory(const std::string &id);
63  void load(const YAML::Node& node, int listOrder);
65  std::string getId() const;
67  int getX() const;
69  int getY() const;
71  InventoryType getType() const;
73  std::vector<struct RuleSlot> *getSlots();
75  bool checkSlotInPosition(int *x, int *y) const;
77  bool fitItemInSlot(RuleItem *item, int x, int y) const;
79  int getCost(RuleInventory *slot) const;
80  int getListOrder() const;
81 };
82 
83 }
84 
85 #endif
std::string getId() const
Gets the inventory's id.
Definition: RuleInventory.cpp:85
~RuleInventory()
Cleans up the inventory ruleset.
Definition: RuleInventory.cpp:60
int getCost(RuleInventory *slot) const
Gets a certain cost in the inventory.
Definition: RuleInventory.cpp:231
InventoryType getType() const
Gets the inventory type.
Definition: RuleInventory.cpp:115
int getX() const
Gets the X position of the inventory.
Definition: RuleInventory.cpp:94
Definition: RuleInventory.h:30
RuleInventory(const std::string &id)
Creates a blank inventory ruleset.
Definition: RuleInventory.cpp:56
Represents a specific type of item.
Definition: RuleItem.h:41
bool checkSlotInPosition(int *x, int *y) const
Checks for a slot in a certain position.
Definition: RuleInventory.cpp:135
bool fitItemInSlot(RuleItem *item, int x, int y) const
Checks if an item fits in a slot.
Definition: RuleInventory.cpp:187
std::vector< struct RuleSlot > * getSlots()
Gets all the slots in the inventory.
Definition: RuleInventory.cpp:124
int getY() const
Gets the Y position of the inventory.
Definition: RuleInventory.cpp:103
void load(const YAML::Node &node, int listOrder)
Loads inventory data from YAML.
Definition: RuleInventory.cpp:69
Represents a specific section of the inventory, containing information like available slots and scree...
Definition: RuleInventory.h:44