Player Class Reference

the different players in ASC. There may be 8 players (0..7) and neutral units (8) More...

#include <player.h>

List of all members.

Public Types

enum  PlayerStatus {
  human, computer, off, supervisor,
  suspended
}
 the status of the player More...
typedef list< Vehicle * > VehicleList
typedef list< Building * > BuildingList
typedef list< DissectionDissectionContainer
 the list of dissected units
typedef list< PlayTimePlayTimeContainer

Public Member Functions

 Player ()
int getPosition () const
const GameMapgetParentMap () const
GameMapgetParentMap ()
void setParentMap (GameMap *map, int pos)
void swap (Player &secondPlayer)
 swaps all information, units, buildings etc with the given player
void merge (Player &secondPlayer)
 merges all units, buildings etc from secondplayer to this one
bool exist () const
 does the player exist at all
ResearchgetResearch ()
bool isHuman () const
ASCString getName () const
 returns the name of the player
void setName (const ASCString &name)
DI_Color getColor () const
PlayerColor getPlayerColor () const
void setColor (const DI_Color &color)
void read (tnstream &stream)
void write (tnstream &stream) const
void resetView ()
void resetResearch ()
void resetTribute ()
void resetPassword ()
bool operator== (const Player &otherPlayer) const
void setPlayerID (int id)
int getPlayerID () const

Static Public Member Functions

static int getHumanPlayerNum (const GameMap *gamemap)

Public Attributes

bool existanceAtBeginOfTurn
 did the player exist when the turn started? Required for checking if a player has been terminated
VehicleList vehicleList
 a list of all units
BuildingList buildingList
 a list of all units
Research research
 the status of the scientific research
BaseAIai
 if the player is run by an AI, this is the pointer to it
enum Player::PlayerStatus stat
 the status of the player
Password passwordcrc
 the Password required for playing this player
DissectionContainer dissections
bool __dissectionsToLoad
MessagePntrContainer unreadmessage
 the list of messages that haven't been read by the player yet
bool __loadunreadmessage
MessagePntrContainer oldmessage
 the list of messages that already have been read by the player yet
bool __loadoldmessage
MessagePntrContainer sentmessage
 the list of messages that have been sent yet
bool __loadsentmessage
int queuedEvents
 if ASC should check all events for fullfilled triggers, this variable will be set to true. This does not mean that there really ARE events that are ready to be executed
int ASCversion
 the version of ASC that this player has used to make his last turn
PlayTimeContainer playTime
 The time this player ended his turns. This is very informative in email games with > 2 players to find out who is delaying the game.
MapCoordinate cursorPos
DiplomaticStateVector diplomacy
ASCString email

Static Public Attributes

static const char * playerStatusNames []

Classes

class  Dissection
struct  PlayTime


Detailed Description

the different players in ASC. There may be 8 players (0..7) and neutral units (8)

Definition at line 98 of file player.h.


Member Typedef Documentation

typedef list<Vehicle*> Player::VehicleList

Definition at line 132 of file player.h.

typedef list<Building*> Player::BuildingList

Definition at line 136 of file player.h.

typedef list<Dissection> Player::DissectionContainer

the list of dissected units

Definition at line 174 of file player.h.

typedef list<PlayTime> Player::PlayTimeContainer

Definition at line 201 of file player.h.


Member Enumeration Documentation

enum Player::PlayerStatus

the status of the player

Enumerator:
human 
computer 
off 
supervisor 
suspended 

Definition at line 149 of file player.h.


Constructor & Destructor Documentation

Player::Player (  ) 

Definition at line 192 of file player.cpp.

References ai, ASCversion, and queuedEvents.


Member Function Documentation

int Player::getPosition ( void   )  const [inline]

Definition at line 111 of file player.h.

Referenced by ChangeDiplomaticState::ChangeDiplomaticState(), DirectResearchCommand::DirectResearchCommand(), getName(), getPlayerColor(), DiplomaticStateVector::getProposal(), DiplomaticStateVector::getState(), RecycleUnitCommand::go(), DiplomacyCommand::go(), initReplayLogging(), DiplomacyCommand::newstate(), MoveUnit::runAction(), ConsumeResource::runAction(), CancelResearchCommand::setPlayer(), TransferControlCommand::setReceiver(), DiplomacyCommand::sneakAttack(), TechnologySelectionItemFactory::spawnNextItem(), DiplomaticStateVector::swap(), testDiplomacy1(), transfer_all_outstanding_tribute(), DiplomaticStateVector::turnBegins(), ConsumeResource::undoAction(), viewOwnReplay(), and viewunreadmessages().

