int main () { srand (time (NULL)); int numGames, numPlayers; Card deck[NUM_CARDS]; Card hand[MAX_PLAYER][HAND_SIZE]; getGameInfo (&numGames); initFile (numGames); for (int i = 0; i < numGames; i++) { getNumPlayers (&numPlayers); int handScores[numPlayers][1 + HAND_SIZE]; memset(handScores, 0, numPlayers * (1 + HAND_SIZE) * sizeof(int)); int bestHandIndices[numPlayers]; memset (bestHandIndices, 0, numPlayers*sizeof(int)); int *numTied = (int *)malloc(sizeof(int)); *numTied = 0; printfName (i + 1, numPlayers); initDeck (deck); shuffleDeck (deck); dealHands (deck, hand, numPlayers); evaluateWinner (hand, numPlayers, handScores, bestHandIndices, numTied); for (int j = 0; j < numPlayers; j++) { printResults (&hand[j][0], HAND_SIZE, j, handScores); } printWinner (i + 1, hand, numPlayers, handScores, bestHandIndices, *numTied); } }
Players() { // build players int autoset; int min_players = min_num_player; int max_players = max_num_player; cout << "Please set the number of players (" << min_players << " - " << max_players << " players):"; // get the total number of players num_players = getNumPlayers(min_players,max_players); cout << "How many computer players do you want? ( 0 - " << num_players - 1 << " computer players):"; // get the number of computer players int num_aiplayers = getNumPlayers(0,num_players - 1); int num_humanplayers = num_players - num_aiplayers; while (true) { // get the user's choice for "automatic mode" or "manual mode" cout << "Automatically set start money for all players?" << endl << "0: No." << endl << "1: Yes." << endl; autoset = getInteger(); if (autoset == 0 || autoset == 1) break; else cout << "Please select from 0 and 1." << endl; } for (int i = 0; i < num_humanplayers; i++) { // build human players if (autoset == 0) { players.push_back(new Player()); } else { players.push_back(new Player(true)); } } for (int i = 0; i < num_aiplayers; i++) { // build computer players if (autoset == 0) { players.push_back(new Aiplayer()); } else { players.push_back(new Aiplayer(true)); } } }
int CTournament::getNumPlayersPlaying() const { int nplayers = 0; if (numPlayers_ == 0) { // Return number of players in queue nplayers = getNumPlayers(); } else { // Count actual number of players playing CBaseTournamentQueue* tq = getTournamentQueue(); if (tq) nplayers = tq->countPlayers(); } return nplayers; }
void MainMenuScene::updateText() { m_numPlayerText->setPlainText("Number of players: " + QString::number(getNumPlayers())); }
void GameParameters::setAppearanceForPlayer(int playerNum, const Appearance &app) { assert(playerNum < getNumPlayers()); assert(playerNum < (int)(m_playerAppearances.size())); m_playerAppearances[playerNum] = app; }