跳到正文

个人记录

CryWorldRPG V1.2.x

DrearySun约 180 分钟
原文
文章信息与版本

文章信息

收录
2026年8月4日
更新
2026年8月4日
篇幅
约 180 分钟

版本

  1. v1当前

v1.2.0

图鉴.,图鉴为最新版本,以后都是这个链接。

INFO
C++
//flpar
#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <conio.h>
#include <Windows.h>
#include <algorithm>
#include <fstream>
#include <cstring>
#include <string>
using namespace std;

// ===================== RPG全局常量 =====================
const char RPG_SAVE_PREFIX[] = "rpg_slot";
const int RPG_SLOT_MAX = 10;
const int SKILL_PAGE_CNT = 8;

// 品质枚举
enum SkillQuality { WHITE, GREEN, BLUE, PURPLE, GOD_SKILL };
// 玩家技能ID
enum SkillID {
	SKILL_NONE,
	SKILL_POWERUP, SKILL_SHIELD, SKILL_LIFESTEAL, SKILL_SWAPHP, SKILL_BLOODDRAIN,
	SKILL_STUN, SKILL_CRIT, SKILL_POISON, SKILL_REFLECT, SKILL_RUSH,
	SKILL_HEAL, SKILL_WEAK, SKILL_SILENCE, SKILL_DOUBLEHIT, SKILL_IMMUNE,
	SKILL_DRAINMP, SKILL_MEDITATE, SKILL_OVERLOAD,
	SKILL_STOPSHORT, SKILL_GOLDBURST, SKILL_MONEYLOVER,
	SKILL_CALM // 静心咒 ID22
};
// 怪物技能ID
enum MonsterSkillID {
	MSKILL_NONE, MSKILL_IMPRISON_PLAYER, MSKILL_POISON, MSKILL_WEAK, MSKILL_DOUBLEATK,
	MSKILL_REVIVE
};

// ===================== 存档工具 =====================
void GetRpgFileName(int slot, char buf[64]) {
	sprintf(buf, "%s%d.dat", RPG_SAVE_PREFIX, slot);
}
bool RpgSlotExist(int slot) {
	char buf[64];
	GetRpgFileName(slot, buf);
	ifstream f(buf, ios::binary);
	bool res = f.is_open();
	f.close();
	return res;
}

// ===================== 数据结构体 =====================
struct Skill {
	int id, quality;
	Skill() : id(SKILL_NONE), quality(WHITE) {}
	Skill(int i, int q) : id(i), quality(q) {}
};
struct RpgSaveData {
	char name[32];
	int hp, maxhp, atk, def, gold, stage;
	int skillCnt;
	Skill skills[20];
	int mp, maxmp, gem;
	vector<int> godSkillList;
} rpgData;
struct MonsterSkill {
	int id, quality;
	bool reviveUsed;
	MonsterSkill() : id(MSKILL_NONE), quality(WHITE), reviveUsed(false) {}
	MonsterSkill(int i, int q) : id(i), quality(q), reviveUsed(false) {}
};
struct Monster {
	int hp, maxhp, atk, def;
	int monsterImprisonTurn;
	vector<MonsterSkill> msList;
	int eliteVal;
	bool revived;
} monster;

// 全局战斗变量
int buffAtk, buffDef, poisonDmg;
int playerImprisonTurn;
float monsterImprisonRate;
int SkillBaseMp[22] = {0,8,12,10,15,20,18,22,14,15,9,24,17,25,11,28,16,6,28,12,22,14};
int curSlot = -1;

// ===================== 存档读写 =====================
bool LoadSave(int slot) {
	char buf[64];
	GetRpgFileName(slot, buf);
	ifstream fin(buf, ios::binary);
	if (!fin.is_open()) return false;
	
	// 手动初始化,禁用memset消除警告
	rpgData.name[0] = '\0';
	rpgData.hp = rpgData.maxhp = rpgData.atk = rpgData.def = rpgData.gold = rpgData.stage = 0;
	rpgData.skillCnt = 0;
	rpgData.mp = rpgData.maxmp = rpgData.gem = 0;
	for(int i=0;i<20;i++) rpgData.skills[i] = Skill();
	rpgData.godSkillList.clear();
	
	fin.read((char*)&rpgData.name, 32);
	fin.read((char*)&rpgData.hp, sizeof(int) * 7);
	fin.read((char*)&rpgData.skills, sizeof(Skill) * 20);
	int godSize;
	fin.read((char*)&godSize, sizeof(int));
	rpgData.godSkillList.resize(godSize);
	fin.read((char*)rpgData.godSkillList.data(), sizeof(int)*godSize);
	fin.close();
	if (rpgData.maxmp == 0) rpgData.maxmp = 50;
	rpgData.mp = rpgData.maxmp;
	return true;
}
void SaveSave(int slot) {
	char buf[64];
	GetRpgFileName(slot, buf);
	ofstream f(buf, ios::binary);
	f.write((char*)&rpgData, sizeof(RpgSaveData) - sizeof(vector<int>));
	int godSize = rpgData.godSkillList.size();
	f.write((char*)&godSize, sizeof(int));
	f.write((char*)rpgData.godSkillList.data(), sizeof(int)*godSize);
	f.close();
}
void NewPlayer() {
	rpgData.name[0] = '\0';
	rpgData.hp = rpgData.maxhp = 100;
	rpgData.atk = 10; rpgData.def = 5;
	rpgData.gold = rpgData.gem = rpgData.stage = rpgData.skillCnt = 0;
	// 逐数组初始化替代memset
	for(int i=0;i<20;i++) rpgData.skills[i] = Skill();
	rpgData.maxmp = 50;
	rpgData.mp = rpgData.maxmp;
	rpgData.godSkillList.clear();
}

// ===================== 文本工具 =====================
string GetQualityStr(int q) {
	if(q == WHITE) return "白色";
	if(q == GREEN) return "绿色";
	if(q == BLUE) return "蓝色";
	if(q == PURPLE) return "紫色";
	if(q == GOD_SKILL) return "神技";
	return "未知";
}
string GetSkillName(int id) {
	switch(id){
		case SKILL_POWERUP: return "狂怒增幅";
		case SKILL_SHIELD: return "钢铁壁垒";
		case SKILL_LIFESTEAL: return "吸血打击";
		case SKILL_SWAPHP: return "生命置换";
		case SKILL_BLOODDRAIN: return "鲜血汲取";
		case SKILL_STUN: return "眩晕重击";
		case SKILL_CRIT: return "致命穿刺";
		case SKILL_POISON: return "毒素腐蚀";
		case SKILL_REFLECT: return "伤害反弹";
		case SKILL_RUSH: return "冲锋突刺";
		case SKILL_HEAL: return "愈疗之光";
		case SKILL_WEAK: return "破碎护甲";
		case SKILL_SILENCE: return "灵魂禁锢";
		case SKILL_DOUBLEHIT: return "连环斩击";
		case SKILL_IMMUNE: return "超负荷";
		case SKILL_DRAINMP: return "吸能打击";
		case SKILL_MEDITATE: return "静心冥想";
		case SKILL_OVERLOAD: return "暗影潜行";
		case SKILL_STOPSHORT: return "点到为止";
		case SKILL_GOLDBURST: return "豪掷千金";
		case SKILL_MONEYLOVER: return "拜金";
		case SKILL_CALM: return "静心咒";
		default: return "未知技能";
	}
}
string GetMonsterSkillName(int id) {
	switch(id){
		case MSKILL_IMPRISON_PLAYER: return "禁锢缠绕";
		case MSKILL_POISON: return "撕裂流血";
		case MSKILL_WEAK: return "削弱攻防";
		case MSKILL_DOUBLEATK: return "狂暴重击";
		case MSKILL_REVIVE: return "卷土重来";
		default: return "无";
	}
}
int GetNormalMpCost(Skill s) {
	int base = SkillBaseMp[s.id];
	double rate;
	if(s.quality == WHITE) rate = 1.0;
	else if(s.quality == GREEN) rate = 0.9;
	else if(s.quality == BLUE) rate = 0.8;
	else if(s.quality == PURPLE) rate = 0.7;
	else rate = 1.0;
	int calc = static_cast<int>(base * rate);
	return max(2, calc);
}
int GetPurpleMp(int skillId) {
	int base = SkillBaseMp[skillId];
	int calc = static_cast<int>(base * 0.7);
	return max(2, calc);
}
int GetGodMpCost(int skillId) {
	int purMp = GetPurpleMp(skillId);
	return min(purMp, 10);
}
int GetCalmMpCost(int q) {
	double pct;
	if(q == WHITE) pct = 0.5;
	else if(q == GREEN) pct = 0.42;
	else if(q == BLUE) pct = 0.35;
	else if(q == PURPLE) pct = 0.3;
	else pct = 0.1;
	return static_cast<int>(rpgData.maxmp * pct);
}
double GetQualityMul(int q) {
	if(q == WHITE) return 1.0;
	if(q == GREEN) return 1.2;
	if(q == BLUE) return 1.45;
	if(q == PURPLE) return 1.8;
	if(q == GOD_SKILL) return 2.0;
	return 1.0;
}
double GetMonsterSkillMul(int q) {
	return GetQualityMul(q);
}

// ===================== 商店、抽卡 =====================
void DrawNormalSkill() {
	system("cls");
	cout << "抽普通技能 消耗30金币,20%空\n金币:" << rpgData.gold << "\n";
	if(rpgData.gold < 30) {
		cout << "金币不足,按任意键返回";
		_getch(); return;
	}
	rpgData.gold -= 30;
	if(rand() % 100 < 20) {
		cout << "本次抽空,无技能";
		_getch(); return;
	}
	Skill sk;
	sk.id = rand() % 21 + 1;
	int r = rand() % 100;
	if(r < 50) sk.quality = WHITE;
	else if(r < 80) sk.quality = GREEN;
	else if(r < 95) sk.quality = BLUE;
	else sk.quality = PURPLE;
	bool hasSame = false;
	for(int i = 0; i < rpgData.skillCnt; i++) {
		if(rpgData.skills[i].id == sk.id) {
			hasSame = true;
			if(sk.quality > rpgData.skills[i].quality) {
				rpgData.skills[i].quality = sk.quality;
				cout << "高品质覆盖旧技能\n";
			} else if(sk.quality == rpgData.skills[i].quality && sk.quality < PURPLE) {
				rpgData.skills[i].quality++;
				cout << "同品质进阶\n";
			}
			break;
		}
	}
	if(!hasSame && rpgData.skillCnt < 20) {
		rpgData.skills[rpgData.skillCnt++] = sk;
		cout << "获得【" << GetQualityStr(sk.quality) << "】" << GetSkillName(sk.id) << "\n";
	} else if(!hasSame) {
		cout << "技能栏已满,无法获取";
	}
	_getch();
}
void BuyGodSkill() {
	system("cls");
	cout << "宝石商店抽取神技,消耗5宝石,必出神技\n宝石:" << rpgData.gem << "\n";
	if(rpgData.gem < 5) {
		cout << "宝石不足";
		_getch(); return;
	}
	rpgData.gem -= 5;
	int newGodId = rand() % 22 + 1;
	for(int i = 0; i < rpgData.skillCnt; i++) {
		if(rpgData.skills[i].id == newGodId) {
			for(int j = i; j < rpgData.skillCnt - 1; j++)
				rpgData.skills[j] = rpgData.skills[j+1];
			rpgData.skillCnt--;
			break;
		}
	}
	bool exist = false;
	for(int x : rpgData.godSkillList)
		if(x == newGodId) exist = true;
	if(!exist) rpgData.godSkillList.push_back(newGodId);
	cout << "获得神技:" << GetSkillName(newGodId) << "\n";
	_getch();
}
void Shop() {
	while(true) {
		system("cls");
		cout << "==== CWR v1.2.0 商店 ====\n";
		cout << "金币:" << rpgData.gold << " 宝石:" << rpgData.gem << "\n";
		cout << "1. 抽普通技能 30金\n";
		cout << "2. 提升血量上限 50金\n";
		cout << "3. 抽取随机神技 5宝石\n";
		cout << "0. 离开商店\n";
		char op = _getch();
		if(op == '0') break;
		if(op == '1') DrawNormalSkill();
		if(op == '2') {
			if(rpgData.gold < 50) { cout << "金币不足"; _getch(); continue; }
			rpgData.gold -= 50;
			rpgData.maxhp += 20;
			rpgData.hp += 20;
			cout << "永久最大HP+20"; _getch();
		}
		if(op == '3') BuyGodSkill();
	}
}
void ShowSkillList() {
	int page = 0;
	while(true) {
		system("cls");
		cout << "=== 已持有普通技能 ===\n";
		int st = page * SKILL_PAGE_CNT;
		size_t ed = min((size_t)(st + SKILL_PAGE_CNT), (size_t)rpgData.skillCnt);
		for(int i = st; (size_t)i < ed; i++) {
			Skill s = rpgData.skills[i];
			int mp;
			if(s.id == SKILL_CALM) mp = GetCalmMpCost(s.quality);
			else mp = GetNormalMpCost(s);
			cout << i+1 << "." << GetQualityStr(s.quality) << GetSkillName(s.id) << " MP:" << mp << "\n";
		}
		cout << "\n=== 神技列表 ===\n";
		for(int gid : rpgData.godSkillList) {
			cout << GetSkillName(gid) << " MP:" << GetGodMpCost(gid) << "\n";
		}
		cout << "\nA上页 D下页 0退出";
		char c = _getch();
		if(c == '0') break;
		if(c == 'a' && page > 0) page--;
		if(c == 'd' && ed < (size_t)rpgData.skillCnt) page++;
	}
}

// ===================== 战斗技能效果 =====================
void CastSkillEffect(int sid, int q, int &pHP, int &mHP, int mMaxHp, bool &moneyLoverFlag) {
	double mul = GetQualityMul(q);
	double atkDmg = (rpgData.atk + buffAtk) * mul;
	switch(sid) {
	case SKILL_POWERUP:
		{
			buffAtk += static_cast<int>(10 * mul);
			cout << "狂怒增幅:临时攻击力提升\n";
		}break;
	case SKILL_SHIELD:
		{
			buffDef += static_cast<int>(8 * mul);
			cout << "钢铁壁垒:临时防御力提升\n";
		}break;
	case SKILL_LIFESTEAL:
		{
			double d = atkDmg * 1.2;
			int hit = max(static_cast<int>(d) - monster.def, 1);
			mHP -= hit;
			int heal = static_cast<int>(d * 0.4 * mul);
			pHP = min(pHP + heal, rpgData.maxhp);
			cout << "吸血打击,造成伤害并回血\n";
		}break;
	case SKILL_SWAPHP:
		{
			int tmp = pHP; pHP = mHP; mHP = tmp;
			pHP += static_cast<int>(80 * mul);
			pHP = min(pHP, rpgData.maxhp);
			cout << "生命置换,互换双方血量\n";
		}break;
	case SKILL_BLOODDRAIN:
		{
			int dot = static_cast<int>(rpgData.atk * 0.4 * mul);
			poisonDmg += dot;
			int hit = max(static_cast<int>(atkDmg) - monster.def, 1);
			mHP -= hit;
			cout << "鲜血汲取,附加持续流血\n";
		}break;
	case SKILL_STUN:
		{
			monster.monsterImprisonTurn += static_cast<int>(2 * mul);
			double raw = atkDmg * 1.5;
			int hit = max(static_cast<int>(raw) - monster.def, 1);
			mHP -= hit;
			cout << "眩晕重击,禁锢怪物\n";
		}break;
	case SKILL_CRIT:
		{
			int trueD = static_cast<int>(rpgData.atk * 1.8 * mul);
			mHP -= max(trueD, 1);
			cout << "致命穿刺,真实伤害\n";
		}break;
	case SKILL_POISON:
		{
			poisonDmg += static_cast<int>(rpgData.atk * 0.25 * mul);
			monster.def -= static_cast<int>(10 * mul);
			cout << "毒素腐蚀,持续毒伤+减防\n";
		}break;
	case SKILL_REFLECT:
		{
			buffDef += static_cast<int>(15 * mul);
			double raw = atkDmg * 0.6;
			int hit = max(static_cast<int>(raw) - monster.def, 1);
			mHP -= hit;
			cout << "伤害反弹护盾\n";
		}break;
	case SKILL_RUSH:
		{
			double raw = atkDmg * 1.3;
			int hit = max(static_cast<int>(raw) - monster.def, 1);
			mHP -= hit;
			cout << "冲锋突刺\n";
		}break;
	case SKILL_HEAL:
		{
			int h = static_cast<int>(rpgData.maxhp * 0.35 * mul);
			pHP = min(pHP + h, rpgData.maxhp);
			poisonDmg = 0;
			cout << "愈疗之光,清除DOT并回血\n";
		}break;
	case SKILL_WEAK:
		{
			monster.def -= static_cast<int>(12 * mul);
			int hit = max(static_cast<int>(atkDmg) - monster.def, 1);
			mHP -= hit;
			cout << "破碎护甲,永久减防\n";
		}break;
	case SKILL_SILENCE:
		{
			monster.monsterImprisonTurn += static_cast<int>(2 * mul);
			int hit = max(static_cast<int>(atkDmg) - monster.def, 1);
			mHP -= hit;
			cout << "灵魂禁锢,封锁怪物技能\n";
		}break;
	case SKILL_DOUBLEHIT:
		{
			double raw = atkDmg * 0.7;
			int hit1 = max(static_cast<int>(raw) - monster.def, 1);
			int hit2 = max(static_cast<int>(raw) - monster.def, 1);
			mHP -= hit1 + hit2;
			cout << "连环斩击两段伤害\n";
		}break;
	case SKILL_IMMUNE:
		{
			buffAtk += static_cast<int>(40 * mul);
			cout << "超负荷大幅增攻\n";
		}break;
	case SKILL_DRAINMP:
		{
			int stealMp = static_cast<int>(8 * mul);
			rpgData.mp = min(rpgData.mp + stealMp, rpgData.maxmp);
			double raw = atkDmg * 1.1;
			int hit = max(static_cast<int>(raw) - monster.def, 1);
			mHP -= hit;
			cout << "吸能打击,偷取魔力\n";
		}break;
	case SKILL_MEDITATE:
		{
			int hpHeal = static_cast<int>(rpgData.maxhp * 0.25 * mul);
			int mpHeal = static_cast<int>(20 * mul);
			pHP = min(pHP + hpHeal, rpgData.maxhp);
			rpgData.mp = min(rpgData.mp + mpHeal, rpgData.maxmp);
			cout << "静心冥想,回血回蓝跳过回合\n";
		}break;
	case SKILL_OVERLOAD:
		{
			double raw = atkDmg * 1.3;
			int hit = max(static_cast<int>(raw) - monster.def, 1);
			mHP -= hit;
			cout << "暗影潜行\n";
		}break;
	case SKILL_STOPSHORT:
		{
			int phys = static_cast<int>(rpgData.atk * 1.2 * mul);
			int trueD = static_cast<int>(rpgData.atk * 0.05 * mul);
			int all = phys + trueD;
			int hit = min(all, mHP - 1);
			mHP -= hit;
			cout << "点到为止,强制保留1血\n";
		}break;
	case SKILL_GOLDBURST:
		{
			cout << "输入消耗金币:";
			int cost; cin >> cost;
			if(cost <= 0 || rpgData.gold < cost) {
				cout << "金币不足,技能失效"; break;
			}
			rpgData.gold -= cost;
			long long hit = static_cast<long long>(cost) * 1.5 * rpgData.atk * mul;
			mHP -= static_cast<int>(hit);
			cout << "豪掷千金巨额伤害\n";
		}break;
	case SKILL_MONEYLOVER:
		{
			mHP -= 1;
			moneyLoverFlag = true;
			cout << "拜金,1点真实伤害,击杀收益翻倍\n";
		}break;
	case SKILL_CALM:
		{
			playerImprisonTurn = 0;
			pHP += static_cast<int>(10 * mul);
			pHP = min(pHP, rpgData.maxhp);
			cout << "静心咒,解除禁锢并回血\n";
		}break;
	default:
		{
			int hit = max(static_cast<int>(atkDmg) - monster.def, 1);
			mHP -= hit;
		}break;
	}
}
void SpawnMonster() {
	monster.msList.clear();
	monster.monsterImprisonTurn = poisonDmg = 0;
	playerImprisonTurn = 0;
	monster.revived = false;
	monsterImprisonRate = 1.0f;
	monster.maxhp = 20 + rpgData.stage * 12;
	monster.hp = monster.maxhp;
	monster.atk = 4 + rpgData.stage * 3;
	monster.def = 3 + rpgData.stage * 2;
	monster.eliteVal = 0;
	vector<int> used;
	bool addRevive = (rand() % 100 < 25);
	if(addRevive) {
		monster.msList.emplace_back(MSKILL_REVIVE, WHITE);
		monster.eliteVal += 5;
		used.push_back(MSKILL_REVIVE);
	}
	int cnt = rand() % 4;
	for(int i = 0; i < cnt; i++) {
		int sid;
		do {
			sid = rand() % 4 + 1;
		} while(find(used.begin(), used.end(), sid) != used.end());
		used.push_back(sid);
		int qr = rand() % 100;
		int q;
		if(qr < 60) { q = WHITE; monster.eliteVal += 1; }
		else if(qr < 85) { q = GREEN; monster.eliteVal += 2; }
		else if(qr < 97) { q = BLUE; monster.eliteVal += 3; }
		else { q = PURPLE; monster.eliteVal += 5; }
		monster.msList.emplace_back(sid, q);
	}
}
void Battle() {
	SpawnMonster();
	int playerHp = rpgData.hp;
	buffAtk = buffDef = 0;
	bool over = false;
	bool moneyLoverKill = false;
	while(!over) {
		system("cls");
		cout << "==== 战斗 第" << rpgData.stage << "层 ====\n";
		cout << "玩家 HP:" << playerHp << "/" << rpgData.maxhp << " MP:" << rpgData.mp << "/" << rpgData.maxmp << "\n";
		cout << "临时ATK+" << buffAtk << " DEF+" << buffDef << "\n";
		cout << "怪物 HP:" << monster.hp << "/" << monster.maxhp;
		if(monster.monsterImprisonTurn > 0) cout << " 怪物禁锢" << monster.monsterImprisonTurn;
		if(playerImprisonTurn > 0) cout << " 你被禁锢" << playerImprisonTurn;
		cout << "\n精英值:" << monster.eliteVal;
		if(monster.eliteVal > 10) cout << "【BOSS】";
		else if(monster.eliteVal > 5) cout << "【领主】";
		else if(monster.eliteVal > 3) cout << "【精英】";
		cout << "\n怪物技能:";
		for(auto &ms : monster.msList)
			cout << GetMonsterSkillName(ms.id) << "(" << GetQualityStr(ms.quality) << ") ";
		cout << "\n1普攻 2释放技能 3逃跑\n";
		char op = _getch();
		bool skip = false;
		if(op == '3') { cout << "逃跑无奖励"; _getch(); return; }
		if(playerImprisonTurn > 0) {
			bool hasCalm = false;
			int calmQ = WHITE;
			for(int i = 0; i < rpgData.skillCnt; i++) {
				if(rpgData.skills[i].id == SKILL_CALM) {
					hasCalm = true; calmQ = rpgData.skills[i].quality; break;
				}
			}
			int calmGodId = -1;
			for(int x : rpgData.godSkillList)
				if(x == SKILL_CALM) calmGodId = x;
			if(hasCalm || calmGodId != -1) {
				cout << "\n被禁锢!是否释放静心咒 1是 0否:";
				char c = _getch();
				if(c == '1') {
					if(calmGodId != -1) {
						int cost = GetCalmMpCost(GOD_SKILL);
						if(rpgData.mp >= cost) {
							rpgData.mp -= cost;
							CastSkillEffect(SKILL_CALM, GOD_SKILL, playerHp, monster.hp, monster.maxhp, moneyLoverKill);
						} else cout << "MP不足\n";
					} else {
						int cost = GetCalmMpCost(calmQ);
						if(rpgData.mp >= cost) {
							rpgData.mp -= cost;
							CastSkillEffect(SKILL_CALM, calmQ, playerHp, monster.hp, monster.maxhp, moneyLoverKill);
						} else cout << "MP不足\n";
					}
					_getch();
				}
			}
			cout << "本回合无法行动,任意键跳过";
			_getch();
			playerImprisonTurn--;
		} else if(op == '1') {
			int rawDmg = (rpgData.atk + buffAtk) - monster.def;
			int d = max(rawDmg, 1);
			monster.hp -= d;
			cout << "普攻造成" << d << "伤害\n";
		} else if(op == '2') {
			system("cls");
			cout << "=== 普通技能 ===\n";
			for(int i = 0; i < rpgData.skillCnt; i++) {
				Skill s = rpgData.skills[i];
				int mp = (s.id == SKILL_CALM) ? GetCalmMpCost(s.quality) : GetNormalMpCost(s);
				cout << i+1 << "." << GetSkillName(s.id) << " MP:" << mp << "\n";
			}
			cout << "\n=== G=释放神技 ===\n";
			size_t godLen = rpgData.godSkillList.size();
			for(size_t i=0;i<godLen;i++)
				cout << GetSkillName(rpgData.godSkillList[i]) << " MP:" << GetGodMpCost(rpgData.godSkillList[i]) << "\n";
			cout << "输入数字/G释放,0返回:";
			string s; cin >> s;
			if(s == "g" || s == "G") {
				cout << "输入神技序号:";
				int gi; cin >> gi; gi--;
				if((size_t)gi < godLen) {
					int gid = rpgData.godSkillList[gi];
					int cost = GetGodMpCost(gid);
					if(rpgData.mp >= cost) {
						rpgData.mp -= cost;
						CastSkillEffect(gid, GOD_SKILL, playerHp, monster.hp, monster.maxhp, moneyLoverKill);
						if(gid == SKILL_MEDITATE) skip = true;
					} else cout << "法力不足";
				} else cout << "序号错误";
			} else {
				int idx = stoi(s) - 1;
				if(idx >= 0 && (size_t)idx < (size_t)rpgData.skillCnt) {
					Skill sk = rpgData.skills[idx];
					int cost;
					if(sk.id == SKILL_CALM) cost = GetCalmMpCost(sk.quality);
					else cost = GetNormalMpCost(sk);
					if(rpgData.mp >= cost) {
						rpgData.mp -= cost;
						CastSkillEffect(sk.id, sk.quality, playerHp, monster.hp, monster.maxhp, moneyLoverKill);
						if(sk.id == SKILL_MEDITATE) skip = true;
						if(sk.id == SKILL_MONEYLOVER) moneyLoverKill = true;
					} else cout << "法力不足";
				} else if(stoi(s) != 0) cout << "无此技能";
			}
			_getch();
		}
		rpgData.mp = min(rpgData.mp + 5, rpgData.maxmp);
		if(poisonDmg > 0) {
			monster.hp -= poisonDmg;
			cout << "毒素持续伤害:" << poisonDmg << "\n";
		}
		if(monster.hp <= 0 && !monster.revived) {
			for(auto &ms : monster.msList) {
				if(ms.id == MSKILL_REVIVE && !ms.reviveUsed) {
					ms.reviveUsed = true;
					monster.revived = true;
					monster.maxhp = static_cast<int>(monster.maxhp * 1.5);
					monster.hp = monster.maxhp;
					monster.atk = static_cast<int>(monster.atk * 1.5);
					monster.def = static_cast<int>(monster.def * 1.5);
					cout << "【卷土重来】怪物复活,全属性1.5倍\n";
					break;
				}
			}
			if(monster.hp > 0) {
				if(monster.monsterImprisonTurn > 0) {
					monsterImprisonRate -= 0.1f;
					if(monsterImprisonRate < 0.1f) monsterImprisonRate = 0.1f;
				}
				continue;
			}
		}
		if(monster.hp <= 0) { over = true; break; }
		if(skip) {
			cout << "冥想跳过怪物行动"; _getch(); continue;
		}
		bool useSkill = false;
		if(rand() % 100 < 40 && monster.msList.size() > 0) {
			auto ms = monster.msList[rand() % monster.msList.size()];
			if(ms.id == MSKILL_REVIVE) goto monsterAtk;
			useSkill = true;
			double mul = GetMonsterSkillMul(ms.quality);
			if(ms.id == MSKILL_IMPRISON_PLAYER) {
				int turn = static_cast<int>(2 * mul * monsterImprisonRate);
				playerImprisonTurn += turn;
				double rawDmg = monster.atk * 0.8 * mul;
				int dmg = max(static_cast<int>(rawDmg) - buffDef, 1);
				playerHp -= dmg;
				cout << "怪物禁锢你" << turn << "回合\n";
			} else if(ms.id == MSKILL_POISON) {
				double rawDmg = monster.atk * 0.6 * mul;
				int dmg = max(static_cast<int>(rawDmg) - buffDef, 1);
				playerHp -= dmg;
				poisonDmg += static_cast<int>(monster.atk * 0.6 * mul);
				cout << "怪物撕裂流血\n";
			} else if(ms.id == MSKILL_WEAK) {
				buffAtk -= static_cast<int>(4 * mul);
				buffDef -= static_cast<int>(4 * mul);
				double rawDmg = monster.atk * 0.9 * mul;
				int dmg = max(static_cast<int>(rawDmg) - buffDef, 1);
				playerHp -= dmg;
				cout << "怪物削弱攻防\n";
			} else if(ms.id == MSKILL_DOUBLEATK) {
				double rawDmg = monster.atk * 1.6 * mul;
				int dmg = max(static_cast<int>(rawDmg) - buffDef, 1);
				playerHp -= dmg;
				cout << "怪物狂暴重击\n";
			}
		}
		monsterAtk:
		if(!useSkill) {
			int dmgRaw = monster.atk - buffDef;
			int dmg = max(dmgRaw, 1);
			playerHp -= dmg;
			cout << "怪物普攻造成" << dmg << "\n";
		}
		_getch();
		if(playerHp <= 0) { over = true; break; }
		if(monster.monsterImprisonTurn > 0) monster.monsterImprisonTurn--;
		if(monster.monsterImprisonTurn == 0 && monsterImprisonRate > 0.1f) {
			monsterImprisonRate -= 0.1f;
			if(monsterImprisonRate < 0.1f) monsterImprisonRate = 0.1f;
		}
	}
	system("cls");
	if(playerHp <= 0) {
		cout << "战败!层数重置为1,血蓝回满\n";
		rpgData.stage = 1;
		rpgData.hp = rpgData.maxhp;
		rpgData.mp = rpgData.maxmp;
	} else {
		rpgData.mp = rpgData.maxmp;
		double rate = 1.0;
		if(monster.eliteVal > 10) rate = 2.0;
		else if(monster.eliteVal > 5) rate = 1.75;
		else if(monster.eliteVal > 3) rate = 1.5;
		if(monster.revived) rate *= 2;
		if(moneyLoverKill) rate *= 2;
		int baseGold = 15 + rpgData.stage * 8;
		int getGold = static_cast<int>(baseGold * rate);
		int gemDrop = 0;
		if(monster.eliteVal > 3) gemDrop = rand() % monster.eliteVal;
		rpgData.gold += getGold;
		rpgData.gem += gemDrop;
		rpgData.stage++;
		rpgData.hp = playerHp;
		cout << "胜利!\n获得金币:" << getGold << " 宝石:" << gemDrop << "\n倍率:" << rate;
		if(monster.revived) cout << "【卷土重来双倍】";
		if(moneyLoverKill) cout << "【拜金双倍】";
	}
	_getch();
}

