Exemple #1
0
	/*********************************************************************
	** Function: attack
	** Description: Rolls attack dice and returns results, if totRoll = 12,
	** then achilles is true (this has an effect on damage()).
	** Parameters: N/A
	** Pre-Conditions: N/A
	** Post-Conditions: Attack dice roll retuls returned, achilles may be
	** true.
	*********************************************************************/
	int attack(){
		int totRoll = attDie.totalRoll();
		
		//totRoll = 12;

		if (totRoll == 12 && enemy != GOBLIN) {
			setAchilles(1);
			std::cout << "An achilles tendon was cut!" << std::endl;
		}

		return totRoll;
	}
Henchman::Henchman()
{
   strengthDefault = 8;
   setName("Henchman");
   setType(HENCHMAN);
   setStrengthPts(strengthDefault);
   setAttackDice(2);
   setAttackSides(6);
   setDefenseDice(1);
   setDefenseSides(6);
   setArmor(3);
   setAchilles(false);
}
/************************************************************
 ** Henchman::attack
 ** Description: Generates a dice roll from AttackDice and
 ** AttackSides values and returns an attack value.
 ** If a 12 is rolled, the achilles attack is successful
 ** Parameters: Character& defender
 ************************************************************/
int Henchman::attack(Character* defender)
{
   int attkTotal = 0;   // Reset accumulator

   for (int d = 0; d < getAttackDice(); d++)
   {
      attkTotal += rollDice(getAttackSides());
   }

   // Achilles attack successful if 12 is rolled and defender
   // is not another Henchman
   if (attkTotal == 12 && defender->getType() != HENCHMAN)
      setAchilles(true);

   return attkTotal;
}