Example #1
0
void cardRender( Card theCard, struct RastPort *Rast, long xPos, long yPos )
{
    SetDrMd( Rast, JAM2 );
    if( theCard )
    {
        if( cardFaceUp( theCard ))
        {
            SetAPen( Rast, 2 );
            RectFill( Rast, xPos, yPos, xPos+CARD_WIDTH-1,
                     yPos+CARD_HEIGHT-1 );
            SetBPen( Rast, 2 );
            switch( cardSuit( theCard ))
            {
            case HEARTS:
            case DIAMONDS:
                SetAPen( Rast, 6 );
                break;
            default:
                SetAPen( Rast, 1 );
                break;
            }
            SuitImages[cardSuit( theCard )].PlaneOnOff = 0x2;
            DrawImage( Rast, &SuitImages[cardSuit( theCard )],
                      xPos + Rast->TxWidth + 3, yPos + 3 );
            DrawImage( Rast, &SuitImages[cardSuit( theCard )],
                      xPos + CARD_WIDTH - Rast->TxWidth - 10,
                      yPos + CARD_HEIGHT - Rast->TxHeight - 2 );
            gfxMove( Rast, xPos + 2, yPos + Rast->TxBaseline + 3 );
            Text( Rast, RankToStr[cardRank( theCard )], 1 );
            gfxMove( Rast, xPos + CARD_WIDTH - Rast->TxWidth - 3,
                 yPos + CARD_HEIGHT - Rast->TxHeight + Rast->TxBaseline - 2 );
            Text( Rast, RankToStr[cardRank( theCard )], 1 );
        }
        else
        {
            SetAPen( Rast, 7 );
            RectFill( Rast, xPos, yPos, xPos+CARD_WIDTH-1,
                     yPos+CARD_HEIGHT-1 );
        }
    }
    else
    {
        SetAPen( Rast, 0 );
        RectFill( Rast, xPos, yPos, xPos+CARD_WIDTH-1, yPos+CARD_HEIGHT-1 );
    }
    SetAPen( Rast, 1 );
    gfxMove( Rast, xPos, yPos );
    Draw( Rast, xPos+CARD_WIDTH-1, yPos );
    Draw( Rast, xPos+CARD_WIDTH-1, yPos+CARD_HEIGHT-1 );
    Draw( Rast, xPos, yPos+CARD_HEIGHT-1 );
    Draw( Rast, xPos, yPos );
    SetAPen( Rast, 5 );
    WritePixel( Rast, xPos, yPos );
    WritePixel( Rast, xPos+CARD_WIDTH-1, yPos );
    WritePixel( Rast, xPos, yPos+CARD_HEIGHT-1 );
    WritePixel( Rast, xPos+CARD_WIDTH-1, yPos+CARD_HEIGHT-1 );
}
Example #2
0
void opponentPrintStacks( Stack *theStacks )
{
    Card loCard, hiCard;
    int i, *stackNoPtr;

    for( i = *(stackNoPtr = tempStacks); i < NUM_STACKS; i = *(++stackNoPtr))
    {
        if( theStacks[i].st_NumCards )
        {
            loCard = theStacks[i].st_Cards[0];
            hiCard = theStacks[i].st_Cards[theStacks[i].st_NumCards-1];
            FPrintf( Output(), "[%s%s,%s%s]", RankToStr[cardRank(loCard)],
                    SuitToStr[cardSuit(loCard)], RankToStr[cardRank(hiCard)],
                    SuitToStr[cardSuit(hiCard)] );
        }
        else
            FPrintf( Output(), "[EMPTY]" );
    }
}
Example #3
0
deck::deck(void)
{
      int n = 0;

      for (int s = int(Diamond); s <= int(Spade); ++s)
      {
            for (int c = int(Ace); c <= int(King); ++c)
            {
                  deck::card_[n].set_rank(cardRank(c));
                  deck::card_[n].set_suit(cardSuit(s));
                  ++n;
            }
      }
      top = 0;
}
Example #4
0
void deck::shuffle(void)
{
      int used[Deck_Size], posn = 0;

      srand((unsigned)time(NULL) | 1);
      memset(used, 0, Deck_Size * sizeof(int));

      for (int s = int(Diamond); s <= int(Spade); ++s)
      {
            for (int c = int(Ace); c <= int(King); ++c)
            {
                  posn = (posn + rand()) % Deck_Size;
                  while (used[posn])
                        posn = ++posn % Deck_Size;
                  deck::card_[posn].set_rank(cardRank(c));
                  deck::card_[posn].set_suit(cardSuit(s));
                  used[posn] = -1;
            }
      }
      top = 0;
}