const GameMap* Player::getParentMap (  )  const [inline]

Definition at line 113 of file player.h.

Referenced by checkJournal(), checkUsedASCVersions(), DiplomaticStateVector::getProposal(), initReplayLogging(), positionCursor(), resetTribute(), resetView(), runPendingTasks(), DiplomaticStateVector::swap(), transfer_all_outstanding_tribute(), DiplomaticStateVector::turnBegins(), viewcomp(), viewOwnReplay(), and viewunreadmessages().

GameMap* Player::getParentMap (  )  [inline]

Definition at line 114 of file player.h.

void Player::setParentMap ( GameMap map,
int  pos 
)

Definition at line 203 of file player.cpp.

References GameMap::sigPlayerTurnBegins, GameMap::sigPlayerTurnEnds, and GameMap::sigPlayerUserInteractionBegins.

void Player::swap ( Player secondPlayer  ) 

swaps all information, units, buildings etc with the given player

Definition at line 350 of file player.cpp.

References ai, ASCversion, GameMap::ResourceTribute::avail, buildingList, color, cursorPos, diplomacy, dissections, email, existanceAtBeginOfTurn, GameMap::field, GameMap::getPlayerCount(), MapField::getVisibility(), name, oldmessage, GameMap::ResourceTribute::paid, passwordcrc, GameMap::ResourceTribute::payStatusLastTurn, player, playTime, queuedEvents, research, sentmessage, stat, DiplomaticStateVector::swap(), swapData(), GameMap::tribute, unreadmessage, vehicleList, GameMap::xsize, and GameMap::ysize.

Referenced by tplayerchange::buttonpressed().

void Player::merge ( Player secondPlayer  ) 

merges all units, buildings etc from secondplayer to this one

Definition at line 482 of file player.cpp.

bool Player::exist (  )  const

does the player exist at all

Definition at line 313 of file player.cpp.

References buildingList, and vehicleList.

Referenced by AdminGameWindow::AdminGameWindow(), AllianceSetupWidget::AllianceSetupWidget(), authenticateUser(), checkforvictory(), checkUsedASCVersions(), computeview(), EmailSetupWidget::EmailSetupWidget(), evaluateviewcalculation(), EventEditor::EventEditor(), ASC_MainScreenWidget::eventKeyDown(), LoseMap::execute(), findNextPlayer(), getHumanPlayerNum(), getPlayersWithSharedViewMask(), getVisibilityStatistics(), PlayerSetupWidget::guessHeight(), ttributepayments::init(), maintainencecheck(), PlayerSetupWidget::PlayerSetupWidget(), process_ASC_map(), process_BI_map(), tmessagedlg::setup(), showPlayerTime(), PutTribute::start(), MapNetwork::start(), and transfer_all_outstanding_tribute().

Research& Player::getResearch (  )  [inline]

Definition at line 143 of file player.h.

References research.

bool Player::isHuman (  )  const [inline]

Definition at line 151 of file player.h.

References human, stat, supervisor, and suspended.

Referenced by NextTurnStrategy_OnlyCampaign::authenticate(), authenticateUser(), editPlayerData(), LoseMap::execute(), and getHumanPlayerNum().

int Player::getHumanPlayerNum ( const GameMap gamemap  )  [static]

Definition at line 285 of file player.cpp.

References exist(), GameMap::getPlayer(), GameMap::getPlayerCount(), and isHuman().

Referenced by changePassword(), and newmessage().

ASCString Player::getName (  )  const

returns the name of the player

Definition at line 274 of file player.cpp.

References getPosition(), off, stat, and ASCString::toString().

Referenced by AdminGameWindow::AdminGameWindow(), AllianceSetupWidget::AllianceSetupWidget(), authenticateUser(), checkforvictory(), checkUsedASCVersions(), EditPlayerData::EditPlayerData(), editResearch(), editResearchPoints(), editTechAdapter(), EditTechAdapter::EditTechAdapter(), EmailSetupWidget::EmailSetupWidget(), EventEditor::EventEditor(), TransferControlCommand::getDescription(), DiplomacyCommand::getDescription(), AnyUnitEntersPolygon::getDetailledName(), Message::getFromText(), MessageLineWidget::getName(), getPlayerStrength(), getVisibilityStatistics(), DiplomacyCommand::go(), ttributepayments::init(), tnetworkloaders::loadnwgame(), PlayerSetupWidget::PlayerSetupWidget(), tsavegameloaders::savegame(), selectPlayer(), FileTransfer::send(), DisplayImmediateMessage::setup(), tmessagedlg::setup(), showPlayerTime(), transfer_all_outstanding_tribute(), viewUnitSetinfo(), and GameMap::write().

