void analyze_hand(void){//这里开始看不懂
int rank,suit,card,pass,run;straight=1;flush=1;four=0;three=0;pairs=0; /*sortcardsbyrank*/
for(pass=1;pass<NUM_CARDS;pass++)//1-4
for(card=0;card<NUM_CARDS-pass;card++){//0-3,0-2,0-1,0
rank=hand[card][RANK];suit=hand[card][SUIT];
if(hand[card+1][RANK]<rank){
hand[card][RANK]=hand[card+1][RANK];hand[card][SUIT]=hand[card+1][SUIT];
hand[card+1][RANK]=rank;hand[card+1][SUIT]=suit;
}
}
/*checkforflush*/
suit=hand[0][SUIT];
for(card=1;card<NUM_CARDS;card++)
if(hand[card][SUIT]!=suit)flush=0;
/*checkforstraight*/
for(card=0;card<NUM_CARDS-1;card++)
if(hand[card][RANK]+1!=hand[card+1][RANK])
straight=0;
/*checkfor4-of-a-kind,3-of-a-kind,and pairs by looking for "runs" of card swith identical ranks*/
card=0;
while(card<NUM_CARDS){
rank=hand[card][RANK];run=0;
do{run++;card++; }
while(card<NUM_CARDS&&hand[card][RANK]==rank);
switch(run){case 2:pairs++;break;case 3:three=1;break;case 4:four=1;break;}
}