相比较 1.2 ,增加了升级模块
C++战列舰小游戏Lv. 1.2版本(半成品)-CSDN博客
相比较1.3,有了大规模完善和模块增加
C++战列舰小游戏Lv. 1.3版本(半成品)-CSDN博客
这是一组初始数据:
a[1].gas=1000;
a[1].attack=0;
a[1].att_1=0;
a[1].att_2=0;
a[1].att_3=0;
a[1].att_4=0;
a[1].fire=0;
a[1].gas_good=0.9;
a[1].guard=0;
a[1].HP=15000;
a[1].name="初级战列舰";
a[1].HPm=15000;
a[1].gasm=1200;
a[1].boat[40][15]=100;
a[1].long_=70;
a[1].att_s_1=0;
a[1].att_good_1=10;
a[1].att_good_2=40;
a[1].att_good_3=15;
a[1].att_good_4=80;
a[1].Lv=1;
cpp
a[1].gas=1000;
a[1].attack=0;
a[1].att_1=0;
a[1].att_2=0;
a[1].att_3=0;
a[1].att_4=0;
a[1].fire=0;
a[1].gas_good=0.9;
a[1].guard=0;
a[1].HP=15000;
a[1].name="初级战列舰";
a[1].HPm=15000;
a[1].gasm=1200;
a[1].boat[40][15]=100;
a[1].long_=70;
a[1].att_s_1=0;
a[1].att_good_1=10;
a[1].att_good_2=40;
a[1].att_good_3=15;
a[1].att_good_4=80;
a[1].Lv=1;
这是战舰的结构体
struct zhan
{
string name;
int attack,guard;//攻击 防御
int att_1,att_2,att_3,att_4;//主炮 副炮 鱼雷 水雷
int att_s_1,att_s_2;
double att_good_1,att_good_2,att_good_3,att_good_4;
double HP,fire,HPm;
double shut_down[100],gas_good;
int gas,gasm;
double boat[150][40];
double long_;
double Lv;
};
cpp
struct zhan
{
string name;
int attack,guard;//攻击 防御
int att_1,att_2,att_3,att_4;//主炮 副炮 鱼雷 水雷
int att_s_1,att_s_2;
double att_good_1,att_good_2,att_good_3,att_good_4;
double HP,fire,HPm;
double shut_down[100],gas_good;
int gas,gasm;
double boat[150][40];
double long_;
double Lv;
};
这是染色函数(特别致谢博主:夜若渊)
void pr(const char* s, int color)
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | color);
printf(s);
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | 7);
}
/*
0 = 黑色 8 = 灰色
1 = 蓝色 9 = 淡蓝色
2 = 绿色 10 = 淡绿色
3 = 浅绿色 11 = 淡浅绿色
4 = 红色 12 = 淡红色
5 = 紫色 13 = 淡紫色
6 = 黄色 14 = 淡黄色
7 = 白色 15 = 亮白色
*/
cpp
void pr(const char* s, int color)
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | color);
printf(s);
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | 7);
}
/*
0 = 黑色 8 = 灰色
1 = 蓝色 9 = 淡蓝色
2 = 绿色 10 = 淡绿色
3 = 浅绿色 11 = 淡浅绿色
4 = 红色 12 = 淡红色
5 = 紫色 13 = 淡紫色
6 = 黄色 14 = 淡黄色
7 = 白色 15 = 亮白色
*/
新手指南
void new_do()
{
system("cls");
Sleep(50);
cout<<setw(50)<<"----------新手指南----------"<<'\n';
cout<<"敌方会有1~3艘 旗舰(战列舰) ";
cout<<"它们的正面装甲级厚,尽量使用鱼雷或在侧面使用主炮攻击"<<'\n';
cout<<"敌方会有3~10艘副舰(驱逐舰、护卫舰)"<<'\n';
cout<<"它们防空能力强悍,副炮数量极多,就连战机都很难靠近它们,想办法用潜艇鱼雷攻击它们"<<'\n';
cout<<"敌方可能会有潜艇,如果你没有反潜设备就要小心了,它们不会出现在《战舰清单》中"<<'\n';
cout<<"你在开始游戏时会有1艘(几乎)空荡荡的战列舰"<<'\n';
cout<<"你可以在 加工厂 升级战舰"<<'\n';
cout<<"你可以在 制造厂 制造战列舰(的空壳,几乎啥都没有)"<<'\n';
cout<<"提示"<<'\n';
cout<<"战列舰的所有数据都在 战舰情况 中,随时可以查看"<<'\n';
cout<<"刚开始你会有 4000w 资金,到了游戏中你就会知道,这远远不够"<<'\n';
cout<<"这是战列舰时代的游戏,没有导弹"<<'\n';
system("pause");
}
cpp
void new_do()
{
system("cls");
Sleep(50);
cout<<setw(50)<<"----------新手指南----------"<<'\n';
cout<<"敌方会有1~3艘 旗舰(战列舰) ";
cout<<"它们的正面装甲级厚,尽量使用鱼雷或在侧面使用主炮攻击"<<'\n';
cout<<"敌方会有3~10艘副舰(驱逐舰、护卫舰)"<<'\n';
cout<<"它们防空能力强悍,副炮数量极多,就连战机都很难靠近它们,想办法用潜艇鱼雷攻击它们"<<'\n';
cout<<"敌方可能会有潜艇,如果你没有反潜设备就要小心了,它们不会出现在《战舰清单》中"<<'\n';
cout<<"你在开始游戏时会有1艘(几乎)空荡荡的战列舰"<<'\n';
cout<<"你可以在 加工厂 升级战舰"<<'\n';
cout<<"你可以在 制造厂 制造战列舰(的空壳,几乎啥都没有)"<<'\n';
cout<<"提示"<<'\n';
cout<<"战列舰的所有数据都在 战舰情况 中,随时可以查看"<<'\n';
cout<<"刚开始你会有 4000w 资金,到了游戏中你就会知道,这远远不够"<<'\n';
cout<<"这是战列舰时代的游戏,没有导弹"<<'\n';
system("pause");
}
完整半成品代码:
cpp
#include <bits/stdc++.h>
#include <time.h>
#include <windows.h>
#include <stdlib.h>
#include <unistd.h>
#include <conio.h>
#include <fstream>
using namespace std;
bool sea;
int km=0;
bool look[100][100];
long long money=4000000000;
int shuliang=1;
struct zhan
{
string name;
int attack,guard;//攻击 防御
int att_1,att_2,att_3,att_4;//主炮 副炮 鱼雷 水雷
int att_s_1,att_s_2;
int att_good_1,att_good_2,att_good_3,att_good_4;
double HP,fire,HPm;
double shut_down[20];
int gas_good;
int gas,gasm;
int boat[90][40];
int long_;
int Lv;
};
zhan a[50];
void pr(const char* s, int color)
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | color);
printf(s);
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | 7);
}
/*
0 = 黑色 8 = 灰色
1 = 蓝色 9 = 淡蓝色
2 = 绿色 10 = 淡绿色
3 = 浅绿色 11 = 淡浅绿色
4 = 红色 12 = 淡红色
5 = 紫色 13 = 淡紫色
6 = 黄色 14 = 淡黄色
7 = 白色 15 = 亮白色
*/
void new_do()
{
system("cls");
Sleep(50);
cout<<setw(50)<<"----------新手指南----------"<<'\n';
cout<<"敌方会有1~3艘 旗舰(战列舰) ";
cout<<"它们的正面装甲级厚,尽量使用鱼雷或在侧面使用主炮攻击"<<'\n';
cout<<"敌方会有3~10艘副舰(驱逐舰、护卫舰)"<<'\n';
cout<<"它们防空能力强悍,副炮数量极多,就连战机都很难靠近它们,想办法用潜艇鱼雷攻击它们"<<'\n';
cout<<"敌方可能会有潜艇,如果你没有反潜设备就要小心了,它们不会出现在《战舰清单》中"<<'\n';
cout<<"你在开始游戏时会有1艘(几乎)空荡荡的战列舰"<<'\n';
cout<<"你可以在 加工厂 升级战舰"<<'\n';
cout<<"你可以在 制造厂 制造战列舰(的空壳,几乎啥都没有)"<<'\n';
cout<<"提示"<<'\n';
cout<<"战列舰的所有数据都在 战舰情况 中,随时可以查看"<<'\n';
cout<<"刚开始你会有 4000w 资金,到了游戏中你就会知道,这远远不够"<<'\n';
cout<<"这是战列舰时代的游戏,没有导弹"<<'\n';
system("pause");
}
void fight()
{
}
void up_gas()
{
cout<<"这里是加油站----------"<<'\n';
for(int i=1; i<=shuliang; i++)
{
Sleep(500);
system("cls");
cout<<i<<" "<<a[i].name<<":"<<a[i].gas<<"/"<<a[i].gasm<<'\n';
cout<<" 可以航行"<<a[i].gas*a[i].gas_good<<"km (需要在"<<a[i].gas*a[i].gas_good/2.0<<"km返回)";
cout<<'\n';
if(a[i].gas==0) pr("必须加油",4);
else if(a[i].gas>0&&a[i].gas!=a[i].gasm) pr("可以加油",6);
else pr("无需加油",2);
cout<<"(y/n)"<<'\n';
string xz;
cin>>xz;
if(xz=="y"||xz=="Y")
{
cout<<"正在加油..."<<'\n';
system("pause");
Sleep(500);
if(a[i].gasm==a[i].gas) cout<<"无需加油--"<<'\n';
else
{
long long money_want=(a[i].gasm-a[i].gas)/(a[i].gas_good)*600;
cout<<"需要"<<money_want<<"资金"<<'\n';
if(money_want>money)
{
cout<<"资金不足,为您尽量加油↖(^ω^)↗"<<'\n';
a[i].gas=a[i].gas+money/600*a[i].gas_good;
money=0;
}
else
{
money-=money_want;
a[i].gas=a[i].gasm;
}
cout<<"加油完成---"<<'\n';
cout<<i<<" "<<a[i].name<<":"<<a[i].gas<<"/"<<a[i].gasm<<'\n';
cout<<" 可以航行"<<a[i].gas/a[i].gas_good<<"km (需要在"<<a[i].gas/a[i].gas_good/2.0<<"km返回)";
cout<<'\n';
if(a[i].gas==0) pr("必须加油",4);
else if(a[i].gas>0&&a[i].gas!=a[i].gasm) pr("可以加油",6);
else pr("无需加油",2);
cout<<'\n';
}
}
else
{
cout<<'\n';
system("pause");
}
}
cout<<'\n';
system("pause");
}
void up_on1()
{
for(int i=1; i<=shuliang; i++)
{
cout<<i<<" "<<a[i].name<<": Lv. "<<a[i].Lv<<'\n';
a[i].HP=a[i].HPm;
cout<<"0 不升级 下一个"<<'\n';
cout<<"1 血量:"<<a[i].HP<<" / "<<a[i].HPm<<'\n';
cout<<"2 油量:"<<a[i].gas<<" / "<<a[i].gasm<<'\n';
cout<<"3 燃油等级:"<<a[i].gas_good<<"/1 (越小越好)"<<'\n';
cout<<"4 长度:"<<a[i].long_<<"m"<<'\n';
cout<<"5 主炮数量:"<<a[i].att_1<<'\n';
cout<<"6 精准度:"<<a[i].att_good_1<<"%"<<'\n';
cout<<"7 副炮数量:"<<a[i].att_2<<'\n';
cout<<"8 精准度:"<<a[i].att_good_2<<"%"<<'\n';
cout<<"9 鱼雷精准度:"<<a[i].att_good_3<<"%"<<'\n';
cout<<"10 水雷精准度:"<<a[i].att_good_4<<"%"<<'\n';
cout<<'\n';
system("pause");
short k;
cin>>k;
double l;
switch(k)
{
case 0:
break;
case 1:
cout<<"血量升级价格:2点/资金 等级≥5时 5点/资金"<<'\n';
cout<<"购买血量(最大";
if(a[i].Lv>=5) cout<<money*5,l=money*5;
else cout<<money*2,l=money*2;
cout<<") : ";
double xz;
cin>>xz;
while(xz>l) cout<<"Error!",cin>>xz;
if(a[i].Lv>=5) l=xz*5;
else l=xz*2;
money-=l;
a[i].HPm+=xz;
break;
case 2:
cout<<"油量升级价格:1点/资金 等级≥10时 2点/资金"<<'\n';
cout<<"购买油量(最大";
if(a[i].Lv>=5) cout<<money*1,l=money*1;
else cout<<money,l=money;
cout<<") : ";
cin>>xz;
while(xz>l) cout<<"Error!",cin>>xz;
if(a[i].Lv>=10) l=xz*2;
else l=xz;
money-=l;
a[i].gasm+=xz;
break;
case 3:
cout<<"90w变为1(需要将该舰现有油量清零)"<<'\n';
if(money>=900000) a[i].gas_good=1,a[i].gas=0,money-=900000;
else system("pause");
break;
case 4:
cout<<"长度升级价格:5w/m"<<'\n';
cout<<"购买长度(最大";
cout<<fixed<<setprecision(2)<<money/5.0,l=money/5.0;
cout<<") : ";
cin>>xz;
while(xz>l) cout<<"Error!",cin>>xz;
l=xz*50000;
money-=l;
a[i].long_+=xz;
break;
case 5:
if(a[i].long_-a[i].att_1*2-a[i].att_2*2-a[i].att_1*1-a[i].att_1*1-a[i].gasm/100<2)
{
cout<<"甲板不够,去加长甲板吧"<<'\n';
}
else
{
cout<<"口径:1 80mm 10w"<<'\n';
cout<<" 2 95mm 12w"<<'\n';
cout<<" 3 110mm 20w"<<'\n';
cout<<" 4 160mm 50w"<<'\n';
cout<<" 5 320mm 90w"<<'\n';
}
int kj;
cin>>kj;
if(kj==1)
{
a[i].att_1++;
a[i].attack+=80;
money-=100000;
}
if(kj==2)
{
a[i].att_1++;
a[i].attack+=95;
money-=120000;
}
if(kj==3)
{
a[i].att_1++;
a[i].attack+=110;
money-=200000;
}
if(kj==4)
{
a[i].att_1++;
a[i].attack+=160;
money-=500000;
}
if(kj==5)
{
a[i].att_1++;
a[i].attack+=320;
money-=900000;
}
break;
case 6:
cout<<"精准度升级为 5000资金/ 0.1%"<<'\n';
cout<<"输入投入资金:";
int mon;
cin>>mon;
money-=mon;
a[i].att_good_1++;
break;
case 7:
if(a[i].long_-a[i].att_1*2-a[i].att_2*2-a[i].att_1*1-a[i].att_1*1-a[i].gasm/100<1)
{
cout<<"甲板不够,去加长甲板吧"<<'\n';
}
else
{
cout<<"口径:1 10mm 10w"<<'\n';
cout<<" 2 25mm 12w"<<'\n';
cout<<" 3 50mm 20w"<<'\n';
cout<<" 4 60mm 50w"<<'\n';
cout<<" 5 70mm 90w"<<'\n';
}
cin>>kj;
if(kj==1)
{
a[i].att_2++;
a[i].attack+=10;
money-=100000;
}
if(kj==2)
{
a[i].att_2++;
a[i].attack+=25;
money-=120000;
}
if(kj==3)
{
a[i].att_2++;
a[i].attack+=50;
money-=200000;
}
if(kj==4)
{
a[i].att_2++;
a[i].attack+=60;
money-=500000;
}
if(kj==5)
{
a[i].att_2++;
a[i].attack+=70;
money-=900000;
}
break;
/*
cout<<"8 精准度:"<<a[i].att_good_2<<"%"<<'\n';
cout<<"9 鱼雷精准度:"<<a[i].att_good_3<<"%"<<'\n';
cout<<"10 水雷精准度:"<<a[i].att_good_4<<"%"<<'\n';
*/
case 8:
cout<<"精准度升级为 5000资金/ 0.1%"<<'\n';
cout<<"输入投入资金:";
cin>>mon;
money-=mon;
a[i].att_good_2++;
break;
case 9:
cout<<"精准度升级为 5000资金/ 0.1%"<<'\n';
cout<<"输入投入资金:";
cin>>mon;
money-=mon;
a[i].att_good_3++;
break;
case 10:
cout<<"精准度升级为 5000资金/ 0.1%"<<'\n';
cout<<"输入投入资金:";
cin>>mon;
money-=mon;
a[i].att_good_4++;
break;
}
}
}
void up_build()
{
int xz;
cout<<"需要:"<<'\n';
cout<<"1 驱逐舰 7500w"<<'\n';
cout<<"2 护卫舰 7500w"<<'\n';
cout<<"3 巡洋舰 8000w"<<'\n';
cout<<"4 战列舰 9500w"<<'\n';
cout<<"5 潜艇 7000w"<<'\n';
cout<<"6 弹药"<<'\n';
cin>>xz;
string namel;
if(xz==1)
{
money-=75000000;
cout<<"名字:";
while(cin>>namel)
{
int f=1;
for(int i=1; i<=shuliang; i++)
{
if(a[i].name==namel)
{
f=0;
cout<<"已有重复名称"<<'\n';
}
}
if(f==1) break;
}
a[shuliang+1].gas=500;
a[shuliang+1].attack=0;
a[shuliang+1].att_1=0;
a[shuliang+1].att_2=0;
a[shuliang+1].att_3=0;
a[shuliang+1].att_4=0;
a[shuliang+1].fire=0;
a[shuliang+1].gas_good=10;
a[shuliang+1].guard=0;
a[shuliang+1].HP=6000;
a[shuliang+1].name=namel;
a[shuliang+1].HPm=6000;
a[shuliang+1].gasm=700;
a[shuliang+1].boat[40][15]=100;
a[shuliang+1].long_=40;
a[shuliang+1].att_s_1=0;
a[shuliang+1].att_good_1=50;
a[shuliang+1].att_good_2=50;
a[shuliang+1].att_good_3=95;
a[shuliang+1].att_good_4=90;
a[shuliang+1].Lv=1;
shuliang++;
}
if(xz==2)
{
money-=75000000;
cout<<"名字:";
while(cin>>namel)
{
int f=1;
for(int i=1; i<=shuliang; i++)
{
if(a[i].name==namel)
{
f=0;
cout<<"已有重复名称"<<'\n';
}
}
if(f==1) break;
}
a[shuliang+1].gas=500;
a[shuliang+1].attack=0;
a[shuliang+1].att_1=0;
a[shuliang+1].att_2=0;
a[shuliang+1].att_3=0;
a[shuliang+1].att_4=0;
a[shuliang+1].fire=0;
a[shuliang+1].gas_good=10;
a[shuliang+1].guard=0;
a[shuliang+1].HP=7000;
a[shuliang+1].name=namel;
a[shuliang+1].HPm=7000;
a[shuliang+1].gasm=900;
a[shuliang+1].boat[40][15]=100;
a[shuliang+1].long_=40;
a[shuliang+1].att_s_1=0;
a[shuliang+1].att_good_1=60;
a[shuliang+1].att_good_2=60;
a[shuliang+1].att_good_3=75;
a[shuliang+1].att_good_4=82;
a[shuliang+1].Lv=1;
shuliang++;
}
if(xz==3)
{
money-=80000000;
cout<<"名字:";
string namel;
while(cin>>namel)
{
int f=1;
for(int i=1; i<=shuliang; i++)
{
if(a[i].name==namel)
{
f=0;
cout<<"已有重复名称"<<'\n';
}
}
if(f==1) break;
}
a[shuliang+1].gas=1000;
a[shuliang+1].attack=0;
a[shuliang+1].att_1=0;
a[shuliang+1].att_2=0;
a[shuliang+1].att_3=0;
a[shuliang+1].att_4=0;
a[shuliang+1].fire=0;
a[shuliang+1].gas_good=10;
a[shuliang+1].guard=0;
a[shuliang+1].HP=10000;
a[shuliang+1].name=namel;
a[shuliang+1].HPm=10000;
a[shuliang+1].gasm=1200;
a[shuliang+1].boat[40][15]=100;
a[shuliang+1].long_=70;
a[shuliang+1].att_s_1=0;
a[shuliang+1].att_good_1=10;
a[shuliang+1].att_good_2=40;
a[shuliang+1].att_good_3=15;
a[shuliang+1].att_good_4=80;
a[shuliang+1].Lv=1;
shuliang++;
}
if(xz==4)
{
money-=95000000;
cout<<"名字:";
string namel;
while(cin>>namel)
{
int f=1;
for(int i=1; i<=shuliang; i++)
{
if(a[i].name==namel)
{
f=0;
cout<<"已有重复名称"<<'\n';
}
}
if(f==1) break;
}
a[shuliang+1].gas=1000;
a[shuliang+1].attack=0;
a[shuliang+1].att_1=0;
a[shuliang+1].att_2=0;
a[shuliang+1].att_3=0;
a[shuliang+1].att_4=0;
a[shuliang+1].fire=0;
a[shuliang+1].gas_good=10;
a[shuliang+1].guard=0;
a[shuliang+1].HP=15000;
a[shuliang+1].name=namel;
a[shuliang+1].HPm=15000;
a[shuliang+1].gasm=1200;
a[shuliang+1].boat[40][15]=100;
a[shuliang+1].long_=70;
a[shuliang+1].att_s_1=0;
a[shuliang+1].att_good_1=10;
a[shuliang+1].att_good_2=40;
a[shuliang+1].att_good_3=15;
a[shuliang+1].att_good_4=80;
a[shuliang+1].Lv=1;
shuliang++;
}
if(xz==5)
{
money-=70000000;
cout<<"名字:";
while(cin>>namel)
{
int f=1;
for(int i=1; i<=shuliang; i++)
{
if(a[i].name==namel)
{
f=0;
cout<<"已有重复名称"<<'\n';
}
}
if(f==1) break;
}
a[shuliang+1].gas=1500;
a[shuliang+1].attack=0;
a[shuliang+1].att_1=0;
a[shuliang+1].att_2=0;
a[shuliang+1].att_3=0;
a[shuliang+1].att_4=0;
a[shuliang+1].fire=0;
a[shuliang+1].gas_good=10;
a[shuliang+1].guard=0;
a[shuliang+1].HP=1000;
a[shuliang+1].name=namel;
a[shuliang+1].HPm=1000;
a[shuliang+1].gasm=3500;
a[shuliang+1].boat[40][3]=100;
a[shuliang+1].long_=8;
a[shuliang+1].att_s_1=0;
a[shuliang+1].att_good_1=0;
a[shuliang+1].att_good_2=0;
a[shuliang+1].att_good_3=95;
a[shuliang+1].att_good_4=90;
a[shuliang+1].Lv=1;
shuliang++;
}
if(xz==6)
{
for(int i=1; i<=shuliang; i++)
{
cout<<a[i].name;
cout<<"1 主炮弹药数量:";
int l=a[i].att_s_1;
cout<<l<<'\n';
if(l==0) pr("没有弹药 建议增添",4);
else if(l<=30) pr("弹药较少 建议增添",6);
else pr("基本足够(仅为评估)",2);
cout<<'\n';
int want;
cout<<"输入需要弹药(40w/枚)数量:";
cin>>want;
money-=want*400000;
a[i].att_s_1+=want;
cout<<"2 副炮弹药数量:";
l=a[i].att_s_2;
cout<<l<<'\n';
if(l==0) pr("没有弹药 建议增添",4);
else if(l<=30) pr("弹药较少 建议增添",6);
else pr("基本足够(仅为评估)",2);
cout<<'\n';
cout<<"输入需要弹药(40w/枚)数量:";
cin>>want;
money-=want*400000;
a[i].att_s_2+=want;
}
}
cout<<"OK"<<'\n';
return ;
}
void up()
{
cout<<"1 加油站"<<'\n';
cout<<"2 加工厂"<<'\n';
cout<<"3 制造厂"<<'\n';
cout<<"4 出航" <<'\n';
cout<<"5 查看状态"<<'\n';
string xz;
cin>>xz;
while(xz!="1"&&xz!="2"&&xz!="3"&&xz!="4"&&xz!="5")
{
cout<<"错误--- 请再次输入"<<'\n';
system("pause");
cin>>xz;
}
int xz_int=stoi(xz);
switch(xz_int)
{
case 1:
up_gas();
break;
case 2:
up_on1();
break;
case 3:
up_build();
break;
case 4:
break;
default:
break;
}
}
void play()
{
shuliang=1;
a[1].gas=1000;
a[1].attack=0;
a[1].att_1=0;
a[1].att_2=0;
a[1].att_3=0;
a[1].att_4=0;
a[1].fire=0;
a[1].gas_good=10;
a[1].guard=0;
a[1].HP=15000;
a[1].name="max fight 1";
a[1].HPm=15000;
a[1].gasm=1200;
a[1].boat[40][15]=100;
a[1].long_=70;
a[1].att_s_1=0;
a[1].att_good_1=10;
a[1].att_good_2=40;
a[1].att_good_3=15;
a[1].att_good_4=80;
a[1].Lv=1;
cout<<"游戏开始"<<'\n';
system("pause");
system("cls");
while(1+1==2)
{
system("cls");
cout<<"游戏进行中----------"<<'\n';
system("pause");
cout<<"资金:"<<money;
if(money<-10000000)
{
cout<<"欠债过多 挑战失败"<<'\n';
return ;
}
if(sea)
{
for(int i=1; i<=shuliang; i++)
{
int f=100;
cout<<a[i].name<<":"<<'\n';
cout<<"该舰艇现在距离基地"<<km<<"km,需要"<<km*a[i].gas_good<<"升燃油"<<'\n';
if(a[i].fire==0) pr("舰艇无火灾",2),cout<<'\n';
else if(a[i].fire>0&&a[i].fire<=1.5) pr("舰艇火灾警告",6),f-=0.1,cout<<'\n';
else if(a[i].fire<=5) pr("中等火灾警告",6),f-=5,cout<<'\n';
else if(a[i].fire<=10) pr("最高火灾警告->立即返航/弃船",4),f-=40,cout<<'\n';
if(km*a[i].gas_good>=a[i].gas*2) pr("最高油量警告->立即返航",4),f-=40,cout<<'\n';
else if(km*a[i].gas_good>=a[i].gas) pr("油量警告",6),f-=35,cout<<'\n';
if(a[i].HP<=100) pr("重伤警告->立即返航/弃船",4),f-=60,cout<<'\n';
else if(a[i].HP<=1000) pr("警告->注意躲避火力",6),f-=20,cout<<'\n';
cout<<"1 主炮弹药数量:";
int l=a[i].att_s_1;
cout<<l<<'\n';
if(l==0) pr("没有弹药 建议增添",4);
else if(l<=30) pr("弹药较少 建议增添",6);
else pr("基本足够(仅为评估)",2);
cout<<'\n';
cout<<"2 副炮弹药数量:";
l=a[i].att_s_2;
cout<<l<<'\n';
if(l==0) pr("没有弹药 建议增添",4);
else if(l<=30) pr("弹药较少 建议增添",6);
else pr("基本足够(仅为评估)",2);
cout<<'\n';
if(a[i].att_1==0) pr("主炮不足",4),cout<<'\n';
if(a[i].att_2==0) pr("副炮不足",4),cout<<'\n';
if(a[i].att_2==0) pr("鱼雷不足",4),cout<<'\n';
if(a[i].att_2==0) pr("水雷不足",4),cout<<'\n';
if(f<0) pr("结果->立即返航/弃船",4),cout<<'\n';
else if(f<=50) pr("结果->准备返航",4),cout<<'\n';
else if(f<=70) pr("结果->状态一般",6),cout<<'\n';
else pr("结果->状态良好",2),cout<<'\n';
}
fight();
}
else
{
for(int i=1; i<=shuliang; i++)
{
cout<<i<<" "<<a[i].name<<'\n';
a[i].HP=a[i].HPm;
int f=100;
if(a[i].gas<=0) pr("油量警告->必须加油",4),f-=40,cout<<'\n';
else if(a[i].gas<=100) pr("油量警告->需要加油",4),f-=40,cout<<'\n';
else if(a[i].gas<=400) pr("油量警告",6),f-=35,cout<<'\n';
cout<<"血量:"<<a[i].HP<<" / "<<a[i].HPm<<'\n';
cout<<"油量:"<<a[i].gas<<" / "<<a[i].gasm<<'\n';
cout<<"长度:"<<a[i].long_<<'\n';
cout<<"主炮数量:"<<a[i].att_1<<'\n';
cout<<"副炮数量:"<<a[i].att_2<<'\n';
cout<<"1 主炮弹药数量:";
int l=a[i].att_s_1;
cout<<l<<'\n';
if(l==0) pr("没有弹药 建议增添",4);
else if(l<=30) pr("弹药较少 建议增添",6);
else pr("基本足够(仅为评估)",2);
cout<<'\n';
cout<<"2 副炮弹药数量:";
l=a[i].att_s_2;
cout<<l<<'\n';
if(l==0) pr("没有弹药 建议增添",4);
else if(l<=30) pr("弹药较少 建议增添",6);
else pr("基本足够(仅为评估)",2);
cout<<'\n';
if(a[i].att_1==0) pr("主炮不足",4),cout<<'\n';
if(a[i].att_2==0) pr("副炮不足",4),cout<<'\n';
if(a[i].att_2==0) pr("鱼雷不足",4),cout<<'\n';
if(a[i].att_2==0) pr("水雷不足",4),cout<<'\n';
cout<<'\n';
if(f<0) pr("结果->状态极差",4),cout<<'\n';
else if(f<=50) pr("结果->状态不好",4),cout<<'\n';
else if(f<=70) pr("结果->状态一般",6),cout<<'\n';
else pr("结果->状态良好",2),cout<<'\n';
}
up();
}
sleep(1);
}
}
int main()
{
a[1].gas=1000;
a[1].attack=0;
a[1].att_1=0;
a[1].att_2=0;
a[1].att_3=0;
a[1].att_4=0;
a[1].fire=0;
a[1].gas_good=10;
a[1].guard=0;
a[1].HP=15000;
a[1].name="max fight 1";
a[1].HPm=15000;
a[1].gasm=1200;
a[1].boat[40][15]=100;
a[1].long_=70;
a[1].att_s_1=0;
a[1].att_good_1=10;
a[1].att_good_2=40;
a[1].att_good_3=15;
a[1].att_good_4=80;
a[1].Lv=1;
cout<<"是否需要新手指南?(y/n)"<<'\n';
char xing;
cin>>xing;
if(xing=='y') new_do();
play();
cout<<"感谢游玩 个人主页: https://blog.csdn.net/YYDS314?type=blog"<<'\n';
return 0;
}
#include <bits/stdc++.h>
#include <time.h>
#include <windows.h>
#include <stdlib.h>
#include <unistd.h>
#include <conio.h>
#include <fstream>
using namespace std;
bool sea;
int km=0;
bool look[100][100];
long long money=4000000000;
int shuliang=1;
struct zhan
{
string name;
int attack,guard;//攻击 防御
int att_1,att_2,att_3,att_4;//主炮 副炮 鱼雷 水雷
int att_s_1,att_s_2;
int att_good_1,att_good_2,att_good_3,att_good_4;
double HP,fire,HPm;
double shut_down[20];
int gas_good;
int gas,gasm;
int boat[90][40];
int long_;
int Lv;
};
zhan a[50];
void pr(const char* s, int color)
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | color);
printf(s);
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | 7);
}
/*
0 = 黑色 8 = 灰色
1 = 蓝色 9 = 淡蓝色
2 = 绿色 10 = 淡绿色
3 = 浅绿色 11 = 淡浅绿色
4 = 红色 12 = 淡红色
5 = 紫色 13 = 淡紫色
6 = 黄色 14 = 淡黄色
7 = 白色 15 = 亮白色
*/
void new_do()
{
system("cls");
Sleep(50);
cout<<setw(50)<<"----------新手指南----------"<<'\n';
cout<<"敌方会有1~3艘 旗舰(战列舰) ";
cout<<"它们的正面装甲级厚,尽量使用鱼雷或在侧面使用主炮攻击"<<'\n';
cout<<"敌方会有3~10艘副舰(驱逐舰、护卫舰)"<<'\n';
cout<<"它们防空能力强悍,副炮数量极多,就连战机都很难靠近它们,想办法用潜艇鱼雷攻击它们"<<'\n';
cout<<"敌方可能会有潜艇,如果你没有反潜设备就要小心了,它们不会出现在《战舰清单》中"<<'\n';
cout<<"你在开始游戏时会有1艘(几乎)空荡荡的战列舰"<<'\n';
cout<<"你可以在 加工厂 升级战舰"<<'\n';
cout<<"你可以在 制造厂 制造战列舰(的空壳,几乎啥都没有)"<<'\n';
cout<<"提示"<<'\n';
cout<<"战列舰的所有数据都在 战舰情况 中,随时可以查看"<<'\n';
cout<<"刚开始你会有 4000w 资金,到了游戏中你就会知道,这远远不够"<<'\n';
cout<<"这是战列舰时代的游戏,没有导弹"<<'\n';
system("pause");
}
void fight()
{
}
void up_gas()
{
cout<<"这里是加油站----------"<<'\n';
for(int i=1; i<=shuliang; i++)
{
Sleep(500);
system("cls");
cout<<i<<" "<<a[i].name<<":"<<a[i].gas<<"/"<<a[i].gasm<<'\n';
cout<<" 可以航行"<<a[i].gas*a[i].gas_good<<"km (需要在"<<a[i].gas*a[i].gas_good/2.0<<"km返回)";
cout<<'\n';
if(a[i].gas==0) pr("必须加油",4);
else if(a[i].gas>0&&a[i].gas!=a[i].gasm) pr("可以加油",6);
else pr("无需加油",2);
cout<<"(y/n)"<<'\n';
string xz;
cin>>xz;
if(xz=="y"||xz=="Y")
{
cout<<"正在加油..."<<'\n';
system("pause");
Sleep(500);
if(a[i].gasm==a[i].gas) cout<<"无需加油--"<<'\n';
else
{
long long money_want=(a[i].gasm-a[i].gas)/(a[i].gas_good)*600;
cout<<"需要"<<money_want<<"资金"<<'\n';
if(money_want>money)
{
cout<<"资金不足,为您尽量加油↖(^ω^)↗"<<'\n';
a[i].gas=a[i].gas+money/600*a[i].gas_good;
money=0;
}
else
{
money-=money_want;
a[i].gas=a[i].gasm;
}
cout<<"加油完成---"<<'\n';
cout<<i<<" "<<a[i].name<<":"<<a[i].gas<<"/"<<a[i].gasm<<'\n';
cout<<" 可以航行"<<a[i].gas/a[i].gas_good<<"km (需要在"<<a[i].gas/a[i].gas_good/2.0<<"km返回)";
cout<<'\n';
if(a[i].gas==0) pr("必须加油",4);
else if(a[i].gas>0&&a[i].gas!=a[i].gasm) pr("可以加油",6);
else pr("无需加油",2);
cout<<'\n';
}
}
else
{
cout<<'\n';
system("pause");
}
}
cout<<'\n';
system("pause");
}
void up_on1()
{
for(int i=1; i<=shuliang; i++)
{
cout<<i<<" "<<a[i].name<<": Lv. "<<a[i].Lv<<'\n';
a[i].HP=a[i].HPm;
cout<<"0 不升级 下一个"<<'\n';
cout<<"1 血量:"<<a[i].HP<<" / "<<a[i].HPm<<'\n';
cout<<"2 油量:"<<a[i].gas<<" / "<<a[i].gasm<<'\n';
cout<<"3 燃油等级:"<<a[i].gas_good<<"/1 (越小越好)"<<'\n';
cout<<"4 长度:"<<a[i].long_<<"m"<<'\n';
cout<<"5 主炮数量:"<<a[i].att_1<<'\n';
cout<<"6 精准度:"<<a[i].att_good_1<<"%"<<'\n';
cout<<"7 副炮数量:"<<a[i].att_2<<'\n';
cout<<"8 精准度:"<<a[i].att_good_2<<"%"<<'\n';
cout<<"9 鱼雷精准度:"<<a[i].att_good_3<<"%"<<'\n';
cout<<"10 水雷精准度:"<<a[i].att_good_4<<"%"<<'\n';
cout<<'\n';
system("pause");
short k;
cin>>k;
double l;
switch(k)
{
case 0:
break;
case 1:
cout<<"血量升级价格:2点/资金 等级≥5时 5点/资金"<<'\n';
cout<<"购买血量(最大";
if(a[i].Lv>=5) cout<<money*5,l=money*5;
else cout<<money*2,l=money*2;
cout<<") : ";
double xz;
cin>>xz;
while(xz>l) cout<<"Error!",cin>>xz;
if(a[i].Lv>=5) l=xz*5;
else l=xz*2;
money-=l;
a[i].HPm+=xz;
break;
case 2:
cout<<"油量升级价格:1点/资金 等级≥10时 2点/资金"<<'\n';
cout<<"购买油量(最大";
if(a[i].Lv>=5) cout<<money*1,l=money*1;
else cout<<money,l=money;
cout<<") : ";
cin>>xz;
while(xz>l) cout<<"Error!",cin>>xz;
if(a[i].Lv>=10) l=xz*2;
else l=xz;
money-=l;
a[i].gasm+=xz;
break;
case 3:
cout<<"90w变为1(需要将该舰现有油量清零)"<<'\n';
if(money>=900000) a[i].gas_good=1,a[i].gas=0,money-=900000;
else system("pause");
break;
case 4:
cout<<"长度升级价格:5w/m"<<'\n';
cout<<"购买长度(最大";
cout<<fixed<<setprecision(2)<<money/5.0,l=money/5.0;
cout<<") : ";
cin>>xz;
while(xz>l) cout<<"Error!",cin>>xz;
l=xz*50000;
money-=l;
a[i].long_+=xz;
break;
case 5:
if(a[i].long_-a[i].att_1*2-a[i].att_2*2-a[i].att_1*1-a[i].att_1*1-a[i].gasm/100<2)
{
cout<<"甲板不够,去加长甲板吧"<<'\n';
}
else
{
cout<<"口径:1 80mm 10w"<<'\n';
cout<<" 2 95mm 12w"<<'\n';
cout<<" 3 110mm 20w"<<'\n';
cout<<" 4 160mm 50w"<<'\n';
cout<<" 5 320mm 90w"<<'\n';
}
int kj;
cin>>kj;
if(kj==1)
{
a[i].att_1++;
a[i].attack+=80;
money-=100000;
}
if(kj==2)
{
a[i].att_1++;
a[i].attack+=95;
money-=120000;
}
if(kj==3)
{
a[i].att_1++;
a[i].attack+=110;
money-=200000;
}
if(kj==4)
{
a[i].att_1++;
a[i].attack+=160;
money-=500000;
}
if(kj==5)
{
a[i].att_1++;
a[i].attack+=320;
money-=900000;
}
break;
case 6:
cout<<"精准度升级为 5000资金/ 0.1%"<<'\n';
cout<<"输入投入资金:";
int mon;
cin>>mon;
money-=mon;
a[i].att_good_1++;
break;
case 7:
if(a[i].long_-a[i].att_1*2-a[i].att_2*2-a[i].att_1*1-a[i].att_1*1-a[i].gasm/100<1)
{
cout<<"甲板不够,去加长甲板吧"<<'\n';
}
else
{
cout<<"口径:1 10mm 10w"<<'\n';
cout<<" 2 25mm 12w"<<'\n';
cout<<" 3 50mm 20w"<<'\n';
cout<<" 4 60mm 50w"<<'\n';
cout<<" 5 70mm 90w"<<'\n';
}
cin>>kj;
if(kj==1)
{
a[i].att_2++;
a[i].attack+=10;
money-=100000;
}
if(kj==2)
{
a[i].att_2++;
a[i].attack+=25;
money-=120000;
}
if(kj==3)
{
a[i].att_2++;
a[i].attack+=50;
money-=200000;
}
if(kj==4)
{
a[i].att_2++;
a[i].attack+=60;
money-=500000;
}
if(kj==5)
{
a[i].att_2++;
a[i].attack+=70;
money-=900000;
}
break;
/*
cout<<"8 精准度:"<<a[i].att_good_2<<"%"<<'\n';
cout<<"9 鱼雷精准度:"<<a[i].att_good_3<<"%"<<'\n';
cout<<"10 水雷精准度:"<<a[i].att_good_4<<"%"<<'\n';
*/
case 8:
cout<<"精准度升级为 5000资金/ 0.1%"<<'\n';
cout<<"输入投入资金:";
cin>>mon;
money-=mon;
a[i].att_good_2++;
break;
case 9:
cout<<"精准度升级为 5000资金/ 0.1%"<<'\n';
cout<<"输入投入资金:";
cin>>mon;
money-=mon;
a[i].att_good_3++;
break;
case 10:
cout<<"精准度升级为 5000资金/ 0.1%"<<'\n';
cout<<"输入投入资金:";
cin>>mon;
money-=mon;
a[i].att_good_4++;
break;
}
}
}
void up_build()
{
int xz;
cout<<"需要:"<<'\n';
cout<<"1 驱逐舰 7500w"<<'\n';
cout<<"2 护卫舰 7500w"<<'\n';
cout<<"3 巡洋舰 8000w"<<'\n';
cout<<"4 战列舰 9500w"<<'\n';
cout<<"5 潜艇 7000w"<<'\n';
cout<<"6 弹药"<<'\n';
cin>>xz;
string namel;
if(xz==1)
{
money-=75000000;
cout<<"名字:";
while(cin>>namel)
{
int f=1;
for(int i=1; i<=shuliang; i++)
{
if(a[i].name==namel)
{
f=0;
cout<<"已有重复名称"<<'\n';
}
}
if(f==1) break;
}
a[shuliang+1].gas=500;
a[shuliang+1].attack=0;
a[shuliang+1].att_1=0;
a[shuliang+1].att_2=0;
a[shuliang+1].att_3=0;
a[shuliang+1].att_4=0;
a[shuliang+1].fire=0;
a[shuliang+1].gas_good=10;
a[shuliang+1].guard=0;
a[shuliang+1].HP=6000;
a[shuliang+1].name=namel;
a[shuliang+1].HPm=6000;
a[shuliang+1].gasm=700;
a[shuliang+1].boat[40][15]=100;
a[shuliang+1].long_=40;
a[shuliang+1].att_s_1=0;
a[shuliang+1].att_good_1=50;
a[shuliang+1].att_good_2=50;
a[shuliang+1].att_good_3=95;
a[shuliang+1].att_good_4=90;
a[shuliang+1].Lv=1;
shuliang++;
}
if(xz==2)
{
money-=75000000;
cout<<"名字:";
while(cin>>namel)
{
int f=1;
for(int i=1; i<=shuliang; i++)
{
if(a[i].name==namel)
{
f=0;
cout<<"已有重复名称"<<'\n';
}
}
if(f==1) break;
}
a[shuliang+1].gas=500;
a[shuliang+1].attack=0;
a[shuliang+1].att_1=0;
a[shuliang+1].att_2=0;
a[shuliang+1].att_3=0;
a[shuliang+1].att_4=0;
a[shuliang+1].fire=0;
a[shuliang+1].gas_good=10;
a[shuliang+1].guard=0;
a[shuliang+1].HP=7000;
a[shuliang+1].name=namel;
a[shuliang+1].HPm=7000;
a[shuliang+1].gasm=900;
a[shuliang+1].boat[40][15]=100;
a[shuliang+1].long_=40;
a[shuliang+1].att_s_1=0;
a[shuliang+1].att_good_1=60;
a[shuliang+1].att_good_2=60;
a[shuliang+1].att_good_3=75;
a[shuliang+1].att_good_4=82;
a[shuliang+1].Lv=1;
shuliang++;
}
if(xz==3)
{
money-=80000000;
cout<<"名字:";
string namel;
while(cin>>namel)
{
int f=1;
for(int i=1; i<=shuliang; i++)
{
if(a[i].name==namel)
{
f=0;
cout<<"已有重复名称"<<'\n';
}
}
if(f==1) break;
}
a[shuliang+1].gas=1000;
a[shuliang+1].attack=0;
a[shuliang+1].att_1=0;
a[shuliang+1].att_2=0;
a[shuliang+1].att_3=0;
a[shuliang+1].att_4=0;
a[shuliang+1].fire=0;
a[shuliang+1].gas_good=10;
a[shuliang+1].guard=0;
a[shuliang+1].HP=10000;
a[shuliang+1].name=namel;
a[shuliang+1].HPm=10000;
a[shuliang+1].gasm=1200;
a[shuliang+1].boat[40][15]=100;
a[shuliang+1].long_=70;
a[shuliang+1].att_s_1=0;
a[shuliang+1].att_good_1=10;
a[shuliang+1].att_good_2=40;
a[shuliang+1].att_good_3=15;
a[shuliang+1].att_good_4=80;
a[shuliang+1].Lv=1;
shuliang++;
}
if(xz==4)
{
money-=95000000;
cout<<"名字:";
string namel;
while(cin>>namel)
{
int f=1;
for(int i=1; i<=shuliang; i++)
{
if(a[i].name==namel)
{
f=0;
cout<<"已有重复名称"<<'\n';
}
}
if(f==1) break;
}
a[shuliang+1].gas=1000;
a[shuliang+1].attack=0;
a[shuliang+1].att_1=0;
a[shuliang+1].att_2=0;
a[shuliang+1].att_3=0;
a[shuliang+1].att_4=0;
a[shuliang+1].fire=0;
a[shuliang+1].gas_good=10;
a[shuliang+1].guard=0;
a[shuliang+1].HP=15000;
a[shuliang+1].name=namel;
a[shuliang+1].HPm=15000;
a[shuliang+1].gasm=1200;
a[shuliang+1].boat[40][15]=100;
a[shuliang+1].long_=70;
a[shuliang+1].att_s_1=0;
a[shuliang+1].att_good_1=10;
a[shuliang+1].att_good_2=40;
a[shuliang+1].att_good_3=15;
a[shuliang+1].att_good_4=80;
a[shuliang+1].Lv=1;
shuliang++;
}
if(xz==5)
{
money-=70000000;
cout<<"名字:";
while(cin>>namel)
{
int f=1;
for(int i=1; i<=shuliang; i++)
{
if(a[i].name==namel)
{
f=0;
cout<<"已有重复名称"<<'\n';
}
}
if(f==1) break;
}
a[shuliang+1].gas=1500;
a[shuliang+1].attack=0;
a[shuliang+1].att_1=0;
a[shuliang+1].att_2=0;
a[shuliang+1].att_3=0;
a[shuliang+1].att_4=0;
a[shuliang+1].fire=0;
a[shuliang+1].gas_good=10;
a[shuliang+1].guard=0;
a[shuliang+1].HP=1000;
a[shuliang+1].name=namel;
a[shuliang+1].HPm=1000;
a[shuliang+1].gasm=3500;
a[shuliang+1].boat[40][3]=100;
a[shuliang+1].long_=8;
a[shuliang+1].att_s_1=0;
a[shuliang+1].att_good_1=0;
a[shuliang+1].att_good_2=0;
a[shuliang+1].att_good_3=95;
a[shuliang+1].att_good_4=90;
a[shuliang+1].Lv=1;
shuliang++;
}
if(xz==6)
{
for(int i=1; i<=shuliang; i++)
{
cout<<a[i].name;
cout<<"1 主炮弹药数量:";
int l=a[i].att_s_1;
cout<<l<<'\n';
if(l==0) pr("没有弹药 建议增添",4);
else if(l<=30) pr("弹药较少 建议增添",6);
else pr("基本足够(仅为评估)",2);
cout<<'\n';
int want;
cout<<"输入需要弹药(40w/枚)数量:";
cin>>want;
money-=want*400000;
a[i].att_s_1+=want;
cout<<"2 副炮弹药数量:";
l=a[i].att_s_2;
cout<<l<<'\n';
if(l==0) pr("没有弹药 建议增添",4);
else if(l<=30) pr("弹药较少 建议增添",6);
else pr("基本足够(仅为评估)",2);
cout<<'\n';
cout<<"输入需要弹药(40w/枚)数量:";
cin>>want;
money-=want*400000;
a[i].att_s_2+=want;
}
}
cout<<"OK"<<'\n';
return ;
}
void up()
{
cout<<"1 加油站"<<'\n';
cout<<"2 加工厂"<<'\n';
cout<<"3 制造厂"<<'\n';
cout<<"4 出航" <<'\n';
cout<<"5 查看状态"<<'\n';
string xz;
cin>>xz;
while(xz!="1"&&xz!="2"&&xz!="3"&&xz!="4"&&xz!="5")
{
cout<<"错误--- 请再次输入"<<'\n';
system("pause");
cin>>xz;
}
int xz_int=stoi(xz);
switch(xz_int)
{
case 1:
up_gas();
break;
case 2:
up_on1();
break;
case 3:
up_build();
break;
case 4:
break;
default:
break;
}
}
void play()
{
shuliang=1;
a[1].gas=1000;
a[1].attack=0;
a[1].att_1=0;
a[1].att_2=0;
a[1].att_3=0;
a[1].att_4=0;
a[1].fire=0;
a[1].gas_good=10;
a[1].guard=0;
a[1].HP=15000;
a[1].name="max fight 1";
a[1].HPm=15000;
a[1].gasm=1200;
a[1].boat[40][15]=100;
a[1].long_=70;
a[1].att_s_1=0;
a[1].att_good_1=10;
a[1].att_good_2=40;
a[1].att_good_3=15;
a[1].att_good_4=80;
a[1].Lv=1;
cout<<"游戏开始"<<'\n';
system("pause");
system("cls");
while(1+1==2)
{
system("cls");
cout<<"游戏进行中----------"<<'\n';
system("pause");
cout<<"资金:"<<money;
if(money<-10000000)
{
cout<<"欠债过多 挑战失败"<<'\n';
return ;
}
if(sea)
{
for(int i=1; i<=shuliang; i++)
{
int f=100;
cout<<a[i].name<<":"<<'\n';
cout<<"该舰艇现在距离基地"<<km<<"km,需要"<<km*a[i].gas_good<<"升燃油"<<'\n';
if(a[i].fire==0) pr("舰艇无火灾",2),cout<<'\n';
else if(a[i].fire>0&&a[i].fire<=1.5) pr("舰艇火灾警告",6),f-=0.1,cout<<'\n';
else if(a[i].fire<=5) pr("中等火灾警告",6),f-=5,cout<<'\n';
else if(a[i].fire<=10) pr("最高火灾警告->立即返航/弃船",4),f-=40,cout<<'\n';
if(km*a[i].gas_good>=a[i].gas*2) pr("最高油量警告->立即返航",4),f-=40,cout<<'\n';
else if(km*a[i].gas_good>=a[i].gas) pr("油量警告",6),f-=35,cout<<'\n';
if(a[i].HP<=100) pr("重伤警告->立即返航/弃船",4),f-=60,cout<<'\n';
else if(a[i].HP<=1000) pr("警告->注意躲避火力",6),f-=20,cout<<'\n';
cout<<"1 主炮弹药数量:";
int l=a[i].att_s_1;
cout<<l<<'\n';
if(l==0) pr("没有弹药 建议增添",4);
else if(l<=30) pr("弹药较少 建议增添",6);
else pr("基本足够(仅为评估)",2);
cout<<'\n';
cout<<"2 副炮弹药数量:";
l=a[i].att_s_2;
cout<<l<<'\n';
if(l==0) pr("没有弹药 建议增添",4);
else if(l<=30) pr("弹药较少 建议增添",6);
else pr("基本足够(仅为评估)",2);
cout<<'\n';
if(a[i].att_1==0) pr("主炮不足",4),cout<<'\n';
if(a[i].att_2==0) pr("副炮不足",4),cout<<'\n';
if(a[i].att_2==0) pr("鱼雷不足",4),cout<<'\n';
if(a[i].att_2==0) pr("水雷不足",4),cout<<'\n';
if(f<0) pr("结果->立即返航/弃船",4),cout<<'\n';
else if(f<=50) pr("结果->准备返航",4),cout<<'\n';
else if(f<=70) pr("结果->状态一般",6),cout<<'\n';
else pr("结果->状态良好",2),cout<<'\n';
}
fight();
}
else
{
for(int i=1; i<=shuliang; i++)
{
cout<<i<<" "<<a[i].name<<'\n';
a[i].HP=a[i].HPm;
int f=100;
if(a[i].gas<=0) pr("油量警告->必须加油",4),f-=40,cout<<'\n';
else if(a[i].gas<=100) pr("油量警告->需要加油",4),f-=40,cout<<'\n';
else if(a[i].gas<=400) pr("油量警告",6),f-=35,cout<<'\n';
cout<<"血量:"<<a[i].HP<<" / "<<a[i].HPm<<'\n';
cout<<"油量:"<<a[i].gas<<" / "<<a[i].gasm<<'\n';
cout<<"长度:"<<a[i].long_<<'\n';
cout<<"主炮数量:"<<a[i].att_1<<'\n';
cout<<"副炮数量:"<<a[i].att_2<<'\n';
cout<<"1 主炮弹药数量:";
int l=a[i].att_s_1;
cout<<l<<'\n';
if(l==0) pr("没有弹药 建议增添",4);
else if(l<=30) pr("弹药较少 建议增添",6);
else pr("基本足够(仅为评估)",2);
cout<<'\n';
cout<<"2 副炮弹药数量:";
l=a[i].att_s_2;
cout<<l<<'\n';
if(l==0) pr("没有弹药 建议增添",4);
else if(l<=30) pr("弹药较少 建议增添",6);
else pr("基本足够(仅为评估)",2);
cout<<'\n';
if(a[i].att_1==0) pr("主炮不足",4),cout<<'\n';
if(a[i].att_2==0) pr("副炮不足",4),cout<<'\n';
if(a[i].att_2==0) pr("鱼雷不足",4),cout<<'\n';
if(a[i].att_2==0) pr("水雷不足",4),cout<<'\n';
cout<<'\n';
if(f<0) pr("结果->状态极差",4),cout<<'\n';
else if(f<=50) pr("结果->状态不好",4),cout<<'\n';
else if(f<=70) pr("结果->状态一般",6),cout<<'\n';
else pr("结果->状态良好",2),cout<<'\n';
}
up();
}
sleep(1);
}
}
int main()
{
a[1].gas=1000;
a[1].attack=0;
a[1].att_1=0;
a[1].att_2=0;
a[1].att_3=0;
a[1].att_4=0;
a[1].fire=0;
a[1].gas_good=10;
a[1].guard=0;
a[1].HP=15000;
a[1].name="max fight 1";
a[1].HPm=15000;
a[1].gasm=1200;
a[1].boat[40][15]=100;
a[1].long_=70;
a[1].att_s_1=0;
a[1].att_good_1=10;
a[1].att_good_2=40;
a[1].att_good_3=15;
a[1].att_good_4=80;
a[1].Lv=1;
cout<<"是否需要新手指南?(y/n)"<<'\n';
char xing;
cin>>xing;
if(xing=='y') new_do();
play();
cout<<"感谢游玩 个人主页: https://blog.csdn.net/YYDS314?type=blog"<<'\n';
return 0;
}