// ===================== 主菜单 =====================
void MainMenu() {
	while(true) {
		system("cls");
		cout << "==== CWR v1.2.0 主菜单 ====\n";
		cout << "1. 新建角色\n";
		cout << "2. 读取存档\n";
		cout << "0. 退出\n";
		char op = _getch();
		if(op == '0') exit(0);
		if(op == '1') {
			NewPlayer();
			cout << "输入角色名:";
			cin >> rpgData.name;
			curSlot = -1;
			break;
		}
		if(op == '2') {
			cout << "输入存档槽位(1~10):";
			int s; cin >> s;
			if(s < 1 || s > 10) { cout << "槽位错误"; _getch(); continue; }
			if(!RpgSlotExist(s)) { cout << "存档不存在"; _getch(); continue; }
			LoadSave(s);
			curSlot = s;
			break;
		}
	}
	while(true) {
		system("cls");
		cout << "角色:" << rpgData.name << " 层数:" << rpgData.stage << "\n";
		cout << "HP:" << rpgData.hp << "/" << rpgData.maxhp << " MP:" << rpgData.mp << "/" << rpgData.maxmp << "\n";
		cout << "ATK:" << rpgData.atk << " DEF:" << rpgData.def << "\n";
		cout << "金币:" << rpgData.gold << " 宝石:" << rpgData.gem << "\n";
		cout << "1. 进入战斗\n";
		cout << "2. 商店\n";
		cout << "3. 查看技能\n";
		cout << "4. 保存存档\n";
		cout << "0. 返回主菜单\n";
		char c = _getch();
		if(c == '0') break;
		if(c == '1') Battle();
		if(c == '2') Shop();
		if(c == '3') ShowSkillList();
		if(c == '4') {
			if(curSlot == -1) {
				cout << "输入存档槽位1~10保存:";
				cin >> curSlot;
			}
			SaveSave(curSlot);
			cout << "保存成功"; _getch();
		}
	}
}

int main() {
	srand((unsigned)time(nullptr));
	while(true) MainMenu();
	return 0;
}

v1.2.5

INFO
C++
//flpar
#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <conio.h>
#include <Windows.h>
#include <algorithm>
#include <fstream>
#include <cstring>
#include <string>
#include <utility>
using namespace std;

// ===================== RPG全局常量 =====================
const char RPG_SAVE_PREFIX[] = "rpg_slot";
const int RPG_SLOT_MAX = 10;
const int SKILL_PAGE_CNT = 8;

// 品质枚举
enum SkillQuality { WHITE, GREEN, BLUE, PURPLE, GOD_SKILL };
// 玩家技能ID
enum SkillID {
	SKILL_NONE,
	SKILL_POWERUP, SKILL_SHIELD, SKILL_LIFESTEAL, SKILL_SWAPHP, SKILL_BLOODDRAIN,
	SKILL_STUN, SKILL_CRIT, SKILL_POISON, SKILL_REFLECT, SKILL_RUSH,
	SKILL_HEAL, SKILL_WEAK, SKILL_SILENCE, SKILL_DOUBLEHIT, SKILL_IMMUNE,
	SKILL_DRAINMP, SKILL_MEDITATE, SKILL_OVERLOAD,
	SKILL_STOPSHORT, SKILL_GOLDBURST, SKILL_MONEYLOVER,
	SKILL_CALM // 静心咒 ID22
};
// 怪物技能ID
enum MonsterSkillID {
	MSKILL_NONE, MSKILL_IMPRISON_PLAYER, MSKILL_POISON, MSKILL_WEAK, MSKILL_DOUBLEATK,
	MSKILL_REVIVE
};
// 道具档次枚举
enum ItemTier { ITEM_SMALL, ITEM_MID, ITEM_BIG, ITEM_GOD };

// ===================== 存档工具 =====================
void GetRpgFileName(int slot, char buf[64]) {
	sprintf(buf, "%s%d.dat", RPG_SAVE_PREFIX, slot);
}
bool RpgSlotExist(int slot) {
	char buf[64];
	GetRpgFileName(slot, buf);
	ifstream f(buf, ios::binary);
	bool res = f.is_open();
	f.close();
	return res;
}

// ===================== 数据结构体(v1.2.3 扩展道具存储,兼容旧存档) =====================
struct Skill {
	int id, quality;
	Skill() : id(SKILL_NONE), quality(WHITE) {}
	Skill(int i, int q) : id(i), quality(q) {}
};
// 道具仓库结构体
struct ItemBag {
	int hpPotion[4];
	int mpPotion[4];
	int knife;
	ItemBag() {
		memset(hpPotion, 0, sizeof(hpPotion));
		memset(mpPotion, 0, sizeof(mpPotion));
		knife = 0;
	}
};
// 基础存档固定块(扩展ItemBag,旧存档自动补0)
struct RpgSaveBase {
	char name[32];
	int hp, maxhp, atk, def, gold, stage;
	int skillCnt;
	Skill skills[20];
	int mp, maxmp, gem;
	ItemBag items;
};
struct RpgSaveData {
	RpgSaveBase base;
	vector<int> godSkillList;
} rpgData;

struct MonsterSkill {
	int id, quality;
	bool reviveUsed;
	MonsterSkill() : id(MSKILL_NONE), quality(WHITE), reviveUsed(false) {}
	MonsterSkill(int i, int q) : id(i), quality(q), reviveUsed(false) {}
};
struct Monster {
	int hp, maxhp, atk, def;
	int monsterImprisonTurn;
	vector<MonsterSkill> msList;
	int eliteVal;
	bool revived;
} monster;

// 全局战斗变量
int buffAtk, buffDef, poisonDmg;
int playerImprisonTurn;
float monsterImprisonRate;
int SkillBaseMp[22] = {0,8,12,10,15,20,18,22,14,15,9,24,17,25,11,28,16,6,28,12,22,14};
int curSlot = -1;
int shopSellType;
ItemTier shopSellTier;

// ===================== 存档读写(兼容v1.2.0/1.2.1旧存档) =====================
bool LoadSave(int slot) {
	char buf[64];
	GetRpgFileName(slot, buf);
	ifstream fin(buf, ios::binary);
	if (!fin.is_open()) return false;
	
	memset(&rpgData.base, 0, sizeof(RpgSaveBase));
	rpgData.godSkillList.clear();
	
	fin.read((char*)&rpgData.base, sizeof(RpgSaveBase));
	int godSize;
	fin.read((char*)&godSize, sizeof(int));
	rpgData.godSkillList.resize(godSize);
	if (godSize > 0)
		fin.read((char*)rpgData.godSkillList.data(), sizeof(int) * godSize);
	fin.close();
	
	if (rpgData.base.maxmp == 0) rpgData.base.maxmp = 50;
	rpgData.base.mp = rpgData.base.maxmp;
	
	// v1.2.5新增:过滤旧存档空技能,同步修正skillCnt
	int realCnt = 0;
	for(int i=0;i<20;i++){
		if(rpgData.base.skills[i].id != SKILL_NONE){
			rpgData.base.skills[realCnt] = rpgData.base.skills[i];
			realCnt++;
		}
	}
	// 剩余位置清空为空技能
	for(int i=realCnt;i<20;i++){
		rpgData.base.skills[i] = Skill();
	}
	rpgData.base.skillCnt = realCnt;
	
	return true;
}
void SaveSave(int slot) {
	char buf[64];
	GetRpgFileName(slot, buf);
	ofstream f(buf, ios::binary);
	f.write((char*)&rpgData.base, sizeof(RpgSaveBase));
	int godSize = rpgData.godSkillList.size();
	f.write((char*)&godSize, sizeof(int));
	if (godSize > 0)
		f.write((char*)rpgData.godSkillList.data(), sizeof(int) * godSize);
	f.close();
}
void NewPlayer() {
	memset(&rpgData.base, 0, sizeof(RpgSaveBase));
	rpgData.base.hp = rpgData.base.maxhp = 100;
	rpgData.base.atk = 10; rpgData.base.def = 5;
	rpgData.base.gold = rpgData.base.gem = rpgData.base.skillCnt = 0;
	rpgData.base.stage = 1; // 修复:初始层数改为1
	for (int i = 0; i < 20; i++) rpgData.base.skills[i] = Skill();
	rpgData.base.maxmp = 50;
	rpgData.base.mp = rpgData.base.maxmp;
	rpgData.base.items = ItemBag();
	rpgData.godSkillList.clear();
}

// ===================== 文本工具 =====================
string GetQualityStr(int q) {
	if (q == WHITE) return "白色";
	if (q == GREEN) return "绿色";
	if (q == BLUE) return "蓝色";
	if (q == PURPLE) return "紫色";
	if (q == GOD_SKILL) return "神技";
	return "未知";
}
string GetSkillName(int id) {
	switch (id) {
		case SKILL_POWERUP: return "狂怒增幅";
		case SKILL_SHIELD: return "钢铁壁垒";
		case SKILL_LIFESTEAL: return "吸血打击";
		case SKILL_SWAPHP: return "生命置换";
		case SKILL_BLOODDRAIN: return "鲜血汲取";
		case SKILL_STUN: return "眩晕重击";
		case SKILL_CRIT: return "致命穿刺";
		case SKILL_POISON: return "毒素腐蚀";
		case SKILL_REFLECT: return "伤害反弹";
		case SKILL_RUSH: return "冲锋突刺";
		case SKILL_HEAL: return "愈疗之光";
		case SKILL_WEAK: return "破碎护甲";
		case SKILL_SILENCE: return "灵魂禁锢";
		case SKILL_DOUBLEHIT: return "连环斩击";
		case SKILL_IMMUNE: return "超负荷";
		case SKILL_DRAINMP: return "吸能打击";
		case SKILL_MEDITATE: return "静心冥想";
		case SKILL_OVERLOAD: return "暗影潜行";
		case SKILL_STOPSHORT: return "点到为止";
		case SKILL_GOLDBURST: return "豪掷千金";
		case SKILL_MONEYLOVER: return "拜金";
		case SKILL_CALM: return "静心咒";
		default: return "未知技能";
	}
}
string GetMonsterSkillName(int id) {
	switch (id) {
		case MSKILL_IMPRISON_PLAYER: return "禁锢缠绕";
		case MSKILL_POISON: return "撕裂流血";
		case MSKILL_WEAK: return "削弱攻防";
		case MSKILL_DOUBLEATK: return "狂暴重击";
		case MSKILL_REVIVE: return "卷土重来";
		default: return "无";
	}
}
string GetItemTierName(ItemTier t) {
	if (t == ITEM_SMALL) return "小";
	if (t == ITEM_MID) return "中";
	if (t == ITEM_BIG) return "大";
	if (t == ITEM_GOD) return "神";
	return "";
}
int GetNormalMpCost(Skill s) {
	int base = SkillBaseMp[s.id];
	double rate;
	if (s.quality == WHITE) rate = 1.0;
	else if (s.quality == GREEN) rate = 0.9;
	else if (s.quality == BLUE) rate = 0.8;
	else if (s.quality == PURPLE) rate = 0.7;
	else rate = 1.0;
	int calc = static_cast<int>(base * rate);
	return max(2, calc);
}
int GetPurpleMp(int skillId) {
	int base = SkillBaseMp[skillId];
	int calc = static_cast<int>(base * 0.7);
	return max(2, calc);
}
int GetGodMpCost(int skillId) {
	int purMp = GetPurpleMp(skillId);
	return min(purMp, 10);
}
int GetCalmMpCost(int q) {
	double pct;
	if (q == WHITE) pct = 0.5;
	else if (q == GREEN) pct = 0.42;
	else if (q == BLUE) pct = 0.35;
	else if (q == PURPLE) pct = 0.3;
	else pct = 0.1;
	return static_cast<int>(rpgData.base.maxmp * pct);
}
double GetQualityMul(int q) {
	if (q == WHITE) return 1.0;
	if (q == GREEN) return 1.2;
	if (q == BLUE) return 1.45;
	if (q == PURPLE) return 1.8;
	if (q == GOD_SKILL) return 2.0;
	return 1.0;
}
pair<int, int> GetItemPrice(int type, ItemTier tier) {
	if (tier == ITEM_SMALL) return make_pair(20, 0);
	if (tier == ITEM_MID) return make_pair(25, 0);
	if (tier == ITEM_BIG) return make_pair(10, 1);
	if (tier == ITEM_GOD) return make_pair(0, 2);
	return make_pair(9999, 9999);
}
void RefreshShopItem() {
	shopSellType = rand() % 2;
	int r = rand() % 100;
	if (r < 45) shopSellTier = ITEM_SMALL;
	else if (r < 80) shopSellTier = ITEM_MID;
	else if (r < 96) shopSellTier = ITEM_BIG;
	else shopSellTier = ITEM_GOD;
}
void PrintItemBag() {
	cout << "===== 【道具仓库】 =====\n";
	cout << "【血瓶】:\n";
	cout << "【小】 x" << rpgData.base.items.hpPotion[ITEM_SMALL] << "\n";
	cout << "【中】 x" << rpgData.base.items.hpPotion[ITEM_MID] << "\n";
	cout << "【大】 x" << rpgData.base.items.hpPotion[ITEM_BIG] << "\n";
	cout << "【神】 x" << rpgData.base.items.hpPotion[ITEM_GOD] << "\n\n";
	cout << "【魔力瓶】:\n";
	cout << "【小】 x" << rpgData.base.items.mpPotion[ITEM_SMALL] << "\n";
	cout << "【中】 x" << rpgData.base.items.mpPotion[ITEM_MID] << "\n";
	cout << "【大】 x" << rpgData.base.items.mpPotion[ITEM_BIG] << "\n";
	cout << "【神】 x" << rpgData.base.items.mpPotion[ITEM_GOD] << "\n\n";
	int knifeCnt = rpgData.base.items.knife;
	cout << "永久增益道具:\n";
	cout << "【小刀】 x" << knifeCnt << "  总永久攻击加成:" << knifeCnt * 15 << "\n";
	cout << "========================\n";
}
bool UseHpPotion() {
	while (true) {
		system("cls");
		cout << "==== 使用血瓶 ====\n";
		cout << "1.【小】 x" << rpgData.base.items.hpPotion[ITEM_SMALL] << "\n";
		cout << "2.【中】 x" << rpgData.base.items.hpPotion[ITEM_MID] << "\n";
		cout << "3.【大】 x" << rpgData.base.items.hpPotion[ITEM_BIG] << "\n";
		cout << "4.【神】 x" << rpgData.base.items.hpPotion[ITEM_GOD] << "\n";
		cout << "0. 返回道具面板\n";
		char op = _getch();
		if (op == '0') return false;
		ItemTier t;
		int heal = 0;
		if (op == '1') { t = ITEM_SMALL; heal = 10; }
		else if (op == '2') { t = ITEM_MID; heal = 25; }
		else if (op == '3') { t = ITEM_BIG; heal = 50; }
		else if (op == '4') { t = ITEM_GOD; heal = 9999; }
		else continue;
		if (rpgData.base.items.hpPotion[t] <= 0) {
			cout << "该道具数量不足!任意键返回\n";
			_getch();
			continue;
		}
		rpgData.base.items.hpPotion[t]--;
		if (heal >= 9999) rpgData.base.hp = rpgData.base.maxhp;
		else rpgData.base.hp = min(rpgData.base.hp + heal, rpgData.base.maxhp);
		cout << "使用成功!当前HP:" << rpgData.base.hp << "\n任意键继续\n";
		_getch();
		return true;
	}
}
bool UseMpPotion() {
	while (true) {
		system("cls");
		cout << "==== 使用魔力瓶 ====\n";
		cout << "1.【小】 x" << rpgData.base.items.mpPotion[ITEM_SMALL] << "\n";
		cout << "2.【中】 x" << rpgData.base.items.mpPotion[ITEM_MID] << "\n";
		cout << "3.【大】 x" << rpgData.base.items.mpPotion[ITEM_BIG] << "\n";
		cout << "4.【神】 x" << rpgData.base.items.mpPotion[ITEM_GOD] << "\n";
		cout << "0. 返回道具面板\n";
		char op = _getch();
		if (op == '0') return false;
		ItemTier t;
		int restore = 0;
		if (op == '1') { t = ITEM_SMALL; restore = 10; }
		else if (op == '2') { t = ITEM_MID; restore = 25; }
		else if (op == '3') { t = ITEM_BIG; restore = 50; }
		else if (op == '4') { t = ITEM_GOD; restore = 9999; }
		else continue;
		if (rpgData.base.items.mpPotion[t] <= 0) {
			cout << "该道具数量不足!任意键返回\n";
			_getch();
			continue;
		}
		rpgData.base.items.mpPotion[t]--;
		if (restore >= 9999) rpgData.base.mp = rpgData.base.maxmp;
		else rpgData.base.mp = min(rpgData.base.mp + restore, rpgData.base.maxmp);
		cout << "使用成功!当前MP:" << rpgData.base.mp << "\n任意键继续\n";
		_getch();
		return true;
	}
}
void OpenItemUsePanel() {
	while (true) {
		system("cls");
		PrintItemBag();
		cout << "1. 使用血瓶\n";
		cout << "2. 使用魔力瓶\n";
		cout << "0. 跳过道具使用,继续回合\n";
		char op = _getch();
		if (op == '0') break;
		if (op == '1') UseHpPotion();
		if (op == '2') UseMpPotion();
	}
}
void DropMonsterItem(int eliteLv) {
	// 精英怪 5%概率掉落
	if (eliteLv == 1) {
		if (rand() % 100 < 5) {
			int type = rand() % 2;
			ItemTier t = ItemTier(rand() % 4);
			if (type == 0) rpgData.base.items.hpPotion[t]++;
			else rpgData.base.items.mpPotion[t]++;
			cout << "精英怪掉落道具1件!\n";
		}
		return;
	}
	// 领主怪:基础掉落+1%小刀
	if (eliteLv == 2) {
		if (rand() % 100 < 5) {
			int type = rand() % 2;
			ItemTier t = ItemTier(rand() % 4);
			if (type == 0) rpgData.base.items.hpPotion[t]++;
			else rpgData.base.items.mpPotion[t]++;
			cout << "领主怪掉落消耗道具1件!\n";
		}
		if (rand() % 100 == 0) {
			rpgData.base.items.knife++;
			rpgData.base.atk += 15;
			cout << "稀有掉落【小刀】!永久攻击+15\n";
		}
		return;
	}
	// BOSS 100% 1~3件
	if (eliteLv == 3) {
		int dropCnt = 1;
		int r = rand() % 100;
		if (r >= 80) dropCnt = rand() % 3 + 1;
		cout << "BOSS掉落" << dropCnt << "件道具!\n";
		for (int i = 0; i < dropCnt; i++) {
			int type = rand() % 2;
			ItemTier t = ItemTier(rand() % 4);
			if (type == 0) rpgData.base.items.hpPotion[t]++;
			else rpgData.base.items.mpPotion[t]++;
		}
		return;
	}
}

