[C++] 小游戏 长路漫漫 0.0.04 未完成版

前言

今天 zty 带来的是『ThoughtsStarHub』小组的项目,长路漫漫的0.0.04的版本(该游戏尚未完成,无法正常游玩),此版本由zty一人开发完成,主要新增内容为指挥与调动部分(战斗函数)的第一次更新,现版本虽然英雄们仍然不可以激情的厮杀,但是终于可以体验到地图的玩法了,在0.0.04版本中,新增了调动与指挥的界面,在界面中,玩家可以操控已拥有的角色进行移动(行进至相邻的城市),驻扎(原地待一天,HP回满),和升级(这个函数还没做好qwq,实在肝不出来了),zty失踪了近十天,我回老家去了,昨天做了7个小时的大客,一回来就更新版本,累死我了(以至于我坐在凳子上睡着了,一直睡到了凌晨4点)。

此项目联合作者:

让我吐槽一下这个 J(这个读勾) 8 霜莲,说好合作,结果都是我干,你就提供个开头剧情就消失了,发消息也不回,我日你仙人

FrostedLotus·霜莲-CSDN博客

                                                  先   赞   后   看    养   成   习   惯 

众所不周知,zty的头图又双叒叕换了(好女生向的头图,管它呢)

(小声嘀咕)宝可梦!!仙子伊布好可爱!!!

                                                  先   赞   后   看    养   成   习   惯  

演示用编译器

Dev C++ 6.7.5 Red panda 

[C++编译器] Dev-C++ 6.7.5 (附下载链接、安装教程)_red panda dev-c++-CSDN博客

标准

C++14

                                                  先   赞   后   看    养   成   习   惯  

正文

更新日志:

        新增:1,调动与指挥第一部分更新  2,是否死亡与是否忙碌的标识

        修改:2,部分UI

        删除:无


But

目前还是未完成版,没法正常游玩,缺的几个主要部分:

  1. 战斗函数
  2. 商铺
  3. 黑暗领主和他手底下一批人的结构体
  4. 剧情
  5. 技能
  6. 美术

游戏地图:

其中枯叶市为初始城市,闇芈市(Yǎn mǐ shì‌)为Boss城市

游戏内截图:

最重要的代码
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>

