コード例 #1
0
ファイル: tstTeamMngr.cpp プロジェクト: Foorgol/QTournament
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();
}
コード例 #2
0
//------------------------------------------------------------------------------
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.");
        }
    }    
}
コード例 #3
0
ファイル: Team.cpp プロジェクト: ebanner/CSCI-1200
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;
}
コード例 #4
0
ファイル: TeamsConsole.cpp プロジェクト: Aracthor/super_zappy
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;
}
コード例 #5
0
ファイル: lottery.cpp プロジェクト: harryhan15/Tankathon
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);
	}
}
コード例 #6
0
ファイル: tstTeamMngr.cpp プロジェクト: Foorgol/QTournament
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();
}
コード例 #7
0
ファイル: Team.cpp プロジェクト: ebanner/CSCI-1200
bool operator== (const Team &team1, const Team &team2) {
    return team1.getName() == team2.getName();
}
コード例 #8
0
ファイル: team.cpp プロジェクト: Mathsoum/Petanque
uint qHash(const Team &team)
{
  return qHash( team.getName() ) ^ qHash( team.getClub() );
}
コード例 #9
0
ファイル: team.cpp プロジェクト: Mathsoum/Petanque
bool operator==( const Team& one, const Team& other ) {
  return one.getName() == other.getName() && one.getClub() == other.getClub();
}