加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
human.c 2.90 KB
一键复制 编辑 原始数据 按行查看 历史
buzhibujue 提交于 2021-12-16 00:32 . Add card J.
#include "zgs.h"
extern int player_number, MP;
extern Pig player[MAX_PLAYER];
extern char identity;
void show_my_card(int id){
printf("Identity:%s Health:%d Weapon:%s\n",ID_NAME(player[id].id),player[id].health,player[id].has_z?CARD_NAME('Z'):"None");
printf(" Cards: ");
for(int i=1;i<=player[id].card_number;i++)
printf("(#%d)%s ",i,CARD_NAME(player[id].card[i].type));
puts("");
}
void human_play(int id){
pick_card(id,2);
int opt;
bool flag=0;
while(!game_end()){
show_my_card(id);
puts("*Input number of card you want to use. -1 to end your play stage.");
do{
opt=read_number();
}while((opt<1||opt>player[id].card_number)&&opt!=-1);
if(opt==-1)
return;
Card card=player[id].card[opt];
switch(card.type){
case 'K':case 'F':{
if(card.type=='K'&&!player[id].has_z&&flag){
printf("You can only use 1 %s in 1 play stage.\n",CARD_NAME('K'));
continue;
}
if(card.type=='K'){
for(int i=1;i<=player_number;i++)if(!is_dead(i)&&i!=id&&dis(i,id)<=1){
show_pig(i,1);
}
}else{
for(int i=1;i<=player_number;i++)if(!is_dead(i)&&i!=id)
show_pig(i,1);
}
int r;
do{
printf("Choose who to %s,-1 to cancel\n",CARD_NAME(card.type));
r=read_number();
if(r<1||r>player_number||is_dead(r)||(card.type=='K'&&!can_use_k(id,r))){
printf("Can't use %s to Player[%d]\n",CARD_NAME(card.type),r);
}
}while((r<1||r>player_number||is_dead(r)||(card.type=='K'&&!can_use_k(id,r)))&&r!=-1);
if(r==-1){
continue;
}
if(card.type=='K') use_k(id,r),flag=1;
else use_f(id,r);
break;
}
case 'Z':{
use_z(id);
break;
}
case 'P':{
use_p(id);
break;
}
case 'W':{
use_w(id);
break;
}
case 'N':{
use_n(id);
break;
}
case 'D':case 'J':{
printf("You can't use %s now\n",CARD_NAME(card.type));
continue;
}
}
}
}
bool will_use(int id,char card){
printf("Use %s? Yy/Nn (Y/y: Yes N/n: No)\n",CARD_NAME(card));
char ch=getchar();
while(ch^'Y'&&ch^'N'&&ch^'y'&&ch^'n')
ch=getchar();
return ch=='Y'||ch=='y';
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化