void Player::setName ( const ASCString name  )  [inline]

Definition at line 159 of file player.h.

Referenced by PlayerSetupWidget::Apply(), and GameMap::read().

DI_Color Player::getColor (  )  const

Definition at line 249 of file player.cpp.

Referenced by AllianceSetupWidget::AllianceSetupWidget(), EmailSetupWidget::EmailSetupWidget(), getPlayerColor(), MessageLineWidget::MessageLineWidget(), DashboardPanel::painter(), PlayerColorPanel::PlayerColorPanel(), PlayerSetupWidget::PlayerSetupWidget(), WholeMapRenderer::renderVisibility(), showAttackAnimation(), and OverviewMapHolder::updateField().

PlayerColor Player::getPlayerColor (  )  const

Definition at line 268 of file player.cpp.

References getColor(), and getPosition().

Referenced by VehicleBaseWidget::display(), VehicleTypeBaseWidget::display(), VehicleTypeImage::display(), VehicleItem::display(), BuildingTypeBaseWidget::display(), DashboardPanel::painter(), and GetTargetImage::visit().

void Player::setColor ( const DI_Color color  ) 

void Player::read ( tnstream stream  ) 

Definition at line 321 of file player.cpp.

References tnstream::readInt().

Referenced by GameMap::read().

void Player::write ( tnstream stream  )  const

Definition at line 331 of file player.cpp.

References tnstream::writeInt().

Referenced by GameMap::write().

void Player::resetView (  ) 

Definition at line 488 of file player.cpp.

References GameMap::getField(), getParentMap(), MapField::setVisibility(), visible_not, GameMap::xsize, and GameMap::ysize.

void Player::resetResearch (  ) 

Definition at line 499 of file player.cpp.

References Research::clear(), and research.

void Player::resetTribute (  ) 

Definition at line 504 of file player.cpp.

References GameMap::ResourceTribute::avail, getParentMap(), GameMap::getPlayerCount(), GameMap::ResourceTribute::paid, GameMap::ResourceTribute::payStatusLastTurn, and GameMap::tribute.

void Player::resetPassword (  ) 

Definition at line 516 of file player.cpp.

References passwordcrc, and Password::reset().

bool Player::operator== ( const Player otherPlayer  )  const

Definition at line 521 of file player.cpp.

References parentMap, and player.

void Player::setPlayerID ( int  id  )  [inline]

Definition at line 226 of file player.h.

int Player::getPlayerID (  )  const [inline]

Definition at line 227 of file player.h.


Member Data Documentation

bool Player::existanceAtBeginOfTurn

did the player exist when the turn started? Required for checking if a player has been terminated

Definition at line 130 of file player.h.

Referenced by authenticateUser(), checkforvictory(), swap(), and GameMap::write().

VehicleList Player::vehicleList

a list of all units

Definition at line 134 of file player.h.

Referenced by tplayerchange::anzeige(), automaticTrainig(), GameMap::beginTurn(), tplayerchange::buttonpressed(), checkForUniqueUnitIDs(), checkUnitsForCrash(), checkunitsforremoval(), clearvisibility(), compareMapResources(), computeview(), GameMap::endRound(), GameMap::endTurn(), Maped_MainScreenWidget::eventKeyDown(), exist(), factoryProductionInstanceExists(), tsearchreactionfireingunits::finalCheck(), getInstances(), getPlayerStrength(), Research::getResearchPerTurn(), AllEnemyUnitsDestroyed::getState(), AllUnitsLost::getState(), GameMap::getUnit(), ResearchGraph::recalc(), Vehicle::registerForNewOwner(), GameMap::resize(), resourceAnalysis(), MapNetwork::searchAllVehiclesNextToBuildings(), ResearchGraph::setResearch(), showAllUnitPositions(), swap(), transformMap(), ResearchWindow::update(), Vehicle::Vehicle(), and vehicleOwned().

BuildingList Player::buildingList

a list of all units

Definition at line 138 of file player.h.

