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