# 13793 - Pokemon Battle Manager 2
>author: Utin
###### tags: `struct`
---
## Brief
See the code below
## Solution 0
```c=
#include <stdio.h>
typedef struct pokemon{
int id;
char name[20];
char first_move[20];
char second_move[20];
int attack;
int special_attack;
int defense;
int special_defense;
int Hp;
int maxHp;
}Pokemon;
int max(int a, int b) {
if (a > b) return a;
else return b;
}
// TODO: recover the Pokémon
void recover(Pokemon *P) {
P->Hp = P->maxHp;
}
// TODO: simulate and print the process of the battle
void battle(Pokemon *A, Pokemon *B) {
if (A->Hp == 0 && B->Hp == 0) printf("Draw.");
else if (A->Hp != 0 && B->Hp == 0)
printf("%s is the winner! %s died in vain...\n\n", A->name, B->name);
else if (A->Hp == 0 && B->Hp != 0)
printf("%s is the winner! %s died in vain...\n\n", B->name, A->name);
else {
if (A->attack > 0) {
int damage = max(2 * (A->attack - B->defense), 1);
B->Hp -= damage;
if (B->Hp < 0) B->Hp = 0;
printf("%s used %s!\n", A->name, A->first_move);
printf("%s now has %d HP.\n", B->name, B->Hp);
A->attack *= -1;
}
else {
int damage = max(2 * (A->special_attack - B->special_defense), 1);
B->Hp -= damage;
if (B->Hp < 0) B->Hp = 0;
printf("%s used %s!\n", A->name, A->second_move);
printf("%s now has %d HP.\n", B->name, B->Hp);
A->attack *= -1;
}
if (B->Hp == 0) {
if (A->attack < 0) A->attack *= -1;
if (B->attack < 0) B->attack *= -1;
printf("%s is the winner! %s died in vain...\n\n", A->name, B->name);
}
else battle(B, A);
}
}
// By Utin
```
## Reference