#include <iostream>
#include "zergling.h"
#include <time.h>
using namespace std;
zergling* createZergling(int num)
{
zergling* z1 = (zergling*)malloc(sizeof(zergling));
z1->atk = 5;
z1->def = 0;
z1->HP = 50;
z1->number = num;
return z1;
}
void attack(zergling* z1, zergling* z2)
{
//sleep(1000);
cout << z1->number << " " << z2->number << "게 " << z1->atk << " HP " << z2->HP << " ." << endl;
z2->HP -= z1->atk;
}
void fight(zergling* z1, zergling* z2)
{
while ( z1->HP != 0 && z2->HP != 0 )
{
attack(z1, z2);
attack(z2, z1);
}
which_is_dead(z1, z2);
}
void fightwith(zergling* z1, zergling* z2)
{
while ( z1->HP != 0 && z2->HP != 0 )
{
attack(z1, z2);
attack(z2, z1);
}
}
void new_fightwith(zergling* z1, zergling* z2)
{
int which = rand() % 2;
if ( which == 0 )
{
fight(z1, z2);
}
else
{
fight(z2, z1);
}
}
void which_is_dead(zergling* z1, zergling* z2)
{
if ( z1->HP == 0 )
{
cout << z1->number << " ." << endl;
}
else
{
cout << z2->number << " ." << endl;
}
}