#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<windows.h>
using namespace std;
int day;
int zhanji=0;
int jinbi=0;
int yourenwaichuma;
int beibao[110]={0,3,3};
string beibao_ming[110]={"","A.香蕉(+5点血量+15饥饿值)","B.苹果(+10点血量+10饥饿值)"};
char xuanze;
string paishei;
string shifoujieshu;
struct p{
string name;
int ji=100;
int ke=100;
int xl=100;
int waichu=0,jitian;//0在家;1外出
}p[5];
void chifan(){//吃饭
for(int i=1;i<=4;i++){
if(yourenwaichuma!=i){
cout<<"是(A)否(B)给"<<p[i].name<<"吃的?"<<endl;
cin>>xuanze;
if(xuanze=='A'){
cout<<"吃点什么?(选项)"<<endl;
cin>>xuanze;
for(char j='A';j<='B';j++){
if(xuanze==j){
if(j=='A'){//香蕉
p[i].ji+=15;
p[i].xl+=5;
}
else if(j=='B'){//苹果
p[i].ji+=10;
p[i].xl+=10;
}
}
}
}
}
}
return;
}
void xiaohao(){//消耗
for(int i=1;i<=4;i++){
p[i].ji-=rand()%16;
p[i].ke-=rand()%16;
if(p[i].ji<=0){
p[i].ji=0;
p[i].xl-=rand()%21;
}
if(p[i].ke<=0){
p[i].ke=0;
p[i].ke-=rand()%21;
}
}
return;
}
void kaitouyu(){//开头语
cout<<"欢";
Sleep(75);
cout<<"迎";
Sleep(75);
cout<<"来";
Sleep(75);
cout<<"到";
Sleep(75);
cout<<"荒";
Sleep(75);
cout<<"岛";
Sleep(75);
cout<<"求";
Sleep(75);
cout<<"生";
Sleep(75);
cout<<"!";
Sleep(1000);
system("cls");
cout<<"你";
Sleep(75);
cout<<"现";
Sleep(75);
cout<<"在";
Sleep(75);
cout<<"一";
Sleep(75);
cout<<"共";
Sleep(75);
cout<<"有";
Sleep(75);
cout<<"4";
Sleep(75);
cout<<"人";
Sleep(75);
cout<<",";
Sleep(75);
cout<<"看";
Sleep(75);
cout<<"你";
Sleep(75);
cout<<"能";
Sleep(75);
cout<<"活";
Sleep(75);
cout<<"几";
Sleep(75);
cout<<"天";
Sleep(1000);
system("cls");
cout<<"现";
Sleep(75);
cout<<"在";
Sleep(75);
cout<<"开";
Sleep(75);
cout<<"始";
Sleep(75);
cout<<"吧";
Sleep(1000);
system("cls");
cout<<"签约合同:"<<endl;
cout<<"1、一但签约不得反悔;"<<endl;
cout<<"2、如果你活到50天,可得9999元,按1234567890(按顺序全打(在输出第几天之后输,否则无效!))结束这次活动;"<<endl;
cout<<"3、请规范输入,无效可不怪我。"<<endl;
cout<<"签约人:(输入4个人的名字)"<<endl;
cin>>p[1].name>>p[2].name>>p[3].name>>p[4].name;
system("cls");
cout<<"正在前往荒岛中";
Sleep(1000);
cout<<"-";
Sleep(1000);
cout<<"-";
Sleep(1000);
cout<<"-";
Sleep(1000);
cout<<"-";
Sleep(1000);
system("cls");
return;
}
bool jieshu(){//是否结束这次游戏
if(day>=30){
cout<<"是否结束?"<<endl;
cin>>shifoujieshu;
if(shifoujieshu=="1234567890"){
zhanji++;
jinbi+=9999;
return true;
}
}
return false;
}
void print_zhuangtai(){//输出
cout<<"4人的状态:"<<endl;
if(yourenwaichuma==1){
cout<<p[1].name<<":外出中"<<endl;
cout<<p[2].name<<":饥饿值:"<<p[2].ji<<" 水分:"<<p[2].ke<<" 血量:"<<p[2].xl<<endl;
cout<<p[3].name<<":饥饿值:"<<p[3].ji<<" 水分:"<<p[3].ke<<" 血量:"<<p[3].xl<<endl;
cout<<p[4].name<<":饥饿值:"<<p[4].ji<<" 水分:"<<p[4].ke<<" 血量:"<<p[4].xl<<endl;
}
else if(yourenwaichuma==2){
cout<<p[1].name<<":饥饿值:"<<p[1].ji<<" 水分:"<<p[1].ke<<" 血量:"<<p[1].xl<<endl;
cout<<p[2].name<<":外出中"<<endl;
cout<<p[3].name<<":饥饿值:"<<p[3].ji<<" 水分:"<<p[3].ke<<" 血量:"<<p[3].xl<<endl;
cout<<p[4].name<<":饥饿值:"<<p[4].ji<<" 水分:"<<p[4].ke<<" 血量:"<<p[4].xl<<endl;
}
else if(yourenwaichuma==3){
cout<<p[1].name<<":饥饿值:"<<p[1].ji<<" 水分:"<<p[1].ke<<" 血量:"<<p[1].xl<<endl;
cout<<p[2].name<<":饥饿值:"<<p[2].ji<<" 水分:"<<p[2].ke<<" 血量:"<<p[2].xl<<endl;
cout<<p[3].name<<":外出中"<<endl;
cout<<p[4].name<<":饥饿值:"<<p[4].ji<<" 水分:"<<p[4].ke<<" 血量:"<<p[4].xl<<endl;
}
else if(yourenwaichuma==4){
cout<<p[1].name<<":饥饿值:"<<p[1].ji<<" 水分:"<<p[1].ke<<" 血量:"<<p[1].xl<<endl;
cout<<p[2].name<<":饥饿值:"<<p[2].ji<<" 水分:"<<p[2].ke<<" 血量:"<<p[2].xl<<endl;
cout<<p[3].name<<":饥饿值:"<<p[3].ji<<" 水分:"<<p[3].ke<<" 血量:"<<p[3].xl<<endl;
cout<<p[4].name<<":饥饿值:"<<p[4].ji<<" 水分:"<<p[4].ke<<" 血量:"<<p[4].xl<<endl;
}
else{
cout<<p[1].name<<":饥饿值:"<<p[1].ji<<" 水分:"<<p[1].ke<<" 血量:"<<p[1].xl<<endl;
cout<<p[2].name<<":饥饿值:"<<p[2].ji<<" 水分:"<<p[2].ke<<" 血量:"<<p[2].xl<<endl;
cout<<p[3].name<<":饥饿值:"<<p[3].ji<<" 水分:"<<p[3].ke<<" 血量:"<<p[3].xl<<endl;
cout<<p[4].name<<":饥饿值:"<<p[4].ji<<" 水分:"<<p[4].ke<<" 血量:"<<p[4].xl<<endl;
}
cout<<"背包:"<<endl;
for(int i=1;i<=2;i++){
if(beibao[i]>0) cout<<beibao_ming[i]<<":"<<beibao[i]<<" ";
}
cout<<endl;
return;
}
void pairenwaichu(){//外派
cout<<"是否派人外出?A.是B.不是"<<endl;
cin>>xuanze;
cout<<endl;
if(xuanze=='A'){
cout<<"派谁?"<<endl;
cin>>paishei;
if(paishei==p[1].name){
p[1].waichu=1;
p[1].jitian=rand()%3+1;
yourenwaichuma=1;
}
else if(paishei==p[2].name){
p[2].waichu=1;
p[2].jitian=rand()%3+1;
yourenwaichuma=2;
}
else if(paishei==p[3].name){
p[3].waichu=1;
p[3].jitian=rand()%3+1;
yourenwaichuma=3;
}
else if(paishei==p[4].name){
p[4].waichu=1;
p[4].jitian=rand()%3+1;
yourenwaichuma=4;
}
}
return;
}
int main(){
for(;;){
day=1;
kaitouyu();
for(;;day++){
cout<<"第"<<day<<"天"<<endl;
jieshu();
print_zhuangtai();
if(yourenwaichuma==0) pairenwaichu();
else{
if(p[yourenwaichuma].jitian==0) yourenwaichuma=0;
else p[yourenwaichuma].jitian--;
}
chifan();
xiaohao();
}
}
return 0;
}
/*
1.香蕉:+5xl+15ji
2.苹果:10xl+10ji
*/
/*
编译日志:
第一天:
今天加了开头语和派人外出探险的功能
第二天:
今天优化了输出,加了吃饭功能和每天的消耗
*/
有没有大佬帮我修改一下程序???