Program randomly generates Gender, Attack from 4 to 8, Defense from 1-3, HP from 30 - 50

This C Program code is for Simplemon: User picks name for pokemon. Program randomly generates Gender, Attack from 4 to 8, Defense from 1-3, HP from 30 - 50. Includes Mewtwo. This code will simulate the Pokemon game battles.



#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>

// This code is for Simplemon:
// User picks name for pokemon
// Program randomly generates Gender, Attack from 4 to 8, Defense from 1-3, HP from 30 - 50
// Includes Mewtwo
// this code will simulate the Pokemon game battles
int main()
{
// Your Pokemon set up
int player_gender, player_attack, player_defense, player_hp;
        char player_random_gender;
        char player_name [80];

// Wild Pokemon set up
int wildpkm_gender, wildpkm_attack, wildpkm_defense, wildpkm_hp;
char wildpkm_random_gender;
char wildpkm_name [80] = "Mewtwo";

// Battle set up
int player_base_atk;
int player_damage_calculation;

// Your Pokemon stats
        printf("Simplemon! Please input the name for your Pokemon: ");
        scanf("%79s", player_name);

        srand(time(NULL));
        player_gender = rand() % 2;
        if (player_gender == 0)
        {
                player_random_gender = 'M';
        }
        else
        {
                player_random_gender = 'F';
        }
        player_attack = rand() % 5 + 4;
        player_defense = rand() % 3 + 1;
        player_hp = rand() % 21 + 30;

        printf("Your Pokemon: %s\n", player_name);
        printf("Gender: %c\n", player_random_gender);
        printf("Attack: %d\n", player_attack);
        printf("Defense: %d\n", player_defense);
        printf("HP: %d\n", player_hp);

// Wild Pokemon stats
srand(time(NULL));
wildpkm_gender = rand() % 2;
if (wildpkm_gender == 0)
        {
                wildpkm_random_gender = 'M';
        }
        else
        {
                wildpkm_random_gender = 'F';
        }
        wildpkm_attack = 8;
        wildpkm_defense = 4;
        wildpkm_hp = 45;

printf("Name: %s\n", wildpkm_name);
printf("Gender: %c\n", wildpkm_random_gender);
printf("Attack: %d\n", wildpkm_attack);
printf("Defense: %d\n", wildpkm_defense);
printf("HP: %d\n", wildpkm_hp);

// Battle!!!!!!!!!!!!!
player_base_atk = rand() % 6 + 3;
player_damage_calculation = player_base_atk + player_attack - wildpkm_defense;
while ( player_hp > 0 && wildpkm_hp > 0)
{
wildpkm_hp = wildpkm_hp - player_damage_calculation;
printf("%s HP: %d\n", wildpkm_name, wildpkm_hp);
if ( wildpkm_hp <= 0)
{
printf("%s has fainted.\n", wildpkm_name);
}
}
}


Learn More :