Example #1
0
bool CDeck::Sapaw(int const pIdx, int pRgn)
{
    if(PlayerHand[pIdx]->GetNumSelectedCards() < 1)
        return false; //too few selected cards

    pRgn -= SETSTART;

    CCardStack *cs = new CCardStack;

    for(int j = 0; j < 6; j++) {

        SDL_PumpEvents();

        if((Sets[pRgn][j] != NULL) && !Sets[pRgn][j]->Empty()) {

            cs->Clear();
            cs->Push(PlayerHand[pIdx]->GetSelectedCards());
            CCardStack set = *Sets[pRgn][j];
            cs->Push(set);

            if(VerifySet(cs)) {

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

                Sets[pRgn][j]->Push(*cs);
                Sets[pRgn][j]->Sort();

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

                ValidSet[pRgn]->Clear();
                ValidSet[pRgn]->Push(ExtractSet(pRgn));
                ValidSet[pRgn]->InitCardCoords();

                mGame.DrawStaticScene();

                if(pRgn != pIdx)
                    Nasapawan[pRgn] = true;//CALL

                return true;
            }
        }
    }

    delete cs;
    return false;
}
Example #2
0
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;
    }
}
Example #3
0
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;
    }
}
Example #4
0
bool CDeck::AutoSapaw(int const pIdx)
{
    //This disables strategy, the player may want to choose where to sapaw
    //in order to inhibit his opponents from 'calling'

    CCardStack *Stack = PlayerHand[pIdx]->GetCardStack();

    int Idx = 0;
    //checks all the cards, performs sapaw until not able to do so
    for(VI vi = Stack->begin(); vi != Stack->end(); ++vi) {

        PlayerHand[pIdx]->SelectCard(Idx);

        CCardStack *cs = new CCardStack;

        for(int i = 0; i < 3; i++) {

            for(int j = 0; j < 6; j++) {

                SDL_PumpEvents();
                if((Sets[i][j] != NULL) && !Sets[i][j]->Empty()) {

                    cs->Clear();
                    cs->Push(PlayerHand[pIdx]->GetSelectedCards());
                    CCardStack set = *Sets[i][j];
                    cs->Push(set);

                    if(VerifySet(cs)) {

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

                        Sets[i][j]->Push(*cs);
                        Sets[i][j]->Sort();

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

                        ValidSet[i]->Clear();
                        ValidSet[i]->Push(ExtractSet(i));
                        ValidSet[i]->InitCardCoords();

                        mGame.DrawStaticScene();

                        if(i != pIdx)
                            Nasapawan[i] = true;//CALL

                        return true;
                    }
                }
            }
        }

        PlayerHand[pIdx]->InitCardCoords(); //select a different card
        Idx++;
        delete cs;

    }//end of for loop

    PlayerHand[pIdx]->InitCardCoords();
    return false;
}