-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgun.h
47 lines (36 loc) · 1.04 KB
/
gun.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef GUN_H
#define GUN_H
#include <QObject>
#include <QTimer>
class Gun : public QObject
{
Q_OBJECT
public:
Gun(bool automatic = false, int fireFrequency = 0);
int getFireFrequency() { return fireFrequency; }
int getDamage() { return damage; }
int ammoLoaded() { return currentLoadedAmmo; }
int ammoOwned() { return currentOwnedAmmo; }
bool isAutomatic() { return automatic; }
bool isReloading() { return reloading; }
bool isFull() { return (currentLoadedAmmo == capacityAmmo) ? true : false; }
void decreaseAmmo() { currentLoadedAmmo--; }
void reload();
void refillCurrentLoadedAmmo() { currentLoadedAmmo = capacityAmmo; }
void refillCurrentOwnedAmmo() { currentOwnedAmmo = maxAmmo; }
void addAmmo(int ammo);
void reset();
protected:
int damage;
int capacityAmmo;
int currentLoadedAmmo;
int maxAmmo;
int currentOwnedAmmo;
private:
const bool automatic;
bool reloading = false;
QTimer reloadTimer;
int fireFrequency;
void reloaded();
};
#endif // GUN_H