Ejemplo n.º 1
0
void tstTeamMngr::testGetAllTeams()
{
  printStartMsg("tstTeamMngr::testGetAllTeams");
  
  TournamentDB* db = getScenario01(true);
  TeamMngr tmngr(db);
  
  // run on empty table
  QList<Team> result = tmngr.getAllTeams();
  CPPUNIT_ASSERT(result.length() == 0);
  
  // actually create a valid team
  CPPUNIT_ASSERT(tmngr.createNewTeam("t1") == OK);
  CPPUNIT_ASSERT(tmngr.createNewTeam("t2") == OK);
  
  // run on filled table
  result = tmngr.getAllTeams();
  CPPUNIT_ASSERT(result.length() == 2);
  Team t = result.at(0);
  CPPUNIT_ASSERT(t.getId() == 1);
  CPPUNIT_ASSERT(t.getName() == "t1");
  t = result.at(1);
  CPPUNIT_ASSERT(t.getId() == 2);
  CPPUNIT_ASSERT(t.getName() == "t2");
  
  delete db;
  printEndMsg();
}
//------------------------------------------------------------------------------
void GameLogicClientSoccer::onTeamAssignmentChanged(Player * player)
{
    if (player == puppet_master_->getLocalPlayer())
    {
        TEAM_ID team_id = score_.getTeamId(puppet_master_->getLocalPlayer()->getId());

        // also update mine warning billboards
        TankMineVisual::setLocalPlayerTeam(team_id);
        
        if (team_id != INVALID_TEAM_ID)
        {
        } else
        {
            setInputMode(IM_CONTROL_CAMERA);
        }
    }



    Team * team = score_.getTeam(player->getId());

    if (player == puppet_master_->getLocalPlayer())
    {
        if (team == NULL)
        {
            puppet_master_->getHud()->addMessage("You have been assigned to no team.");

            // Hide respawn counter
            show_respawn_text_ = false;
            handleRespawnCounter(0.0f);
        } else
        {
            show_respawn_text_ = true;
            puppet_master_->getHud()->addMessage(std::string("You have been assigned to ") +
                                                 team->getName() +
                                                 ".",
                                                 team->getColor());

            sendRespawnRequest(0);
        }
    } else if (puppet_master_->getLocalPlayer()->isLevelDataSet())
    {
        // Notification if other player changes team
        if (team)
        {
            puppet_master_->getHud()->addMessage(player->getName()   +
                                                 " has been assigned to " +
                                                 team->getName() +
                                                 ".",
                                                 team->getColor());
        } else
        {
            puppet_master_->getHud()->addMessage(player->getName() + " has been assigned to no team.");
        }
    }    
}
Ejemplo n.º 3
0
bool sortByWinningPercentage(const Team &team1, const Team &team2) {
    if (team1.getWinningPercentage() > team2.getWinningPercentage())
        return true;
    else if (team1.getWinningPercentage() < team2.getWinningPercentage())
        return false;

    // winning percentages are equal
    
    if (team1.getGamesPlayed() > team2.getGamesPlayed())
        return true;
    else if (team1.getGamesPlayed() < team2.getGamesPlayed())
        return false;

    // games played are equal
    
    if (team1.getName() < team2.getName())
        return true;
    else if (team1.getName() > team2.getName())
        return false;

    // Teams are the same. Impossible! But return true anyway;
    return true;
}
Ejemplo n.º 4
0
void
TeamsConsole::drawElemData(const Team& team) const
{
  unsigned int	colorIndex;

  colorIndex = this->getServerData()->getTeamId(team);
  this->move(1, m_index + 1);
  this->setColor(m_colors.getColor(colorIndex));
  {
    this->print("Team %s", team.getName());
  }
  this->unsetColor(m_colors.getColor(colorIndex));
  ++m_index;
}
Ejemplo n.º 5
0
void Lottery::assign(Team &t, int odds, int &count) {
	int randomNum = rand() % RANDOM_NUM;

	if (!lotteryNum[randomNum].occupied) {
		lotteryNum[randomNum].team = t.getName();
		lotteryNum[randomNum].occupied = true;

		count++;
	}
	else {
		assign(t, odds, count);
	}

	if (count != odds) {
		assign(t, odds, count);
	}
}
Ejemplo n.º 6
0
void tstTeamMngr::testGetTeam()
{
  printStartMsg("tstTeamMngr::testGetTeam");
  
  TournamentDB* db = getScenario01(true);
  TeamMngr tmngr(db);
  
  // actually create a valid team
  CPPUNIT_ASSERT(tmngr.createNewTeam("t1") == OK);
  CPPUNIT_ASSERT(tmngr.createNewTeam("t2") == OK);
  
  // try queries on filled table
  CPPUNIT_ASSERT_THROW(tmngr.getTeam(""), std::invalid_argument);
  CPPUNIT_ASSERT_THROW(tmngr.getTeam(QString::null), std::invalid_argument);
  CPPUNIT_ASSERT_THROW(tmngr.getTeam("dflsjdf"), std::invalid_argument);
  Team t = tmngr.getTeam("t2");
  CPPUNIT_ASSERT(t.getId() == 2);
  CPPUNIT_ASSERT(t.getName() == "t2");
  
  delete db;
  printEndMsg();
}
Ejemplo n.º 7
0
bool operator== (const Team &team1, const Team &team2) {
    return team1.getName() == team2.getName();
}
Ejemplo n.º 8
0
uint qHash(const Team &team)
{
  return qHash( team.getName() ) ^ qHash( team.getClub() );
}
Ejemplo n.º 9
0
bool operator==( const Team& one, const Team& other ) {
  return one.getName() == other.getName() && one.getClub() == other.getClub();
}