Example #1
0
void Initialize() // must be called only once
{
	//do some initialization and create the regions in here

	SDL_WM_SetCaption("Scorpion", NULL); // Set the window title
	font1 = initFont("font/data/font1");
	font2 = initFont("font/data/font2");

	InitDeck(screen);
	Scorpion.Initialize(screen);

	//index 0: The Stock
 	Scorpion.CreateRegion(CRD_STOCK,
						CRD_VISIBLE|CRD_3D,
						0,
						0,
						CRD_OSYMBOL,
						(SCREEN_WIDTH / 2) - (CARDWIDTH / 2), 400,
						2, 2);

	//index 1-7: The tableau
	for(int i=1; i <= 7; i++){
		Scorpion.CreateRegion(CRD_TABLEAU,
							CRD_VISIBLE|CRD_FACEUP|CRD_DODRAG|CRD_DODROP,
							CRD_DOLOWER|CRD_DOKING,
							CRD_DRAGCARDS,
							CRD_HSYMBOL,
							(CARDWIDTH * (i - 1)) + (i * 35), 10,
							0, 25);
	}
}
Example #2
0
int main () {
int c;

	srand (0);
	InitDeck (&Deck);
	Shuffle (&Deck);		/* Shuffle Deck. */

#if 1
	printf ("STRAIGHT_FLUSH_SCORE\t%08x\n",STRAIGHT_FLUSH_SCORE);
	printf ("FOUR_KIND_SCORE\t\t%08x\n",FOUR_KIND_SCORE);
	printf ("FULL_HOUSE_SCORE\t%08x\n",FULL_HOUSE_SCORE);
	printf ("FLUSH_SCORE\t\t%08x\n",FLUSH_SCORE);
	printf ("STRAIGHT_SCORE\t\t%08x\n",STRAIGHT_SCORE);
	printf ("THREE_KIND_SCORE\t%08x\n",THREE_KIND_SCORE);
	printf ("TWO_PAIR_SCORE\t\t%08x\n",TWO_PAIR_SCORE);
	printf ("TWO_KIND_SCORE\t\t%08x\n",TWO_KIND_SCORE);

	printf ("\n");

	for (c=0; c < 8; c++) {
		Deal (&Hand, &Deck, 5);
		DisplayHand5 (&Hand);
		Deal (&Deck, &Hand, 5);
		Shuffle (&Deck);
	}

	for (c=0; c < 8; c++) {
		Deal (&Hand, &Deck, 7);
		DisplayHand7 (&Hand);
		Deal (&Deck, &Hand, 7);
		Shuffle (&Deck);
	}

	printf("\nRigged hands\n\n");

	Hand.len = 5;
	Hand.entry[0] = 12;
	Hand.entry[1] = 12+13;
	Hand.entry[2] = 12+26;
	Hand.entry[3] = 12+39;
	Hand.entry[4] = 11;
	DisplayHand5 (&Hand);

	Hand.entry[0] = 12;
	Hand.entry[1] = 12+13;
	Hand.entry[2] = 12+26;
	Hand.entry[3] = 11+39;
	Hand.entry[4] = 11;
	DisplayHand5 (&Hand);

	Hand.entry[0] = 12;
	Hand.entry[1] =  0+13;
	Hand.entry[2] =  1+26;
	Hand.entry[3] =  2+39;
	Hand.entry[4] =  3;
	DisplayHand5 (&Hand);

	printf ("\n");
#endif

#ifndef DETERMINISTIC
	srand ((unsigned int) time ((void *) 0));
#endif
	Shuffle (&Deck);		/* Shuffle Deck. */
	Hand.len = 0;

	c = 0;

	printf ("7 Card Draw test\n\n");

	for (;;) {
		Deal (&Hand, &Deck, 7);
		if (SevenCardDrawScore (&Hand.entry[0]) != SevenCardDrawScoreSlow (&Hand.entry[0])) break;
		Deal (&Deck, &Hand, 7);	/* Add hand back into Deck. */
		Shuffle (&Deck);		/* Reshuffle Deck.          */
		c++;
		if ((c & 0xFFFFF) == 0) {
#ifndef DETERMINISTIC
			srand ((unsigned int) time ((void *) 0));
#endif
			printf ("%d \t(no errors)\n", c);
		}
	}

	/* There must be an error ! */

	DisplayHand7 (&Hand);
	return 0;
}