再求求大佬提提意见
  • 板块灌水区
  • 楼主tanshunqu
  • 当前回复3
  • 已保存回复3
  • 发布时间2025/1/18 09:58
  • 上次更新2025/1/18 12:07:46
查看原帖
再求求大佬提提意见
1372510
tanshunqu楼主2025/1/18 09:58
#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<windows.h>
#include <conio.h>
using namespace std;
int day;
int cunhuo = 0;//成功存活次数
int shibai = 0; //失败次数
int jinbi = 1000;
int yourenwaichuma;
int beibao[110] = {0, 3, 3, 3};
int len = 3;
int renshu = 4;
int suiji;
bool youmeiyoucundang = 0;
string beibao_ming[110] = {"", "A.香蕉(+5点血量+15饥饿值)", "B.苹果(+10点血量+10饥饿值)", "C.矿泉水(+25水分)"};
char xuanze;
char xuanze_zhuye;
string paishei;
string shifoujieshu;
struct p {
	string name;
	int ji = 100;
	int ke = 100;
	int xl = 100;
	int waichu = 0, jitian; //0在家;1外出
	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;
				switch (xuanze) {
					case 'A':
						p[i].ji += 15;
						p[i].xl += 5;
						beibao[1]--;
						break;
					case 'B':
						p[i].ji += 10;
						p[i].xl += 10;
						beibao[2]--;
						break;
					default:
						p[i].ke += 25;
						beibao[3]--;
						break;
				}
			}
		}
	}
	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元,按1234567890结束这次活动。" << 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") {
			jinbi += 9999;
			system("cls");
			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);
	}
	cout << endl;
	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;
}
void gerenxinxi() { //主页->个人信息
	system("cls");
	cout << "姓名:(未开放)" << endl;
	Sleep(1000);
	cout << "资金:" << jinbi << endl;
	Sleep(1000);
	cout << "参加次数:" << cunhuo + shibai << endl;
	Sleep(1000);
	cout << "存活次数:" << cunhuo << endl;
	Sleep(2000);
	system("cls");
	return;
}
void jiaocheng() { //教程
	system("cls");
	string s="荒岛求生玩过吧";
	for(int i=0;i<s.size();i++){
		cout<<s[i];
		Sleep(25);
	}
	Sleep(975);
	cout<<endl;
	s="其实这个游戏十分简单";
	for(int i=0;i<s.size();i++){
		cout<<s[i];
		Sleep(25);
	}
	Sleep(975);
	cout<<endl;
	s="规则都在剧情里(也不算剧情吧)";
	for(int i=0;i<s.size();i++){
		cout<<s[i];
		Sleep(25);
	}
	cout<<endl;
	Sleep(1975);
	system("cls");
	return;
}
int main() {
	for (;;) {
		cout << setw(50) << "荒岛求生" << endl;
		cout << setw(50) << "作者:凌空" << endl;
		cout << setw(65) << "----------测试版0.1.4673.1923----------" << endl;
		cout << setw(50) << "按任意键开始游戏" << endl;
		getch();
		system("cls");
		//A、C暂不支持
		cout << "A.使用原存档(暂不支持,输入自动转换为B选项)" << endl;
		cout << "B.新建存档" << endl;
		cout << "C.选择用户(暂不支持,输入自动转换为B选项)" << endl;
		cout << "D.查看个人信息" << endl;
		cout << "E.查看新手教程" << endl;
		while (cin >> xuanze_zhuye) {
			if (xuanze_zhuye == 'A' || xuanze_zhuye == 'B' || xuanze_zhuye == 'C') break;
			else if (xuanze_zhuye == 'D') gerenxinxi();
			else if (xuanze_zhuye == 'E') jiaocheng();
			cout << "A.使用原存档(暂不支持,输入自动转换为B选项)" << endl;
			cout << "B.新建存档" << endl;
			cout << "C.选择用户(暂不支持,输入自动转换为B选项)" << endl;
			cout << "D.查看个人信息" << endl;
			cout << "E.查看新手教程" << endl;
		}
		system("cls");
		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();
			suiji = rand() % 10 + 1;
			switch (suiji) {//90%啥也没有,10%找到钱
				case 1:
					int duoshaoqian;
					duoshaoqian = rand() % 100 + 1;
					jinbi += duoshaoqian;
					cout << p[yourenwaichuma].name << "在外找到一些钱,共计" << duoshaoqian << endl;
					break;
				default:
					//啥也没有
					break;
			}
			xiaohao();
			system("cls");
			if (renshu == 0) break;
		}
		if (renshu == 0) {
			jieshuyu();
			shibai++;
		} else {
			cout << "恭喜你,成功完成荒岛求生的节目!" << endl;
			cunhuo++;
		}
		cout << setw(50) << "按任意键重启" << endl;
		getch();
		system("cls");
		cout << "重启中";
		Sleep(1000);
		cout << "-";
		Sleep(1000);
		cout << "-";
		Sleep(1000);
		cout << "-";
		Sleep(1000);
		system("cls");
		renshu = 4;
	}

	return 0;
}
/*
物品栏:
1.香蕉:+5xl+15ji
2.苹果:10xl+10ji
3.矿泉水:+25ke
*/

/*
编译日志:
第一天:
今天加了开头语和派人外出探险的功能
第二天:
今天优化了输出,加了吃饭功能和每天的消耗
第三天:
改了一下输出,增加了矿泉水
第四天:
又改了一下输出
第五天:
又改了一下输出,加了死亡、结束语和结束一次后的购买(测试)
第六天:
做完结束一次后的购买(未完成)
第七天:
啥也没干
第八天:
把“结束一次后的购买”给删了('.')
第九天~第二十九天:
复习,准备期末考
第三十天:
加了主页和填补了漏洞
第三十一天:
修补漏洞,更新了个人信息
第三十二天:
更新了新手教程
*/
2025/1/18 09:58
1626767
zty2012zty2025/1/18 10:16

小伙子,看你挺有资质的,加个团吧宣团:https://www.luogu.com.cn/team/98296

2025/1/18 10:16
749539
__yun__2025/1/18 10:18
2025/1/18 10:18
1499574
lxc_why2025/1/18 10:45

@tanshunqu挺赞的

2025/1/18 10:45