using namespace std;
void No() {
	HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_CURSOR_INFO info;
	info.dwSize = 100;
	info.bVisible = FALSE;
	SetConsoleCursorInfo(consoleHandle, &info);
}
void print(string text) {
	for (int i = 0; i < text.size(); i++) {
		cout << text[i];
		Sleep(20);
	}
}
void Yan(int a) {// 1蓝 2绿 3紫 4红 5黄 6深蓝 7棕 8浅灰 9深灰 10绿绿 11绿紫 12绿黄 13蓝蓝
	if (a == 0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
	if (a == 1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE);
	if (a == 2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
	if (a == 3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
	if (a == 4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
	if (a == 5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
	if (a == 6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
	if (a == 7) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN);
	if (a == 8) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
	if (a == 9) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
	if (a == 10) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN | BACKGROUND_GREEN);
	if (a == 11) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_BLUE | BACKGROUND_GREEN);
	if (a == 12) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_GREEN);
	if (a == 13) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE | BACKGROUND_INTENSITY | BACKGROUND_BLUE);
}
void Bai() {
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}
enum Job { WAR, ARCH, DEF, MAG, ASN, SUP };
struct Way {
	int num = -1;
	int days = 0;
};

struct City {
	string name;
	Way way[5];
	Way cannotseeway[5];
};

City city[15] = {
	// 0. 枯叶市 (中心枢纽)
	{
		"枯叶市",
		{{1, 2}, {2, 3}, {3, 3}, {6, 2}, {-1, 0}},
		{{12, 5}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}}
	},

	// 1. 滨海市
	{
		"滨海市",
		{{0, 2}, {4, 3}, {9, 4}, {-1, 0}, {-1, 0}},
		{{-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}}
	},

	// 2. 枫林市
	{
		"枫林市",
		{{0, 3}, {5, 2}, {11, 3}, {-1, 0}, {-1, 0}},
		{{-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}}
	},

	// 3. 钢铁市
	{
		"钢铁市",
		{{0, 3}, {8, 2}, {10, 3}, {-1, 0}, {-1, 0}},
		{{-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}}
	},

	// 4. 绿源市
	{
		"绿源市",
		{{1, 3}, {9, 2}, {-1, 0}, {-1, 0}, {-1, 0}},
		{{-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}}
	},

	// 5. 云州市
	{
		"云州市",
		{{2, 2}, {13, 3}, {-1, 0}, {-1, 0}, {-1, 0}}, // 直接连接凤凰台市
		{{0, 4}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}}
	},

	// 6. 湖光市
	{
		"湖光市",
		{{0, 2}, {10, 2}, {-1, 0}, {-1, 0}, {-1, 0}},
		{{13, 4}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}}
	},

	// 7. (原风铃市位置保留为空)
	{"", {{-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}}, {{-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}}},

	// 8. 石岗市
	{
		"石岗市",
		{{3, 2}, {12, 3}, {-1, 0}, {-1, 0}, {-1, 0}},
		{{-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}}
	},

	// 9. 白露市
	{
		"白露市",
		{{1, 4}, {4, 2}, {-1, 0}, {-1, 0}, {-1, 0}},
		{{-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}}
	},

	// 10. 金山市
	{
		"金山市",
		{{3, 3}, {6, 2}, {8, 2}, {-1, 0}, {-1, 0}}, // 增加与石岗市的连接
		{{9, 3}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}}
	},

	// 11. 双龙镇市
	{
		"双龙镇市",
		{{2, 3}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}},
		{{14, 6}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}}
	},

	// 12. 平安堡市
	{
		"平安堡市",
		{{8, 3}, {14, 4}, {-1, 0}, {-1, 0}, {-1, 0}},
		{{-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}}
	},

	// 13. 凤凰台市
	{
		"凤凰台市",
		{{5, 3}, {14, 5}, {-1, 0}, {-1, 0}, {-1, 0}}, // 直接连接云州市
		{{-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}}
	},

	// 14. 闇芈市 (BOSS城市)
	{
		"闇芈市",
		{{12, 4}, {13, 5}, {-1, 0}, {-1, 0}, {-1, 0}},
		{{-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}}
	}
};

struct Character {
	string name;
	Job job;
	int lv;
	int exp;
	int skills[3];
	bool unlocked[3];
	int Maxhp;
	int hp;
	int atk;
	int def;
	float spd;
	bool owned;
	bool isPlayer;
	bool isBusy;   // 新增:忙碌状态
	bool isDead;   // 新增:是否死亡
	int currentCity = 0;
	int busyDays = 0;
	int getRequiredExp() {
		return 200 + 50 * (lv - 1);
	}

	bool levelUp() {
		int requiredExp = getRequiredExp();
		if (exp < requiredExp) return false;

		exp -= requiredExp;
		lv++;
		float boost = isPlayer ? 1.2f : 1.0f;

		switch (job) {
			case WAR:
				Maxhp += 15 * boost;
				atk += 8 * boost;
				def += 5 * boost;
				spd += 0.02f * boost;
				break;
			case ARCH:
				Maxhp += 10 * boost;
				atk += 10 * boost;
				def += 3 * boost;
				spd += 0.05f * boost;
				break;
			case DEF:
				Maxhp += 20 * boost;
				atk += 3 * boost;
				def += 8 * boost;
				spd += 0.01f * boost;
				break;
			case MAG:
				Maxhp += 8 * boost;
				atk += 12 * boost;
				def += 2 * boost;
				spd += 0.03f * boost;
				break;
			case ASN:
				Maxhp += 12 * boost;
				atk += 9 * boost;
				def += 4 * boost;
				spd += 0.06f * boost;
				break;
			case SUP:
				Maxhp += 13 * boost;
				atk += 5 * boost;
				def += 6 * boost;
				spd += 0.04f * boost;
				break;
		}

		if (lv == 15) unlocked[1] = true;
		if (lv == 30) unlocked[2] = true;
		return true;
	}

