2013-12-18 08:30:58 +01:00
|
|
|
#include "Team.h"
|
|
|
|
|
|
|
|
using namespace GameLogic;
|
|
|
|
|
|
|
|
|
|
|
|
Team::Team(void)
|
2014-01-20 15:47:52 +01:00
|
|
|
: players(5)
|
|
|
|
, teamSize(5)
|
|
|
|
{}
|
2013-12-18 08:30:58 +01:00
|
|
|
|
|
|
|
Team::Team(int teamSize)
|
2014-01-20 15:47:52 +01:00
|
|
|
: players((unsigned int)teamSize)
|
|
|
|
, teamSize(teamSize)
|
|
|
|
{}
|
2013-12-18 08:30:58 +01:00
|
|
|
|
|
|
|
|
|
|
|
Team::~Team(void)
|
|
|
|
{
|
2014-01-20 15:47:52 +01:00
|
|
|
this->players.Clear();
|
2013-12-18 08:30:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Player* Team::GetPlayer(int playerID)
|
|
|
|
{
|
2014-01-20 15:47:52 +01:00
|
|
|
if(playerID >= 0 && playerID < this->teamSize)
|
|
|
|
return this->players[playerID];
|
|
|
|
|
|
|
|
return NULL;
|
2013-12-18 08:30:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Team::AddPlayer(Player *player)
|
|
|
|
{
|
2014-01-20 15:47:52 +01:00
|
|
|
if ((int)this->players.Size() >= this->teamSize)
|
2013-12-18 08:30:58 +01:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-20 15:47:52 +01:00
|
|
|
int k = -1;
|
|
|
|
for (int i = 0; k == -1 && i < this->teamSize; i++)
|
|
|
|
{
|
|
|
|
if(!this->players[i])
|
|
|
|
k = i;
|
|
|
|
}
|
|
|
|
if(k == -1)
|
|
|
|
{
|
|
|
|
this->players.Push(player);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->players[k] = player;
|
|
|
|
}
|
2013-12-18 08:30:58 +01:00
|
|
|
}
|
2013-12-18 13:07:10 +01:00
|
|
|
|
|
|
|
return true;
|
2013-12-18 08:30:58 +01:00
|
|
|
}
|