// ===================== 商店、抽卡(v1.2.3新增随机道具贩卖) =====================
void DrawNormalSkill() {
	system("cls");
	cout << "抽普通技能 消耗30金币,20%空\n金币:" << rpgData.base.gold << "\n";
	if (rpgData.base.gold < 30) {
		cout << "金币不足,按任意键返回";
		_getch(); return;
	}
	rpgData.base.gold -= 30;
	if (rand() % 100 < 20) {
		cout << "本次抽空,无技能";
		_getch(); return;
	}
	Skill sk;
	sk.id = rand() % 21 + 1;
	int r = rand() % 100;
	if (r < 50) sk.quality = WHITE;
	else if (r < 80) sk.quality = GREEN;
	else if (r < 95) sk.quality = BLUE;
	else sk.quality = PURPLE;
	bool hasSame = false;
	for (int i = 0; i < rpgData.base.skillCnt; i++) {
		if (rpgData.base.skills[i].id == sk.id) {
			hasSame = true;
			Skill& old = rpgData.base.skills[i];
			if (sk.quality > old.quality) {
				cout << "品质提升:【" << GetQualityStr(old.quality) << "】" << GetSkillName(old.id);
				old.quality = sk.quality;
				cout << " → 【" << GetQualityStr(old.quality) << "】" << GetSkillName(old.id) << "\n";
			} else if (sk.quality == old.quality && sk.quality < PURPLE) {
				cout << "同品质进阶:【" << GetQualityStr(old.quality) << "】" << GetSkillName(old.id);
				old.quality++;
				cout << " → 【" << GetQualityStr(old.quality) << "】" << GetSkillName(old.id) << "\n";
			} else {
				cout << "已有更高/同等品质的【" << GetSkillName(old.id) << "】,无变化\n";
			}
			break;
		}
	}
	if (!hasSame) {
		if (rpgData.base.skillCnt < 20) {
			rpgData.base.skills[rpgData.base.skillCnt++] = sk;
			cout << "获得新技能:【" << GetQualityStr(sk.quality) << "】" << GetSkillName(sk.id) << "\n";
		} else {
			cout << "技能栏已满,无法获取【" << GetSkillName(sk.id) << "】\n";
		}
	}
	_getch();
}
void BuyGodSkill() {
	system("cls");
	cout << "宝石商店抽取神技,消耗5宝石,必出神技\n宝石:" << rpgData.base.gem << "\n";
	if (rpgData.base.gem < 5) {
		cout << "宝石不足";
		_getch(); return;
	}
	rpgData.base.gem -= 5;
	int newGodId = rand() % 22 + 1;
	for (int i = 0; i < rpgData.base.skillCnt; i++) {
		if (rpgData.base.skills[i].id == newGodId) {
			for (int j = i; j < rpgData.base.skillCnt - 1; j++)
				rpgData.base.skills[j] = rpgData.base.skills[j + 1];
			rpgData.base.skillCnt--;
			break;
		}
	}
	bool exist = false;
	for (int x : rpgData.godSkillList)
		if (x == newGodId) exist = true;
	if (!exist) rpgData.godSkillList.push_back(newGodId);
	cout << "获得神技:" << GetSkillName(newGodId) << "\n";
	_getch();
}
void BuyShopItem() {
	pair<int, int> price = GetItemPrice(shopSellType, shopSellTier);
	int costGold = price.first;
	int costGem = price.second;
	if (rpgData.base.gold < costGold || rpgData.base.gem < costGem) {
		cout << "资源不足,无法购买!\n";
		_getch();
		return;
	}
	rpgData.base.gold -= costGold;
	rpgData.base.gem -= costGem;
	if (shopSellType == 0) rpgData.base.items.hpPotion[shopSellTier]++;
	else rpgData.base.items.mpPotion[shopSellTier]++;
	cout << "购买成功!道具已存入仓库\n";
	RefreshShopItem();
	_getch();
}
void Shop() {
	RefreshShopItem();
	while (true) {
		system("cls");
		cout << "==== CWR v1.2.5 商店 ====\n";
		cout << "金币:" << rpgData.base.gold << " 宝石:" << rpgData.base.gem << "\n";
		cout << "1. 抽普通技能 30金\n";
		cout << "2. 永久血量上限+20 50金\n";
		cout << "3. 永久攻击力+5 80金\n";
		cout << "4. 永久防御力+3 80金\n";
		cout << "5. 永久魔力上限+15 60金\n";
		cout << "6. 抽取随机神技 5宝石\n";
		pair<int, int> p = GetItemPrice(shopSellType, shopSellTier);
		string itemName = (shopSellType == 0) ? "血瓶" : "魔力瓶";
		cout << "7. 购买【" << GetItemTierName(shopSellTier) << "】" << itemName;
		if (p.first > 0) cout << " " << p.first << "金";
		if (p.second > 0) cout << " " << p.second << "宝石";
		cout << "\n";
		cout << "8. 打开道具仓库\n";
		cout << "0. 离开商店\n";
		char op = _getch();
		if (op == '0') break;
		if (op == '1') DrawNormalSkill();
		if (op == '2') {
			if (rpgData.base.gold < 50) { cout << "金币不足"; _getch(); continue; }
			rpgData.base.gold -= 50;
			rpgData.base.maxhp += 20;
			rpgData.base.hp += 20;
			cout << "永久最大HP+20"; _getch();
		}
		if (op == '3') {
			if (rpgData.base.gold < 80) { cout << "金币不足"; _getch(); continue; }
			rpgData.base.gold -= 80;
			rpgData.base.atk += 5;
			cout << "永久攻击力+5"; _getch();
		}
		if (op == '4') {
			if (rpgData.base.gold < 80) { cout << "金币不足"; _getch(); continue; }
			rpgData.base.gold -= 80;
			rpgData.base.def += 3;
			cout << "永久防御力+3"; _getch();
		}
		if (op == '5') {
			if (rpgData.base.gold < 60) { cout << "金币不足"; _getch(); continue; }
			rpgData.base.gold -= 60;
			rpgData.base.maxmp += 15;
			rpgData.base.mp += 15;
			cout << "永久魔力上限+15"; _getch();
		}
		if (op == '6') BuyGodSkill();
		if (op == '7') BuyShopItem();
		if (op == '8') {
			system("cls");
			PrintItemBag();
			cout << "任意键返回商店\n";
			_getch();
		}
	}
}
void ShowSkillList() {
	int page = 0;
	while (true) {
		system("cls");
		cout << "=== 已持有普通技能 ===\n";
		int st = page * SKILL_PAGE_CNT;
		size_t ed = min((size_t)(st + SKILL_PAGE_CNT), (size_t)rpgData.base.skillCnt);
		for (int i = st; (size_t)i < ed; i++) {
			Skill s = rpgData.base.skills[i];
			int mp;
			if (s.id == SKILL_CALM) mp = GetCalmMpCost(s.quality);
			else mp = GetNormalMpCost(s);
			cout << i + 1 << "." << GetQualityStr(s.quality) << GetSkillName(s.id) << " MP:" << mp << "\n";
		}
		cout << "\n=== 神技列表 ===\n";
		for (int gid : rpgData.godSkillList) {
			cout << GetSkillName(gid) << " MP:" << GetGodMpCost(gid) << "\n";
		}
		cout << "\nA上页 D下页 0退出";
		char c = _getch();
		if (c == '0') break;
		if (c == 'a' && page > 0) page--;
		if (c == 'd' && ed < (size_t)rpgData.base.skillCnt) page++;
	}
}

