int Enemy::attack() { static default_random_engine engine(time(NULL)); uniform_int_distribution<int> attackRoll(0, _attack); return attackRoll(engine); }
/*********************************************************************************************** * Function: attack() * Description: This function lets this creature attack another one * Parameters: none * Pre-Conditions: an object of this class must be created * Post-Conditions: none * Return: the attack points directed towards the opposing creature *************************************************************************************************/ int Medusa::attack(){ int damage = attackRoll(); if (damage == 12){ // SPECIAL ABLITY cout << "Medusa rolled a 12! Opponent has looked in Medusa's eyes and turned to stone!" << endl; damage = 999; }else if(damage != 12){ cout << "Medusa attacks! Medusa generated " << damage << " damage points to opponent..." << endl; } return damage; }
/*********************************************************************************************** * Function: attack() * Description: This function lets this creature attack another one * Parameters: none * Pre-Conditions: an object of this class must be created * Post-Conditions: none * Return: the attack points directed towards the opposing creature *************************************************************************************************/ int Vampire::attack(){ int damage = attackRoll(); cout << "Vampire attacks! Vampire generated " << damage << " damage points to opponent..." << endl; return damage; }
int Enemy::attack(){ static mt19937 randomEngine(time(0)); uniform_int_distribution<int> attackRoll(0, _attack); return attackRoll(randomEngine); }
/*********************************************************************************************** * Function: attack() * Description: This function lets this creature attack another one * Parameters: none * Pre-Conditions: an object of this class must be created * Post-Conditions: none * Return: the attack points directed towards the opposing creature *************************************************************************************************/ int BlueMen::attack(){ int damage = attackRoll(); cout << "Blue Men attack! Blue Men generated " << damage << " damage points to opponent..." << endl; return damage; }