#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<windows.h>
using namespace std;
int day;
int zhanji = 0;
int jinbi = 1000;
int yourenwaichuma;
int beibao[110] = {0, 3, 3, 3};
int len = 3;
int renshu = 4;
string beibao_ming[110] = {"", "A.香蕉(+5点血量+15饥饿值", "B.苹果(+10点血量+10饥饿值)", "C.矿泉水(+25水分"};
char xuanze;
string paishei;
string shifoujieshu;
int maimai[110];
struct p {
string name;
int ji = 100;
int ke = 100;
int xl = 100;
int waichu = 0, jitian;
int sw = 0;
} p[5];
void chifan() {
for (int i = 1; i <= 4; i++) {
if (yourenwaichuma != i && p[i].sw == 0) {
cout << "是(A)否(B)给" << p[i].name << "吃的?" << endl;
cin >> xuanze;
if (xuanze == 'A') {
cout << "吃点什么?(选项)" << endl;
cin >> xuanze;
for (char j = 'A'; j <= len + 65; j++) {
if (xuanze == j) {
if (j == 'A') {
p[i].ji += 15;
p[i].xl += 5;
beibao[1]--;
} else if (j == 'B') {
p[i].ji += 10;
p[i].xl += 10;
beibao[2]--;
} else if (j == 'C') {
p[i].ke += 25;
beibao[3]--;
}
}
}
}
}
}
return;
}
void xiaohao() {
for (int i = 1; i <= 4; i++) {
if (p[i].sw == 0) {
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].xl -= rand() % 21;
}
if (p[i].ke > 100) {
p[i].ke = 100;
}
if (p[i].ji > 100) {
p[i].ji = 100;
}
if (p[i].xl <= 0) {
p[i].sw = 1;
renshu--;
}
if (p[i].xl > 100) {
p[i].xl = 100;
}
}
}
return;
}
void kaitouyu() {
string s = "欢迎来到荒岛求生!";
for (int i = 0; i < s.size(); i++) {
cout << s[i];
Sleep(25);
}
Sleep(975);
system("cls");
s = "你现在一共有4人,看你能活几天";
for (int i = 0; i < s.size(); i++) {
cout << s[i];
Sleep(25);
}
Sleep(975);
system("cls");
s = "现在开始吧";
for (int i = 0; i < s.size(); i++) {
cout << s[i];
Sleep(25);
}
Sleep(975);
system("cls");
cout << "签约合同:" << endl;
cout << "1、一但签约不得反悔;" << endl;
cout << "2、如果你活到30天,可得9999元,按Ctrl+z结束这次活动。" << 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;
for (int i = 1; i <= 4; i++) {
if (p[i].sw == 0 && yourenwaichuma != i) {
cout << p[i].name;
if (p[i].ji >= 70) cout << "饱腹感:很饱";
else if (p[i].ji >= 50) cout << "饱腹感:良好";
else if (p[i].ji >= 30)cout << "饱腹感:有点饿";
else cout << "饱腹感:快饿死了";
cout<<" ";
if (p[i].ke >= 70) cout << "水分:很充足";
else if (p[i].ke >= 50) cout << "水分:良好";
else if (p[i].ke >= 30)cout << "水分:有点渴";
else cout << "水分:快渴死了";
cout<<" ";
if (p[i].xl >= 70) cout << "血量:很多";
else if (p[i].xl >= 50) cout << "血量:良好";
else if (p[i].xl >= 30)cout << "血量:有点晕";
else cout << "血量:快死了";
cout<<" ";
cout << endl;
} else if (p[i].sw == 0) cout << p[i].name << ":外出中" << endl;
else cout << p[i].name << ":已死亡" << endl;
}
cout << "背包:" << endl;
for (int i = 1; i <= len; 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;
for (int i = 1; i <= 4; i++) {
if (paishei == p[i].name && p[i].sw == 0) {
p[i].waichu = 1;
p[i].jitian = rand() % 3 + 1;
yourenwaichuma = i;
}
}
}
return;
}
void jieshuyu(string s = "你在荒岛中孤独地死去,却没人为你悲伤……") {
for (int j = 0; j < s.size(); j++) {
cout << s[j];
Sleep(100);
}
Sleep(1900);
return;
}
void buxingl() {
for (int i = 1; i <= 4; i++) {
if (p[i].sw == 1) {
cout << "检测到" << p[i].name << "快要不行了,是(A)否(B)消耗1200元进行抢救?" << endl;
cin >> xuanze;
if (xuanze == 'A') {
cout << "抢救成功!" << endl;
p[i].sw = 0;
p[i].ji = 50;
p[i].ke = 50;
p[i].xl = 50;
}
}
}
return;
}
int main() {
cout << setw(50) << "荒岛求生" << endl;
cout << setw(50) << "作者:凌空" << endl;
cout << setw(65) << "----------测试版0.1.4723.1823----------" << endl;
cout << setw(50) << "按Enter键开始游戏" << endl;
string s;
getline(cin, s);
system("cls");
for (;;) {
day = 1;
kaitouyu();
for (;; day++) {
if (yourenwaichuma != 0) {
if (p[yourenwaichuma].jitian == 0) {
p[yourenwaichuma].xl -= rand() % 21;
yourenwaichuma = 0;
for (int i = 1; i <= len; i++) {
beibao[i] += rand() % 5;
}
} else p[yourenwaichuma].jitian--;
}
cout << "第" << day << "天" << endl;
if (jieshu())break;
print_zhuangtai();
if (yourenwaichuma == 0)pairenwaichu();
chifan();
xiaohao();
system("cls");
if (renshu == 0) break;
}
if (renshu == 0) break;
}
jieshuyu();
return 0;
}