Robot Devastation
Weapon.hpp
1 // Authors: see AUTHORS.md at project root.
2 // CopyPolicy: released under the terms of the LGPLv2.1, see LICENSE at project root.
3 // URL: https://github.com/asrob-uc3m/robotDevastation
4 
5 #ifndef __RD_WEAPON_HPP__
6 #define __RD_WEAPON_HPP__
7 
8 #include <string>
9 
10 #include "Target.hpp"
11 
12 namespace rd {
13 
14 class Target;
15 
22 class Weapon
23 {
24 public:
26  Weapon();
27  Weapon(const std::string & name, int damage, int max_ammo);
28 
30  bool canShootTarget(const Target& target);
31 
33  bool reload();
34 
35  const std::string & getName() const;
36  int getDamage() const;
37  int getCurrentAmmo() const;
38  bool setCurrentAmmo(int current_ammo);
39  int getMaxAmmo() const;
40 
42  static const int SCOPE_X;
44  static const int SCOPE_Y;
45 
46 private:
47  std::string name;
48 
50  int damage;
51 
54 
56  int max_ammo;
57 };
58 
59 }
60 #endif //__RD_WEAPON_HPP__
rd::Weapon::Weapon
Weapon()
Constructs a default, dummy weapon. (That is invalid for the game, by the way)
Definition: Weapon.cpp:10
rd::Weapon::SCOPE_X
static const int SCOPE_X
X coordinate of the weapon's scope.
Definition: Weapon.hpp:42
rd
The main, catch-all namespace for Robot Devastation.
Definition: groups.dox:4
rd::Weapon::SCOPE_Y
static const int SCOPE_Y
Y coordinate of the weapon's scope.
Definition: Weapon.hpp:44
rd::Weapon::damage
int damage
Damage that this weapon can inflict in one shot.
Definition: Weapon.hpp:50
rd::Weapon
Class that represents a weapon.
Definition: Weapon.hpp:22
rd::Target
Class that represents a target detected. This target is (or should be) associated to a player.
Definition: Target.hpp:18
rd::Weapon::canShootTarget
bool canShootTarget(const Target &target)
Checks if the target is within the weapon's current range and can be hit by it.
Definition: Weapon.cpp:27
rd::Weapon::current_ammo
int current_ammo
Current ammount of ammo.
Definition: Weapon.hpp:53
rd::Weapon::max_ammo
int max_ammo
Maximum ammount of ammo.
Definition: Weapon.hpp:56
rd::Weapon::reload
bool reload()
Increases the current ammo to max_ammo.
Definition: Weapon.cpp:46