[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [pbmserv-dev] Blackout - Following suit



Here is my rewriting of the ForcedMove method for blackout to automatically follow suit.

const char *Blackout::ForcedMove(void)
{
	/* changed ReadWriteCardList to Hand to use CountSuit */
	Hand *hptr[MaxPlayers()];

	hptr[0] = &hand1;
	hptr[1] = &hand2;
	hptr[2] = &hand3;
	hptr[3] = &hand4;

	int i,maxh=0,bidding=0;
	for (i=0 ; i<players.Count() ; i++) {
		if (hptr[i]->Count() > maxh)
			maxh = hptr[i]->Count();
		if (bids[i] == -1)
			bidding=1;
	}

	/* Changed to follow suit automatically */
	if (!bidding) {
		if (maxh == 1) {
			return (*handptr)[0].CardAbbrev();
		} else {
			Hand *handptr=hptr[CurrentPlayer()];
			if (trick.Count() && (handptr->CountSuit(lead) == 1)) {
				SUITS lead;
				lead = trick[0].GetSuit();
				for (i=0 ; i<handptr->Count() ; i++)
					if ((*handptr)[i].GetSuit() == lead)
						return (*handptr)[i].CardAbbrev();
			}
		}
	}

	return NULL;
}

_____________________________________________________________________
Envie de discuter en "live" avec vos amis ? Télécharger MSN Messenger
http://www.ifrance.com/_reloc/m la 1ère messagerie instantanée de France