[ create a new paste ] login | about

Link: http://codepad.org/mEiFG1pB    [ raw code | fork ]

C++, pasted on Jan 4:
#include <iostream>
#include <random>
#include <ctime>

using namespace std;

int main()


{            cout << "*** All the King's Men***" << endl;

   cout << "*** on a cold November's dawn as the violet and peach shades of the early sun paint across the sky the air is thick with tension and the bite of winter's breath.The welcoming sounds of Fan fair and hoof beats mark the beginings of a very long day ***" << endl;

    // Random number generator code
    mt19937 Fox;
    uniform_real_distribution <float> dmg(0.0f , 1.0f);

    // Variable declarations
    int heroarmy;
    int vilians;
    int starthero;
     int startvillian;

    // Informs player how many soldiers we have
    cout <<  " how many men did you bring my liege? " << endl;
    cin >> heroarmy;
    starthero = heroarmy;

    if (heroarmy <= 100 ) // Informs of small-to-tiny amount of soldiers
    {
        cout << " thats not nearly enough! Hope they are brave! " << endl;
    }
    else if (heroarmy <= 500) // Informs of medium/average amount of soldiers
    {
        cout << " I See...Well if thats all we can muster then we will make due,may they feel the sun at their backs and our blades in their sides!" << endl;
    }
    else if (heroarmy <= 10000) // Informs of plentiful amount of soldiers
    {
        cout << heroarmy << "! By the saints!! You must have rallied the whole kingdom! Such a miraculous feat sire! " << endl;
    }

    //Informs player of # of enemies
    cout << " General...GENERAL!! The enemies war banner has been spotted on the horizon!! "<< endl;
    cout << " How many did you see lad?! " << endl;
    cin >> vilians;
    startvillian = vilians;

    //Informs player of difficulty by seeing if they have more enemies than we have soldiers
    if (heroarmy >= vilians) // Informs we have good odds of winning
    {
        cout << " HA! Thats less than we thought! We should be done before lunch " << endl;
    }
    else if (vilians >= heroarmy) // Informs we may have difficulty winning
    {
        cout << " I will rally the men, if we die we can take comfort in knowing that we took some of those bastards with us." << endl;
    }

    /// Battle portion of code
    // Kings army stats
    float heroarmyskill = 0.5f;
    float heroarmyHP = 300.0f;
    float heroarmyDmg = 75.0f;
    float HAremaininghp = heroarmyHP;

    //Dreads army Stats
    float villianskill = 0.5f;
    float villianHP = 300.0f;
    float villianDmg = 75.0f;
    float VremainingHP = villianHP;


    float dmgreport;
    char turn = 'H';

 // battle begins
    while ((heroarmy > 0 ) && (vilians > 0 ))
{
    if (turn == 'H'){
    // get attack result
       dmgreport = dmg(Fox);
       // check if it was a success
       if (dmgreport <= heroarmyskill){

        VremainingHP -= heroarmyDmg;
        if (VremainingHP < 0 ){
            vilians --;
            VremainingHP = villianHP;
        }
       }

       turn = 'v';

    } else {
              turn = 'v';
        if ( dmgreport <= villianskill ){
          HAremaininghp -=   villianDmg;
          if ( HAremaininghp < 0) {
            heroarmy --;
            HAremaininghp = heroarmyHP;


    }
    }
   turn = 'H';
    }






}

  if (heroarmy > 0) {
    cout << " We have came out victorious!! " << endl;
     cout << " Though we lost many great men this day and only " << heroarmy << " of us remained. We will all be heroes upon our return." << endl;
  }
   else {
        cout << " Despite the efforts of our king, the day was lost." <<endl ;
        cout << " Our enemy emerged with " << vilians << " remaining, Pray to the saints their losses were enough to stop their advance on our beloved land." << endl;

   }

     cout << "Many lives were claimed as a result of this battle, a total of " << starthero - heroarmy << " for our forces and " << startvillian - vilians << " fell to our skilled knights " << endl;


    return 0;

}


Create a new paste based on this one


Comments: