hi,
I have a singleton Evaluation class that I'm calling repeatedly in one
sequence. would someone plz have a look at the code below and tell me
if one instance of the singleton can ever "clash" with another?
I'm asking because I'm getting unexpected results. I've looked for the
problem the past several days and can't attribute the anomalies to
logic errors.
the Evaluate function uses private vectors and other internal class
members to return an int value corresponding to poker hand strength.
void Game::RunShowdo wn()
{
deque<Player> showDownPlayers ;
for(posPlayer = players.begin() ; posPlayer != players.end();
++posPlayer)
{
if((*posPlayer) .GetActive()) showDownPlayers .push_back(*pos Player);
}
ShowChipsStatus ();
ShowRiver();
for(posPlayer = showDownPlayers .begin(); posPlayer !=
showDownPlayers .end(); ++posPlayer)
{
cout << "\n " << (*posPlayer).Ge tLastName() << "'s hand:\n\n\n";
(*posPlayer).Ge tHand().Peek();
}
Player winner = showDownPlayers .front();
for(posPlayer = showDownPlayers .begin() + 1; posPlayer !=
showDownPlayers .end(); ++posPlayer)
{
if(Evaluation:: Instance().Eval uate(ReturnComm unityCards(),
(*posPlayer).Ge tHand()) >
Evaluation::Ins tance().Evaluat e(ReturnCommuni tyCards(),
winner.GetHand( ))) winner = (*posPlayer);
else if(Evaluation:: Instance().Eval uate(ReturnComm unityCards(),
(*posPlayer).Ge tHand()) ==
Evaluation::Ins tance().Evaluat e(ReturnCommuni tyCards(),
winner.GetHand( )))
{
if((*posPlayer) .GetHand().GetT opCard().GetVal ue() >
winner.GetHand( ).GetTopCard(). GetValue())
winner = (*posPlayer);
else if((*posPlayer) .GetHand().GetT opCard().GetVal ue() ==
winner.GetHand( ).GetTopCard(). GetValue())
{
if((*posPlayer) .GetHand().GetL owPairValue() >
winner.GetHand( ).GetLowPairVal ue())
winner = (*posPlayer);
else if((*posPlayer) .GetHand().GetL owPairValue() ==
winner.GetHand( ).GetLowPairVal ue())
{
if((*posPlayer) .GetHand().GetK icker().GetValu e() >
winner.GetHand( ).GetKicker().G etValue())
winner = (*posPlayer);
}
}
}
PayWinner(winne r);
}