Example #1
0
//************************************
// Method:    returnAllCardsToDeck - takes the card form each user and return it to the bottom of the deck (note that because the deck shuffles itself when all cards have been drawn the order is random)
// FullName:  Game::returnAllCardsToDeck
// Access:    protected 
// Returns:   void
// Qualifier:
//************************************
void Game::returnAllCardsToDeck()
{
	for (int j=0; j<Hand::NUM_OF_CARDS_IN_COMUNITY; j++)
	{
		m_gameDeck.insertCardToEnd(const_cast<Card *>(m_comunityCards[j])); //Explicit "de-constization"
		m_comunityCards[j]=NULL;
	}

	for (unsigned int i=0; i<m_numberOfplayers; i++)//each user returns his cards
	{
		for (int j=1; j<=Hand::NUM_OF_CARDS_IN_HAND;j++)
		{
			if (getPlayerAt(i)->getCard(j)!=NULL && !(getPlayerAt(i)->getCard(j)->isBlank()))
				returnCardForUser(i,j);
		}	
	}
}
Example #2
0
 virtual void updateModelInRow(int row)
 {
     gcn::DropDown *choicebox = static_cast<gcn::DropDown *>(
                                getElementAt(row, RELATION_CHOICE_COLUMN));
     player_relations.setRelation(getPlayerAt(row),
                                static_cast<PlayerRelation::Relation>(
                                choicebox->getSelected()));
 }
