+ 1

I am just learning this but this is a piece of code I wrote to simulate a battle. At a certain point (it is marked) the values a

#include <iostream> #include <string> using namespace std; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////Battle Class//////////////////////////////////////////////////////////////// //Create battle class class Battle { protected: string nm[2]; int Stats[2][6]; int xp[2]; int AttInc; int MpDec; public: Battle(){}; const string StatArr[6] = {"Dmg ","Def ","Mdmg ","Mdef ","Hp ","Mp "}; //simulate battle void BattleSim() { //DisplayInfo(); //loop to keep deducting attack values until 1 or other hp value is 0 or less while(Stats[0][4] > 0 && Stats[1][4] > 0) { GetInfo(); DisplayInfo(); Stats[0][4] = Stats[0][4] - (Stats[1][0] - Stats[0][1]); Stats[1][4] = Stats[1][4] - ((AttInc + Stats[0][0]) - Stats[1][1]); Stats[0][5] -= MpDec; } } //get attack info from player void GetInfo() { //DisplayInfo(); int a; cout << "1.Attack 2.Punch 3.Kick" << endl; cin >> a; //determine extra attack and mp decrease based on selection switch(a) { case 1: AttInc = 0; MpDec = 0; break; case 2: AttInc = 2; MpDec = 3; break; case 3: AttInc = 5; MpDec = 4; break; } } //display battle info void DisplayInfo() { cout << nm[0] << "'s Hp is " << Stats[0][4] << endl; cout << nm[1] << "'s Hp is " << Stats[1][4] << endl; cout << nm[0] << "'s Mp is " << Stats[0][5] << endl; cout << nm[1] << "'s

5th Oct 2016, 4:26 PM
James Watt
1 Resposta
0
What should be done here? I mean what are you asking? Ur question is not clear
17th Sep 2017, 12:16 PM
suraj mandal
suraj mandal - avatar