本文整理汇总了C++中CDate::setMin方法的典型用法代码示例。如果您正苦于以下问题:C++ CDate::setMin方法的具体用法?C++ CDate::setMin怎么用?C++ CDate::setMin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDate
的用法示例。
在下文中一共展示了CDate::setMin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: endDayEventHandler
void CTimeManager::endDayEventHandler(const IGameEvent &event)
{
// Only one "NoMoreEventsToday" event is on the events queue at time,
// so we need to add a new event of this type for tomorrow
CDate date = event.getDate();
date.setDay(date.getDay()+1);
date.setHour(23);
date.setMin(59);
date.setSec(59);
CGameEngine::getInstance()->getEventManager()->addEvent(new CEndDayEvent(date));
}
示例2: load
IGame* CSinglePlayerGame::load(const CPfGames &game)
{
LOG_DEBUG("CSinglePlayerGame::load");
CSinglePlayerGame *singlePlayerGame = new CSinglePlayerGame(game);
singlePlayerGame->loadGameEvents();
CDate date = singlePlayerGame->m_optionManager->getGameCurrentDate();
CGameEngine::getInstance()->getTimeManager()->setCurrentTime(date);
date.setHour(23);
date.setMin(59);
date.setSec(59);
CGameEngine::getInstance()->getEventManager()->addEvent(new CEndDayEvent(date));
return singlePlayerGame;
}
示例3: simulateMatch
void CSinglePlayerGame::simulateMatch(const CPfMatches &match)
{
CEventManager *eventMngr = CGameEngine::getInstance()->getEventManager();
std::string currentTimestamp = match.getDMatch().getTimestamp();
IPfTeamPlayersDAO *teamPlayersDAO = m_daoFactory->getIPfTeamPlayersDAO();
IPfTeamAveragesDAO *teamsAvgDAO = m_daoFactory->getIPfTeamAveragesDAO();
eventMngr->addEvent(new CStartMatchEvent(match.getDMatch(), match.getXMatch()));
int xHomeTeam = match.getXFkTeamHome();
int xAwayTeam = match.getXFkTeamAway();
CPfTeamAverages *homeTeamAvg = teamsAvgDAO->findByXTeam(xHomeTeam, currentTimestamp);
CPfTeamAverages *awayTeamAvg = teamsAvgDAO->findByXTeam(xAwayTeam, currentTimestamp);
int nHomeGoals = getRandomNGoals(homeTeamAvg, awayTeamAvg);
int nAwayGoals = getRandomNGoals(awayTeamAvg, homeTeamAvg);
delete homeTeamAvg;
delete awayTeamAvg;
if( nHomeGoals>0 ){
std::vector<CPfTeamPlayers*>* teamPlayesList = teamPlayersDAO->findLineUpByXFkTeam(xHomeTeam, currentTimestamp);
while( nHomeGoals>0 ){
int numPlayer = rand()%teamPlayesList->size();
if(numPlayer == 0) { //Goalie don't score
numPlayer = 10;
}
CPfTeamPlayers *teamPlayer = teamPlayesList->operator[](numPlayer);
int minute = rand()%90;
CDate eventDate = match.getDMatch();
eventDate.setMin(eventDate.getMin()+minute);
eventMngr->addEvent(new CGoalMatchEvent(eventDate, match.getXMatch(), xHomeTeam, teamPlayer->getXTeamPlayer(), minute, false));
nHomeGoals--;
}
teamPlayersDAO->freeVector(teamPlayesList);
}
if( nAwayGoals>0 ){
std::vector<CPfTeamPlayers*>* teamPlayesList = teamPlayersDAO->findLineUpByXFkTeam(xAwayTeam, currentTimestamp);
while( nAwayGoals>0 ){
int numPlayer = rand()%teamPlayesList->size();
if(numPlayer == 0) { //Goalie don't score
numPlayer = 10;
}
CPfTeamPlayers *teamPlayer = teamPlayesList->operator[](numPlayer);
int minute = rand()%90;
CDate eventDate = match.getDMatch();
eventDate.setMin(eventDate.getMin()+minute);
eventMngr->addEvent(new CGoalMatchEvent(eventDate, match.getXMatch(), xAwayTeam, teamPlayer->getXTeamPlayer(), minute, false));
nAwayGoals--;
}
teamPlayersDAO->freeVector(teamPlayesList);
}
CDate eventDate = match.getDMatch();
eventDate.setMin(eventDate.getMin()+90);
eventMngr->addEvent(new CEndMatchEvent(eventDate, match.getXMatch()));
}
示例4: newGame
IGame* CSinglePlayerGame::newGame(const CPfUsers &user, const std::string &gameName, const std::string &coachName)
{
LOG_DEBUG("CSinglePlayerGame::newGame");
CDate nowDate;
CPfGames game;
game.setDLastSaved(nowDate);
game.setSDriverName("SQLite");
game.setSConnectionString(CResourceManager::getInstance()->getDbFileName());
game.setSGameName(gameName);
game.setSGameType(S_GAME_TYPE_SINGLEPLAYER);
game.setXFkUser(user.getXUser());
// With this way, here we only need to set the initial environment for
// a new game, forgetting the creation of attributes for a CSinglePlayerGame
// object. This task rests now on constructor.
CSinglePlayerGame *singlePlayerGame = new CSinglePlayerGame(game);
// retrieve the last season in the database and the end date of the itself
CDate maxDate = CDate::MIN_DATE;
CPfSeasons *season = singlePlayerGame->m_daoFactory->getIPfSeasonsDAO()->findLastSeason();
if( season->getXSeason() == 0 ){
throw PFEXCEPTION("The last season is NULL");
}
IPfCompetitionPhasesBySeasonDAO *competitionBySeasonDAO = singlePlayerGame->m_daoFactory->getIPfCompetitionPhasesBySeasonDAO();
std::vector<CPfCompetitionPhasesBySeason*> *competitionsBySeasonList = competitionBySeasonDAO->findByXFkSeason(season->getXSeason_str());
std::vector<CPfCompetitionPhasesBySeason*>::iterator itCompetitionsBySeason;
for( itCompetitionsBySeason=competitionsBySeasonList->begin(); itCompetitionsBySeason!=competitionsBySeasonList->end(); itCompetitionsBySeason++ ){
CPfCompetitionPhasesBySeason *competitionBySeason = *itCompetitionsBySeason;
if( competitionBySeason->getDEndCompetitionPhase()>maxDate ){
maxDate = competitionBySeason->getDEndCompetitionPhase();
}
}
singlePlayerGame->m_optionManager->setGameNew(true);
singlePlayerGame->m_optionManager->setGameCurrentDate(maxDate);
singlePlayerGame->m_optionManager->setGameCurrentSeason(season->getXSeason());
// Create player's coach
// TODO: create coach in another way. Maybe player settings?
CPfCoaches *playerCoach = new CPfCoaches();
playerCoach->setSName(coachName);
playerCoach->setSShortName(coachName);
playerCoach->setSPhoto("p_unknown");
playerCoach->setXFkFormationSelected(1);
playerCoach->setXFkCountry(1);
singlePlayerGame->m_daoFactory->getIPfCoachesDAO()->insertReg(playerCoach);
singlePlayerGame->m_optionManager->setGamePlayerCoach(playerCoach->getXCoach());
delete playerCoach;
competitionBySeasonDAO->freeVector(competitionsBySeasonList);
delete season;
singlePlayerGame->loadGameEvents();
CDate date = singlePlayerGame->m_optionManager->getGameCurrentDate();
CGameEngine::getInstance()->getTimeManager()->setCurrentTime(date);
date.setHour(23);
date.setMin(59);
date.setSec(59);
CGameEngine::getInstance()->getEventManager()->addEvent(new CEndDayEvent(date));
return singlePlayerGame;
}