Player class. Written for OOP Review. Derived from life_entity.
Revision 1:2548417420a3, committed 2011-04-01
- Comitter:
- Nakor
- Date:
- Fri Apr 01 01:30:26 2011 +0000
- Parent:
- 0:7c89d9ec2d76
- Commit message:
- Documentation.
Changed in this revision
player.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 7c89d9ec2d76 -r 2548417420a3 player.h --- a/player.h Thu Mar 31 19:56:01 2011 +0000 +++ b/player.h Fri Apr 01 01:30:26 2011 +0000 @@ -7,46 +7,226 @@ #define DEBUG_PLAYER 0x01 - +/** Player class derived from life_entity. + * + * This class is derived from life_entity. + * + * Example: + * @code + * + * // Create a new player object. + * player *user = new player(); + * + * int main() + * { + * // Get the user's level (for example) + * char playerLevel = user->getLevel(); + * } + * @endcode + */ class player : public life_entity { public: - // Constructor + /** Player class constructor. + * + * This class is derived from life_entity. + * + * Example: + * @code + * + * // Create a new player object. + * player *user = new player(); + * + * int main() + * { + * // Get the user's level (for example) + * char playerLevel = user->getLevel(); + * } + * @endcode + */ player(); - // Return the player's experience point count + /** Get the number of experience points the player currently has. + * + * Example: + * @code + * // Create a new player object. + * player *user = new player(); + * + * int main() + * { + * // Get the user's xp + * unsigned long int xp = user->getExperience(); + * } + * @endcode + */ unsigned long int getExperience(); - // Return player's current level + /** Get the number player's current level. + * + * Example: + * @code + * // Create a new player object. + * player *user = new player(); + * + * int main() + * { + * // Get the user's level + * char playerLevel = user->getLevel(); + * } + * @endcode + */ char getLevel(); - // Check experience with required experience - // and level up if needed/possible + /** Check to see if the player is ready to level up. + * + * Compare the player's current experience with the amount + * of experience required to reach the next level. + * If enough experience is present, level up the player. + * + * Example: + * @code + * // Create a new player object. + * player *user = new player(); + * + * int main() + * { + * // Check for level up + * user->isLevelUp(); + * } + * @endcode + */ void isLevelUp(); - // Add experience points + /** Add experience points (and apply rest health). + * + * Add experience points for the win and calculate + * bonus health from 'rest'. + * + * Example: + * @code + * // Create a new player object. + * player *user = new player(); + * + * int main() + * { + * // Add experience points to player + * user->addExperience(); + * } + * @endcode + */ void addExperience(); - // Display entire experience ramp + /** Display player experience ramp. + * + * Display the amount of experience required + * for each level. + * + * Example: + * @code + * // Create a new player object. + * player *user = new player(); + * + * int main() + * { + * // Print experience ramp + * user->displayExpRamp(); + * } + * @endcode + */ void displayExpRamp(); - // Incoming damage + /** Take damage from apponent. + * + * This applies the enemy's damage roll to the player's health after a dodge roll + * is performed. + * + * @param roll The damage roll to be passed in (most likely from rollDamage()). + * + * Example: + * @code + * player *user = new player(); + * life_entity *currentEnemy; + * + * int main() + * { + * // Use the pointer to create a new armoured_vehicle (derived class) + * currentEnemy = new enemy(user); + * + * // Enemy rolls for damage + * int roll = currentEnemy->rollDamage(); + * // Player takes the hit + * user->takeDamage(roll); + * } + * @endcode + */ virtual void takeDamage(int roll); - // Communicate info about current enemy + /** Send information about the current enemy. + * + * Pass amount of health and (optionally) level of current enemy. + * + * @param health Amount of enemy health left. + * @param level Enemy level (optional). Defaults to 0x00. + * + * Example: + * @code + * // Create a new player object. + * player *user = new player(); + * + * int main() + * { + * // Get current enemy health + * int enemyHealth = currentEnemy->getHealth(); + * // Send update on enemy health status to user + * user->setCurrentEnemy(enemyHealth); + * } + * @endcode + */ void setCurrentEnemy(int health, char level = 0x00); - // Check to see if the player is dead + /** Check to see if the player is dead. + * + * If player is dead it makes fun of player and pretends to restart everything. + * Returns true if player is dead. + * + * Example: + * @code + * // Create a new player object. + * player *user = new player(); + * + * int main() + * { + * char thereIsCake = user->isDead(); + * if(thereIsCake) + * { + * // Do your delete and new code here + * } + * } + * @endcode + */ char isDead(); protected: + /** + * Variable to hold amount of player's experience points. + */ unsigned long int _experience; + /** + * Variable to hold the current enemy's level. + */ char _enemyLevel; + /** + * Variable to hold the current enemy's health. + */ int _enemyHealth; + /** + * Base health of player (that is then multiplied by level). + */ int _baseHealth; };