// ===================== 战斗技能效果 =====================
void CastSkillEffect(int sid, int q, int &pHP, int &mHP, int mMaxHp, bool &moneyLoverFlag) {
	double mul = GetQualityMul(q);
	double atkDmg = (rpgData.base.atk + buffAtk) * mul;
	switch (sid) {
	case SKILL_POWERUP:
		{
			buffAtk += static_cast<int>(10 * mul);
			cout << "狂怒增幅:临时攻击力提升\n";
		}break;
	case SKILL_SHIELD:
		{
			buffDef += static_cast<int>(8 * mul);
			cout << "钢铁壁垒:临时防御力提升\n";
		}break;
	case SKILL_LIFESTEAL:
		{
			double d = atkDmg * 1.2;
			int hit = max(static_cast<int>(d) - monster.def, 1);
			mHP -= hit;
			int heal = static_cast<int>(d * 0.4 * mul);
			pHP = min(pHP + heal, rpgData.base.maxhp);
			cout << "吸血打击,造成伤害并回血\n";
		}break;
	case SKILL_SWAPHP:
		{
			int tmp = pHP; pHP = mHP; mHP = tmp;
			pHP += static_cast<int>(80 * mul);
			pHP = min(pHP, rpgData.base.maxhp);
			cout << "生命置换,互换双方血量\n";
		}break;
	case SKILL_BLOODDRAIN:
		{
			int dot = static_cast<int>(rpgData.base.atk * 0.4 * mul);
			poisonDmg += dot;
			int hit = max(static_cast<int>(atkDmg) - monster.def, 1);
			mHP -= hit;
			cout << "鲜血汲取,附加持续流血\n";
		}break;
	case SKILL_STUN:
		{
			monster.monsterImprisonTurn += static_cast<int>(2 * mul);
			double raw = atkDmg * 1.5;
			int hit = max(static_cast<int>(raw) - monster.def, 1);
			mHP -= hit;
			cout << "眩晕重击,禁锢怪物\n";
		}break;
	case SKILL_CRIT:
		{
			int trueD = static_cast<int>(rpgData.base.atk * 1.8 * mul);
			mHP -= max(trueD, 1);
			cout << "致命穿刺,真实伤害\n";
		}break;
	case SKILL_POISON:
		{
			poisonDmg += static_cast<int>(rpgData.base.atk * 0.25 * mul);
			monster.def -= static_cast<int>(10 * mul);
			cout << "毒素腐蚀,持续毒伤+减防\n";
		}break;
	case SKILL_REFLECT:
		{
			buffDef += static_cast<int>(15 * mul);
			double raw = atkDmg * 0.6;
			int hit = max(static_cast<int>(raw) - monster.def, 1);
			mHP -= hit;
			cout << "伤害反弹护盾\n";
		}break;
	case SKILL_RUSH:
		{
			double raw = atkDmg * 1.3;
			int hit = max(static_cast<int>(raw) - monster.def, 1);
			mHP -= hit;
			cout << "冲锋突刺\n";
		}break;
	case SKILL_HEAL:
		{
			int h = static_cast<int>(rpgData.base.maxhp * 0.35 * mul);
			pHP = min(pHP + h, rpgData.base.maxhp);
			poisonDmg = 0;
			cout << "愈疗之光,清除DOT并回血\n";
		}break;
	case SKILL_WEAK:
		{
			monster.def -= static_cast<int>(12 * mul);
			int hit = max(static_cast<int>(atkDmg) - monster.def, 1);
			mHP -= hit;
			cout << "破碎护甲,永久减防\n";
		}break;
	case SKILL_SILENCE:
		{
			monster.monsterImprisonTurn += static_cast<int>(2 * mul);
			int hit = max(static_cast<int>(atkDmg) - monster.def, 1);
			mHP -= hit;
			cout << "灵魂禁锢,封锁怪物技能\n";
		}break;
	case SKILL_DOUBLEHIT:
		{
			double raw = atkDmg * 0.7;
			int hit1 = max(static_cast<int>(raw) - monster.def, 1);
			int hit2 = max(static_cast<int>(raw) - monster.def, 1);
			mHP -= hit1 + hit2;
			cout << "连环斩击两段伤害\n";
		}break;
	case SKILL_IMMUNE:
		{
			buffAtk += static_cast<int>(40 * mul);
			cout << "超负荷大幅增攻\n";
		}break;
	case SKILL_DRAINMP:
		{
			int stealMp = static_cast<int>(8 * mul);
			rpgData.base.mp = min(rpgData.base.mp + stealMp, rpgData.base.maxmp);
			double raw = atkDmg * 1.1;
			int hit = max(static_cast<int>(raw) - monster.def, 1);
			mHP -= hit;
			cout << "吸能打击,偷取魔力\n";
		}break;
	case SKILL_MEDITATE:
		{
			int hpHeal = static_cast<int>(rpgData.base.maxhp * 0.25 * mul);
			int mpHeal = static_cast<int>(20 * mul);
			pHP = min(pHP + hpHeal, rpgData.base.maxhp);
			rpgData.base.mp = min(rpgData.base.mp + mpHeal, rpgData.base.maxmp);
			cout << "静心冥想,回血回蓝跳过回合\n";
		}break;
	case SKILL_OVERLOAD:
		{
			double raw = atkDmg * 1.3;
			int hit = max(static_cast<int>(raw) - monster.def, 1);
			mHP -= hit;
			cout << "暗影潜行\n";
		}break;
	case SKILL_STOPSHORT:
		{
			int phys = static_cast<int>(rpgData.base.atk * 1.2 * mul);
			int trueD = static_cast<int>(rpgData.base.atk * 0.05 * mul);
			int all = phys + trueD;
			int hit = min(all, mHP - 1);
			mHP -= hit;
			cout << "点到为止,强制保留1血\n";
		}break;
	case SKILL_GOLDBURST:
		{
			cout << "输入消耗金币:";
			int cost; cin >> cost;
			if (cost <= 0 || rpgData.base.gold < cost) {
				cout << "金币不足,技能失效"; break;
			}
			rpgData.base.gold -= cost;
			long long hit = static_cast<long long>(cost) * 1.5 * rpgData.base.atk * mul;
			mHP -= static_cast<int>(hit);
			cout << "豪掷千金巨额伤害\n";
		}break;
	case SKILL_MONEYLOVER:
		{
			mHP -= 1;
			moneyLoverFlag = true;
			cout << "拜金,1点真实伤害,击杀收益翻倍\n";
		}break;
	case SKILL_CALM:
		{
			playerImprisonTurn = 0;
			pHP += static_cast<int>(10 * mul);
			pHP = min(pHP, rpgData.base.maxhp);
			cout << "静心咒,解除禁锢并回血\n";
		}break;
	default:
		{
			int hit = max(static_cast<int>(atkDmg) - monster.def, 1);
			mHP -= hit;
		}break;
	}
}
void SpawnMonster() {
	monster.msList.clear();
	monster.monsterImprisonTurn = poisonDmg = 0;
	playerImprisonTurn = 0;
	monster.revived = false;
	monsterImprisonRate = 1.0f;
	monster.maxhp = 20 + rpgData.base.stage * 12;
	monster.hp = monster.maxhp;
	monster.atk = 4 + rpgData.base.stage * 3;
	monster.def = 3 + rpgData.base.stage * 2;
	monster.eliteVal = 0;
	vector<int> used;
	bool addRevive = (rand() % 100 < 25);
	if (addRevive) {
		monster.msList.emplace_back(MSKILL_REVIVE, WHITE);
		monster.eliteVal += 5;
		used.push_back(MSKILL_REVIVE);
	}
	int cnt = rand() % 4;
	for (int i = 0; i < cnt; i++) {
		int sid;
		do {
			sid = rand() % 4 + 1;
		} while (find(used.begin(), used.end(), sid) != used.end());
		used.push_back(sid);
		int qr = rand() % 100;
		int q;
		if (qr < 60) { q = WHITE; monster.eliteVal += 1; }
		else if (qr < 85) { q = GREEN; monster.eliteVal += 2; }
		else if (qr < 97) { q = BLUE; monster.eliteVal += 3; }
		else { q = PURPLE; monster.eliteVal += 5; }
		monster.msList.emplace_back(sid, q);
	}
}
void Battle() {
	SpawnMonster();
	int playerHp = rpgData.base.hp;
	buffAtk = buffDef = 0;
	bool over = false;
	bool moneyLoverKill = false;
	while (!over) {
		system("cls");
		cout << "==== 战斗 第" << rpgData.base.stage << "层 ====\n";
		cout << "玩家 HP:" << playerHp << "/" << rpgData.base.maxhp << " MP:" << rpgData.base.mp << "/" << rpgData.base.maxmp << "\n";
		cout << "临时ATK+" << buffAtk << " DEF+" << buffDef << "\n";
		cout << "怪物 HP:" << monster.hp << "/" << monster.maxhp;
		if (monster.monsterImprisonTurn > 0) cout << " 怪物禁锢" << monster.monsterImprisonTurn;
		if (playerImprisonTurn > 0) cout << " 你被禁锢" << playerImprisonTurn;
		cout << "\n精英值:" << monster.eliteVal;
		int eliteLv = 0;
		if (monster.eliteVal > 10) { cout << "【BOSS】"; eliteLv = 3; }
		else if (monster.eliteVal > 5) { cout << "【领主】"; eliteLv = 2; }
		else if (monster.eliteVal > 3) { cout << "【精英】"; eliteLv = 1; }
		cout << "\n怪物技能:";
		for (auto &ms : monster.msList)
			cout << GetMonsterSkillName(ms.id) << "(" << GetQualityStr(ms.quality) << ") ";
		cout << "\n1普攻 2释放技能 3逃跑\n";
		char op = _getch();
		bool skip = false;
		if (op == '3') { cout << "逃跑无奖励"; _getch(); return; }
		if (playerImprisonTurn > 0) {
			bool hasCalm = false;
			int calmQ = WHITE;
			for (int i = 0; i < rpgData.base.skillCnt; i++) {
				if (rpgData.base.skills[i].id == SKILL_CALM) {
					hasCalm = true; calmQ = rpgData.base.skills[i].quality; break;
				}
			}
			int calmGodId = -1;
			for (int x : rpgData.godSkillList)
				if (x == SKILL_CALM) calmGodId = x;
			if (hasCalm || calmGodId != -1) {
				cout << "\n被禁锢!是否释放静心咒 1是 0否:";
				char c = _getch();
				if (c == '1') {
					if (calmGodId != -1) {
						int cost = GetGodMpCost(SKILL_CALM);
						if (rpgData.base.mp >= cost) {
							rpgData.base.mp -= cost;
							CastSkillEffect(SKILL_CALM, GOD_SKILL, playerHp, monster.hp, monster.maxhp, moneyLoverKill);
						} else cout << "MP不足\n";
					} else {
						int cost = GetCalmMpCost(calmQ);
						if (rpgData.base.mp >= cost) {
							rpgData.base.mp -= cost;
							CastSkillEffect(SKILL_CALM, calmQ, playerHp, monster.hp, monster.maxhp, moneyLoverKill);
						} else cout << "MP不足\n";
					}
					_getch();
				}
			}
			cout << "本回合无法行动,任意键跳过";
			_getch();
			playerImprisonTurn--;
		} else if (op == '1') {
			int rawDmg = (rpgData.base.atk + buffAtk) - monster.def;
			int d = max(rawDmg, 1);
			monster.hp -= d;
			cout << "普攻造成" << d << "伤害\n";
		} else if (op == '2') {
			system("cls");
			cout << "=== 普通技能 ===\n";
			for (int i = 0; i < rpgData.base.skillCnt; i++) {
				Skill s = rpgData.base.skills[i];
				int mp = (s.id == SKILL_CALM) ? GetCalmMpCost(s.quality) : GetNormalMpCost(s);
				cout << i + 1 << "." << GetQualityStr(s.quality) << GetSkillName(s.id) << " MP:" << mp << "\n";
			}
			cout << "\n=== G=释放神技 ===\n";
			size_t godLen = rpgData.godSkillList.size();
			for (size_t i = 0; i < godLen; i++)
				cout << GetSkillName(rpgData.godSkillList[i]) << " MP:" << GetGodMpCost(rpgData.godSkillList[i]) << "\n";
			cout << "输入数字/G释放,0返回:";
			string s; cin >> s;
			if (s == "g" || s == "G") {
				cout << "输入神技序号:";
				int gi; cin >> gi; gi--;
				if ((size_t)gi < godLen) {
					int gid = rpgData.godSkillList[gi];
					int cost = GetGodMpCost(gid);
					if (rpgData.base.mp >= cost) {
						rpgData.base.mp -= cost;
						CastSkillEffect(gid, GOD_SKILL, playerHp, monster.hp, monster.maxhp, moneyLoverKill);
						if (gid == SKILL_MEDITATE) skip = true;
					} else cout << "法力不足";
				} else cout << "序号错误";
			} else {
				int idx = stoi(s) - 1;
				if (idx >= 0 && (size_t)idx < (size_t)rpgData.base.skillCnt) {
					Skill sk = rpgData.base.skills[idx];
					int cost;
					if (sk.id == SKILL_CALM) cost = GetCalmMpCost(sk.quality);
					else cost = GetNormalMpCost(sk);
					if (rpgData.base.mp >= cost) {
						rpgData.base.mp -= cost;
						CastSkillEffect(sk.id, sk.quality, playerHp, monster.hp, monster.maxhp, moneyLoverKill);
						if (sk.id == SKILL_MEDITATE) skip = true;
						if (sk.id == SKILL_MONEYLOVER) moneyLoverKill = true;
					} else cout << "法力不足";
				} else if (stoi(s) != 0) cout << "无此技能";
			}
			_getch();
		}
		OpenItemUsePanel();
		rpgData.base.mp = min(rpgData.base.mp + 5, rpgData.base.maxmp);
		if (poisonDmg > 0) {
			monster.hp -= poisonDmg;
			cout << "毒素持续伤害:" << poisonDmg << "\n";
		}
		if (monster.hp <= 0 && !monster.revived) {
			for (auto &ms : monster.msList) {
				if (ms.id == MSKILL_REVIVE && !ms.reviveUsed) {
					ms.reviveUsed = true;
					monster.revived = true;
					monster.maxhp = static_cast<int>(monster.maxhp * 1.5);
					monster.hp = monster.maxhp;
					monster.atk = static_cast<int>(monster.atk * 1.5);
					monster.def = static_cast<int>(monster.def * 1.5);
					cout << "【卷土重来】怪物复活,全属性1.5倍\n";
					break;
				}
			}
			if (monster.hp > 0) {
				if (monster.monsterImprisonTurn > 0) {
					monsterImprisonRate -= 0.1f;
					if (monsterImprisonRate < 0.1f) monsterImprisonRate = 0.1f;
				}
				continue;
			}
		}
		if (monster.hp <= 0) { over = true; break; }
		if (skip) {
			cout << "冥想跳过怪物行动"; _getch(); continue;
		}
		bool useSkill = false;
		if (rand() % 100 < 40 && monster.msList.size() > 0) {
			auto ms = monster.msList[rand() % monster.msList.size()];
			if (ms.id == MSKILL_REVIVE) goto monsterAtk;
			useSkill = true;
			double mul = GetQualityMul(ms.quality);
			if (ms.id == MSKILL_IMPRISON_PLAYER) {
				int turn = static_cast<int>(2 * mul * monsterImprisonRate);
				playerImprisonTurn += turn;
				double rawDmg = monster.atk * 0.8 * mul;
				int dmg = max(static_cast<int>(rawDmg) - buffDef, 1);
				playerHp -= dmg;
				cout << "怪物禁锢你" << turn << "回合\n";
			} else if (ms.id == MSKILL_POISON) {
				double rawDmg = monster.atk * 0.6 * mul;
				int dmg = max(static_cast<int>(rawDmg) - buffDef, 1);
				playerHp -= dmg;
				poisonDmg += static_cast<int>(monster.atk * 0.6 * mul);
				cout << "怪物撕裂流血\n";
			} else if (ms.id == MSKILL_WEAK) {
				buffAtk -= static_cast<int>(4 * mul);
				buffDef -= static_cast<int>(4 * mul);
				double rawDmg = monster.atk * 0.9 * mul;
				int dmg = max(static_cast<int>(rawDmg) - buffDef, 1);
				playerHp -= dmg;
				cout << "怪物削弱攻防\n";
			} else if (ms.id == MSKILL_DOUBLEATK) {
				double rawDmg = monster.atk * 1.6 * mul;
				int dmg = max(static_cast<int>(rawDmg) - buffDef, 1);
				playerHp -= dmg;
				cout << "怪物狂暴重击\n";
			}
		}
		monsterAtk:
		if (!useSkill) {
			int dmgRaw = monster.atk - buffDef;
			int dmg = max(dmgRaw, 1);
			playerHp -= dmg;
			cout << "怪物普攻造成" << dmg << "\n";
		}
		_getch();
		if (playerHp <= 0) { over = true; break; }
		if (monster.monsterImprisonTurn > 0) monster.monsterImprisonTurn--;
		if (monster.monsterImprisonTurn == 0 && monsterImprisonRate > 0.1f) {
			monsterImprisonRate -= 0.1f;
			if (monsterImprisonRate < 0.1f) monsterImprisonRate = 0.1f;
		}
	}
	system("cls");
	if (playerHp <= 0) {
		cout << "战败!层数重置为1,血蓝回满\n";
		rpgData.base.stage = 1;
		rpgData.base.hp = rpgData.base.maxhp;
		rpgData.base.mp = rpgData.base.maxmp;
	} else {
		rpgData.base.mp = rpgData.base.maxmp;
		double rate = 1.0;
		if (monster.eliteVal > 10) rate = 2.0;
		else if (monster.eliteVal > 5) rate = 1.75;
		else if (monster.eliteVal > 3) rate = 1.5;
		if (monster.revived) rate *= 2;
		if (moneyLoverKill) rate *= 2;
		int baseGold = 15 + rpgData.base.stage * 8;
		int getGold = static_cast<int>(baseGold * rate);
		int gemDrop = 0;
		int eliteLv = 0;
		if (monster.eliteVal > 10) eliteLv = 3;
		else if (monster.eliteVal > 5) eliteLv = 2;
		else if (monster.eliteVal > 3) eliteLv = 1;
		DropMonsterItem(eliteLv);
		if (monster.eliteVal > 3) gemDrop = rand() % monster.eliteVal;
		rpgData.base.gold += getGold;
		rpgData.base.gem += gemDrop;
		cout << "胜利!\n获得金币:" << getGold << " 宝石:" << gemDrop << "\n倍率:" << rate;
		if (monster.revived) cout << "【卷土重来双倍】";
		if (moneyLoverKill) cout << "【拜金双倍】";
	}
	rpgData.base.stage++; // 通关自动下一层
	_getch();
}

void MainMenu() {
	while (true) {
		system("cls");
		cout << "==== CWR v1.2.5 主菜单 ====\n";
		cout << "1. 新建角色\n";
		cout << "2. 读取存档\n";
		cout << "0. 退出\n";
		char op = _getch();
		if (op == '0') exit(0);
		if (op == '1') {
			NewPlayer();
			cout << "输入角色名:";
			cin >> rpgData.base.name;
			curSlot = -1;
			break;
		}
		if (op == '2') {
			cout << "输入存档槽位(1~10):";
			int s; cin >> s;
			if (s < 1 || s > 10) { cout << "槽位错误"; _getch(); continue; }
			if (!RpgSlotExist(s)) { cout << "存档不存在"; _getch(); continue; }
			LoadSave(s);
			curSlot = s;
			break;
		}
	}
	while (true) {
		system("cls");
		cout << "角色:" << rpgData.base.name << " 层数:" << rpgData.base.stage << "\n";
		cout << "HP:" << rpgData.base.hp << "/" << rpgData.base.maxhp << " MP:" << rpgData.base.mp << "/" << rpgData.base.maxmp << "\n";
		int knifeTotalAtk = rpgData.base.items.knife * 15;
		cout << "ATK:" << rpgData.base.atk << "(小刀加成+" << knifeTotalAtk << ") DEF:" << rpgData.base.def << "\n";
		cout << "金币:" << rpgData.base.gold << " 宝石:" << rpgData.base.gem << "\n";
		cout << "1. 进入战斗\n";
		cout << "2. 商店\n";
		cout << "3. 查看技能\n";
		cout << "4. 保存存档\n";
		cout << "5. 打开道具仓库\n";
		cout << "0. 返回主菜单\n";
		char c = _getch();
		if (c == '0') break;
		if (c == '1') Battle();
		if (c == '2') Shop();
		if (c == '3') ShowSkillList();
		if (c == '4') {
			if (curSlot == -1) {
				cout << "输入存档槽位1~10保存:";
				cin >> curSlot;
			}
			SaveSave(curSlot);
			cout << "保存成功"; _getch();
		}
		if (c == '5') {
			system("cls");
			PrintItemBag();
			cout << "任意键返回\n";
			_getch();
		}
	}
}

int main() {
	srand((unsigned)time(nullptr));
	while (true) MainMenu();
	return 0;
}

v1.2.6

INFO
C++
//flpar
#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <conio.h>
#include <Windows.h>
#include <algorithm>
#include <fstream>
#include <cstring>
#include <string>
#include <utility>
using namespace std;

