示例#1
0
文件: CDeck.cpp 项目: ricoz/tong-its
bool CDeck::Show(int const pIdx, int pRgn)
{
    if(PlayerHand[pIdx]->GetNumSelectedCards() < 3)
        return false; //too few selected cards

    if(pRgn != -1) {

        pRgn -= SETSTART;
        if(pIdx != pRgn) return false; //should click on your own sets
    }

    CCardStack *cs = new CCardStack;
    cs->Push(PlayerHand[pIdx]->GetSelectedCards());

    if(VerifySet(cs)) {

        cs->Clear();
        cs->Push(PlayerHand[pIdx]->PopSelectedCards());
        cs->SetCardsFaceUp(true);
        cs->Sort();

        Sets[pIdx][this->GetEmptyStack(pIdx)] = cs;

        mGame.InitDrag(cs, PlayerHand[pIdx], -1 , -1);
        mGame.DoDrop(ValidSet[pIdx]);

        return true;
    }
    else {
        PlayerHand[pIdx]->InitCardCoords();
        return false;
    }
}
示例#2
0
文件: CDeck.cpp 项目: ricoz/tong-its
bool CDeck::Chow(int const pIdx)
{
    if(PlayerHand[pIdx]->GetNumSelectedCards() < 2)
        return false; //too few selected cards

    if(DumpPile->Empty())
        return false;

    if(!TransferPile->Empty())
        return false;

    CCard thrown = DumpPile->Pop(); //push again if unsuccessful

    CCardStack *cs = new CCardStack;
    cs->Push(thrown);
    cs->Push(PlayerHand[pIdx]->GetSelectedCards());

    if(VerifySet(cs)) {

        cs->Clear();
        cs->Push(thrown);
        cs->Push(PlayerHand[pIdx]->PopSelectedCards());
        cs->SetCardsFaceUp(true);
        cs->Sort();

        Sets[pIdx][this->GetEmptyStack(pIdx)] = cs;

        mGame.InitDrag(cs, PlayerHand[pIdx], -1 , -1);
        mGame.DoDrop(ValidSet[pIdx]);

        return true;
    }
    else {
        DumpPile->Push(thrown);
        DumpPile->InitCardCoords();
        PlayerHand[pIdx]->InitCardCoords();
        return false;
    }
}