#include <iostream> //cin/cout
#include <cmath> //all the math stuffs
#include <cstdlib> //rand and srand
#include <string> // for strings!
#include <ctime> // for the time function
using namespace std;
int main() {
  srand(time(0)); rand();//seeds - initializes the RNG

  int r1 = rand() % 6 + 1; // 1-6
  int r2 = rand() % 6 + 1;
  int r3 = rand() % 6 + 1;
  cout << "my rs are " << r1 << " " << r2 << " " << r3 << endl;
  int dragonHP = 200;
  int charactersHP = 40;
  while (dragonHP > 0 && charactersHP > 0) {
    cout << "Heal or attack? ";
    string choice;
    cin >> choice;
    if (choice == "heal") {
      int healAmount = rand() % 6 + 5; //5-10
      cout << "You healed " << healAmount << endl;
      charactersHP = charactersHP + healAmount;
      cout << "Your hps are now " << charactersHP << endl;
    }
    else { //assume they typed attack
      //5% you do triple damage?
      int attackAmount = rand() % 21 + 20; //20-40
      if (rand() % 20 + 1 == 20) { // rolled a 20
	attackAmount = attackAmount * 3;
      }
      dragonHP = dragonHP - attackAmount;
      cout << "You smash the dragon for " << attackAmount << endl;
      cout << "The dragon has " << dragonHP << " hps " << endl;
    }

    //the dragon attacks and heals
    int dragonAttackDamage = rand() % 6 + 1 + rand() % 6 + 1; // 2d6
    if (rand() % 10 + 1 == 10) {
      cout << "The dragon misses and QQs all over the place." << endl;
    }
    else if (rand() % 6 + 1 == 6) {
      cout << "The dragon breathes sleepy gas on you." << endl;
      dragonAttackDamage = dragonAttackDamage * 2;
      charactersHP = charactersHP - dragonAttackDamage;
      cout << "You now have " << charactersHP << " hp" << endl;
    }
    else {
      cout << "The dragon pokes you for " << dragonAttackDamage << " hp" << endl;
      charactersHP = charactersHP - dragonAttackDamage;
      cout << "You now have " << charactersHP << endl;
    }
    int dragonHealAmount = rand() % 4 + 2; //2-5
    dragonHP = dragonHP + dragonHealAmount;
    cout << "The dragon regenerates to " << dragonHP << endl;
  }


}
