Пример #1
0
static void actionphase() {
	int num,i,j;
	int list[MAXCARD];
	char s[MAXSMALLS];
	while(cur->action && (num=countcardsmask(TYPE_ACTION))) {
		printf("type 1 to %d to play an action card or 0 to skip.\n",num);
		for(i=j=0;i<cur->handn;i++)
			if(card[player[currentplayer].hand[i]].type&TYPE_ACTION) {
				list[j]=i;
				printf("  %d. %s\n",++j,card[player[currentplayer].hand[i]].fullname);
			}
		while(1) {
			scanf(scans,s);
			if(isinteger(s)) {
				j=strtol(s,0,10);
				if(!j) return;
				else {
					playcard(cur->hand[list[j-1]]);
					cur->action--;
					movecard(list[j-1],cur->hand,&cur->handn,cur->playarea,&cur->playarean);
					break;
				}
			}
		}
	}
}
Пример #2
0
/*
 * asks each player for card to play
 * or check war results if in war
 * or removes player if no cards left
*/
static void askplaycard(void)
{
	int trn;
	int wspa[5];
	int nwp = (currentwarplayercount + 1);
	if (wplayercardstotal[currentplayer] == 0) {
		removewar(wplayernick[currentplayer]);
	}
	if (wplayercardstotal[currentplayer] == 52) {
		currentplayer++;
		removewar(wplayernick[currentplayer]);
	}
	if (currentwarplayercount < 2) {
		return;
	}
	if (warinprogress == 1) {
		if (currentplayer < currentwarplayercount) {
			for (wpln = currentplayer; wpln < currentwarplayercount; wpln++) {
				if (wplayeratwar[wpln] == 1) {
					nwp= wpln;
					wpln= currentwarplayercount;
				}
			}
			currentplayer = nwp;
		}
		if (nwp > currentwarplayercount) {
			checkwarwinner();
		} else {
			if (!ircstrcasecmp (wplayernick[currentplayer], ws_bot->name)) {
				trn= wplayercardstotal[currentplayer];
				wspa[2]= ((rand() % trn) + 1);
				trn--;
				wspa[3]= ((rand() % trn) + 1);
				if (wspa[3] == wspa[2]) {
					wspa[3]++;
				}
				trn--;
				wspa[4]= ((rand() % trn) + 1);
				if ((wspa[4] == wspa[2]) || (wspa[4] == wspa[3])) {
					wspa[4]++;
				}
				if ((wspa[4] == wspa[2]) || (wspa[4] == wspa[3])) {
					wspa[4]++;
				}
				playwarcards(wspa[2], wspa[3], wspa[4]);
			} else {
				irc_chanprivmsg (ws_bot, warroom, "\0037%s\0039 you hold\00311 %d\0039 cards, and are currently at \0034WAR\0039 which three would you like to play ?", wplayernick[currentplayer], wplayercardstotal[currentplayer]);
			}
		}
	} else {
		if (!ircstrcasecmp (wplayernick[currentplayer], ws_bot->name)) {
			playcard(((rand() % wplayercardstotal[currentplayer]) + 1));
		} else {
			irc_chanprivmsg (ws_bot, warroom, "\0037%s\0039 you currently hold\00311 %d\0039 cards, which would you like to play ?", wplayernick[currentplayer], wplayercardstotal[currentplayer]);
		}
	}
}
Пример #3
0
static void buyphase() {
	int num,i,j,pid,id;
	int list[MAXCARD];
	char s[MAXSMALLS];
	while((num=countcardsmask(TYPE_TREASURE))) {
		printf("type 1 to %d to play a treasure card or 0 to skip.\n",num);
		for(i=j=0;i<cur->handn;i++)
			if(card[player[currentplayer].hand[i]].type&TYPE_TREASURE) {
				list[j]=i;
				printf("  %d. %s\n",++j,card[player[currentplayer].hand[i]].fullname);
			}
		while(1) {
			scanf(scans,s);
			if(isinteger(s)) {
				j=strtol(s,0,10);
				if(!j) goto buy;
				else {
					playcard(cur->hand[list[j-1]]);
					movecard(list[j-1],cur->hand,&cur->handn,cur->playarea,&cur->playarean);
					break;
				}
			}
		}
	}
buy:
	/* the rules for prosperity clarifies the following: it's not allowed to play
	   treasure cards after buying a card! so no playing copper after buying grand
	   market. */
	/* TODO take into account cards that change the money values, for
	   example increasing copper value by 1 */
	while(player[currentplayer].buy) {
		printf("you have %d money, %d potions and %d buys!\n",player[currentplayer].money,player[currentplayer].potion,player[currentplayer].buy);
		if((pid=choosepiletogain(currentplayer,0,player[currentplayer].money,0,player[currentplayer].potion))>-1) {
			id=pile[pid].card[pile[pid].cards-1];
			player[currentplayer].buy--;
			player[currentplayer].money-=money_cost_L(id);
			player[currentplayer].potion-=potion_cost_L(id);
			gaincardfromsupply(pid,currentplayer);
		} else break;
	}
}
Пример #4
0
void
domove()
{
	PLAY	*pp;
	int	i, j;
	bool	goodplay;

	pp = &Player[Play];
	if (Play == PLAYER)
		getmove();
	else
		calcmove();
	Next = FALSE;
	goodplay = TRUE;
	switch (Movetype) {
	  case M_DISCARD:
		if (haspicked(pp)) {
			if (pp->hand[Card_no] == C_INIT) {
				if (Card_no == 6)
					Finished = TRUE;
				else
					error("no card there");
			} else {
				if (is_safety(pp->hand[Card_no])) {
					error("discard a safety?");
					goodplay = FALSE;
					break;
				}
				Discard = pp->hand[Card_no];
				pp->hand[Card_no] = C_INIT;
				Next = TRUE;
				if (Play == PLAYER)
					account(Discard);
			}
		}
		else
			error("must pick first");
		break;
	  case M_PLAY:
		goodplay = playcard(pp);
		break;
	  case M_DRAW:
		Card_no = 0;
		if (Topcard <= Deck)
			error("no more cards");
		else if (haspicked(pp))
			error("already picked");
		else {
			pp->hand[0] = *--Topcard;
#ifdef DEBUG
			if (Debug)
				fprintf(outf, "DOMOVE: Draw %s\n", C_name[*Topcard]);
#endif
acc:
			if (Play == COMP) {
				account(*Topcard);
				if (is_safety(*Topcard))
					pp->safety[*Topcard-S_CONV] = S_IN_HAND;
			}
			if (pp->hand[1] == C_INIT && Topcard > Deck) {
				Card_no = 1;
				pp->hand[1] = *--Topcard;
#ifdef DEBUG
				if (Debug)
					fprintf(outf, "DOMOVE: Draw %s\n", C_name[*Topcard]);
#endif
				goto acc;
			}
			pp->new_battle = FALSE;
			pp->new_speed = FALSE;
		}
		break;

	  case M_ORDER:
		break;
	}
	/*
	 * move blank card to top by one of two methods.  If the
	 * computer's hand was sorted, the randomness for picking
	 * between equally valued cards would be lost
	 */
	if (Order && Movetype != M_DRAW && goodplay && pp == &Player[PLAYER])
		sort(pp->hand);
	else
		for (i = 1; i < HAND_SZ; i++)
			if (pp->hand[i] == C_INIT) {
				for (j = 0; (j < HAND_SZ) &&
					 (pp->hand[j] == C_INIT); j++)
					;	
				if (j == HAND_SZ)
					j = 0;
				pp->hand[i] = pp->hand[j];
				pp->hand[j] = C_INIT;
			}
	if (Topcard <= Deck)
		check_go();
	if (Next)
		nextplay();
}