	void showDetail() {
		const char* jobs[] = {"战士", "射手", "肉盾", "法师", "刺客", "辅助"};
		const char* status = isDead ? "[已阵亡]" : (isBusy ? "[忙碌中]" : "[空闲中]");

		cout << "=== 详细信息 ===\n"
		     << "名称: " << name << (isPlayer ? "[玩家]" : "") << "\n"
		     << "等级: " << lv << "\n职业: " << jobs[job]
		     << "\nHP: " << hp << "/" << Maxhp << "\n攻击: " << atk
		     << "\n防御: " << def << "\n速度: " << spd
		     << "\n经验: " << exp << "/" << getRequiredExp()
		     << "\n状态: " << (owned ? "已拥有" : "未拥有")
		     << " | " << status  // 新增状态显示
		     << "\n\n";
	}

	void showSimple(bool selected) {
		const char* jobs[] = {"战士", "射手", "肉盾", "法师", "刺客", "辅助"};
		const char* status = isDead ? "[已阵亡]" : (isBusy ? "[忙碌中]" : "[空闲中]");
		cout << (selected ? "> " : "  ")
		     << name << " Lv." << lv
		     << " [" << jobs[job] << "]"
		     << (owned ? "[已拥有]" : "")
		     << " " << status  // 新增状态符号
		     << endl;
	}
} heroes[13] = {
	{"阿瑞斯", WAR, 1, 0, {101, 102, 103}, {1, 0, 0}, 350, 350, 45, 60, 1.1f, false, false, false, false, 1}, // 0:枯叶市
	{"威廉", WAR, 1, 0, {101, 102, 103}, {1, 0, 0}, 280, 280, 38, 55, 1.05f, false, false, false, false, 3},  // 1:滨海市
	{"艾玛", ARCH, 1, 0, {101, 102, 103}, {1, 0, 0}, 190, 190, 28, 65, 1.3f, false, false, false, false, 2},   // 2:枫林市
	{"艾琳", ARCH, 1, 0, {101, 102, 103}, {1, 0, 0}, 150, 150, 22, 50, 1.25f, false, false, false, false, 4},  // 3:钢铁市
	{"迈克尔", DEF, 1, 0, {101, 102, 103}, {1, 0, 0}, 500, 500, 35, 80, 0.8f, false, false, false, false, 12},  // 4:绿源市
	{"詹姆斯", DEF, 1, 0, {101, 102, 103}, {1, 0, 0}, 420, 420, 30, 75, 0.9f, false, false, false, false, 5},  // 5:云州市
	{"索菲亚", MAG, 1, 0, {101, 102, 103}, {1, 0, 0}, 180, 180, 65, 40, 1.0f, false, false, false, false, 6},  // 6:湖光市
	{"莉莉丝", MAG, 1, 0, {101, 102, 103}, {1, 0, 0}, 160, 160, 55, 35, 1.1f, false, false, false, false, 7},  // 7:石岗市
	{"丹尼尔", ASN, 1, 0, {101, 102, 103}, {1, 0, 0}, 220, 220, 70, 30, 1.5f, false, false, false, false, 6},  // 8:白露市
	{"奥利亚", SUP, 1, 0, {101, 102, 103}, {1, 0, 0}, 200, 200, 25, 40, 1.2f, false, false, false, false, 9},  // 9:金山市
};

