コード例 #1
0
/*
    Function Name: updateStrengthPts
    Function Parameters: defense and opponent's attack roll integers
    What the function does: custom update function which gets Barbarian's current
                            strength, and calculates total damage done by
                            subtracting the sum of defense roll and armor from the
                            opponent's attack roll.  If damage done > 0, sets his
                            strength points, subtracting the damage inflicted from
                            current strength points
*/
void Barbarian::updateStrengthPts(int defenseRoll, int opponentRoll) {
    int currStrength = getStrengthPts();
    int damageDone = opponentRoll - defenseRoll;

    if (damageDone > 0) {
        setStrengthPts(currStrength - damageDone);
    }
}
コード例 #2
0
/*
    Function Name: Barbarian
    Function Parameters: creature's name string
    What the function does: initializes a new instance of the Barbarian subclass,
                            setting its type, strengthPts, armorPts, attackDieSides,
                            numAttackDice, and numDefenseDice to Barbarian defaults
*/
Barbarian::Barbarian(string name) : Creature(name) {
    setCreatureType(BARBARIAN);
    setStrengthPts(12);
    setArmorPts(0);
    setAttackDieSides(6);
    setNumAttackDice(2);
    setNumDefenseDice(2);
}
コード例 #3
0
Henchman::Henchman()
{
   strengthDefault = 8;
   setName("Henchman");
   setType(HENCHMAN);
   setStrengthPts(strengthDefault);
   setAttackDice(2);
   setAttackSides(6);
   setDefenseDice(1);
   setDefenseSides(6);
   setArmor(3);
   setAchilles(false);
}