void PendingChecks::runChecks()
{
    DynMutex::Guard guard = m_mutex.lock();
    Checks::iterator it = m_checks.begin();
    bool removed = false;
    while (it != m_checks.end()) {
        bool cont;
        try {
            cont = (**it)();
        } catch (...) {
            Exception::handle(HANDLE_EXCEPTION_FATAL);
            // keep compiler happy
            cont = false;
        }

        if (!cont) {
            // Done with this check
            Checks::iterator next = it;
            ++next;
            m_checks.erase(it);
            it = next;
            removed = true;
        } else {
            ++it;
        }
    }
    // Tell blockOnCheck() calls that they may have completed.
    if (removed) {
        m_cond.signal();
    }
}
Exemplo n.º 2
0
void GamePlay::thirdhand2()
{
	Checks b;
	PlayerHandValue = 0;
	CpuHandValue = 0;
	result = "";
	int x = 24;
	int y = 3;
	showc = true;
	shows = true;
	PressEnterToContinue = "Press Enter To Continue...";

	Checks ck;
	Poker a;
	
	system("cls");
	a.tablecards(deck, 10);
	a.createhand(hand, 25, 40);
	a.createtable(tablehand, 5, 17);  // this will create the table, passing in the table hand, always pass in 5 and 7 for location
	Cards();
	a.createtable(cpuhand, x, y);//creating the hands  
	PlayerHandValue = ck.DetermineHand(PlayerValues, psuits);// determine the player hand storing value in PlayerHandValue
	CpuHandValue = ck.DetermineHand(cvalues, csuits);// determine the cpu hand storing value in CpuHandValue

	if (foldv)
	{
		PlayerHandValue = 0;
	}
	ck.determine(PlayerHandValue, CpuHandValue);
	if (showc)
	{
		chand = chand;
	}
	if (shows)
	{
		PressEnterToContinue = PressEnterToContinue;
	}
	if (!foldc)
	{
		fold = " ";
	}
	if (foldc == true)
	{
		//fold = "YOU LOSE!";
	}
	Text(); // method to display the text on screen
	cout << chand;
	cin.get();
	g = 0;
	cash = 0;
	if (cash == 0)
	{
		Clear();
		system("cls");
		NGameMenu();
	}
	NewHand();

}
Exemplo n.º 3
0
void GamePlay::getValues()
{

	PlayerHandValue = 0;
	PlayerHandValue = checks.DetermineHand(PlayerValues, psuits);
	inhand = checks.handText(PlayerHandValue);
	for (size_t i = 0; i < listOfComputerPlayers.size(); i++)
	{
		listOfComputerPlayers[i].CpuHandValue = 0;
		listOfComputerPlayers[i].CpuHandValue = checks.DetermineHand(listOfComputerPlayers[i].cvalues, listOfComputerPlayers[i].csuits);
	}
}
void PendingChecks::blockOnCheck(const boost::function<bool ()> &check, bool checkFirst)
{
    DynMutex::Guard guard = m_mutex.lock();
    // When we get here, the conditions for returning may already have
    // been met.  Check before sleeping. If we need to continue, then
    // holding the mutex ensures that the main thread will run the
    // check on the next iteration.
    if (!checkFirst || check()) {
        m_checks.insert(&check);
        if (!checkFirst) {
            // Must wake up the main thread from its g_main_context_iteration.
            g_main_context_wakeup(g_main_context_default());
        }
        do {
             m_cond.wait(m_mutex);
        } while (m_checks.find(&check) != m_checks.end());
    }
}
Exemplo n.º 5
0
void GamePlay::uiText()
{
	system("cls");
	
	if (listOfComputerPlayers.size() == 1)
	{
		drawcard.createhand(hand, 25, 40);
		drawcard.createhand(tablehand, 5, 20);
		drawcard.drawCardBack(listOfComputerPlayers[0].cpuhand, listOfComputerPlayers[0].cardX, listOfComputerPlayers[0].cardY, listOfComputerPlayers[0].cardbackColor);
	}
	if (listOfComputerPlayers.size() == 2)
	{
		drawcard.createhand(hand, 25, 40);
		drawcard.createhand(tablehand, 5, 20);
		drawcard.drawCardBack(listOfComputerPlayers[0].cpuhand, listOfComputerPlayers[0].cardX, listOfComputerPlayers[0].cardY, listOfComputerPlayers[0].cardbackColor);
		drawcard.drawCardBack(listOfComputerPlayers[1].cpuhand, listOfComputerPlayers[1].cardX, listOfComputerPlayers[1].cardY, listOfComputerPlayers[1].cardbackColor);
	}
	if (listOfComputerPlayers.size() == 3)
	{
		drawcard.createhand(hand, 1, 40);
		drawcard.createhand(tablehand, 5, 20);
		drawcard.drawCardBack(listOfComputerPlayers[0].cpuhand, listOfComputerPlayers[0].cardX, listOfComputerPlayers[0].cardY, listOfComputerPlayers[0].cardbackColor);
		drawcard.drawCardBack(listOfComputerPlayers[1].cpuhand, listOfComputerPlayers[1].cardX, listOfComputerPlayers[1].cardY, listOfComputerPlayers[1].cardbackColor);
		drawcard.drawCardBack(listOfComputerPlayers[2].cpuhand, listOfComputerPlayers[2].cardX, listOfComputerPlayers[2].cardY, listOfComputerPlayers[2].cardbackColor);
	}
	//drawcard.drawCardBack(listOfComputerPlayers[0].cpuhand, 24, 3);

	if (!showComputer)
	{
		for (size_t i = 0; i < listOfComputerPlayers.size(); i++)
		{
			listOfComputerPlayers[i].computerHandText = "?????";
		}
	}
	if (!shows)
	{
		PressEnterToContinue = " ";
	}
	if (!foldc)
	{
		fold = " ";
	}

	inhand = checks.handText(PlayerHandValue);

	aesthetics.mainText("1");

	//CHANGE ME
	aesthetics.changingText(cash, inhand, listOfComputerPlayers, fold, pot, result);
	
}
Exemplo n.º 6
0
 std::size_t size() const { return checks.size(); }
