1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
 
  | 
//Battle with Samer
#include <iostream>
#include <string>
#include <sstream>
#include <ctime>
#include <cstdlib>
using namespace std;
struct Opponent{
	string name;
	int health;
	int attack;
};
struct Mystats {
	string name;
	int health;
	int attack;
};
Opponent samer[6] = {
	"Charizard", 40, 10,
	"Umbreon", 30, 10,
	"Mew", 50, 15,
	"Arcanine", 30, 15,
	"Espurr", 20, 15,
	"Luxaray", 20, 10
};
Mystats trainer[3] = {
	"Charizard", 20, 10,
	"Slowking", 30, 6,
	"Weavile", 15, 15
};
int main()
{
	string mystr;
	string Samer;
	string Trainer;
	int samer_choice;
	int player_choice;
	cout << "Musician Samer wants to battle! \n";
	cout << "Go, ";
	srand((unsigned)time(0));
	samer_choice = rand() % 6;
	cout << samer[samer_choice].name << "!" << "\n";
	cout << "Please choose your Pokemon: \n";
	cout << "Press 1 for Charizard \n";
	cout << "Press 2 for Slowking \n";
	cout << "Press 3 for Weavile \n";
	getline(cin, mystr);
	stringstream(mystr) >> player_choice;
	cout << trainer[player_choice -= 1].name << ", I choose you!" << endl;
	cout << "Enemy Health:" << samer[samer_choice].health << endl;
	cout << "My Health:" << trainer[player_choice].health << endl;
	cout << "Would you like to attack? \n";
	cout << "yes or no? \n";
	getline(cin, mystr);	
	do {
		samer[samer_choice].health -= trainer[player_choice].attack;
		trainer[player_choice].health -= samer[samer_choice].attack;
	}	
	while (samer[samer_choice].health > 0 || trainer[player_choice].health > 0);
	if (samer[samer_choice].health <= 0) {
		cout << samer[samer_choice].name << " has feinted! You are victorious!";
	}
	else {
		cout << trainer[player_choice].name << " has feinted! You are out of useable pokemone!  You blacked out!";
	};
	system("PAUSE");
}
  |  |