本文整理汇总了C++中ITable::PlayersInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ ITable::PlayersInfo方法的具体用法?C++ ITable::PlayersInfo怎么用?C++ ITable::PlayersInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITable
的用法示例。
在下文中一共展示了ITable::PlayersInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseData
void ParseData(const std::string& data, ITable& table)
{
static const boost::regex line("\\[.*?\\]\\:(.*?)/\\*");
boost::sregex_iterator itLine(data.begin(), data.end(), line);
boost::sregex_iterator end;
pcmn::Player::List players;
unsigned count = 0;
for (; itLine != end; ++itLine, ++count)
{
boost::sregex_iterator itNext = itLine;
++itNext;
if (itNext != end)
++itNext;
if (itNext != end)
{
const std::string& nextLine = (*itNext)[0];
if (nextLine.find("SecondsLeft") != std::string::npos && nextLine.find("CLRN") != std::string::npos)
++itNext;
}
const std::string& fullLine = (*itLine)[0];
const std::string& lineText = (*itLine)[1];
// info
{
static const boost::regex info(".*'(.+)'.*stack.*'(\\d+)'");
boost::sregex_iterator it(lineText.begin(), lineText.end(), info);
while (it != end)
{
const std::string& name = (*it)[1];
const unsigned stack = boost::lexical_cast<unsigned>((*it)[2]);
players.push_back(Player(name, stack));
++it;
}
}
// actions
{
static const boost::regex action(".*'(.+)'.*action.*'(.+)',.*?(('(\\d+)')|(cards.*'(\\S+)'))");
boost::sregex_iterator it(lineText.begin(), lineText.end(), action);
while (it != end)
{
if (!players.empty())
{
table.PlayersInfo(players);
players.clear();
}
const std::string& name = (*it)[1];
const std::string& action = (*it)[2];
const std::string& cards = (*it)[7];
if (cards.empty())
{
const unsigned amount = boost::lexical_cast<unsigned>((*it)[5]);
const pcmn::Action::Value actionValue = Action::FromString(action);
if (actionValue == pcmn::Action::SmallBlind)
std::cout << "small blind" << std::endl;
table.PlayerAction(name, actionValue, amount);
}
else
if (cards.size() == 4)
{
Card::List cardsList;
Card tmp(Card::FromString(cards[0]), static_cast<Suit::Value>(cards[1]));
cardsList.push_back(tmp);
tmp.m_Value = Card::FromString(cards[2]);
tmp.m_Suit = static_cast<Suit::Value>(cards[3]);
cardsList.push_back(tmp);
table.PlayerCards(name, cardsList);
table.PlayerAction(name, Action::ShowCards, 0);
}
++it;
}
}
// flop cards
{
static const boost::regex cards("Cards\\sreceived(.*?)");
boost::sregex_iterator it(lineText.begin(), lineText.end(), cards);
if (it != end)
{
while (it != end)
{
Card::List cards;
ParseCards(lineText, cards);
table.FlopCards(cards);
++it;
}
}
//.........这里部分代码省略.........