#include<iostream>
#include<windows.h>
#include<conio.h>
#include<cstdlib>
#include<ctime>
using namespace std;
#define takekey(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
int ans,ans2,ans3;
const int zk=8;
bool over;int winner;int sqs,sqm;
string zhm[zk]{"气","刃","盾","重击","天马","大盾","八卦","集气瓶"};
int xh[zk]{0,1,0,2,2,1,4,3},lb[zk]{0,1,2,1,1,2,1,0},cd[zk]{0,0,0,0,0,0,0,0},xg[zk]{1,1,1,2,3,3,5,10},pf[zk]{0,0,0,1,0,0,10},fix[zk]{0,0,1,0,0,2,0},least[zk]{0,0,1,0,2,2,0,0};
string lmb[3]{"收获","攻击","防御"};bool have[zk],br[zk],brm[zk];int qs,qm,hz[zk],top=-1,czs,czm;int per[zk]{10,10,12,10,8,5,80,70};
string td[zk]{"最普通的攒气","最普通的攻击","最普通的防御","破防+1","高伤害","铜墙铁壁","秒杀一切","以小换大"};
int random(int x){
return rand()%x+0;
}void color(int ForgC, int BackC) {
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), wColor);
}void sayQ(string s){
bool flag=false;
int L=s.length();
while(takekey(13));
for(int i=0;i<L;i++){
printf("%c",s[i]);
if(takekey(13))flag=true;
if(!flag)Sleep(30);
}while(takekey(13));
//getch();printf("\n");
return;
}void say(string s){
bool flag=false;
int L=s.length();
while(takekey(13)||takekey(1));
for(int i=0;i<L;i++){
printf("%c",s[i]);
if(takekey(13)||takekey(1))flag=true;
if(!flag)Sleep(30);
}while(takekey(13)||takekey(1));
while(!(takekey(13)||takekey(1)));printf("\n");
return;
}string its(int x){
if(x==0)return "0";
char str[10]="";
int i=-1,a=x;
while(a){
i++;a/=10;
}while(x){
str[i]=x%10+'0';
x/=10;i--;
}return str;
}int choose(string s[],int l){
printf("你选择:\n");
for(int i=0;i<l;i++)
printf("%d.",i+1),cout<<s[i]<<endl;
char c=getch();
while(c<'1'||c>'0'+l)c=getch();
return c-'0';
}void show(int x){
system("cls");
sayQ("名称:");say(zhm[x]);
sayQ("类型:");say(lmb[lb[x]]);
sayQ("消耗:");say(its(xh[x]));
if(lb[x]==0)sayQ("收获:"),say(its(xg[x]));
else if(lb[x]==1)sayQ("伤害:"),say(its(xg[x]));
else sayQ("防御值:"),say(its(xg[x]));
if(lb[x]==2)sayQ("修复所需:"),say(its(fix[x]));
sayQ("特点:");say(td[x]);
system("cls");
return;
}void hit(){
system("cls");
if(lb[hz[czs]]==2&&br[hz[czs]]){
sayQ("你修了"),say(zhm[hz[czs]]);
br[hz[czs]]=false;qs-=fix[hz[czs]];
}sayQ("你使用了"),say(zhm[hz[czs]]);
if(lb[czm]==2&&brm[czm]){
sayQ("敌人修了"),say(zhm[czm]);
brm[czm]=false;qm-=fix[czm];
}sayQ("敌人使用了"),say(zhm[czm]);
qs-=xh[hz[czs]];qm-=xh[czm];
if(lb[hz[czs]]==0){
if(lb[czm]==1){
winner=2;
over=true;
return;
}qs+=xg[hz[czs]];
}if(lb[czm]==0){
if(lb[hz[czs]]==1){
winner=1;
over=true;
return;
}qm+=xg[czm];
}if(lb[hz[czs]]==1&&lb[czm]==1){
if(xg[hz[czs]]>xg[czm])winner=1;
if(xg[hz[czs]]<xg[czm])winner=2;
if(!(xg[hz[czs]]==xg[czm])){
over=true;return;
}
}if(lb[hz[czs]]==1&&lb[czm]==2)
if(pf[hz[czs]]==xg[czm])brm[czm]=true;
else if(pf[hz[czs]]>xg[czm])winner=1,over=true;
if(lb[hz[czs]]==2&&lb[czm]==1)
if(pf[czm]==xg[hz[czs]])br[hz[czs]]=true;
else if(pf[czm]>xg[hz[czs]])winner=2,over=true;
getch();system("cls");
return;
}void fight(bool mh[]){
system("cls");
sayQ("你的敌人有:");
for(int i=0;i<zk;i++)
if(mh[i])sayQ(zhm[i]),printf(" ");
printf("\n");say("准备开始");
system("cls");qs=sqs,qm=sqm;
over=false;int need;
for(int i=0;i<zk;i++)
brm[i]=false;
while(!over){
printf("你的气:%d 敌人的气:%d\n",qs,qm);
for(int i=0;i<=top;i++){
need=(br[hz[i]])?xh[hz[i]]+1:xh[hz[i]];
if(need>qs)color(8,0);else color(7,0);
printf("%d.",i+1),cout<<zhm[hz[i]];
if(br[hz[i]])cout<<"(破损)";
printf(" ");
}char c=getch();color(7,0);
while(c<'1'||c>'0'+top+1||xh[hz[c-'0'-1]]>qs)c=getch();
czs=c-'0'-1;bool ok=false;
if(qs==0&&qm==0)czm=0;
else{
while(!ok){
for(int i=0;i<zk&&!ok;i++){
if(mh[i]){
need=(brm[i])?xh[i]+fix[i]:xh[i];
//if(need<=qm&&(((!(lb[i]==2))&&random(100)<10)||(lb[i]==2&&qs>0&&random(100)<15)))
if(need<=qm&&random(100)<per[i]&&qs>=least[i])czm=i,ok=true;
}
}
}
}
hit();
}system("cls");
color(7,0);
return;
}int main(){
srand(time(0));
say("QI adventure(按回车或鼠标继续 数字键选择)");
system("cls");
say("这里是气的冒险");
say("先给你四个招吧");
for(int i=0;i<4;i++){
hz[++top]=i;
have[i]=true;
show(i);
} system("cls");
say("按数字键选择");
say("看看你的实力如何");
bool m1[zk]{1,1,1,1,0,0};
winner=2;
while(winner==2){
fight(m1);
if(winner==2)
say("发挥失误?再来一次");
}say("很好,你还是有点实力的");
say("那再选择一个招吧");
string s1[2]{"天马","大盾"};
ans=choose(s1,2);
hz[++top]=3+ans;
have[3+ans]=true;
show(3+ans);
say("来一个厉害的");
bool m2[zk]{1,1,1,1,1,1};
winner=2;
while(winner==2){
fight(m2);
if(winner==2)
say("不行了吧,再来一次");
}say("你还挺厉害的");
say("选个大招吧");
string s2[2]{"八卦","集气瓶"};
ans=choose(s2,2);
hz[++top]=5+ans;
have[5+ans]=true;
show(5+ans);
say("挑战一下试试");
bool m3[zk]{1,1,1,1,1,1,1,1};
winner=2;
while(winner==2){
fight(m3);
if(winner==2)
say("很正常,再来一次");
}say("......");
say("不可思议");
color(7,0);
return 0;
}
QI adventure
最新推荐文章于 2024-09-16 17:46:36 发布