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
|
#include <Commander.hpp>
Commander::Commander(): infxp(0), mobxp(0), avixp(0), orgxp(0),
tactics(5), clout(5), education(5), mechapt(5),
freepoints(20), reincarnations(0), bank(0),
honor(0), wins(0), losses(0), prestige(0),
reincSignup(false),
tactics(5), clout(5), education(5), mechapt(5)
{
cout << "In TEST Commander Constructor\n";
char hero[25];
cout << "Choose a name for your commander:\t";
cin >> hero;
strncpy(name,hero,20);
inventoryslot = new Unit*[UnitSlots()];
for (int i = 0; i < UnitSlots(); i++) {
inventoryslot[i] = 0;
}
deployslot = new Unit*[BattleSlots()];
for (int i = 0; i < UnitSlots(); i++) {
deployslot[i] = 0;
}
}
Commander::~Commander() { cout << "In Commander Destructor\n"; delete[] inventoryslot; delete[] deployslot; }
int Commander::FindSlot() {
cout << "In Commander::FindSlot()\n";
if (Unitcount() < UnitSlots()) {
int x;
for (x = 0; inventoryslot[x] != 0; x++) { cout << "FindSlot():\tSlot " << x << " full!\n"; }
return x;
} else { cout << "All full!\n"; }
}
int Commander::FindDeploySlot() {
cout << "In Commander::FindDeploySlot()\n";
if (Deploycount() < BattleSlots()) {
int x;
for (x = 0; deployslot[x] != 0; x++) { cout << "FindDeploySlot():\tSlot " << x << " full!\n"; }
return x;
} else { cout << "All full!\n"; }
}
int Commander::BonusPoints(int lvlbank, int reinc) const {
cout << "In Commander::BonusPoints()\n";
int a=1, b=0, c=0, points=0;
while (c<lvlbank) {
points = (lvlbank/a)+(b);
c++;
if (c/(2*a)==(a+1)) {
a++;
b+=2;
}
}
return (points + (reinc*2));
}
int Commander::Unitcount() const {
cout << "In Commander::Unitcount()\n";
int a=0, i=0;
for (; i < UnitSlots(); i++) { if (inventoryslot[i] != 0) { a++; } }
return a;
}
int Commander::Deploycount() const {
cout << "In Commander::Deploycount()\n";
int a=0, i=0;
for (; i < BattleSlots(); i++) { if (deployslot[i] != 0) { a++; } }
return a;
}
int Commander::UnitSlots() const { // Calculate maximum number of unit slots in inventory
return (48 + (reincarnations*2)); // 48 (default starting number) + 2 bonus slots per reincarnation
}
int Commander::BattleSlots() const { // Calculate maximum number of deployed units based on tactics score
cout << "In Commander::BattleSlots()\n";
if (tactics < 20) { return 6; }
if ( (tactics >= 20) && (tactics < 40) ) { return 7; }
if ( (tactics >= 40) && (tactics < 60) ) { return 8; }
if ( (tactics >= 60) && (tactics < 80) ) { return 9; }
if ( (tactics >= 80) && (tactics < 100) ) { return 10; }
if ( (tactics >= 100) && (tactics < 120) ) { return 11; }
if (tactics == 120) { return 12; }
}
|