// ===================== RPG全局常量 =====================
const char RPG_SAVE_PREFIX[] = "rpg_slot";
const int RPG_SLOT_MAX = 10;
const int SKILL_PAGE_CNT = 8;

// 品质枚举
enum SkillQuality { WHITE, GREEN, BLUE, PURPLE, GOD_SKILL };
// 玩家技能ID
enum SkillID {
	SKILL_NONE,
	SKILL_POWERUP, SKILL_SHIELD, SKILL_LIFESTEAL, SKILL_SWAPHP, SKILL_BLOODDRAIN,
	SKILL_STUN, SKILL_CRIT, SKILL_POISON, SKILL_REFLECT, SKILL_RUSH,
	SKILL_HEAL, SKILL_WEAK, SKILL_SILENCE, SKILL_DOUBLEHIT, SKILL_IMMUNE,
	SKILL_DRAINMP, SKILL_MEDITATE, SKILL_OVERLOAD,
	SKILL_STOPSHORT, SKILL_GOLDBURST, SKILL_MONEYLOVER,
	SKILL_CALM // 静心咒 ID22
};
// 怪物技能ID
enum MonsterSkillID {
	MSKILL_NONE, MSKILL_IMPRISON_PLAYER, MSKILL_POISON, MSKILL_WEAK, MSKILL_DOUBLEATK,
	MSKILL_REVIVE
};
// 道具档次枚举
enum ItemTier { ITEM_SMALL, ITEM_MID, ITEM_BIG, ITEM_GOD };

// ===================== 存档工具 =====================
void GetRpgFileName(int slot, char buf[64]) {
	sprintf(buf, "%s%d.dat", RPG_SAVE_PREFIX, slot);
}
bool RpgSlotExist(int slot) {
	char buf[64];
	GetRpgFileName(slot, buf);
	ifstream f(buf, ios::binary);
	bool res = f.is_open();
	f.close();
	return res;
}

// ===================== 数据结构体(v1.2.3 扩展道具存储,兼容旧存档) =====================
struct Skill {
	int id, quality;
	Skill() : id(SKILL_NONE), quality(WHITE) {}
	Skill(int i, int q) : id(i), quality(q) {}
};
// 道具仓库结构体
struct ItemBag {
	int hpPotion[4];
	int mpPotion[4];
	int knife;
	ItemBag() {
		memset(hpPotion, 0, sizeof(hpPotion));
		memset(mpPotion, 0, sizeof(mpPotion));
		knife = 0;
	}
};
// 基础存档固定块(扩展ItemBag,旧存档自动补0)
struct RpgSaveBase {
	char name[32];
	int hp, maxhp, atk, def, gold, stage;
	int skillCnt;
	Skill skills[20];
	int mp, maxmp, gem;
	ItemBag items;
};
struct RpgSaveData {
	RpgSaveBase base;
	vector<int> godSkillList;
} rpgData;

struct MonsterSkill {
	int id, quality;
	bool reviveUsed;
	MonsterSkill() : id(MSKILL_NONE), quality(WHITE), reviveUsed(false) {}
	MonsterSkill(int i, int q) : id(i), quality(q), reviveUsed(false) {}
};
struct Monster {
	int hp, maxhp, atk, def;
	int monsterImprisonTurn;
	vector<MonsterSkill> msList;
	int eliteVal;
	bool revived;
} monster;

// 全局战斗变量
int buffAtk, buffDef, poisonDmg;
int playerImprisonTurn;
float monsterImprisonRate;
int SkillBaseMp[22] = {0,8,12,10,15,20,18,22,14,15,9,24,17,25,11,28,16,6,28,12,22,14};
int curSlot = -1;
int shopSellType;
ItemTier shopSellTier;
bool playerFirst; // v1.2.6 新增:固定先后手标记

// ===================== 存档读写(兼容v1.2.0/1.2.1旧存档) =====================
bool LoadSave(int slot) {
	char buf[64];
	GetRpgFileName(slot, buf);
	ifstream fin(buf, ios::binary);
	if (!fin.is_open()) return false;
	
	memset(&rpgData.base, 0, sizeof(RpgSaveBase));
	rpgData.godSkillList.clear();
	
	fin.read((char*)&rpgData.base, sizeof(RpgSaveBase));
	int godSize;
	fin.read((char*)&godSize, sizeof(int));
	rpgData.godSkillList.resize(godSize);
	if (godSize > 0)
		fin.read((char*)rpgData.godSkillList.data(), sizeof(int) * godSize);
	fin.close();
	
	if (rpgData.base.maxmp == 0) rpgData.base.maxmp = 50;
	rpgData.base.mp = rpgData.base.maxmp;
	
	// v1.2.5 旧存档空技能过滤修复
	int realCnt = 0;
	for(int i=0;i<20;i++){
		if(rpgData.base.skills[i].id != SKILL_NONE){
			rpgData.base.skills[realCnt] = rpgData.base.skills[i];
			realCnt++;
		}
	}
	for(int i=realCnt;i<20;i++){
		rpgData.base.skills[i] = Skill();
	}
	rpgData.base.skillCnt = realCnt;
	
	return true;
}
void SaveSave(int slot) {
	char buf[64];
	GetRpgFileName(slot, buf);
	ofstream f(buf, ios::binary);
	f.write((char*)&rpgData.base, sizeof(RpgSaveBase));
	int godSize = rpgData.godSkillList.size();
	f.write((char*)&godSize, sizeof(int));
	if (godSize > 0)
		f.write((char*)rpgData.godSkillList.data(), sizeof(int) * godSize);
	f.close();
}
void NewPlayer() {
	memset(&rpgData.base, 0, sizeof(RpgSaveBase));
	rpgData.base.hp = rpgData.base.maxhp = 100;
	rpgData.base.atk = 10; rpgData.base.def = 5;
	rpgData.base.gold = rpgData.base.gem = rpgData.base.skillCnt = 0;
	rpgData.base.stage = 1; // v1.2.5 修复初始层数为1
	for (int i = 0; i < 20; i++) rpgData.base.skills[i] = Skill();
	rpgData.base.maxmp = 50;
	rpgData.base.mp = rpgData.base.maxmp;
	rpgData.base.items = ItemBag();
	rpgData.godSkillList.clear();
}

// ===================== 文本工具 =====================
string GetQualityStr(int q) {
	if (q == WHITE) return "白色";
	if (q == GREEN) return "绿色";
	if (q == BLUE) return "蓝色";
	if (q == PURPLE) return "紫色";
	if (q == GOD_SKILL) return "神技";
	return "未知";
}
string GetSkillName(int id) {
	switch (id) {
		case SKILL_POWERUP: return "狂怒增幅";
		case SKILL_SHIELD: return "钢铁壁垒";
		case SKILL_LIFESTEAL: return "吸血打击";
		case SKILL_SWAPHP: return "生命置换";
		case SKILL_BLOODDRAIN: return "鲜血汲取";
		case SKILL_STUN: return "眩晕重击";
		case SKILL_CRIT: return "致命穿刺";
		case SKILL_POISON: return "毒素腐蚀";
		case SKILL_REFLECT: return "伤害反弹";
		case SKILL_RUSH: return "冲锋突刺";
		case SKILL_HEAL: return "愈疗之光";
		case SKILL_WEAK: return "破碎护甲";
		case SKILL_SILENCE: return "灵魂禁锢";
		case SKILL_DOUBLEHIT: return "连环斩击";
		case SKILL_IMMUNE: return "超负荷";
		case SKILL_DRAINMP: return "吸能打击";
		case SKILL_MEDITATE: return "静心冥想";
		case SKILL_OVERLOAD: return "暗影潜行";
		case SKILL_STOPSHORT: return "点到为止";
		case SKILL_GOLDBURST: return "豪掷千金";
		case SKILL_MONEYLOVER: return "拜金";
		case SKILL_CALM: return "静心咒";
		default: return "未知技能";
	}
}
string GetMonsterSkillName(int id) {
	switch (id) {
		case MSKILL_IMPRISON_PLAYER: return "禁锢缠绕";
		case MSKILL_POISON: return "撕裂流血";
		case MSKILL_WEAK: return "削弱攻防";
		case MSKILL_DOUBLEATK: return "狂暴重击";
		case MSKILL_REVIVE: return "卷土重来";
		default: return "无";
	}
}
string GetItemTierName(ItemTier t) {
	if (t == ITEM_SMALL) return "小";
	if (t == ITEM_MID) return "中";
	if (t == ITEM_BIG) return "大";
	if (t == ITEM_GOD) return "神";
	return "";
}
int GetNormalMpCost(Skill s) {
	int base = SkillBaseMp[s.id];
	double rate;
	if (s.quality == WHITE) rate = 1.0;
	else if (s.quality == GREEN) rate = 0.9;
	else if (s.quality == BLUE) rate = 0.8;
	else if (s.quality == PURPLE) rate = 0.7;
	else rate = 1.0;
	int calc = static_cast<int>(base * rate);
	return max(2, calc);
}
int GetPurpleMp(int skillId) {
	int base = SkillBaseMp[skillId];
	int calc = static_cast<int>(base * 0.7);
	return max(2, calc);
}
int GetGodMpCost(int skillId) {
	int purMp = GetPurpleMp(skillId);
	return min(purMp, 10);
}
int GetCalmMpCost(int q) {
	double pct;
	if (q == WHITE) pct = 0.5;
	else if (q == GREEN) pct = 0.42;
	else if (q == BLUE) pct = 0.35;
	else if (q == PURPLE) pct = 0.3;
	else pct = 0.1;
	return static_cast<int>(rpgData.base.maxmp * pct);
}
double GetQualityMul(int q) {
	if (q == WHITE) return 1.0;
	if (q == GREEN) return 1.2;
	if (q == BLUE) return 1.45;
	if (q == PURPLE) return 1.8;
	if (q == GOD_SKILL) return 2.0;
	return 1.0;
}
// 修复编译报错:缺失怪物技能倍率函数
double GetMonsterSkillMul(int q) {
	return GetQualityMul(q);
}
pair<int, int> GetItemPrice(int type, ItemTier tier) {
	if (tier == ITEM_SMALL) return make_pair(20, 0);
	if (tier == ITEM_MID) return make_pair(25, 0);
	if (tier == ITEM_BIG) return make_pair(10, 1);
	if (tier == ITEM_GOD) return make_pair(0, 2);
	return make_pair(9999, 9999);
}
void RefreshShopItem() {
	shopSellType = rand() % 2;
	int r = rand() % 100;
	if (r < 45) shopSellTier = ITEM_SMALL;
	else if (r < 80) shopSellTier = ITEM_MID;
	else if (r < 96) shopSellTier = ITEM_BIG;
	else shopSellTier = ITEM_GOD;
}
void PrintItemBag() {
	cout << "===== 【道具仓库】 =====\n";
	cout << "【血瓶】:\n";
	cout << "【小】 x" << rpgData.base.items.hpPotion[ITEM_SMALL] << "\n";
	cout << "【中】 x" << rpgData.base.items.hpPotion[ITEM_MID] << "\n";
	cout << "【大】 x" << rpgData.base.items.hpPotion[ITEM_BIG] << "\n";
	cout << "【神】 x" << rpgData.base.items.hpPotion[ITEM_GOD] << "\n\n";
	cout << "【魔力瓶】:\n";
	cout << "【小】 x" << rpgData.base.items.mpPotion[ITEM_SMALL] << "\n";
	cout << "【中】 x" << rpgData.base.items.mpPotion[ITEM_MID] << "\n";
	cout << "【大】 x" << rpgData.base.items.mpPotion[ITEM_BIG] << "\n";
	cout << "【神】 x" << rpgData.base.items.mpPotion[ITEM_GOD] << "\n\n";
	int knifeCnt = rpgData.base.items.knife;
	cout << "永久增益道具:\n";
	cout << "【小刀】 x" << knifeCnt << "  总永久攻击加成:" << knifeCnt * 15 << "\n";
	cout << "========================\n";
}
bool UseHpPotion() {
	while (true) {
		system("cls");
		cout << "==== 使用血瓶 ====\n";
		cout << "1.【小】 x" << rpgData.base.items.hpPotion[ITEM_SMALL] << "\n";
		cout << "2.【中】 x" << rpgData.base.items.hpPotion[ITEM_MID] << "\n";
		cout << "3.【大】 x" << rpgData.base.items.hpPotion[ITEM_BIG] << "\n";
		cout << "4.【神】 x" << rpgData.base.items.hpPotion[ITEM_GOD] << "\n";
		cout << "0. 返回道具面板\n";
		char op = _getch();
		if (op == '0') return false;
		ItemTier t;
		int heal = 0;
		if (op == '1') { t = ITEM_SMALL; heal = 10; }
		else if (op == '2') { t = ITEM_MID; heal = 25; }
		else if (op == '3') { t = ITEM_BIG; heal = 50; }
		else if (op == '4') { t = ITEM_GOD; heal = 9999; }
		else continue;
		if (rpgData.base.items.hpPotion[t] <= 0) {
			cout << "该道具数量不足!任意键返回\n";
			_getch();
			continue;
		}
		rpgData.base.items.hpPotion[t]--;
		if (heal >= 9999) rpgData.base.hp = rpgData.base.maxhp;
		else rpgData.base.hp = min(rpgData.base.hp + heal, rpgData.base.maxhp);
		cout << "使用成功!当前HP:" << rpgData.base.hp << "\n任意键继续\n";
		_getch();
		return true;
	}
}
bool UseMpPotion() {
	while (true) {
		system("cls");
		cout << "==== 使用魔力瓶 ====\n";
		cout << "1.【小】 x" << rpgData.base.items.mpPotion[ITEM_SMALL] << "\n";
		cout << "2.【中】 x" << rpgData.base.items.mpPotion[ITEM_MID] << "\n";
		cout << "3.【大】 x" << rpgData.base.items.mpPotion[ITEM_BIG] << "\n";
		cout << "4.【神】 x" << rpgData.base.items.mpPotion[ITEM_GOD] << "\n";
		cout << "0. 返回道具面板\n";
		char op = _getch();
		if (op == '0') return false;
		ItemTier t;
		int restore = 0;
		if (op == '1') { t = ITEM_SMALL; restore = 10; }
		else if (op == '2') { t = ITEM_MID; restore = 25; }
		else if (op == '3') { t = ITEM_BIG; restore = 50; }
		else if (op == '4') { t = ITEM_GOD; restore = 9999; }
		else continue;
		if (rpgData.base.items.mpPotion[t] <= 0) {
			cout << "该道具数量不足!任意键返回\n";
			_getch();
			continue;
		}
		rpgData.base.items.mpPotion[t]--;
		if (restore >= 9999) rpgData.base.mp = rpgData.base.maxmp;
		else rpgData.base.mp = min(rpgData.base.mp + restore, rpgData.base.maxmp);
		cout << "使用成功!当前MP:" << rpgData.base.mp << "\n任意键继续\n";
		_getch();
		return true;
	}
}
void OpenItemUsePanel() {
	while (true) {
		system("cls");
		PrintItemBag();
		cout << "1. 使用血瓶\n";
		cout << "2. 使用魔力瓶\n";
		cout << "0. 跳过道具使用,继续回合\n";
		char op = _getch();
		if (op == '0') break;
		if (op == '1') UseHpPotion();
		if (op == '2') UseMpPotion();
	}
}
void DropMonsterItem(int eliteLv) {
	if (eliteLv == 1) {
		if (rand() % 100 < 5) {
			int type = rand() % 2;
			ItemTier t = ItemTier(rand() % 4);
			if (type == 0) rpgData.base.items.hpPotion[t]++;
			else rpgData.base.items.mpPotion[t]++;
			cout << "精英怪掉落道具1件!\n";
		}
		return;
	}
	if (eliteLv == 2) {
		if (rand() % 100 < 5) {
			int type = rand() % 2;
			ItemTier t = ItemTier(rand() % 4);
			if (type == 0) rpgData.base.items.hpPotion[t]++;
			else rpgData.base.items.mpPotion[t]++;
			cout << "领主怪掉落消耗道具1件!\n";
		}
		if (rand() % 100 == 0) {
			rpgData.base.items.knife++;
			rpgData.base.atk += 15;
			cout << "稀有掉落【小刀】!永久攻击+15\n";
		}
		return;
	}
	if (eliteLv == 3) {
		int dropCnt = 1;
		int r = rand() % 100;
		if (r >= 80) dropCnt = rand() % 3 + 1;
		cout << "BOSS掉落" << dropCnt << "件道具!\n";
		for (int i = 0; i < dropCnt; i++) {
			int type = rand() % 2;
			ItemTier t = ItemTier(rand() % 4);
			if (type == 0) rpgData.base.items.hpPotion[t]++;
			else rpgData.base.items.mpPotion[t]++;
		}
		return;
	}
}
// ===================== 商店、抽卡(v1.2.4优化抽卡提示) =====================
void DrawNormalSkill() {
	system("cls");
	cout << "抽普通技能 消耗30金币,20%空\n金币:" << rpgData.base.gold << "\n";
	if (rpgData.base.gold < 30) {
		cout << "金币不足,按任意键返回";
		_getch(); return;
	}
	rpgData.base.gold -= 30;
	if (rand() % 100 < 20) {
		cout << "本次抽空,无技能";
		_getch(); return;
	}
	Skill sk;
	sk.id = rand() % 22 + 1;
	int r = rand() % 100;
	if (r < 50) sk.quality = WHITE;
	else if (r < 80) sk.quality = GREEN;
	else if (r < 95) sk.quality = BLUE;
	else sk.quality = PURPLE;
	bool hasSame = false;
	for (int i = 0; i < rpgData.base.skillCnt; i++) {
		if (rpgData.base.skills[i].id == sk.id) {
			hasSame = true;
			Skill& old = rpgData.base.skills[i];
			if (sk.quality > old.quality) {
				cout << "品质提升:【" << GetQualityStr(old.quality) << "】" << GetSkillName(old.id);
				old.quality = sk.quality;
				cout << " → 【" << GetQualityStr(old.quality) << "】" << GetSkillName(old.id) << "\n";
			} else if (sk.quality == old.quality && sk.quality < PURPLE) {
				cout << "同品质进阶:【" << GetQualityStr(old.quality) << "】" << GetSkillName(old.id);
				old.quality++;
				cout << " → 【" << GetQualityStr(old.quality) << "】" << GetSkillName(old.id) << "\n";
			} else {
				cout << "已有更高/同等品质的【" << GetSkillName(old.id) << "】,无变化\n";
			}
			break;
		}
	}
	if (!hasSame) {
		if (rpgData.base.skillCnt < 20) {
			rpgData.base.skills[rpgData.base.skillCnt++] = sk;
			cout << "获得新技能:【" << GetQualityStr(sk.quality) << "】" << GetSkillName(sk.id) << "\n";
		} else {
			cout << "技能栏已满,无法获取【" << GetSkillName(sk.id) << "】\n";
		}
	}
	_getch();
}
void BuyGodSkill() {
	system("cls");
	cout << "宝石商店抽取神技,消耗5宝石,必出神技\n宝石:" << rpgData.base.gem << "\n";
	if (rpgData.base.gem < 5) {
		cout << "宝石不足";
		_getch(); return;
	}
	rpgData.base.gem -= 5;
	int newGodId = rand() % 22 + 1;
	for (int i = 0; i < rpgData.base.skillCnt; i++) {
		if (rpgData.base.skills[i].id == newGodId) {
			for (int j = i; j < rpgData.base.skillCnt - 1; j++)
				rpgData.base.skills[j] = rpgData.base.skills[j + 1];
			rpgData.base.skillCnt--;
			break;
		}
	}
	bool exist = false;
	for (int x : rpgData.godSkillList)
		if (x == newGodId) exist = true;
	if (!exist) rpgData.godSkillList.push_back(newGodId);
	cout << "获得神技:" << GetSkillName(newGodId) << "\n";
	_getch();
}
void BuyShopItem() {
	pair<int, int> price = GetItemPrice(shopSellType, shopSellTier);
	int costGold = price.first;
	int costGem = price.second;
	if (rpgData.base.gold < costGold || rpgData.base.gem < costGem) {
		cout << "资源不足,无法购买!\n";
		_getch();
		return;
	}
	rpgData.base.gold -= costGold;
	rpgData.base.gem -= costGem;
	if (shopSellType == 0) rpgData.base.items.hpPotion[shopSellTier]++;
	else rpgData.base.items.mpPotion[shopSellTier]++;
	cout << "购买成功!道具已存入仓库\n";
	RefreshShopItem();
	_getch();
}
void Shop() {
	RefreshShopItem();
	while (true) {
		system("cls");
		cout << "==== CWR v1.2.6 商店 ====\n";
		cout << "金币:" << rpgData.base.gold << " 宝石:" << rpgData.base.gem << "\n";
		cout << "1. 抽普通技能 30金\n";
		cout << "2. 永久血量上限+20 50金\n";
		cout << "3. 永久攻击力+5 80金\n";
		cout << "4. 永久防御力+3 80金\n";
		cout << "5. 永久魔力上限+15 60金\n";
		cout << "6. 抽取随机神技 5宝石\n";
		pair<int, int> p = GetItemPrice(shopSellType, shopSellTier);
		string itemName = (shopSellType == 0) ? "血瓶" : "魔力瓶";
		cout << "7. 购买【" << GetItemTierName(shopSellTier) << "】" << itemName;
		if (p.first > 0) cout << " " << p.first << "金";
		if (p.second > 0) cout << " " << p.second << "宝石";
		cout << "\n";
		cout << "8. 打开道具仓库\n";
		cout << "0. 离开商店\n";
		char op = _getch();
		if (op == '0') break;
		if (op == '1') DrawNormalSkill();
		if (op == '2') {
			if (rpgData.base.gold < 50) { cout << "金币不足"; _getch(); continue; }
			rpgData.base.gold -= 50;
			rpgData.base.maxhp += 20;
			rpgData.base.hp += 20;
			cout << "永久最大HP+20"; _getch();
		}
		if (op == '3') {
			if (rpgData.base.gold < 80) { cout << "金币不足"; _getch(); continue; }
			rpgData.base.gold -= 80;
			rpgData.base.atk += 5;
			cout << "永久攻击力+5"; _getch();
		}
		if (op == '4') {
			if (rpgData.base.gold < 80) { cout << "金币不足"; _getch(); continue; }
			rpgData.base.gold -= 80;
			rpgData.base.def += 3;
			cout << "永久防御力+3"; _getch();
		}
		if (op == '5') {
			if (rpgData.base.gold < 60) { cout << "金币不足"; _getch(); continue; }
			rpgData.base.gold -= 60;
			rpgData.base.maxmp += 15;
			rpgData.base.mp += 15;
			cout << "永久魔力上限+15"; _getch();
		}
		if (op == '6') BuyGodSkill();
		if (op == '7') BuyShopItem();
		if (op == '8') {
			system("cls");
			PrintItemBag();
			cout << "任意键返回商店\n";
			_getch();
		}
	}
}
void ShowSkillList() {
	int page = 0;
	while (true) {
		system("cls");
		cout << "=== 已持有普通技能 ===\n";
		int st = page * SKILL_PAGE_CNT;
		size_t ed = min((size_t)(st + SKILL_PAGE_CNT), (size_t)rpgData.base.skillCnt);
		for (int i = st; (size_t)i < ed; i++) {
			Skill s = rpgData.base.skills[i];
			int mp;
			if (s.id == SKILL_CALM) mp = GetCalmMpCost(s.quality);
			else mp = GetNormalMpCost(s);
			cout << i + 1 << "." << GetQualityStr(s.quality) << GetSkillName(s.id) << " MP:" << mp << "\n";
		}
		cout << "\n=== 神技列表 ===\n";
		for (int gid : rpgData.godSkillList) {
			cout << GetSkillName(gid) << " MP:" << GetGodMpCost(gid) << "\n";
		}
		cout << "\nA上页 D下页 0退出";
		char c = _getch();
		if (c == '0') break;
		if (c == 'a' && page > 0) page--;
		if (c == 'd' && ed < (size_t)rpgData.base.skillCnt) page++;
	}
}

