From 3e231f951aa8ab53c2df3a7053575c06cab51021 Mon Sep 17 00:00:00 2001 From: "Ryan Gillett (gillettr)" Date: Mon, 11 Mar 2019 07:50:00 +0000 Subject: [PATCH] Create combat.cpp --- combat.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 combat.cpp diff --git a/combat.cpp b/combat.cpp new file mode 100644 index 0000000..518a0c6 --- /dev/null +++ b/combat.cpp @@ -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;; + +}