-
Notifications
You must be signed in to change notification settings - Fork 1
/
combat.h
114 lines (85 loc) · 2.11 KB
/
combat.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
const unsigned T_ATTACKER = 0;
const unsigned T_DEFENDER = 1;
const unsigned MAX_SLOTS = 100;
struct T_SHIP {
int id;
long attack;
long hull;
long shield;
int *rapidfire;
};
struct T_PLAYER {
int playerId;
int techWeapon;
int techShield;
int techArmor;
int *shipList;
};
class T_UNIT {
public:
bool exploded;
int shieldLeft;
int shieldMax;
int hullLeft;
int hullMax;
T_SHIP *original;
T_PLAYER *owner;
};
struct T_ROUND {
long attackShots;
long attackDamage;
long attackAbsorbed;
long defendShots;
long defendDamage;
long defendAbsorbed;
T_PLAYER *thisRoundData[2];
int **shiplist[2];
};
class RNG
{
private:
SpeedRand _sr;
public:
RNG();
bool chanceDecide(int chance);
bool chanceDecide(int chance, bool toPerMille);
int getRandom(int a, int b);
unsigned long RandomNumber(unsigned long Max);
};
class CombatSys
{
private:
T_SHIP * _SHIPS;
T_PLAYER *_PLAYERS[2];
T_UNIT *_UNITS[2];
int unitCount;
int unitsSet;
int allShipCount[2]; //for allocating memory
int allPlayersCount[2];
RNG _RNG;
int roundCount;
T_ROUND _ROUNDS[6];
int _VERSION;
bool _CAN_BATTLE;
bool _CAN_GET_RESULT;
bool _SHOOT_AGAINST_EXPLODED;
bool _ENABLE_RAPID_FIRE;
public:
CombatSys();
int getVersion();
void setShootAgainstExploded(bool modus);
void setRapidfire(bool modus);
void setUnitCount(int count);
bool canSetShip(int id);
void configShip(int id, long attack, long hull, long shield, char *rapidfire);
bool allShipsConfigured();
bool canSetAttacker(int id);
void addAttacker(int id, int weapon, int shield, int armor);
bool canSetDefender(int id);
void addDefender(int id, int weapon, int shield, int armor);
void addShips(const unsigned fraction, int playerId, int shipId, int amount);
void UpdateFleets();
void Shoot(T_UNIT *source, T_UNIT *target, long *attackpower, long *absorbed, bool *nextshot);
void battle();
char * getResult();
};