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


C++ Card::LoVal方法代码示例

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


在下文中一共展示了Card::LoVal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CanDrop

//
//    Can only drop a card onto a suit-stack if the
//  card is 1 higher, and is the same suit
//
bool CanDrop(CardRegion &stackobj, Card card)
{
    TRACE("ENTER CanDrop()\n");
    int topval;

    const CardStack &cardstack = stackobj.GetCardStack();

    if(cardstack.NumCards() > 0)
    {
        if(card.Suit() != cardstack[0].Suit())
        {
            TRACE("EXIT CanDrop()\n");
            return false;
        }

        topval = cardstack[0].LoVal();
    }
    else
    {
        topval = 0;
    }

    //make sure 1 higher
    if(card.LoVal() != (topval + 1))
    {
        TRACE("EXIT CanDrop()\n");
        return false;
    }

    TRACE("EXIT CanDrop()\n");
    return true;
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:36,代码来源:solgame.cpp

示例2: StackDropProc

/* Cards dropped to a stack */
bool CARDLIBPROC StackDropProc(CardRegion &stackobj, CardStack &dragcards)
{
    Card dragcard = dragcards[dragcards.NumCards() - 1];
    int faceup, facedown;

    /* Only drop our cards on other stacks */
    if (stackobj.Id() == from->Id())
    {
        return false;
    }
    
    /* If stack is empty, everything can be dropped */
    if (stackobj.NumCards() != 0)
    {
        const CardStack &mystack = stackobj.GetCardStack();

        /* Can only drop if card is 1 less */
        if (mystack[0].LoVal() != dragcard.LoVal() + 1)
        {
            return false;
        }

        /* Check if stack complete */
        stackobj.GetFaceDirection(&facedown);
        faceup = stackobj.NumCards() - facedown;

        if (faceup + dragcards.NumCards() >= NUM_ONECOLOR_CARDS)
        {            
            int i, max = NUM_ONECOLOR_CARDS - dragcards.NumCards() - 1;

            /* Dragged cards have been checked to be in order, check stack cards */
            if (mystack[0].Suit() == dragcard.Suit() &&
                stackLookingGood(mystack, max)) 
            {
                CardStack s = stackobj.GetCardStack();
                CardStack f;

                /* Remove from card stack */
                for (i = 0; i < max + 1; i++)
                {
                    s.RemoveCard(0);
                }
                /* Remove dragged cards */
                dragcards = f;
                stackobj.SetCardStack(s);
                cardsFinished += NUM_ONECOLOR_CARDS;
                /* Flip top card of the dest stack */
                TurnStackCard(stackobj);
            }
        }
    }
    /* Flip the top card of the source stack */
    TurnStackCard(*from);
    fGameStarted = true;
    return true;
}
开发者ID:hoangduit,项目名称:reactos,代码行数:57,代码来源:spigame.cpp

示例3: RowStackDropProc

//
//    Row a row-stack, we can only drop cards
//    that are lower / different colour
//
bool CARDLIBPROC RowStackDropProc(CardRegion &stackobj, CardStack &dragcards)
{
    TRACE("ENTER RowStackDropProc()\n");
    Card dragcard = dragcards[dragcards.NumCards() - 1];

    //if we are empty, can only drop a stack with a King at bottom
    if(stackobj.NumCards() == 0)
    {
        if(dragcard.LoVal() != 13)
        {
            TRACE("EXIT RowStackDropProc(false)\n");
            return false;
        }
    }
    else
    {
        const CardStack &mystack = stackobj.GetCardStack();

        //can only drop if card is 1 less
        if(mystack[0].LoVal() != dragcard.LoVal() + 1)
        {
            TRACE("EXIT RowStackDropProc(false)\n");
            return false;
        }

        //can only drop if card is different colour
        if( (mystack[0].IsBlack() && !dragcard.IsRed()) ||
           (!mystack[0].IsBlack() &&  dragcard.IsRed()) )
        {
            TRACE("EXIT RowStackDropProc(false)\n");
            return false;
        }
    }

    fGameStarted = true;

    TRACE("EXIT RowStackDropProc(true)\n");
    return true;
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:43,代码来源:solgame.cpp


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