// ===================== 战斗技能效果(全部补充伤害文字,解决看不到自身伤害) =====================
void CastSkillEffect(int sid, int q, int &pHP, int &mHP, int mMaxHp, bool &moneyLoverFlag) {
	double mul = GetQualityMul(q);
	double atkDmg = (rpgData.base.atk + buffAtk) * mul;
	switch (sid) {
	case SKILL_POWERUP:
		{
			buffAtk += static_cast<int>(10 * mul);
			cout << "狂怒增幅:临时攻击力提升\n";
		}break;
	case SKILL_SHIELD:
		{
			buffDef += static_cast<int>(8 * mul);
			cout << "钢铁壁垒:临时防御力提升\n";
		}break;
	case SKILL_LIFESTEAL:
		{
			double d = atkDmg * 1.2;
			int hit = max(static_cast<int>(d) - monster.def, 1);
			mHP -= hit;
			int heal = static_cast<int>(d * 0.4 * mul);
			pHP = min(pHP + heal, rpgData.base.maxhp);
			cout << "吸血打击!你造成" << hit << "伤害,回复" << heal << "生命值\n";
		}break;
	case SKILL_SWAPHP:
		{
			int tmp = pHP; pHP = mHP; mHP = tmp;
			int healAdd = static_cast<int>(80 * mul);
			pHP = min(pHP + healAdd, rpgData.base.maxhp);
			cout << "生命置换,互换双方血量,额外回复" << healAdd << "生命\n";
		}break;
	case SKILL_BLOODDRAIN:
		{
			int dot = static_cast<int>(rpgData.base.atk * 0.4 * mul);
			poisonDmg += dot;
			int hit = max(static_cast<int>(atkDmg) - monster.def, 1);
			mHP -= hit;
			cout << "鲜血汲取!造成" << hit << "伤害,附加每回合" << dot << "持续流血\n";
		}break;
	case SKILL_STUN:
		{
			int stunTurn = static_cast<int>(2 * mul);
			monster.monsterImprisonTurn += stunTurn;
			double raw = atkDmg * 1.5;
			int hit = max(static_cast<int>(raw) - monster.def, 1);
			mHP -= hit;
			cout << "眩晕重击!你造成" << hit << "伤害,怪物禁锢" << stunTurn << "回合\n";
		}break;
	case SKILL_CRIT:
		{
			int trueD = static_cast<int>(rpgData.base.atk * 1.8 * mul);
			mHP -= max(trueD, 1);
			cout << "致命穿刺!真实伤害" << trueD << ",无视防御\n";
		}break;
	case SKILL_POISON:
		{
			int dot = static_cast<int>(rpgData.base.atk * 0.25 * mul);
			poisonDmg += dot;
			int defCut = static_cast<int>(10 * mul);
			monster.def -= defCut;
			cout << "毒素腐蚀!附加每回合" << dot << "毒伤,怪物永久减防" << defCut << "\n";
		}break;
	case SKILL_REFLECT:
		{
			buffDef += static_cast<int>(15 * mul);
			double raw = atkDmg * 0.6;
			int hit = max(static_cast<int>(raw) - monster.def, 1);
			mHP -= hit;
			cout << "伤害反弹护盾!造成" << hit << "伤害,临时防御大幅提升\n";
		}break;
	case SKILL_RUSH:
		{
			double raw = atkDmg * 1.3;
			int hit = max(static_cast<int>(raw) - monster.def, 1);
			mHP -= hit;
			cout << "冲锋突刺!造成" << hit << "点伤害\n";
		}break;
	case SKILL_HEAL:
		{
			int h = static_cast<int>(rpgData.base.maxhp * 0.35 * mul);
			pHP = min(pHP + h, rpgData.base.maxhp);
			poisonDmg = 0;
			cout << "愈疗之光!清除所有持续伤害,回复" << h << "生命值\n";
		}break;
	case SKILL_WEAK:
		{
			int defCut = static_cast<int>(12 * mul);
			monster.def -= defCut;
			int hit = max(static_cast<int>(atkDmg) - monster.def, 1);
			mHP -= hit;
			cout << "破碎护甲!造成" << hit << "伤害,怪物永久减防" << defCut << "\n";
		}break;
	case SKILL_SILENCE:
		{
			int stunTurn = static_cast<int>(2 * mul);
			monster.monsterImprisonTurn += stunTurn;
			int hit = max(static_cast<int>(atkDmg) - monster.def, 1);
			mHP -= hit;
			cout << "灵魂禁锢!造成" << hit << "伤害,怪物禁锢" << stunTurn << "回合\n";
		}break;
	case SKILL_DOUBLEHIT:
		{
			double raw = atkDmg * 0.7;
			int hit1 = max(static_cast<int>(raw) - monster.def, 1);
			int hit2 = max(static_cast<int>(raw) - monster.def, 1);
			int total = hit1 + hit2;
			mHP -= total;
			cout << "连环斩击两段伤害,总计" << total << "点\n";
		}break;
	case SKILL_IMMUNE:
		{
			buffAtk += static_cast<int>(40 * mul);
			cout << "超负荷!临时攻击力大幅提升\n";
		}break;
	case SKILL_DRAINMP:
		{
			int stealMp = static_cast<int>(8 * mul);
			rpgData.base.mp = min(rpgData.base.mp + stealMp, rpgData.base.maxmp);
			double raw = atkDmg * 1.1;
			int hit = max(static_cast<int>(raw) - monster.def, 1);
			mHP -= hit;
			cout << "吸能打击!造成" << hit << "伤害,偷取" << stealMp << "魔力\n";
		}break;
	case SKILL_MEDITATE:
		{
			int hpHeal = static_cast<int>(rpgData.base.maxhp * 0.25 * mul);
			int mpHeal = static_cast<int>(20 * mul);
			pHP = min(pHP + hpHeal, rpgData.base.maxhp);
			rpgData.base.mp = min(rpgData.base.mp + mpHeal, rpgData.base.maxmp);
			cout << "静心冥想!回血" << hpHeal << "回蓝" << mpHeal << ",跳过怪物行动\n";
		}break;
	case SKILL_OVERLOAD:
		{
			double raw = atkDmg * 1.3;
			int hit = max(static_cast<int>(raw) - monster.def, 1);
			mHP -= hit;
			cout << "暗影潜行!造成" << hit << "点伤害\n";
		}break;
	case SKILL_STOPSHORT:
		{
			int phys = static_cast<int>(rpgData.base.atk * 1.2 * mul);
			int trueD = static_cast<int>(rpgData.base.atk * 0.05 * mul);
			int all = phys + trueD;
			int hit = min(all, mHP - 1);
			mHP -= hit;
			cout << "点到为止!造成" << hit << "伤害,强制保留怪物1点血量\n";
		}break;
	case SKILL_GOLDBURST:
		{
			cout << "输入消耗金币:";
			int cost; cin >> cost;
			if (cost <= 0 || rpgData.base.gold < cost) {
				cout << "金币不足,技能失效"; break;
			}
			rpgData.base.gold -= cost;
			long long hit = static_cast<long long>(cost) * 1.5 * rpgData.base.atk * mul;
			int realHit = static_cast<int>(hit);
			mHP -= realHit;
			cout << "豪掷千金!消耗" << cost << "金币,造成巨额" << realHit << "伤害\n";
		}break;
	case SKILL_MONEYLOVER:
		{
			mHP -= 1;
			moneyLoverFlag = true;
			cout << "拜金!1点真实伤害,击杀金币收益直接翻倍\n";
		}break;
	case SKILL_CALM:
		{
			playerImprisonTurn = 0;
			int heal = static_cast<int>(10 * mul);
			pHP = min(pHP + heal, rpgData.base.maxhp);
			cout << "静心咒!解除自身禁锢,回复" << heal << "生命值\n";
		}break;
	default:
		{
			int hit = max(static_cast<int>(atkDmg) - monster.def, 1);
			mHP -= hit;
			cout << "普通技能攻击,造成" << hit << "点伤害\n";
		}break;
	}
}
void SpawnMonster() {
	monster.msList.clear();
	monster.monsterImprisonTurn = poisonDmg = 0;
	playerImprisonTurn = 0;
	monster.revived = false;
	monsterImprisonRate = 1.0f;
	monster.maxhp = 20 + rpgData.base.stage * 12;
	monster.hp = monster.maxhp;
	monster.atk = 4 + rpgData.base.stage * 3;
	monster.def = 3 + rpgData.base.stage * 2;
	monster.eliteVal = 0;
	vector<int> used;
	bool addRevive = (rand() % 100 < 25);
	if (addRevive) {
		monster.msList.emplace_back(MSKILL_REVIVE, WHITE);
		monster.eliteVal += 5;
		used.push_back(MSKILL_REVIVE);
	}
	int cnt = rand() % 4;
	for (int i = 0; i < cnt; i++) {
		int sid;
		do {
			sid = rand() % 4 + 1;
		} while (find(used.begin(), used.end(), sid) != used.end());
		used.push_back(sid);
		int qr = rand() % 100;
		int q;
		if (qr < 60) { q = WHITE; monster.eliteVal += 1; }
		else if (qr < 85) { q = GREEN; monster.eliteVal += 2; }
		else if (qr < 97) { q = BLUE; monster.eliteVal += 3; }
		else { q = PURPLE; monster.eliteVal += 5; }
		monster.msList.emplace_back(sid, q);
	}
	// v1.2.6 随机先后手:1/3怪物先手,2/3玩家先手
	int roll = rand() % 3;
	if(roll == 0) playerFirst = false;
	else playerFirst = true;
}
// v1.2.6 封装怪物行动逻辑,复用代码
void MonsterAct(int &playerHp)
{
	bool skipMonster = false;
	if(monster.monsterImprisonTurn > 0)
	{
		cout << "\n怪物处于禁锢状态,跳过本次全部行动!剩余禁锢:" << monster.monsterImprisonTurn << "回合\n";
		monster.monsterImprisonTurn--;
		skipMonster = true;
	}
	if(!skipMonster)
	{
		bool useSkill = false;
		if (rand() % 100 < 40 && monster.msList.size() > 0) {
			auto ms = monster.msList[rand() % monster.msList.size()];
			if (ms.id == MSKILL_REVIVE) goto NormalAtk;
			useSkill = true;
			double mul = GetMonsterSkillMul(ms.quality);
			if (ms.id == MSKILL_IMPRISON_PLAYER) {
				int turn = static_cast<int>(2 * mul * monsterImprisonRate);
				playerImprisonTurn += turn;
				double rawDmg = monster.atk * 0.8 * mul;
				int dmg = max(static_cast<int>(rawDmg) - buffDef, 1);
				playerHp -= dmg;
				cout << "\n怪物释放禁锢缠绕!禁锢你" << turn << "回合,你受到" << dmg << "伤害\n";
			} else if (ms.id == MSKILL_POISON) {
				double rawDmg = monster.atk * 0.6 * mul;
				int dmg = max(static_cast<int>(rawDmg) - buffDef, 1);
				playerHp -= dmg;
				poisonDmg += static_cast<int>(monster.atk * 0.6 * mul);
				cout << "\n怪物撕裂流血!你受到" << dmg << "伤害,每回合持续扣血\n";
			} else if (ms.id == MSKILL_WEAK) {
				buffAtk -= static_cast<int>(4 * mul);
				buffDef -= static_cast<int>(4 * mul);
				double rawDmg = monster.atk * 0.9 * mul;
				int dmg = max(static_cast<int>(rawDmg) - buffDef, 1);
				playerHp -= dmg;
				cout << "\n怪物削弱攻防!你受到" << dmg << "伤害,临时攻防降低\n";
			} else if (ms.id == MSKILL_DOUBLEATK) {
				double rawDmg = monster.atk * 1.6 * mul;
				int dmg = max(static_cast<int>(rawDmg) - buffDef, 1);
				playerHp -= dmg;
				cout << "\n怪物狂暴重击!造成" << dmg << "点伤害\n";
			}
		}
		NormalAtk:
		if (!useSkill) {
			int dmgRaw = monster.atk - buffDef;
			int dmg = max(dmgRaw, 1);
			playerHp -= dmg;
			cout << "\n怪物普攻,你受到" << dmg << "点伤害\n";
		}
	}
	_getch();
}
void Battle() {
	SpawnMonster();
	int playerHp = rpgData.base.hp;
	buffAtk = buffDef = 0;
	bool over = false;
	bool moneyLoverKill = false;
	bool firstRound = true;
	
	while (!over) {
		system("cls");
		cout << "==== 战斗 第" << rpgData.base.stage << "层 ====\n";
		cout << "玩家 HP:" << playerHp << "/" << rpgData.base.maxhp << " MP:" << rpgData.base.mp << "/" << rpgData.base.maxmp << "\n";
		cout << "临时ATK+" << buffAtk << " DEF+" << buffDef << "\n";
		cout << "怪物 HP:" << monster.hp << "/" << monster.maxhp;
		if (monster.monsterImprisonTurn > 0) cout << " 怪物禁锢剩余" << monster.monsterImprisonTurn;
		if (playerImprisonTurn > 0) cout << " 你被禁锢" << playerImprisonTurn;
		cout << "\n精英值:" << monster.eliteVal;
		int eliteLv = 0;
		if (monster.eliteVal > 10) { cout << "【BOSS】"; eliteLv = 3; }
		else if (monster.eliteVal > 5) { cout << "【领主】"; eliteLv = 2; }
		else if (monster.eliteVal > 3) { cout << "【精英】"; eliteLv = 1; }
		cout << "\n怪物技能:";
		for (auto &ms : monster.msList)
			cout << GetMonsterSkillName(ms.id) << "(" << GetQualityStr(ms.quality) << ") ";
		cout << "\n1普攻 2释放技能 3逃跑\n";
		
		// 首回合单独判断先后手,仅第一回合生效
		if(firstRound)
		{
			firstRound = false;
			if(!playerFirst)
			{
				cout << "\n【首回合:怪物先手】\n";
				MonsterAct(playerHp);
				if(playerHp <= 0){ over = true; break; }
			}
			cout << "\n轮到你的行动回合\n";
		}
		
		// ========== 玩家行动阶段 ==========
		char op = _getch();
		bool skipTurn = false;
		if (op == '3') { cout << "逃跑无奖励"; _getch(); return; }
		if (playerImprisonTurn > 0) {
			bool hasCalm = false;
			int calmQ = WHITE;
			for (int i = 0; i < rpgData.base.skillCnt; i++) {
				if (rpgData.base.skills[i].id == SKILL_CALM) {
					hasCalm = true; calmQ = rpgData.base.skills[i].quality; break;
				}
			}
			int calmGodId = -1;
			for (int x : rpgData.godSkillList)
				if (x == SKILL_CALM) calmGodId = x;
			if (hasCalm || calmGodId != -1) {
				cout << "\n被禁锢!是否释放静心咒 1是 0否:";
				char c = _getch();
				if (c == '1') {
					if (calmGodId != -1) {
						int cost = GetGodMpCost(SKILL_CALM);
						if (rpgData.base.mp >= cost) {
							rpgData.base.mp -= cost;
							CastSkillEffect(SKILL_CALM, GOD_SKILL, playerHp, monster.hp, monster.maxhp, moneyLoverKill);
						} else cout << "MP不足\n";
					} else {
						int cost = GetCalmMpCost(calmQ);
						if (rpgData.base.mp >= cost) {
							rpgData.base.mp -= cost;
							CastSkillEffect(SKILL_CALM, calmQ, playerHp, monster.hp, monster.maxhp, moneyLoverKill);
						} else cout << "MP不足\n";
					}
					_getch();
				}
			}
			cout << "本回合无法行动,任意键跳过";
			_getch();
			playerImprisonTurn--;
		} else if (op == '1') {
			int rawDmg = (rpgData.base.atk + buffAtk) - monster.def;
			int d = max(rawDmg, 1);
			monster.hp -= d;
			cout << "你的普攻对怪物造成" << d << "点伤害\n";
		} else if (op == '2') {
			system("cls");
			cout << "=== 普通技能 ===\n";
			for (int i = 0; i < rpgData.base.skillCnt; i++) {
				Skill s = rpgData.base.skills[i];
				int mp = (s.id == SKILL_CALM) ? GetCalmMpCost(s.quality) : GetNormalMpCost(s);
				cout << i + 1 << "." << GetQualityStr(s.quality) << GetSkillName(s.id) << " MP:" << mp << "\n";
			}
			cout << "\n=== G=释放神技 ===\n";
			size_t godLen = rpgData.godSkillList.size();
			for (size_t i = 0; i < godLen; i++)
				cout << GetSkillName(rpgData.godSkillList[i]) << " MP:" << GetGodMpCost(rpgData.godSkillList[i]) << "\n";
			cout << "输入数字/G释放,0返回:";
			string s; cin >> s;
			if (s == "g" || s == "G") {
				cout << "输入神技序号:";
				int gi; cin >> gi; gi--;
				if ((size_t)gi < godLen) {
					int gid = rpgData.godSkillList[gi];
					int cost = GetGodMpCost(gid);
					if (rpgData.base.mp >= cost) {
						rpgData.base.mp -= cost;
						CastSkillEffect(gid, GOD_SKILL, playerHp, monster.hp, monster.maxhp, moneyLoverKill);
						if (gid == SKILL_MEDITATE) skipTurn = true;
					} else cout << "法力不足";
				} else cout << "序号错误";
			} else {
				int idx = stoi(s) - 1;
				if (idx >= 0 && (size_t)idx < (size_t)rpgData.base.skillCnt) {
					Skill sk = rpgData.base.skills[idx];
					int cost;
					if (sk.id == SKILL_CALM) cost = GetCalmMpCost(sk.quality);
					else cost = GetNormalMpCost(sk);
					if (rpgData.base.mp >= cost) {
						rpgData.base.mp -= cost;
						CastSkillEffect(sk.id, sk.quality, playerHp, monster.hp, monster.maxhp, moneyLoverKill);
						if (sk.id == SKILL_MEDITATE) skipTurn = true;
						if (sk.id == SKILL_MONEYLOVER) moneyLoverKill = true;
					} else cout << "法力不足";
				} else if (stoi(s) != 0) cout << "无此技能";
			}
			_getch();
		}
		OpenItemUsePanel();
		rpgData.base.mp = min(rpgData.base.mp + 5, rpgData.base.maxmp);
		if (poisonDmg > 0) {
			monster.hp -= poisonDmg;
			cout << "毒素对怪物持续造成" << poisonDmg << "点伤害\n";
		}
		// 怪物复活判定
		if (monster.hp <= 0 && !monster.revived) {
			for (auto &ms : monster.msList) {
				if (ms.id == MSKILL_REVIVE && !ms.reviveUsed) {
					ms.reviveUsed = true;
					monster.revived = true;
					monster.maxhp = static_cast<int>(monster.maxhp * 1.5);
					monster.hp = monster.maxhp;
					monster.atk = static_cast<int>(monster.atk * 1.5);
					monster.def = static_cast<int>(monster.def * 1.5);
					cout << "【卷土重来】怪物复活,全属性1.5倍\n";
					break;
				}
			}
			if (monster.hp > 0) {
				if (monster.monsterImprisonTurn > 0) {
					monsterImprisonRate -= 0.1f;
					if (monsterImprisonRate < 0.1f) monsterImprisonRate = 0.1f;
				}
				continue;
			}
		}
		if (monster.hp <= 0) { over = true; break; }
		if (skipTurn) {
			cout << "静心冥想跳过怪物行动回合\n";
			_getch();
			continue;
		}
		// 常规回合怪物行动
		MonsterAct(playerHp);
		if (playerHp <= 0) { over = true; break; }
	}
	// 战斗结算
	system("cls");
	if (playerHp <= 0) {
		cout << "战败!层数重置为1,血量回满\n";
		rpgData.base.stage = 1;
		rpgData.base.hp = rpgData.base.maxhp;
	} else {
		rpgData.base.stage++;
		cout << "胜利!成功通关第" << rpgData.base.stage - 1 << "层,进入下一层\n";
		double rate = 1.0;
		if (monster.revived) rate *= 2;
		if (moneyLoverKill) rate *= 2;
		int baseGold = 15 + rpgData.base.stage * 8;
		int getGold = static_cast<int>(baseGold * rate);
		int gemDrop = 0;
		int eliteLv = 0;
		if (monster.eliteVal > 10) { eliteLv = 3; gemDrop = rand() % 3 + 1; }
		else if (monster.eliteVal > 5) { eliteLv = 2; gemDrop = rand() % 2; }
		else if (monster.eliteVal > 3) { eliteLv = 1; if(rand()%100<10) gemDrop=1; }
		rpgData.base.gold += getGold;
		rpgData.base.gem += gemDrop;
		DropMonsterItem(eliteLv);
		cout << "获得金币:" << getGold << ",宝石:" << gemDrop << "\n倍率加成:" << rate;
		if (monster.revived) cout << "【卷土重来双倍】";
		if (moneyLoverKill) cout << "【拜金双倍】";
	}
	cout << "\n任意键返回主菜单";
	_getch();
}