Exemplo n.º 7
0
 void finish() {
   for (Checks::iterator i = checks.begin(), e = checks.end(); i != e; ++i) i->finish();
   checks.clear();
 }
Exemplo n.º 8
0
 void start() {
   for (Checks::iterator i = checks.begin(), e = checks.end(); i != e; ++i) i->start();
 }
Exemplo n.º 9
0
 void add(ILeakCheck* p) { checks.push_back(p); }
Exemplo n.º 10
0
 bool enabled() const { return !checks.empty(); }
Exemplo n.º 11
0
void GamePlay::thirdhand()
{
	Checks b;
	PlayerHandValue = 0;
	CpuHandValue = 0;
	result = "";
	int x = 24;
	int y = 3;
	showc = true;
	shows = true;
	PressEnterToContinue = "Press Enter To Continue...";

	Checks ck;
	Poker a;
	Aesthetics cb;
	system("cls");
	a.createhand(hand, 25, 40);
	a.createtable(tablehand, 5, 17);  // this will create the table, passing in the table hand, always pass in 5 and 7 for location
	Cards();
	a.createtable(cpuhand, x, y);//creating the hands  
	PlayerHandValue = ck.DetermineHand(PlayerValues, psuits);// determine the player hand storing value in PlayerHandValue
	CpuHandValue = ck.DetermineHand(cvalues, csuits);// determine the cpu hand storing value in CpuHandValue

	if (foldv)
	{
		PlayerHandValue = 0;
	}
	ck.determine(PlayerHandValue, CpuHandValue);
	if (showc)
	{
		chand = chand;
	}
	if (shows)
	{
		PressEnterToContinue = PressEnterToContinue;
	}
	if (!foldc)
	{
		fold = " ";
	}
	if (foldc == true)
	{
		//fold = "YOU LOSE!";
	}
	Text(); // method to display the text on screen
	cin.get();
	cout << chand;
	g = 0;
	duringhand = true;
	if (!duringhand)
	{
		cb.text1("You Ran Out of Money!");
		cin.get();
		system("cls");
		Clear();
		NGameMenu();
	}
	if (cash == 0)
	{
		Clear();
		system("cls");
		NGameMenu();
	}
	if (cpucash == 0)
	{
		system("cls");
		Aesthetics a;
		a.textattr(13);
		cout << " " << endl;
		cout << " " << endl;
		cout << "               /////////////////////////////////////////////////" << endl;
		cout << "               // "; a.textattr(3); cout << "*         *  *           *        *       * "; a.textattr(13); cout << "//" << endl;
		cout << "               //    "; a.textattr(3); cout << " * "; a.textattr(6); cout << "    CPU RAN OUT OF MONEY!         "; a.textattr(3); cout << "*   "; a.textattr(13); cout << "//" << endl;
		cout << "               // "; a.textattr(3); cout << "*                                     *     "; a.textattr(13); cout << "//" << endl;
		cout << "               //   "; a.textattr(3); cout << "*          "; a.textattr(6); cout << "You Win!                     "; a.textattr(3); cout << "* "; a.textattr(13); cout << "//" << endl;
		cout << "               //  "; a.textattr(3); cout << "*   "; a.textattr(3); cout << "*                             *    *   "; a.textattr(13); cout << "//" << endl;
		a.textattr(13); cout << "               //"; a.textattr(3); cout << "*********************************************"; a.textattr(13); cout << "//" << endl;
		a.textattr(13); cout << "               /////////////////////////////////////////////////" << endl;
		cout << " " << endl;
		cout << " " << endl;
		cout << " " << endl;
		NGameMenu2();
	}
	NewHand();

}
Exemplo n.º 12
0
void GamePlay::finalCards()
{
	//CHANGE ME
	PlayerHandValue = 0;
	listOfComputerPlayers[0].CpuHandValue = 0;
	showComputer = true;
	shows = true;

	system("cls");
	if (tablehand.size() < 4)
	{

		tablehand = hands.dealCards(deck, tablehand, 2);
	}
	if (tablehand.size() < 5)
	{

		tablehand = hands.dealCards(deck, tablehand, 1);
	}
	Cards();
	getValues();
	
	if (playerFold == true)
	{
		PlayerHandValue = 0;
	}
	for (size_t i = 0; i < listOfComputerPlayers.size(); i++)
	{

			listOfComputerPlayers[i].computerHandText = checks.handText(listOfComputerPlayers[i].CpuHandValue);
		
	}

	determine();

	uiText();

	if (listOfComputerPlayers.size() == 1)
	{
		drawcard.createhand(hand, 25, 40);
		drawcard.createhand(tablehand, 5, 20);
		drawcard.createhand(listOfComputerPlayers[0].cpuhand, 24, 3);
	}
	if (listOfComputerPlayers.size() == 2)
	{
		drawcard.createhand(hand, 25, 40);
		drawcard.createhand(tablehand, 5, 20);
		drawcard.createhand(listOfComputerPlayers[0].cpuhand, 1, 3);
		drawcard.createhand(listOfComputerPlayers[1].cpuhand, 60, 3);
	}
	if (listOfComputerPlayers.size() == 3)
	{
		drawcard.createhand(hand, 1, 40);
		drawcard.createhand(tablehand, 5, 20);
		drawcard.createhand(listOfComputerPlayers[0].cpuhand, 1, 3);
		drawcard.createhand(listOfComputerPlayers[1].cpuhand, 60, 3);
		drawcard.createhand(listOfComputerPlayers[2].cpuhand, 60, 40);
	}


	cin.get();


	gameoverCheck();

	Clear();
	system("cls");
	Flop();
}
Exemplo n.º 13
0
void GamePlay::determine()
{

	vector<findWinner> fw;
	vector<findWinner> fw2;
	vector<findWinner> fw3;
	vector<string> fw4;

	for (size_t i = 0; i < listOfComputerPlayers.size(); i++)
	{
		listOfComputerPlayers[i].cpuHighCardValue = checks.highCardValues(listOfComputerPlayers[i].cpuhand);
	}
	playerHighCardValue = checks.highCardValues(playerhand);


	for (size_t i = 0; i < listOfComputerPlayers.size(); i++)
	{
		if (listOfComputerPlayers[i].didFold == false)
		{
			fw.push_back({ listOfComputerPlayers[i].CpuHandValue, listOfComputerPlayers[i].cpuHighCardValue, listOfComputerPlayers[i].cpucash, listOfComputerPlayers[i].name });
		}
	}
	fw.push_back({ PlayerHandValue, playerHighCardValue, cash, "You" });


	sort(fw.begin(), fw.end(), sortFunc);



	for (size_t i = 0; i < fw.size(); i++)
	{
		if (fw.back().handValue == fw[i].handValue)
		{
			fw2.push_back(fw[i]);
		}
	}
	if (fw2.size() > 1)
	{
		sort(fw2.begin(), fw2.end(), sortFunc1);
		for (size_t i = 0; i < fw2.size(); i++)
		{
			if (fw2.back().highCard == fw2[i].highCard)
			{

				fw3.push_back(fw2[i]);
			}
		}
	}

	if (fw3.size() > 1)
	{
		for (size_t i = 1; i < fw3.size(); i++)
		{
			if (fw3[0].name != fw3[i].name)
			{
				fw4.push_back(fw3[i].name);

			}
			fw4.push_back(fw3[0].name);
		}
	}

	if (fw3.size() <= 1)
	{
		if (fw2.size() < 1)
		{
			fw4.push_back(fw.back().name);
		}
		if (fw2.size() >= 1)
		{
			fw4.push_back(fw2.back().name);
		}

	}

	std::sort(fw4.begin(), fw4.end());
	auto it = std::unique(fw4.begin(), fw4.end());
	fw4.erase(it, fw4.end());

	if (fw4.size() > 1)
	{


		int pot2 = pot / fw4.size();

		if (fw4.size() == 2)
		{
			result = "Split Pot " + fw4[0] + " " + fw4[1] + " split $" + to_string(pot2) + " each!";
		}
		if (fw4.size() == 3)
		{
			result = "Split Pot " + fw4[0] + " " + fw4[1] + " " + fw4[2] + " split $" + to_string(pot2) + " each!";

		}
		if (fw4.size() == 4)
		{
			result = "Split Pot " + fw4[0] + " " + fw4[1] + " " + fw4[2] + " " + fw4[3] + " split $" + to_string(pot2) + " each!";

		}

		for (string splitwinners : fw4)
		{

			if (splitwinners == "You")
			{
				cash = cash + pot2;
			}
			if (splitwinners == "Jim")
			{
				listOfComputerPlayers[0].cpucash = listOfComputerPlayers[0].cpucash + pot2;
			}
			if (splitwinners == "Tom")
			{
				listOfComputerPlayers[1].cpucash = listOfComputerPlayers[1].cpucash + pot2;
			}
			if (splitwinners == "John")
			{
				listOfComputerPlayers[2].cpucash = listOfComputerPlayers[2].cpucash + pot2;
			}
		}

	}
	else
	{

		if (fw4.back() == "You")
		{
			result = fw4.back() + " Win $" + to_string(pot)+"!!";
			cash = cash + pot;
		}
		if (fw4.back() == "Jim")
		{
			result = fw4.back() + " Wins $" + to_string(pot) + "!!";
			listOfComputerPlayers[0].cpucash = listOfComputerPlayers[0].cpucash + pot;
		}
		if (fw4.back() == "Tom")
		{
			result = fw4.back() + " Wins $" + to_string(pot) + "!!";
			listOfComputerPlayers[1].cpucash = listOfComputerPlayers[1].cpucash + pot;
		}
		if (fw4.back() == "John")
		{
			result = fw4.back() + " Wins $" + to_string(pot) + "!!";
			listOfComputerPlayers[2].cpucash = listOfComputerPlayers[2].cpucash + pot;
		}


	}






}