【文件属性】:
文件名称:C/C++ 拳皇争霸
文件大小:5KB
文件格式:CPP
更新时间:2012-08-03 02:29:15
C/C++
#include
#include
#include
#include
#include
#define N 100
int n=0;
int Checktoseek(char name[]);//查找
void mainmenu();//菜单
void Register();//登记注册
void Showplayer();//显示当前人物数据
void Showallplayer();//显示所有人物数据
void Chooseopponent();//选择对手
void Chooseplayer(int i);//选择角色
void vs(int i,int j);//PK
void Attack(int i,int j);//攻击
void recovery(int i,int j);//防御
void Energy(int i,int j);//能量
struct Kof
{
char name[20];
int Hp;
int AP;
int Dp;
int Rp;
}player[N];
void main()
{
srand(unsigned(time(NULL)));
mainmenu();
}
void login()
{
}
void mainmenu()
{
while(1)
{
int x;
printf("\n");
printf("\n");
printf(" ***************************************************************\n");
printf(" *** ***\n");
printf(" *** ***\n");
printf(" *** 欢迎进入Kof ***\n");
printf(" *** ***\n");
printf(" *** ***\n");
printf(" ***************************************************************\n");
printf("\t\t\t\t\t1----请先注册\n");
printf("\t\t\t\t\t2----查看玩家信息\n");
printf("\t\t\t\t\t3----查看自己信息\n");
printf("\t\t\t\t\t4----选择对手\n");
printf("\t\t\t\t\t5----结束\n");
printf("\n\n请选择菜单:");
scanf("%d",&x);
if(x==5) break;
switch(x)
{
case 1:Register();break;
case 2:Showallplayer();break;
case 3:Showplayer();break;
case 4:Chooseopponent();break;
}
printf("\n\n\n\n\n按任意键继续:");
getch();
system("cls");
}
}
void Register()
{
char name[20];
printf("输入名称:");
fflush(stdin);
gets(name);
if(Checktoseek(name)==-1)
{
strcpy(player[n].name,name);
player[n].Hp=rand()%1000;
player[n].AP=rand()%(100+1)+50;
player[n].Dp=rand()%(10-5+2)+5;
player[n].Rp=rand()%(60+2)+60;
n++;
printf("人物创建成功\n");
}
else
{
Register();
}
}
void Showplayer()
{
char name[20];
printf("角色名:");
fflush(stdin);
gets(name);
int i=Checktoseek(name);
if(i!=-1)
{
printf("人物名称:%s\n",player[i].name);
printf("Hp:%d\n",player[i].Hp);
printf("Ap:%d\n",player[i].AP);
printf("Dp:%d\n",player[i].Dp);
printf("Rp:%d\n",player[i].Rp);
}
else
{
printf("请重新输入角色名");
Showplayer();
}
}
void Showallplayer()
{
printf("%-10s%-10s%-10s%-10s%-10s\n","Name","Hp","Ap","Dp","Rp");
for(int i=0;i0 && player[j].Hp>0)
{
printf("第%d局***************\n",count);
if(count%2==0)
{
Attack(i,j);
recovery(i,j);
Energy(i,j);
}
else
{
Attack(j,i);
recovery(i,j);
Energy(i,j);
}
count++;
_sleep(3344);
}
if(player[i].Hp>0)
{
printf("%s Victory \n",player[i].name);
}
else
{
printf("%s Winner \n",player[j].name);
}
printf("******************************\n");
}
void Attack(int i,int j)
{
int x;
int s;
x=rand()%5;
switch(x)
{
case 0:
printf("\n%s发出波动伤害%s\n",player[i].name,player[j].name);
s=rand()%100;
player[j].Hp-=s;
printf("%s受到%d点伤害\n\n",player[j].name,s);
break;
case 1:
printf("\n%s使用连招攻击%s\n",player[i].name,player[j].name);
s=rand()%100*2;
player[j].Hp-=s;
printf("%s受到%d点伤害\n\n",player[j].name,s);
break;
case 2:
printf("\n%s释放超杀技\n",player[i].name);
s=(rand()%100)*4;
player[j].Hp-=s;
printf("%s受到%d点伤害\n\n",player[j].name,s);
break;
}
}
void recovery(int i,int j)
{
int s;
int x;
s=rand()%3;
switch(s)
{
case 0:
printf("\n%s防御%s的攻击\n",player[i].name,player[j].name);
x=rand()%(10-5+2)+5;
player[i].Dp==x;
printf("%s抵挡%d点伤害\n\n",player[i].name,x);
break;
case 1:
printf("\n%s防御%s的攻击\n",player[j].name,player[i].name);
x=rand()%(10-5+2)+5;
player[j].Dp==x;
printf("%s抵挡%d点伤害\n\n",player[j].name,x);
break;
}
}
void Energy(int i,int j)
{
int x;
int s;
x=rand()%6;
switch(x)
{
case 0:
printf("\n%s大怒,使用超必杀技\n",player[i].name);
s=(rand()%100)*6;
player[j].Hp-=s;
printf("%s受到%d点伤害\n\n",player[j].name,s);
break;
case 1:
printf("\n%s大怒,使用超必杀技\n",player[j].name);
s=(rand()%100)*6;
player[i].Hp-=s;
printf("%s受到%d点伤害\n\n",player[i].name,s);
break;
}
}