void setColor(int color) {
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
}
void stri(int i) {
	while (i--) {
		Yan(8);
		cout << "█";
	}
	return;
}
void strin(int i) {
	while (i--) {
		setColor(14); // 黄色标题
		cout << "█";
	}
	return;
}
Character createPlayer() {
	system("cls");
	setColor(14); // 黄色标题
	cout << "\n\n\t================= 角色创建 ==================" << endl;
	cout << "\n\t输入角色名: ";
	string name;
	cin >> name;

	setColor(7); // 恢复白色

	const int BAR_LENGTH = 20;
	int currentChoice = 1;
	bool confirmed = false;

	while (!confirmed) {
		system("cls");
		setColor(14);
		cout << "\n\n\t================= 角色创建 ==================" << endl;
		cout << "\n\t输入角色名: " << name << endl;

		cout << "\n\t选择职业 (↑↓选择,空格确认):" << endl;
		cout << "\t1. " << string(10, '=') << " 战士 " << string(10, '=') << endl;
		cout << "\t2. " << string(10, '=') << " 射手 " << string(10, '=') << endl;
		cout << "\t3. " << string(10, '=') << " 肉盾 " << string(10, '=') << endl;
		cout << "\t4. " << string(10, '=') << " 法师 " << string(10, '=') << endl;
		cout << "\t5. " << string(10, '=') << " 刺客 " << string(10, '=') << endl;
		cout << "\t6. " << string(10, '=') << " 辅助 " << string(10, '=') << endl;

		cout << "\n\t当前选择: " << currentChoice << endl;

		// 优化选择部分
		if (GetAsyncKeyState(VK_UP) & 0x8000 && currentChoice > 1) {
			currentChoice--;
		}
		if (GetAsyncKeyState(VK_DOWN) & 0x8000 && currentChoice < 6) {
			currentChoice++;
		}
		if (GetAsyncKeyState(VK_SPACE) & 0x8000) {
			confirmed = true;
		}

		// 保留原有属性进度条
		int hp = 0, atk = 0, def = 0, spd = 0;
		switch (currentChoice) {
			case 1:
				hp = 200;
				atk = 30;
				def = 25;
				spd = 10;
				break;
			case 2:
				hp = 150;
				atk = 35;
				def = 15;
				spd = 13;
				break;
			case 3:
				hp = 250;
				atk = 20;
				def = 40;
				spd = 8;
				break;
			case 4:
				hp = 120;
				atk = 45;
				def = 10;
				spd = 11;
				break;
			case 5:
				hp = 160;
				atk = 40;
				def = 15;
				spd = 15;
				break;
			case 6:
				hp = 180;
				atk = 25;
				def = 30;
				spd = 12;
				break;
		}

		cout << "\n\t属性预览:" << endl;
		setColor(14);
		cout << "\t生命值: [" ;
		setColor(14);
		strin(hp * BAR_LENGTH / 250 ) ;
		setColor(14);
		stri(BAR_LENGTH - (hp * BAR_LENGTH) / 250);
		cout << "] " << hp << "/250" << endl << endl;
		setColor(14);
		cout << "\t攻击力: [" ;
		setColor(14);
		strin(atk * BAR_LENGTH / 45 );
		setColor(14);
		stri(BAR_LENGTH - (atk * BAR_LENGTH) / 45);
		cout << "] " << atk << "/45" << endl << endl;
		setColor(14);
		cout << "\t防御力: [" ;
		setColor(14);
		strin(def * BAR_LENGTH / 40);
		setColor(14);
		stri(BAR_LENGTH - (def * BAR_LENGTH) / 40);
		cout << "] " << def << "/40" << endl << endl;
		setColor(14);
		// 新增速度进度条
		setColor(14);
		cout << "\t 速度 : [";
		setColor(14);
		strin(spd * BAR_LENGTH / 15); // 1.5为最大速度值
		setColor(14);
		stri(BAR_LENGTH - (spd * BAR_LENGTH ) / 15);
		cout << "] " << fixed << setprecision(1) << spd << "/15" << endl << endl;
		Sleep(450);
	}
	heroes[10].lv = 1;
	heroes[10].currentCity = 0;
	heroes[10].owned = 1;
	heroes[10].isPlayer = 1;
	heroes[10].name = name;
	heroes[10].job = WAR;
	heroes[10].hp = 200; // 使用switch初始化实际值
	heroes[10].atk = 30;
	heroes[10].def = 25;
	heroes[10].spd = 1.0f;
	heroes[10].isBusy = false;  // 初始化状态
	heroes[10].isDead = false;  // 初始化状态
	switch (currentChoice) {
		case 2:
			heroes[10].job = ARCH;
			heroes[10].hp = 150;
			heroes[10].atk = 35;
			heroes[10].def = 15;
			heroes[10].spd = 1.3f;
			break;
		case 3:
			heroes[10].job = DEF;
			heroes[10].hp = 250;
			heroes[10].atk = 20;
			heroes[10].def = 40;
			heroes[10].spd = 0.8f;
			break;
		case 4:
			heroes[10].job = MAG;
			heroes[10].hp = 120;
			heroes[10].atk = 45;
			heroes[10].def = 10;
			heroes[10].spd = 1.1f;
			break;
		case 5:
			heroes[10].job = ASN;
			heroes[10].hp = 160;
			heroes[10].atk = 40;
			heroes[10].def = 15;
			heroes[10].spd = 1.5f;
			break;
		case 6:
			heroes[10].job = SUP;
			heroes[10].hp = 180;
			heroes[10].atk = 25;
			heroes[10].def = 30;
			heroes[10].spd = 1.2f;
			break;
	}
	heroes[10].Maxhp = heroes[10].hp;
	return heroes[10];
}
void heroDisplay() {
	int select = 0;
	system("cls");
	system("pause");
	while (true) {
		system("cls");
		cout << "==== 英雄列表 (↑/↓选择,空格查看,ESC返回) ====\n\n";

		for (int i = 0; i < 11; i++) {
			cout << "\t";
			heroes[i].showSimple(i == select);
			cout << "\n";
		}
		int key = _getch();
		switch (key) {
			case 72: // ↑
				select = (select - 1 + 11) % 11;
				break;
			case 80: // ↓
				select = (select + 1) % 11;
				break;
			case 32:
				system("cls");
				if (select == 10) {
					heroes[10].showDetail();
					_getch();
					break;
				}
				heroes[select].showDetail();
				_getch();
				break;
			case 27:
				return;
		}
	}
}
void start() {
	Yan(8);
	cout << "\n";
	cout << "    █      ██  █    █  ██      ███  ██  █  █ ███ █    █ ███ █    █\n";
	cout << "    █     █  █ ██  █ █   █      █   █  █ █  █ █  █ ██  █ █      █  █ \n";
	cout << "    █     █  █ █ █ █ █           █   █  █ █  █ ███ █ █ █ ███   ██   \n";
	cout << "    █     █  █ █  ██ █ ▄█      █   █  █ █  █ █ █  █  ██ █        █   \n";
	cout << "    ███  ██  █    █  █▔█     █     ██   ██  █  █ █    █ ███    █   \n\n";
	print(  "-----------------------------------------");
	Yan(1);
	cout << "长";
	Yan(4);
	cout << "路";
	Yan(1);
	cout << "漫漫";
	Yan(8);
	print("---------------------------------------------");
	print("---------------------------------------long journey-------------------------------------------");
	print("----------------------------------------版本0.0.04--------------------------------------------");
	print("-----------------------------------按下任意键开始游戏-----------------------------------------\n\n\n\n\n\n\n\n\n\n\n");
	cout << "                   联合作者:   CSDN zty郑桐羽呀   CSDN FrostedLotus·霜莲                     ";
	cout << "              所属组别:『ThoughtsStarHub』项目组   所属团队:『ZTY』CSDN创作主团               ";
	cout << "                              版权归属:『ZTY』CSDN创作主团                                   ";
}
void slowsay(string s, int t) {
	for (int i = 0; i < s.size(); i++) {
		cout << s[i];
		Sleep(t);
	}
}
void Intro() {
	Bai();
	Yan(4);
	system("cls");
	slowsay("\n\n\t(以下剧情可按ESC键跳过)\n\n\t很久很久以前,奥诺本大陆曾是一片繁荣祥和的土地\n\n", 20);
	if (_kbhit() && _getch() == 27) return;

	slowsay("\t直到黑暗领主玛尔加斯施展了诅咒——\n\n", 20);
	if (_kbhit() && _getch() == 27) return;

	print("\t他窃取了大陆上所有生灵的战魂,使人们变得软弱无力,怪物横行肆虐……\n\n");
	if (_kbhit() && _getch() == 27) return;

	slowsay("\t而你,是一位未被完全剥夺战魂的觉醒者\n\n", 20);
	if (_kbhit() && _getch() == 27) return;

	slowsay("\t为了破除诅咒,你必须击败盘踞在各处的魔物领主,夺回战魂碎片,让大陆重现光明!\n\n", 20);
	if (_kbhit() && _getch() == 27) return;

	print("\t\t按下任意键继续\n\n\n\t\t");
	if (_getch() == 27) return;
	system("cls");
}

