最近闲来无事,就打了一点点代码:
#include
#include
#include
#include
#include
#include
#include
#include
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
string cih[101]={
"OMG","我觉得1号是狼人","奥里给!","我觉得二号是狼人","给力奥","我不知道耶","您是谁?","你们觉得我是谁?","你好","啊呀,我手滑了","!!!","giao!","无情哈拉少!","666","G^O^D!","I L Y","正在编程中...","程序猿登录!","您真厉害!","奆老!","我是蒟蒻,大蒟蒻,大大大蒟蒻!","Oh My God!!!","我是好人,不要投我!","我是坏人。加油,奥利给!","大家玩的嗨森吗?","很嗨森!","感谢Robotlongtime给予的机会!","大家感谢他!","大家还有话要说吗?","好玩吗?","这使人愉快"};
bool js1[1000001];
long long usertime[1000001];
int xl=1000,gjl=10,fyl=0;
int yyjtp=-1;
int a;
bool bn[6];
bool nwjy=1;
int rb[6];
int xc[6];
int pm1,pm2,lr2,yyj,nw,lr;
int js();
string name[1000001]={
"admin"},pass[1000001]={
"asdfghjkl"};
int score[100001];
string inn;
char ink[100001];
string inpo;
int n;
int m;
string rrr[100001];
int r[100001];
int userr;
string dluser;
void DCsort(int l, int rr, int* x,string *xx)
{
if (l == rr) return;
int mid = (l + rr) / 2;
DCsort(l, mid, x,xx);
DCsort(mid + 1, rr, x,xx);
int i = l, j = mid + 1, k = l;
while (i <= mid && j <= rr)
{
if (x[i] >= x[j])
{
rrr[k] = xx[i];
r[k] = x[i]; k++; i++;
}
else
{
rrr[k] = xx[j];
r[k] = x[j]; k++; j++;
}
}
while (i <= mid)
{
rrr[k] = xx[i];
r[k] = x[i];
k++;
i++;
}
while (j <= rr)
{
rrr[k] = xx[j];
r[k] = x[j];
k++;
j++;
}
for (int i = l; i <= rr; i++)
{
x[i] = r[i];
xx[i] = rrr[i];
}
}
void inGame(int user)
{
string ls;
ifstream fin("up.txt");
fin>>n;
for(int i=1;i<=n;i++)
{
fin>>ls>>ls>>score[i]>>ls>>ls;
}
DCsort(1,n,score,name);
system("cls");
printf("---------------排行榜----------------\n");
for(int i=1;i<=n;i++)
{
printf("%d:%-16s| %-10d\n",i,name[i].c_str(),score[i]);
}
system("pause");
}
int read()
{
cout<<"请输入邀请码:";
cin>>m;
if(m==123456789)
{
cout<<"输入正确!请输入个人信息:\n用户名:";
}
else
{
cout<<"输入错误!";
Sleep(1000);
return 1;
}
string rean,reap;
cin>>rean;
cout<<"密码:";
memset(ink,0,sizeof(ink));
int k=0;
char ch;
while(ch=getch())
{
if((ch<32||ch>126)&&ch!='\b') break;
else if(ch=='\b')
{
system("cls");
cout<<"本程序只供部分用户使用,请输入用户名和密码;或在用户名处输入“注册”。\n";
cout<<"用户名:"<<"注册"<<endl<<"请输入邀请码:123456789\n输入正确!请输入个人信息:\n用户名:"<<rean<<endl<<"密码:";
if(k<=0) continue;
k--;
ink[k+1]=0;
for(int j=0;j<k;j++) cout<<"*";
}
else
{
ink[k]=ch+150;
k++;
cout<<"*";
}
}
reap=ink;
cout<<endl;
for(int i=0;i<=n;i++)
{
if(rean==name[i]) {
cout<<"已有此用户!";Sleep(1500);return 1;}
}
ofstream fout("up.txt");
n++;
fout<<n<<endl;
for(int i=1;i<n;i++)
{
fout<<name[i]<<" ";
for(int j=0;j<pass[i].length();j++) fout<<(char)(pass[i][j]+150);
fout<<" "<<score[i]<<" "<<js1[i]<<" "<<usertime[i]<<endl;
}
fout<<rean<<" "<<reap<<" 0 0 0";
name[n]=rean;
pass[n]=reap;
for(int i=0;i<pass[n].length();i++) pass[n][i]-=150;
userr=n;
dluser=rean;
usertime[userr]=0;
return 0;
}
int keytest()
{
system("cls");
ifstream fin("up.txt");
fin>>n;
for(int i=1;i<=n;i++)
{
fin>>name[i]>>pass[i]>>score[i]>>js1[i]>>usertime[i];
for(int j=0;j<pass[i].length();j++) pass[i][j]-=150;
}
fin.close();
cout<<"本程序只供部分用户使用,请输入用户名和密码;或在用户名处输入“注册”。\n";
cout<<"用户名:";
cin>>inn;
int flag;
if(inn=="注册")
{
flag=read();
return flag;
}
cout<<"密码:";
memset(ink,0,sizeof(ink));
int k=0;
char ch;
while(ch=getch())
{
if(ch==13) break;
else if(ch=='\b')
{
system("cls");
cout<<"本程序只供部分用户使用,请输入用户名和密码;或在用户名处输入“注册”(请使用英文填写注册信息)。\n";
cout<<"用户名:"<<inn<<endl<<"密码:";
if(k<=0) continue;
k--;
ink[k+1]=0;
for(int j=0;j<k;j++) cout<<"*";
}
else
{
ink[k]=ch;
k++;
cout<<"*";
// cout<
}
}
inpo=ink;
cout<<endl;
for(int i=0;i<=n;i++)
{
if(name[i]==inn)
{
if(pass[i]==inpo)
{
cout<<"登录成功!"<<endl;
Sleep(500);
userr=i;
dluser=inn;
return 0;
}
else
{
cout<<"密码错误!";
Sleep(1500);
return 1;
}
}
}
cout<<"用户名错误!";
Sleep(1500);
return 1;
}
void welcome()
{
system("cls");
system("color 70");
cout<<"欢迎进入狼人杀!!!\n";
Sleep(1000);
cout<<"游戏规则:\n";
Sleep(1000);
cout<<"1:6人局有两个狼人,一个预言家,一个女巫,还有两个平民!\n";
Sleep(1000);
cout<<"2:12人局未开发,请尽请等待...\n";
Sleep(1000);
cout<<"3:系统自动控制其他角色,行为固定。请利用好人机,赢得胜利。\n";
system("pause");
system("cls");
cout<<"游戏加载中...";
Sleep(600);
system("cls");
cout<<"游戏加载中.";
Sleep(500);
system("cls");
cout<<"游戏加载中..";
Sleep(500);
system("cls");
cout<<"游戏加载中...";
Sleep(500);
system("cls");
for(int i=1;i<=60;i++)
{
Sleep(40);
system("cls");
cout<<"加载中("<<i<<"%)";
if(KEY_DOWN(' ')) i+=5;
}
system("cls");
cout<<"加载中("<<60<<"%)";
Sleep(1500);
for(int i=61;i<=80;i++)
{
Sleep(80);
system("cls");
cout<<"加载中("<<i<<"%)";
if(KEY_DOWN(' ')) i+=5;
}
system("cls");
cout<<"加载中("<<80<<"%)";
Sleep(1000);
for(int i=81;i<=90;i++)
{
Sleep(30);
system("cls");
cout<<"加载中("<<i<<"%)";
if(KEY_DOWN(' ')) i+=5;
}
Sleep(1000);
system("cls");
cout<<"加载中("<<100<<"%)";
Sleep(1600);
}
bool pd(int* s)
{
if(bn[*s]==1)
{
cout<<"此人已死!\n";
cin>>*s;
return 1;
}
return 0;
}
bool pdnw(int *s)
{
if(*s!=1&&*s!=2)
{
cout<<"输入不正确!\n";
cin>>*s;
return 1;
}
return 0;
}
void game(bool flag)
{
system("cls");
cout<<"您是"<<a<<"号,您是";
if(pm1==a||pm2==a)
{
cout<<"平民。";
}
if(lr==a)
{
cout<<"狼人。";
}
if(nw==a)
{
cout<<"女巫。";
}
if(yyj==a)
{
cout<<"预言家。";
}
cout<<"\n天黑请闭眼。\n";
system("color 07");
Sleep(1500);
cout<<"狼人请睁眼。\n";
if(lr==a&&flag==0)
{
system("color 70");
}
Sleep(1500);
cout<<"请问您要杀谁?\n";
int s;
if(lr==a||lr2==a&&flag==0)
{
for(int i=1;i<=6;i++) if(bn[i]==0) cout<<i<<" ";
cout<<endl;
cin>>s;
while(pd(&s));
system("color 00");
}
else
{
Sleep(1500);
if(bn[lr]==0)
{
s=rand()%6+1;
while(bn[s]==1||s==lr) s=rand()%6+1;
Sleep(rand()%1000+500);
}
}
bn[s]=1;
int jl1=s,jl2=-1;
cout<<"狼人请闭眼。\n";
system("color 07");
Sleep(6000);
cout<<"女巫请睁眼。\n";
if(nw==a&&flag==0)
{
system("color 70");
}
Sleep(1500);
cout<<"今晚*号死了,请问您要使用解药救他还是使用毒药毒人?\n";
Sleep(500);
if(nw==a&&flag==0)
{
cout<<"使用毒药,请输入1。解药请输入2。\n";
cin>>s;
while(pdnw(&s));
if(s==1)
{
Sleep(1000);
cout<<"请问您要毒谁?\n";
for(int i=1;i<=6;i++) if(bn[i]==0) cout<<i<<" ";
cout<<endl;
int d;
cin>>d;
while(pd(&s));
bn[d]=1;
jl2=d;
}
if(s==2&&nwjy==1)
{
nwjy=0;
bn[jl1]=0;
jl1=-1;
}
if(s==2&&nwjy==0&&jl1!=-1)
{
cout<<"只能毒人!\n";
Sleep(1500);
cout<<"请问您要毒谁?\n";
for(int i=1;i<=6;i++) if(bn[i]==0) cout<<i<<" ";
cout<<endl;
int d;
cin>>d;
while(pd(&d));
bn[d]=1;
jl2=d;
}
}
else
{
Sleep(3000);
if(bn[nw]==0||jl1==nw)
{
int choose=0;
choose=rand()%2+1;
if(nwjy==0&&choose==1)
{
int d=rand()%6+1;
while(bn[d]==1) d=rand()%6+1;
bn[d]=1;
jl2=d;
}
else
{
bn[jl1]=0;
jl1=-1;
nwjy=0;
}
}
}
cout<<"女巫请闭眼。\n";
system("color 07");
Sleep(1000);
cout<<"预言家请睁眼。\n";
if(yyj==a&&flag==0)
system("color 70");
Sleep(1000);
cout<<"请问你要预言谁的身份?\n";
if(yyj==a&&flag==0)
{
int s;
cin>>s;
cout<<"他的身份是:";
if(s==lr) cout<<"Bad\n";
else cout<<"Good\n";
}
else
{
if(bn[yyj]==0||jl1==yyj)
{
int s=rand()%6+1;
if(s==lr) yyjtp=lr;
}
cout<<"他的身份是:\n";
}
cout<<"预言家请闭眼。\n";
system("color 07");
Sleep(1000);
cout<<"天亮了。\n";
system("color 70");
cout<<"昨晚,";
Sleep(1001);
if(jl1==-1&&jl2==-1) cout<<"是平安夜。";
if(jl1!=-1) cout<<jl1;
if(jl2!=-1) cout<<"和"<<jl2;
if(jl1!=-1||jl2!=-1) cout<<"死了。";
Sleep(5000);
if(a==jl1||a==jl2) return;
if((js()==1||js()==2)&&bn[lr]==0){
return;}
if(bn[lr]==1){
return;}
system("cls");
cout<<"您是"<<a<<"号,您是";
if(pm1==a||pm2==a)
{
cout<<"平民。";
}
if(lr==a||lr2==a)
{
cout<<"狼人。";
}
if(nw==a)
{
cout<<"女巫。";
}
if(yyj==a)
{
cout<<"预言家。";
}
cout<<"\n接下来,是发言时间!\n";
for(int i=1;i<=6;i++)
{
if(i==a&&flag==0)
{
string ch;
cout<<i<<":";
cin>>ch;
}
else if(bn[i]==0)
{
cout<<i<<':'<<cih[rand()%41]<<endl;
}
Sleep(1000);
}
cout<<"\n现在开始投票环节。\n";
int tp[7]={
};
for(int i=1;i<=6;i++)
{
if(i==a&&bn[a]==0)
{
// cout<
int b;
cout<<"请问您投几号?";
cin>>b;
tp[b]++;
}
if(i!=a&&bn[i]==0)
{
if(i==yyj)
{
if(yyjtp!=-1)
{
tp[yyjtp]++;
// cout<
}
else
{
int b=rand()%6+1;
tp[b]++;
// cout<
}
}
else
{
int b=rand()%6+1;
tp[b]++;
// cout<
}
}
}
Sleep(3000);
int mmax=-99999999,maxx;
cout<<"投票结果:\n";
for(int i=1;i<=6;i++)
{
if(bn[i]==0)
{
cout<<i<<":"<<tp[i]<<endl;
if(tp[i]>mmax)
{
mmax=tp[i];
maxx=i;
}
else
{
if(tp[i]==mmax)
{
maxx=-1;
}
}
}
}
if(maxx==-1) cout<<"投票无结果!";
else
{
if(bn[maxx]==1) cout<<"已经出局!";
else
{
cout<<maxx<<"出局!";
bn[maxx]=1;
}
}
Sleep(5000);
}
void gamestart(int ms)
{
memset(rb,0,sizeof(rb));
pm1=0;pm2=0;lr=0;nw=0;yyj=0;lr2=0;
int i=1,flag=0,b;
srand((unsigned)time(NULL));
do
{
b=rand()%6+1;
}
while(rb[b]==1);
rb[b]=1;
pm1=b;
do
{
b=rand()%6+1;
}
while(rb[b]==1);
rb[b]=1;
lr2=b;
do
{
b=rand()%6+1;
}
while(rb[b]==1);
rb[b]=1;
pm2=b;
do
{
b=rand()%6+1;
}
while(rb[b]==1);
rb[b]=1;
lr=b;
do
{
b=rand()%6+1;
}
while(rb[b]==1);
rb[b]=1;
nw=b;
do
{
b=rand()%6+1;
}
while(rb[b]==1);
rb[b]=1;
yyj=b;
a=rand()%6+1;
system("cls");
cout<<"您是"<<a<<"号,您是";
if(pm1==a||pm2==a)
{
cout<<"平民。";
}
if(lr==a||lr2==a)
{
cout<<"狼人。";
}
if(nw==a)
{
cout<<"女巫。";
}
if(yyj==a)
{
cout<<"预言家。";
}
cout<<"\n狼人:"<<lr<<"\n女巫:"<<nw;
Sleep(1000);
while(bn[a]==0)
{
// if(ms==1) game(3);
/*else*/ game(0);
if((js()==1||js()==2)&&bn[lr]==0)
{
cout<<"\n狼人胜利!\n";
if(a==lr)
{
score[userr]+=20;
ofstream fout("up.txt", fstream::out | ios_base::trunc);
fout<<n<<endl;
for(int i=1;i<=n;i++)
{
fout<<name[i]<<" ";
for(int j=0;j<pass[i].length();j++) fout<<pass[i][j]+150;
fout<<" "<<score[i]<<" "<<js1[i]<<" "<<usertime[i]<<endl;
}
}
system("pause");
return;
}
if(bn[lr]==1)
{
cout<<"\n平民胜利!\n";
if(a==pm1||a==pm2||a==yyj||a==nw)
{
score[userr]+=20;
ofstream fout("up.txt", fstream::out | ios_base::trunc);
fout<<n<<endl;
for(int i=1;i<=n;i++)
{
fout<<name[i]<<" ";
for(int j=0;j<pass[i].length();j++) fout<<pass[i][j]+150;
fout<<" "<<score[i]<<" "<<js1[i]<<" "<<usertime[i]<<endl;
}
}
system("pause");
return;
}
}
cout<<"\n您死了!\n";
if(bn[lr]==1) cout<<"平民胜利!";
else
{
cout<<"是否继续观战?请输入是或否。\n";
string xz;
cin>>xz;
if(xz=="否")
{
cout<<"您输了!";
score[userr]--;
ofstream fout("up.txt", fstream::out | ios_base::trunc);
fout<<n<<endl;
for(int i=1;i<=n;i++)
{
fout<<name[i]<<" ";
for(int j=0;j<pass[i].length();j++) fout<<pass[i][j]+150;
fout<<" "<<score[i]<<" "<<js1[i]<<" "<<usertime[i]<<endl;
}
}
if(xz=="是")
{
cout<<"开始观战:\n";
game(1);
if((js()==1||js()==2)&&bn[lr]==0)
{
cout<<"\n狼人胜利!";
if(a==lr)
{
score[userr]+=5;
ofstream fout("up.txt", fstream::out | ios_base::trunc);
fout<<n<<endl;
for(int i=1;i<=n;i++)
{
fout<<name[i]<<" ";
for(int j=0;j<pass[i].length();j++) fout<<pass[i][j]+150;
fout<<" "<<score[i]<<" "<<js1[i]<<" "<<usertime[i]<<endl;
}
}
else
{
cout<<"\n您输了!";
score[userr]--;
ofstream fout("up.txt", fstream::out | ios_base::trunc);
fout<<n<<endl;
for(int i=1;i<=n;i++)
{
fout<<name[i]<<" ";
for(int j=0;j<pass[i].length();j++) fout<<pass[i][j]+150;
fout<<" "<<score[i]<<" "<<js1[i]<<" "<<usertime[i]<<endl;
}
}
system("pause");
return;
}
if(bn[lr]==1)
{
cout<<"\n平民胜利!";
if(a==pm1||a==pm2||a==yyj||a==nw)
{
score[userr]+=20;
ofstream fout("up.txt", fstream::out | ios_base::trunc);
fout<<n<<endl;
for(int i=1;i<=n;i++)
{
fout<<name[i]<<" ";
for(int j=0;j<pass[i].length();j++) fout<<pass[i][j]+150;
fout<<" "<<score[i]<<" "<<js1[i]<<" "<<usertime[i]<<endl;
}
}
else
{
cout<<"\n您输了!";
score[userr]--;
ofstream fout("up.txt", fstream::out | ios_base::trunc);
fout<<n<<endl;
for(int i=1;i<=n;i++)
{
fout<<name[i]<<" ";
for(int j=0;j<pass[i].length();j++) fout<<pass[i][j]+150;
fout<<" "<<score[i]<<" "<<js1[i]<<" "<<usertime[i]<<endl;
}
}
system("pause");
return;
}
}
}
}
void repair()
{
system("cls");
cout<<"请输入旧密码:";
memset(ink,0,sizeof(ink));
int k=0;
char ch;
while(ch=getch())
{
if(ch==13) break;
else if(ch=='\b')
{
system("cls");
cout<<"请输入旧密码:";
if(k<=0) continue;
k--;
ink[k+1]=0;
for(int j=0;j<k;j++) cout<<"*";
}
else
{
ink[k]=ch;
k++;
cout<<"*";
}
}
printf("\n");
int xk=k;
if(ink!=pass[userr]) cout<<"\n密码错误!",Sleep(3000);
else
{
cout<<"请输入新密码:";
memset(ink,0,sizeof(ink));
int k=0;
char ch;
while(ch=getch())
{
if(ch==13) break;
else if(ch=='\b')
{
system("cls");
cout<<"请输入旧密码:";
for(int i=1;i<=xk;i++) cout<<"*";
cout<<endl;
cout<<"请输入新密码:";
if(k<=0) continue;
k--;
ink[k+1]=0;
for(int j=0;j<k;j++) cout<<"*";
}
else
{
ink[k]=ch;
k++;
cout<<"*";
}
}
string strls=ink;
int yk=k;
cout<<endl;
cout<<"请重复输入密码:";
memset(ink,0,sizeof(ink));
k=0;
while(ch=getch())
{
if(ch==13) break;
else if(ch=='\b')
{
system("cls");
cout<<"请输入旧密码:";
for(int i=1;i<=xk;i++) cout<<"*";
cout<<endl;
cout<<"请输入新密码:";
for(int i=1;i<=yk;i++) cout<<"*";
cout<<endl;
cout<<"请重复输入密码:";
if(k<=0) continue;
k--;
ink[k+1]=0;
for(int j=0;j<k;j++) cout<<"*";
}
else
{
ink[k]=ch;
k++;
cout<<"*";
}
}
if(ink!=strls) {
cout<<"\n密码重复错误!";Sleep(3000);return;}
pass[userr]=ink;
ofstream fout("up.txt");
fout<<n<<endl;
for(int i=1;i<=n;i++)
{
fout<<name[i]<<" ";
for(int j=0;j<pass[i].length();j++) fout<<(char)(pass[i][j]+150);
fout<<" "<<score[i]<<" "<<js1[i]<<" "<<usertime[i]<<endl;
}
cout<<"\n密码修改成功!";
Sleep(3000);
}
}
void pt()
{
cout<<"您的状态:\n血量:"<<xl<<"\n攻击力:"<<gjl<<"\n防御力:"<<fyl<<endl<<"金币:"<<score[userr]<<"\n";
}
void userlook()
{
system("cls");
cout<<"现有用户:\n";
for(int i=1;i<=n;i++) cout<<name[i]<<" "<<pass[i]<<"\n";
system("pause");
}
int wqd()
{
int wq[5]={
0,5,10,15,20};
int vq[5]={
0,2,5,-2,-5};
system("cls");
cout<<"欢迎进入武器店!\n";
pt();
cout<<"今有特价商品:\n1:小刀(5$2kill)\n2:养箭壶(10$5kill)\n3:小木盾(15$2kill)\n4:铁盾(20$5kill)\n5:退出武器店\n";
char getans=getch();
if(getans=='5')
{
cout<<"正在退出...";
Sleep(250);
return 0;
}
if(getans<'1'||getans>'4')
{
cout<<"输入错误!";
Sleep(250);
return 1;
}
if(score[userr]-wq[getans-'0']<0)
{
cout<<"没钱滚蛋!";
Sleep(250);
return 1;
}
if(vq[getans-'0']>0)
gjl+=vq[getans-'0'];
if(vq[getans-'0']<0)
fyl-=vq[getans-'0'];
score[userr]-=wq[getans-'0'];
cout<<"购买成功!";
Sleep(250);
return 1;
}
bool dg(int jn,int* gx,int gg,int gf,int gd)
{
system("cls");
if(xl<=0)
{
cout<<"您死了!死亡将失去所有奖励...";
Sleep(1000);
return 0;
}
cout<<"开始打怪!";
pt();
cout<<"怪兽的状态:\n血量:"<<*gx<<"\n攻击力:"<<gg<<"\n防御力:"<<gf<<endl<<"金币:"<<gd<<"\n";
cout<<"您要干什么?\n1:攻击\n2:逃跑回家\n3:使用技能\n";
char xz=getch();
if(xz=='1')
{
cout<<"进攻!\n";
bool bj=rand()%2;
if(bj==1)
{
cout<<"你扣了怪兽"<<2*gjl-gf<<"的血量...(暴击)"<<endl;
*gx-=2*gjl-gf;
}
else
{
cout<<"你扣了怪兽"<<gjl-gf<<"的血量..."<<endl;
*gx-=gjl-gf;
}
Sleep(500);
cout<<"怪兽扣了你"<<gg-fyl<<"的血量..."<<endl;
xl-=gg-fyl;
Sleep(500);
return 1;
}
else if(xz=='2')
{
cout<<"逃跑回家...";
Sleep(2000);
return 0;
}
else if(xz=='3')
{
cout<<"使用技能...\n";
if(jn>=100)
{
cout<<"正在使用技能...\n";
Sleep(100);
cout<<"你扣了怪兽100的血量...";
gx-=100;
jn-=100;
}
else
{
cout<<"不能使用技能!";
return 1;
}
}
else return 1;
}
void jjstart()
{
xl=1000,gjl=10,fyl=0;
system("color f0");
while(1)
{
system("cls");
cout<<"欢迎进入街机!\n您好,"<<dluser<<endl;
pt();
cout<<"1、进入武器店\n2、进入药店\n3、打怪模式\n4、挣钱模式\n5、退出街机\n";
char getc=getch();
if(getc=='1')
{
while(wqd());
}
// if(getc=='2') yd();
if(getc=='3')
{
srand(time(NULL)*time(NULL)*rand());
int gx,gg,gf,gd;
gx=rand()%1000;
gg=rand()%50;
gf=rand()%40;
gd=rand()%100;
int jnlj=0;
while(dg(jnlj,&gx,gg,gf,gd)){
jnlj+=rand()%50;}
}
// if(getc=='4') zq();
if(getc=='5')
{
cout<<"正在保存...";
Sleep(500);
return;
}
}
}
void qd()
{
system("cls");
long long nowtime=time(NULL);
if(nowtime-86400>=usertime[userr])
{
cout<<"签到成功!领到:";
srand(time(NULL)*time(NULL)*time(NULL));
int gold=rand()%70;
for(int i=1;i<=140;i+=rand()%5)
{
system("cls");
if(i<=70) cout<<"签到成功!领到:"<<i<<"金币";
else cout<<"签到成功!领到:"<<70+70-i<<"金币";
}
system("cls");
cout<<"签到成功!领到:"<<gold<<"金币";
usertime[userr]=nowtime;
score[userr]+=gold;
ofstream fout("up.txt");
fout<<n<<endl;
for(int i=1;i<=n;i++)
{
fout<<name[i]<<" ";
for(int j=0;j<pass[i].length();j++) fout<<(char)(pass[i][j]+150);
fout<<" "<<score[i]<<" "<<js1[i]<<" "<<usertime[i]<<endl;
}
Sleep(700);
}
else
{
cout<<"最近一天内已经签到,感谢您的参与!";
Sleep(1000);
return;
}
}
int gamewelcome()
{
system("cls");
cout<<"您好,"<<dluser<<endl;
cout<<"1:开始狼人杀\n2:开始街机\n3:查看排行榜\n4:登出账号\n5:退出游戏\n6:修改密码\n7:签到领奖\n";
if(dluser=="admin") cout<<"8:监察用户\n9:游戏测试";
char num;
num=getch();
if(num=='1')
{
welcome();
gamestart(0);
system("color 07");
return 0;
}
if(num=='2')
{
jjstart();
return 0;
}
if(num=='3')
inGame(userr);
if(num=='4')
return 1;
if(num=='5')
{
printf("正");
Sleep(200);
printf("在");
Sleep(200);
printf("退");
Sleep(200);
printf("出");
Sleep(200);
printf("游");
Sleep(200);
printf("戏");
Sleep(200);
printf(".");
Sleep(200);
printf(".");
Sleep(200);
printf(".");
Sleep(200);
exit(0);
}
if(num=='6') repair();
if(num=='7')
qd();
if(num=='8'&&dluser=="admin")
userlook();
if(num=='9'&&dluser=="admin")
gamestart(1);
}
int main()
{
int fl=keytest();
while(fl) fl=keytest();
int flag;
while(1)
{
flag=gamewelcome();
if(flag==1)
{
system("color 07");
fl=1;
while(fl) fl=keytest();
}
}
}
int js()
{
int ans=0;
for(int i=1;i<=6;i++)
{
if(bn[i]==0) ans++;
}
return ans;
}
附录说明:本代码有可能出BUG,也请大佬们回复出来,感谢!注册邀请码为:
123456789 123456789 123456789