Example #3
0
//************************************
// Method:    drawCardForUser-draw a card for the userPlace player in the current round place it at slot cardNumber and show cards if it a human and !hidecard
// FullName:  Game::drawCardForUser
// Access:    private 
// Returns:   void
// Qualifier:
// Parameter: int userPlace -a number between 0 and number of players -1
// Parameter: int cardNumber- the number of card
// Parameter: bool hideCard- only valid for humen players- false(default) to show true to hide
//************************************
void Game::drawCardForUser(int userPlace, int cardNumber,bool hideCard/*=false*/)
{
	Player* currPlayer=getPlayerAt(userPlace);
	currPlayer->setCard(m_gameDeck.takeCard(),cardNumber);;
	if (!hideCard && currPlayer->isHumanPlayer())
	{
		UIs::UI::printUserDetails(userPlace+1);//print the card if its the player's
	}
}
Example #4
0
void CCenario::update()
{
	for(int i = 0; i < max(max(_jogadores->size(), _vendedores->size()) , max(_inimigos->size(), _npcs->size())); i=i+1)
	{
		if(i < _inimigos->size())	getMonsterAt(i)->update();
		if(i < _jogadores->size())  getPlayerAt(i)->update();
		if(i < _npcs->size())		getNpcAt(i)->update();
		if(i < _vendedores->size())	getSalesmanAt(i)->update();
	}
}
Example #5
0
//************************************
// Method:    closeRound - Used at end of round to show all cards, name the winner, and return them to the deck.
// FullName:  Game::closeRound
// Access:    virtual protected 
// Returns:   void
// Qualifier:
//************************************
void Game::closeRound()
{
	UIs::UI::showAllCards();
	UIs::UI::clearConsole();
	decideWinners();
	string announcement1="the winner is "+string(getPlayerAt(0)->getName());
	string announcement2="With "+Hand::getStringOfWinningRule(m_winningRule);
	UIs::UI::dispalyFlashingMessage(announcement1,announcement2);
	returnAllCardsToDeck();//allocation not lost
}
Example #6
0
//************************************
// Method:    drawComunityCards - draw cards for the community
// FullName:  Game::drawComunityCards
// Access:    private 
// Returns:   void
// Qualifier:
//************************************
void Game::drawComunityCards()
{
	for (int j=0; j<Hand::NUM_OF_CARDS_IN_COMUNITY; j++)
	{
		m_comunityCards[j]=m_gameDeck.takeCard();
		for (unsigned int i=0;i<m_numberOfplayers;i++)
		{
			getPlayerAt(i)->setComunityCard(m_comunityCards[j],j+1);
		}
		UIs::UI::updateComunityCards(m_comunityCards[j],j+1);
	}
}
Example #7
0
//************************************
// Method:    play - main function for game handles entire game play until user exits
// FullName:  Game::play
// Access:    public 
// Returns:   void
// Qualifier:
//************************************
void Game::play()
{
	char userInput='c';
	while (!m_endGame && userInput=='c')//user asks to continue playing and game isnt over
	{
		//set current players order to reflect on UI
		UIs::UI::setPlayers(getPlayerAt(0),getPlayerAt(1),getPlayerAt(2),getPlayerAt(3));
		newRound();//play a game round
		if (m_endGame)
		{
			UIs::UI::displayMessage("Game over!! enter e to exit or n for new game");
		}
		else
		{
			UIs::UI::displayMessage("enter e to exit,c to continue or n for new game");
		}

		userInput=UIs::UI::getUserGameInput();
		while((userInput=='c'&& m_endGame )||(userInput!='e' && userInput!='c' && userInput!='n'))//input isn't valid
		{
			UIs::UI::clearInputLine();
			if (m_endGame)
			{
				UIs::UI::displayErrorMessage("ERROR:the input you entered is invalid: use n or e only!");
			}
			else
			{
				UIs::UI::displayErrorMessage("ERROR:the input you entered is invalid: use c n or e only!");
			}
			userInput=UIs::UI::getUserGameInput();
		}
		UIs::UI::clearConsole();
		if (userInput=='n')//new game
		{
			UIs::UI::plotGoodbyeScreen(m_numberOfRounds,returnNameOfWinningPlayer());//summery
			destroyGame();  //Clear game settings
			initGame();		//initialize new game from user decisions
			play();			//Start anew
		}
		else if (userInput =='e')//exit
		{
			UIs::UI::plotGoodbyeScreen(m_numberOfRounds,returnNameOfWinningPlayer());
			m_endGame=true;//ask to end game
		}
		else // must be c
		{
			UIs::UI::setPlayers(getPlayerAt(0),getPlayerAt(1),getPlayerAt(2),getPlayerAt(3));//new order- winner starts
		}
	}//end main while
}
Example #8
0
//************************************
// Method:    getDecisions - get the players decisions
// FullName:  Game::getDecisions
// Access:    private 
// Returns:   void
// Qualifier:
//************************************
void Game::getDecisions()
{
	Player* currPlayer;
	for (unsigned int i=0; i<m_numberOfplayers; i++)
	{
		currPlayer=getPlayerAt(i);
		for (int j=1; j<=Hand::NUM_OF_CARDS_IN_HAND; j++)
		{
			currPlayer->makeDecision(j);
			UIs::UI::printPlayerDecision(i,j);//this way the user can see his predecessors decisions
			if (currPlayer->getDecision(j)==Player::THROW)
			{
				returnCardForUser(i,j);
				drawCardForUser(i,j,true);
			}
			Sleep(100);
		}
		if(currPlayer->isHumanPlayer())
		{
			UIs::UI::printUserDetails(i+1);//print the cards
		}
		Sleep(600);
	}
}
Example #9
0
//************************************
// Method:    returnCardForUser - takes a player cards and return them to the bottom of the deck
// FullName:  Game::returnCardForUser
// Access:    protected 
// Returns:   void
// Qualifier:
// Parameter: int userPlace  -a number between 0 and number of players -1
// Parameter: int cardNumber- a card number from 1 to 3
//************************************
void Game::returnCardForUser(int userPlace, int cardNumber)
{
	m_gameDeck.insertCardToEnd(const_cast<Card *>(getPlayerAt(userPlace)->getCard(cardNumber))); //Explicit "de-constization"
	getPlayerAt(userPlace)->setCard(NULL,cardNumber);
}