void rizhi() {
	int selection = 0;
	system("cls");
	system("pause");
	bool confirmed = false;
	while (!confirmed) {
		cout << "\n\n\n\t请选择更新日志选项(注:DNF指 Did Not Finish):\n";
		cout << "\t1. " << "0.0.01 DNF版\n\n";
		cout << "\t2. " << "0.0.02 DNF版\n\n";
		cout << "\t3. " << "0.0.03 DNF版\n\n";
		cout << "\t4. " << "0.0.04 DNF版\n\n";  // 新增选项
		cout << "\n当前选择: " << selection + 1 << "  回车键确定  " << endl;

		if (GetAsyncKeyState(VK_UP) & 0x8000 && selection > 0) selection = (selection - 1) % 4;  // 修改选择逻辑
		if (GetAsyncKeyState(VK_DOWN) & 0x8000 && selection < 3) selection = (selection + 1) % 4;  // 修改选择逻辑
		if (GetAsyncKeyState(VK_RETURN) & 0x8000) {
			confirmed = true;
		}
		Sleep(150);
		system("cls");
	}
	system("cls");

	switch (selection + 1) {
		case 1:
			cout << "\t完成:\n\n\t1,主干部分\t2,图鉴\t 3,英雄结构体   4,角色创建   5,剧情   6,第一版封面\n\n";
			cout << "\t修改:\n\n\t  无\n\n";
			cout << "\t删除:\n\n\t  无\n\n";
			system("pause");
			break;
		case 2:
			cout << "\t完成:\n\n\t1,更新日志  \n\n";
			cout << "\t修改:\n\n\t1,角色创建  2,开头剧情  3,部分UI\n\n";
			cout << "\t删除: \n\n\t  无\n\n";
			system("pause");
			break;
		case 3:
			cout << "\t完成:\n\n\t1,城市  2,道路\n\n";
			cout << "\t修改:\n\n\t  无\n\n";
			cout << "\t删除:\n\n\t  无\n\n";
			system("pause");
			break;
		case 4:  // 新增0.0.04 DNF版内容
			cout << "\t完成:\n\n\t1,调动与指挥第一部分更新  2,是否死亡与是否忙碌的标识\n\n";
			cout << "\t修改:\n\n\t1,部分UI\n\n";
			cout << "\t删除:\n\n\t  无\n\n";
			system("pause");
			break;
		default:
			break;
	}
	return;
}
void moveHero(int heroIndex) {
	Character& hero = heroes[heroIndex];
	int currentCity = hero.currentCity;

	while (true) {
		system("cls");
		cout << "==== 选择移动目标 (当前在 " << city[currentCity].name << ") ====\n\n";
		cout << "0. 返回\n";

		// 显示常规道路
		int optionIndex = 1;
		for (int i = 0; i < 5; i++) {
			if (city[currentCity].way[i].num != -1) {
				cout << optionIndex++ << ". " << city[city[currentCity].way[i].num].name
				     << " (" << city[currentCity].way[i].days << "天)" << endl;
			}
		}

		// 显示隐藏道路
		for (int i = 0; i < 5; i++) {
			if (city[currentCity].cannotseeway[i].num != -1) {
				cout << optionIndex++ << ". [密道] " << city[city[currentCity].cannotseeway[i].num].name
				     << " (" << city[currentCity].cannotseeway[i].days << "天)" << endl;
			}
		}

		int choice;
		cin >> choice;

		if (choice == 0) return;

		int totalOptions = optionIndex - 1;
		if (choice < 1 || choice > totalOptions) {
			cout << "无效选择!\n";
			Sleep(1000);
			continue;
		}

		// 计算实际选择的目标
		int targetIndex = -1;
		int days = 0;
		optionIndex = 1;

		// 查找常规道路
		for (int i = 0; i < 5; i++) {
			if (city[currentCity].way[i].num != -1) {
				if (optionIndex == choice) {
					targetIndex = city[currentCity].way[i].num;
					days = city[currentCity].way[i].days;
					break;
				}
				optionIndex++;
			}
		}

		// 如果常规道路没找到,查找隐藏道路
		if (targetIndex == -1) {
			for (int i = 0; i < 5; i++) {
				if (city[currentCity].cannotseeway[i].num != -1) {
					if (optionIndex == choice) {
						targetIndex = city[currentCity].cannotseeway[i].num;
						days = city[currentCity].cannotseeway[i].days;
						break;
					}
					optionIndex++;
				}
			}
		}

		if (targetIndex != -1) {
			hero.currentCity = targetIndex;
			hero.isBusy = true;
			hero.busyDays = days;
			cout << "\n" << hero.name << " 已出发前往 " << city[targetIndex].name
			     << ",需要 " << days << " 天时间\n";
			Sleep(2000);
			return;
		}
	}
}

