#include<bits/stdc++.h>
using namespace std;
int a, mm;
int shu,shu1,kj=1,bl=10,dfbl[6],jf=1000,fy=0,mj=2,zcbd=0,rk=10,jfbl=1;
int xxs=1,bol=0,sss=12,xxl,ra,cqjf=2000,cq=0,cnt=0,sum=0,gj=1;
void jfbz(){ cout<<"\b经费不足\n"; }
void jsxd(){
cout<<"\b1、侦查 2、攻打 3、算了\n";
cin>>shu;
if(shu==1) {
cout<<"\b要对哪国进行侦查\n";
if(dfbl[0]!=-1) cout<<"\b1、韩 ";
if(dfbl[1]!=-1) cout<<"\b2、赵 ";
if(dfbl[2]!=-1) cout<<"\b3、魏 ";
if(dfbl[3]!=-1) cout<<"\b4、楚 ";
if(dfbl[4]!=-1) cout<<"\b5、燕 ";
if(dfbl[5]!=-1) cout<<"\b6、齐";
cout<<"\n";
cin>>shu1;
if(shu1==0||shu1>6) {
cout<<"\b有这个国家吗\n";
return ;
}
if(dfbl[shu1-1]==-1) {
cout<<"\b这个国家已经不存在了\n";
return ;
}
switch(shu1) {
case 1:{
if(zcbd>=3) {
cout<<"\b对方兵力为"<<dfbl[shu-1]<<"\n";
zcbd-=3;
_sleep(850);
}
else cout<<"\b侦查部队不足\n";
_sleep(850);
break;
}
case 2:{
if(zcbd>=3) {
cout<<"\b对方兵力为"<<dfbl[shu-1]<<"\n";
_sleep(850);
zcbd-=3;
}
else cout<<"\b侦查部队不足\n";
_sleep(850);
break;
}
case 3:{
if(zcbd>=3) {
cout<<"\b对方兵力为"<<dfbl[shu-1]<<"\n";
zcbd-=3;
_sleep(850);
}
else cout<<"\b侦查部队不足\n";
_sleep(850);
break;
}
case 4:{
if(zcbd>=3) {
cout<<"\b对方兵力为"<<dfbl[shu-1]<<"\n";
zcbd-=3;
_sleep(850);
}
else cout<<"\b侦查部队不足\n";
_sleep(850);
break;
}
case 5:{
if(zcbd>=3) {
cout<<"\b对方兵力为"<<dfbl[shu-1]<<"\n";
_sleep(850);
zcbd-=3;
}
else cout<<"\b侦查部队不足\n";
_sleep(850);
break;
}
case 6:{
if(zcbd>=3) {
cout<<"\b对方兵力为"<<dfbl[shu-1]<<"\n";
_sleep(850);
zcbd-=3;
}
else cout<<"\b侦查部队不足\n";
_sleep(850);
break;
}
} //switch
}
else if(shu==2) {
cout<<"\b要攻打哪国?\n";
if(dfbl[0]!=-1) cout<<"\b1、韩 ";
if(dfbl[1]!=-1) cout<<"\b2、赵 ";
if(dfbl[2]!=-1) cout<<"\b3、魏 ";
if(dfbl[3]!=-1) cout<<"\b4、楚 ";
if(dfbl[4]!=-1) cout<<"\b5、燕 ";
if(dfbl[5]!=-1) cout<<"\b6、齐";
cout<<"\n";
cin>>shu;
if(shu==0||shu>6) {
cout<<"\b不想打直说!有这个国家吗!\n";
return ;
}
if(dfbl[shu-1]<0) {
cout<<"\b不想打直说!人家灭国了你还想鞭尸!\n";
return ;
}
if(bl<dfbl[shu-1]) {
cout<<"\b当前胜率较低,确认攻打吗?1确认,2算了\n";
cin>>shu1;
}
if(shu1==2) return ;
else {
if(bl*gj>dfbl[shu-1]) {
int sj=rand()%20;
if(sj<=2) {
cout<<"\b失败!\n";
jf-=bl;
bl-=dfbl[shu-1];
rk/=2;
} //失败
else {
cout<<"\b胜利!\n";
jf+=dfbl[shu-1];
bl-=dfbl[shu-1];
dfbl[shu-1]=-1;
} //胜利
} //大胜率
else if(bl*gj<dfbl[shu-1]) {
int sj=rand()%20;
if(sj<=0) {
cout<<"\b胜利!\n";
jf+=dfbl[shu-1];
bl-=dfbl[shu-1];
dfbl[shu-1]=-1;
} //胜利
else {
cout<<"\b失败!\n";
jf-=bl;
bl-=dfbl[shu-1];
rk/=2;
} //失败
} //小胜率
else {
int sj=rand()%2;
if(sj==0) {
cout<<"\b胜利!\n";
jf+=dfbl[shu-1];
bl-=dfbl[shu-1];
dfbl[shu-1]=-1;
} //胜利
else {
cout<<"\b失败!\n";
jf-=bl;
bl-=dfbl[shu-1];
rk/=2;
} //失败
} //平概率
}
}
}
int tglf(int k){
cout<<"\b对方兵力为 "<<dfbl[k-1]<<" k\n";
_sleep(1100);
cout<<"\b我方防御力为 "<<fy<<" k\n";
_sleep(1100);
if(fy*gj>dfbl[k-1]) {
int sj=rand()%20;
if(sj<=0) {
cout<<"\b你失败了!\n";
return 0;
} //失败
else {
cout<<"\b胜利!\n";
jf+=dfbl[k-1];
bl-=dfbl[k-1];
return 1;
} //胜利
} //大胜率
else if(fy*gj<dfbl[k-1]) {
int sj=rand()%20;
if(sj<=0) {
cout<<"\b胜利!\n";
jf+=dfbl[k-1];
bl-=dfbl[k-1];
return 1;
} //胜利
else {
cout<<"\b你失败了!\n";
return 0;
} //失败
} //小胜率
else if(fy*gj==dfbl[k-1]){
int sj=rand()%2;
if(sj==0) {
cout<<"\b胜利!\n";
jf+=dfbl[k-1];
bl-=dfbl[k-1];
return 1;
} //胜利
else {
cout<<"\b你失败了!\n";
return 0;
} //失败
} //平概率
}
int yfkj(){
int sj=rand()%15;
if(sj<7) return 1;
else return 2;
}
int main() {
srand(time(NULL));
std::ifstream fileIn("information.txt");
fileIn>>a;
fileIn.close();
if(a==0) {
cout<<"\b请设置你的密码(一个小于21亿且不为0的数)\n";
cin>>mm;
if(mm>2100000000||mm<=0) {
cout<<"\b叫你不听话!\n";
return 0;
}
std::ofstream fileOut("information.txt");
fileOut<<a;
fileOut.close();
}
a=114514;
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"\b请输入你的密码\n";
cin>>mm;
while(1) {
if(mm==a) break;
cout<<"wrong!\n";
cin>>mm;
}
cout<<"Welcome!\n";
_sleep(1500);
for(int i=0;i<6;++i) {
if(dfbl[i]!=-1) dfbl[i]=13+i*(rand()%3);
}
cout<<"\b鸣谢: Lionel_Messi_10(洛谷名)\n";
cout<<"\b感谢这位达佬为存档机制做出伟大贡献!\n";
_sleep(850);
cout<<"\b下一站,秦王朝\n";
cout<<"\b版本:1.3.0\n";
cout<<"\b在七雄之中,成为最后的赢家\n";
cout<<"\b输入1开始\n";
while(1) {
cin>>shu;
if(shu!=1) cout<<"\b树枝在哪里!?开了游戏不开始!一天天就知道乱输入,知不知道判定很麻烦啊!\n";
else break;
}
while(1) {
ra=rand()%20000;
if(ra==0) {
cout<<"\b一个陨石砸向你的大秦\n";
_sleep(750);
cout<<"\b大秦王朝";
_sleep(750);
cout<<"\b亡了!\n";
return 0;
}
if(sum>170) {
_sleep(500);
cout<<"\b时间过去了很久,欧洲的一股强大势力杀向你的大秦\n";
_sleep(650);
cout<<"\b盛极一时的大秦";
_sleep(750);
cout<<"\b亡了!\n";
return 0;
}
if(ra>0&&ra<=100) {
cout<<"\b国家出现反贼,农民开始起义\n";
_sleep(600);
cout<<"\b你损失了大量兵力和经费\n";
bl/=3;
jf/=3;
rk/=2;
}
if(ra>100&&ra<=175) {
cout<<"\b大饥荒\n";
_sleep(650);
cout<<"\b你损失大量兵力\n";
if(bl<1500) bl=bl/2;
else if(bl>=1500&&bl<4000) bl=bl/3;
else bl/=4;
rk/=2;
}
if(ra>175&&ra<=225) {
cout<<"\b平民反抗收税\n";
_sleep(650);
cout<<"\b经济大萧条,你损失大量经费\n";
jf/=5;
}
if(bl<0) bl=0;
if(jf<0) jf=0;
if(fy<0) fy=0;
fy=bl+cq*150;
for(int i=0;i<6;++i) {
if(dfbl[i]!=-1) {
dfbl[i]+=((rand()%7)*cnt*10);
}
if(cnt%((rand()%5)+1)==0) cnt+=2;
}
rk+=(rk/3);
if(jf>=rk*1.25) jf-=rk/1.25;
else if(rk*1.25>jf) {
cout<<"\b你的经费无法保证人民的温饱,人口锐减\n";
rk/=2;
_sleep(500);
}
jfbl=rk/10;
if(kj<3) jf+=mj*125;
else if(kj>=3&&kj<6) jf+=mj*175*jfbl;
else if(kj>=6&&kj<12) jf+=mj*225*jfbl;
else if(kj>12) jf+=mj*300*jfbl;
if(bl>999999||jf>999999) {
cout<<"\b你的数据太离谱了\n";
_sleep(750);
cout<<"\b作者奖励你一次重新开始的机会\n";
_sleep(750);
bl=999,jf=100;
}
cout<<"\b现在你的兵力为 "<<bl<<"k, \b防御力为"<<fy<<"\n";
cout<<"\b当前科技值为"<<kj<<" \b,当前剩余经费为 "<<jf<<" \bk\n";
cout<<"\b当前人口为 "<<rk<<" \b k\n";
cout<<"\b当前拥有 "<<mj<<" \b座民居、 "<<bl<<" \bk兵力和 "<<zcbd<<" \b支侦查部队\n";
_sleep(500);
cout<<"\b你当前操作?\n";
_sleep(500);
cout<<"\b1、建筑 2、升级 3、兵力 4、跳过此阶段 5、读档 6、存档\n";
_sleep(500);
cin>>shu;
if(shu==1) {
cout<<"\b你将要建?\n";
_sleep(500);
cout<<"\b1、城墙 2、民居 3、返回\n";
cin>>shu;
if(shu==1) {
cout<<"\b建造城墙将要花费350k经费,1确认操作,2取消\n";
cin>>shu;
if(shu==1&&jf>=350) {
cq++;
jf-=350;
}
else jfbz();
}
else if(shu==2) {
cout<<"\b建造民居将要花费650k经费,1确认操作,2取消\n";
cin>>shu;
if(shu==1&&jf>=650) {
mj++;
jf-=650;
}
else jfbz();
}
else if(shu==3) continue;
else cout<<"\b没事别乱输入!\n";
} //建筑
if(shu==2) {
cout<<"\b你将要升级?\n";
_sleep(500);
cout<<"\b1、城墙 2、民居 3、返回\n";
cin>>shu;
if(shu==1) {
if(fy==0) cout<<"\b你没有城墙,不能升级\n";
else {
cout<<"\b升级城墙将要花费"<<cqjf<<" \bk经费,1确认操作,2取消\n";
cin>>shu;
if(shu==1&&jf>=cqjf) {
cq*=2.75;
jf-=cqjf;
cqjf*=1.5;
}
else if(shu==1&&jf<cqjf) cout<<"\b经费不足!\n";
}
} //升级城墙
else if(shu==2) {
if(mj<9) {
cout<<"\b升级民居将要花费2100k经费,1确认操作,2取消\n";
xxl=2100;
}
if(mj>=9&&mj<20) {
cout<<"\b升级民居将要花费12500k经费,1确认操作,2取消\n";
xxl=12500;
}
if(mj>=20&&mj<25) {
cout<<"\b升级民居将要花费45000k经费,1确认操作,2取消\n";
xxl=45000;
}
if(mj>=25) {
cout<<"\b升级民居将要花费150000k经费,1确认操作,2取消\n";
xxl=150000;
}
cin>>shu;
if(shu==1&&jf>=xxl) {
mj=mj*1.5;
jf-=xxl;
}
else if(shu==1&&jf<xxl) cout<<"\b经费不足!\n";
} //升级民居
else if(shu==3) continue;
else cout<<"\b没事别乱输入!\n";
} //升级
if(shu==3) {
cout<<"\b你选择?\n";
cout<<"1、研发科技 2、招兵买马 3、返回\n";
cin>>shu;
if(shu==1) {
cout<<"\b升级科技需要 "<<kj*1000<<" \bk经费,1确认,2取消\n";
cin>>shu;
if(shu==1&&jf>=kj*1000) {
int sjj=yfkj();
if(sjj==1) {
kj++;
cout<<"\b科研成功\n";
_sleep(650);
if(kj==2) cout<<"\b解锁新兵种:精兵\n";
if(kj==3)cout<<"\b民居解锁二级产量\n";
if(kj==4) cout<<"\b解锁新兵种:骑兵\n";
if(kj==6) cout<<"\b民居解锁三级产量\n";
if(kj==7) cout<<"\b解锁新兵种:重装兵\n";
if(kj==9) {
gj++;
cout<<"\b你的士兵获得了二级攻击武器\n";
}
if(kj==11) cout<<"\b解锁新兵种:弩箭兵\n";
if(kj==12) cout<<"\b民居解锁四级产量\n";
if(kj==14) {
gj++;
cout<<"\b你的士兵获得了三级级攻击武器\n";
}
if(kj==16) cout<<"\b解锁新兵种:投石车\n";
_sleep(650);
}
else cout<<"\b科研失败\n";
}
else if(shu==1&&jf<kj*700) jfbz();
jf-=1000*kj;
}
if(shu==2) {
cout<<"\b现在可以招:步兵(1)、侦查部队(2)";
if(kj>=2) cout<<" \b、精兵(3)";
if(kj>=4) cout<<" \b、骑兵(4)";
if(kj>=7) cout<<" \b、重装兵(5)";
if(kj>=11) cout<<" \b、弩箭兵(6)";
if(kj>=16) cout<<" \b、投石车(7)";
cout<<"\n";
cin>>shu;
switch(shu) {
case 1:{
cout<<"\b招多少?\n";
cin>>shu;
if(shu>rk/3) {
cout<<"\b没有那么多人给你招\n";
break;
}
if(shu<0) {
cout<<"\b天生反骨是不是!\n";
return 0;
}
cout<<"\b共需 "<<shu*3<<" \bk经费,1确认,2取消\n";
cin>>shu1;
if(shu1==1&&jf>=shu*3) {
bl+=shu;
jf-=shu*3;
}
else if(shu1==1&&jf<shu*3) jfbz();
break;
}
case 2: {
cout<<"\b招多少?\n";
cin>>shu;
if(shu>rk/3) {
cout<<"\b没有那么多人给你招\n";
break;
}
if(shu<0) {
cout<<"\b天生反骨是不是!\n";
return 0;
}
cout<<"\b共需 "<<shu*3<<" \bk经费,1确认,2取消\n";
cin>>shu1;
if(shu1==1&&jf>=shu*3) {
zcbd+=shu;
jf-=shu*3;
}
else if(shu1==1&&jf<shu*3) jfbz();
break;
}
case 3:{
if(kj>=2) {
cout<<"\b招多少?\n";
cin>>shu;
if(shu>rk/3) {
cout<<"\b没有那么多人给你招\n";
break;
}
if(shu<0) {
cout<<"\b天生反骨是不是!\n";
return 0;
}
cout<<"\b共需 "<<shu*6<<" \bk经费,1确认,2取消\n";
cin>>shu1;
if(shu1==1&&jf>=shu*6) {
bl+=shu*2;
jf-=shu*6;
}
else if(shu1==1&&jf<shu*6) jfbz();
}
break;
}
case 4:{
if(kj>=4) {
cout<<"\b招多少?\n";
cin>>shu;
if(shu>rk/3) {
cout<<"\b没有那么多人给你招\n";
break;
}
if(shu<0) {
cout<<"\b天生反骨是不是!\n";
return 0;
}
cout<<"\b共需 "<<shu*15<<" \bk经费,1确认,2取消\n";
cin>>shu1;
if(shu1==1&&jf>=shu*15) {
bl+=shu*7;
jf-=shu*15;
}
else if(shu1==1&&jf<shu*15) jfbz();
}
break;
}
case 5:{
if(kj>=7) {
cout<<"\b招多少?\n";
cin>>shu;
if(shu>rk/3) {
cout<<"\b没有那么多人给你招\n";
break;
}
if(shu<0) {
cout<<"\b天生反骨是不是!\n";
return 0;
}
cout<<"\b共需 "<<shu*30<<" \bk经费,1确认,2取消\n";
cin>>shu1;
if(shu1==1&&jf>=shu*30) {
bl+=shu*25;
jf-=shu*30;
}
else if(shu1==1&&jf<shu*30) jfbz();
}
break;
}
case 6:{
if(kj>=11) {
cout<<"\b招多少?\n";
cin>>shu;
if(shu>rk/3) {
cout<<"\b没有那么多人给你招\n";
break;
}
if(shu<0) {
cout<<"\b天生反骨是不是!\n";
return 0;
}
cout<<"\b共需 "<<shu*35<<" \bk经费,1确认,2取消\n";
cin>>shu1;
if(shu1==1&&jf>=shu*35) {
bl+=shu*35;
jf-=shu*35;
}
else if(shu1==1&&jf<shu*35) jfbz();
}
break;
}
case 7:{
if(kj>=16) {
cout<<"\b招多少?\n";
cin>>shu;
if(shu>rk/3) {
cout<<"\b没有那么多人给你招来用投石车\n";
break;
}
if(shu<0) {
cout<<"\b天生反骨是不是!\n";
return 0;
}
cout<<"\b共需 "<<shu*500<<" \bk经费,1确认,2取消\n";
cin>>shu1;
if(shu1==1&&jf>=shu*500) {
bl+=shu*95;
jf-=shu*500;
}
}else if(shu1==1&&jf<shu*500) jfbz();
}
} //switch
}
else if(shu==3) continue;
else if(shu==5) {
std::ifstream fileIn("result.txt");
fileIn>>kj>>bl;
for(int o=0;o<6;++o) fileIn>>dfbl[o];
fileIn>>jf>>fy>>mj>>zcbd>>rk>>jfbl;
fileIn>>cqjf>>cq>>cnt>>sum>>gj;
fileIn.close();
continue;
}
else if(shu==6) {
std::ofstream fileOut("result.txt");
fileOut<<kj<<" "<<bl<<" ";
for(int i=0;i<6;++i) fileOut<<dfbl[i]<<" ";
fileOut<<jf<<" "<<fy<<" "<<mj<<" "<<zcbd<<" "<<rk<<" "<<jfbl<<" ";
fileOut<<cqjf<<" "<<cq<<" "<<cnt<<" "<<sum<<" "<<gj;
fileOut.close();
continue;
}
} //兵力
else if(shu==5) {
std::ifstream fileIn("result.txt");
fileIn>>kj>>bl;
for(int o=0;o<6;++o) fileIn>>dfbl[o];
fileIn>>jf>>fy>>mj>>zcbd>>rk>>jfbl;
fileIn>>cqjf>>cq>>cnt>>sum>>gj;
fileIn.close();
continue;
}
else if(shu==6) {
std::ofstream fileOut("result.txt");
fileOut<<kj<<" "<<bl<<" ";
for(int i=0;i<6;++i) fileOut<<dfbl[i]<<" ";
fileOut<<jf<<" "<<fy<<" "<<mj<<" "<<zcbd<<" "<<rk<<" "<<jfbl<<" ";
fileOut<<cqjf<<" "<<cq<<" "<<cnt<<" "<<sum<<" "<<gj;
fileOut.close();
continue;
}
cout<<"\b是否进行军事行动?1确认,2算了\n";
cin>>shu;
if(shu==1) jsxd();
if(sss==0) {
int sj1=rand()%10,sj2=rand()%7;
if(sj1<=(rand()%7))
if(dfbl[sj2]!=0) {
cout<<"\b他国来犯!\n";
_sleep(750);
xxs=tglf(sj2);
if(xxs==0) return 0;
}
}
bol=0;
for(int i=0;i<6;++i) if(dfbl[i]<0) bol++;
if(bol==6) break;
sss--;
sum++;
}
cout<<"\b你赢了,你是最后的赢家\n";
_sleep(850);
cout<<"\b接下来,是暴政时代......";
_sleep(750);
cout<<"\b敬请期待续集\n";
return 0;
}