Referenced by tplayerchange::anzeige(), automaticTrainig(), Building::Building(), tplayerchange::buttonpressed(), clearvisibility(), compareMapResources(), computeview(), Building::convert(), doresearch(), GameMap::endRound(), GameMap::endTurn(), exist(), factoryProductionInstanceExists(), getInstances(), getPlayerStrength(), Research::getResearchPerTurn(), AllEnemyBuildingsDestroyed::getState(), AllBuildingsLost::getState(), ConstructUnitCommand::go(), tnetworkloaders::loadnwgame(), ResearchGraph::recalc(), Building::registerForNewOwner(), GameMap::resize(), resourceAnalysis(), resourceComparison(), ResearchGraph::setResearch(), MapNetwork::start(), swap(), transfer_all_outstanding_tribute(), transformMap(), ResearchWindow::update(), viewMiningPower(), and Building::~Building().

Research Player::research

the status of the scientific research

Definition at line 141 of file player.h.

Referenced by anyTechAvailable(), DirectResearchCommand::available(), ChooseTech::cancel(), checkForNewResearch(), checkType(), ChooseTech::ChooseTech(), chooseTechnologyIfAvail(), compareMapResources(), doresearch(), editResearch(), editResearchPoints(), EditTechAdapter::EditTechAdapter(), NewGadgetDetection::evaluate(), trunreplay::execnextreplaymove(), executeUserAction(), GameMap::GameMap(), DirectResearchCommand::getAvailableTechnologies(), getInstances(), getNextTechnologyTowardsGoal(), getResearch(), DirectResearchCommand::go(), CancelResearchCommand::go(), tresearchinfo::init(), tsavegameloaders::loadgame(), tnetworkloaders::loadnwgame(), NewGadgetDetection::NewGadgetDetection(), EditTechAdapter::ok(), CancelResearchCommand::preCheck(), BuildProductionLineCommand::productionLinesBuyable(), GameMap::read(), researchinfo(), resetResearch(), tchoosetechlevel::run(), runResearch(), ChooseTech::showPrerequisites(), GameMap::startGame(), swap(), testresearch1(), testresearch2(), DirectResearchCommand::undoAction(), CancelResearchCommand::undoAction(), unitProductionAnalysis(), ResearchWindow::update(), and GameMap::write().

BaseAI* Player::ai

if the player is run by an AI, this is the pointer to it

Definition at line 143 of file player.h.

Referenced by checkforvictory(), ASC_MainScreenWidget::eventKeyDown(), executeUserAction(), Player(), GameMap::read(), tgameloaders::readAI(), runai(), swap(), tgameloaders::writeAI(), and GameMap::~GameMap().

enum Player::PlayerStatus Player::stat

the status of the player

Referenced by PlayerSetupWidget::Apply(), authenticateUser(), GuiFunctions::OpenContainer::available(), ResourceInfoWindow::available(), calcvisibilityfield(), checkforreplay(), checkforvictory(), editAlliances(), EditPlayerData::EditPlayerData(), ASC_MainScreenWidget::eventKeyDown(), ChangePlayerState::execute(), LoseMap::execute(), findNextPlayer(), GameMap::GameMap(), generatemap(), getName(), CargoDialog::getResourceValue(), getVisibilityStatistics(), initReplayLogging(), isHuman(), iterateToNextPlayer(), k_loadmap(), maintainencecheck(), next_turn(), ResourceGraphLayer::paintSingleField(), PlayerSetupWidget::PlayerSetupWidget(), process_ASC_map(), process_BI_map(), GameMap::read(), FileTransfer::send(), swap(), viewOwnReplay(), and viewunreadmessages().

const char * Player::playerStatusNames [static]

Definition at line 155 of file player.h.

Referenced by EditPlayerData::EditPlayerData(), and PlayerSetupWidget::PlayerSetupWidget().

Password Player::passwordcrc

the Password required for playing this player

Definition at line 159 of file player.h.

Referenced by authenticateUser(), k_loadmap(), GameMap::read(), resetPassword(), swap(), and GameMap::write().

DissectionContainer Player::dissections

Definition at line 175 of file player.h.

Referenced by tspfldloaders::readdissections(), swap(), and tspfldloaders::writedissections().

bool Player::__dissectionsToLoad

Definition at line 177 of file player.h.

Referenced by GameMap::read(), and tspfldloaders::readdissections().

MessagePntrContainer Player::unreadmessage

the list of messages that haven't been read by the player yet

Definition at line 180 of file player.h.

Referenced by Message::Message(), tspfldloaders::readmessages(), swap(), viewunreadmessages(), and tspfldloaders::writemessages().

bool Player::__loadunreadmessage

Definition at line 181 of file player.h.