void Example(int heroIndex) {
	Character& hero = heroes[heroIndex];

	// 检查英雄状态
	if (hero.isDead) {
		cout << "该英雄已阵亡,无法执行操作!\n";
		system("pause");

		return;
	}

	if (hero.isBusy) {
		cout << "该英雄正在忙碌中(剩余 " << hero.busyDays << " 天)\n";
		system("pause");

		return;
	}

	int choice = 0;
	bool confirmed = false;
	system("pause");
	while (!confirmed) {
		system("cls");
		hero.showDetail();
		cout << "==== 请选择操作 ====(上下箭头选择,空格确认)\n\n";
		cout << (choice == 0 ? "> " : "  ") << "1. 移动\n\n";
		cout << (choice == 1 ? "> " : "  ") << "2. 升级\n\n";
		cout << (choice == 2 ? "> " : "  ") << "3. 驻扎\n\n";
		cout << (choice == 3 ? "> " : "  ") << "4. 返回\n\n";

		int key = _getch();
		switch (key) {
			case 72: // 上箭头
				if (choice > 0) choice--;
				break;
			case 80: // 下箭头
				if (choice < 3) choice++;
				break;
			case 32: // 回车
				confirmed = true;
				break;
		}
	}

	switch (choice) {
		case 0: // 移动
			moveHero(heroIndex);
			break;
		case 1: // 升级
			cout << "升级功能尚未实现!\n";
			Sleep(1000);
			break;
		case 2: // 驻扎
			hero.hp = hero.Maxhp;
			hero.isBusy = true;
			hero.busyDays = 1;
			cout << hero.name << " 正在驻扎休整,生命值已恢复!\n";
			Sleep(1500);
			break;
		case 3: // 返回
			break;
	}
}
void gotowar() {
	int select = 0;
	cout << "amns";
	system("pause");
	while (true) {
		system("cls");
		cout << "==== 英雄列表 (↑/↓选择,空格查看,ESC返回) ====\n\n";

		// 先计算已拥有的英雄数量
		int ownedCount = 0;
		for (int i = 0; i < 11; i++) {
			if (heroes[i].owned) {
				ownedCount++;
			}
		}

		// 如果没有已拥有的英雄,显示提示信息
		if (ownedCount == 0) {
			cout << "\t暂无已拥有的英雄\n";
			_getch();
			return;
		}

		// 显示已拥有的英雄
		int displayIndex = 0;
		for (int i = 0; i < 11; i++) {
			if (!heroes[i].owned) continue;  // 跳过未拥有的英雄

			cout << "\t";
			cout << (select == displayIndex ? "> " : "  ")
			     << heroes[i].name << " Lv." << heroes[i].lv
			     << " [" << (heroes[i].job == WAR ? "战士" :
			                 heroes[i].job == ARCH ? "射手" :
			                 heroes[i].job == DEF ? "肉盾" :
			                 heroes[i].job == MAG ? "法师" :
			                 heroes[i].job == ASN ? "刺客" : "辅助") << "]"
			     << " @" << city[heroes[i].currentCity].name
			     << " " << (heroes[i].isDead ? "[已阵亡]" : (heroes[i].isBusy ? "[忙碌中]" : "[空闲中]"))
			     << "\n";
			displayIndex++;
		}

		int key = _getch();
		switch (key) {
			case 72: // ↑
				select = (select - 1 + ownedCount) % ownedCount;
				break;
			case 80: // ↓
				select = (select + 1) % ownedCount;
				break;
			case 32: {
				system("cls");
				// 找到实际对应的英雄索引
				int actualIndex = 0;
				for (int i = 0; i < 11; i++) {
					if (!heroes[i].owned) {
						continue;
					}
					if (actualIndex == select) {//遍历成功,里面放调动代码
						Example(i);
					}
					actualIndex++;
				}
				_getch();
				break;
			}
			case 27:
				return;
		}
	}
}