void MainMenu() {
	while (true) {
		system("cls");
		cout << "==== CWR v1.2.6 主菜单 ====\n";
		cout << "1. 新建角色\n";
		cout << "2. 读取存档\n";
		cout << "0. 退出\n";
		char op = _getch();
		if (op == '0') exit(0);
		if (op == '1') {
			NewPlayer();
			cout << "输入角色名称:";
			cin >> rpgData.base.name;
			curSlot = -1;
			break;
		}
		if (op == '2') {
			cout << "输入存档槽位(1~10):";
			int s; cin >> s;
			if (s < 1 || s > 10) { cout << "槽位超出范围"; _getch(); continue; }
			if (!RpgSlotExist(s)) { cout << "该存档不存在"; _getch(); continue; }
			LoadSave(s);
			curSlot = s;
			break;
		}
	}
	while (true) {
		system("cls");
		cout << "角色:" << rpgData.base.name << "  当前层数:" << rpgData.base.stage << "\n";
		cout << "HP:" << rpgData.base.hp << "/" << rpgData.base.maxhp << " MP:" << rpgData.base.mp << "/" << rpgData.base.maxmp << "\n";
		int knifeTotalAtk = rpgData.base.items.knife * 15;
		cout << "攻击力:" << rpgData.base.atk << "(小刀永久加成+" << knifeTotalAtk << ") 防御力:" << rpgData.base.def << "\n";
		cout << "金币:" << rpgData.base.gold << " 宝石:" << rpgData.base.gem << "\n";
		cout << "1. 进入战斗\n";
		cout << "2. 商店\n";
		cout << "3. 查看技能列表\n";
		cout << "4. 保存存档\n";
		cout << "5. 打开道具仓库\n";
		cout << "0. 返回主菜单\n";
		char c = _getch();
		if (c == '0') break;
		if (c == '1') Battle();
		if (c == '2') Shop();
		if (c == '3') ShowSkillList();
		if (c == '4') {
			if (curSlot == -1) {
				cout << "请输入存档槽位1~10用于保存:";
				cin >> curSlot;
			}
			SaveSave(curSlot);
			cout << "存档保存完成"; _getch();
		}
		if (c == '5') {
			system("cls");
			PrintItemBag();
			cout << "任意键返回";
			_getch();
		}
	}
}

int main() {
	srand((unsigned)time(nullptr));
	while (true) MainMenu();
	return 0;
}
原文