OpenXcom  1.0
Open-source clone of the original X-Com
CraftWeapon.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_CRAFTWEAPON_H
20 #define OPENXCOM_CRAFTWEAPON_H
21 
22 #include <string>
23 #include <yaml-cpp/yaml.h>
24 #include <cmath>
25 
26 namespace OpenXcom
27 {
28 
29 class RuleCraftWeapon;
30 class CraftWeaponProjectile;
31 class Ruleset;
32 
39 {
40 private:
41  RuleCraftWeapon *_rules;
42  int _ammo;
43  bool _rearming;
44 public:
46  CraftWeapon(RuleCraftWeapon *rules, int ammo);
48  ~CraftWeapon();
50  void load(const YAML::Node& node);
52  YAML::Node save() const;
54  RuleCraftWeapon *getRules() const;
56  int getAmmo() const;
58  bool setAmmo(int ammo);
60  bool isRearming() const;
62  void setRearming(bool rearming);
64  int rearm(const int available, const int clipSize);
66  CraftWeaponProjectile* fire() const;
68  int getClipsLoaded(Ruleset* ruleset);
69 
70 };
71 
72 }
73 
74 #endif
Represents a craft weapon equipped by a craft.
Definition: CraftWeapon.h:39
void setRearming(bool rearming)
Sets the craft weapon's rearming status.
Definition: CraftWeapon.cpp:120
int getClipsLoaded(Ruleset *ruleset)
get how many clips are loaded into this weapon.
Definition: CraftWeapon.cpp:179
void load(const YAML::Node &node)
Loads the craft weapon from YAML.
Definition: CraftWeapon.cpp:48
RuleCraftWeapon * getRules() const
Gets the craft weapon's ruleset.
Definition: CraftWeapon.cpp:72
CraftWeaponProjectile * fire() const
Fires the craft weapon. Used during dogfights.
Definition: CraftWeapon.cpp:163
YAML::Node save() const
Saves the craft weapon to YAML.
Definition: CraftWeapon.cpp:58
bool isRearming() const
Gets the craft weapon's rearming status.
Definition: CraftWeapon.cpp:110
bool setAmmo(int ammo)
Sets the craft weapon's ammo.
Definition: CraftWeapon.cpp:91
int getAmmo() const
Gets the craft weapon's ammo.
Definition: CraftWeapon.cpp:81
CraftWeapon(RuleCraftWeapon *rules, int ammo)
Creates a craft weapon of the specified type.
Definition: CraftWeapon.cpp:33
int rearm(const int available, const int clipSize)
Rearms the craft weapon.
Definition: CraftWeapon.cpp:131
~CraftWeapon()
Cleans up the craft weapon.
Definition: CraftWeapon.cpp:40
Definition: CraftWeaponProjectile.h:37
Represents a specific type of craft weapon.
Definition: RuleCraftWeapon.h:36
Set of rules and stats for a game.
Definition: Ruleset.h:70
COPYING:
Definition: BaseInfoState.cpp:41