/* ******************************************************************* * Includes * ******************************************************************/ #include "Player.h" #include "Unit.h" #include /* ******************************************************************* * Defines * ******************************************************************/ /* ******************************************************************* * Types definition * ******************************************************************/ /* ******************************************************************* * Global variables definition * ******************************************************************/ /* ******************************************************************* * Local variables definition * ******************************************************************/ /* ******************************************************************* * Local prototypes declaration * ******************************************************************/ /* ******************************************************************* * Functions definition * ******************************************************************/ /*****************************************************************//** * * \brief Constructor for Player class. * *********************************************************************/ Player::Player(const char* const strPlayerName): _name{'\0'} { enum { DEFAULT_RESOURCES = 300 }; if (strPlayerName != NULL) { strncpy(_name, strPlayerName, MAX_NAME_LENGTH); } else { /* Undefined player name. */ } /* Set all resources to default value. */ memset(_resourcesMap, DEFAULT_RESOURCES, sizeof(uint8_t) * MAX_RESOURCE_TYPES); } void Player::handleUnits(void) { for (size_t szUnit = 0; szUnit < MAX_UNITS; szUnit++) { /* Select Unit object from internal table. */ Unit& unit = _unitsMap[szUnit]; /* Execute unit handler. */ unit.handler(); } } void Player::drawUnits(void) { for (size_t szUnit = 0; szUnit < MAX_UNITS; szUnit++) { /* Select Unit object from internal table. */ Unit& u = _unitsMap[szUnit]; /* Execute drawHandler for selected Unit. */ u.drawHandler(); } }