#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;

class Bosses {
public:
  int hp, xp;
  string name, element, alignment;
  //return th dmg done 
  //if resist matches element
  //element part of the dmg is 1/4th
  int attack(string resist) {
    int eledamage = 20+rand() % 10;
    if (resist == element)
      eledamage = eledamage / 4;
    return eledamage + rand() % 10;
  }

  int dodge() {
    return rand() % 3 == 0 ? 1 : 0;
    // if(rand()%3 == 0) return 1;
    // else return 0;
  }
};

class Heroes {
public:
  string name, resist, align;
  int hp, numberOfPotions;
  //returns dmg dealt
  int performChoice(string choice, int dodge) {
    int dmg = 0;
    if (choice == "take")
      takePotion();
    else //then choice must have been attack
      dmg = attack();
    return dmg;
  }
  //returns dmg dealt
  int attack() {
    return 21 + rand() % 10;
  }
  //take a potion - if available
  void takePotion() {
    if (numberOfPotions > 0) {
      numberOfPotions--;
      hp = hp + 11 + rand() % 30;
      cout << "You heal up!" << endl;
    }
    else {
    }
  }
};

string getChoice() {
  string choice;
  cout << "Input a choice take for potion or attack to attack : ";
  cin >> choice;
  while (choice != "take" && choice != "attack") {
    cout << " take or attack";
    cin >> choice;
  }
  return choice;
}


int main() {
  srand(time(0)); rand();
  Bosses sniper;//("Sniper Boss", 100, 100, "Fire", "CE");
  sniper.name = "Sniper Boss";
  sniper.xp = 10;
  sniper.hp = 100;
  string elements[4] = { "Fire","Ice","Lightning", "Poison" };
  sniper.element = elements[rand() % 4];
  sniper.alignment = "CE";
  Heroes double07;
  double07.align = "CG";
  double07.hp = 100;
  double07.name = "Cash Bonds";
  double07.resist = elements[rand() % 4];
  double07.numberOfPotions = 22;


  cout << double07.name << " resists " << double07.resist << endl;
  cout << sniper.name << " has element " << sniper.element << endl;
  while (double07.hp > 0 && sniper.hp > 0) {
    string choice = getChoice();
    sniper.hp -= double07.performChoice(choice, sniper.dodge());
    double07.hp -= sniper.attack(double07.resist);
    cout << "Your hps are: " << double07.hp << " hps." << endl;
    cout << sniper.name << " has " << sniper.hp << " hps." << endl;
  }



}
