So I'm trying to make my own version of Pokemon simulator and this is what i have so far..

/*
Pokemon.cpp
*/
#include <iostream>
#include <vector>

using namespace std;

void battle( int enemyHealth, int Health, int enemyAttack, int Attack, vector <string> &att, vector <string> &enmAtt );
int main()
{
    cout << "Pikachu! I choose you!" << endl;
    
    int enemyHealth = 100;
    int Health = 100;
    int enemyAttack;
    int Attack;

    vector <string> att(4);//your attacks
    att[0] = "ThunderShock";
    att[1] = "ThunderWave";
    att[2] = "Agility";
    att[3] = "Quick Attack";

    cout << endl;
    cout << "Your attacks:" << endl;
    cout << endl;

    //output your attacks
    for (int i = 0; i < 4; i++){
    cout  << i + 1 << ". " << att[i] << endl;
    }

    //ENEMY

    vector <string> enmAtt(4);//enemy's attacks
    enmAtt[0] = "BubbleBeam";
    enmAtt[1] = "HydroPump";
    enmAtt[2] = "Watergun";
    enmAtt[3] = "Crabhammer";

    cout << endl;
    cout << "Enemy's attacks:" << endl;
    cout << endl;

    //output enemy's attacks
    for (int i = 0; i < 4; i++){
    cout << i + 1 << ". " << enmAtt[i] << endl;
    }

    cout << endl;

    battle( enemyHealth, Health, Attack, enemyAttack, att, enmAtt );

    system("PAUSE");
    return EXIT_SUCCESS;
}

void battle( int enemyHealth, int Health, int enemyAttack, int Attack, vector <string> &att, vector <string> &enmAtt )
{
    srand(time(NULL));
    int dmg;
    int eDmg;

    while( ( enemyHealth > 0 ) && ( Health > 0) )
    {
    cout << "Attack number: ";
    cin >> Attack;
    cout << endl;

    if ( ( Attack == 1 ) || ( Attack == 2 ) ){
        dmg = rand() % 16 + 15;
        enemyHealth = enemyHealth - dmg;
        if ( enemyHealth < 1 )
        {
            cout << "Pikachu Wins!" << endl;
            cout << endl;
            break;
        }
        cout << "Squirtle's Health: " << enemyHealth << "%" << endl;
        cout << "Pikachu' Health: " << Health << "%" << endl;
        cout << "______________________________________________" << endl;
        cout << endl;
    }

    if ( ( Attack == 3 ) || ( Attack == 4 ) ){
        dmg = rand() % 8 + 8;
        enemyHealth = enemyHealth - dmg;
        if ( enemyHealth < 1 )
        {
            cout << "Pikachu Wins!" << endl;
            cout << endl;
            break;
        }
        cout << "Squirtle's Health: " << enemyHealth << "%" << endl;
        cout << "Pikachu' Health: " << Health << "%" << endl;
        cout << "______________________________________________" << endl;
        cout << endl;
    }

    //enemy's turn
    enemyAttack = rand() % 3 + 2;
    if ( ( enemyAttack == 2) || ( enemyAttack == 3) )
    {
        cout << "Squirtle uses " << enmAtt[ enemyAttack - 1] << endl;
        cout << endl;

        eDmg = eDmg % 6 + 5;
        Health = Health - eDmg;
        if ( Health < 1)
        {
            cout << "Squirtle Wins!" << endl;
            cout << endl;
            break;
        }
        cout << "Pikachu's Health: " << Health << "%" << endl;
        cout << "Squirtle's Health: " << enemyHealth << "%" << endl;
        cout << "______________________________________________" << endl;
        cout << endl;
    }
    if ( ( enemyAttack == 1) || ( enemyAttack == 4) )
    {
        cout << "Squirtle uses " << enmAtt[ enemyAttack - 1] << endl;
        cout << endl;

        eDmg = eDmg % 11 + 10;
        Health = Health - eDmg;
        if ( Health < 1)
        {
            cout << "Squirtle Wins!" << endl;
            cout << endl;
            break;
        }
        cout << "Pikachu's Health: " << Health << "%" << endl;
        cout << "Squirtle's Health: " << enemyHealth << "%" << endl;
        cout << "______________________________________________" << endl;
        cout << endl;
    }

    }


}

I'm Sure most of you know what Pokemon is but if you don't know what Pokemon simulator is, its a small ( about 3 MB ) but very addicting game and I decided to make my own version. Right now as you can see, all I have is a program that lets you battle the only enemy Pokemon in the game - a Squirtle (water Pokemon) with your only Pokemon, Pikachu (electric Pokemon). What I want to do now is add a bunch of other choices for the user and also add more enemy Pokemon.

I was wondering if anyone has any idea how I should do this.
Thanks in advance :)

P.S. If you find my idea of making a Pokemon game interesting and want to join me, please PM me (or simply reply to this thread)

Line 25,26 and 27. Just write

cout << endl << "Your attacks:" << endl << endl;

Edited 5 Years Ago by alexchen: n/a

Use switch instead of if.

switch(Attack){

case 1: case 2: dmg = rand() % 16 + 15;
//
break;

case 3: case 4: 
dmg = rand() % 8 + 8;
enemyHealth = enemyHealth - dmg;
//
break;
}

Upvote my post if they help.

This article has been dead for over six months. Start a new discussion instead.