Skip to content
Permalink
Browse files
Create combat.cpp
  • Loading branch information
gillettr committed Mar 11, 2019
1 parent ec49446 commit 3e231f951aa8ab53c2df3a7053575c06cab51021
Showing 1 changed file with 39 additions and 0 deletions.
@@ -0,0 +1,39 @@
#include "Combat.h"
#include "Monster.h"
#include "Character.h"

Combat::Combat(Monster& newM) : M(newM)
{

}
void Combat::combatChoice(Character& C)
{
C.display();
cout << "What do you do? 1: Attack, 2: Fire Arrow" << endl;
short choice;
cin >> choice;
switch (choice)
{
case 1:
C.attack(M);
break;

case 2:
C.rangedAttack(M);
break;
}
}
void Combat::combat1(Character& C)
{
while (M.health > 0 && C.health > 0)
{
M->attack(C);
combatChoice(C);

}
if (M.health < 0) //we're using -> for pointer in this
cout << "Congratulations! You succeessfully killed the monster!" << endl;
if (C.health < 0) //used a dot for the reference
cout << "YOU HAVE DIED!" << endl;;

}

0 comments on commit 3e231f9

Please sign in to comment.