当前位置: 首页>>代码示例>>C++>>正文


C++ ITable::PlayerAction方法代码示例

本文整理汇总了C++中ITable::PlayerAction方法的典型用法代码示例。如果您正苦于以下问题:C++ ITable::PlayerAction方法的具体用法?C++ ITable::PlayerAction怎么用?C++ ITable::PlayerAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITable的用法示例。


在下文中一共展示了ITable::PlayerAction方法的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;
                    }
                }
//.........这里部分代码省略.........
开发者ID:Bia10,项目名称:clrn,代码行数:101,代码来源:Utils.cpp


注:本文中的ITable::PlayerAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。