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
|
bool Combat::runCombat()
{
Combatant kyle(1, 10, 10, 3, 5, 6, 15, 12, 500, 1000);
Combatant one(1, 10, 10, 2, 5, 6, 15, 12, 500, 1000);
Combatant two(1, 10, 10, 1, 5, 6, 15, 12, 500, 1000);
Combatant three(1, 10, 10, 4, 5, 6, 15, 12, 500, 1000);
kyle._name = "Kyle";
one._name = "Orrin";
two._name = "Braedon";
three._name = "Brent";
bool cbat = true;
while (cbat == true)
{
int turn = checkSpeed(kyle._speed, one._speed, two._speed, three._speed);
if (turn == 1) {
int choice = kyle.pickAction();
if (choice == 1) {
//Pick target
cout << "Please pick a target" << endl;
cout << "1)." << one._name << " " << one._currentHealth << endl;
cout << "2)." << two._name << " " << two._currentHealth << endl;
cout << "3)." << three._name << " " << three._currentHealth << endl;
int choice;
cin >> choice;
//Check is attack beats target defense, then subtract armor from damage total and inflict to health.
switch (choice)
{
case 1:
if (one._alive == true) {
one._currentHealth -= kyle.attack(one);
if (one._currentHealth <= 0) {
cout << one._name << " has been slain!!" << endl;
one._alive = false;
}
}
else {
cout << "Please pick another target. " << one._name << " has had enough!" << endl;
}
break;
case 2:
if (two._alive == true) {
two._currentHealth -= kyle.attack(two);
if (two._currentHealth <= 0) {
cout << two._name << " has been slain!!" << endl;
two._alive = false;
}
}
else {
cout << "Please pick another target. " << two._name << " has had enough!" << endl;
}
break;
case 3:
if (three._alive == true) {
three._currentHealth -= kyle.attack(three);
if (three._currentHealth <= 0) {
cout << three._name << " has been slain!!" << endl;
three._alive = false;
}
}
else {
cout << "Please pick another target. " << three._name << " has had enough!" << endl;
}
break;
}
}
}
else if (turn == 2) {
one.attack(kyle);
}
else if (turn == 3) {
two.attack(kyle);
}
else {
three.attack(kyle);
}
}
return true;
}
|