Referenced by GameMap::read(), and tspfldloaders::readmessages().

MessagePntrContainer Player::oldmessage

the list of messages that already have been read by the player yet

Definition at line 184 of file player.h.

Referenced by executeUserAction(), tspfldloaders::readmessages(), swap(), viewunreadmessages(), and tspfldloaders::writemessages().

bool Player::__loadoldmessage

Definition at line 185 of file player.h.

Referenced by GameMap::read(), and tspfldloaders::readmessages().

MessagePntrContainer Player::sentmessage

the list of messages that have been sent yet

Definition at line 188 of file player.h.

Referenced by executeUserAction(), tspfldloaders::readmessages(), swap(), and tspfldloaders::writemessages().

bool Player::__loadsentmessage

Definition at line 189 of file player.h.

Referenced by GameMap::read(), and tspfldloaders::readmessages().

int Player::queuedEvents

if ASC should check all events for fullfilled triggers, this variable will be set to true. This does not mean that there really ARE events that are ready to be executed

Definition at line 192 of file player.h.

Referenced by Research::addanytechnology(), checkevents(), eventReady(), mainloopidle(), Player(), seteventtriggers(), swap(), and GameMap::write().

int Player::ASCversion

the version of ASC that this player has used to make his last turn

Definition at line 195 of file player.h.

Referenced by checkUsedASCVersions(), GameMap::endTurn(), Player(), GameMap::read(), showPlayerTime(), and swap().

PlayTimeContainer Player::playTime

The time this player ended his turns. This is very informative in email games with > 2 players to find out who is delaying the game.

Definition at line 204 of file player.h.

Referenced by GameMap::endTurn(), GameMap::read(), showPlayerTime(), swap(), and GameMap::write().

MapCoordinate Player::cursorPos

Definition at line 206 of file player.h.

Referenced by DashboardPanel::eval(), GameMap::getCursor(), UnitInfoPanel::onClick(), GameMap::read(), swap(), and GameMap::write().

DiplomaticStateVector Player::diplomacy

Definition at line 208 of file player.h.

Referenced by AllianceSetupWidget::AllianceSetupWidget(), AllianceSetupWidget::Apply(), attackpossible(), attackpossible2n(), attackpossible2u(), Mine::attacksunit(), GuiFunctions::SelfDestructIcon::available(), GuiFunctions::InternalAmmoTransferDialog::available(), GuiFunctions::OpenContainer::available(), CargoGuiFunctions::RecycleUnitCommandButton::available(), CargoGuiFunctions::OpenContainer::available(), CargoGuiFunctions::UnitTraining::available(), ResearchWindow::available(), ResourceInfoWindow::available(), BuildingControlWindow::available(), NetControlWindow::available(), WindPowerWindow::available(), SolarPowerWindow::available(), calcMoveMalus(), Vehicle::ReactionFire::canPerformAttack(), ServiceChecker::check(), checkSymmetry(), ReplayMapDisplay::displayMovingUnit(), PG_MapDisplay::displayMovingUnit(), evaluateviewcalculation(), trunreplay::execnextreplaymove(), SetViewSharing::execute(), executeUserAction(), fieldAccessible(), tsearchreactionfireingunits::finalCheck(), HiddenAStar3D::getMoveCost(), HiddenAStar::getMoveCost(), getPlayersWithSharedViewMask(), DiplomaticStateVector::getProposal(), AllEnemyBuildingsDestroyed::getState(), AllEnemyUnitsDestroyed::getState(), getTransferLimitation(), DiplomacyCommand::go(), VisibilityLayer::paintSingleField(), GameMap::read(), MoveUnit::runAction(), ChangeDiplomaticState::runAction(), showCargoSummary(), DiplomaticStateVector::swap(), swap(), testDiplomacy1(), testDiplomacy2(), testDiplomacy3(), SearchReconquerBuilding::testfield(), DiplomaticStateVector::turnBegins(), ChangeDiplomaticState::undoAction(), ContainerBase::vehicleFit(), ContainerBase::vehicleLoadable(), viewterraininfo(), and GameMap::write().

ASCString Player::email

Definition at line 210 of file player.h.

Referenced by EmailSetupWidget::Apply(), EditPlayerData::EditPlayerData(), EmailSetupWidget::EmailSetupWidget(), GameMap::read(), FileTransfer::send(), and swap().


The documentation for this class was generated from the following files:
Generated on Mon Feb 6 01:48:02 2012 for Advanced Strategic Command by  doxygen 1.5.1