コード例 #1
0
/**
 * Reference to the declaration
 */
void BlackJackCardTable::clean() {

    //Clean up crCards for a new game
    deleteCards(crCards);

    //Clean up crDCrds for a new game
    deleteCards(crDCrds);

}
コード例 #2
0
ファイル: play.c プロジェクト: suix2/InUW
int play(){
	int pass=0;
	Boolean firstRound=FALSE;
	// true if first round
	if(ll==myNum)
		firstRound=TRUE;
	// use for "for loop"
	int i;
	// number of cards played
	int number = 0;
	// pattern code
	int pattern=0; //sync
	int temp; //for sync
	// current card played, no need to init
	char ccp[20];
	// key value of card played
	int key=CUTOFF; //sync
	char card[3];
	Boolean check;
	//checkPattern
	printf("Current Player: %d\n", PCS);
	while(!haveWinner()){
		if(isCurrentPlayer()){
			check=TRUE;
			do{
				if(!check)
					printf("Your Inputs Are Illegal, Please Input Again\n");
				check=FALSE;
				//input to ccp, check num here
				display();
				printf("hey player, tell me the number of cards you want to play this round."
						"You can input 0 if you want to give up\n");
				scanf(" %d", &number);
				for(i=0;i<number;i++) {
					if(!i)
						printf("please tell me the card you want to play this round. One by One please. \n");
					else
						printf("please tell me the next card you want to play. \n");
					scanf("%s", card);
					switch(card[0]){
						case 'a':
						case 'A':
							ccp[i]=11;
							break;
						case '2':
							ccp[i]=12;
							break;
						case '3':
							ccp[i]=0;
							break;
						case '4':
							ccp[i]=1;
							break;
						case '5':
							ccp[i]=2;
							break;
						case '6':
							ccp[i]=3;
							break;
						case '7':
							ccp[i]=4;
							break;
						case '8':
							ccp[i]=5;
							break;
						case '9':
							ccp[i]=6;
							break;
						case '1':
							ccp[i]=7;
							break;
						case 'j':
						case 'J':
							ccp[i]=8;
							break;
						case 'q':
						case 'Q':
							ccp[i]=9;
							break;
						case 'k':
						case 'K':
							ccp[i]=10;
							break;
						case 'b':
						case 'B':
							ccp[i]=13;
							break;
						case 'r':
						case 'R':
							ccp[i]=14;
							break;
					}
				}
				if(number && checkCards(number, ccp))
					check=checkPatternAndValue(&pattern, ccp, number, &key);
				printf("check: %d\nkey: %d\n", pattern, key);
			}while((number && !check) || (!number && firstRound));
			if(!number){
				sendchar(CUTOFF | 0x40);
				usleep(10000);
			}
			else{
				if(firstRound)
					firstRound=!firstRound;
				sendchar(key | 0x40);
				usleep(1000);
				sendchar((pattern & 0x3f) | 0x40);
				usleep(1000);
				sendchar((pattern >> 6) | 0x40);
				usleep(1000);
				deleteCards(number, ccp);
				temp=sramread(CHNP+myNum-1);
				sramwrite(CHNP+myNum-1, temp-pattern/10);
				usleep(1000);
				sendchar(sramread(CHNP) | 0x40);
				usleep(1000);
				sendchar(sramread(CHNP+1) | 0x40);
				usleep(1000);
				sendchar(sramread(CHNP+2) | 0x40);
				usleep(1000);
			}
		}
		else{
			recvchar(&temp);
			usleep(80);
			if(temp!=CUTOFF){
				key=temp;
				recvchar(&pattern); //last 6 bits
				usleep(80);
				recvchar(&temp); //11-6 bits of pattern
				usleep(80);
				pattern+=temp*64;
				recvchar(&temp);
				usleep(80);
				sramwrite(CHNP, temp);
				recvchar(&temp);
				usleep(80);
				sramwrite(CHNP+1, temp);
				recvchar(&temp);
				usleep(80);
				sramwrite(CHNP+2, temp);
			}
			else{
				pass++;
				if(pass==2){
					pass=0;
					pattern=0;
					key=0;
				}
			}
		}
		if(pattern==42)
			multiplier*=2;
		temp=sramread(CHNP);
		printf("Pattern Is: %d\nKey Is: %d\nPlayer1 Num Remainds: %d\n", pattern, (key+3)%14+(key==11)+(key==12)+12*(key==13)+12*(key==14), temp);
		temp=sramread(CHNP+1);
		printf("Player2 Num Remainds: %d\n", temp);
		temp=sramread(CHNP+2);
		printf("Player3 Num Remainds: %d\n", temp);
		nextPlayer();
	}