// // Pour starter un new round // void Game::resetGameType(int pGameType) { // Server ony gameType = pGameType; spawnType = gameVar.sv_spawnType; subGameType = gameVar.sv_subGameType; blueScore = 0; redScore = 0; blueWin = 0; redWin = 0; gameTimeLeft = gameVar.sv_gameTimeLimit; roundTimeLeft = gameVar.sv_roundTimeLimit; resetRound(); // On dit aux autres d'en faire autant if (isServerGame) { net_svcl_change_game_type changeGameType; changeGameType.newGameType = pGameType; bb_serverSend((char*)&changeGameType, sizeof(net_svcl_change_game_type), NET_SVCL_CHANGE_GAME_TYPE, 0); } // On remet les score des players à 0 for (int i=0;i<MAX_PLAYER;++i) { if (players[i]) { players[i]->reinit(); } } }
void Match::sim(MatchScreen* screen) { this->screen = screen; resetRound(); int timer; for(timer = 0; timer < 180 && roundOver == false; timer+=3) { screen->tick(timer); cout << teamOne->getPlayer(0)->getRole()<< endl; screen->resetKillFeed(); cout<< "TIME: " << timer << endl; setMoveOrder(); for(int i = 0; i < playersToMove.size() && roundOver == false; i++) { Player* p = playersToMove[i]; checkBall(p); setPlayerStatus(p); int act = p->getAction(); //cout << p->getName(); if(act == p->MOVE_UP) { moveUp(p); } else if(act == p->MOVE_DOWN) { moveBack(p); } else if(act == p->MOVE_LEFT) { moveLeft(p); } else if(act == p->MOVE_RIGHT) { moveRight(p); } else if(act == p->PASS) { pass(p); } else if(act == p->MOVE_TO_BALL) { moveTowardBall(p); } else if(act == p->ATTACK) { attack(p); } else if(act == p->MOVE_TO_GOAL) { moveTowardGoal(p); } else if(act == p->MOVE_TO_OWN_GOAL) { moveToOwnGoal(p); } } cout << "BALL TEAM: " << ball->getTeam() << " PLAYER: " << ball->getPlayer() << endl; screen->updateStatScreen(teamOne, teamTwo); screen->displayPlayers(teamOne, teamTwo, ball); QTime dieTime= QTime::currentTime().addSecs(1); while( QTime::currentTime() < dieTime ) QCoreApplication::processEvents(QEventLoop::AllEvents, 100); } cout << "GAME OVER TIME: " << timer << endl; if(winningTeam == 1 || winningTeam == 2) { cout << "WINNER: Team " << winningTeam << endl; } else { cout << "DRAW" << endl; } cout << teamOne->getScore() << "-" << teamTwo->getScore() << endl; }