void home2(int d) {
A:
	int xuan = 0;
	bool confirmed = false;

	while (!confirmed) {
		system("cls"); // 清屏刷新界面

		cout << "\n\nDay : " << d << " \n\n";
		cout << (xuan == 0 ? "> " : "  ") << "  调动与指挥\n\n";
		cout << (xuan == 1 ? "> " : "  ") << "  英雄图鉴\n\n";
		cout << (xuan == 2 ? "> " : "  ") << "  更新日志\n\n";
		cout << (xuan == 3 ? "> " : "  ") << "  万事俱备,睡个好觉\n\n\n";
		cout << "当前选择: " <<
		     (xuan == 0 ? "调动与指挥" :
		      xuan == 1 ? "英雄图鉴" :
		      xuan == 2 ? "更新日志" : "万事俱备,睡个好觉") << endl;

		// 检测上下键
		if (GetAsyncKeyState(VK_UP) & 0x8000) {
			xuan = (xuan - 1 + 4) % 4; // 循环向上选择
			Sleep(100);
		} else if (GetAsyncKeyState(VK_DOWN) & 0x8000) {
			xuan = (xuan + 1) % 4; // 循环向下选择
			Sleep(100);
		}

		// 检测空格键确认
		if (GetAsyncKeyState(VK_SPACE) & 0x8000) {
			confirmed = true;
			switch (xuan) {
				case 0:
					gotowar();
					break;
				case 1:
					heroDisplay();
					break;
				case 2:
					rizhi(); // 新增更新日志功能
					break;
				case 3:
					// 减少所有英雄的忙碌天数
					for (int i = 0; i < 11; i++) {
						if (heroes[i].busyDays > 0) {
							heroes[i].busyDays--;
							if (heroes[i].busyDays == 0) {
								heroes[i].isBusy = false;
							}
						}
					}
					return; // 直接返回
			}
		}

		Sleep(50); // 降低CPU占用
	}
	goto A;
}
void home() {
	int d = 1;
	while (1) {
		home2(d);
		d++;
	}
}
signed main() {
	system("mode con cols=94 lines=25");
	No();
	start();
	getch();
	Intro();
	createPlayer();
	home();
	return 0;
}

后记

作者:zty郑桐羽呀

联系方式:(不挂了,有事私信)

兄弟们给个赞呗

注:『ThoughtsStarHub』小组与新加坡公司StarHub没有任何隶属关系,『ThoughtsStarHub』小组是『ZTY』CSDN创作主团下的一个项目小组

                                                  先   赞   后   看    养   成   习   惯  

评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zty郑桐羽呀 『ZTY』主团团长

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值