OpenXcom  1.0
Open-source clone of the original X-Com
Transfer.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 <yaml-cpp/yaml.h>
22 
23 namespace OpenXcom
24 {
25 
26 enum TransferType { TRANSFER_ITEM, TRANSFER_CRAFT, TRANSFER_SOLDIER, TRANSFER_SCIENTIST, TRANSFER_ENGINEER };
27 
29 {
30  TransferType type;
31  void *rule;
32  std::string name;
33  int cost;
34  int qtySrc, qtyDst;
35  int amount;
36 };
37 
38 class Soldier;
39 class Craft;
40 class Language;
41 class Base;
42 class Mod;
43 class SavedGame;
44 
50 class Transfer
51 {
52 private:
53  int _hours;
54  Soldier *_soldier;
55  Craft *_craft;
56  std::string _itemId;
57  int _itemQty, _scientists, _engineers;
58  bool _delivered;
59 public:
61  Transfer(int hours);
63  ~Transfer();
65  bool load(const YAML::Node& node, Base *base, const Mod *mod, SavedGame *save);
67  YAML::Node save() const;
69  void setSoldier(Soldier *soldier);
71  void setCraft(Craft *craft);
73  Craft *getCraft();
75  std::string getItems() const;
77  void setItems(const std::string &id, int qty = 1);
79  void setScientists(int scientists);
81  void setEngineers(int engineers);
83  std::string getName(Language *lang) const;
85  int getHours() const;
87  int getQuantity() const;
89  TransferType getType() const;
91  void advance(Base *base);
94 
95 };
96 
97 }
void advance(Base *base)
Advances the transfer.
Definition: Transfer.cpp:298
Represents a craft stored in a base.
Definition: Craft.h:45
int getHours() const
Gets the hours remaining of the transfer.
Definition: Transfer.cpp:242
Transfer(int hours)
Creates a new transfer.
Definition: Transfer.cpp:35
The game data that gets written to disk when the game is saved.
Definition: SavedGame.h:99
Contains all the game-specific static data that never changes throughout the game, like rulesets and resources.
Definition: Mod.h:87
Represents an item transfer.
Definition: Transfer.h:50
void setItems(const std::string &id, int qty=1)
Sets the items of the transfer.
Definition: Transfer.cpp:187
std::string getItems() const
Gets the items of the transfer.
Definition: Transfer.cpp:177
Soldier * getSoldier()
Get a pointer to the soldier being transferred.
Definition: Transfer.cpp:333
~Transfer()
Cleans up the transfer.
Definition: Transfer.cpp:42
bool load(const YAML::Node &node, Base *base, const Mod *mod, SavedGame *save)
Loads the transfer from YAML.
Definition: Transfer.cpp:59
Contains strings used throughout the game for localization.
Definition: Language.h:39
Represents a soldier hired by the player.
Definition: Soldier.h:48
void setCraft(Craft *craft)
Sets the craft of the transfer.
Definition: Transfer.cpp:159
YAML::Node save() const
Saves the transfer to YAML.
Definition: Transfer.cpp:114
Represents a player base on the globe.
Definition: Base.h:45
Definition: Transfer.h:28
std::string getName(Language *lang) const
Gets the name of the transfer.
Definition: Transfer.cpp:216
int getQuantity() const
Gets the quantity of the transfer.
Definition: Transfer.cpp:251
void setScientists(int scientists)
Sets the scientists of the transfer.
Definition: Transfer.cpp:197
Craft * getCraft()
Gets the craft of the transfer.
Definition: Transfer.cpp:168
void setSoldier(Soldier *soldier)
Sets the soldier of the transfer.
Definition: Transfer.cpp:150
void setEngineers(int engineers)
Sets the engineers of the transfer.
Definition: Transfer.cpp:206
TransferType getType() const
Gets the type of the transfer.
Definition: Transfer.cpp:272
Definition: BaseInfoState.cpp:40