Player Class Reference
#include <player.h>
List of all members.
Detailed Description
This class is meant to represent a local human being playing a card game.
- Author:
- John Schneiderman
|
Public Types |
enum | SkillLevel {
Skill_Error = 0,
Master,
Pwner,
Professional,
Apprentice,
Amateur,
Novice,
Newb
} |
enum | SkillLevelPercentages {
MasterLowScore = 95,
PwnerLowScore = 84,
ProfessionalLowScore = 73,
ApprenticeLowScore = 57,
AmateurLowScore = 41,
NoviceLowScore = 20,
NewbLowScore = 0
} |
Public Member Functions |
void | addPoint (int point) |
void | clear () |
void | decrementGamesWon () |
GameInformation & | gameInformation () |
GameInformation | gameInformation () const |
int | gamesWon () const |
CardSequence & | hand () |
const CardSequence & | hand () const |
void | incrementGamesWon () |
bool | isDealer () const |
bool | isTurn () const |
QString | name () const |
bool | operator== (const Player &player) const |
| Player () |
void | removePoint (int point) |
void | reset () |
void | resetRoundScore () |
int | score () const |
void | setDealer (bool dealer) |
void | setName (const QString &name) |
void | setSkillLevel (SkillLevel level) |
void | setTurn (bool turn) |
SkillLevel | skillLevel () const |
virtual | ~Player () |
Protected Attributes |
bool | m_dealer |
GameInformation | m_gameInformation |
int | m_gamesWon |
CardSequence | m_hand |
SkillLevel | m_level |
QString | m_name |
int | m_score |
bool | m_turn |
Friends |
ostream & | operator<< (ostream &out, const Player &player) |
QTextStream & | operator<< (QTextStream &out, const Player &player) |
QTextStream & | operator>> (QTextStream &in, Player &player) |
Member Enumeration Documentation
This is the range for the various skill levels.
- Parameters:
-
| Skill_Error | is when there is a problem with the skill level. |
| Master | is when the player wins more than 95% of the time. |
| Pwner | is when the player wins from 84% to 94% of the time. |
| Professional | is when the player wins from 73% to 83% of the time. |
| Apprentice | is when the player wins from 57% to 72% of the time. |
| Amateur | is when the player wins from 41% to 56% of the time. |
| Novice | is when the player wins from 20% to 40% of the time. |
| Newb | is when the player wins less than 20% of the time. |
These are the lower percentate levels for each of the skill levels.
- Parameters:
-
| MasterLowScore | is the master skill low score. |
| PwnerLowScore | is the pwner skill low score. |
| ProfessionalLowScore | is the professional skill low score. |
| ApprenticeLowScore | is the apprentice skill low score. |
| AmateurLowScore | is the amateur skill low score. |
| NoviceLowScore | is the novice skill low score. |
| NewbLowScore | is the newb skill low score. |
Constructor & Destructor Documentation
This is a general constructor.
Player::~Player |
( |
|
) |
[virtual] |
Member Function Documentation
void Player::addPoint |
( |
int |
point |
) |
|
This adds points to a players score.
- Parameters:
-
| point | is the number of points to increase the score by. |
This clears everthing a players has.
void Player::decrementGamesWon |
( |
|
) |
|
Decreases the number of games won by one.
A modifier to the game information that is known to the player.
- Returns:
- the game information known to the player.
An accessor to the game information that is known to the player.
- Returns:
- the game information known to the player.
int Player::gamesWon |
( |
|
) |
const |
This gives the number of games a player has won.
- Returns:
- the number of games won.
This gives the current hand a player is holding.
- Returns:
- a reference to the hand a player is holding.
This gives the current hand a player is holding.
- Returns:
- the hand a player is holding.
void Player::incrementGamesWon |
( |
|
) |
|
Increases the number of games won by one.
bool Player::isDealer |
( |
|
) |
const |
This determines if a player is the dealer or not.
- Returns:
- true if the player is the dealer, false elsewise.
bool Player::isTurn |
( |
|
) |
const |
This determines if it is a players turn.
- Returns:
- true if it is the players turn, false elsewise.
QString Player::name |
( |
|
) |
const |
This gives the name/nickname of the player.
- Returns:
- The name/nickname of the player.
bool Player::operator== |
( |
const Player & |
player |
) |
const |
Equivalent operator
- Parameters:
-
| player | is the what you wish to compare *this to. |
- Returns:
- true if their names and hands are the same, false elsewise.
void Player::removePoint |
( |
int |
point |
) |
|
This removes points from players score.
- Parameters:
-
| point | is the number of points to decrease the score by. |
This resets a player's hand, turn setting, and dealer setting to their starting values.
void Player::resetRoundScore |
( |
|
) |
|
This resets a player's round score to their starting values.
int Player::score |
( |
|
) |
const |
This returns the current score a player has earned during the game.
- Returns:
- The current value of the players score.
void Player::setDealer |
( |
bool |
dealer |
) |
|
This sets a player to be the dealer or not.
- Parameters:
-
| dealer | true if you want the player to be a dealer, false if not. |
void Player::setName |
( |
const QString & |
name |
) |
|
This sets the name/nickname of the player.
- Parameters:
-
| name | is the name/nickname for the player. |
This sets the skill level for the player.
- Parameters:
-
| level | is the level to set for the player for the current game. |
void Player::setTurn |
( |
bool |
turn |
) |
|
This sets a player's turn.
- Parameters:
-
| turn | should be set to true if it is time for a players turn, false if it is not. |
This is the accessor to a player's skill level.
- Returns:
- the current skill level the player has for the current game.
Friends And Related Function Documentation
ostream& operator<< |
( |
ostream & |
out, |
|
|
const Player & |
player | |
|
) |
| | [friend] |
This is the stream insertion for a player.
- Parameters:
-
| out | is the stream to insert the player data into. |
| player | is the player to insert into the stream. |
- Note:
- If a player's name contains spaces, the spaces are replaced with an underscore.
- Returns:
- out.
QTextStream& operator<< |
( |
QTextStream & |
out, |
|
|
const Player & |
player | |
|
) |
| | [friend] |
This is the stream insertion for a player.
- Parameters:
-
| out | is the stream to insert the player data into. |
| player | is the player to insert into the stream. |
- Note:
- If a player's name contains spaces, the spaces are replaced with an underscore.
- Returns:
- out.
QTextStream& operator>> |
( |
QTextStream & |
in, |
|
|
Player & |
player | |
|
) |
| | [friend] |
This is the stream extraction for a player.
- Parameters:
-
| in | is the stream to extract the player data from. |
| player | is the player to fill in with the data extracted. |
- Returns:
- in.
Member Data Documentation
- Parameters:
-
| m_dealer | is true if he is a dealer, false elsewise. |
- Parameters:
-
| m_gameInformation | is used to hold game specific information, generally used by the computer based player AI's. |
- Parameters:
-
| m_gamesWon | is the number of games a player has won. |
- Parameters:
-
| m_hand | is the players hand. |
- Parameters:
-
| m_level | is the level that the player plays the current game at. |
- Parameters:
-
| m_name | is the players name/nickname. |
- Parameters:
-
| m_score | is the players score during a round/phase. |
- Parameters:
-
| m_turn | is true if it is his turn, false elsewise. |
The documentation for this class was generated from the following files:
- gamebase/player.h
- gamebase/player.cpp